@angular-devkit/schematics-cli
Advanced tools
Comparing version 18.1.0-next.1 to 18.1.0-next.2
@@ -7,3 +7,3 @@ #!/usr/bin/env node | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
@@ -18,14 +18,1 @@ import 'symbol-observable'; | ||
export declare function main({ args, stdout, stderr, }: MainOptions): Promise<0 | 1>; | ||
/** | ||
* This uses a dynamic import to load a module which may be ESM. | ||
* CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript | ||
* will currently, unconditionally downlevel dynamic import into a require call. | ||
* require calls cannot load ESM code and will result in a runtime error. To workaround | ||
* this, a Function constructor is used to prevent TypeScript from changing the dynamic import. | ||
* Once TypeScript provides support for keeping the dynamic import this workaround can | ||
* be dropped. | ||
* | ||
* @param modulePath The path of the module to load. | ||
* @returns A Promise that resolves to the dynamically imported module. | ||
*/ | ||
export declare function loadEsmModule<T>(modulePath: string | URL): Promise<T>; |
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
@@ -39,3 +39,2 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
exports.main = main; | ||
exports.loadEsmModule = loadEsmModule; | ||
// symbol polyfill must go first | ||
@@ -89,62 +88,78 @@ require("symbol-observable"); | ||
return async (definitions) => { | ||
const questions = definitions.map((definition) => { | ||
const question = { | ||
name: definition.id, | ||
message: definition.message, | ||
default: definition.default, | ||
}; | ||
const validator = definition.validator; | ||
if (validator) { | ||
question.validate = (input) => validator(input); | ||
// Filter allows transformation of the value prior to validation | ||
question.filter = async (input) => { | ||
for (const type of definition.propertyTypes) { | ||
let value; | ||
switch (type) { | ||
case 'string': | ||
value = String(input); | ||
break; | ||
case 'integer': | ||
case 'number': | ||
value = Number(input); | ||
break; | ||
default: | ||
value = input; | ||
break; | ||
} | ||
// Can be a string if validation fails | ||
const isValid = (await validator(value)) === true; | ||
if (isValid) { | ||
return value; | ||
} | ||
} | ||
return input; | ||
}; | ||
} | ||
let prompts; | ||
const answers = {}; | ||
for (const definition of definitions) { | ||
// Only load prompt package if needed | ||
prompts ??= await Promise.resolve().then(() => __importStar(require('@inquirer/prompts'))); | ||
switch (definition.type) { | ||
case 'confirmation': | ||
return { ...question, type: 'confirm' }; | ||
answers[definition.id] = await prompts.confirm({ | ||
message: definition.message, | ||
default: definition.default, | ||
}); | ||
break; | ||
case 'list': | ||
return { | ||
...question, | ||
type: definition.multiselect ? 'checkbox' : 'list', | ||
choices: definition.items && | ||
definition.items.map((item) => { | ||
if (typeof item == 'string') { | ||
return item; | ||
if (!definition.items?.length) { | ||
continue; | ||
} | ||
const choices = definition.items?.map((item) => { | ||
return typeof item == 'string' | ||
? { | ||
name: item, | ||
value: item, | ||
} | ||
: { | ||
name: item.label, | ||
value: item.value, | ||
}; | ||
}); | ||
answers[definition.id] = await (definition.multiselect ? prompts.checkbox : prompts.select)({ | ||
message: definition.message, | ||
default: definition.default, | ||
choices, | ||
}); | ||
break; | ||
case 'input': | ||
let finalValue; | ||
answers[definition.id] = await prompts.input({ | ||
message: definition.message, | ||
default: definition.default, | ||
async validate(value) { | ||
if (definition.validator === undefined) { | ||
return true; | ||
} | ||
let lastValidation = false; | ||
for (const type of definition.propertyTypes) { | ||
let potential; | ||
switch (type) { | ||
case 'string': | ||
potential = String(value); | ||
break; | ||
case 'integer': | ||
case 'number': | ||
potential = Number(value); | ||
break; | ||
default: | ||
potential = value; | ||
break; | ||
} | ||
else { | ||
return { | ||
name: item.label, | ||
value: item.value, | ||
}; | ||
lastValidation = await definition.validator(potential); | ||
// Can be a string if validation fails | ||
if (lastValidation === true) { | ||
finalValue = potential; | ||
return true; | ||
} | ||
}), | ||
}; | ||
default: | ||
return { ...question, type: definition.type }; | ||
} | ||
return lastValidation; | ||
}, | ||
}); | ||
// Use validated value if present. | ||
// This ensures the correct type is inserted into the final schema options. | ||
if (finalValue !== undefined) { | ||
answers[definition.id] = finalValue; | ||
} | ||
break; | ||
} | ||
}); | ||
const { default: inquirer } = await loadEsmModule('inquirer'); | ||
return inquirer.prompt(questions); | ||
} | ||
return answers; | ||
}; | ||
@@ -437,21 +452,1 @@ } | ||
} | ||
/** | ||
* Lazily compiled dynamic import loader function. | ||
*/ | ||
let load; | ||
/** | ||
* This uses a dynamic import to load a module which may be ESM. | ||
* CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript | ||
* will currently, unconditionally downlevel dynamic import into a require call. | ||
* require calls cannot load ESM code and will result in a runtime error. To workaround | ||
* this, a Function constructor is used to prevent TypeScript from changing the dynamic import. | ||
* Once TypeScript provides support for keeping the dynamic import this workaround can | ||
* be dropped. | ||
* | ||
* @param modulePath The path of the module to load. | ||
* @returns A Promise that resolves to the dynamically imported module. | ||
*/ | ||
function loadEsmModule(modulePath) { | ||
load ??= new Function('modulePath', `return import(modulePath);`); | ||
return load(modulePath); | ||
} |
@@ -6,3 +6,3 @@ /** | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
@@ -9,0 +9,0 @@ import { Rule } from '@angular-devkit/schematics'; |
@@ -7,3 +7,3 @@ "use strict"; | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
@@ -10,0 +10,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
{ | ||
"name": "@angular-devkit/schematics-cli", | ||
"version": "18.1.0-next.1", | ||
"version": "18.1.0-next.2", | ||
"description": "Angular Schematics - CLI", | ||
@@ -24,9 +24,10 @@ "homepage": "https://github.com/angular/angular-cli", | ||
"dependencies": { | ||
"@angular-devkit/core": "18.1.0-next.1", | ||
"@angular-devkit/schematics": "18.1.0-next.1", | ||
"@angular-devkit/core": "18.1.0-next.2", | ||
"@angular-devkit/schematics": "18.1.0-next.2", | ||
"@inquirer/prompts": "5.0.5", | ||
"ansi-colors": "4.1.3", | ||
"inquirer": "9.2.23", | ||
"symbol-observable": "4.0.0", | ||
"yargs-parser": "21.1.1" | ||
}, | ||
"packageManager": "yarn@4.2.2", | ||
"repository": { | ||
@@ -45,3 +46,11 @@ "type": "git", | ||
"url": "https://github.com/angular/angular-cli/issues" | ||
}, | ||
"dependenciesMeta": { | ||
"esbuild": { | ||
"built": true | ||
}, | ||
"puppeteer": { | ||
"built": true | ||
} | ||
} | ||
} |
@@ -6,3 +6,3 @@ /** | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
@@ -9,0 +9,0 @@ import { Rule } from '@angular-devkit/schematics'; |
@@ -7,3 +7,3 @@ "use strict"; | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
@@ -10,0 +10,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
0
44295
909
+ Added@inquirer/prompts@5.0.5
+ Added@angular-devkit/core@18.1.0-next.2(transitive)
+ Added@angular-devkit/schematics@18.1.0-next.2(transitive)
+ Added@inquirer/checkbox@2.5.0(transitive)
+ Added@inquirer/confirm@3.2.0(transitive)
+ Added@inquirer/core@9.2.1(transitive)
+ Added@inquirer/editor@2.2.0(transitive)
+ Added@inquirer/expand@2.3.0(transitive)
+ Added@inquirer/input@2.3.0(transitive)
+ Added@inquirer/password@2.2.0(transitive)
+ Added@inquirer/prompts@5.0.5(transitive)
+ Added@inquirer/rawlist@2.3.0(transitive)
+ Added@inquirer/select@2.5.0(transitive)
+ Added@inquirer/type@1.5.52.0.0(transitive)
+ Added@types/mute-stream@0.0.4(transitive)
+ Added@types/node@22.7.4(transitive)
+ Added@types/wrap-ansi@3.0.0(transitive)
+ Addedsignal-exit@4.1.0(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedyoctocolors-cjs@2.1.2(transitive)
- Removedinquirer@9.2.23
- Removed@angular-devkit/core@18.1.0-next.1(transitive)
- Removed@angular-devkit/schematics@18.1.0-next.1(transitive)
- Removed@ljharb/through@2.3.13(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedchalk@5.3.0(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinquirer@9.2.23(transitive)
- Removedlodash@4.17.21(transitive)
- Removedrun-async@3.0.0(transitive)
- Removedset-function-length@1.2.2(transitive)