@ms-cloudpack/cli 0.57.4 → 0.57.6

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.
@@ -1,17 +1,19 @@
1
- import { Command, Option, type OutputConfiguration } from 'commander';
1
+ import { Command, Option, type Argument, type OutputConfiguration } from 'commander';
2
2
  import type { CommandActionModule } from '../types/CommandAction.js';
3
3
  import type { ProgramOptions } from '../types/ProgramOptions.js';
4
4
  /**
5
5
  * Parameters for creating a command.
6
6
  * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.
7
7
  */
8
- interface CloudpackCommandParams<TOptions extends object> {
8
+ interface CloudpackCommandParams<TOptions extends object, TArguments extends object> {
9
9
  /** Command name */
10
10
  name: string;
11
11
  /** Command description */
12
12
  description: string;
13
13
  /** Options specific to this command. The record ensures that all options are available in the CLI. */
14
14
  options?: Record<keyof TOptions, Option>;
15
+ /** Arguments specific to this command. */
16
+ args?: Record<keyof TArguments, Argument>;
15
17
  /**
16
18
  * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.
17
19
  * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse
@@ -35,22 +37,24 @@ interface CloudpackCommandParams<TOptions extends object> {
35
37
  * - The top-level "program" command should be created with `new CloudpackCommand()`.
36
38
  * - Sub-commands should be created with the `.addSubCommand` method on the parent.
37
39
  */
38
- export declare class CloudpackCommand<TOptions extends object> {
40
+ export declare class CloudpackCommand<TOptions extends object, TArguments extends object> {
39
41
  private _command;
40
42
  private _programOptions;
41
43
  /**
42
44
  * This should only be used directly (outside this class) to create the top-level `program` command.
43
45
  * To add sub-commands, use `.addSubCommand` instead.
44
46
  */
45
- constructor(params: CloudpackCommandParams<TOptions> & {
47
+ constructor(params: CloudpackCommandParams<TOptions, TArguments> & {
46
48
  programOptions: ProgramOptions;
47
49
  /** This must be undefined for the top-level program command */
48
50
  parent?: Command;
49
51
  });
50
52
  /** Create a child command. */
51
- addSubCommand<TChildOptions extends object>(params: CloudpackCommandParams<TChildOptions>): CloudpackCommand<TChildOptions>;
53
+ addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(params: CloudpackCommandParams<TChildOptions, TChildArguments>): CloudpackCommand<TChildOptions, TChildArguments>;
52
54
  /** Run the program (only works on the top-level program command). */
53
55
  run(): Promise<void>;
56
+ /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */
57
+ private _addArguemnts;
54
58
  /** Add options. The generic enforces that option objects are included for all keys of a type. */
55
59
  private _addOptions;
56
60
  private _addAction;
@@ -1 +1 @@
1
- {"version":3,"file":"CloudpackCommand.d.ts","sourceRoot":"","sources":["../../src/common/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAKjE;;;GAGG;AACH,UAAU,sBAAsB,CAAC,QAAQ,SAAS,MAAM;IACtD,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IAEb,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IAEpB,sGAAsG;IACtG,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEzC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE3D,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mDAAmD;IACnD,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAgB,CAAC,QAAQ,SAAS,MAAM;IACnD,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC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AAM,CAAC;IAEf,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mDAAmD;IACnD,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAgB,CAAC,QAAQ,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM;IAC9E,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,eAAe,CAAiB;IAExC;;;OAGG;gBAGD,MAAM,EAAE,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG;QACrD,cAAc,EAAE,cAAc,CAAC;QAC/B,+DAA+D;QAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB;IAsCH,8BAA8B;IACvB,aAAa,CAAC,aAAa,SAAS,MAAM,EAAE,eAAe,SAAS,MAAM,GAAG,KAAK,EACvF,MAAM,EAAE,sBAAsB,CAAC,aAAa,EAAE,eAAe,CAAC,GAC7D,gBAAgB,CAAC,aAAa,EAAE,eAAe,CAAC;IAQnD,qEAAqE;IACxD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAWjC,qGAAqG;IACrG,OAAO,CAAC,aAAa;IAMrB,iGAAiG;IACjG,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,UAAU;CAoCnB"}
@@ -26,6 +26,9 @@ export class CloudpackCommand {
26
26
  params.alias && command.alias(params.alias);
27
27
  params.outputOptions && command.configureOutput(params.outputOptions);
28
28
  params.getExecutor && this._addAction(params.getExecutor);
29
+ if (params.args) {
30
+ this._addArguemnts(params.args);
31
+ }
29
32
  if (params.options) {
30
33
  // Add the command-specific options first so they show up first in help
31
34
  this._addOptions(params.options);
@@ -60,6 +63,12 @@ export class CloudpackCommand {
60
63
  this._command.help();
61
64
  }
62
65
  }
66
+ /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */
67
+ _addArguemnts(args) {
68
+ for (const argument of Object.values(args)) {
69
+ this._command.addArgument(argument);
70
+ }
71
+ }
63
72
  /** Add options. The generic enforces that option objects are included for all keys of a type. */
64
73
  _addOptions(options) {
65
74
  for (const option of Object.values(options)) {
@@ -71,6 +80,9 @@ export class CloudpackCommand {
71
80
  // The action function receives parsed options as its first parameter, but we ignore those
72
81
  // because they only contain options *specific to this command*, not shared options like `debug`.
73
82
  command.action(async () => {
83
+ // Commander has support for custom parsers that parse arguments.
84
+ // Use processedArgs instead of args to get the parsed arguments.
85
+ const processedArgs = command.processedArgs;
74
86
  // Get the shared options too, not just the ones for this command.
75
87
  // (In `cloudpackCommand`, we added the shared options to each command object so that they show up
76
88
  // in help, but commander still seems to respect options only at the first command where they're
@@ -85,7 +97,13 @@ export class CloudpackCommand {
85
97
  // throw instead of exiting politely, since this is a major developer error
86
98
  throw new Error(`No execute function was exported from the command module for ${verb}.`);
87
99
  }
88
- const commandExecutor = new CommandExecutor({ options, execute, programOptions: this._programOptions, verb });
100
+ const commandExecutor = new CommandExecutor({
101
+ args: processedArgs,
102
+ options,
103
+ execute,
104
+ programOptions: this._programOptions,
105
+ verb,
106
+ });
89
107
  await commandExecutor.execute();
90
108
  });
91
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/common/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAA4B,MAAM,WAAW,CAAC;AAItE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAmCvD;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IAI3B;;;OAGG;IACH;IACE,4EAA4E;IAC5E,MAIC;QAED,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;QAE7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;Q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AAE,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEpG,0CAA0C;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9G,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { CommandExecutor } from './CommandExecutor.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>({\n 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 });\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object>(\n params: CloudpackCommandParams<TChildOptions>,\n ): CloudpackCommand<TChildOptions> {\n return new CloudpackCommand<TChildOptions>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(options: Record<keyof TAddOptions, Option>): void {\n for (const option of Object.values(options)) {\n this._command.addOption(option as Option); // not sure why this isn't being inferred\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions>['getExecutor']>) {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor({ options, execute, programOptions: this._programOptions, verb });\n await commandExecutor.execute();\n });\n }\n}\n"]}
1
+ {"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/common/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAA2C,MAAM,WAAW,CAAC;AAIrF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAsCvD;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IAI3B;;;OAGG;IACH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AAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAgB,CAAC,CAAC,CAAC,yCAAyC;QACtF,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,WAAqF;QACtG,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,0FAA0F;QAC1F,iGAAiG;QACjG,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;YACxB,iEAAiE;YACjE,iEAAiE;YACjE,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;YAE5C,kEAAkE;YAClE,kGAAkG;YAClG,gGAAgG;YAChG,6EAA6E;YAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,EAA4B,CAAC;YAEpE,kGAAkG;YAClG,wBAAwB;YACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEpG,0CAA0C;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,eAAe;gBACpC,IAAI;aACL,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { CommandExecutor } from './CommandExecutor.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n\n /** Arguments specific to this command. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>({\n 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 });\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>) {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(options: Record<keyof TAddOptions, Option>): void {\n for (const option of Object.values(options)) {\n this._command.addOption(option as Option); // not sure why this isn't being inferred\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>) {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs;\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n });\n await commandExecutor.execute();\n });\n }\n}\n"]}
@@ -13,7 +13,10 @@ export declare class CommandExecutor<TOptions extends SharedOptions> {
13
13
  private _autoDisposableList;
14
14
  private _abortController;
15
15
  private _hasCalledExit;
16
+ private _args;
16
17
  constructor(params: {
18
+ /** Command-specific arguments */
19
+ args: string[];
17
20
  /** Command-specific and shared options. */
18
21
  options: TOptions;
19
22
  /** Function to execute the command. */
@@ -1 +1 @@
1
- {"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/common/CommandExecutor.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,2BAA2B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAA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AO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAW;gBAEZ,MAAM,EAAE;QAClB,iCAAiC;QACjC,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,2CAA2C;QAC3C,OAAO,EAAE,QAAQ,CAAC;QAClB,uCAAuC;QACvC,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;QACjC,0CAA0C;QAC1C,cAAc,EAAE,cAAc,CAAC;QAC/B,sDAAsD;QACtD,IAAI,EAAE,MAAM,CAAC;KACd;IAWD,uBAAuB;IAEV,OAAO;IAyCpB;;;;;OAKG;YACW,WAAW;YAoGX,cAAc;IAkD5B;;;OAGG;IACH,OAAO,CAAC,KAAK,CA0BX;CACH"}
@@ -37,6 +37,7 @@ export class CommandExecutor {
37
37
  }
38
38
  process.exit(exitCode);
39
39
  };
40
+ this._args = params.args;
40
41
  this._options = params.options;
41
42
  this._execute = params.execute;
42
43
  this._programOptions = params.programOptions;
@@ -66,6 +67,7 @@ export class CommandExecutor {
66
67
  // Call the execute function which is the real command logic
67
68
  // (ie: real init command logic, real start command logic, etc.)
68
69
  await this._execute({
70
+ args: this._args,
69
71
  options: this._options,
70
72
  cwd: this._programOptions.cwd,
71
73
  reporter: this._reporter,
@@ -1 +1 @@
1
- {"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/common/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,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,qBAAqB,EAAwB,MAAM,yBAAyB,CAAC;AACtF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAA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,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7G,eAAe,CAAC,sBAAsB,CAAC,SAAS,EAAE,OAAO,IAAI,WAAW,CAAC,CAAC;QAE1E,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,YAAY,GAAG;gBACnB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBAClC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;gBAC7C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;gBACrC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,gCAAgC;aAC5D,CAAC;YAEF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBACxD,IAAI,KAAK,EAAE,CAAC;oBACV,eAAe,CAAC,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC;QACH,CAAC;QAED,qFAAqF;QACrF,4BAA4B,CAAC,eAAe,CAAC,CAAC;QAE9C,OAAO,eAAe,CAAC;IACzB,CAAC;CAiCF","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/config-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 { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport { registerPerformanceObservers } from '../performance/registerPerformanceObservers.js';\nimport type { CommandAction, InitContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport { getMergedFeatureFlags } from './getMergedFeatureFlags.js';\nimport { isCodespaces } from '../utilities/isCodespaces.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\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 _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _abortController: AbortController;\n private _hasCalledExit = false;\n\n constructor(params: {\n /** Command-specific and shared options. */\n options: TOptions;\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n }) {\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._reporter = new TaskReporter();\n this._abortController = new AbortController();\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() {\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 this._exit();\n });\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 this._execute({\n options: this._options,\n cwd: this._programOptions.cwd,\n reporter: this._reporter,\n initialize: this._initialize.bind(this),\n abortSignal: this._abortController.signal,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n exit: this._exit,\n });\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: error instanceof Error ? error.stack || error.message : String(error),\n });\n }\n }\n\n /**\n * This is the `initialize` function passed to the command's execute function.\n * This function uses `this` to references several class members, which is why\n * the `execute` method must use `.bind(this)`.\n * (An arrow function isn't possible here due to the overloaded method signature).\n */\n private async _initialize(initializeParams: {\n appPath: string;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<InitContext>;\n private async _initialize(initializeParams: {\n appPaths: string[];\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<InitContext[]>;\n private async _initialize(initializeParams: {\n appPath?: string;\n appPaths?: string[];\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<InitContext | InitContext[]> {\n const { appPath: singleAppPath } = initializeParams;\n let { appPaths } = initializeParams;\n\n if (singleAppPath && appPaths) {\n throw Error('appPath and appPaths cannot both be specified at the same time');\n }\n if (!singleAppPath && !appPaths) {\n throw Error('one of appPath or appPaths must be specified');\n }\n\n if (!appPaths || appPaths.length === 0) {\n appPaths = singleAppPath ? [singleAppPath] : [];\n }\n\n const initContexts = [];\n\n const actionOptions: SharedOptions = {\n ...this._options,\n ...initializeParams.overrideOptions,\n };\n\n const helpMessages = new Set<string>();\n\n const configs = new Map<string, CloudpackConfig>();\n for (const appPath of appPaths) {\n const config = await readConfig(appPath);\n if (config.helpMessage) {\n helpMessages.add(config.helpMessage);\n }\n configs.set(appPath, config);\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.entries()].join('\\n'),\n plainTextMode: !actionOptions.color,\n ...(actionOptions.debug\n ? debugLoggingConfig\n : actionOptions.verbose\n ? verboseLoggingConfig\n : actionOptions.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs.get(appPath) as CloudpackConfig;\n const definition = (await readJson(path.join(appPath, 'package.json'))) as PackageJson;\n\n const telemetryClient = await this._initTelemetry(definition.name, config);\n // Dispose the telemetry client when the app is closing\n this._autoDisposableList.add({\n dispose: () => telemetryClient.shutdown(),\n });\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 featureErrors = checkFeatures({ configFeatures: config.features });\n // If there are any invalid features, exit with an error.\n if (featureErrors.length) {\n featureErrors.forEach((error) => console.error(error));\n process.exit(1);\n }\n\n const enabledFeatureNames = Object.entries(config.features)\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n telemetryClient.setSharedSpanAttribute('features', enabledFeatureNames);\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n initContexts.push({\n appPath: appPath,\n telemetryClient,\n config,\n });\n }\n\n return singleAppPath ? initContexts[0] : initContexts;\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString = programOptions.disableTelemetry\n ? undefined\n : config.telemetry?.connectionString || process.env.CLOUDPACK_TELEMETRY_CONNECTION_STRING;\n\n const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;\n if (!options.debug) {\n this._reporter.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 const isCI = isCIBuild();\n\n telemetryClient.setSharedSpanAttribute('verb', this._verb);\n telemetryClient.setSharedSpanAttribute('arguments', programOptions.argv.slice(3).join(' '));\n telemetryClient.setSharedSpanAttribute('environment', isCI ? 'ci' : isCodespaces() ? 'codespaces' : 'local');\n telemetryClient.setSharedSpanAttribute('appName', appName || '<unknown>');\n\n if (isCI) {\n const ciAttributes = {\n buildId: process.env.BUILD_BUILDID,\n definitionId: process.env.SYSTEM_DEFINITIONID,\n buildReason: process.env.BUILD_REASON,\n pullRequestId: process.env.SYSTEM_PULLREQUEST_PULLREQUESTID,\n };\n\n for (const [key, value] of Object.entries(ciAttributes)) {\n if (value) {\n telemetryClient.setSharedSpanAttribute(key, value);\n }\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\n /**\n * This is the `exit` function passed to the command's execute function.\n * (It must be an arrow function to ensure the correct `this` context.)\n */\n private _exit = async (\n exitOptions: {\n hasErrors?: boolean;\n message?: string;\n exitCode?: number;\n } = {},\n ) => {\n const { message, hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = exitOptions;\n\n if (this._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 this._hasCalledExit = true;\n\n // Let the execute function know that we are exiting.\n this._abortController.abort();\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete(hasErrors ? red(message) : message);\n }\n\n process.exit(exitCode);\n };\n}\n"]}
1
+ {"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/common/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,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,qBAAqB,EAAwB,MAAM,yBAAyB,CAAC;AACtF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAI9F,OAAO,EAAE,SAAS,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GAAG,CAAC,CAAC,CAAC;QAC5F,eAAe,CAAC,sBAAsB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7G,eAAe,CAAC,sBAAsB,CAAC,SAAS,EAAE,OAAO,IAAI,WAAW,CAAC,CAAC;QAE1E,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,YAAY,GAAG;gBACnB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBAClC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;gBAC7C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;gBACrC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,gCAAgC;aAC5D,CAAC;YAEF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBACxD,IAAI,KAAK,EAAE,CAAC;oBACV,eAAe,CAAC,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC;QACH,CAAC;QAED,qFAAqF;QACrF,4BAA4B,CAAC,eAAe,CAAC,CAAC;QAE9C,OAAO,eAAe,CAAC;IACzB,CAAC;CAiCF","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/config-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 { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport { registerPerformanceObservers } from '../performance/registerPerformanceObservers.js';\nimport type { CommandAction, InitContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport { getMergedFeatureFlags } from './getMergedFeatureFlags.js';\nimport { isCodespaces } from '../utilities/isCodespaces.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\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 _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _abortController: AbortController;\n private _hasCalledExit = false;\n private _args: string[];\n\n constructor(params: {\n /** Command-specific arguments */\n args: string[];\n /** Command-specific and shared options. */\n options: TOptions;\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n }) {\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._reporter = new TaskReporter();\n this._abortController = new AbortController();\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() {\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 this._exit();\n });\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 this._execute({\n args: this._args,\n options: this._options,\n cwd: this._programOptions.cwd,\n reporter: this._reporter,\n initialize: this._initialize.bind(this),\n abortSignal: this._abortController.signal,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n exit: this._exit,\n });\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: error instanceof Error ? error.stack || error.message : String(error),\n });\n }\n }\n\n /**\n * This is the `initialize` function passed to the command's execute function.\n * This function uses `this` to references several class members, which is why\n * the `execute` method must use `.bind(this)`.\n * (An arrow function isn't possible here due to the overloaded method signature).\n */\n private async _initialize(initializeParams: {\n appPath: string;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<InitContext>;\n private async _initialize(initializeParams: {\n appPaths: string[];\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<InitContext[]>;\n private async _initialize(initializeParams: {\n appPath?: string;\n appPaths?: string[];\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<InitContext | InitContext[]> {\n const { appPath: singleAppPath } = initializeParams;\n let { appPaths } = initializeParams;\n\n if (singleAppPath && appPaths) {\n throw Error('appPath and appPaths cannot both be specified at the same time');\n }\n if (!singleAppPath && !appPaths) {\n throw Error('one of appPath or appPaths must be specified');\n }\n\n if (!appPaths || appPaths.length === 0) {\n appPaths = singleAppPath ? [singleAppPath] : [];\n }\n\n const initContexts = [];\n\n const actionOptions: SharedOptions = {\n ...this._options,\n ...initializeParams.overrideOptions,\n };\n\n const helpMessages = new Set<string>();\n\n const configs = new Map<string, CloudpackConfig>();\n for (const appPath of appPaths) {\n const config = await readConfig(appPath);\n if (config.helpMessage) {\n helpMessages.add(config.helpMessage);\n }\n configs.set(appPath, config);\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.entries()].join('\\n'),\n plainTextMode: !actionOptions.color,\n ...(actionOptions.debug\n ? debugLoggingConfig\n : actionOptions.verbose\n ? verboseLoggingConfig\n : actionOptions.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs.get(appPath) as CloudpackConfig;\n const definition = (await readJson(path.join(appPath, 'package.json'))) as PackageJson;\n\n const telemetryClient = await this._initTelemetry(definition.name, config);\n // Dispose the telemetry client when the app is closing\n this._autoDisposableList.add({\n dispose: () => telemetryClient.shutdown(),\n });\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 featureErrors = checkFeatures({ configFeatures: config.features });\n // If there are any invalid features, exit with an error.\n if (featureErrors.length) {\n featureErrors.forEach((error) => console.error(error));\n process.exit(1);\n }\n\n const enabledFeatureNames = Object.entries(config.features)\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n telemetryClient.setSharedSpanAttribute('features', enabledFeatureNames);\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n initContexts.push({\n appPath: appPath,\n telemetryClient,\n config,\n });\n }\n\n return singleAppPath ? initContexts[0] : initContexts;\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString = programOptions.disableTelemetry\n ? undefined\n : config.telemetry?.connectionString || process.env.CLOUDPACK_TELEMETRY_CONNECTION_STRING;\n\n const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;\n if (!options.debug) {\n this._reporter.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 const isCI = isCIBuild();\n\n telemetryClient.setSharedSpanAttribute('verb', this._verb);\n telemetryClient.setSharedSpanAttribute('arguments', programOptions.argv.slice(3).join(' '));\n telemetryClient.setSharedSpanAttribute('environment', isCI ? 'ci' : isCodespaces() ? 'codespaces' : 'local');\n telemetryClient.setSharedSpanAttribute('appName', appName || '<unknown>');\n\n if (isCI) {\n const ciAttributes = {\n buildId: process.env.BUILD_BUILDID,\n definitionId: process.env.SYSTEM_DEFINITIONID,\n buildReason: process.env.BUILD_REASON,\n pullRequestId: process.env.SYSTEM_PULLREQUEST_PULLREQUESTID,\n };\n\n for (const [key, value] of Object.entries(ciAttributes)) {\n if (value) {\n telemetryClient.setSharedSpanAttribute(key, value);\n }\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\n /**\n * This is the `exit` function passed to the command's execute function.\n * (It must be an arrow function to ensure the correct `this` context.)\n */\n private _exit = async (\n exitOptions: {\n hasErrors?: boolean;\n message?: string;\n exitCode?: number;\n } = {},\n ) => {\n const { message, hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = exitOptions;\n\n if (this._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 this._hasCalledExit = true;\n\n // Let the execute function know that we are exiting.\n this._abortController.abort();\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete(hasErrors ? red(message) : message);\n }\n\n process.exit(exitCode);\n };\n}\n"]}
@@ -21,6 +21,11 @@ export interface CommandActionParams<TOptions extends object> {
21
21
  * The command line options are defined in each command's `src/commands/<name>/index.ts` module.
22
22
  */
23
23
  options: TOptions;
24
+ /**
25
+ * Command-specific arguments. Arguments in commander are positional arguments that are not options.
26
+ * For example, in `echo somestring`, `somestring` is an argument.
27
+ */
28
+ args: string[];
24
29
  reporter: TaskReporter;
25
30
  abortSignal: AbortSignal;
26
31
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"CommandAction.d.ts","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,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AAM,EAAE,CAAC;YAAC,eAAe,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;SAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;KAC/G,CAAC;IAEF;;;OAGG;IACH,IAAI,EAAE,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,QAAQ,GAAG,aAAa,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/G,MAAM,MAAM,mBAAmB,CAAC,QAAQ,IAAI;IAC1C,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CAClC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandAction.js","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"","sourcesContent":["import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { AutoDispose } from './AutoDispose.js';\nimport type { SharedOptions } from './SharedOptions.js';\n\nexport type InitContext = {\n appPath: string;\n telemetryClient: TelemetryClient;\n config: CloudpackConfig;\n};\n\nexport interface CommandActionParams<TOptions extends object> {\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 /**\n * Command-specific options, parsed from `process.argv`.\n * Types are generally defined in each command's `src/commands/<name>/types/<Name>Types.ts` module.\n * The command line options are defined in each command's `src/commands/<name>/index.ts` module.\n */\n options: TOptions;\n\n reporter: TaskReporter;\n\n abortSignal: AbortSignal;\n\n /**\n * Function that can be called with any `Disposable`s that should be cleaned up automatically\n * when the program exits. (See `AutoDisposableList.add` for implementation.)\n */\n autoDispose: AutoDispose;\n\n /**\n * This should be called at or near the beginning of the action to initialize the config,\n * telemetry, and reporting. (See `createInitializeFunction` for implementation.)\n * `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.\n * If it is called with a single string, it returns `Promise<InitContext>`\n * If it is called with a string[], it returns `Promise<InitContext[]>`\n */\n initialize: {\n (initializeOptions: { appPath: string; overrideOptions?: Partial<SharedOptions> }): Promise<InitContext>;\n (initializeOptions: { appPaths: string[]; overrideOptions?: Partial<SharedOptions> }): Promise<InitContext[]>;\n };\n\n /**\n * This should be called at the end of the action to dispose resources, log completion,\n * and exit the program. (See `createExitFunction` for implementation.)\n */\n exit: (result: { exitCode: number; message?: string }) => Promise<void>;\n}\n\n/**\n * Command action function. This is the type of the `execute` function which should be exported\n * from each command's `src/commands/<name>/execute.ts` module.\n */\nexport type CommandAction<TOptions> = (params: CommandActionParams<TOptions & SharedOptions>) => Promise<void>;\n\nexport type CommandActionModule<TOptions> = {\n execute: CommandAction<TOptions>;\n};\n"]}
1
+ {"version":3,"file":"CommandAction.js","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"","sourcesContent":["import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { AutoDispose } from './AutoDispose.js';\nimport type { SharedOptions } from './SharedOptions.js';\n\nexport type InitContext = {\n appPath: string;\n telemetryClient: TelemetryClient;\n config: CloudpackConfig;\n};\n\nexport interface CommandActionParams<TOptions extends object> {\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 /**\n * Command-specific options, parsed from `process.argv`.\n * Types are generally defined in each command's `src/commands/<name>/types/<Name>Types.ts` module.\n * The command line options are defined in each command's `src/commands/<name>/index.ts` module.\n */\n options: TOptions;\n\n /**\n * Command-specific arguments. Arguments in commander are positional arguments that are not options.\n * For example, in `echo somestring`, `somestring` is an argument.\n */\n args: string[];\n\n reporter: TaskReporter;\n\n abortSignal: AbortSignal;\n\n /**\n * Function that can be called with any `Disposable`s that should be cleaned up automatically\n * when the program exits. (See `AutoDisposableList.add` for implementation.)\n */\n autoDispose: AutoDispose;\n\n /**\n * This should be called at or near the beginning of the action to initialize the config,\n * telemetry, and reporting. (See `createInitializeFunction` for implementation.)\n * `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.\n * If it is called with a single string, it returns `Promise<InitContext>`\n * If it is called with a string[], it returns `Promise<InitContext[]>`\n */\n initialize: {\n (initializeOptions: { appPath: string; overrideOptions?: Partial<SharedOptions> }): Promise<InitContext>;\n (initializeOptions: { appPaths: string[]; overrideOptions?: Partial<SharedOptions> }): Promise<InitContext[]>;\n };\n\n /**\n * This should be called at the end of the action to dispose resources, log completion,\n * and exit the program. (See `createExitFunction` for implementation.)\n */\n exit: (result: { exitCode: number; message?: string }) => Promise<void>;\n}\n\n/**\n * Command action function. This is the type of the `execute` function which should be exported\n * from each command's `src/commands/<name>/execute.ts` module.\n */\nexport type CommandAction<TOptions> = (params: CommandActionParams<TOptions & SharedOptions>) => Promise<void>;\n\nexport type CommandActionModule<TOptions> = {\n execute: CommandAction<TOptions>;\n};\n"]}
@@ -4,7 +4,7 @@ import type { CloudpackCommand } from '../common/CloudpackCommand.js';
4
4
  * This is the type for the `init` function exported by each `src/commands/<name>/index.ts` module.
5
5
  * @param program Command object for the program.
6
6
  */
7
- export type CommandInitFunction = (program: CloudpackCommand<object>) => void;
7
+ export type CommandInitFunction = (program: CloudpackCommand<object, object>) => void;
8
8
  /**
9
9
  * Type for each `src/commands/<name>/index.ts` module.
10
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"CommandInitFunction.d.ts","sourceRoot":"","sources":["../../src/types/CommandInitFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,mBAAmB,CAAC;CAC3B,CAAC"}
1
+ {"version":3,"file":"CommandInitFunction.d.ts","sourceRoot":"","sources":["../../src/types/CommandInitFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AAEtF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,mBAAmB,CAAC;CAC3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandInitFunction.js","sourceRoot":"","sources":["../../src/types/CommandInitFunction.ts"],"names":[],"mappings":"","sourcesContent":["import type { CloudpackCommand } from '../common/CloudpackCommand.js';\n\n/**\n * Initialize a command object for a sub-command.\n * This is the type for the `init` function exported by each `src/commands/<name>/index.ts` module.\n * @param program Command object for the program.\n */\nexport type CommandInitFunction = (program: CloudpackCommand<object>) => void;\n\n/**\n * Type for each `src/commands/<name>/index.ts` module.\n */\nexport type CommandInitModule = {\n init: CommandInitFunction;\n};\n"]}
1
+ {"version":3,"file":"CommandInitFunction.js","sourceRoot":"","sources":["../../src/types/CommandInitFunction.ts"],"names":[],"mappings":"","sourcesContent":["import type { CloudpackCommand } from '../common/CloudpackCommand.js';\n\n/**\n * Initialize a command object for a sub-command.\n * This is the type for the `init` function exported by each `src/commands/<name>/index.ts` module.\n * @param program Command object for the program.\n */\nexport type CommandInitFunction = (program: CloudpackCommand<object, object>) => void;\n\n/**\n * Type for each `src/commands/<name>/index.ts` module.\n */\nexport type CommandInitModule = {\n init: CommandInitFunction;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.57.4",
3
+ "version": "0.57.6",
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,19 +10,19 @@
10
10
  "cloudpack": "./bin/cloudpack.js"
11
11
  },
12
12
  "dependencies": {
13
- "@ms-cloudpack/api-server": "^0.33.1",
14
- "@ms-cloudpack/app-server": "^0.2.9",
15
- "@ms-cloudpack/bundle-server": "^0.2.39",
13
+ "@ms-cloudpack/api-server": "^0.33.3",
14
+ "@ms-cloudpack/app-server": "^0.2.11",
15
+ "@ms-cloudpack/bundle-server": "^0.2.41",
16
16
  "@ms-cloudpack/config": "^0.17.38",
17
17
  "@ms-cloudpack/config-types": "^0.7.0",
18
18
  "@ms-cloudpack/feature-flags": "^0.1.1",
19
19
  "@ms-cloudpack/json-utilities": "^0.1.4",
20
- "@ms-cloudpack/overlay": "^0.16.88",
20
+ "@ms-cloudpack/overlay": "^0.16.90",
21
21
  "@ms-cloudpack/package-utilities": "^7.0.1",
22
22
  "@ms-cloudpack/path-string-parsing": "^1.2.1",
23
23
  "@ms-cloudpack/path-utilities": "^2.6.1",
24
- "@ms-cloudpack/remote-cache": "^0.6.1",
25
- "@ms-cloudpack/task-reporter": "^0.11.2",
24
+ "@ms-cloudpack/remote-cache": "^0.6.2",
25
+ "@ms-cloudpack/task-reporter": "^0.11.3",
26
26
  "@ms-cloudpack/telemetry": "^0.5.1",
27
27
  "@yarnpkg/lockfile": "^1.1.0",
28
28
  "commander": "^11.1.0",
@@ -35,10 +35,10 @@
35
35
  "workspace-tools": "^0.36.4"
36
36
  },
37
37
  "devDependencies": {
38
- "@ms-cloudpack/bundler-types": "*",
39
- "@ms-cloudpack/eslint-plugin-internal": "*",
40
- "@ms-cloudpack/scripts": "*",
41
- "@ms-cloudpack/test-utilities": "*",
38
+ "@ms-cloudpack/bundler-types": "^0.25.2",
39
+ "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
40
+ "@ms-cloudpack/scripts": "^0.0.1",
41
+ "@ms-cloudpack/test-utilities": "^0.5.0",
42
42
  "@types/cross-spawn": "^6.0.2",
43
43
  "@types/didyoumean": "^1.2.2",
44
44
  "@types/prompts": "^2.4.4",