@o3r/create 10.0.0-prerelease.99 → 10.1.0-prerelease.0
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 -1
- package/index.js +37 -19
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -19,10 +19,18 @@ or
|
|
|
19
19
|
yarn create @o3r <project-name> [...options]
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
>
|
|
22
|
+
> [!WARNING]
|
|
23
|
+
> 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
|
|
|
24
25
|
You can generate an environment with a specific package manager thanks to the `--package-manager` options:
|
|
25
26
|
|
|
26
27
|
```shell
|
|
27
28
|
npm create @o3r <project-name> -- --package-manager=yarn [...options]
|
|
28
29
|
```
|
|
30
|
+
|
|
31
|
+
## Available options
|
|
32
|
+
|
|
33
|
+
The generator accepts all the configurations from Angular `ng new` command, find the list [here](https://angular.io/cli/new#options).
|
|
34
|
+
On top of them, the following options can be provided to the initializer:
|
|
35
|
+
|
|
36
|
+
- `--yarn-version` : specify the version of yarn to use (default: `latest`)
|
package/index.js
CHANGED
|
@@ -7,6 +7,9 @@ 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
9
|
const { version, dependencies, devDependencies } = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.resolve)(__dirname, 'package.json'), { encoding: 'utf-8' }));
|
|
10
|
+
const optionsList = [
|
|
11
|
+
'yarn-version'
|
|
12
|
+
];
|
|
10
13
|
const logo = `
|
|
11
14
|
|
|
12
15
|
&BPPPB & &BPGB&
|
|
@@ -104,8 +107,17 @@ const isNgNewOptions = (arg) => {
|
|
|
104
107
|
}
|
|
105
108
|
return true;
|
|
106
109
|
};
|
|
110
|
+
const exitProcessIfErrorInSpawnSync = (exitCode, { error, status }) => {
|
|
111
|
+
if (error || status !== 0) {
|
|
112
|
+
if (error) {
|
|
113
|
+
// eslint-disable-next-line no-console
|
|
114
|
+
console.error(error);
|
|
115
|
+
}
|
|
116
|
+
process.exit(exitCode);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
107
119
|
const schematicsCliOptions = Object.entries(argv)
|
|
108
|
-
.filter(([key]) => key !== '_')
|
|
120
|
+
.filter(([key]) => key !== '_' && !optionsList.includes(key))
|
|
109
121
|
.map(([key, value]) => value === true && [key] || value === false && key.length > 1 && [`no-${key}`] || [key, value])
|
|
110
122
|
.map(([key, value]) => {
|
|
111
123
|
const optionKey = key.length > 1 ? `--${key}` : `-${key}`;
|
|
@@ -115,25 +127,19 @@ const createNgProject = () => {
|
|
|
115
127
|
const options = schematicsCliOptions
|
|
116
128
|
.filter(([key]) => isNgNewOptions(key))
|
|
117
129
|
.flat();
|
|
118
|
-
|
|
130
|
+
exitProcessIfErrorInSpawnSync(1, (0, node_child_process_1.spawnSync)(process.execPath, [binPath, 'new', ...argv._, ...options], {
|
|
119
131
|
stdio: 'inherit'
|
|
120
|
-
});
|
|
121
|
-
if (error) {
|
|
122
|
-
// eslint-disable-next-line no-console
|
|
123
|
-
console.error(error);
|
|
124
|
-
process.exit(1);
|
|
125
|
-
}
|
|
132
|
+
}));
|
|
126
133
|
};
|
|
127
|
-
const
|
|
134
|
+
const prepareWorkspace = (relativeDirectory = '.', projectPackageManager = 'npm') => {
|
|
135
|
+
const cwd = (0, node_path_1.resolve)(process.cwd(), relativeDirectory);
|
|
136
|
+
const runner = process.platform === 'win32' ? `${projectPackageManager}.cmd` : projectPackageManager;
|
|
128
137
|
const mandatoryDependencies = [
|
|
129
138
|
'@angular-devkit/schematics',
|
|
130
139
|
'@schematics/angular',
|
|
131
140
|
'@angular-devkit/core',
|
|
132
141
|
'@angular-devkit/architect'
|
|
133
142
|
];
|
|
134
|
-
const cwd = (0, node_path_1.resolve)(process.cwd(), relativeDirectory);
|
|
135
|
-
const options = schematicsCliOptions
|
|
136
|
-
.flat();
|
|
137
143
|
const packageJsonPath = (0, node_path_1.resolve)(cwd, 'package.json');
|
|
138
144
|
const packageJson = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, { encoding: 'utf-8' })
|
|
139
145
|
// Replace the ^ with ~ to use the same minor version for angular packages as @angular/cli
|
|
@@ -143,17 +149,29 @@ const addOtterFramework = (relativeDirectory = '.', projectPackageManager = 'npm
|
|
|
143
149
|
packageJson.devDependencies[dep] = dependencies?.[dep] || devDependencies?.[dep] || 'latest';
|
|
144
150
|
});
|
|
145
151
|
(0, node_fs_1.writeFileSync)(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
146
|
-
|
|
152
|
+
if (projectPackageManager === 'yarn') {
|
|
153
|
+
exitProcessIfErrorInSpawnSync(2, (0, node_child_process_1.spawnSync)(runner, ['set', 'version', argv['yarn-version'] || 'stable'], {
|
|
154
|
+
stdio: 'inherit',
|
|
155
|
+
cwd
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
exitProcessIfErrorInSpawnSync(2, (0, node_child_process_1.spawnSync)(runner, ['install'], {
|
|
147
159
|
stdio: 'inherit',
|
|
148
160
|
cwd
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
}));
|
|
162
|
+
};
|
|
163
|
+
const addOtterFramework = (relativeDirectory = '.', projectPackageManager = 'npm') => {
|
|
164
|
+
const cwd = (0, node_path_1.resolve)(process.cwd(), relativeDirectory);
|
|
165
|
+
const runner = process.platform === 'win32' ? `${projectPackageManager}.cmd` : projectPackageManager;
|
|
166
|
+
const options = schematicsCliOptions
|
|
167
|
+
.flat();
|
|
168
|
+
exitProcessIfErrorInSpawnSync(3, (0, node_child_process_1.spawnSync)(runner, ['exec', 'ng', 'add', `@o3r/core@~${version}`, ...(projectPackageManager === 'npm' ? ['--'] : []), ...options], {
|
|
169
|
+
stdio: 'inherit',
|
|
170
|
+
cwd
|
|
171
|
+
}));
|
|
155
172
|
};
|
|
156
173
|
const projectFolder = argv._[0]?.replaceAll(' ', '-').toLowerCase() || '.';
|
|
157
174
|
console.info(logo);
|
|
158
175
|
createNgProject();
|
|
176
|
+
prepareWorkspace(projectFolder, packageManager);
|
|
159
177
|
addOtterFramework(projectFolder, packageManager);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/create",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.0-prerelease.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"@nx/eslint-plugin": "~18.0.2",
|
|
35
35
|
"@nx/jest": "~18.0.2",
|
|
36
36
|
"@nx/js": "~18.0.2",
|
|
37
|
-
"@o3r/build-helpers": "^10.
|
|
38
|
-
"@o3r/eslint-config-otter": "^10.
|
|
39
|
-
"@o3r/eslint-plugin": "^10.
|
|
40
|
-
"@o3r/test-helpers": "^10.
|
|
37
|
+
"@o3r/build-helpers": "^10.1.0-prerelease.0",
|
|
38
|
+
"@o3r/eslint-config-otter": "^10.1.0-prerelease.0",
|
|
39
|
+
"@o3r/eslint-plugin": "^10.1.0-prerelease.0",
|
|
40
|
+
"@o3r/test-helpers": "^10.1.0-prerelease.0",
|
|
41
41
|
"@stylistic/eslint-plugin-ts": "^1.5.4",
|
|
42
42
|
"@types/jest": "~29.5.2",
|
|
43
43
|
"@types/minimist": "^1.2.2",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"eslint": "^8.42.0",
|
|
49
49
|
"eslint-import-resolver-node": "^0.3.4",
|
|
50
50
|
"eslint-plugin-jest": "~27.9.0",
|
|
51
|
-
"eslint-plugin-jsdoc": "~48.
|
|
51
|
+
"eslint-plugin-jsdoc": "~48.2.0",
|
|
52
52
|
"eslint-plugin-prefer-arrow": "~1.2.3",
|
|
53
53
|
"eslint-plugin-unicorn": "^51.0.0",
|
|
54
54
|
"jest": "~29.7.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"rxjs": "^7.8.1",
|
|
60
60
|
"ts-jest": "~29.1.1",
|
|
61
61
|
"type-fest": "^4.10.2",
|
|
62
|
-
"typescript": "~5.
|
|
62
|
+
"typescript": "~5.3.3"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=18.0.0",
|