@ms-cloudpack/cli 0.55.0 → 0.55.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cloudpack.js +0 -1
- package/lib/commands/bundle/execute.js +3 -3
- package/lib/commands/bundle/execute.js.map +1 -1
- package/lib/commands/bundle/index.d.ts.map +1 -1
- package/lib/commands/bundle/index.js +1 -3
- package/lib/commands/bundle/index.js.map +1 -1
- package/lib/commands/cache/clean.d.ts.map +1 -1
- package/lib/commands/cache/clean.js +2 -2
- package/lib/commands/cache/clean.js.map +1 -1
- package/lib/commands/cache/index.d.ts.map +1 -1
- package/lib/commands/cache/index.js +4 -7
- package/lib/commands/cache/index.js.map +1 -1
- package/lib/commands/info/index.d.ts.map +1 -1
- package/lib/commands/info/index.js +5 -9
- package/lib/commands/info/index.js.map +1 -1
- package/lib/commands/info/lockFile/execute.js +2 -2
- package/lib/commands/info/lockFile/execute.js.map +1 -1
- package/lib/commands/info/nonSemverDeps/execute.js +3 -3
- package/lib/commands/info/nonSemverDeps/execute.js.map +1 -1
- package/lib/commands/info/nonSemverDeps/getNonSemverDeps.d.ts +1 -1
- package/lib/commands/info/nonSemverDeps/getNonSemverDeps.d.ts.map +1 -1
- package/lib/commands/info/nonSemverDeps/getNonSemverDeps.js.map +1 -1
- package/lib/commands/init/execute.js +2 -2
- package/lib/commands/init/execute.js.map +1 -1
- package/lib/commands/init/index.d.ts.map +1 -1
- package/lib/commands/init/index.js +1 -3
- package/lib/commands/init/index.js.map +1 -1
- package/lib/commands/start/execute.d.ts.map +1 -1
- package/lib/commands/start/execute.js +8 -10
- package/lib/commands/start/execute.js.map +1 -1
- package/lib/commands/start/index.d.ts.map +1 -1
- package/lib/commands/start/index.js +1 -3
- package/lib/commands/start/index.js.map +1 -1
- package/lib/commands/sync/execute.d.ts.map +1 -1
- package/lib/commands/sync/execute.js +3 -2
- package/lib/commands/sync/execute.js.map +1 -1
- package/lib/commands/sync/index.d.ts.map +1 -1
- package/lib/commands/sync/index.js +1 -3
- package/lib/commands/sync/index.js.map +1 -1
- package/lib/common/CloudpackCommand.d.ts +59 -0
- package/lib/common/CloudpackCommand.d.ts.map +1 -0
- package/lib/common/CloudpackCommand.js +93 -0
- package/lib/common/CloudpackCommand.js.map +1 -0
- package/lib/common/CommandExecutor.d.ts +40 -0
- package/lib/common/CommandExecutor.d.ts.map +1 -0
- package/lib/common/CommandExecutor.js +163 -0
- package/lib/common/CommandExecutor.js.map +1 -0
- package/lib/index.d.ts +9 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -15
- package/lib/index.js.map +1 -1
- package/lib/types/CommandAction.d.ts +9 -4
- package/lib/types/CommandAction.d.ts.map +1 -1
- package/lib/types/CommandAction.js.map +1 -1
- package/lib/types/CommandInitFunction.d.ts +2 -2
- package/lib/types/CommandInitFunction.d.ts.map +1 -1
- package/lib/types/CommandInitFunction.js.map +1 -1
- package/lib/types/ProgramOptions.d.ts +17 -0
- package/lib/types/ProgramOptions.d.ts.map +1 -0
- package/lib/types/ProgramOptions.js +2 -0
- package/lib/types/ProgramOptions.js.map +1 -0
- package/lib/types/SharedOptions.d.ts +1 -6
- package/lib/types/SharedOptions.d.ts.map +1 -1
- package/lib/types/SharedOptions.js.map +1 -1
- package/package.json +5 -5
- package/lib/common/createCommand.d.ts +0 -29
- package/lib/common/createCommand.d.ts.map +0 -1
- package/lib/common/createCommand.js +0 -42
- package/lib/common/createCommand.js.map +0 -1
- package/lib/common/createCommandActionFunction.d.ts +0 -9
- package/lib/common/createCommandActionFunction.d.ts.map +0 -1
- package/lib/common/createCommandActionFunction.js +0 -72
- package/lib/common/createCommandActionFunction.js.map +0 -1
- package/lib/common/createExitFunction.d.ts +0 -13
- package/lib/common/createExitFunction.d.ts.map +0 -1
- package/lib/common/createExitFunction.js +0 -26
- package/lib/common/createExitFunction.js.map +0 -1
- package/lib/common/createInitializeFunction.d.ts +0 -19
- package/lib/common/createInitializeFunction.d.ts.map +0 -1
- package/lib/common/createInitializeFunction.js +0 -52
- package/lib/common/createInitializeFunction.js.map +0 -1
- package/lib/initTelemetry.d.ts +0 -17
- package/lib/initTelemetry.d.ts.map +0 -1
- package/lib/initTelemetry.js +0 -34
- package/lib/initTelemetry.js.map +0 -1
- package/lib/setupReporting.d.ts +0 -13
- package/lib/setupReporting.d.ts.map +0 -1
- package/lib/setupReporting.js +0 -45
- package/lib/setupReporting.js.map +0 -1
- package/lib/types/CommandContext.d.ts +0 -11
- package/lib/types/CommandContext.d.ts.map +0 -1
- package/lib/types/CommandContext.js +0 -2
- package/lib/types/CommandContext.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These options are not provided on the command line but need to be shared between commands.
|
|
3
|
+
*/
|
|
4
|
+
export interface ProgramOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Initial working directory (usually `process.cwd()` except in tests).
|
|
7
|
+
* Note that this may differ from the `appPath` used by individual commands.
|
|
8
|
+
*/
|
|
9
|
+
cwd: string;
|
|
10
|
+
/** Raw argv (usually `process.argv` except in tests). */
|
|
11
|
+
argv: string[];
|
|
12
|
+
/** CLI version. */
|
|
13
|
+
version: string;
|
|
14
|
+
/** Disable telemetry, e.g. for tests. */
|
|
15
|
+
disableTelemetry?: boolean;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ProgramOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgramOptions.d.ts","sourceRoot":"","sources":["../../src/types/ProgramOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ,yDAAyD;IACzD,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,mBAAmB;IACnB,OAAO,EAAE,MAAM,CAAC;IAEhB,yCAAyC;IACzC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgramOptions.js","sourceRoot":"","sources":["../../src/types/ProgramOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * These options are not provided on the command line but need to be shared between commands.\n */\nexport interface ProgramOptions {\n /**\n * Initial working directory (usually `process.cwd()` except in tests).\n * Note that this may differ from the `appPath` used by individual commands.\n */\n cwd: string;\n\n /** Raw argv (usually `process.argv` except in tests). */\n argv: string[];\n\n /** CLI version. */\n version: string;\n\n /** Disable telemetry, e.g. for tests. */\n disableTelemetry?: boolean;\n}\n"]}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared options for all commands.
|
|
2
|
+
* Shared CLI options for all commands.
|
|
3
3
|
*/
|
|
4
4
|
export interface SharedOptions {
|
|
5
|
-
/**
|
|
6
|
-
* The current working directory (mainly customized for tests).
|
|
7
|
-
* @default process.cwd()
|
|
8
|
-
*/
|
|
9
|
-
cwd: string;
|
|
10
5
|
/**
|
|
11
6
|
* Whether to enable debug logging (superset of --verbose).
|
|
12
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedOptions.d.ts","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B
|
|
1
|
+
{"version":3,"file":"SharedOptions.d.ts","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"AAAA;;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,EAAE,CAAC;CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedOptions.js","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Shared options for all commands.\n */\nexport interface SharedOptions {\n /**\n *
|
|
1
|
+
{"version":3,"file":"SharedOptions.js","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\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 feature names to enable.\n */\n features?: string[];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.2",
|
|
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",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"cloudpack": "./bin/cloudpack.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ms-cloudpack/api-server": "^0.30.
|
|
14
|
-
"@ms-cloudpack/bundle-server": "^0.2.
|
|
15
|
-
"@ms-cloudpack/config": "^0.17.
|
|
13
|
+
"@ms-cloudpack/api-server": "^0.30.2",
|
|
14
|
+
"@ms-cloudpack/bundle-server": "^0.2.17",
|
|
15
|
+
"@ms-cloudpack/config": "^0.17.22",
|
|
16
16
|
"@ms-cloudpack/config-types": "^0.4.3",
|
|
17
17
|
"@ms-cloudpack/feature-flags": "^0.0.2",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.3",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@ms-cloudpack/path-string-parsing": "^1.1.3",
|
|
21
21
|
"@ms-cloudpack/path-utilities": "^2.5.0",
|
|
22
22
|
"@ms-cloudpack/remote-cache": "^0.4.7",
|
|
23
|
-
"@ms-cloudpack/app-server": "^0.1.
|
|
23
|
+
"@ms-cloudpack/app-server": "^0.1.20",
|
|
24
24
|
"@ms-cloudpack/task-reporter": "^0.11.1",
|
|
25
25
|
"@ms-cloudpack/telemetry": "^0.4.6",
|
|
26
26
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Option, Command } from 'commander';
|
|
2
|
-
import type { CommandActionModule } from '../types/CommandAction.js';
|
|
3
|
-
/**
|
|
4
|
-
* Options for creating a command.
|
|
5
|
-
* This helps enforce that all commands have a description and shared options.
|
|
6
|
-
*
|
|
7
|
-
* `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.
|
|
8
|
-
*/
|
|
9
|
-
interface CreateCommandOptions<TOptions extends object> {
|
|
10
|
-
/** Parent of this command: usually the program, or could be a sub-command for sub-sub-commands */
|
|
11
|
-
parent: Command;
|
|
12
|
-
/** Command name */
|
|
13
|
-
name: string;
|
|
14
|
-
/** Command description */
|
|
15
|
-
description: string;
|
|
16
|
-
/** Options specific to this command. The record ensures that all options are available in the CLI. */
|
|
17
|
-
options?: Record<keyof TOptions, Option>;
|
|
18
|
-
/** Function returning an async import of the command's `src/commands/<name>/execute.ts` module */
|
|
19
|
-
getExecutor?: () => Promise<CommandActionModule<TOptions>>;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Create a command, ensuring that it has an option for each common option, as well as each key of
|
|
23
|
-
* TOptions if `params.options` is provided.
|
|
24
|
-
* @param params Usually an object with command options, or just a name for the root command.
|
|
25
|
-
* @returns The created command, for any further modifications.
|
|
26
|
-
*/
|
|
27
|
-
export declare function createCommand<TOptions extends object>(params: string | CreateCommandOptions<TOptions>): Command;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=createCommand.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createCommand.d.ts","sourceRoot":"","sources":["../../src/common/createCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAIrE;;;;;GAKG;AACH,UAAU,oBAAoB,CAAC,QAAQ,SAAS,MAAM;IACpD,kGAAkG;IAClG,MAAM,EAAE,OAAO,CAAC;IAChB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,sGAAsG;IACtG,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzC,kGAAkG;IAClG,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC5D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,SAAS,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAAC,QAAQ,CAAC,WAmCrG"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Option, Command } from 'commander';
|
|
2
|
-
import { createCommandActionFunction } from './createCommandActionFunction.js';
|
|
3
|
-
import { isCIBuild } from '../utilities/isCIBuild.js';
|
|
4
|
-
/**
|
|
5
|
-
* Create a command, ensuring that it has an option for each common option, as well as each key of
|
|
6
|
-
* TOptions if `params.options` is provided.
|
|
7
|
-
* @param params Usually an object with command options, or just a name for the root command.
|
|
8
|
-
* @returns The created command, for any further modifications.
|
|
9
|
-
*/
|
|
10
|
-
export function createCommand(params) {
|
|
11
|
-
const { parent, name, description, options, getExecutor } = typeof params === 'string' ? { name: params, ...{} } : params;
|
|
12
|
-
const command = parent ? parent.command(name) : new Command(name);
|
|
13
|
-
if (description) {
|
|
14
|
-
command.description(description);
|
|
15
|
-
}
|
|
16
|
-
// Add the command-specific options first so they're first in help.
|
|
17
|
-
if (options) {
|
|
18
|
-
addOptions(command, options);
|
|
19
|
-
}
|
|
20
|
-
// These options should also be applied to sub-commands to ensure they show up in help.
|
|
21
|
-
addOptions(command, {
|
|
22
|
-
verbose: new Option('-v, --verbose', 'Show additional details about the running tasks.'),
|
|
23
|
-
debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).').conflicts('verbose'),
|
|
24
|
-
quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),
|
|
25
|
-
color:
|
|
26
|
-
// In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)
|
|
27
|
-
new Option('-n, --no-color', 'Disable colors in the output.').default(!process.env.JEST_WORKER_ID && !isCIBuild()),
|
|
28
|
-
features: new Option('--features <featureNames...>', 'Enable experimental features.'),
|
|
29
|
-
// eslint-disable-next-line no-restricted-properties -- this is the one place we need cwd (for a default)
|
|
30
|
-
cwd: new Option('--cwd <path>', 'Path to the starting directory.').default(process.cwd()).hideHelp(),
|
|
31
|
-
});
|
|
32
|
-
if (getExecutor) {
|
|
33
|
-
command.action(createCommandActionFunction(getExecutor));
|
|
34
|
-
}
|
|
35
|
-
return command;
|
|
36
|
-
}
|
|
37
|
-
function addOptions(command, options) {
|
|
38
|
-
for (const option of Object.values(options)) {
|
|
39
|
-
command.addOption(option);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=createCommand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createCommand.js","sourceRoot":"","sources":["../../src/common/createCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAqBtD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAA0B,MAA+C;IACpG,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,GACvD,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAI,EAA8C,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAE7G,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAED,mEAAmE;IACnE,IAAI,OAAO,EAAE,CAAC;QACZ,UAAU,CAAW,OAAO,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,uFAAuF;IACvF,UAAU,CAAgB,OAAO,EAAE;QACjC,OAAO,EAAE,IAAI,MAAM,CAAC,eAAe,EAAE,kDAAkD,CAAC;QACxF,KAAK,EAAE,IAAI,MAAM,CAAC,aAAa,EAAE,iDAAiD,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;QACxG,KAAK,EAAE,IAAI,MAAM,CAAC,aAAa,EAAE,gCAAgC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;QAC1G,KAAK;QACH,yGAAyG;QACzG,IAAI,MAAM,CAAC,gBAAgB,EAAE,+BAA+B,CAAC,CAAC,OAAO,CACnE,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,SAAS,EAAE,CAC5C;QACH,QAAQ,EAAE,IAAI,MAAM,CAAC,8BAA8B,EAAE,+BAA+B,CAAC;QACrF,yGAAyG;QACzG,GAAG,EAAE,IAAI,MAAM,CAAC,cAAc,EAAE,iCAAiC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;KACrG,CAAC,CAAC;IAEH,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,MAAM,CAAC,2BAA2B,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,UAAU,CAA0B,OAAgB,EAAE,OAAuC;IACpG,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5C,OAAO,CAAC,SAAS,CAAC,MAAgB,CAAC,CAAC;IACtC,CAAC;AACH,CAAC","sourcesContent":["import { Option, Command } from 'commander';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport { createCommandActionFunction } from './createCommandActionFunction.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\n\n/**\n * Options for creating a command.\n * This helps enforce that all commands have a description and shared options.\n *\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CreateCommandOptions<TOptions extends object> {\n /** Parent of this command: usually the program, or could be a sub-command for sub-sub-commands */\n parent: Command;\n /** Command name */\n name: string;\n /** Command description */\n description: string;\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n /** Function returning an async import of the command's `src/commands/<name>/execute.ts` module */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n}\n\n/**\n * Create a command, ensuring that it has an option for each common option, as well as each key of\n * TOptions if `params.options` is provided.\n * @param params Usually an object with command options, or just a name for the root command.\n * @returns The created command, for any further modifications.\n */\nexport function createCommand<TOptions extends object>(params: string | CreateCommandOptions<TOptions>) {\n const { parent, name, description, options, getExecutor } =\n typeof params === 'string' ? { name: params, ...({} as Partial<CreateCommandOptions<TOptions>>) } : params;\n\n const command = parent ? parent.command(name) : new Command(name);\n\n if (description) {\n command.description(description);\n }\n\n // Add the command-specific options first so they're first in help.\n if (options) {\n addOptions<TOptions>(command, options);\n }\n\n // These options should also be applied to sub-commands to ensure they show up in help.\n addOptions<SharedOptions>(command, {\n verbose: new Option('-v, --verbose', 'Show additional details about the running tasks.'),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).').conflicts('verbose'),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),\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.').default(\n !process.env.JEST_WORKER_ID && !isCIBuild(),\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.'),\n // eslint-disable-next-line no-restricted-properties -- this is the one place we need cwd (for a default)\n cwd: new Option('--cwd <path>', 'Path to the starting directory.').default(process.cwd()).hideHelp(),\n });\n\n if (getExecutor) {\n command.action(createCommandActionFunction(getExecutor));\n }\n\n return command;\n}\n\nfunction addOptions<TOptions extends object>(command: Command, options: Record<keyof TOptions, Option>) {\n for (const option of Object.values(options)) {\n command.addOption(option as Option);\n }\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Command } from 'commander';
|
|
2
|
-
import type { CommandActionModule } from '../types/CommandAction.js';
|
|
3
|
-
/**
|
|
4
|
-
* Call this function to create a command's action.
|
|
5
|
-
* @param getExecutor Function that returns an async import of the `src/commands/<name>/execute.ts`
|
|
6
|
-
* module for this command. The module must export a single function `execute`.
|
|
7
|
-
*/
|
|
8
|
-
export declare function createCommandActionFunction<TActionOptions>(getExecutor: () => Promise<CommandActionModule<TActionOptions>>): (_thisCommandOptions: TActionOptions, command: Command) => Promise<void>;
|
|
9
|
-
//# sourceMappingURL=createCommandActionFunction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createCommandActionFunction.d.ts","sourceRoot":"","sources":["../../src/common/createCommandActionFunction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,cAAc,EACxD,WAAW,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC,yBASN,cAAc,WAAW,OAAO,mBAiE1F"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
2
|
-
import { AutoDisposableList } from './AutoDisposableList.js';
|
|
3
|
-
import { createExitFunction } from './createExitFunction.js';
|
|
4
|
-
import { createInitializeFunction } from './createInitializeFunction.js';
|
|
5
|
-
/**
|
|
6
|
-
* Call this function to create a command's action.
|
|
7
|
-
* @param getExecutor Function that returns an async import of the `src/commands/<name>/execute.ts`
|
|
8
|
-
* module for this command. The module must export a single function `execute`.
|
|
9
|
-
*/
|
|
10
|
-
export function createCommandActionFunction(getExecutor) {
|
|
11
|
-
/**
|
|
12
|
-
* This is the actual function which is passed to `command.action(...)` and eventually called via
|
|
13
|
-
* `program.parseAsync()` (for whichever command is specified).
|
|
14
|
-
* @param _options Options parsed by commander *specific to this command*.
|
|
15
|
-
* This is ignored because it's missing shared options such as `debug`.
|
|
16
|
-
* @param command Command object for this sub-command (not for the whole program).
|
|
17
|
-
*/
|
|
18
|
-
return async function commandAction(_thisCommandOptions, command) {
|
|
19
|
-
// Get the shared options too, not just the ones for this command.
|
|
20
|
-
// (In `createCommand`, we added the shared options to each command object so that they show up
|
|
21
|
-
// in help, but commander still seems to respect options only at the first command where they're
|
|
22
|
-
// encountered, which for shared options will always be the program command.)
|
|
23
|
-
const options = command.optsWithGlobals();
|
|
24
|
-
// Dynamically import the execute function
|
|
25
|
-
const { execute } = await getExecutor();
|
|
26
|
-
if (typeof execute !== 'function') {
|
|
27
|
-
// throw instead of exiting politely, since this is a major developer error
|
|
28
|
-
throw new Error(`No execute function was exported from the command module for ${command.name()}.`);
|
|
29
|
-
}
|
|
30
|
-
// The reporter options will be configured in `setupReporting` (called via `initialize`),
|
|
31
|
-
// but it's easiest if the object exists before then.
|
|
32
|
-
const reporter = new TaskReporter();
|
|
33
|
-
const abortController = new AbortController();
|
|
34
|
-
// This list will be used to dispose all registered disposables.
|
|
35
|
-
const autoDisposableList = new AutoDisposableList();
|
|
36
|
-
// This function will be used to register a disposable.
|
|
37
|
-
const autoDispose = autoDisposableList.add.bind(autoDisposableList);
|
|
38
|
-
// This function will be called instead of process.exit. It provides a way to cleanup and exit the process gracefully.
|
|
39
|
-
const exit = createExitFunction({ abortController, reporter, autoDisposableList });
|
|
40
|
-
// This function will be called to initialize the command.
|
|
41
|
-
const initialize = createInitializeFunction({ reporter, autoDispose, command, options: options });
|
|
42
|
-
try {
|
|
43
|
-
// Setup cleanup and close things on completion.
|
|
44
|
-
let sigintCount = 0;
|
|
45
|
-
// Handle SIGINT (Ctrl+C) gracefully.
|
|
46
|
-
process.on('SIGINT', () => {
|
|
47
|
-
sigintCount++;
|
|
48
|
-
if (sigintCount > 1) {
|
|
49
|
-
console.debug('Forcing exit');
|
|
50
|
-
// We are forcing the process to exit.
|
|
51
|
-
// No clean-up is needed because user pressed Ctrl+C twice.
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
// We are trying to exit gracefully.
|
|
55
|
-
void exit();
|
|
56
|
-
});
|
|
57
|
-
// This is the abort signal that will be passed to the execute function.
|
|
58
|
-
const abortSignal = abortController.signal;
|
|
59
|
-
// Call the execute function which is the real command logic
|
|
60
|
-
// (ie: real init command logic, real start command logic, etc.)
|
|
61
|
-
await execute({ options, reporter, initialize, abortSignal, autoDispose, exit });
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
// If an error occurs, exit the process with a non-zero exit code.
|
|
65
|
-
await exit({
|
|
66
|
-
hasErrors: true,
|
|
67
|
-
message: error instanceof Error ? error.stack || error.message : String(error),
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=createCommandActionFunction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createCommandActionFunction.js","sourceRoot":"","sources":["../../src/common/createCommandActionFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAIzE;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,WAA+D;IAE/D;;;;;;OAMG;IACH,OAAO,KAAK,UAAU,aAAa,CAAC,mBAAmC,EAAE,OAAgB;QACvF,kEAAkE;QAClE,+FAA+F;QAC/F,gGAAgG;QAChG,6EAA6E;QAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,EAAkC,CAAC;QAE1E,0CAA0C;QAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;QACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YAClC,2EAA2E;YAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACrG,CAAC;QAED,yFAAyF;QACzF,qDAAqD;QACrD,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;QAEpC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAE9C,gEAAgE;QAChE,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAEpD,uDAAuD;QACvD,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEpE,sHAAsH;QACtH,MAAM,IAAI,GAAG,kBAAkB,CAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC,CAAC;QAEnF,0DAA0D;QAC1D,MAAM,UAAU,GAAG,wBAAwB,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAElG,IAAI,CAAC;YACH,gDAAgD;YAChD,IAAI,WAAW,GAAG,CAAC,CAAC;YAEpB,qCAAqC;YACrC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;gBACxB,WAAW,EAAE,CAAC;gBACd,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;oBACpB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;oBAE9B,sCAAsC;oBACtC,2DAA2D;oBAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;gBAED,oCAAoC;gBACpC,KAAK,IAAI,EAAE,CAAC;YACd,CAAC,CAAC,CAAC;YAEH,wEAAwE;YACxE,MAAM,WAAW,GAAG,eAAe,CAAC,MAAM,CAAC;YAE3C,4DAA4D;YAC5D,gEAAgE;YAChE,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QACnF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,kEAAkE;YAClE,MAAM,IAAI,CAAC;gBACT,SAAS,EAAE,IAAI;gBACf,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC/E,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { Command } from 'commander';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { createExitFunction } from './createExitFunction.js';\nimport { createInitializeFunction } from './createInitializeFunction.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport type { CommandActionModule } from '../types/CommandAction.js';\n\n/**\n * Call this function to create a command's action.\n * @param getExecutor Function that returns an async import of the `src/commands/<name>/execute.ts`\n * module for this command. The module must export a single function `execute`.\n */\nexport function createCommandActionFunction<TActionOptions>(\n getExecutor: () => Promise<CommandActionModule<TActionOptions>>,\n) {\n /**\n * This is the actual function which is passed to `command.action(...)` and eventually called via\n * `program.parseAsync()` (for whichever command is specified).\n * @param _options Options parsed by commander *specific to this command*.\n * This is ignored because it's missing shared options such as `debug`.\n * @param command Command object for this sub-command (not for the whole program).\n */\n return async function commandAction(_thisCommandOptions: TActionOptions, command: Command) {\n // Get the shared options too, not just the ones for this command.\n // (In `createCommand`, 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<TActionOptions & SharedOptions>();\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 ${command.name()}.`);\n }\n\n // The reporter options will be configured in `setupReporting` (called via `initialize`),\n // but it's easiest if the object exists before then.\n const reporter = new TaskReporter();\n\n const abortController = new AbortController();\n\n // This list will be used to dispose all registered disposables.\n const autoDisposableList = new AutoDisposableList();\n\n // This function will be used to register a disposable.\n const autoDispose = autoDisposableList.add.bind(autoDisposableList);\n\n // This function will be called instead of process.exit. It provides a way to cleanup and exit the process gracefully.\n const exit = createExitFunction({ abortController, reporter, autoDisposableList });\n\n // This function will be called to initialize the command.\n const initialize = createInitializeFunction({ reporter, autoDispose, command, options: options });\n\n try {\n // Setup cleanup and close things on completion.\n let sigintCount = 0;\n\n // Handle SIGINT (Ctrl+C) gracefully.\n process.on('SIGINT', () => {\n sigintCount++;\n if (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 process.exit(1);\n }\n\n // We are trying to exit gracefully.\n void exit();\n });\n\n // This is the abort signal that will be passed to the execute function.\n const abortSignal = abortController.signal;\n\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n await execute({ options, reporter, initialize, abortSignal, autoDispose, exit });\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await exit({\n hasErrors: true,\n message: error instanceof Error ? error.stack || error.message : String(error),\n });\n }\n };\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
3
|
-
import type { AutoDisposableList } from './AutoDisposableList.js';
|
|
4
|
-
export declare function createExitFunction(options: {
|
|
5
|
-
reporter: TaskReporter;
|
|
6
|
-
abortController: AbortController;
|
|
7
|
-
autoDisposableList: AutoDisposableList;
|
|
8
|
-
}): (exitOptions?: {
|
|
9
|
-
hasErrors?: boolean;
|
|
10
|
-
message?: string;
|
|
11
|
-
exitCode?: number;
|
|
12
|
-
}) => Promise<never>;
|
|
13
|
-
//# sourceMappingURL=createExitFunction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createExitFunction.d.ts","sourceRoot":"","sources":["../../src/common/createExitFunction.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,YAAY,EAAO,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,kBAMgB;IACX,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,oBAyBJ"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { red } from '@ms-cloudpack/task-reporter';
|
|
2
|
-
export function createExitFunction(options) {
|
|
3
|
-
const { abortController, reporter, autoDisposableList } = options;
|
|
4
|
-
let hasCalledExit = false;
|
|
5
|
-
return async function exit(exitOptions = {}) {
|
|
6
|
-
const { message } = exitOptions;
|
|
7
|
-
const hasErrors = exitOptions.hasErrors ?? reporter.hasErrors();
|
|
8
|
-
if (hasCalledExit) {
|
|
9
|
-
// Skip most of the operations if exit() was called multiple times.
|
|
10
|
-
console.warn("exit() was called multiple times. This call's options:", exitOptions);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
hasCalledExit = true;
|
|
14
|
-
// Let the execute function know that we are exiting.
|
|
15
|
-
abortController.abort();
|
|
16
|
-
// Dispose all registered disposables.
|
|
17
|
-
await autoDisposableList.dispose();
|
|
18
|
-
// Show the summary message (this will throw if called twice).
|
|
19
|
-
reporter.complete(hasErrors ? red(message) : message);
|
|
20
|
-
}
|
|
21
|
-
// Exit the process with the appropriate exit code.
|
|
22
|
-
const exitCode = exitOptions.exitCode ?? (hasErrors ? 1 : 0);
|
|
23
|
-
process.exit(exitCode);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=createExitFunction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createExitFunction.js","sourceRoot":"","sources":["../../src/common/createExitFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAGrE,MAAM,UAAU,kBAAkB,CAAC,OAIlC;IACC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC;IAElE,IAAI,aAAa,GAAG,KAAK,CAAC;IAE1B,OAAO,KAAK,UAAU,IAAI,CACxB,cAII,EAAE;QAEN,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;QAChC,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;QAEhE,IAAI,aAAa,EAAE,CAAC;YAClB,mEAAmE;YACnE,OAAO,CAAC,IAAI,CAAC,wDAAwD,EAAE,WAAW,CAAC,CAAC;QACtF,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,IAAI,CAAC;YAErB,qDAAqD;YACrD,eAAe,CAAC,KAAK,EAAE,CAAC;YAExB,sCAAsC;YACtC,MAAM,kBAAkB,CAAC,OAAO,EAAE,CAAC;YAEnC,8DAA8D;YAC9D,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC;QAED,mDAAmD;QACnD,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { type TaskReporter, red } from '@ms-cloudpack/task-reporter';\nimport type { AutoDisposableList } from './AutoDisposableList.js';\n\nexport function createExitFunction(options: {\n reporter: TaskReporter;\n abortController: AbortController;\n autoDisposableList: AutoDisposableList;\n}) {\n const { abortController, reporter, autoDisposableList } = options;\n\n let hasCalledExit = false;\n\n return async function exit(\n exitOptions: {\n hasErrors?: boolean;\n message?: string;\n exitCode?: number;\n } = {},\n ) {\n const { message } = exitOptions;\n const hasErrors = exitOptions.hasErrors ?? reporter.hasErrors();\n\n if (hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n console.warn(\"exit() was called multiple times. This call's options:\", exitOptions);\n } else {\n hasCalledExit = true;\n\n // Let the execute function know that we are exiting.\n abortController.abort();\n\n // Dispose all registered disposables.\n await autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n reporter.complete(hasErrors ? red(message) : message);\n }\n\n // Exit the process with the appropriate exit code.\n const exitCode = exitOptions.exitCode ?? (hasErrors ? 1 : 0);\n process.exit(exitCode);\n };\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
2
|
-
import type { Command } from 'commander';
|
|
3
|
-
import type { AutoDispose } from '../types/AutoDispose.js';
|
|
4
|
-
import type { SharedOptions } from '../types/SharedOptions.js';
|
|
5
|
-
export declare function createInitializeFunction(params: {
|
|
6
|
-
reporter: TaskReporter;
|
|
7
|
-
/** Command object for the current command (not the whole program). */
|
|
8
|
-
command: Command;
|
|
9
|
-
autoDispose: AutoDispose;
|
|
10
|
-
/** Options from CLI args for the whole program. */
|
|
11
|
-
options: SharedOptions;
|
|
12
|
-
}): (initializeParams: {
|
|
13
|
-
appPath: string;
|
|
14
|
-
optionsOverrides?: Partial<SharedOptions>;
|
|
15
|
-
}) => Promise<{
|
|
16
|
-
telemetryClient: import("@ms-cloudpack/telemetry").TelemetryClient;
|
|
17
|
-
config: import("@ms-cloudpack/config-types").CloudpackConfig;
|
|
18
|
-
}>;
|
|
19
|
-
//# sourceMappingURL=createInitializeFunction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createInitializeFunction.d.ts","sourceRoot":"","sources":["../../src/common/createInitializeFunction.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAO/D,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC/C,QAAQ,EAAE,YAAY,CAAC;IACvB,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,mDAAmD;IACnD,OAAO,EAAE,aAAa,CAAC;CACxB,sBAEoD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,QAAQ,aAAa,CAAC,CAAA;CAAE;;;GAmDlH"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { readConfig } from '@ms-cloudpack/config';
|
|
2
|
-
import { yellow } from '@ms-cloudpack/task-reporter';
|
|
3
|
-
import { setupReporting } from '../setupReporting.js';
|
|
4
|
-
import { checkFeatures } from './checkFeatures.js';
|
|
5
|
-
import { readJson } from '@ms-cloudpack/json-utilities';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { getMergedFeatureFlags } from './getMergedFeatureFlags.js';
|
|
8
|
-
export function createInitializeFunction(params) {
|
|
9
|
-
const { reporter, autoDispose, command } = params;
|
|
10
|
-
return async function initialize(initializeParams) {
|
|
11
|
-
const { appPath } = initializeParams;
|
|
12
|
-
const actionOptions = {
|
|
13
|
-
...params.options,
|
|
14
|
-
...initializeParams.optionsOverrides,
|
|
15
|
-
};
|
|
16
|
-
const config = await readConfig(appPath);
|
|
17
|
-
const definition = (await readJson(path.join(appPath, 'package.json')));
|
|
18
|
-
// Merge in any additional features from the command line and remote feature flags.
|
|
19
|
-
config.features = await getMergedFeatureFlags(config, actionOptions, appPath, definition.name);
|
|
20
|
-
const enabledFeatureNames = Object.entries(config.features)
|
|
21
|
-
.filter(([, value]) => value)
|
|
22
|
-
.map(([key]) => key);
|
|
23
|
-
const telemetryClient = await setupReporting({
|
|
24
|
-
appName: definition.name,
|
|
25
|
-
config,
|
|
26
|
-
reporter,
|
|
27
|
-
command,
|
|
28
|
-
options: actionOptions,
|
|
29
|
-
});
|
|
30
|
-
const errors = checkFeatures({ configFeatures: config.features });
|
|
31
|
-
// If there are any invalid features, exit with an error.
|
|
32
|
-
if (errors.length) {
|
|
33
|
-
errors.forEach((error) => console.error(error));
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
if (enabledFeatureNames.length) {
|
|
37
|
-
telemetryClient.setSharedSpanAttribute('features', enabledFeatureNames);
|
|
38
|
-
console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);
|
|
39
|
-
}
|
|
40
|
-
// Dispose the telemetry client when the app is closing
|
|
41
|
-
const disposeTelemetryClient = telemetryClient.shutdown.bind(telemetryClient);
|
|
42
|
-
const disposableTelemetry = {
|
|
43
|
-
dispose: disposeTelemetryClient,
|
|
44
|
-
};
|
|
45
|
-
autoDispose(disposableTelemetry);
|
|
46
|
-
return {
|
|
47
|
-
telemetryClient,
|
|
48
|
-
config,
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=createInitializeFunction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createInitializeFunction.js","sourceRoot":"","sources":["../../src/common/createInitializeFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAqB,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,UAAU,wBAAwB,CAAC,MAOxC;IACC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAClD,OAAO,KAAK,UAAU,UAAU,CAAC,gBAAgF;QAC/G,MAAM,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC;QAErC,MAAM,aAAa,GAAkB;YACnC,GAAG,MAAM,CAAC,OAAO;YACjB,GAAG,gBAAgB,CAAC,gBAAgB;SACrC,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;QAEzC,MAAM,UAAU,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAgB,CAAC;QAEvF,mFAAmF;QACnF,MAAM,CAAC,QAAQ,GAAG,MAAM,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QAE/F,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;aACxD,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC;aAC5B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;QAEvB,MAAM,eAAe,GAAG,MAAM,cAAc,CAAC;YAC3C,OAAO,EAAE,UAAU,CAAC,IAAI;YACxB,MAAM;YACN,QAAQ;YACR,OAAO;YACP,OAAO,EAAE,aAAa;SACvB,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,aAAa,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAClE,yDAAyD;QACzD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,mBAAmB,CAAC,MAAM,EAAE,CAAC;YAC/B,eAAe,CAAC,sBAAsB,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;YACxE,OAAO,CAAC,GAAG,CAAC,qBAAqB,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3F,CAAC;QAED,uDAAuD;QACvD,MAAM,sBAAsB,GAAG,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC9E,MAAM,mBAAmB,GAAe;YACtC,OAAO,EAAE,sBAAsB;SAChC,CAAC;QACF,WAAW,CAAC,mBAAmB,CAAC,CAAC;QAEjC,OAAO;YACL,eAAe;YACf,MAAM;SACP,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport { yellow, type TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { Command } from 'commander';\nimport { setupReporting } from '../setupReporting.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport type { AutoDispose } from '../types/AutoDispose.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport type { Disposable } from '../types/Disposable.js';\nimport type { PackageJson } from '@ms-cloudpack/config-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport { getMergedFeatureFlags } from './getMergedFeatureFlags.js';\n\nexport function createInitializeFunction(params: {\n reporter: TaskReporter;\n /** Command object for the current command (not the whole program). */\n command: Command;\n autoDispose: AutoDispose;\n /** Options from CLI args for the whole program. */\n options: SharedOptions;\n}) {\n const { reporter, autoDispose, command } = params;\n return async function initialize(initializeParams: { appPath: string; optionsOverrides?: Partial<SharedOptions> }) {\n const { appPath } = initializeParams;\n\n const actionOptions: SharedOptions = {\n ...params.options,\n ...initializeParams.optionsOverrides,\n };\n\n const config = await readConfig(appPath);\n\n const definition = (await readJson(path.join(appPath, 'package.json'))) as PackageJson;\n\n // Merge in any additional features from the command line and remote feature flags.\n config.features = await getMergedFeatureFlags(config, actionOptions, appPath, definition.name);\n\n const enabledFeatureNames = Object.entries(config.features)\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n const telemetryClient = await setupReporting({\n appName: definition.name,\n config,\n reporter,\n command,\n options: actionOptions,\n });\n\n const errors = checkFeatures({ configFeatures: config.features });\n // If there are any invalid features, exit with an error.\n if (errors.length) {\n errors.forEach((error) => console.error(error));\n process.exit(1);\n }\n\n if (enabledFeatureNames.length) {\n telemetryClient.setSharedSpanAttribute('features', enabledFeatureNames);\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n // Dispose the telemetry client when the app is closing\n const disposeTelemetryClient = telemetryClient.shutdown.bind(telemetryClient);\n const disposableTelemetry: Disposable = {\n dispose: disposeTelemetryClient,\n };\n autoDispose(disposableTelemetry);\n\n return {\n telemetryClient,\n config,\n };\n };\n}\n"]}
|
package/lib/initTelemetry.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type TelemetryConfig } from '@ms-cloudpack/config-types';
|
|
2
|
-
import { type SpanAttributes } from '@ms-cloudpack/telemetry';
|
|
3
|
-
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
4
|
-
export interface TelemetryInitOptions {
|
|
5
|
-
useDebugLogging: boolean;
|
|
6
|
-
useVerboseLogging: boolean;
|
|
7
|
-
telemetryConfig: TelemetryConfig | undefined;
|
|
8
|
-
sharedSpanAttributes?: SpanAttributes;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Initialize the telemetry client, create the root span, register performance observers.
|
|
12
|
-
* Telemetry will not be sent if no instrumentation key is found.
|
|
13
|
-
* @param options - options to initialize telemetry
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
export declare function initTelemetry(options: TelemetryInitOptions, taskReporter: TaskReporter): Promise<import("@ms-cloudpack/telemetry").TelemetryClient>;
|
|
17
|
-
//# sourceMappingURL=initTelemetry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initTelemetry.d.ts","sourceRoot":"","sources":["../src/initTelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAErF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,eAAe,EAAE,eAAe,GAAG,SAAS,CAAC;IAC7C,oBAAoB,CAAC,EAAE,cAAc,CAAC;CACvC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,YAAY,8DA4B5F"}
|
package/lib/initTelemetry.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {} from '@ms-cloudpack/config-types';
|
|
2
|
-
import { getVersion } from '@ms-cloudpack/package-utilities';
|
|
3
|
-
import { createTelemetryClient } from '@ms-cloudpack/telemetry';
|
|
4
|
-
import { registerPerformanceObservers } from './performance/registerPerformanceObservers.js';
|
|
5
|
-
/**
|
|
6
|
-
* Initialize the telemetry client, create the root span, register performance observers.
|
|
7
|
-
* Telemetry will not be sent if no instrumentation key is found.
|
|
8
|
-
* @param options - options to initialize telemetry
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
export async function initTelemetry(options, taskReporter) {
|
|
12
|
-
const connectionString = options.telemetryConfig?.connectionString || process.env.CLOUDPACK_TELEMETRY_CONNECTION_STRING;
|
|
13
|
-
const logLevel = options.useVerboseLogging ? 'VERBOSE' : options.useDebugLogging ? 'DEBUG' : undefined;
|
|
14
|
-
if (!options.useDebugLogging) {
|
|
15
|
-
taskReporter.ignoreLogMessage('ApplicationInsights:');
|
|
16
|
-
}
|
|
17
|
-
const telemetryClient = await createTelemetryClient({
|
|
18
|
-
productVersion: getVersion(import.meta.url),
|
|
19
|
-
connectionString,
|
|
20
|
-
logLevel,
|
|
21
|
-
serviceNamespace: 'cloudpack',
|
|
22
|
-
serviceName: 'cli',
|
|
23
|
-
rootSpanName: 'CLI',
|
|
24
|
-
});
|
|
25
|
-
if (options.sharedSpanAttributes) {
|
|
26
|
-
for (const [key, value] of Object.entries(options.sharedSpanAttributes)) {
|
|
27
|
-
telemetryClient.setSharedSpanAttribute(key, value);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
// Register performance observers to track performance metrics as events of CLI span.
|
|
31
|
-
registerPerformanceObservers(telemetryClient);
|
|
32
|
-
return telemetryClient;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=initTelemetry.js.map
|
package/lib/initTelemetry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initTelemetry.js","sourceRoot":"","sources":["../src/initTelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAuB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAU7F;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B,EAAE,YAA0B;IAC3F,MAAM,gBAAgB,GACpB,OAAO,CAAC,eAAe,EAAE,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC;IAEjG,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IACvG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;QAC7B,YAAY,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,qBAAqB,CAAC;QAClD,cAAc,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3C,gBAAgB;QAChB,QAAQ;QACR,gBAAgB,EAAE,WAAW;QAC7B,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;QACjC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;YACxE,eAAe,CAAC,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAED,qFAAqF;IACrF,4BAA4B,CAAC,eAAe,CAAC,CAAC;IAE9C,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import { type TelemetryConfig } from '@ms-cloudpack/config-types';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { createTelemetryClient, type SpanAttributes } from '@ms-cloudpack/telemetry';\nimport { registerPerformanceObservers } from './performance/registerPerformanceObservers.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\n\nexport interface TelemetryInitOptions {\n useDebugLogging: boolean;\n useVerboseLogging: boolean;\n telemetryConfig: TelemetryConfig | undefined;\n sharedSpanAttributes?: SpanAttributes;\n}\n\n/**\n * Initialize the telemetry client, create the root span, register performance observers.\n * Telemetry will not be sent if no instrumentation key is found.\n * @param options - options to initialize telemetry\n * @returns\n */\nexport async function initTelemetry(options: TelemetryInitOptions, taskReporter: TaskReporter) {\n const connectionString =\n options.telemetryConfig?.connectionString || process.env.CLOUDPACK_TELEMETRY_CONNECTION_STRING;\n\n const logLevel = options.useVerboseLogging ? 'VERBOSE' : options.useDebugLogging ? 'DEBUG' : undefined;\n if (!options.useDebugLogging) {\n taskReporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n connectionString,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n rootSpanName: 'CLI',\n });\n\n if (options.sharedSpanAttributes) {\n for (const [key, value] of Object.entries(options.sharedSpanAttributes)) {\n telemetryClient.setSharedSpanAttribute(key, value);\n }\n }\n\n // Register performance observers to track performance metrics as events of CLI span.\n registerPerformanceObservers(telemetryClient);\n\n return telemetryClient;\n}\n"]}
|
package/lib/setupReporting.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CloudpackConfig } from '@ms-cloudpack/config-types';
|
|
2
|
-
import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
3
|
-
import type { Command } from 'commander';
|
|
4
|
-
import type { SharedOptions } from './types/SharedOptions.js';
|
|
5
|
-
export declare function setupReporting(params: {
|
|
6
|
-
appName?: string;
|
|
7
|
-
options: SharedOptions;
|
|
8
|
-
reporter: TaskReporter;
|
|
9
|
-
config: CloudpackConfig;
|
|
10
|
-
/** Command object for the current command (not the whole program). */
|
|
11
|
-
command: Command;
|
|
12
|
-
}): Promise<import("@ms-cloudpack/telemetry").TelemetryClient>;
|
|
13
|
-
//# sourceMappingURL=setupReporting.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupReporting.d.ts","sourceRoot":"","sources":["../src/setupReporting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAML,KAAK,YAAY,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D,wBAAsB,cAAc,CAAC,MAAM,EAAE;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;IACxB,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;CAClB,8DA8CA"}
|
package/lib/setupReporting.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { getVersion } from '@ms-cloudpack/package-utilities';
|
|
2
|
-
import { bold, defaultLoggingConfig, verboseLoggingConfig, debugLoggingConfig, noLoggingConfig, } from '@ms-cloudpack/task-reporter';
|
|
3
|
-
import { initTelemetry } from './initTelemetry.js';
|
|
4
|
-
import { isCIBuild } from './utilities/isCIBuild.js';
|
|
5
|
-
const version = getVersion(import.meta.url);
|
|
6
|
-
export async function setupReporting(params) {
|
|
7
|
-
const { appName, config, reporter, options, command } = params;
|
|
8
|
-
// commander stores the original argv under the "program" command where `parseAsync` was called.
|
|
9
|
-
// Usually `command` is a sub-command (e.g. "bundle"), but it could also be a sub-sub-command
|
|
10
|
-
// (e.g. "cache clean"), so we look up two levels if present.
|
|
11
|
-
const program = command.parent?.parent || command.parent || command;
|
|
12
|
-
// It looks like rawArgs was intended to be a public API ("private" member are prefixed with _)
|
|
13
|
-
// but isn't included in the types...
|
|
14
|
-
const argv = program.rawArgs;
|
|
15
|
-
// For same reasons as above, check if this is a sub-sub-command
|
|
16
|
-
const verb = command.parent?.parent ? command.parent.name() : command.name();
|
|
17
|
-
// Set reporter options and print the product info header
|
|
18
|
-
reporter.setOptions({
|
|
19
|
-
productName: 'Cloudpack',
|
|
20
|
-
version,
|
|
21
|
-
description: () => `Running "${bold(argv.slice(2).join(' '))}"`,
|
|
22
|
-
helpMessage: config.helpMessage,
|
|
23
|
-
plainTextMode: !options.color,
|
|
24
|
-
...(options.debug
|
|
25
|
-
? debugLoggingConfig
|
|
26
|
-
: options.verbose
|
|
27
|
-
? verboseLoggingConfig
|
|
28
|
-
: options.quiet
|
|
29
|
-
? noLoggingConfig
|
|
30
|
-
: defaultLoggingConfig),
|
|
31
|
-
});
|
|
32
|
-
const telemetryClient = await initTelemetry({
|
|
33
|
-
useDebugLogging: !!options.debug,
|
|
34
|
-
useVerboseLogging: !!options.verbose,
|
|
35
|
-
telemetryConfig: config.telemetry,
|
|
36
|
-
sharedSpanAttributes: {
|
|
37
|
-
verb,
|
|
38
|
-
arguments: argv.slice(3).join(' '),
|
|
39
|
-
environment: isCIBuild() ? 'ci' : 'local',
|
|
40
|
-
appName: appName || '<unknown>',
|
|
41
|
-
},
|
|
42
|
-
}, reporter);
|
|
43
|
-
return telemetryClient;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=setupReporting.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupReporting.js","sourceRoot":"","sources":["../src/setupReporting.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EACL,IAAI,EACJ,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,GAEhB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAOpC;IACC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAE/D,gGAAgG;IAChG,6FAA6F;IAC7F,6DAA6D;IAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC;IACpE,+FAA+F;IAC/F,qCAAqC;IACrC,MAAM,IAAI,GAAI,OAA4C,CAAC,OAAO,CAAC;IAEnE,gEAAgE;IAChE,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAE7E,yDAAyD;IACzD,QAAQ,CAAC,UAAU,CAAC;QAClB,WAAW,EAAE,WAAW;QACxB,OAAO;QACP,WAAW,EAAE,GAAG,EAAE,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG;QAC/D,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,aAAa,EAAE,CAAC,OAAO,CAAC,KAAK;QAC7B,GAAG,CAAC,OAAO,CAAC,KAAK;YACf,CAAC,CAAC,kBAAkB;YACpB,CAAC,CAAC,OAAO,CAAC,OAAO;gBACf,CAAC,CAAC,oBAAoB;gBACtB,CAAC,CAAC,OAAO,CAAC,KAAK;oBACb,CAAC,CAAC,eAAe;oBACjB,CAAC,CAAC,oBAAoB,CAAC;KAC9B,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,MAAM,aAAa,CACzC;QACE,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK;QAChC,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO;QACpC,eAAe,EAAE,MAAM,CAAC,SAAS;QACjC,oBAAoB,EAAE;YACpB,IAAI;YACJ,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YAClC,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;YACzC,OAAO,EAAE,OAAO,IAAI,WAAW;SAChC;KACF,EACD,QAAQ,CACT,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/config-types';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport {\n bold,\n defaultLoggingConfig,\n verboseLoggingConfig,\n debugLoggingConfig,\n noLoggingConfig,\n type TaskReporter,\n} from '@ms-cloudpack/task-reporter';\nimport type { Command } from 'commander';\nimport { initTelemetry } from './initTelemetry.js';\nimport type { SharedOptions } from './types/SharedOptions.js';\nimport { isCIBuild } from './utilities/isCIBuild.js';\n\nconst version = getVersion(import.meta.url);\n\nexport async function setupReporting(params: {\n appName?: string;\n options: SharedOptions;\n reporter: TaskReporter;\n config: CloudpackConfig;\n /** Command object for the current command (not the whole program). */\n command: Command;\n}) {\n const { appName, config, reporter, options, command } = params;\n\n // commander stores the original argv under the \"program\" command where `parseAsync` was called.\n // Usually `command` is a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\"), so we look up two levels if present.\n const program = command.parent?.parent || command.parent || command;\n // It looks like rawArgs was intended to be a public API (\"private\" member are prefixed with _)\n // but isn't included in the types...\n const argv = (program as unknown as { rawArgs: string[] }).rawArgs;\n\n // For same reasons as above, check if this is a sub-sub-command\n const verb = command.parent?.parent ? command.parent.name() : command.name();\n\n // Set reporter options and print the product info header\n reporter.setOptions({\n productName: 'Cloudpack',\n version,\n description: () => `Running \"${bold(argv.slice(2).join(' '))}\"`,\n helpMessage: config.helpMessage,\n plainTextMode: !options.color,\n ...(options.debug\n ? debugLoggingConfig\n : options.verbose\n ? verboseLoggingConfig\n : options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n const telemetryClient = await initTelemetry(\n {\n useDebugLogging: !!options.debug,\n useVerboseLogging: !!options.verbose,\n telemetryConfig: config.telemetry,\n sharedSpanAttributes: {\n verb,\n arguments: argv.slice(3).join(' '),\n environment: isCIBuild() ? 'ci' : 'local',\n appName: appName || '<unknown>',\n },\n },\n reporter,\n );\n\n return telemetryClient;\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { CloudpackConfig } from '@ms-cloudpack/config-types';
|
|
2
|
-
import type { readConfig } from '@ms-cloudpack/config';
|
|
3
|
-
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
4
|
-
import type { TelemetryClient } from '@ms-cloudpack/telemetry';
|
|
5
|
-
export type CreateCommandContext = () => Promise<CommandContext>;
|
|
6
|
-
export interface CommandContext {
|
|
7
|
-
reporter: TaskReporter;
|
|
8
|
-
readConfig: typeof readConfig;
|
|
9
|
-
createTelemetryClient: (config: CloudpackConfig) => Promise<TelemetryClient>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=CommandContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommandContext.d.ts","sourceRoot":"","sources":["../../src/types/CommandContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;AAEjE,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,qBAAqB,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;CAC9E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommandContext.js","sourceRoot":"","sources":["../../src/types/CommandContext.ts"],"names":[],"mappings":"","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/config-types';\nimport type { readConfig } from '@ms-cloudpack/config';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\n\nexport type CreateCommandContext = () => Promise<CommandContext>;\n\nexport interface CommandContext {\n reporter: TaskReporter;\n readConfig: typeof readConfig;\n createTelemetryClient: (config: CloudpackConfig) => Promise<TelemetryClient>;\n}\n"]}
|