@ms-cloudpack/cli 0.77.24 → 0.77.26
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/utilities/AutoDisposableList.d.ts +6 -0
- package/lib/utilities/AutoDisposableList.d.ts.map +1 -1
- package/lib/utilities/AutoDisposableList.js +6 -0
- package/lib/utilities/AutoDisposableList.js.map +1 -1
- package/lib/utilities/CommandExecutor.d.ts +7 -1
- package/lib/utilities/CommandExecutor.d.ts.map +1 -1
- package/lib/utilities/CommandExecutor.js +72 -73
- package/lib/utilities/CommandExecutor.js.map +1 -1
- package/package.json +21 -21
|
@@ -2,6 +2,12 @@ import type { Disposable } from '../types/Disposable.js';
|
|
|
2
2
|
export declare class AutoDisposableList {
|
|
3
3
|
private readonly disposables;
|
|
4
4
|
add<T extends Disposable>(item: T): T;
|
|
5
|
+
/**
|
|
6
|
+
* Dispose all registered disposables.
|
|
7
|
+
* If any disposables throw, it will be logged, and a single error will be thrown at the end.
|
|
8
|
+
*
|
|
9
|
+
* After each call, the registered disposables will be cleared, so the list can be reused.
|
|
10
|
+
*/
|
|
5
11
|
dispose(): Promise<void>;
|
|
6
12
|
}
|
|
7
13
|
//# sourceMappingURL=AutoDisposableList.d.ts.map
|
|
@@ -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,CAAyB;IAE9C,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC;
|
|
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;IAK5C;;;;;OAKG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAqBtC"}
|
|
@@ -4,6 +4,12 @@ export class AutoDisposableList {
|
|
|
4
4
|
this.disposables.add(item);
|
|
5
5
|
return item;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Dispose all registered disposables.
|
|
9
|
+
* If any disposables throw, it will be logged, and a single error will be thrown at the end.
|
|
10
|
+
*
|
|
11
|
+
* After each call, the registered disposables will be cleared, so the list can be reused.
|
|
12
|
+
*/
|
|
7
13
|
async dispose() {
|
|
8
14
|
let errorCount = 0;
|
|
9
15
|
const disposables = Array.from(this.disposables);
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;IAED;;;;;OAKG;IACI,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 /**\n * Dispose all registered disposables.\n * If any disposables throw, it will be logged, and a single error will be thrown at the end.\n *\n * After each call, the registered disposables will be cleared, so the list can be reused.\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"]}
|
|
@@ -48,8 +48,14 @@ export declare class CommandExecutor<TOptions extends SharedOptions> {
|
|
|
48
48
|
private static _activeInstances;
|
|
49
49
|
static exitAll(params: CommandExitParams): Promise<void>;
|
|
50
50
|
constructor(params: CommandExecutorParams<TOptions>);
|
|
51
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Run the command, including handling for restarts.
|
|
53
|
+
*/
|
|
52
54
|
execute(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Execute a single iteration of the command.
|
|
57
|
+
*/
|
|
58
|
+
private _executeOnce;
|
|
53
59
|
/**
|
|
54
60
|
* Determine the app paths and initialize the context for each app.
|
|
55
61
|
* @returns Context(s), or an exit options object if there was an error. (might also throw on error)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAe9D,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;AAS7E,MAAM,WAAW,qBAAqB,CAAC,QAAQ,SAAS,aAAa;IACnE,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,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAEnD;;;OAGG;IACH,oBAAoB,EAChB,CAAC,CACC,OAAO,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MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC;IAYnD;;OAEG;IAEU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA0BrC;;OAEG;YACW,YAAY;IAmE1B;;;OAGG;YACW,mBAAmB;IAmGjC,qEAAqE;IACrE,OAAO,CAAC,+BAA+B;YAgBzB,cAAc;IAkD5B,SAAS,CAAC,cAAc,QAAO,IAAI,CAgBjC;IAEF;;;OAGG;cACa,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;CAoCjE"}
|
|
@@ -51,82 +51,20 @@ export class CommandExecutor {
|
|
|
51
51
|
this._reporter = new TaskReporter();
|
|
52
52
|
this._autoDisposableList = new AutoDisposableList();
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Run the command, including handling for restarts.
|
|
56
|
+
*/
|
|
55
57
|
// This has to be a separate method because constructors can't be async.
|
|
56
58
|
async execute() {
|
|
57
59
|
CommandExecutor._activeInstances.add(this);
|
|
60
|
+
// Handle SIGINT (Ctrl+C) gracefully.
|
|
61
|
+
if (!environmentInfo.isJest) {
|
|
62
|
+
process.on('SIGINT', this._sigintHandler);
|
|
63
|
+
}
|
|
58
64
|
try {
|
|
59
|
-
// Handle SIGINT (Ctrl+C) gracefully.
|
|
60
|
-
if (!environmentInfo.isJest) {
|
|
61
|
-
process.on('SIGINT', this._sigintHandler);
|
|
62
|
-
}
|
|
63
65
|
let shouldRestart = false;
|
|
64
66
|
do {
|
|
65
|
-
|
|
66
|
-
if (!Array.isArray(contexts)) {
|
|
67
|
-
await this._exit(contexts);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const spanName = `${this._verb.toUpperCase().replace(/ /g, '_')}_EXECUTE`;
|
|
71
|
-
const results = [];
|
|
72
|
-
for (const context of contexts) {
|
|
73
|
-
// Call the execute function which is the real command logic
|
|
74
|
-
// (ie: real init command logic, real start command logic, etc.)
|
|
75
|
-
const result = await context.telemetryClient.tracer.startActiveSpan(spanName, async (span) => {
|
|
76
|
-
this._onInterrupt = () => {
|
|
77
|
-
span.setAttribute('isInterrupted', true);
|
|
78
|
-
span.end();
|
|
79
|
-
};
|
|
80
|
-
return this._execute({
|
|
81
|
-
...context,
|
|
82
|
-
span,
|
|
83
|
-
isMultiApp: contexts.length > 1,
|
|
84
|
-
args: this._args,
|
|
85
|
-
options: this._options,
|
|
86
|
-
isRestart: shouldRestart,
|
|
87
|
-
autoDispose: (disposable) => this._autoDisposableList.add(disposable),
|
|
88
|
-
setInterruptMessageHandler: (getMessage) => {
|
|
89
|
-
this._getMessageOnInterrupt = getMessage;
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
if (result?.isInterrupted) {
|
|
94
|
-
return await this._exit(result);
|
|
95
|
-
}
|
|
96
|
-
if (result) {
|
|
97
|
-
results.push(result);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
// If the command returned null, this means it should keep running (e.g. start).
|
|
101
|
-
// We disallow returning undefined to avoid accidents.
|
|
102
|
-
throw new Error('Command executor must return exit options or null');
|
|
103
|
-
}
|
|
104
|
-
this._onInterrupt = undefined;
|
|
105
|
-
}
|
|
106
|
-
// Clear the shouldRestart flag after passing it to the command execution.
|
|
107
|
-
// This ensures the next iteration starts with shouldRestart=false, until
|
|
108
|
-
// a command explicitly requests another restart by returning { restart: true }
|
|
109
|
-
if (shouldRestart) {
|
|
110
|
-
shouldRestart = false;
|
|
111
|
-
}
|
|
112
|
-
if (results.length) {
|
|
113
|
-
if (results.some((r) => r.restart)) {
|
|
114
|
-
shouldRestart = true;
|
|
115
|
-
// Dispose all registered disposables.
|
|
116
|
-
await this._autoDisposableList.dispose();
|
|
117
|
-
this._reporter.reset(true /* clearOutputs */);
|
|
118
|
-
console.warn(results.map((r) => r.message).join('\n'));
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
// If one or more apps returned a result, exit.
|
|
122
|
-
await this._exit({
|
|
123
|
-
message: results.map((r) => r.message).join('\n'),
|
|
124
|
-
hasErrors: results.some((r) => r.hasErrors),
|
|
125
|
-
// If any app returned a non-zero exit code, use that.
|
|
126
|
-
exitCode: results.find(({ exitCode }) => !!exitCode)?.exitCode,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
67
|
+
shouldRestart = await this._executeOnce(shouldRestart);
|
|
130
68
|
} while (shouldRestart);
|
|
131
69
|
}
|
|
132
70
|
catch (error) {
|
|
@@ -141,6 +79,69 @@ export class CommandExecutor {
|
|
|
141
79
|
});
|
|
142
80
|
}
|
|
143
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Execute a single iteration of the command.
|
|
84
|
+
*/
|
|
85
|
+
async _executeOnce(isRestart) {
|
|
86
|
+
const contexts = await this._initializeContexts();
|
|
87
|
+
if (!Array.isArray(contexts)) {
|
|
88
|
+
return await this._exit(contexts);
|
|
89
|
+
}
|
|
90
|
+
const spanName = `${this._verb.toUpperCase().replace(/ /g, '_')}_EXECUTE`;
|
|
91
|
+
const results = [];
|
|
92
|
+
for (const context of contexts) {
|
|
93
|
+
// Call the execute function which is the real command logic
|
|
94
|
+
// (ie: real init command logic, real start command logic, etc.)
|
|
95
|
+
const result = await context.telemetryClient.tracer.startActiveSpan(spanName, async (span) => {
|
|
96
|
+
this._onInterrupt = () => {
|
|
97
|
+
span.setAttribute('isInterrupted', true);
|
|
98
|
+
span.end();
|
|
99
|
+
};
|
|
100
|
+
return this._execute({
|
|
101
|
+
...context,
|
|
102
|
+
span,
|
|
103
|
+
isMultiApp: contexts.length > 1,
|
|
104
|
+
args: this._args,
|
|
105
|
+
options: this._options,
|
|
106
|
+
isRestart,
|
|
107
|
+
autoDispose: (disposable) => this._autoDisposableList.add(disposable),
|
|
108
|
+
setInterruptMessageHandler: (getMessage) => {
|
|
109
|
+
this._getMessageOnInterrupt = getMessage;
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
if (result?.isInterrupted) {
|
|
114
|
+
return await this._exit(result);
|
|
115
|
+
}
|
|
116
|
+
if (result) {
|
|
117
|
+
results.push(result);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// If the command returned null, this means it should keep running (e.g. start).
|
|
121
|
+
// We disallow returning undefined to avoid accidents.
|
|
122
|
+
throw new Error('Command executor must return exit options or null');
|
|
123
|
+
}
|
|
124
|
+
this._onInterrupt = undefined;
|
|
125
|
+
}
|
|
126
|
+
// Determine whether a command requested a restart in this iteration.
|
|
127
|
+
const shouldRestart = results.some((r) => r.restart);
|
|
128
|
+
if (shouldRestart) {
|
|
129
|
+
// Dispose all registered disposables.
|
|
130
|
+
await this._autoDisposableList.dispose();
|
|
131
|
+
this._reporter.reset(true /* clearOutputs */);
|
|
132
|
+
console.warn(results.map((r) => r.message).join('\n'));
|
|
133
|
+
}
|
|
134
|
+
else if (results.length) {
|
|
135
|
+
// If one or more apps returned a result, exit.
|
|
136
|
+
return await this._exit({
|
|
137
|
+
message: results.map((r) => r.message).join('\n'),
|
|
138
|
+
hasErrors: results.some((r) => r.hasErrors),
|
|
139
|
+
// If any app returned a non-zero exit code, use that.
|
|
140
|
+
exitCode: results.find(({ exitCode }) => !!exitCode)?.exitCode,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return shouldRestart;
|
|
144
|
+
}
|
|
144
145
|
/**
|
|
145
146
|
* Determine the app paths and initialize the context for each app.
|
|
146
147
|
* @returns Context(s), or an exit options object if there was an error. (might also throw on error)
|
|
@@ -157,9 +158,7 @@ export class CommandExecutor {
|
|
|
157
158
|
cachePath: this._options.cachePath,
|
|
158
159
|
desiredApp: app,
|
|
159
160
|
},
|
|
160
|
-
context: {
|
|
161
|
-
reporter: this._reporter,
|
|
162
|
-
},
|
|
161
|
+
context: { reporter: this._reporter },
|
|
163
162
|
})
|
|
164
163
|
: await discoverLocalAppPaths({
|
|
165
164
|
cwd: this._programOptions.cwd,
|
|
@@ -1 +1 @@
|
|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C,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';\nimport { commandEvents } from './commandEvents.js';\n\nexport interface CommandExecutorParams<TOptions extends SharedOptions> {\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 | undefined;\n\n /**\n * Apply any command-specific CLI options that need to be passed through to `readConfig`.\n * (Shared and reused options are applied automatically.)\n */\n applyOptionsToConfig:\n | ((\n options: Omit<TOptions, keyof (SharedOptions & ReusedOptions)>,\n ) => Pick<ReadConfigOptions, 'extraServerConfig'> | undefined)\n | undefined;\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 SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n private _applyOptionsToConfig: CommandExecutorParams<TOptions>['applyOptionsToConfig'];\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._applyOptionsToConfig = params.applyOptionsToConfig;\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 let shouldRestart = false;\n do {\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 isRestart: shouldRestart,\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 {\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 // Clear the shouldRestart flag after passing it to the command execution.\n // This ensures the next iteration starts with shouldRestart=false, until\n // a command explicitly requests another restart by returning { restart: true }\n if (shouldRestart) {\n shouldRestart = false;\n }\n\n if (results.length) {\n if (results.some((r) => r.restart)) {\n shouldRestart = true;\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n this._reporter.reset(true /* clearOutputs */);\n\n console.warn(results.map((r) => r.message).join('\\n'));\n } else {\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 }\n } while (shouldRestart);\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 { app, login } = this._options as unknown as Pick<ReusedOptions, 'app' | 'login'>;\n const appPathsResult =\n this._discoverAppPaths === 'remote'\n ? await discoverRemoteAppPaths({\n options: {\n login,\n cachePath: this._options.cachePath,\n desiredApp: app,\n },\n context: {\n reporter: this._reporter,\n },\n })\n : await discoverLocalAppPaths({\n cwd: this._programOptions.cwd,\n discover: this._discoverAppPaths,\n desiredApp: 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 // 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 ...this._getConfigOptionsFromCliOptions(),\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 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({ dispose: () => telemetryApi.shutdown() });\n\n const contexts: AppCommandContext[] = [];\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 extraFeatures: options.features,\n extraDefineFlags: options.define,\n ...(this._applyOptionsToConfig?.(this._options) || {}),\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 // Remove all event listeners. Currently this is only done on final disposal because one of\n // the start tests relies on a 'ready' event listener carrying over across restarts.\n commandEvents.removeAllListeners();\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;AACvD,OAAO,EAAE,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zC,2FAA2F;YAC3F,oFAAoF;YACpF,aAAa,CAAC,kBAAkB,EAAE,CAAC;YAEnC,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';\nimport { commandEvents } from './commandEvents.js';\n\nexport interface CommandExecutorParams<TOptions extends SharedOptions> {\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 | undefined;\n\n /**\n * Apply any command-specific CLI options that need to be passed through to `readConfig`.\n * (Shared and reused options are applied automatically.)\n */\n applyOptionsToConfig:\n | ((\n options: Omit<TOptions, keyof (SharedOptions & ReusedOptions)>,\n ) => Pick<ReadConfigOptions, 'extraServerConfig'> | undefined)\n | undefined;\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 SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n private _applyOptionsToConfig: CommandExecutorParams<TOptions>['applyOptionsToConfig'];\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._applyOptionsToConfig = params.applyOptionsToConfig;\n this._reporter = new TaskReporter();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /**\n * Run the command, including handling for restarts.\n */\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 // Handle SIGINT (Ctrl+C) gracefully.\n if (!environmentInfo.isJest) {\n process.on('SIGINT', this._sigintHandler);\n }\n\n try {\n let shouldRestart = false;\n do {\n shouldRestart = await this._executeOnce(shouldRestart);\n } while (shouldRestart);\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 * Execute a single iteration of the command.\n */\n private async _executeOnce(isRestart: boolean): Promise<boolean> {\n const contexts = await this._initializeContexts();\n\n if (!Array.isArray(contexts)) {\n return await this._exit(contexts);\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 isRestart,\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 {\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 // Determine whether a command requested a restart in this iteration.\n const shouldRestart = results.some((r) => r.restart);\n\n if (shouldRestart) {\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n this._reporter.reset(true /* clearOutputs */);\n\n console.warn(results.map((r) => r.message).join('\\n'));\n } else if (results.length) {\n // If one or more apps returned a result, exit.\n return 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\n return shouldRestart;\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 { app, login } = this._options as unknown as Pick<ReusedOptions, 'app' | 'login'>;\n const appPathsResult =\n this._discoverAppPaths === 'remote'\n ? await discoverRemoteAppPaths({\n options: {\n login,\n cachePath: this._options.cachePath,\n desiredApp: app,\n },\n context: { reporter: this._reporter },\n })\n : await discoverLocalAppPaths({\n cwd: this._programOptions.cwd,\n discover: this._discoverAppPaths,\n desiredApp: 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 // 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 ...this._getConfigOptionsFromCliOptions(),\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 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({ dispose: () => telemetryApi.shutdown() });\n\n const contexts: AppCommandContext[] = [];\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 extraFeatures: options.features,\n extraDefineFlags: options.define,\n ...(this._applyOptionsToConfig?.(this._options) || {}),\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 // Remove all event listeners. Currently this is only done on final disposal because one of\n // the start tests relies on a 'ready' event listener carrying over across restarts.\n commandEvents.removeAllListeners();\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"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.77.
|
|
3
|
+
"version": "0.77.26",
|
|
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",
|
|
7
|
-
"
|
|
7
|
+
"bin": {
|
|
8
|
+
"cloudpack": "./bin/cloudpack.js"
|
|
9
|
+
},
|
|
8
10
|
"types": "./lib/index.d.ts",
|
|
11
|
+
"sideEffects": false,
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
14
|
"source": "./src/index.ts",
|
|
@@ -14,13 +17,22 @@
|
|
|
14
17
|
},
|
|
15
18
|
"./package.json": "./package.json"
|
|
16
19
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
20
|
+
"scripts": {
|
|
21
|
+
"api": "cloudpack-scripts api",
|
|
22
|
+
"build:watch": "cloudpack-scripts build-watch",
|
|
23
|
+
"build": "cloudpack-scripts build && yarn schema",
|
|
24
|
+
"lint:update": "cloudpack-scripts lint-update",
|
|
25
|
+
"lint": "cloudpack-scripts lint",
|
|
26
|
+
"prepack": "cp .npmignore lib/.npmignore",
|
|
27
|
+
"schema": "cloudpack-scripts copy ../common-types/schema ./schema",
|
|
28
|
+
"test:update": "cloudpack-scripts test-update",
|
|
29
|
+
"test:watch": "cloudpack-scripts test-watch",
|
|
30
|
+
"test": "cloudpack-scripts test"
|
|
19
31
|
},
|
|
20
32
|
"dependencies": {
|
|
21
|
-
"@ms-cloudpack/api-server": "^0.65.
|
|
22
|
-
"@ms-cloudpack/app-server": "^0.20.
|
|
23
|
-
"@ms-cloudpack/bundler": "^0.26.
|
|
33
|
+
"@ms-cloudpack/api-server": "^0.65.7",
|
|
34
|
+
"@ms-cloudpack/app-server": "^0.20.31",
|
|
35
|
+
"@ms-cloudpack/bundler": "^0.26.16",
|
|
24
36
|
"@ms-cloudpack/bundler-capabilities": "^0.4.8",
|
|
25
37
|
"@ms-cloudpack/common-types": "^0.32.2",
|
|
26
38
|
"@ms-cloudpack/config": "^0.38.18",
|
|
@@ -28,8 +40,8 @@
|
|
|
28
40
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
29
41
|
"@ms-cloudpack/file-watcher": "^0.4.21",
|
|
30
42
|
"@ms-cloudpack/json-utilities": "^0.1.11",
|
|
31
|
-
"@ms-cloudpack/link-proxy": "^0.2.
|
|
32
|
-
"@ms-cloudpack/overlay": "^0.19.
|
|
43
|
+
"@ms-cloudpack/link-proxy": "^0.2.53",
|
|
44
|
+
"@ms-cloudpack/overlay": "^0.19.49",
|
|
33
45
|
"@ms-cloudpack/package-utilities": "^13.2.2",
|
|
34
46
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
35
47
|
"@ms-cloudpack/path-utilities": "^3.1.34",
|
|
@@ -59,18 +71,6 @@
|
|
|
59
71
|
"@types/prompts": "^2.4.4",
|
|
60
72
|
"@types/yarnpkg__lockfile": "^1.1.5"
|
|
61
73
|
},
|
|
62
|
-
"scripts": {
|
|
63
|
-
"api": "cloudpack-scripts api",
|
|
64
|
-
"build:watch": "cloudpack-scripts build-watch",
|
|
65
|
-
"build": "cloudpack-scripts build && yarn schema",
|
|
66
|
-
"lint:update": "cloudpack-scripts lint-update",
|
|
67
|
-
"lint": "cloudpack-scripts lint",
|
|
68
|
-
"prepack": "cp .npmignore lib/.npmignore",
|
|
69
|
-
"schema": "cloudpack-scripts copy ../common-types/schema ./schema",
|
|
70
|
-
"test:update": "cloudpack-scripts test-update",
|
|
71
|
-
"test:watch": "cloudpack-scripts test-watch",
|
|
72
|
-
"test": "cloudpack-scripts test"
|
|
73
|
-
},
|
|
74
74
|
"files": [
|
|
75
75
|
"lib/**/!(*.test.*)",
|
|
76
76
|
"schema"
|