@angular/cli 18.1.0-next.3 → 18.1.0-rc.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/package.json +16 -16
- package/src/command-builder/architect-base-command-module.js +1 -1
- package/src/command-builder/architect-command-module.js +158 -124
- package/src/command-builder/command-module.js +225 -196
- package/src/command-builder/schematics-command-module.js +308 -284
- package/src/commands/new/cli.js +1 -1
- package/src/utilities/color.d.ts +1 -1
- package/src/utilities/color.js +9 -21
- package/src/utilities/memoize.d.ts +1 -1
- package/src/utilities/memoize.js +14 -19
- package/src/utilities/package-manager.js +265 -239
- package/src/utilities/tty.d.ts +1 -1
- package/src/utilities/tty.js +2 -2
- package/src/utilities/version.js +1 -1
|
@@ -22,11 +22,39 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
26
|
+
var useValue = arguments.length > 2;
|
|
27
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
28
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
29
|
+
}
|
|
30
|
+
return useValue ? value : void 0;
|
|
31
|
+
};
|
|
32
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
33
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
34
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
35
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
36
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
37
|
+
var _, done = false;
|
|
38
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
39
|
+
var context = {};
|
|
40
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
41
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
42
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
43
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
44
|
+
if (kind === "accessor") {
|
|
45
|
+
if (result === void 0) continue;
|
|
46
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
47
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
48
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
49
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
50
|
+
}
|
|
51
|
+
else if (_ = accept(result)) {
|
|
52
|
+
if (kind === "field") initializers.unshift(_);
|
|
53
|
+
else descriptor[key] = _;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
57
|
+
done = true;
|
|
30
58
|
};
|
|
31
59
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
32
60
|
if (mod && mod.__esModule) return mod;
|
|
@@ -35,9 +63,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
35
63
|
__setModuleDefault(result, mod);
|
|
36
64
|
return result;
|
|
37
65
|
};
|
|
38
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
39
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
40
|
-
};
|
|
41
66
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
67
|
exports.SchematicsCommandModule = exports.DEFAULT_SCHEMATICS_COLLECTION = void 0;
|
|
43
68
|
const core_1 = require("@angular-devkit/core");
|
|
@@ -55,300 +80,299 @@ const json_schema_1 = require("./utilities/json-schema");
|
|
|
55
80
|
const schematic_engine_host_1 = require("./utilities/schematic-engine-host");
|
|
56
81
|
const schematic_workflow_1 = require("./utilities/schematic-workflow");
|
|
57
82
|
exports.DEFAULT_SCHEMATICS_COLLECTION = '@schematics/angular';
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.option('defaults', {
|
|
75
|
-
describe: 'Disable interactive input prompts for options with a default.',
|
|
76
|
-
type: 'boolean',
|
|
77
|
-
default: false,
|
|
78
|
-
})
|
|
79
|
-
.option('force', {
|
|
80
|
-
describe: 'Force overwriting of existing files.',
|
|
81
|
-
type: 'boolean',
|
|
82
|
-
default: false,
|
|
83
|
-
})
|
|
84
|
-
.strict();
|
|
85
|
-
}
|
|
86
|
-
/** Get schematic schema options.*/
|
|
87
|
-
async getSchematicOptions(collection, schematicName, workflow) {
|
|
88
|
-
const schematic = collection.createSchematic(schematicName, true);
|
|
89
|
-
const { schemaJson } = schematic.description;
|
|
90
|
-
if (!schemaJson) {
|
|
91
|
-
return [];
|
|
83
|
+
let SchematicsCommandModule = (() => {
|
|
84
|
+
let _classSuper = command_module_1.CommandModule;
|
|
85
|
+
let _instanceExtraInitializers = [];
|
|
86
|
+
let _getOrCreateWorkflowForBuilder_decorators;
|
|
87
|
+
let _getOrCreateWorkflowForExecution_decorators;
|
|
88
|
+
let _getSchematicCollections_decorators;
|
|
89
|
+
return class SchematicsCommandModule extends _classSuper {
|
|
90
|
+
static {
|
|
91
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
92
|
+
_getOrCreateWorkflowForBuilder_decorators = [memoize_1.memoize];
|
|
93
|
+
_getOrCreateWorkflowForExecution_decorators = [memoize_1.memoize];
|
|
94
|
+
_getSchematicCollections_decorators = [memoize_1.memoize];
|
|
95
|
+
__esDecorate(this, null, _getOrCreateWorkflowForBuilder_decorators, { kind: "method", name: "getOrCreateWorkflowForBuilder", static: false, private: false, access: { has: obj => "getOrCreateWorkflowForBuilder" in obj, get: obj => obj.getOrCreateWorkflowForBuilder }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
96
|
+
__esDecorate(this, null, _getOrCreateWorkflowForExecution_decorators, { kind: "method", name: "getOrCreateWorkflowForExecution", static: false, private: false, access: { has: obj => "getOrCreateWorkflowForExecution" in obj, get: obj => obj.getOrCreateWorkflowForExecution }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
97
|
+
__esDecorate(this, null, _getSchematicCollections_decorators, { kind: "method", name: "getSchematicCollections", static: false, private: false, access: { has: obj => "getSchematicCollections" in obj, get: obj => obj.getSchematicCollections }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
98
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
92
99
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
workflow.registry.useXDeprecatedProvider((msg) => logger.warn(msg));
|
|
127
|
-
workflow.registry.addSmartDefaultProvider('projectName', () => this.getProjectName());
|
|
128
|
-
const workingDir = (0, core_1.normalize)((0, path_1.relative)(this.context.root, process.cwd()));
|
|
129
|
-
workflow.registry.addSmartDefaultProvider('workingDirectory', () => workingDir === '' ? undefined : workingDir);
|
|
130
|
-
let shouldReportAnalytics = true;
|
|
131
|
-
workflow.engineHost.registerOptionsTransform(async (schematic, options) => {
|
|
132
|
-
// Report analytics
|
|
133
|
-
if (shouldReportAnalytics) {
|
|
134
|
-
shouldReportAnalytics = false;
|
|
135
|
-
const { collection: { name: collectionName }, name: schematicName, } = schematic;
|
|
136
|
-
const analytics = (0, analytics_1.isPackageNameSafeForAnalytics)(collectionName)
|
|
137
|
-
? await this.getAnalytics()
|
|
138
|
-
: undefined;
|
|
139
|
-
analytics?.reportSchematicRunEvent({
|
|
140
|
-
[analytics_parameters_1.EventCustomDimension.SchematicCollectionName]: collectionName,
|
|
141
|
-
[analytics_parameters_1.EventCustomDimension.SchematicName]: schematicName,
|
|
142
|
-
...this.getAnalyticsParameters(options),
|
|
143
|
-
});
|
|
100
|
+
scope = (__runInitializers(this, _instanceExtraInitializers), command_module_1.CommandScope.In);
|
|
101
|
+
allowPrivateSchematics = false;
|
|
102
|
+
async builder(argv) {
|
|
103
|
+
return argv
|
|
104
|
+
.option('interactive', {
|
|
105
|
+
describe: 'Enable interactive input prompts.',
|
|
106
|
+
type: 'boolean',
|
|
107
|
+
default: true,
|
|
108
|
+
})
|
|
109
|
+
.option('dry-run', {
|
|
110
|
+
describe: 'Run through and reports activity without writing out results.',
|
|
111
|
+
type: 'boolean',
|
|
112
|
+
alias: ['d'],
|
|
113
|
+
default: false,
|
|
114
|
+
})
|
|
115
|
+
.option('defaults', {
|
|
116
|
+
describe: 'Disable interactive input prompts for options with a default.',
|
|
117
|
+
type: 'boolean',
|
|
118
|
+
default: false,
|
|
119
|
+
})
|
|
120
|
+
.option('force', {
|
|
121
|
+
describe: 'Force overwriting of existing files.',
|
|
122
|
+
type: 'boolean',
|
|
123
|
+
default: false,
|
|
124
|
+
})
|
|
125
|
+
.strict();
|
|
126
|
+
}
|
|
127
|
+
/** Get schematic schema options.*/
|
|
128
|
+
async getSchematicOptions(collection, schematicName, workflow) {
|
|
129
|
+
const schematic = collection.createSchematic(schematicName, true);
|
|
130
|
+
const { schemaJson } = schematic.description;
|
|
131
|
+
if (!schemaJson) {
|
|
132
|
+
return [];
|
|
144
133
|
}
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
134
|
+
return (0, json_schema_1.parseJsonSchemaToOptions)(workflow.registry, schemaJson);
|
|
135
|
+
}
|
|
136
|
+
getOrCreateWorkflowForBuilder(collectionName) {
|
|
137
|
+
return new tools_1.NodeWorkflow(this.context.root, {
|
|
138
|
+
resolvePaths: this.getResolvePaths(collectionName),
|
|
139
|
+
engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async getOrCreateWorkflowForExecution(collectionName, options) {
|
|
143
|
+
const { logger, root, packageManager } = this.context;
|
|
144
|
+
const { force, dryRun, packageRegistry } = options;
|
|
145
|
+
const workflow = new tools_1.NodeWorkflow(root, {
|
|
146
|
+
force,
|
|
147
|
+
dryRun,
|
|
148
|
+
packageManager: packageManager.name,
|
|
149
|
+
// A schema registry is required to allow customizing addUndefinedDefaults
|
|
150
|
+
registry: new core_1.schema.CoreSchemaRegistry(schematics_1.formats.standardFormats),
|
|
151
|
+
packageRegistry,
|
|
152
|
+
resolvePaths: this.getResolvePaths(collectionName),
|
|
153
|
+
schemaValidation: true,
|
|
154
|
+
optionTransforms: [
|
|
155
|
+
// Add configuration file defaults
|
|
156
|
+
async (schematic, current) => {
|
|
157
|
+
const projectName = typeof current?.project === 'string' ? current.project : this.getProjectName();
|
|
158
|
+
return {
|
|
159
|
+
...(await (0, config_1.getSchematicDefaults)(schematic.collection.name, schematic.name, projectName)),
|
|
160
|
+
...current,
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
engineHostCreator: (options) => new schematic_engine_host_1.SchematicEngineHost(options.resolvePaths),
|
|
165
|
+
});
|
|
166
|
+
workflow.registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
|
|
167
|
+
workflow.registry.useXDeprecatedProvider((msg) => logger.warn(msg));
|
|
168
|
+
workflow.registry.addSmartDefaultProvider('projectName', () => this.getProjectName());
|
|
169
|
+
const workingDir = (0, core_1.normalize)((0, path_1.relative)(this.context.root, process.cwd()));
|
|
170
|
+
workflow.registry.addSmartDefaultProvider('workingDirectory', () => workingDir === '' ? undefined : workingDir);
|
|
171
|
+
let shouldReportAnalytics = true;
|
|
172
|
+
workflow.engineHost.registerOptionsTransform(async (schematic, options) => {
|
|
173
|
+
// Report analytics
|
|
174
|
+
if (shouldReportAnalytics) {
|
|
175
|
+
shouldReportAnalytics = false;
|
|
176
|
+
const { collection: { name: collectionName }, name: schematicName, } = schematic;
|
|
177
|
+
const analytics = (0, analytics_1.isPackageNameSafeForAnalytics)(collectionName)
|
|
178
|
+
? await this.getAnalytics()
|
|
179
|
+
: undefined;
|
|
180
|
+
analytics?.reportSchematicRunEvent({
|
|
181
|
+
[analytics_parameters_1.EventCustomDimension.SchematicCollectionName]: collectionName,
|
|
182
|
+
[analytics_parameters_1.EventCustomDimension.SchematicName]: schematicName,
|
|
183
|
+
...this.getAnalyticsParameters(options),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return options;
|
|
187
|
+
});
|
|
188
|
+
if (options.interactive !== false && (0, tty_1.isTTY)()) {
|
|
189
|
+
workflow.registry.usePromptProvider(async (definitions) => {
|
|
190
|
+
let prompts;
|
|
191
|
+
const answers = {};
|
|
192
|
+
for (const definition of definitions) {
|
|
193
|
+
if (options.defaults && definition.default !== undefined) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
// Only load prompt package if needed
|
|
197
|
+
prompts ??= await Promise.resolve().then(() => __importStar(require('@inquirer/prompts')));
|
|
198
|
+
switch (definition.type) {
|
|
199
|
+
case 'confirmation':
|
|
200
|
+
answers[definition.id] = await prompts.confirm({
|
|
201
|
+
message: definition.message,
|
|
202
|
+
default: definition.default,
|
|
203
|
+
});
|
|
204
|
+
break;
|
|
205
|
+
case 'list':
|
|
206
|
+
if (!definition.items?.length) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
const choices = definition.items?.map((item) => {
|
|
210
|
+
return typeof item == 'string'
|
|
211
|
+
? {
|
|
212
|
+
name: item,
|
|
213
|
+
value: item,
|
|
208
214
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
215
|
+
: {
|
|
216
|
+
name: item.label,
|
|
217
|
+
value: item.value,
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
answers[definition.id] = await (definition.multiselect ? prompts.checkbox : prompts.select)({
|
|
221
|
+
message: definition.message,
|
|
222
|
+
default: definition.default,
|
|
223
|
+
choices,
|
|
224
|
+
});
|
|
225
|
+
break;
|
|
226
|
+
case 'input':
|
|
227
|
+
let finalValue;
|
|
228
|
+
answers[definition.id] = await prompts.input({
|
|
229
|
+
message: definition.message,
|
|
230
|
+
default: definition.default,
|
|
231
|
+
async validate(value) {
|
|
232
|
+
if (definition.validator === undefined) {
|
|
213
233
|
return true;
|
|
214
234
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
235
|
+
let lastValidation = false;
|
|
236
|
+
for (const type of definition.propertyTypes) {
|
|
237
|
+
let potential;
|
|
238
|
+
switch (type) {
|
|
239
|
+
case 'string':
|
|
240
|
+
potential = String(value);
|
|
241
|
+
break;
|
|
242
|
+
case 'integer':
|
|
243
|
+
case 'number':
|
|
244
|
+
potential = Number(value);
|
|
245
|
+
break;
|
|
246
|
+
default:
|
|
247
|
+
potential = value;
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
lastValidation = await definition.validator(potential);
|
|
251
|
+
// Can be a string if validation fails
|
|
252
|
+
if (lastValidation === true) {
|
|
253
|
+
finalValue = potential;
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return lastValidation;
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
// Use validated value if present.
|
|
261
|
+
// This ensures the correct type is inserted into the final schema options.
|
|
262
|
+
if (finalValue !== undefined) {
|
|
263
|
+
answers[definition.id] = finalValue;
|
|
264
|
+
}
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
225
267
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
268
|
+
return answers;
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return workflow;
|
|
229
272
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
273
|
+
async getSchematicCollections() {
|
|
274
|
+
// Resolve relative collections from the location of `angular.json`
|
|
275
|
+
const resolveRelativeCollection = (collectionName) => collectionName.charAt(0) === '.'
|
|
276
|
+
? (0, path_1.resolve)(this.context.root, collectionName)
|
|
277
|
+
: collectionName;
|
|
278
|
+
const getSchematicCollections = (configSection) => {
|
|
279
|
+
if (!configSection) {
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
const { schematicCollections } = configSection;
|
|
283
|
+
if (Array.isArray(schematicCollections)) {
|
|
284
|
+
return new Set(schematicCollections.map((c) => resolveRelativeCollection(c)));
|
|
285
|
+
}
|
|
239
286
|
return undefined;
|
|
240
|
-
}
|
|
241
|
-
const {
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const project = (0, config_1.getProjectByCwd)(workspace);
|
|
250
|
-
if (project) {
|
|
251
|
-
const value = getSchematicCollections(workspace.getProjectCli(project));
|
|
252
|
-
if (value) {
|
|
253
|
-
return value;
|
|
287
|
+
};
|
|
288
|
+
const { workspace, globalConfiguration } = this.context;
|
|
289
|
+
if (workspace) {
|
|
290
|
+
const project = (0, config_1.getProjectByCwd)(workspace);
|
|
291
|
+
if (project) {
|
|
292
|
+
const value = getSchematicCollections(workspace.getProjectCli(project));
|
|
293
|
+
if (value) {
|
|
294
|
+
return value;
|
|
295
|
+
}
|
|
254
296
|
}
|
|
255
297
|
}
|
|
298
|
+
const value = getSchematicCollections(workspace?.getCli()) ??
|
|
299
|
+
getSchematicCollections(globalConfiguration.getCli());
|
|
300
|
+
if (value) {
|
|
301
|
+
return value;
|
|
302
|
+
}
|
|
303
|
+
return new Set([exports.DEFAULT_SCHEMATICS_COLLECTION]);
|
|
256
304
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
parseSchematicInfo(schematic) {
|
|
265
|
-
if (schematic?.includes(':')) {
|
|
266
|
-
const [collectionName, schematicName] = schematic.split(':', 2);
|
|
267
|
-
return [collectionName, schematicName];
|
|
268
|
-
}
|
|
269
|
-
return [undefined, schematic];
|
|
270
|
-
}
|
|
271
|
-
async runSchematic(options) {
|
|
272
|
-
const { logger } = this.context;
|
|
273
|
-
const { schematicOptions, executionOptions, collectionName, schematicName } = options;
|
|
274
|
-
const workflow = await this.getOrCreateWorkflowForExecution(collectionName, executionOptions);
|
|
275
|
-
if (!schematicName) {
|
|
276
|
-
throw new Error('schematicName cannot be undefined.');
|
|
305
|
+
parseSchematicInfo(schematic) {
|
|
306
|
+
if (schematic?.includes(':')) {
|
|
307
|
+
const [collectionName, schematicName] = schematic.split(':', 2);
|
|
308
|
+
return [collectionName, schematicName];
|
|
309
|
+
}
|
|
310
|
+
return [undefined, schematic];
|
|
277
311
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
options: schematicOptions,
|
|
285
|
-
logger,
|
|
286
|
-
allowPrivate: this.allowPrivateSchematics,
|
|
287
|
-
})
|
|
288
|
-
.toPromise();
|
|
289
|
-
if (!files.size) {
|
|
290
|
-
logger.info('Nothing to be done.');
|
|
312
|
+
async runSchematic(options) {
|
|
313
|
+
const { logger } = this.context;
|
|
314
|
+
const { schematicOptions, executionOptions, collectionName, schematicName } = options;
|
|
315
|
+
const workflow = await this.getOrCreateWorkflowForExecution(collectionName, executionOptions);
|
|
316
|
+
if (!schematicName) {
|
|
317
|
+
throw new Error('schematicName cannot be undefined.');
|
|
291
318
|
}
|
|
292
|
-
|
|
293
|
-
|
|
319
|
+
const { unsubscribe, files } = (0, schematic_workflow_1.subscribeToWorkflow)(workflow, logger);
|
|
320
|
+
try {
|
|
321
|
+
await workflow
|
|
322
|
+
.execute({
|
|
323
|
+
collection: collectionName,
|
|
324
|
+
schematic: schematicName,
|
|
325
|
+
options: schematicOptions,
|
|
326
|
+
logger,
|
|
327
|
+
allowPrivate: this.allowPrivateSchematics,
|
|
328
|
+
})
|
|
329
|
+
.toPromise();
|
|
330
|
+
if (!files.size) {
|
|
331
|
+
logger.info('Nothing to be done.');
|
|
332
|
+
}
|
|
333
|
+
if (executionOptions.dryRun) {
|
|
334
|
+
logger.warn(`\nNOTE: The "--dry-run" option means no changes were made.`);
|
|
335
|
+
}
|
|
294
336
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
337
|
+
catch (err) {
|
|
338
|
+
// In case the workflow was not successful, show an appropriate error message.
|
|
339
|
+
if (err instanceof schematics_1.UnsuccessfulWorkflowExecution) {
|
|
340
|
+
// "See above" because we already printed the error.
|
|
341
|
+
logger.fatal('The Schematic workflow failed. See above.');
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
(0, error_1.assertIsError)(err);
|
|
345
|
+
logger.fatal(err.message);
|
|
346
|
+
}
|
|
347
|
+
return 1;
|
|
301
348
|
}
|
|
302
|
-
|
|
303
|
-
(
|
|
304
|
-
logger.fatal(err.message);
|
|
349
|
+
finally {
|
|
350
|
+
unsubscribe();
|
|
305
351
|
}
|
|
306
|
-
return
|
|
307
|
-
}
|
|
308
|
-
finally {
|
|
309
|
-
unsubscribe();
|
|
352
|
+
return 0;
|
|
310
353
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
354
|
+
getProjectName() {
|
|
355
|
+
const { workspace, logger } = this.context;
|
|
356
|
+
if (!workspace) {
|
|
357
|
+
return undefined;
|
|
358
|
+
}
|
|
359
|
+
const projectName = (0, config_1.getProjectByCwd)(workspace);
|
|
360
|
+
if (projectName) {
|
|
361
|
+
return projectName;
|
|
362
|
+
}
|
|
316
363
|
return undefined;
|
|
317
364
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return
|
|
365
|
+
getResolvePaths(collectionName) {
|
|
366
|
+
const { workspace, root } = this.context;
|
|
367
|
+
return workspace
|
|
368
|
+
? // Workspace
|
|
369
|
+
collectionName === exports.DEFAULT_SCHEMATICS_COLLECTION
|
|
370
|
+
? // Favor __dirname for @schematics/angular to use the build-in version
|
|
371
|
+
[__dirname, process.cwd(), root]
|
|
372
|
+
: [process.cwd(), root, __dirname]
|
|
373
|
+
: // Global
|
|
374
|
+
[__dirname, process.cwd()];
|
|
321
375
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
getResolvePaths(collectionName) {
|
|
325
|
-
const { workspace, root } = this.context;
|
|
326
|
-
return workspace
|
|
327
|
-
? // Workspace
|
|
328
|
-
collectionName === exports.DEFAULT_SCHEMATICS_COLLECTION
|
|
329
|
-
? // Favor __dirname for @schematics/angular to use the build-in version
|
|
330
|
-
[__dirname, process.cwd(), root]
|
|
331
|
-
: [process.cwd(), root, __dirname]
|
|
332
|
-
: // Global
|
|
333
|
-
[__dirname, process.cwd()];
|
|
334
|
-
}
|
|
335
|
-
}
|
|
376
|
+
};
|
|
377
|
+
})();
|
|
336
378
|
exports.SchematicsCommandModule = SchematicsCommandModule;
|
|
337
|
-
__decorate([
|
|
338
|
-
memoize_1.memoize,
|
|
339
|
-
__metadata("design:type", Function),
|
|
340
|
-
__metadata("design:paramtypes", [String]),
|
|
341
|
-
__metadata("design:returntype", tools_1.NodeWorkflow)
|
|
342
|
-
], SchematicsCommandModule.prototype, "getOrCreateWorkflowForBuilder", null);
|
|
343
|
-
__decorate([
|
|
344
|
-
memoize_1.memoize,
|
|
345
|
-
__metadata("design:type", Function),
|
|
346
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
347
|
-
__metadata("design:returntype", Promise)
|
|
348
|
-
], SchematicsCommandModule.prototype, "getOrCreateWorkflowForExecution", null);
|
|
349
|
-
__decorate([
|
|
350
|
-
memoize_1.memoize,
|
|
351
|
-
__metadata("design:type", Function),
|
|
352
|
-
__metadata("design:paramtypes", []),
|
|
353
|
-
__metadata("design:returntype", Promise)
|
|
354
|
-
], SchematicsCommandModule.prototype, "getSchematicCollections", null);
|