@m2c2kit/cli 0.3.10 → 0.3.12
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/dist/index.d.ts +19 -7
- package/dist/index.js +31 -11
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* The code in this file is adapted from a reference CLI implementation from
|
|
4
4
|
* the Angular devkit repository:
|
|
5
|
-
* https://github.com/angular/angular-cli/blob/
|
|
6
|
-
*
|
|
5
|
+
* https://github.com/angular/angular-cli/blob/e1d6ee2b5cc5ee34e4e5b67aaa8c34662a315007/packages/angular_devkit/schematics_cli/bin/schematics.ts
|
|
7
6
|
* The license for that code is as follows:
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
* Copyright
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright Google LLC All Rights Reserved.
|
|
10
|
+
*
|
|
11
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
12
|
+
* found in the LICENSE file at https://angular.io/license
|
|
14
13
|
*/
|
|
15
14
|
import "symbol-observable";
|
|
16
15
|
import { ProcessOutput } from "@angular-devkit/core/node";
|
|
@@ -20,3 +19,16 @@ export interface MainOptions {
|
|
|
20
19
|
stderr?: ProcessOutput;
|
|
21
20
|
}
|
|
22
21
|
export declare function main({ args, stdout, stderr, }: MainOptions): Promise<0 | 1>;
|
|
22
|
+
/**
|
|
23
|
+
* This uses a dynamic import to load a module which may be ESM.
|
|
24
|
+
* CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
|
|
25
|
+
* will currently, unconditionally downlevel dynamic import into a require call.
|
|
26
|
+
* require calls cannot load ESM code and will result in a runtime error. To workaround
|
|
27
|
+
* this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
|
|
28
|
+
* Once TypeScript provides support for keeping the dynamic import this workaround can
|
|
29
|
+
* be dropped.
|
|
30
|
+
*
|
|
31
|
+
* @param modulePath The path of the module to load.
|
|
32
|
+
* @returns A Promise that resolves to the dynamically imported module.
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadEsmModule<T>(modulePath: string | URL): Promise<T>;
|
package/dist/index.js
CHANGED
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* The code in this file is adapted from a reference CLI implementation from
|
|
5
5
|
* the Angular devkit repository:
|
|
6
|
-
* https://github.com/angular/angular-cli/blob/
|
|
7
|
-
*
|
|
6
|
+
* https://github.com/angular/angular-cli/blob/e1d6ee2b5cc5ee34e4e5b67aaa8c34662a315007/packages/angular_devkit/schematics_cli/bin/schematics.ts
|
|
8
7
|
* The license for that code is as follows:
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
* Copyright
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright Google LLC All Rights Reserved.
|
|
11
|
+
*
|
|
12
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
13
|
+
* found in the LICENSE file at https://angular.io/license
|
|
15
14
|
*/
|
|
16
15
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
16
|
if (k2 === undefined) k2 = k;
|
|
@@ -37,7 +36,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
37
36
|
return result;
|
|
38
37
|
};
|
|
39
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.main = void 0;
|
|
39
|
+
exports.loadEsmModule = exports.main = void 0;
|
|
41
40
|
// symbol polyfill must go first
|
|
42
41
|
require("symbol-observable");
|
|
43
42
|
const core_1 = require("@angular-devkit/core");
|
|
@@ -46,7 +45,6 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
|
46
45
|
const tools_1 = require("@angular-devkit/schematics/tools");
|
|
47
46
|
const ansiColors = __importStar(require("ansi-colors"));
|
|
48
47
|
const fs_1 = require("fs");
|
|
49
|
-
const inquirer = __importStar(require("inquirer"));
|
|
50
48
|
const path = __importStar(require("path"));
|
|
51
49
|
const yargs_parser_1 = __importStar(require("yargs-parser"));
|
|
52
50
|
/**
|
|
@@ -88,7 +86,7 @@ function _listSchematics(workflow, collectionName, logger) {
|
|
|
88
86
|
return 0;
|
|
89
87
|
}
|
|
90
88
|
function _createPromptProvider() {
|
|
91
|
-
return (definitions) => {
|
|
89
|
+
return async (definitions) => {
|
|
92
90
|
const questions = definitions.map((definition) => {
|
|
93
91
|
const question = {
|
|
94
92
|
name: definition.id,
|
|
@@ -147,6 +145,7 @@ function _createPromptProvider() {
|
|
|
147
145
|
return { ...question, type: definition.type };
|
|
148
146
|
}
|
|
149
147
|
});
|
|
148
|
+
const { default: inquirer } = await loadEsmModule("inquirer");
|
|
150
149
|
return inquirer.prompt(questions);
|
|
151
150
|
};
|
|
152
151
|
}
|
|
@@ -333,7 +332,7 @@ async function main({ args, stdout = process.stdout, stderr = process.stderr, })
|
|
|
333
332
|
logger.fatal("The Schematic workflow failed. See above.");
|
|
334
333
|
}
|
|
335
334
|
else if (debug && err instanceof Error) {
|
|
336
|
-
logger.fatal(`An error
|
|
335
|
+
logger.fatal(`An error occurred:\n${err.stack}`);
|
|
337
336
|
}
|
|
338
337
|
else {
|
|
339
338
|
logger.fatal(`Error: ${err instanceof Error ? err.message : err}`);
|
|
@@ -444,3 +443,24 @@ if (require.main === module) {
|
|
|
444
443
|
throw e;
|
|
445
444
|
});
|
|
446
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* Lazily compiled dynamic import loader function.
|
|
448
|
+
*/
|
|
449
|
+
let load;
|
|
450
|
+
/**
|
|
451
|
+
* This uses a dynamic import to load a module which may be ESM.
|
|
452
|
+
* CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
|
|
453
|
+
* will currently, unconditionally downlevel dynamic import into a require call.
|
|
454
|
+
* require calls cannot load ESM code and will result in a runtime error. To workaround
|
|
455
|
+
* this, a Function constructor is used to prevent TypeScript from changing the dynamic import.
|
|
456
|
+
* Once TypeScript provides support for keeping the dynamic import this workaround can
|
|
457
|
+
* be dropped.
|
|
458
|
+
*
|
|
459
|
+
* @param modulePath The path of the module to load.
|
|
460
|
+
* @returns A Promise that resolves to the dynamically imported module.
|
|
461
|
+
*/
|
|
462
|
+
function loadEsmModule(modulePath) {
|
|
463
|
+
load ?? (load = new Function("modulePath", `return import(modulePath);`));
|
|
464
|
+
return load(modulePath);
|
|
465
|
+
}
|
|
466
|
+
exports.loadEsmModule = loadEsmModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m2c2kit/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "Command line interface to create new m2c2kit apps",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**"
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://m2c2-project.github.io/m2c2kit",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@angular-devkit/core": "^
|
|
29
|
-
"@angular-devkit/schematics": "^
|
|
28
|
+
"@angular-devkit/core": "^17.0.6",
|
|
29
|
+
"@angular-devkit/schematics": "^17.0.6",
|
|
30
30
|
"@m2c2kit/schematics": "^0.1.0",
|
|
31
|
-
"@schematics/angular": "^
|
|
31
|
+
"@schematics/angular": "^17.0.6",
|
|
32
32
|
"ansi-colors": "4.1.3",
|
|
33
|
-
"inquirer": "
|
|
33
|
+
"inquirer": "9.2.12",
|
|
34
34
|
"symbol-observable": "4.0.0",
|
|
35
35
|
"yargs-parser": "21.1.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/inquirer": "
|
|
39
|
-
"rimraf": "5.0.
|
|
40
|
-
"typescript": "5.
|
|
38
|
+
"@types/inquirer": "9.0.7",
|
|
39
|
+
"rimraf": "5.0.5",
|
|
40
|
+
"typescript": "5.3.3"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=18"
|