Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of alias #276

Merged
merged 3 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Update webpack to v5. Refs STCLI-187.
* Avoid sabotaged `colors`. Refs STCLI-188.
* Deprecated `alias` command and updated user documention in favor of `workspace`. Refs STCLI-155.

## [2.4.0](https://github.com/folio-org/stripes-cli/tree/v2.4.0) (2021-09-24)

Expand Down
6 changes: 3 additions & 3 deletions doc/commands.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Stripes CLI Commands

Version 1.20.0
Version 2.5.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes!!


This following command documentation is generated from the CLI's own built-in help. Run any command with the `--help` option to view the latest help for your currently installed CLI. To regenerate this file, run `yarn docs`.

Expand Down Expand Up @@ -80,7 +80,7 @@ $ stripes app create "Hello World" --no-interactive

## `alias` command

Maintain global aliases that apply to all platforms and apps
Maintain global aliases that apply to all platforms and apps [deprecated: use workspace instead]

Usage:
```
Expand Down Expand Up @@ -224,7 +224,7 @@ Option | Description | Type | Notes
`--okapi` | Specify an Okapi URL | string |
`--output` | Directory to place build output. If omitted, default value of "./output" is used. | string |
`--publicPath` | Specify the Webpack publicPath output option | string |
`--skipStripesBuild` | Bypass Stripes-specific steps in build (useful when building third-party Webpack DLLs). | boolean |
`--skipStripesBuild` | Bypass Stripes-specific steps in build (useful when building third-party Webpack DLLs). | boolean | default: false
`--sourcemap` | Include sourcemaps in build output | boolean |
`--stripesConfig` | Stripes config JSON | string | supports stdin
`--tenant` | Specify a tenant ID | string |
Expand Down
23 changes: 4 additions & 19 deletions doc/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,13 @@ ERROR in multi webpack-hot-middleware/client typeface-source-sans-pro @folio/str
Module not found: Error: Can't resolve 'babel-loader' in 'C:\Users\mattjones\projects\folio\ui-users'
```

The interim solution is to include `stripes-core` locally in your platform's dependencies, or in the case of an app, create an alias to clone of stripes-core.
The interim solution is to include `stripes-core` locally in your platform's dependencies, or in the case of an app, create a workspace which includes stripes-core.

Install stripes-core:
Create workspace with stripes-core:
```
$ git clone https://github.com/folio-org/stripes-core.git
$ cd stripes-core
$ yarn install
```

Create an alias:
```
$ stripes alias add @folio/stripes-core ..path/to/stripes-core
```

Alternatively, update your `.stripesclirc` configuration:
```
{
"aliases": {
"@folio/stripes-core": "..path/to/stripes-core"
}
}
$ stripes workspace
```
From interactive menu, select stripes-core along with any other modules you plan to modify.

## Global install not detected

Expand Down
55 changes: 27 additions & 28 deletions doc/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Note: When serving or building an existing app module that has dependencies on u
* [Background](#background)
* [CLI Context](#cli-context)
* [Platforms](#platforms)
* [Aliases](#aliases)
* [Workspaces](#workspaces)
* [Development prerequisites](#development-prerequisites)
* [App development](#app-development)
* [Creating your app](#creating-your-app)
Expand Down Expand Up @@ -152,15 +152,6 @@ Any supported command-line positional or option can be defined. For example:
}
```

In addition to command-line options, aliases for Stripes UI modules are also supported. Aliases paths should be relative to the directory containing the `.stripesclirc` config file which defines the aliases.
```json
{
"aliases": {
"@folio/users": "../ui-users"
}
}
```

### Module export
In addition to JSON, the CLI configuration may be authored as a JavaScript module export. This is useful for generating options dynamically or defining [CLI plugins](./dev-guide.md#plugins). When defining a JavaScript module export, be sure to use the `.js` file extension.

Expand Down Expand Up @@ -216,17 +207,17 @@ Tip: Use the `status` command (optionally with a file and/or other config option



### Aliases
### Workspaces

Aliases are used to associate platform modules with local code repositories in a development environment. An alias is comprised of a key-value pair where the key is a module (`@folio/users`) and the value is the relative path to where the module can be found (`../ui-users`). Aliases are not limited to `@folio` scope modules. At build time, any defined aliases will be applied to the Webpack configuration as Webpack aliases.
Workspaces are used to associate platform modules with local code repositories in a development environment. Workspaces are not limited to `@folio` scope modules. At build time, any defined modules will be linked by `yarn`.

The initial goals of defining aliases was to facilitate serving an app in isolation, as well as eliminate the need for Yarn-linking modules for platform development. The latter can be mitigated by using Yarn workspaces for the platform developer, however, aliases can still provide some advantages. Aliases are easily added ad-hoc for debugging or testing. They can work with modules outside the workspace, or used to share across workspaces.
There are two methods of adding workspaces in the CLI:

There are two methods of adding aliases in the CLI:
1) `workspace` command - This command will checkout from github any requested components into a workspace. See the [`workspace` command](./commands.md#workspace-command) for more detail.

1) `alias` command - This command manages aliases in a global collection. Aliases defined with the `alias` command will be available for all commands, regardless of where they are run, until the alias is removed. This command is useful for adding aliases ad-hoc and sharing an alias across multiple apps, platforms, or workspaces. See the [`alias` command](./commands.md#alias-command) for more detail.
2) Top-level `package.json` file - This file is auto-generated by the `workspace` command, but it can be created manually as well and `yarn` will respect it when calling `yarn install`. See [yarn workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/) for more information.

1) `.stripesclirc` file - Any aliases defined in a CLI configuration file apply to commands run from the directory containing `.stripesclirc` file. Use the configuration file when adding aliases in bulk or looking for a consistent set of alias. See the [CLI configuration](#configuration) for more information.
Note that in order for local code repositories to be used for a reference made in another module or platform `package.json` file, the local code repository version must fall in the requested version range. Otherwise, `yarn` will fetch from the remote repository instead.

Comment on lines +220 to 221
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an especially helpful note. Thanks for adding it!

## Development prerequisites

Expand Down Expand Up @@ -357,34 +348,42 @@ $ stripes serve --hasAllPerms

Now that our Hello World app is up and running on its own, we may want to bring in an existing app for testing or further development. The CLI makes this easy. The following will demonstrate how to add `ui-users`.

From the directory above `ui-hello-world`, clone `ui-users` and install its dependencies.
Create a new directory adjacent to `ui-hello-world`, call `stripes workspace` and select `ui-users` from the list.
```
$ git clone https://github.com/folio-org/ui-users.git
$ cd ui-users
$ yarn install
$ mkdir workspace-hello-world
$ stripes workspace
```

Now, move `ui-hello-world` into your new workspace
```
$ mv ../ui-hello-world .
```

or on Windows:
```
$ move ..\ui-hello-world .
```

We should now have the following directory structure:
```
myDir
├─ui-hello-world
└─ui-users
workspace-hello-world
└─stripes
├─ui-hello-world
└─ui-users
```

Next add an alias for ui-users. Provide a relative path to the ui-users directory. Given you're in /ui-hello-world:
Next from the `stripes` directory, run:
```
$ stripes alias add @folio/users ../ui-users
$ yarn install
```

Now simply start the app up again. From the ui-hello-world directory, run:
This will ensure proper linking of dependencies. Now simply start the app up again. From the `ui-hello-world` directory, run:
```
$ stripes serve
```

The FOLIO platform generated will now include ui-users! The same procedure can be followed to include non-app modules as well such as `stripes-components` and `stripes-core`.

Note: When adding an alias via the `alias add` command, the alias is considered global and will remain in effect for any command, run from any directory, until removed with `alias remove`.


## Platform development

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function aliasCommand(argv) {

module.exports = {
command: 'alias <sub> [mod] [path]',
describe: 'Maintain global aliases that apply to all platforms and apps',
describe: 'Maintain global aliases that apply to all platforms and apps [deprecated: use workspace instead]',
builder: (yargs) => {
yargs.positional('sub', {
describe: 'Alias operation',
Expand Down