@ms-cloudpack/cli 0.76.15 → 0.77.1
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/commands/info/index.js +1 -1
- package/lib/commands/info/index.js.map +1 -1
- package/lib/commands/report/index.js +1 -1
- package/lib/commands/report/index.js.map +1 -1
- package/lib/types/SharedOptions.d.ts +4 -0
- package/lib/types/SharedOptions.d.ts.map +1 -1
- package/lib/types/SharedOptions.js.map +1 -1
- package/lib/utilities/AutoDisposableList.d.ts.map +1 -1
- package/lib/utilities/AutoDisposableList.js +6 -3
- package/lib/utilities/AutoDisposableList.js.map +1 -1
- package/lib/utilities/CloudpackCommand.d.ts.map +1 -1
- package/lib/utilities/CloudpackCommand.js +1 -0
- package/lib/utilities/CloudpackCommand.js.map +1 -1
- package/lib/utilities/CommandExecutor.d.ts.map +1 -1
- package/lib/utilities/CommandExecutor.js +6 -1
- package/lib/utilities/CommandExecutor.js.map +1 -1
- package/lib/utilities/readLocalConfigs.d.ts +8 -1
- package/lib/utilities/readLocalConfigs.d.ts.map +1 -1
- package/lib/utilities/readLocalConfigs.js +10 -2
- package/lib/utilities/readLocalConfigs.js.map +1 -1
- package/package.json +20 -18
- package/schema/AppConfig.json +1242 -0
- package/schema/GeneratedConfig.json +108 -0
- package/schema/UserConfig.json +1248 -0
- package/schema/UserPreferences.json +16 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Option } from 'commander';
|
|
2
|
-
const hideSharedOptions = ['cachePath', 'features'];
|
|
2
|
+
const hideSharedOptions = ['cachePath', 'features', 'config'];
|
|
3
3
|
/** Defines the "info" verb. */
|
|
4
4
|
export const init = (program) => {
|
|
5
5
|
const infoCommand = program.addSubCommand({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAInC,MAAM,iBAAiB,GAA+B,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAInC,MAAM,iBAAiB,GAA+B,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAE1F,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;QACxC,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,+DAA+D;QAC5E,KAAK,EAAE,WAAW;QAClB,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;IAEH,WAAW,CAAC,aAAa,CAAC;QACxB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,gFAAgF;QAC7F,iBAAiB;QACjB,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC;KACnD,CAAC,CAAC;IAEH,WAAW,CAAC,aAAa,CAAC;QACxB,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,oDAAoD;QACjE,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,4BAA4B,CAAC;QACvD,iBAAiB;QACjB,OAAO,EAAE;YACP,IAAI,EAAE,IAAI,MAAM,CAAC,QAAQ,EAAE,0BAA0B,CAAC;SACvD;KACF,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { SharedOptions } from '../../types/SharedOptions.js';\n\nconst hideSharedOptions: Array<keyof SharedOptions> = ['cachePath', 'features', 'config'];\n\n/** Defines the \"info\" verb. */\nexport const init: CommandInitFunction = (program) => {\n const infoCommand = program.addSubCommand({\n name: 'info',\n description: 'Get repo info relevant to Cloudpack (requires a sub-command).',\n usage: '<command>',\n hideSharedOptions: true,\n });\n\n infoCommand.addSubCommand({\n name: 'lock-file',\n alias: 'lockfile',\n description: 'Get info about potentially problematic deps from the lock file (yarn v1 only).',\n hideSharedOptions,\n getExecutor: () => import('./lockFile/execute.js'),\n });\n\n infoCommand.addSubCommand({\n name: 'non-semver-deps',\n description: 'Get a list of non-semver deps from local packages.',\n getExecutor: () => import('./nonSemverDeps/execute.js'),\n hideSharedOptions,\n options: {\n prod: new Option('--prod', 'Only get production deps'),\n },\n });\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/report/index.ts"],"names":[],"mappings":"AAGA,MAAM,iBAAiB,GAA+B,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/report/index.ts"],"names":[],"mappings":"AAGA,MAAM,iBAAiB,GAA+B,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAE1F,iCAAiC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;QACxC,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,iDAAiD;QAC9D,KAAK,EAAE,WAAW;QAClB,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;IAEH,WAAW,CAAC,aAAa,CAAC;QACxB,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,4FAA4F;QACzG,iBAAiB;QACjB,wFAAwF;QACxF,WAAW,EAAE,GAAG,EAAE,CAChB,OAAO,CAAC,OAAO,CAAC;YACd,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,kCAAkC,EAAE,CAAC;SAChF,CAAC;KACL,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { SharedOptions } from '../../types/SharedOptions.js';\n\nconst hideSharedOptions: Array<keyof SharedOptions> = ['cachePath', 'features', 'config'];\n\n/** Defines the \"report\" verb. */\nexport const init: CommandInitFunction = (program) => {\n const infoCommand = program.addSubCommand({\n name: 'report',\n description: 'Report telemetry data (requires a sub-command).',\n usage: '<command>',\n hideSharedOptions: true,\n });\n\n infoCommand.addSubCommand({\n name: 'legacy-start',\n description: 'Report the start of a legacy app. This is useful to track cloudpack vs legacy start usage.',\n hideSharedOptions,\n // The run of the \"cloudpack report legacy-start\" command will be reported to telemetry.\n getExecutor: () =>\n Promise.resolve({\n execute: () => Promise.resolve({ message: 'Legacy start telemetry reported.' }),\n }),\n });\n};\n"]}
|
|
@@ -35,5 +35,9 @@ export interface SharedOptions {
|
|
|
35
35
|
* Write log file with all console output.
|
|
36
36
|
*/
|
|
37
37
|
logFile?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Custom config file name to use instead of cloudpack.config.json.
|
|
40
|
+
*/
|
|
41
|
+
config?: string;
|
|
38
42
|
}
|
|
39
43
|
//# sourceMappingURL=SharedOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedOptions.d.ts","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SharedOptions.d.ts","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedOptions.js","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { DefineFlags } from '@ms-cloudpack/common-types-browser';\n\n/**\n * Shared CLI options for all commands.\n */\nexport interface SharedOptions {\n /**\n * Whether to enable debug logging (superset of --verbose).\n */\n debug?: boolean;\n\n /**\n * Whether to enable verbose logging.\n */\n verbose?: boolean;\n\n /**\n * Whether to enable colors. Available on the command line as `--no-color`.\n */\n color?: boolean;\n\n /**\n * Whether to disable non-essential logging.\n */\n quiet?: boolean;\n\n /**\n * Experimental features to enable.\n */\n features?: Record<string, boolean>;\n\n /**\n * Custom cache folder to use for this run of the command.\n */\n cachePath?: string;\n\n /**\n * Key value pairs that will be used to define global variables in the runtime.\n */\n define?: DefineFlags;\n\n /**\n * Write log file with all console output.\n */\n logFile?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SharedOptions.js","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { DefineFlags } from '@ms-cloudpack/common-types-browser';\n\n/**\n * Shared CLI options for all commands.\n */\nexport interface SharedOptions {\n /**\n * Whether to enable debug logging (superset of --verbose).\n */\n debug?: boolean;\n\n /**\n * Whether to enable verbose logging.\n */\n verbose?: boolean;\n\n /**\n * Whether to enable colors. Available on the command line as `--no-color`.\n */\n color?: boolean;\n\n /**\n * Whether to disable non-essential logging.\n */\n quiet?: boolean;\n\n /**\n * Experimental features to enable.\n */\n features?: Record<string, boolean>;\n\n /**\n * Custom cache folder to use for this run of the command.\n */\n cachePath?: string;\n\n /**\n * Key value pairs that will be used to define global variables in the runtime.\n */\n define?: DefineFlags;\n\n /**\n * Write log file with all console output.\n */\n logFile?: boolean;\n\n /**\n * Custom config file name to use instead of cloudpack.config.json.\n */\n config?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoDisposableList.d.ts","sourceRoot":"","sources":["../../src/utilities/AutoDisposableList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"AutoDisposableList.d.ts","sourceRoot":"","sources":["../../src/utilities/AutoDisposableList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyB;IAE9C,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC;IAK/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAqBtC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export class AutoDisposableList {
|
|
2
|
-
disposables =
|
|
2
|
+
disposables = new Set();
|
|
3
3
|
add(item) {
|
|
4
|
-
this.disposables.
|
|
4
|
+
this.disposables.add(item);
|
|
5
5
|
return item;
|
|
6
6
|
}
|
|
7
7
|
async dispose() {
|
|
8
8
|
let errorCount = 0;
|
|
9
|
-
|
|
9
|
+
const disposables = Array.from(this.disposables);
|
|
10
|
+
await Promise.all(disposables.map(async (d) => {
|
|
10
11
|
try {
|
|
11
12
|
await d.dispose?.();
|
|
12
13
|
}
|
|
@@ -15,6 +16,8 @@ export class AutoDisposableList {
|
|
|
15
16
|
errorCount++;
|
|
16
17
|
}
|
|
17
18
|
}));
|
|
19
|
+
// Clear the set after attempting to dispose all items
|
|
20
|
+
this.disposables.clear();
|
|
18
21
|
if (errorCount) {
|
|
19
22
|
throw new Error(`Failed to dispose ${errorCount} disposable(s)`);
|
|
20
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoDisposableList.js","sourceRoot":"","sources":["../../src/utilities/AutoDisposableList.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAkB;IACZ,WAAW,
|
|
1
|
+
{"version":3,"file":"AutoDisposableList.js","sourceRoot":"","sources":["../../src/utilities/AutoDisposableList.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAkB;IACZ,WAAW,GAAG,IAAI,GAAG,EAAc,CAAC;IAE9C,GAAG,CAAuB,IAAO;QACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjD,MAAM,OAAO,CAAC,GAAG,CACf,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAC1B,IAAI,CAAC;gBACH,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;YACtB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,sBAAuB,GAAa,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC;gBACnE,UAAU,EAAE,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CACH,CAAC;QAEF,sDAAsD;QACtD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAEzB,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,qBAAqB,UAAU,gBAAgB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { Disposable } from '../types/Disposable.js';\n\nexport class AutoDisposableList {\n private readonly disposables = new Set<Disposable>();\n\n public add<T extends Disposable>(item: T): T {\n this.disposables.add(item);\n return item;\n }\n\n public async dispose(): Promise<void> {\n let errorCount = 0;\n const disposables = Array.from(this.disposables);\n await Promise.all(\n disposables.map(async (d) => {\n try {\n await d.dispose?.();\n } catch (err) {\n console.error(`Failed to dispose: ${(err as Error).stack || err}`);\n errorCount++;\n }\n }),\n );\n\n // Clear the set after attempting to dispose all items\n this.disposables.clear();\n\n if (errorCount) {\n throw new Error(`Failed to dispose ${errorCount} disposable(s)`);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudpackCommand.d.ts","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC/G,OAAO,KAAK,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B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,yDAAyD;IACzD,WAAW,CAAC,EAAE;QACZ;;;WAGG;QACH,QAAQ,EAAE,mBAAmB,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAEF,mDAAmD;IACnD,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAEpC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,aAAa,CAAC,GAAG,IAAI,CAAC;CACvD;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAgB,CAAC,QAAQ,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM;IAC9E,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,iBAAiB,CAAmC;IAE5D;;;OAGG;gBAGD,MAAM,EAAE,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG;QACrD,cAAc,EAAE,cAAc,CAAC;QAC/B,+DAA+D;QAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB;IAqEH,8BAA8B;IACvB,aAAa,CAAC,aAAa,SAAS,MAAM,EAAE,eAAe,SAAS,MAAM,GAAG,KAAK,EACvF,MAAM,EAAE,sBAAsB,CAAC,aAAa,EAAE,eAAe,CAAC,GAC7D,gBAAgB,CAAC,aAAa,EAAE,eAAe,CAAC;IAQnD,qEAAqE;IACxD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAWjC,qGAAqG;IACrG,OAAO,CAAC,aAAa;IAMrB,iGAAiG;IACjG,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,UAAU;CAqCnB"}
|
|
@@ -64,6 +64,7 @@ export class CloudpackCommand {
|
|
|
64
64
|
.default(!environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI),
|
|
65
65
|
logFile: new Option('--log-file', 'Write a log file with all console output.').helpGroup(optionGroups.logging),
|
|
66
66
|
cachePath: new Option('--cache-path <path>', 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.').helpGroup(optionGroups.common),
|
|
67
|
+
config: new Option('-c, --config <filename>', 'Custom config file name to use instead of cloudpack.config.json.').helpGroup(optionGroups.common),
|
|
67
68
|
define: new Option('--define <key=value>', 'Define a global variable. Can be specified multiple times.')
|
|
68
69
|
.helpGroup(optionGroups.common)
|
|
69
70
|
.argParser(parseDefine),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAI/G,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0DjE;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IACnB,QAAQ,CAAU;IAClB,eAAe,CAAiB;IAChC,iBAAiB,CAAmC;IAE5D;;;OAGG;IACH;IACE,4EAA4E;IAC5E,MAIC;QAED,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,gBAAgB,CAAC;QAEjD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,OAAO,CAAC,OAAO,CAAC,MAAM,CA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H,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,WAAqF;QACtG,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,0FAA0F;QAC1F,iGAAiG;QACjG,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;YACxB,iEAAiE;YACjE,iEAAiE;YACjE,MAAM,aAAa,GAAG,OAAO,CAAC,aAAyB,CAAC;YAExD,kEAAkE;YAClE,kGAAkG;YAClG,gGAAgG;YAChG,6EAA6E;YAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,EAA4B,CAAC;YAEpE,kGAAkG;YAClG,wBAAwB;YACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEpG,0CAA0C;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,eAAe;gBACpC,IAAI;gBACJ,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;aACzC,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { CommandExecutor, type CommandExecutorParams } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { parseFeature } from './parseFeature.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { parseDefine } from './parseDefine.js';\nimport { CloudpackHelp, optionGroups } from './CloudpackHelp.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object>\n extends Pick<CommandExecutorParams, 'discoverAppPaths'> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /**\n * Options specific to this command. The record ensures that all options are available in the CLI.\n * Allow multiple options for the same key since commander supports it with negatable options.\n */\n options?: Record<keyof TOptions, Option | Option[]>; //\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n this._discoverAppPaths = params.discoverAppPaths;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n\n const isTopLevel = !params.parent;\n command.createHelp = () => new CloudpackHelp({ isTopLevel });\n // set the default help group for options\n command.optionsGroup(optionGroups.default);\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details in logging.').helpGroup(optionGroups.logging),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).')\n .conflicts('verbose')\n .helpGroup(optionGroups.logging),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.')\n .conflicts('verbose')\n .conflicts('debug')\n .helpGroup(optionGroups.logging),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.')\n .helpGroup(optionGroups.logging)\n .default(!environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI),\n logFile: new Option('--log-file', 'Write a log file with all console output.').helpGroup(optionGroups.logging),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ).helpGroup(optionGroups.common),\n define: new Option('--define <key=value>', 'Define a global variable. Can be specified multiple times.')\n .helpGroup(optionGroups.common)\n .argParser(parseDefine),\n features: new Option('--features <featureNames...>', 'Enable experimental features.')\n .helpGroup(optionGroups.common)\n .argParser(parseFeature),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>): void {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option | Option[]>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, optionOrOptions] of Object.entries(options) as [keyof TAddOptions, Option | Option[]][]) {\n const optionArray = Array.isArray(optionOrOptions) ? optionOrOptions : [optionOrOptions];\n for (const option of optionArray) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>): void {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n discoverAppPaths: this._discoverAppPaths,\n });\n await commandExecutor.execute();\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAI/G,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0DjE;;;;;;;GAOG;AACH,MAAM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AC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,eAAe;gBACpC,IAAI;gBACJ,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;aACzC,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { CommandExecutor, type CommandExecutorParams } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { parseFeature } from './parseFeature.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { parseDefine } from './parseDefine.js';\nimport { CloudpackHelp, optionGroups } from './CloudpackHelp.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object>\n extends Pick<CommandExecutorParams, 'discoverAppPaths'> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /**\n * Options specific to this command. The record ensures that all options are available in the CLI.\n * Allow multiple options for the same key since commander supports it with negatable options.\n */\n options?: Record<keyof TOptions, Option | Option[]>; //\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n this._discoverAppPaths = params.discoverAppPaths;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n\n const isTopLevel = !params.parent;\n command.createHelp = () => new CloudpackHelp({ isTopLevel });\n // set the default help group for options\n command.optionsGroup(optionGroups.default);\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details in logging.').helpGroup(optionGroups.logging),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).')\n .conflicts('verbose')\n .helpGroup(optionGroups.logging),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.')\n .conflicts('verbose')\n .conflicts('debug')\n .helpGroup(optionGroups.logging),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.')\n .helpGroup(optionGroups.logging)\n .default(!environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI),\n logFile: new Option('--log-file', 'Write a log file with all console output.').helpGroup(optionGroups.logging),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ).helpGroup(optionGroups.common),\n config: new Option(\n '-c, --config <filename>',\n 'Custom config file name to use instead of cloudpack.config.json.',\n ).helpGroup(optionGroups.common),\n define: new Option('--define <key=value>', 'Define a global variable. Can be specified multiple times.')\n .helpGroup(optionGroups.common)\n .argParser(parseDefine),\n features: new Option('--features <featureNames...>', 'Enable experimental features.')\n .helpGroup(optionGroups.common)\n .argParser(parseFeature),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>): void {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option | Option[]>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, optionOrOptions] of Object.entries(options) as [keyof TAddOptions, Option | Option[]][]) {\n const optionArray = Array.isArray(optionOrOptions) ? optionOrOptions : [optionOrOptions];\n for (const option of optionArray) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>): void {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n discoverAppPaths: this._discoverAppPaths,\n });\n await commandExecutor.execute();\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAqB,MAAM,2BAA2B,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAQ7E,MAAM,MAAM,0BAA0B,GAAG,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAEpF,MAAM,WAAW,qBAAqB,CAAC,QAAQ,SAAS,0BAA0B,GAAG,0BAA0B;IAC7G,iCAAiC;IACjC,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,2CAA2C;IAC3C,OAAO,EAAE,QAAQ,CAAC;IAElB,uCAAuC;IACvC,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAEjC,0CAA0C;IAC1C,cAAc,EAAE,cAAc,CAAC;IAE/B,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAED;;GAEG;AAEH,qBAAa,eAAe,CAAC,QAAQ,SAAS,0BAA0B;IACtE,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,eAAe,C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C,CAAC;IAEjC,0CAA0C;IAC1C,cAAc,EAAE,cAAc,CAAC;IAE/B,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAED;;GAEG;AAEH,qBAAa,eAAe,CAAC,QAAQ,SAAS,0BAA0B;IACtE,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,iBAAiB,CAAmC;IAC5D,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,YAAY,CAAC,CAAa;IAClC,OAAO,CAAC,sBAAsB,CAAC,CAAe;IAE9C,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAmC;WAE9C,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;gBASzD,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC;IAWnD,uBAAuB;IAEV,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA2ErC;;;OAGG;YACW,mBAAmB;IA0GjC,qEAAqE;IACrE,OAAO,CAAC,+BAA+B;YAazB,cAAc;IAkD5B,SAAS,CAAC,cAAc,QAAO,IAAI,CAgBjC;IAEF;;;OAGG;cACa,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;CAgCjE"}
|
|
@@ -109,9 +109,13 @@ export class CommandExecutor {
|
|
|
109
109
|
}
|
|
110
110
|
catch (error) {
|
|
111
111
|
// If an error occurs, exit the process with a non-zero exit code.
|
|
112
|
+
const err = error;
|
|
113
|
+
const message = err.isExpected
|
|
114
|
+
? err.message // Only show message for expected errors
|
|
115
|
+
: err.stack || err.message || String(error); // Show full stack for unexpected errors
|
|
112
116
|
await this._exit({
|
|
113
117
|
hasErrors: true,
|
|
114
|
-
message
|
|
118
|
+
message,
|
|
115
119
|
});
|
|
116
120
|
}
|
|
117
121
|
}
|
|
@@ -215,6 +219,7 @@ export class CommandExecutor {
|
|
|
215
219
|
return {
|
|
216
220
|
mode: options.mode,
|
|
217
221
|
logBundleInfo: options.logBundleInfo,
|
|
222
|
+
configFileName: options.config,
|
|
218
223
|
// Handle --bundler by passing it as a universal package override, which will be appended
|
|
219
224
|
// to any user-provided packageSettings so that it takes precedence.
|
|
220
225
|
extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,GAAG,EACH,oBAAoB,EACpB,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAA2C,MAAM,yBAAyB,CAAC;AAClG,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,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,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,KAAK,GAAG,CAAC;qBAC1C,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,0DAA0D,YAAY,GAAG,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAE3B,sCAAsC;YACtC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;YAEzC,8DAA8D;YAC9D,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;gBAC5B,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;gBAC3C,QAAQ,EAAE,QAAQ,KAAK,CAAC;aACzB,CAAC,CAAC;QACL,CAAC;QAED,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3C,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC","sourcesContent":["import type { ReadConfigOptions } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { startTelemetry, type TelemetryApi, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { discoverRemoteAppPaths } from './discoverRemoteAppPaths.js';\nimport { discoverLocalAppPaths } from './discoverLocalAppPaths.js';\nimport { TaskRunner } from '@ms-cloudpack/api-server';\nimport { readLocalConfigs } from './readLocalConfigs.js';\nimport { readRemoteConfigs } from './readRemoteConfigs.js';\nimport { getCliStartTime } from './getCliStartTime.js';\n\nexport type BaseCommandExecutorOptions = SharedOptions & Pick<ReusedOptions, 'app'>;\n\nexport interface CommandExecutorParams<TOptions extends BaseCommandExecutorOptions = BaseCommandExecutorOptions> {\n /** Command-specific arguments */\n args: string[];\n\n /** Command-specific and shared options. */\n options: TOptions;\n\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n\n /**\n * By default, the command will run against `cwd` (usually `process.cwd()`).\n * If this option is set, attempt to discover app path(s) instead.\n * (`cwd` will still be preferred if it has a `cloudpack.config.json`.)\n * See {@link AppPathDiscoveryMode} for details.\n */\n discoverAppPaths?: AppPathDiscoveryMode;\n}\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\n// 'app' is an optional reused option\nexport class CommandExecutor<TOptions extends BaseCommandExecutorOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _onInterrupt?: () => void;\n private _getMessageOnInterrupt?: () => string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances = new Set<CommandExecutor<any>>();\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = new Set();\n }\n\n constructor(params: CommandExecutorParams<TOptions>) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._discoverAppPaths = params.discoverAppPaths;\n this._reporter = new TaskReporter();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute(): Promise<void> {\n CommandExecutor._activeInstances.add(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n if (!environmentInfo.isJest) {\n process.on('SIGINT', this._sigintHandler);\n }\n\n const contexts = await this._initializeContexts();\n\n if (!Array.isArray(contexts)) {\n await this._exit(contexts);\n return;\n }\n\n const spanName = `${this._verb.toUpperCase().replace(/ /g, '_')}_EXECUTE`;\n const results: CommandExitParams[] = [];\n\n for (const context of contexts) {\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await context.telemetryClient.tracer.startActiveSpan(spanName, async (span) => {\n this._onInterrupt = () => {\n span.setAttribute('isInterrupted', true);\n span.end();\n };\n\n return this._execute({\n ...context,\n span,\n isMultiApp: contexts.length > 1,\n args: this._args,\n options: this._options,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n });\n if (result?.isInterrupted) {\n return await this._exit(result);\n }\n if (result) {\n results.push(result);\n } else if ((result as unknown) !== null) {\n // If the command returned null, this means it should keep running (e.g. start).\n // We disallow returning undefined to avoid accidents.\n throw new Error('Command executor must return exit options or null');\n }\n this._onInterrupt = undefined;\n }\n\n if (results.length) {\n // If one or more apps returned a result, exit.\n await this._exit({\n message: results.map((r) => r.message).join('\\n'),\n hasErrors: results.some((r) => r.hasErrors),\n // If any app returned a non-zero exit code, use that.\n exitCode: results.find(({ exitCode }) => !!exitCode)?.exitCode,\n });\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: (error as Error).stack || (error as Error).message || String(error),\n });\n }\n }\n\n /**\n * Determine the app paths and initialize the context for each app.\n * @returns Context(s), or an exit options object if there was an error. (might also throw on error)\n */\n private async _initializeContexts(): Promise<AppCommandContext[] | CommandExitParams> {\n let appPaths: string[];\n\n if (this._discoverAppPaths) {\n // Search for cloudpack configs to determine the app path(s)\n const appPathsResult =\n this._discoverAppPaths === 'remote'\n ? await discoverRemoteAppPaths({\n options: {\n login: (this._options as unknown as Pick<ReusedOptions, 'login'>).login,\n cachePath: this._options.cachePath,\n desiredApp: this._options.app,\n },\n context: {\n reporter: this._reporter,\n },\n })\n : await discoverLocalAppPaths({\n cwd: this._programOptions.cwd,\n discover: this._discoverAppPaths,\n desiredApp: this._options.app,\n });\n if (!Array.isArray(appPathsResult)) {\n // This means there was an error (or the user cancelled) while getting app paths.\n return appPathsResult;\n }\n appPaths = appPathsResult;\n } else {\n // Just use the cwd\n appPaths = [this._programOptions.cwd];\n }\n\n const configOptions = this._getConfigOptionsFromCliOptions();\n\n // The task runner is shared between all apps so that task results can potentially be reused.\n const taskRunner = new TaskRunner();\n\n const readConfig = this._discoverAppPaths === 'remote' ? readRemoteConfigs : readLocalConfigs;\n const configs = await readConfig(appPaths, {\n ...configOptions,\n extraFeatures: this._options.features,\n extraDefineFlags: this._options.define,\n enableDefaultFeatures: true,\n });\n\n const helpMessages = new Set<string>(\n Object.values(configs)\n .filter((c) => c.helpMessage)\n .map((c) => c.helpMessage) as string[],\n );\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n logFile: !!this._options.logFile,\n cwd: this._programOptions.cwd,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n const contexts: AppCommandContext[] = [];\n\n const logLevel = this._options.verbose ? 'VERBOSE' : this._options.debug ? 'DEBUG' : undefined;\n if (!this._options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryApi = startTelemetry({\n productVersion: getVersion(import.meta.url),\n logLevel,\n serviceName: 'cli',\n });\n\n this._autoDisposableList.add({\n dispose: () => telemetryApi.shutdown(),\n });\n\n for (const appPath of Object.keys(configs)) {\n const config = configs[appPath];\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config, telemetryApi);\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n taskRunner,\n });\n }\n\n return contexts;\n }\n\n /** Translate certain CLI options into options for `readConfig()`. */\n private _getConfigOptionsFromCliOptions(): ReadConfigOptions {\n // These options don't exist for all commands, but that's fine.\n const options = this._options as Partial<ReusedOptions & SharedOptions>;\n return {\n mode: options.mode,\n logBundleInfo: options.logBundleInfo,\n // Handle --bundler by passing it as a universal package override, which will be appended\n // to any user-provided packageSettings so that it takes precedence.\n extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,\n };\n }\n\n private async _initTelemetry(\n appName: string | undefined,\n config: CloudpackConfig,\n telemetryApi: TelemetryApi,\n ): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n\n const connectionString =\n this._programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\n\n const telemetryClient = await telemetryApi.createClient(connectionString);\n\n telemetryClient.tracer.startSpan('CLI_ENTRY', { startTime: getCliStartTime() }).end();\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode,\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = (): void => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n this._onInterrupt?.();\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams): Promise<never> {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt?.() || 'Interrupted by user' : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n await this._reporter.complete({\n summary: hasErrors ? red(message) : message,\n showHelp: exitCode !== 0,\n });\n }\n\n CommandExecutor._activeInstances.delete(this);\n process.off('SIGINT', this._sigintHandler);\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,GAAG,EACH,oBAAoB,EACpB,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAA2C,MAAM,yBAAyB,CAAC;AAClG,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAoC,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA6BvD;;GAEG;AACH,qCAAqC;AACrC,MAAM,OAAO,eAAe;IAClB,QAAQ,CAAW;IACnB,QAAQ,CAA0B;IAClC,eAAe,CAAiB;IAChC,K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AE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,KAAK,GAAG,CAAC;qBAC1C,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,0DAA0D,YAAY,GAAG,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAE3B,sCAAsC;YACtC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;YAEzC,8DAA8D;YAC9D,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;gBAC5B,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;gBAC3C,QAAQ,EAAE,QAAQ,KAAK,CAAC;aACzB,CAAC,CAAC;QACL,CAAC;QAED,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3C,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC","sourcesContent":["import type { ReadConfigOptions } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { startTelemetry, type TelemetryApi, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { discoverRemoteAppPaths } from './discoverRemoteAppPaths.js';\nimport { discoverLocalAppPaths } from './discoverLocalAppPaths.js';\nimport { TaskRunner } from '@ms-cloudpack/api-server';\nimport { readLocalConfigs, type InvalidCloudpackConfigError } from './readLocalConfigs.js';\nimport { readRemoteConfigs } from './readRemoteConfigs.js';\nimport { getCliStartTime } from './getCliStartTime.js';\n\nexport type BaseCommandExecutorOptions = SharedOptions & Pick<ReusedOptions, 'app'>;\n\nexport interface CommandExecutorParams<TOptions extends BaseCommandExecutorOptions = BaseCommandExecutorOptions> {\n /** Command-specific arguments */\n args: string[];\n\n /** Command-specific and shared options. */\n options: TOptions;\n\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n\n /**\n * By default, the command will run against `cwd` (usually `process.cwd()`).\n * If this option is set, attempt to discover app path(s) instead.\n * (`cwd` will still be preferred if it has a `cloudpack.config.json`.)\n * See {@link AppPathDiscoveryMode} for details.\n */\n discoverAppPaths?: AppPathDiscoveryMode;\n}\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\n// 'app' is an optional reused option\nexport class CommandExecutor<TOptions extends BaseCommandExecutorOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _onInterrupt?: () => void;\n private _getMessageOnInterrupt?: () => string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances = new Set<CommandExecutor<any>>();\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = new Set();\n }\n\n constructor(params: CommandExecutorParams<TOptions>) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._discoverAppPaths = params.discoverAppPaths;\n this._reporter = new TaskReporter();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute(): Promise<void> {\n CommandExecutor._activeInstances.add(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n if (!environmentInfo.isJest) {\n process.on('SIGINT', this._sigintHandler);\n }\n\n const contexts = await this._initializeContexts();\n\n if (!Array.isArray(contexts)) {\n await this._exit(contexts);\n return;\n }\n\n const spanName = `${this._verb.toUpperCase().replace(/ /g, '_')}_EXECUTE`;\n const results: CommandExitParams[] = [];\n\n for (const context of contexts) {\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await context.telemetryClient.tracer.startActiveSpan(spanName, async (span) => {\n this._onInterrupt = () => {\n span.setAttribute('isInterrupted', true);\n span.end();\n };\n\n return this._execute({\n ...context,\n span,\n isMultiApp: contexts.length > 1,\n args: this._args,\n options: this._options,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n });\n if (result?.isInterrupted) {\n return await this._exit(result);\n }\n if (result) {\n results.push(result);\n } else if ((result as unknown) !== null) {\n // If the command returned null, this means it should keep running (e.g. start).\n // We disallow returning undefined to avoid accidents.\n throw new Error('Command executor must return exit options or null');\n }\n this._onInterrupt = undefined;\n }\n\n if (results.length) {\n // If one or more apps returned a result, exit.\n await this._exit({\n message: results.map((r) => r.message).join('\\n'),\n hasErrors: results.some((r) => r.hasErrors),\n // If any app returned a non-zero exit code, use that.\n exitCode: results.find(({ exitCode }) => !!exitCode)?.exitCode,\n });\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n const err = error as InvalidCloudpackConfigError;\n const message = err.isExpected\n ? err.message // Only show message for expected errors\n : err.stack || err.message || String(error); // Show full stack for unexpected errors\n\n await this._exit({\n hasErrors: true,\n message,\n });\n }\n }\n\n /**\n * Determine the app paths and initialize the context for each app.\n * @returns Context(s), or an exit options object if there was an error. (might also throw on error)\n */\n private async _initializeContexts(): Promise<AppCommandContext[] | CommandExitParams> {\n let appPaths: string[];\n\n if (this._discoverAppPaths) {\n // Search for cloudpack configs to determine the app path(s)\n const appPathsResult =\n this._discoverAppPaths === 'remote'\n ? await discoverRemoteAppPaths({\n options: {\n login: (this._options as unknown as Pick<ReusedOptions, 'login'>).login,\n cachePath: this._options.cachePath,\n desiredApp: this._options.app,\n },\n context: {\n reporter: this._reporter,\n },\n })\n : await discoverLocalAppPaths({\n cwd: this._programOptions.cwd,\n discover: this._discoverAppPaths,\n desiredApp: this._options.app,\n });\n if (!Array.isArray(appPathsResult)) {\n // This means there was an error (or the user cancelled) while getting app paths.\n return appPathsResult;\n }\n appPaths = appPathsResult;\n } else {\n // Just use the cwd\n appPaths = [this._programOptions.cwd];\n }\n\n const configOptions = this._getConfigOptionsFromCliOptions();\n\n // The task runner is shared between all apps so that task results can potentially be reused.\n const taskRunner = new TaskRunner();\n\n const readConfig = this._discoverAppPaths === 'remote' ? readRemoteConfigs : readLocalConfigs;\n const configs = await readConfig(appPaths, {\n ...configOptions,\n extraFeatures: this._options.features,\n extraDefineFlags: this._options.define,\n enableDefaultFeatures: true,\n });\n\n const helpMessages = new Set<string>(\n Object.values(configs)\n .filter((c) => c.helpMessage)\n .map((c) => c.helpMessage) as string[],\n );\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n logFile: !!this._options.logFile,\n cwd: this._programOptions.cwd,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n const contexts: AppCommandContext[] = [];\n\n const logLevel = this._options.verbose ? 'VERBOSE' : this._options.debug ? 'DEBUG' : undefined;\n if (!this._options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryApi = startTelemetry({\n productVersion: getVersion(import.meta.url),\n logLevel,\n serviceName: 'cli',\n });\n\n this._autoDisposableList.add({\n dispose: () => telemetryApi.shutdown(),\n });\n\n for (const appPath of Object.keys(configs)) {\n const config = configs[appPath];\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config, telemetryApi);\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n taskRunner,\n });\n }\n\n return contexts;\n }\n\n /** Translate certain CLI options into options for `readConfig()`. */\n private _getConfigOptionsFromCliOptions(): ReadConfigOptions {\n // These options don't exist for all commands, but that's fine.\n const options = this._options as Partial<ReusedOptions & SharedOptions>;\n return {\n mode: options.mode,\n logBundleInfo: options.logBundleInfo,\n configFileName: options.config,\n // Handle --bundler by passing it as a universal package override, which will be appended\n // to any user-provided packageSettings so that it takes precedence.\n extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,\n };\n }\n\n private async _initTelemetry(\n appName: string | undefined,\n config: CloudpackConfig,\n telemetryApi: TelemetryApi,\n ): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n\n const connectionString =\n this._programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\n\n const telemetryClient = await telemetryApi.createClient(connectionString);\n\n telemetryClient.tracer.startSpan('CLI_ENTRY', { startTime: getCliStartTime() }).end();\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode,\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = (): void => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n this._onInterrupt?.();\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams): Promise<never> {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt?.() || 'Interrupted by user' : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n await this._reporter.complete({\n summary: hasErrors ? red(message) : message,\n showHelp: exitCode !== 0,\n });\n }\n\n CommandExecutor._activeInstances.delete(this);\n process.off('SIGINT', this._sigintHandler);\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { CloudpackConfig } from '@ms-cloudpack/common-types';
|
|
2
2
|
import { type ReadConfigOptions } from '@ms-cloudpack/config';
|
|
3
3
|
export declare class InvalidCloudpackConfigError extends Error {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* If true, only the error message will be shown (no stack trace).
|
|
6
|
+
* Used for expected errors like missing config files.
|
|
7
|
+
*/
|
|
8
|
+
isExpected?: boolean;
|
|
9
|
+
constructor(message: string, options?: {
|
|
10
|
+
isExpected?: boolean;
|
|
11
|
+
});
|
|
5
12
|
}
|
|
6
13
|
/**
|
|
7
14
|
* Read local cloudpack configs for multiple apps, and augment with the given options.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readLocalConfigs.d.ts","sourceRoot":"","sources":["../../src/utilities/readLocalConfigs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE1E,qBAAa,2BAA4B,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"readLocalConfigs.d.ts","sourceRoot":"","sources":["../../src/utilities/readLocalConfigs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE1E,qBAAa,2BAA4B,SAAQ,KAAK;IACpD;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;gBAET,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE;CAKhE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAAE,EAClB,iBAAiB,EAAE,iBAAiB,GACnC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAkB1C"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { readConfig } from '@ms-cloudpack/config';
|
|
2
2
|
export class InvalidCloudpackConfigError extends Error {
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* If true, only the error message will be shown (no stack trace).
|
|
5
|
+
* Used for expected errors like missing config files.
|
|
6
|
+
*/
|
|
7
|
+
isExpected;
|
|
8
|
+
constructor(message, options) {
|
|
4
9
|
super(message);
|
|
5
10
|
this.name = 'InvalidCloudpackConfigError';
|
|
11
|
+
this.isExpected = options?.isExpected;
|
|
6
12
|
}
|
|
7
13
|
}
|
|
8
14
|
/**
|
|
@@ -16,7 +22,9 @@ export async function readLocalConfigs(appPaths, readConfigOptions) {
|
|
|
16
22
|
config = await readConfig(appPath, readConfigOptions);
|
|
17
23
|
}
|
|
18
24
|
catch (err) {
|
|
19
|
-
|
|
25
|
+
const errorMessage = err.message || String(err);
|
|
26
|
+
const isExpected = errorMessage.includes('Config file not found:');
|
|
27
|
+
throw new InvalidCloudpackConfigError(`Invalid cloudpack config in ${appPath}: ${errorMessage}`, { isExpected });
|
|
20
28
|
}
|
|
21
29
|
configs[appPath] = config;
|
|
22
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readLocalConfigs.js","sourceRoot":"","sources":["../../src/utilities/readLocalConfigs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAA0B,MAAM,sBAAsB,CAAC;AAE1E,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD,YAAY,OAAe;
|
|
1
|
+
{"version":3,"file":"readLocalConfigs.js","sourceRoot":"","sources":["../../src/utilities/readLocalConfigs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAA0B,MAAM,sBAAsB,CAAC;AAE1E,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD;;;OAGG;IACH,UAAU,CAAW;IAErB,YAAY,OAAe,EAAE,OAAkC;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;QAC1C,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;IACxC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAkB,EAClB,iBAAoC;IAEpC,MAAM,OAAO,GAAoC,EAAE,CAAC;IAEpD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,MAAuB,CAAC;QAE5B,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,YAAY,GAAI,GAAa,CAAC,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;YAC3D,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAC;YACnE,MAAM,IAAI,2BAA2B,CAAC,+BAA+B,OAAO,KAAK,YAAY,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;QACnH,CAAC;QAED,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;IAC5B,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/common-types';\nimport { readConfig, type ReadConfigOptions } from '@ms-cloudpack/config';\n\nexport class InvalidCloudpackConfigError extends Error {\n /**\n * If true, only the error message will be shown (no stack trace).\n * Used for expected errors like missing config files.\n */\n isExpected?: boolean;\n\n constructor(message: string, options?: { isExpected?: boolean }) {\n super(message);\n this.name = 'InvalidCloudpackConfigError';\n this.isExpected = options?.isExpected;\n }\n}\n\n/**\n * Read local cloudpack configs for multiple apps, and augment with the given options.\n */\nexport async function readLocalConfigs(\n appPaths: string[],\n readConfigOptions: ReadConfigOptions,\n): Promise<Record<string, CloudpackConfig>> {\n const configs: Record<string, CloudpackConfig> = {};\n\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, readConfigOptions);\n } catch (err) {\n const errorMessage = (err as Error).message || String(err);\n const isExpected = errorMessage.includes('Config file not found:');\n throw new InvalidCloudpackConfigError(`Invalid cloudpack config in ${appPath}: ${errorMessage}`, { isExpected });\n }\n\n configs[appPath] = config;\n }\n\n return configs;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.1",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,24 +18,24 @@
|
|
|
18
18
|
"cloudpack": "./bin/cloudpack.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ms-cloudpack/api-server": "^0.64.
|
|
22
|
-
"@ms-cloudpack/app-server": "^0.20.
|
|
23
|
-
"@ms-cloudpack/bundler": "^0.25.
|
|
24
|
-
"@ms-cloudpack/bundler-capabilities": "^0.2.
|
|
25
|
-
"@ms-cloudpack/common-types": "^0.27.
|
|
26
|
-
"@ms-cloudpack/config": "^0.
|
|
27
|
-
"@ms-cloudpack/create-express-app": "^1.10.
|
|
21
|
+
"@ms-cloudpack/api-server": "^0.64.16",
|
|
22
|
+
"@ms-cloudpack/app-server": "^0.20.8",
|
|
23
|
+
"@ms-cloudpack/bundler": "^0.25.29",
|
|
24
|
+
"@ms-cloudpack/bundler-capabilities": "^0.2.38",
|
|
25
|
+
"@ms-cloudpack/common-types": "^0.27.3",
|
|
26
|
+
"@ms-cloudpack/config": "^0.38.0",
|
|
27
|
+
"@ms-cloudpack/create-express-app": "^1.10.47",
|
|
28
28
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
29
29
|
"@ms-cloudpack/json-utilities": "^0.1.10",
|
|
30
|
-
"@ms-cloudpack/link-proxy": "^0.2.
|
|
31
|
-
"@ms-cloudpack/overlay": "^0.19.
|
|
32
|
-
"@ms-cloudpack/package-utilities": "^12.3.
|
|
30
|
+
"@ms-cloudpack/link-proxy": "^0.2.30",
|
|
31
|
+
"@ms-cloudpack/overlay": "^0.19.26",
|
|
32
|
+
"@ms-cloudpack/package-utilities": "^12.3.24",
|
|
33
33
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
34
|
-
"@ms-cloudpack/path-utilities": "^3.1.
|
|
35
|
-
"@ms-cloudpack/remote-cache": "^0.11.
|
|
36
|
-
"@ms-cloudpack/setup-utilities": "^0.5.
|
|
34
|
+
"@ms-cloudpack/path-utilities": "^3.1.18",
|
|
35
|
+
"@ms-cloudpack/remote-cache": "^0.11.35",
|
|
36
|
+
"@ms-cloudpack/setup-utilities": "^0.5.39",
|
|
37
37
|
"@ms-cloudpack/task-reporter": "^0.17.2",
|
|
38
|
-
"@ms-cloudpack/telemetry": "^0.11.
|
|
38
|
+
"@ms-cloudpack/telemetry": "^0.11.36",
|
|
39
39
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
40
40
|
"commander": "^14.0.0",
|
|
41
41
|
"cross-spawn": "^7.0.3",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"workspace-tools": "^0.38.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@ms-cloudpack/common-types": "^0.27.
|
|
51
|
+
"@ms-cloudpack/common-types": "^0.27.3",
|
|
52
52
|
"@ms-cloudpack/common-types-browser": "^0.6.2",
|
|
53
53
|
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
54
54
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
@@ -61,16 +61,18 @@
|
|
|
61
61
|
"scripts": {
|
|
62
62
|
"api": "cloudpack-scripts api",
|
|
63
63
|
"build:watch": "cloudpack-scripts build-watch",
|
|
64
|
-
"build": "cloudpack-scripts build",
|
|
64
|
+
"build": "cloudpack-scripts build && yarn schema",
|
|
65
65
|
"lint:update": "cloudpack-scripts lint-update",
|
|
66
66
|
"lint": "cloudpack-scripts lint",
|
|
67
67
|
"prepack": "cp .npmignore lib/.npmignore",
|
|
68
|
+
"schema": "cloudpack-scripts copy ../common-types/schema ./schema",
|
|
68
69
|
"test:update": "cloudpack-scripts test-update",
|
|
69
70
|
"test:watch": "cloudpack-scripts test-watch",
|
|
70
71
|
"test": "cloudpack-scripts test"
|
|
71
72
|
},
|
|
72
73
|
"files": [
|
|
73
|
-
"lib/**/!(*.test.*)"
|
|
74
|
+
"lib/**/!(*.test.*)",
|
|
75
|
+
"schema"
|
|
74
76
|
],
|
|
75
77
|
"engines": {
|
|
76
78
|
"node": ">=20.11.0"
|