Skip to content

Commit

Permalink
feat: add --yarn option to create scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kpanot committed Nov 20, 2024
1 parent 0042a21 commit d87065a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/@ama-sdk/create/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ npm create @ama-sdk typescript <project-name> -- --package-manager=yarn [...opti

## Options list

- `--package-manager`: Node package manager to be used (`npm` and `yarn` are available).
- `--package-manager`: Node package manager to be used (`npm` and `yarn` are available). If not specified, the automatically detected one will be used.
- `--yarn`: Enforce `yarn` package manager. This option will be ignored if `--package-manager` is already specified.
- `--debug --no-dry-run`: Enable schematics debug mode (dry-run is not currently supported).
- `--o3r-metrics`: Enable or disable the collection of anonymous data for Otter
- `--exact-o3r-version` : use a pinned version for [otter packages](https://github.com/AmadeusITGroup/otter/blob/main/docs/README.md).
Expand Down
2 changes: 1 addition & 1 deletion packages/@ama-sdk/create/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (packageManagerEnv && ['npm', 'yarn'].includes(packageManagerEnv)) {
defaultPackageManager = packageManagerEnv;
}

const packageManager: string = argv['package-manager'] || defaultPackageManager;
const packageManager: string = argv['package-manager'] || (argv.yarn && 'yarn') || defaultPackageManager;

if (argv._.length < 2) {
console.error('The SDK type and project name are mandatory');
Expand Down
8 changes: 6 additions & 2 deletions packages/@o3r/create/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ npm create @o3r <project-name> -- [...options]
### Custom package manager

You can generate an environment with a specific package manager thanks to the `--package-manager` options:
By default, the `npm` package manager will be used to generate the project, but you can generate an environment with a specific package manager using the `--package-manager` option:

```shell
npm create @o3r <project-name> -- --package-manager=yarn [...options]
```

> [!TIP]
> The option `--package-manager=yarn` can be simplified to `--yarn`.
> [!NOTE]
> At the moment, the ``package-manager`` option only supports `yarn` and `npm`.
> At the moment, the `package-manager` option only supports `yarn` and `npm`.
### Custom registry

Expand All @@ -50,5 +53,6 @@ If the specified package manager is `yarn`, it will also configure the `.yarnrc.
The generator accepts all the configurations from the Angular `ng new` command, see the [options list](https://angular.io/cli/new#options).
On top of them, the following options can be provided to the initializer:

- `--yarn`: Enforce `yarn` package manager. This option will be ignored if `--package-manager` is already specified.
- `--yarn-version`: specify the version of yarn to use (default: `latest`)
- `--exact-o3r-version`: use a pinned version for [Otter packages](https://github.com/AmadeusITGroup/otter/blob/main/docs/README.md).
4 changes: 2 additions & 2 deletions packages/@o3r/create/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ let defaultPackageManager = supportedPackageManager[0];
if (packageManagerEnv && supportedPackageManager.includes(packageManagerEnv)) {
defaultPackageManager = packageManagerEnv;
}
const argvPackageManager = argv['package-manager'];
let packageManager = supportedPackageManagerRegExp.test(argvPackageManager) ? argv['package-manager'] : defaultPackageManager;
const argvPackageManager = argv['package-manager'] || (argv.yarn && 'yarn');
let packageManager = supportedPackageManagerRegExp.test(argvPackageManager) ? argvPackageManager : defaultPackageManager;
if (argvPackageManager && supportedPackageManagerRegExp.test(argvPackageManager)) {
packageManager = argvPackageManager;
} else if (argvPackageManager) {
Expand Down

0 comments on commit d87065a

Please sign in to comment.