@o3r/create 10.0.0-prerelease.4 → 10.0.0-prerelease.41
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.
- package/README.md +9 -3
- package/index.js +24 -12
- package/package.json +11 -6
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
|
-
|
|
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
|
|
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,24 @@ 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
|
|
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
|
+
packageJson.devDependencies ||= {};
|
|
140
|
+
mandatoryDependencies.forEach((dep) => {
|
|
141
|
+
packageJson.devDependencies[dep] = dependencies?.[dep] || devDependencies?.[dep] || 'latest';
|
|
142
|
+
});
|
|
143
|
+
(0, node_fs_1.writeFileSync)(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
144
|
+
const { error } = (0, node_child_process_1.spawnSync)(process.platform === 'win32' ? `${projectPackageManager}.cmd` : projectPackageManager, ['exec', 'ng', 'add', `@o3r/core@~${version}`, ...(projectPackageManager === 'npm' ? ['--'] : []), ...options], {
|
|
133
145
|
stdio: 'inherit',
|
|
134
146
|
cwd
|
|
135
147
|
});
|
|
@@ -142,4 +154,4 @@ const addOtterFramework = (relativeDirectory = '.') => {
|
|
|
142
154
|
const projectFolder = argv._[0]?.replaceAll(' ', '-').toLowerCase() || '.';
|
|
143
155
|
console.info(logo);
|
|
144
156
|
createNgProject();
|
|
145
|
-
addOtterFramework(projectFolder);
|
|
157
|
+
addOtterFramework(projectFolder, packageManager);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/create",
|
|
3
|
-
"version": "10.0.0-prerelease.
|
|
3
|
+
"version": "10.0.0-prerelease.41",
|
|
4
4
|
"description": "Create a new Otter based application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"create",
|
|
@@ -21,16 +21,19 @@
|
|
|
21
21
|
"tslib": "^2.5.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"@angular-devkit/architect": "~0.1700.3",
|
|
25
|
+
"@angular-devkit/core": "~17.0.3",
|
|
26
|
+
"@angular-devkit/schematics": "~17.0.3",
|
|
24
27
|
"@angular-eslint/eslint-plugin": "~17.2.0",
|
|
25
28
|
"@angular-eslint/eslint-plugin-template": "~17.2.0",
|
|
26
29
|
"@nx/eslint": "~17.2.0",
|
|
27
30
|
"@nx/eslint-plugin": "~17.2.0",
|
|
28
31
|
"@nx/jest": "~17.2.0",
|
|
29
32
|
"@nx/js": "~17.2.0",
|
|
30
|
-
"@o3r/build-helpers": "^10.0.0-prerelease.
|
|
31
|
-
"@o3r/eslint-config-otter": "^10.0.0-prerelease.
|
|
32
|
-
"@o3r/eslint-plugin": "^10.0.0-prerelease.
|
|
33
|
-
"@o3r/test-helpers": "^10.0.0-prerelease.
|
|
33
|
+
"@o3r/build-helpers": "^10.0.0-prerelease.41",
|
|
34
|
+
"@o3r/eslint-config-otter": "^10.0.0-prerelease.41",
|
|
35
|
+
"@o3r/eslint-plugin": "^10.0.0-prerelease.41",
|
|
36
|
+
"@o3r/test-helpers": "^10.0.0-prerelease.41",
|
|
34
37
|
"@types/jest": "~29.5.2",
|
|
35
38
|
"@types/minimist": "^1.2.2",
|
|
36
39
|
"@types/node": "^20.0.0",
|
|
@@ -54,7 +57,9 @@
|
|
|
54
57
|
"typescript": "~5.2.2"
|
|
55
58
|
},
|
|
56
59
|
"engines": {
|
|
57
|
-
"node": ">=18.0.0"
|
|
60
|
+
"node": ">=18.0.0",
|
|
61
|
+
"yarn": "<2.0.0",
|
|
62
|
+
"npm": "*"
|
|
58
63
|
},
|
|
59
64
|
"contributors": [
|
|
60
65
|
{
|