@angular-devkit/schematics-cli 18.1.0-next.0 → 18.1.0-next.2

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.
@@ -4,9 +4,8 @@
4
4
  * Copyright Google LLC All Rights Reserved.
5
5
  *
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
7
+ * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
- /// <reference types="node" />
10
9
  import 'symbol-observable';
11
10
  import { ProcessOutput } from '@angular-devkit/core/node';
12
11
  export interface MainOptions {
@@ -15,16 +14,3 @@ export interface MainOptions {
15
14
  stderr?: ProcessOutput;
16
15
  }
17
16
  export declare function main({ args, stdout, stderr, }: MainOptions): Promise<0 | 1>;
18
- /**
19
- * This uses a dynamic import to load a module which may be ESM.
20
- * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
21
- * will currently, unconditionally downlevel dynamic import into a require call.
22
- * require calls cannot load ESM code and will result in a runtime error. To workaround
23
- * this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
24
- * Once TypeScript provides support for keeping the dynamic import this workaround can
25
- * be dropped.
26
- *
27
- * @param modulePath The path of the module to load.
28
- * @returns A Promise that resolves to the dynamically imported module.
29
- */
30
- export declare function loadEsmModule<T>(modulePath: string | URL): Promise<T>;
package/bin/schematics.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Copyright Google LLC All Rights Reserved.
6
6
  *
7
7
  * Use of this source code is governed by an MIT-style license that can be
8
- * found in the LICENSE file at https://angular.io/license
8
+ * found in the LICENSE file at https://angular.dev/license
9
9
  */
10
10
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
11
  if (k2 === undefined) k2 = k;
@@ -34,7 +34,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
34
34
  return (mod && mod.__esModule) ? mod : { "default": mod };
35
35
  };
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.loadEsmModule = exports.main = void 0;
37
+ exports.main = main;
38
38
  // symbol polyfill must go first
39
39
  require("symbol-observable");
40
40
  const node_1 = require("@angular-devkit/core/node");
@@ -83,66 +83,82 @@ function _listSchematics(workflow, collectionName, logger) {
83
83
  }
84
84
  function _createPromptProvider() {
85
85
  return async (definitions) => {
86
- const questions = definitions.map((definition) => {
87
- const question = {
88
- name: definition.id,
89
- message: definition.message,
90
- default: definition.default,
91
- };
92
- const validator = definition.validator;
93
- if (validator) {
94
- question.validate = (input) => validator(input);
95
- // Filter allows transformation of the value prior to validation
96
- question.filter = async (input) => {
97
- for (const type of definition.propertyTypes) {
98
- let value;
99
- switch (type) {
100
- case 'string':
101
- value = String(input);
102
- break;
103
- case 'integer':
104
- case 'number':
105
- value = Number(input);
106
- break;
107
- default:
108
- value = input;
109
- break;
110
- }
111
- // Can be a string if validation fails
112
- const isValid = (await validator(value)) === true;
113
- if (isValid) {
114
- return value;
115
- }
116
- }
117
- return input;
118
- };
119
- }
86
+ let prompts;
87
+ const answers = {};
88
+ for (const definition of definitions) {
89
+ // Only load prompt package if needed
90
+ prompts ??= await Promise.resolve().then(() => __importStar(require('@inquirer/prompts')));
120
91
  switch (definition.type) {
121
92
  case 'confirmation':
122
- return { ...question, type: 'confirm' };
93
+ answers[definition.id] = await prompts.confirm({
94
+ message: definition.message,
95
+ default: definition.default,
96
+ });
97
+ break;
123
98
  case 'list':
124
- return {
125
- ...question,
126
- type: definition.multiselect ? 'checkbox' : 'list',
127
- choices: definition.items &&
128
- definition.items.map((item) => {
129
- if (typeof item == 'string') {
130
- return item;
99
+ if (!definition.items?.length) {
100
+ continue;
101
+ }
102
+ const choices = definition.items?.map((item) => {
103
+ return typeof item == 'string'
104
+ ? {
105
+ name: item,
106
+ value: item,
107
+ }
108
+ : {
109
+ name: item.label,
110
+ value: item.value,
111
+ };
112
+ });
113
+ answers[definition.id] = await (definition.multiselect ? prompts.checkbox : prompts.select)({
114
+ message: definition.message,
115
+ default: definition.default,
116
+ choices,
117
+ });
118
+ break;
119
+ case 'input':
120
+ let finalValue;
121
+ answers[definition.id] = await prompts.input({
122
+ message: definition.message,
123
+ default: definition.default,
124
+ async validate(value) {
125
+ if (definition.validator === undefined) {
126
+ return true;
127
+ }
128
+ let lastValidation = false;
129
+ for (const type of definition.propertyTypes) {
130
+ let potential;
131
+ switch (type) {
132
+ case 'string':
133
+ potential = String(value);
134
+ break;
135
+ case 'integer':
136
+ case 'number':
137
+ potential = Number(value);
138
+ break;
139
+ default:
140
+ potential = value;
141
+ break;
131
142
  }
132
- else {
133
- return {
134
- name: item.label,
135
- value: item.value,
136
- };
143
+ lastValidation = await definition.validator(potential);
144
+ // Can be a string if validation fails
145
+ if (lastValidation === true) {
146
+ finalValue = potential;
147
+ return true;
137
148
  }
138
- }),
139
- };
140
- default:
141
- return { ...question, type: definition.type };
149
+ }
150
+ return lastValidation;
151
+ },
152
+ });
153
+ // Use validated value if present.
154
+ // This ensures the correct type is inserted into the final schema options.
155
+ if (finalValue !== undefined) {
156
+ answers[definition.id] = finalValue;
157
+ }
158
+ break;
142
159
  }
143
- });
144
- const { default: inquirer } = await loadEsmModule('inquirer');
145
- return inquirer.prompt(questions);
160
+ }
161
+ return answers;
146
162
  };
147
163
  }
148
164
  function findUp(names, from) {
@@ -328,7 +344,6 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
328
344
  return 1;
329
345
  }
330
346
  }
331
- exports.main = main;
332
347
  /**
333
348
  * Get usage of the CLI tool.
334
349
  */
@@ -431,24 +446,3 @@ if (require.main === module) {
431
446
  throw e;
432
447
  });
433
448
  }
434
- /**
435
- * Lazily compiled dynamic import loader function.
436
- */
437
- let load;
438
- /**
439
- * This uses a dynamic import to load a module which may be ESM.
440
- * CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
441
- * will currently, unconditionally downlevel dynamic import into a require call.
442
- * require calls cannot load ESM code and will result in a runtime error. To workaround
443
- * this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
444
- * Once TypeScript provides support for keeping the dynamic import this workaround can
445
- * be dropped.
446
- *
447
- * @param modulePath The path of the module to load.
448
- * @returns A Promise that resolves to the dynamically imported module.
449
- */
450
- function loadEsmModule(modulePath) {
451
- load ??= new Function('modulePath', `return import(modulePath);`);
452
- return load(modulePath);
453
- }
454
- exports.loadEsmModule = loadEsmModule;
@@ -3,7 +3,7 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  import { Rule } from '@angular-devkit/schematics';
9
9
  import { Schema } from './schema';
package/blank/factory.js CHANGED
@@ -4,9 +4,10 @@
4
4
  * Copyright Google LLC All Rights Reserved.
5
5
  *
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
7
+ * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.default = default_1;
10
11
  const core_1 = require("@angular-devkit/core");
11
12
  const schematics_1 = require("@angular-devkit/schematics");
12
13
  const tasks_1 = require("@angular-devkit/schematics/tasks");
@@ -76,4 +77,3 @@ function default_1(options) {
76
77
  ]);
77
78
  };
78
79
  }
79
- exports.default = default_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-devkit/schematics-cli",
3
- "version": "18.1.0-next.0",
3
+ "version": "18.1.0-next.2",
4
4
  "description": "Angular Schematics - CLI",
5
5
  "homepage": "https://github.com/angular/angular-cli",
6
6
  "bin": {
@@ -21,13 +21,14 @@
21
21
  ],
22
22
  "schematics": "./collection.json",
23
23
  "dependencies": {
24
- "@angular-devkit/core": "18.1.0-next.0",
25
- "@angular-devkit/schematics": "18.1.0-next.0",
24
+ "@angular-devkit/core": "18.1.0-next.2",
25
+ "@angular-devkit/schematics": "18.1.0-next.2",
26
+ "@inquirer/prompts": "5.0.5",
26
27
  "ansi-colors": "4.1.3",
27
- "inquirer": "9.2.22",
28
28
  "symbol-observable": "4.0.0",
29
29
  "yargs-parser": "21.1.1"
30
30
  },
31
+ "packageManager": "yarn@4.2.2",
31
32
  "repository": {
32
33
  "type": "git",
33
34
  "url": "https://github.com/angular/angular-cli.git"
@@ -41,5 +42,13 @@
41
42
  "license": "MIT",
42
43
  "bugs": {
43
44
  "url": "https://github.com/angular/angular-cli/issues"
45
+ },
46
+ "dependenciesMeta": {
47
+ "esbuild": {
48
+ "built": true
49
+ },
50
+ "puppeteer": {
51
+ "built": true
52
+ }
44
53
  }
45
54
  }
@@ -3,7 +3,7 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  import { Rule } from '@angular-devkit/schematics';
9
9
  import { Schema } from './schema';
@@ -4,9 +4,10 @@
4
4
  * Copyright Google LLC All Rights Reserved.
5
5
  *
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
7
+ * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.default = default_1;
10
11
  const core_1 = require("@angular-devkit/core");
11
12
  const schematics_1 = require("@angular-devkit/schematics");
12
13
  const tasks_1 = require("@angular-devkit/schematics/tasks");
@@ -29,4 +30,3 @@ function default_1(options) {
29
30
  ]));
30
31
  };
31
32
  }
32
- exports.default = default_1;