diff --git a/packages/@ama-sdk/create/README.md b/packages/@ama-sdk/create/README.md index b5b72383b6..d1bb466cfd 100644 --- a/packages/@ama-sdk/create/README.md +++ b/packages/@ama-sdk/create/README.md @@ -37,7 +37,8 @@ npm create @ama-sdk typescript -- --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). diff --git a/packages/@ama-sdk/create/src/index.ts b/packages/@ama-sdk/create/src/index.ts index 620f171afa..c31cae9cf3 100644 --- a/packages/@ama-sdk/create/src/index.ts +++ b/packages/@ama-sdk/create/src/index.ts @@ -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'); diff --git a/packages/@o3r/create/README.md b/packages/@o3r/create/README.md index 9f7388f382..1c97f93541 100644 --- a/packages/@o3r/create/README.md +++ b/packages/@o3r/create/README.md @@ -25,14 +25,17 @@ npm create @o3r -- [...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 -- --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 @@ -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). diff --git a/packages/@o3r/create/src/index.ts b/packages/@o3r/create/src/index.ts index f37f415a67..9eda96c293 100644 --- a/packages/@o3r/create/src/index.ts +++ b/packages/@o3r/create/src/index.ts @@ -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) {