@angular/cli 15.0.0-next.1 → 15.0.0-next.3
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/lib/config/schema.json +67 -45
- package/lib/init.js +3 -1
- package/package.json +11 -11
- package/src/command-builder/architect-base-command-module.js +1 -1
- package/src/command-builder/command-module.d.ts +8 -1
- package/src/command-builder/command-module.js +22 -2
- package/src/command-builder/schematics-command-module.js +1 -8
- package/src/command-builder/utilities/schematic-engine-host.js +5 -7
- package/src/commands/add/cli.d.ts +1 -0
- package/src/commands/add/cli.js +6 -7
- package/src/commands/update/cli.js +8 -6
package/lib/config/schema.json
CHANGED
|
@@ -1662,8 +1662,22 @@
|
|
|
1662
1662
|
"description": "The full path for the main entry point to the app, relative to the current workspace."
|
|
1663
1663
|
},
|
|
1664
1664
|
"polyfills": {
|
|
1665
|
-
"
|
|
1666
|
-
"
|
|
1665
|
+
"description": "Polyfills to be included in the build.",
|
|
1666
|
+
"oneOf": [
|
|
1667
|
+
{
|
|
1668
|
+
"type": "array",
|
|
1669
|
+
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
|
|
1670
|
+
"items": {
|
|
1671
|
+
"type": "string",
|
|
1672
|
+
"uniqueItems": true
|
|
1673
|
+
},
|
|
1674
|
+
"default": []
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
"type": "string",
|
|
1678
|
+
"description": "The full path for the polyfills file, relative to the current workspace or a module specifier. Example: 'zone.js'."
|
|
1679
|
+
}
|
|
1680
|
+
]
|
|
1667
1681
|
},
|
|
1668
1682
|
"tsConfig": {
|
|
1669
1683
|
"type": "string",
|
|
@@ -1716,7 +1730,7 @@
|
|
|
1716
1730
|
"input": {
|
|
1717
1731
|
"type": "string",
|
|
1718
1732
|
"description": "The file to include.",
|
|
1719
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
1733
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
1720
1734
|
},
|
|
1721
1735
|
"bundleName": {
|
|
1722
1736
|
"type": "string",
|
|
@@ -1734,7 +1748,7 @@
|
|
|
1734
1748
|
{
|
|
1735
1749
|
"type": "string",
|
|
1736
1750
|
"description": "The file to include.",
|
|
1737
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
1751
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
1738
1752
|
}
|
|
1739
1753
|
]
|
|
1740
1754
|
}
|
|
@@ -2215,8 +2229,22 @@
|
|
|
2215
2229
|
"description": "The full path for the main entry point to the app, relative to the current workspace."
|
|
2216
2230
|
},
|
|
2217
2231
|
"polyfills": {
|
|
2218
|
-
"
|
|
2219
|
-
"
|
|
2232
|
+
"description": "Polyfills to be included in the build.",
|
|
2233
|
+
"oneOf": [
|
|
2234
|
+
{
|
|
2235
|
+
"type": "array",
|
|
2236
|
+
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
|
|
2237
|
+
"items": {
|
|
2238
|
+
"type": "string",
|
|
2239
|
+
"uniqueItems": true
|
|
2240
|
+
},
|
|
2241
|
+
"default": []
|
|
2242
|
+
},
|
|
2243
|
+
{
|
|
2244
|
+
"type": "string",
|
|
2245
|
+
"description": "The full path for the polyfills file, relative to the current workspace or a module specifier. Example: 'zone.js'."
|
|
2246
|
+
}
|
|
2247
|
+
]
|
|
2220
2248
|
},
|
|
2221
2249
|
"tsConfig": {
|
|
2222
2250
|
"type": "string",
|
|
@@ -2269,7 +2297,7 @@
|
|
|
2269
2297
|
"input": {
|
|
2270
2298
|
"type": "string",
|
|
2271
2299
|
"description": "The file to include.",
|
|
2272
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
2300
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
2273
2301
|
},
|
|
2274
2302
|
"bundleName": {
|
|
2275
2303
|
"type": "string",
|
|
@@ -2287,7 +2315,7 @@
|
|
|
2287
2315
|
{
|
|
2288
2316
|
"type": "string",
|
|
2289
2317
|
"description": "The file to include.",
|
|
2290
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
2318
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
2291
2319
|
}
|
|
2292
2320
|
]
|
|
2293
2321
|
}
|
|
@@ -2674,36 +2702,18 @@
|
|
|
2674
2702
|
]
|
|
2675
2703
|
},
|
|
2676
2704
|
"fileReplacement": {
|
|
2677
|
-
"
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
"
|
|
2681
|
-
|
|
2682
|
-
"type": "string",
|
|
2683
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
2684
|
-
},
|
|
2685
|
-
"replaceWith": {
|
|
2686
|
-
"type": "string",
|
|
2687
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
2688
|
-
}
|
|
2689
|
-
},
|
|
2690
|
-
"additionalProperties": false
|
|
2705
|
+
"type": "object",
|
|
2706
|
+
"properties": {
|
|
2707
|
+
"replace": {
|
|
2708
|
+
"type": "string",
|
|
2709
|
+
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
2691
2710
|
},
|
|
2692
|
-
{
|
|
2693
|
-
"type": "
|
|
2694
|
-
"
|
|
2695
|
-
"replace": {
|
|
2696
|
-
"type": "string",
|
|
2697
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
2698
|
-
},
|
|
2699
|
-
"with": {
|
|
2700
|
-
"type": "string",
|
|
2701
|
-
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
2702
|
-
}
|
|
2703
|
-
},
|
|
2704
|
-
"additionalProperties": false
|
|
2711
|
+
"with": {
|
|
2712
|
+
"type": "string",
|
|
2713
|
+
"pattern": "\\.(([cm]?j|t)sx?|json)$"
|
|
2705
2714
|
}
|
|
2706
|
-
|
|
2715
|
+
},
|
|
2716
|
+
"additionalProperties": false
|
|
2707
2717
|
},
|
|
2708
2718
|
"budget": {
|
|
2709
2719
|
"type": "object",
|
|
@@ -2918,8 +2928,22 @@
|
|
|
2918
2928
|
"description": "The name of the Karma configuration file."
|
|
2919
2929
|
},
|
|
2920
2930
|
"polyfills": {
|
|
2921
|
-
"
|
|
2922
|
-
"
|
|
2931
|
+
"description": "Polyfills to be included in the build.",
|
|
2932
|
+
"oneOf": [
|
|
2933
|
+
{
|
|
2934
|
+
"type": "array",
|
|
2935
|
+
"description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
|
|
2936
|
+
"items": {
|
|
2937
|
+
"type": "string",
|
|
2938
|
+
"uniqueItems": true
|
|
2939
|
+
},
|
|
2940
|
+
"default": []
|
|
2941
|
+
},
|
|
2942
|
+
{
|
|
2943
|
+
"type": "string",
|
|
2944
|
+
"description": "The full path for the polyfills file, relative to the current workspace or a module specifier. Example: 'zone.js'."
|
|
2945
|
+
}
|
|
2946
|
+
]
|
|
2923
2947
|
},
|
|
2924
2948
|
"assets": {
|
|
2925
2949
|
"type": "array",
|
|
@@ -2976,7 +3000,7 @@
|
|
|
2976
3000
|
"input": {
|
|
2977
3001
|
"type": "string",
|
|
2978
3002
|
"description": "The file to include.",
|
|
2979
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
3003
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
2980
3004
|
},
|
|
2981
3005
|
"bundleName": {
|
|
2982
3006
|
"type": "string",
|
|
@@ -2994,7 +3018,7 @@
|
|
|
2994
3018
|
{
|
|
2995
3019
|
"type": "string",
|
|
2996
3020
|
"description": "The file to include.",
|
|
2997
|
-
"pattern": "\\.(?:css|scss|sass|less
|
|
3021
|
+
"pattern": "\\.(?:css|scss|sass|less)$"
|
|
2998
3022
|
}
|
|
2999
3023
|
]
|
|
3000
3024
|
}
|
|
@@ -3030,6 +3054,9 @@
|
|
|
3030
3054
|
"items": {
|
|
3031
3055
|
"type": "string"
|
|
3032
3056
|
},
|
|
3057
|
+
"default": [
|
|
3058
|
+
"**/*.spec.ts"
|
|
3059
|
+
],
|
|
3033
3060
|
"description": "Globs of files to include, relative to workspace or project root. \nThere are 2 special cases:\n - when a path to directory is provided, all spec files ending \".spec.@(ts|tsx)\" will be included\n - when a path to a file is provided, and a matching spec file exists it will be included instead."
|
|
3034
3061
|
},
|
|
3035
3062
|
"sourceMap": {
|
|
@@ -3431,11 +3458,6 @@
|
|
|
3431
3458
|
"description": "Use file name for lazy loaded chunks.",
|
|
3432
3459
|
"default": false
|
|
3433
3460
|
},
|
|
3434
|
-
"bundleDependencies": {
|
|
3435
|
-
"description": "Which external dependencies to bundle into the bundle. By default, all of node_modules will be bundled.",
|
|
3436
|
-
"default": true,
|
|
3437
|
-
"type": "boolean"
|
|
3438
|
-
},
|
|
3439
3461
|
"externalDependencies": {
|
|
3440
3462
|
"description": "Exclude the listed external dependencies from being bundled into the bundle. Instead, the created bundle relies on these dependencies to be available during runtime.",
|
|
3441
3463
|
"type": "array",
|
package/lib/init.js
CHANGED
|
@@ -33,6 +33,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
require("symbol-observable");
|
|
34
34
|
// symbol polyfill must go first
|
|
35
35
|
const fs_1 = require("fs");
|
|
36
|
+
const module_1 = require("module");
|
|
36
37
|
const path = __importStar(require("path"));
|
|
37
38
|
const semver_1 = require("semver");
|
|
38
39
|
const color_1 = require("../src/utilities/color");
|
|
@@ -67,7 +68,8 @@ let forceExit = false;
|
|
|
67
68
|
try {
|
|
68
69
|
// No error implies a projectLocalCli, which will load whatever
|
|
69
70
|
// version of ng-cli you have installed in a local package.json
|
|
70
|
-
const
|
|
71
|
+
const cwdRequire = (0, module_1.createRequire)(process.cwd() + '/');
|
|
72
|
+
const projectLocalCli = cwdRequire.resolve('@angular/cli');
|
|
71
73
|
cli = await Promise.resolve().then(() => __importStar(require(projectLocalCli)));
|
|
72
74
|
const globalVersion = new semver_1.SemVer(version_1.VERSION.full);
|
|
73
75
|
// Older versions might not have the VERSION export
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/cli",
|
|
3
|
-
"version": "15.0.0-next.
|
|
3
|
+
"version": "15.0.0-next.3",
|
|
4
4
|
"description": "CLI tool for Angular",
|
|
5
5
|
"main": "lib/cli/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/angular/angular-cli",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@angular-devkit/architect": "0.1500.0-next.
|
|
29
|
-
"@angular-devkit/core": "15.0.0-next.
|
|
30
|
-
"@angular-devkit/schematics": "15.0.0-next.
|
|
31
|
-
"@schematics/angular": "15.0.0-next.
|
|
28
|
+
"@angular-devkit/architect": "0.1500.0-next.3",
|
|
29
|
+
"@angular-devkit/core": "15.0.0-next.3",
|
|
30
|
+
"@angular-devkit/schematics": "15.0.0-next.3",
|
|
31
|
+
"@schematics/angular": "15.0.0-next.3",
|
|
32
32
|
"@yarnpkg/lockfile": "1.1.0",
|
|
33
33
|
"ansi-colors": "4.1.3",
|
|
34
34
|
"debug": "4.3.4",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"ng-update": {
|
|
50
50
|
"migrations": "@schematics/angular/migrations/migration-collection.json",
|
|
51
51
|
"packageGroup": {
|
|
52
|
-
"@angular/cli": "15.0.0-next.
|
|
53
|
-
"@angular-devkit/architect": "0.1500.0-next.
|
|
54
|
-
"@angular-devkit/build-angular": "15.0.0-next.
|
|
55
|
-
"@angular-devkit/build-webpack": "0.1500.0-next.
|
|
56
|
-
"@angular-devkit/core": "15.0.0-next.
|
|
57
|
-
"@angular-devkit/schematics": "15.0.0-next.
|
|
52
|
+
"@angular/cli": "15.0.0-next.3",
|
|
53
|
+
"@angular-devkit/architect": "0.1500.0-next.3",
|
|
54
|
+
"@angular-devkit/build-angular": "15.0.0-next.3",
|
|
55
|
+
"@angular-devkit/build-webpack": "0.1500.0-next.3",
|
|
56
|
+
"@angular-devkit/core": "15.0.0-next.3",
|
|
57
|
+
"@angular-devkit/schematics": "15.0.0-next.3"
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
@@ -39,7 +39,7 @@ class ArchitectBaseCommandModule extends command_module_1.CommandModule {
|
|
|
39
39
|
await this.reportAnalytics({
|
|
40
40
|
...(await architectHost.getOptionsForTarget(target)),
|
|
41
41
|
...options,
|
|
42
|
-
});
|
|
42
|
+
}, undefined /** paths */, undefined /** dimensions */, builderName);
|
|
43
43
|
const { logger } = this.context;
|
|
44
44
|
const run = await this.getArchitect().scheduleTarget(target, options, {
|
|
45
45
|
logger,
|
|
@@ -74,7 +74,7 @@ export declare abstract class CommandModule<T extends {} = {}> implements Comman
|
|
|
74
74
|
abstract builder(argv: Argv): Promise<Argv<T>> | Argv<T>;
|
|
75
75
|
abstract run(options: Options<T> & OtherOptions): Promise<number | void> | number | void;
|
|
76
76
|
handler(args: ArgumentsCamelCase<T> & OtherOptions): Promise<void>;
|
|
77
|
-
reportAnalytics(options: (Options<T> & OtherOptions) | OtherOptions, paths?: string[], dimensions?: (boolean | number | string)[]): Promise<void>;
|
|
77
|
+
reportAnalytics(options: (Options<T> & OtherOptions) | OtherOptions, paths?: string[], dimensions?: (boolean | number | string)[], title?: string): Promise<void>;
|
|
78
78
|
protected getAnalytics(): Promise<analytics.Analytics>;
|
|
79
79
|
/**
|
|
80
80
|
* Adds schema options to a command also this keeps track of options that are required for analytics.
|
|
@@ -82,6 +82,13 @@ export declare abstract class CommandModule<T extends {} = {}> implements Comman
|
|
|
82
82
|
*/
|
|
83
83
|
protected addSchemaOptionsToCommand<T>(localYargs: Argv<T>, options: Option[]): Argv<T>;
|
|
84
84
|
protected getWorkspaceOrThrow(): AngularWorkspace;
|
|
85
|
+
/**
|
|
86
|
+
* Flush on an interval (if the event loop is waiting).
|
|
87
|
+
*
|
|
88
|
+
* @returns a method that when called will terminate the periodic
|
|
89
|
+
* flush and call flush one last time.
|
|
90
|
+
*/
|
|
91
|
+
private periodicAnalyticsFlush;
|
|
85
92
|
}
|
|
86
93
|
/**
|
|
87
94
|
* Creates an known command module error.
|
|
@@ -99,8 +99,10 @@ class CommandModule {
|
|
|
99
99
|
}
|
|
100
100
|
// Gather and report analytics.
|
|
101
101
|
const analytics = await this.getAnalytics();
|
|
102
|
+
let stopPeriodicFlushes;
|
|
102
103
|
if (this.shouldReportAnalytics) {
|
|
103
104
|
await this.reportAnalytics(camelCasedOptions);
|
|
105
|
+
stopPeriodicFlushes = this.periodicAnalyticsFlush(analytics);
|
|
104
106
|
}
|
|
105
107
|
let exitCode;
|
|
106
108
|
try {
|
|
@@ -109,7 +111,6 @@ class CommandModule {
|
|
|
109
111
|
exitCode = await this.run(camelCasedOptions);
|
|
110
112
|
const endTime = Date.now();
|
|
111
113
|
analytics.timing(this.commandName, 'duration', endTime - startTime);
|
|
112
|
-
await analytics.flush();
|
|
113
114
|
}
|
|
114
115
|
catch (e) {
|
|
115
116
|
if (e instanceof core_1.schema.SchemaValidationException) {
|
|
@@ -121,12 +122,13 @@ class CommandModule {
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
finally {
|
|
125
|
+
await (stopPeriodicFlushes === null || stopPeriodicFlushes === void 0 ? void 0 : stopPeriodicFlushes());
|
|
124
126
|
if (typeof exitCode === 'number' && exitCode > 0) {
|
|
125
127
|
process.exitCode = exitCode;
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
|
-
async reportAnalytics(options, paths = [], dimensions = []) {
|
|
131
|
+
async reportAnalytics(options, paths = [], dimensions = [], title) {
|
|
130
132
|
for (const [name, ua] of this.optionsWithAnalytics) {
|
|
131
133
|
const value = options[name];
|
|
132
134
|
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
@@ -137,6 +139,7 @@ class CommandModule {
|
|
|
137
139
|
analytics.pageview('/command/' + [this.commandName, ...paths].join('/'), {
|
|
138
140
|
dimensions,
|
|
139
141
|
metrics: [],
|
|
142
|
+
title,
|
|
140
143
|
});
|
|
141
144
|
}
|
|
142
145
|
getAnalytics() {
|
|
@@ -204,6 +207,23 @@ class CommandModule {
|
|
|
204
207
|
}
|
|
205
208
|
return workspace;
|
|
206
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Flush on an interval (if the event loop is waiting).
|
|
212
|
+
*
|
|
213
|
+
* @returns a method that when called will terminate the periodic
|
|
214
|
+
* flush and call flush one last time.
|
|
215
|
+
*/
|
|
216
|
+
periodicAnalyticsFlush(analytics) {
|
|
217
|
+
let analyticsFlushPromise = Promise.resolve();
|
|
218
|
+
const analyticsFlushInterval = setInterval(() => {
|
|
219
|
+
analyticsFlushPromise = analyticsFlushPromise.then(() => analytics.flush());
|
|
220
|
+
}, 2000);
|
|
221
|
+
return () => {
|
|
222
|
+
clearInterval(analyticsFlushInterval);
|
|
223
|
+
// Flush one last time.
|
|
224
|
+
return analyticsFlushPromise.then(() => analytics.flush());
|
|
225
|
+
};
|
|
226
|
+
}
|
|
207
227
|
}
|
|
208
228
|
__decorate([
|
|
209
229
|
memoize_1.memoize
|
|
@@ -128,16 +128,9 @@ class SchematicsCommandModule extends command_module_1.CommandModule {
|
|
|
128
128
|
workflow.registry.addSmartDefaultProvider('workingDirectory', () => workingDir === '' ? undefined : workingDir);
|
|
129
129
|
let shouldReportAnalytics = true;
|
|
130
130
|
workflow.engineHost.registerOptionsTransform(async (schematic, options) => {
|
|
131
|
-
var _a;
|
|
132
131
|
if (shouldReportAnalytics) {
|
|
133
132
|
shouldReportAnalytics = false;
|
|
134
|
-
|
|
135
|
-
const commandName = (_a = this.command) === null || _a === void 0 ? void 0 : _a.split(' ', 1)[0];
|
|
136
|
-
await this.reportAnalytics(options, [
|
|
137
|
-
commandName,
|
|
138
|
-
schematic.collection.name.replace(/\//g, '_'),
|
|
139
|
-
schematic.name.replace(/\//g, '_'),
|
|
140
|
-
]);
|
|
133
|
+
await this.reportAnalytics(options, undefined /** paths */, undefined /** dimensions */, schematic.collection.name + ':' + schematic.name);
|
|
141
134
|
}
|
|
142
135
|
// TODO: The below should be removed in version 15 when we change 1P schematics to use the `workingDirectory smart default`.
|
|
143
136
|
// Handle `"format": "path"` options.
|
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
9
|
var _a;
|
|
13
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
11
|
exports.SchematicEngineHost = void 0;
|
|
@@ -16,7 +13,7 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
|
16
13
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
17
14
|
const fs_1 = require("fs");
|
|
18
15
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
19
|
-
const module_1 =
|
|
16
|
+
const module_1 = require("module");
|
|
20
17
|
const path_1 = require("path");
|
|
21
18
|
const vm_1 = require("vm");
|
|
22
19
|
const error_1 = require("../../utilities/error");
|
|
@@ -56,7 +53,8 @@ class SchematicEngineHost extends tools_1.NodeModulesEngineHost {
|
|
|
56
53
|
const [path, name] = refString.split('#', 2);
|
|
57
54
|
// Mimic behavior of ExportStringRef class used in default behavior
|
|
58
55
|
const fullPath = path[0] === '.' ? (0, path_1.resolve)(parentPath !== null && parentPath !== void 0 ? parentPath : process.cwd(), path) : path;
|
|
59
|
-
const
|
|
56
|
+
const referenceRequire = (0, module_1.createRequire)(__filename);
|
|
57
|
+
const schematicFile = referenceRequire.resolve(fullPath, { paths: [parentPath] });
|
|
60
58
|
if (shouldWrapSchematic(schematicFile, !!(collectionDescription === null || collectionDescription === void 0 ? void 0 : collectionDescription.encapsulation))) {
|
|
61
59
|
const schematicPath = (0, path_1.dirname)(schematicFile);
|
|
62
60
|
const moduleCache = new Map();
|
|
@@ -103,8 +101,8 @@ const legacyModules = {
|
|
|
103
101
|
* @param exportName An optional name of a specific export to return. Otherwise, return all exports.
|
|
104
102
|
*/
|
|
105
103
|
function wrap(schematicFile, schematicDirectory, moduleCache, exportName) {
|
|
106
|
-
const hostRequire = module_1.
|
|
107
|
-
const schematicRequire = module_1.
|
|
104
|
+
const hostRequire = (0, module_1.createRequire)(__filename);
|
|
105
|
+
const schematicRequire = (0, module_1.createRequire)(schematicFile);
|
|
108
106
|
const customRequire = function (id) {
|
|
109
107
|
if (legacyModules[id]) {
|
|
110
108
|
// Provide compatibility modules for older versions of @angular/cdk
|
|
@@ -20,6 +20,7 @@ export declare class AddCommandModule extends SchematicsCommandModule implements
|
|
|
20
20
|
longDescriptionPath: string;
|
|
21
21
|
protected allowPrivateSchematics: boolean;
|
|
22
22
|
private readonly schematicName;
|
|
23
|
+
private rootRequire;
|
|
23
24
|
builder(argv: Argv): Promise<Argv<AddCommandArgs>>;
|
|
24
25
|
run(options: Options<AddCommandArgs> & OtherOptions): Promise<number | void>;
|
|
25
26
|
private isProjectVersionValid;
|
package/src/commands/add/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.AddCommandModule = void 0;
|
|
14
14
|
const core_1 = require("@angular-devkit/core");
|
|
15
15
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
16
|
+
const module_1 = require("module");
|
|
16
17
|
const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
|
|
17
18
|
const path_1 = require("path");
|
|
18
19
|
const semver_1 = require("semver");
|
|
@@ -42,6 +43,7 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
42
43
|
this.longDescriptionPath = (0, path_1.join)(__dirname, 'long-description.md');
|
|
43
44
|
this.allowPrivateSchematics = true;
|
|
44
45
|
this.schematicName = 'ng-add';
|
|
46
|
+
this.rootRequire = (0, module_1.createRequire)(this.context.root + '/');
|
|
45
47
|
}
|
|
46
48
|
async builder(argv) {
|
|
47
49
|
const localYargs = (await super.builder(argv))
|
|
@@ -214,9 +216,8 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
214
216
|
// Temporary packages are located in a different directory
|
|
215
217
|
// Hence we need to resolve them using the temp path
|
|
216
218
|
const { success, tempNodeModules } = await packageManager.installTemp(packageIdentifier.raw, registry ? [`--registry="${registry}"`] : undefined);
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
});
|
|
219
|
+
const tempRequire = (0, module_1.createRequire)(tempNodeModules + '/');
|
|
220
|
+
const resolvedCollectionPath = tempRequire.resolve((0, path_1.join)(collectionName, 'package.json'));
|
|
220
221
|
if (!success) {
|
|
221
222
|
return 1;
|
|
222
223
|
}
|
|
@@ -266,7 +267,7 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
266
267
|
}
|
|
267
268
|
isPackageInstalled(name) {
|
|
268
269
|
try {
|
|
269
|
-
|
|
270
|
+
this.rootRequire.resolve((0, path_1.join)(name, 'package.json'));
|
|
270
271
|
return true;
|
|
271
272
|
}
|
|
272
273
|
catch (e) {
|
|
@@ -309,9 +310,7 @@ class AddCommandModule extends schematics_command_module_1.SchematicsCommandModu
|
|
|
309
310
|
const { logger, root } = this.context;
|
|
310
311
|
let installedPackage;
|
|
311
312
|
try {
|
|
312
|
-
installedPackage =
|
|
313
|
-
paths: [root],
|
|
314
|
-
});
|
|
313
|
+
installedPackage = this.rootRequire.resolve((0, path_1.join)(name, 'package.json'));
|
|
315
314
|
}
|
|
316
315
|
catch { }
|
|
317
316
|
if (installedPackage) {
|
|
@@ -38,6 +38,7 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
|
38
38
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
39
39
|
const child_process_1 = require("child_process");
|
|
40
40
|
const fs_1 = require("fs");
|
|
41
|
+
const module_1 = require("module");
|
|
41
42
|
const npm_package_arg_1 = __importDefault(require("npm-package-arg"));
|
|
42
43
|
const npm_pick_manifest_1 = __importDefault(require("npm-pick-manifest"));
|
|
43
44
|
const path = __importStar(require("path"));
|
|
@@ -366,7 +367,8 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
366
367
|
// Try to resolve from package location.
|
|
367
368
|
// This avoids issues with package hoisting.
|
|
368
369
|
try {
|
|
369
|
-
|
|
370
|
+
const packageRequire = (0, module_1.createRequire)(packagePath + '/');
|
|
371
|
+
migrations = packageRequire.resolve(migrations);
|
|
370
372
|
}
|
|
371
373
|
catch (e) {
|
|
372
374
|
(0, error_1.assertIsError)(e);
|
|
@@ -531,6 +533,7 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
531
533
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
532
534
|
const migrations = global.externalMigrations;
|
|
533
535
|
if (success && migrations) {
|
|
536
|
+
const rootRequire = (0, module_1.createRequire)(this.context.root + '/');
|
|
534
537
|
for (const migration of migrations) {
|
|
535
538
|
// Resolve the package from the workspace root, as otherwise it will be resolved from the temp
|
|
536
539
|
// installed CLI version.
|
|
@@ -540,15 +543,13 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
540
543
|
try {
|
|
541
544
|
packagePath = path.dirname(
|
|
542
545
|
// This may fail if the `package.json` is not exported as an entry point
|
|
543
|
-
|
|
544
|
-
paths: [this.context.root],
|
|
545
|
-
}));
|
|
546
|
+
rootRequire.resolve(path.join(migration.package, 'package.json')));
|
|
546
547
|
}
|
|
547
548
|
catch (e) {
|
|
548
549
|
(0, error_1.assertIsError)(e);
|
|
549
550
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
550
551
|
// Fallback to trying to resolve the package's main entry point
|
|
551
|
-
packagePath =
|
|
552
|
+
packagePath = rootRequire.resolve(migration.package);
|
|
552
553
|
}
|
|
553
554
|
else {
|
|
554
555
|
throw e;
|
|
@@ -577,7 +578,8 @@ class UpdateCommandModule extends command_module_1.CommandModule {
|
|
|
577
578
|
// Try to resolve from package location.
|
|
578
579
|
// This avoids issues with package hoisting.
|
|
579
580
|
try {
|
|
580
|
-
|
|
581
|
+
const packageRequire = (0, module_1.createRequire)(packagePath + '/');
|
|
582
|
+
migrations = packageRequire.resolve(migration.collection);
|
|
581
583
|
}
|
|
582
584
|
catch (e) {
|
|
583
585
|
(0, error_1.assertIsError)(e);
|