@o3r/create 10.0.0-prerelease.1 → 10.0.0-prerelease.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +9 -3
  2. package/index.js +26 -12
  3. package/package.json +30 -20
package/README.md CHANGED
@@ -9,14 +9,20 @@ This package is simplifying the start of an [Otter Framework](https://github.com
9
9
 
10
10
  ## Usage
11
11
 
12
- ### NPM
13
-
14
12
  ```shell
15
13
  npm create @o3r <project-name> -- [...options]
16
14
  ```
17
15
 
18
- ### Yarn
16
+ or
19
17
 
20
18
  ```shell
21
19
  yarn create @o3r <project-name> [...options]
22
20
  ```
21
+
22
+ > **Warning** : Please notice that the command `yarn create` is **not** available for versions *>= 2.0.0* (see [Yarn cli commands](https://yarnpkg.com/cli)).
23
+
24
+ You can generate an environment with a specific package manager thanks to the `--package-manager` options:
25
+
26
+ ```shell
27
+ npm create @o3r <project-name> -- --package-manager=yarn [...options]
28
+ ```
package/index.js CHANGED
@@ -6,7 +6,7 @@ const node_path_1 = require("node:path");
6
6
  const node_fs_1 = require("node:fs");
7
7
  const minimist = require("minimist");
8
8
  const { properties } = JSON.parse((0, node_fs_1.readFileSync)(require.resolve('@schematics/angular/ng-new/schema').replace(/\.js$/, '.json'), { encoding: 'utf-8' }));
9
- const { version } = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.resolve)(__dirname, 'package.json'), { encoding: 'utf-8' }));
9
+ const { version, dependencies, devDependencies } = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.resolve)(__dirname, 'package.json'), { encoding: 'utf-8' }));
10
10
  const logo = `
11
11
 
12
12
  &BPPPB & &BPGB&
@@ -77,15 +77,14 @@ if (!args.some((a) => a.startsWith('--style'))) {
77
77
  if (!args.some((a) => a.startsWith('--preset'))) {
78
78
  args.push('--preset', 'basic');
79
79
  }
80
- const hasPackageManagerArg = args.some((a) => a.startsWith('--package-manager'));
81
- if (!hasPackageManagerArg) {
82
- const packageManager = process.env.npm_config_user_agent?.split('/')[0];
83
- if (packageManager && ['npm', 'pnpm', 'yarn', 'cnpm'].includes(packageManager)) {
84
- args.push('--package-manager', packageManager);
85
- }
86
- }
87
80
  args.push('--no-create-application');
88
81
  const argv = minimist(args);
82
+ const packageManagerEnv = process.env.npm_config_user_agent?.split('/')[0];
83
+ let defaultPackageManager = 'npm';
84
+ if (packageManagerEnv && ['npm', 'yarn'].includes(packageManagerEnv)) {
85
+ defaultPackageManager = packageManagerEnv;
86
+ }
87
+ const packageManager = argv['package-manager'] || defaultPackageManager;
89
88
  if (argv._.length === 0) {
90
89
  // eslint-disable-next-line no-console
91
90
  console.error('The project name is mandatory');
@@ -116,7 +115,7 @@ const createNgProject = () => {
116
115
  const options = schematicsCliOptions
117
116
  .filter(([key]) => isNgNewOptions(key))
118
117
  .flat();
119
- const { error } = (0, node_child_process_1.spawnSync)(process.execPath, [binPath, 'new', ...argv._, ...options, '--skip-install'], {
118
+ const { error } = (0, node_child_process_1.spawnSync)(process.execPath, [binPath, 'new', ...argv._, ...options], {
120
119
  stdio: 'inherit'
121
120
  });
122
121
  if (error) {
@@ -125,11 +124,26 @@ const createNgProject = () => {
125
124
  process.exit(1);
126
125
  }
127
126
  };
128
- const addOtterFramework = (relativeDirectory = '.') => {
127
+ const addOtterFramework = (relativeDirectory = '.', projectPackageManager = 'npm') => {
128
+ const mandatoryDependencies = [
129
+ '@angular-devkit/schematics',
130
+ '@schematics/angular',
131
+ '@angular-devkit/core',
132
+ '@angular-devkit/architect'
133
+ ];
129
134
  const cwd = (0, node_path_1.resolve)(process.cwd(), relativeDirectory);
130
135
  const options = schematicsCliOptions
131
136
  .flat();
132
- const { error } = (0, node_child_process_1.spawnSync)(process.execPath, [binPath, 'add', `@o3r/core@${version || 'latest'}`, ...options], {
137
+ const packageJsonPath = (0, node_path_1.resolve)(cwd, 'package.json');
138
+ const packageJson = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, { encoding: 'utf-8' })
139
+ // Replace the ^ with ~ to use the same minor version for angular packages as @angular/cli
140
+ .replace(/(@(?:angular|schematics).*)\^/g, '$1~'));
141
+ packageJson.devDependencies ||= {};
142
+ mandatoryDependencies.forEach((dep) => {
143
+ packageJson.devDependencies[dep] = dependencies?.[dep] || devDependencies?.[dep] || 'latest';
144
+ });
145
+ (0, node_fs_1.writeFileSync)(packageJsonPath, JSON.stringify(packageJson, null, 2));
146
+ const { error } = (0, node_child_process_1.spawnSync)(process.platform === 'win32' ? `${projectPackageManager}.cmd` : projectPackageManager, ['exec', 'ng', 'add', `@o3r/core@~${version}`, ...(projectPackageManager === 'npm' ? ['--'] : []), ...options], {
133
147
  stdio: 'inherit',
134
148
  cwd
135
149
  });
@@ -142,4 +156,4 @@ const addOtterFramework = (relativeDirectory = '.') => {
142
156
  const projectFolder = argv._[0]?.replaceAll(' ', '-').toLowerCase() || '.';
143
157
  console.info(logo);
144
158
  createNgProject();
145
- addOtterFramework(projectFolder);
159
+ addOtterFramework(projectFolder, packageManager);
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@o3r/create",
3
- "version": "10.0.0-prerelease.1",
3
+ "version": "10.0.0-prerelease.100",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "Create a new Otter based application",
5
8
  "keywords": [
6
9
  "create",
@@ -15,46 +18,53 @@
15
18
  "prepare:publish": "prepare-publish ./dist"
16
19
  },
17
20
  "dependencies": {
18
- "@angular/cli": "~17.0.3",
19
- "@schematics/angular": "~17.0.3",
21
+ "@angular/cli": "~17.2.0",
22
+ "@schematics/angular": "~17.2.0",
20
23
  "minimist": "^1.2.6",
21
- "tslib": "^2.5.3"
24
+ "tslib": "^2.5.3",
25
+ "type-fest": "^4.10.2"
22
26
  },
23
27
  "devDependencies": {
28
+ "@angular-devkit/architect": "~0.1702.0",
29
+ "@angular-devkit/core": "~17.2.0",
30
+ "@angular-devkit/schematics": "~17.2.0",
24
31
  "@angular-eslint/eslint-plugin": "~17.2.0",
25
32
  "@angular-eslint/eslint-plugin-template": "~17.2.0",
26
- "@nx/eslint": "~17.2.0",
27
- "@nx/eslint-plugin": "~17.2.0",
28
- "@nx/jest": "~17.2.0",
29
- "@nx/js": "~17.2.0",
30
- "@o3r/build-helpers": "^10.0.0-prerelease.1",
31
- "@o3r/eslint-config-otter": "^10.0.0-prerelease.1",
32
- "@o3r/eslint-plugin": "^10.0.0-prerelease.1",
33
- "@o3r/test-helpers": "^10.0.0-prerelease.1",
33
+ "@nx/eslint": "~18.0.2",
34
+ "@nx/eslint-plugin": "~18.0.2",
35
+ "@nx/jest": "~18.0.2",
36
+ "@nx/js": "~18.0.2",
37
+ "@o3r/build-helpers": "^10.0.0-prerelease.100",
38
+ "@o3r/eslint-config-otter": "^10.0.0-prerelease.100",
39
+ "@o3r/eslint-plugin": "^10.0.0-prerelease.100",
40
+ "@o3r/test-helpers": "^10.0.0-prerelease.100",
41
+ "@stylistic/eslint-plugin-ts": "^1.5.4",
34
42
  "@types/jest": "~29.5.2",
35
43
  "@types/minimist": "^1.2.2",
36
44
  "@types/node": "^20.0.0",
37
- "@typescript-eslint/eslint-plugin": "^6.19.0",
38
- "@typescript-eslint/parser": "^6.11.0",
45
+ "@typescript-eslint/eslint-plugin": "^7.0.1",
46
+ "@typescript-eslint/parser": "^7.0.1",
39
47
  "cpy-cli": "^5.0.0",
40
48
  "eslint": "^8.42.0",
41
49
  "eslint-import-resolver-node": "^0.3.4",
42
- "eslint-plugin-jest": "~27.6.0",
43
- "eslint-plugin-jsdoc": "~48.0.0",
50
+ "eslint-plugin-jest": "~27.9.0",
51
+ "eslint-plugin-jsdoc": "~48.1.0",
44
52
  "eslint-plugin-prefer-arrow": "~1.2.3",
45
- "eslint-plugin-unicorn": "^50.0.0",
53
+ "eslint-plugin-unicorn": "^51.0.0",
46
54
  "jest": "~29.7.0",
47
55
  "jest-junit": "~16.0.0",
48
56
  "jsonc-eslint-parser": "~2.4.0",
49
- "nx": "~17.2.0",
57
+ "nx": "~18.0.2",
50
58
  "rimraf": "^5.0.1",
51
59
  "rxjs": "^7.8.1",
52
60
  "ts-jest": "~29.1.1",
53
- "type-fest": "^4.3.1",
61
+ "type-fest": "^4.10.2",
54
62
  "typescript": "~5.2.2"
55
63
  },
56
64
  "engines": {
57
- "node": ">=18.0.0"
65
+ "node": ">=18.0.0",
66
+ "yarn": "<2.0.0",
67
+ "npm": "*"
58
68
  },
59
69
  "contributors": [
60
70
  {