@ms-cloudpack/cli 0.77.1 → 0.77.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAK9E,gCAAgC;AAChC,eAAO,MAAM,IAAI,EAAE,mBAwBlB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAQ9E,gCAAgC;AAChC,eAAO,MAAM,IAAI,EAAE,mBAmClB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { InvalidArgumentError, Option } from 'commander';
2
2
  import { portNumbers } from 'get-port';
3
3
  import { reusedOptions } from '../../utilities/reusedOptions.js';
4
+ // verify the values are correct
5
+ const showOverlayChoices = ['always', 'errors-only', 'never'];
4
6
  /** Defines the "start" verb. */
5
7
  export const init = (program) => {
6
8
  program.addSubCommand({
@@ -14,6 +16,7 @@ export const init = (program) => {
14
16
  ],
15
17
  cache: reusedOptions.cache(),
16
18
  mode: reusedOptions.mode({ action: 'run' }),
19
+ showOverlay: new Option('--show-overlay <when>', 'Override whether to show the Cloudpack overlay (status badge and dialog) in the app UI.').choices(showOverlayChoices),
17
20
  logResolveMap: reusedOptions.logResolveMap(),
18
21
  logBundleInfo: reusedOptions.logBundleInfo({ requiresNoCache: true }),
19
22
  apiServerPort: getPortOption('--api-server-port <port>', 'API', true),
@@ -21,6 +24,11 @@ export const init = (program) => {
21
24
  bundleServerPort: getPortOption('--bundle-server-port <port>', 'bundle'),
22
25
  login: reusedOptions.login('start'),
23
26
  },
27
+ applyOptionsToConfig: (options) => {
28
+ if (options.showOverlay) {
29
+ return { extraServerConfig: { showOverlay: options.showOverlay } };
30
+ }
31
+ },
24
32
  getExecutor: () => import('./execute.js'),
25
33
  // If cwd isn't a cloudpack app, discover other cloudpack apps and possibly prompt the user
26
34
  // to choose one. Also handles --app.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,gCAAgC;AAChC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAe;QAClC,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,qCAAqC;QAClD,OAAO,EAAE;YACP,GAAG,EAAE,aAAa,CAAC,GAAG,EAAE;YACxB,IAAI,EAAE;gBACJ,IAAI,MAAM,CAAC,cAAc,EAAE,qCAAqC,CAAC;gBACjE,IAAI,MAAM,CAAC,WAAW,EAAE,0BAA0B,CAAC;aACpD;YACD,KAAK,EAAE,aAAa,CAAC,KAAK,EAAE;YAC5B,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;YAC3C,aAAa,EAAE,aAAa,CAAC,aAAa,EAAE;YAC5C,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;YACrE,aAAa,EAAE,aAAa,CAAC,0BAA0B,EAAE,KAAK,EAAE,IAAI,CAAC;YACrE,aAAa,EAAE,aAAa,CAAC,0BAA0B,EAAE,KAAK,CAAC;YAC/D,gBAAgB,EAAE,aAAa,CAAC,6BAA6B,EAAE,QAAQ,CAAC;YACxE,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;SACpC;QACD,WAAW,EAAE,GAAG,E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Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { portNumbers } from 'get-port';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n/** Defines the \"start\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<StartOptions>({\n name: 'start',\n description: 'Starts a web inner-loop for an app.',\n options: {\n app: reusedOptions.app(),\n open: [\n new Option('--open <url>', 'Open the browser to a specific URL.'),\n new Option('--no-open', 'Do not open the browser.'),\n ],\n cache: reusedOptions.cache(),\n mode: reusedOptions.mode({ action: 'run' }),\n logResolveMap: reusedOptions.logResolveMap(),\n logBundleInfo: reusedOptions.logBundleInfo({ requiresNoCache: true }),\n apiServerPort: getPortOption('--api-server-port <port>', 'API', true),\n appServerPort: getPortOption('--app-server-port <port>', 'app'),\n bundleServerPort: getPortOption('--bundle-server-port <port>', 'bundle'),\n login: reusedOptions.login('start'),\n },\n getExecutor: () => import('./execute.js'),\n // If cwd isn't a cloudpack app, discover other cloudpack apps and possibly prompt the user\n // to choose one. Also handles --app.\n discoverAppPaths: 'single',\n });\n};\n\nfunction getPortOption(flags: string, name: string, isFirst?: boolean): Option {\n return new Option(\n flags,\n `Port for the ${name} server (${isFirst ? 'single, comma-separated, or range with dash' : 'as above'}).`,\n ).argParser(parsePorts);\n}\n\nfunction parsePorts(value: string): number[] {\n if (value.includes('-')) {\n const split = value.split('-');\n if (split.length !== 2) {\n throw new InvalidArgumentError(`Invalid port range: \"${value}\"`);\n }\n return [...portNumbers(parseNumber(split[0]), parseNumber(split[1]))];\n }\n\n return value.split(',').map(parseNumber);\n}\n\nfunction parseNumber(value: string): number {\n value = value.trim();\n const parsed = parseInt(value, 10);\n if (isNaN(parsed)) {\n throw new InvalidArgumentError(`Port must be a number; received: \"${value}\"`);\n }\n return parsed;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAAA,O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K,CAAC,MAAM,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,oBAAoB,CAAC,qCAAqC,KAAK,GAAG,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { InvalidArgumentError, Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { portNumbers } from 'get-port';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n// verify the values are correct\nconst showOverlayChoices: NonNullable<StartOptions['showOverlay']>[] = ['always', 'errors-only', 'never'];\n\n/** Defines the \"start\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<StartOptions>({\n name: 'start',\n description: 'Starts a web inner-loop for an app.',\n options: {\n app: reusedOptions.app(),\n open: [\n new Option('--open <url>', 'Open the browser to a specific URL.'),\n new Option('--no-open', 'Do not open the browser.'),\n ],\n cache: reusedOptions.cache(),\n mode: reusedOptions.mode({ action: 'run' }),\n showOverlay: new Option(\n '--show-overlay <when>',\n 'Override whether to show the Cloudpack overlay (status badge and dialog) in the app UI.',\n // Don't specify a default for this option to avoid unconditionally overriding any value\n // set in the ServerConfig\n ).choices(showOverlayChoices),\n logResolveMap: reusedOptions.logResolveMap(),\n logBundleInfo: reusedOptions.logBundleInfo({ requiresNoCache: true }),\n apiServerPort: getPortOption('--api-server-port <port>', 'API', true),\n appServerPort: getPortOption('--app-server-port <port>', 'app'),\n bundleServerPort: getPortOption('--bundle-server-port <port>', 'bundle'),\n login: reusedOptions.login('start'),\n },\n applyOptionsToConfig: (options) => {\n if (options.showOverlay) {\n return { extraServerConfig: { showOverlay: options.showOverlay } };\n }\n },\n getExecutor: () => import('./execute.js'),\n // If cwd isn't a cloudpack app, discover other cloudpack apps and possibly prompt the user\n // to choose one. Also handles --app.\n discoverAppPaths: 'single',\n });\n};\n\nfunction getPortOption(flags: string, name: string, isFirst?: boolean): Option {\n return new Option(\n flags,\n `Port for the ${name} server (${isFirst ? 'single, comma-separated, or range with dash' : 'as above'}).`,\n ).argParser(parsePorts);\n}\n\nfunction parsePorts(value: string): number[] {\n if (value.includes('-')) {\n const split = value.split('-');\n if (split.length !== 2) {\n throw new InvalidArgumentError(`Invalid port range: \"${value}\"`);\n }\n return [...portNumbers(parseNumber(split[0]), parseNumber(split[1]))];\n }\n\n return value.split(',').map(parseNumber);\n}\n\nfunction parseNumber(value: string): number {\n value = value.trim();\n const parsed = parseInt(value, 10);\n if (isNaN(parsed)) {\n throw new InvalidArgumentError(`Port must be a number; received: \"${value}\"`);\n }\n return parsed;\n}\n"]}
@@ -2,7 +2,7 @@ import type { PartialContext } from '@ms-cloudpack/api-server';
2
2
  /** Open the browser. */
3
3
  export declare function openBrowser(options: {
4
4
  url: string;
5
- }, context: PartialContext<'telemetryClient', 'urls'>): Promise<void>;
5
+ }, context: PartialContext<'telemetryClient', 'config' | 'urls'>): Promise<void>;
6
6
  /** Set an override for the browser opening behavior. `null` disables opening. */
7
7
  export declare function overrideOpenBrowser(fn: typeof openBrowser | null): void;
8
8
  /** Get the most recently opened URL (for tests) */
@@ -1 +1 @@
1
- {"version":3,"file":"openBrowser.d.ts","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM/D,wBAAwB;AACxB,wBAAsB,WAAW,CAC/B,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC;CACb,EAED,OAAO,EAAE,cAAc,CAAC,iBAAiB,EAAE,MAAM,CAAC,GACjD,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,OAAO,WAAW,GAAG,IAAI,GAAG,IAAI,CAEvE;AAED,mDAAmD;AACnD,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD;AAED,qDAAqD;AACrD,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
1
+ {"version":3,"file":"openBrowser.d.ts","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM/D,wBAAwB;AACxB,wBAAsB,WAAW,CAC/B,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC;CACb,EAED,OAAO,EAAE,cAAc,CAAC,iBAAiB,EAAE,QAAQ,GAAG,MAAM,CAAC,GAC5D,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,OAAO,WAAW,GAAG,IAAI,GAAG,IAAI,CAEvE;AAED,mDAAmD;AACnD,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD;AAED,qDAAqD;AACrD,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
@@ -3,7 +3,7 @@ let lastOpenedUrl;
3
3
  let altOpenBrowser;
4
4
  /** Open the browser. */
5
5
  export async function openBrowser(options,
6
- // urls aren't used directly in the function, but are used in a test via overrideOpenBrowser
6
+ // session properties aren't used directly in the function, but are used in a test via overrideOpenBrowser
7
7
  context) {
8
8
  const { url } = options;
9
9
  const { telemetryClient } = context;
@@ -1 +1 @@
1
- {"version":3,"file":"openBrowser.js","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,IAAI,aAAiC,CAAC;AACtC,IAAI,cAAqD,CAAC;AAE1D,wBAAwB;AACxB,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAEC;AACD,4FAA4F;AAC5F,OAAkD;IAElD,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEpC,aAAa,GAAG,GAAG,CAAC;IACpB,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;SAAM,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QACnC,kIAAkI;QAClI,MAAM,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACxG,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,mBAAmB,CAAC,EAA6B;IAC/D,cAAc,GAAG,EAAE,CAAC;AACtB,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,kBAAkB;IAChC,aAAa,GAAG,SAAS,CAAC;AAC5B,CAAC","sourcesContent":["import type { PartialContext } from '@ms-cloudpack/api-server';\nimport open from 'open';\n\nlet lastOpenedUrl: string | undefined;\nlet altOpenBrowser: typeof openBrowser | null | undefined;\n\n/** Open the browser. */\nexport async function openBrowser(\n options: {\n url: string;\n },\n // urls aren't used directly in the function, but are used in a test via overrideOpenBrowser\n context: PartialContext<'telemetryClient', 'urls'>,\n): Promise<void> {\n const { url } = options;\n const { telemetryClient } = context;\n\n lastOpenedUrl = url;\n if (altOpenBrowser) {\n await altOpenBrowser(options, context);\n } else if (altOpenBrowser !== null) {\n // This span measures the time required to create a process for the browser, but it does not imply that the browser is fully open.\n await telemetryClient.tracer.startActiveSpan('OPEN_BROWSER', () => open(url, { newInstance: false }));\n }\n}\n\n/** Set an override for the browser opening behavior. `null` disables opening. */\nexport function overrideOpenBrowser(fn: typeof openBrowser | null): void {\n altOpenBrowser = fn;\n}\n\n/** Get the most recently opened URL (for tests) */\nexport function getLastOpenedUrl(): string | undefined {\n return lastOpenedUrl;\n}\n\n/** Reset the most recently opened URL (for tests) */\nexport function resetLastOpenedUrl(): void {\n lastOpenedUrl = undefined;\n}\n"]}
1
+ {"version":3,"file":"openBrowser.js","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,IAAI,aAAiC,CAAC;AACtC,IAAI,cAAqD,CAAC;AAE1D,wBAAwB;AACxB,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAEC;AACD,0GAA0G;AAC1G,OAA6D;IAE7D,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEpC,aAAa,GAAG,GAAG,CAAC;IACpB,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;SAAM,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QACnC,kIAAkI;QAClI,MAAM,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACxG,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,mBAAmB,CAAC,EAA6B;IAC/D,cAAc,GAAG,EAAE,CAAC;AACtB,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,kBAAkB;IAChC,aAAa,GAAG,SAAS,CAAC;AAC5B,CAAC","sourcesContent":["import type { PartialContext } from '@ms-cloudpack/api-server';\nimport open from 'open';\n\nlet lastOpenedUrl: string | undefined;\nlet altOpenBrowser: typeof openBrowser | null | undefined;\n\n/** Open the browser. */\nexport async function openBrowser(\n options: {\n url: string;\n },\n // session properties aren't used directly in the function, but are used in a test via overrideOpenBrowser\n context: PartialContext<'telemetryClient', 'config' | 'urls'>,\n): Promise<void> {\n const { url } = options;\n const { telemetryClient } = context;\n\n lastOpenedUrl = url;\n if (altOpenBrowser) {\n await altOpenBrowser(options, context);\n } else if (altOpenBrowser !== null) {\n // This span measures the time required to create a process for the browser, but it does not imply that the browser is fully open.\n await telemetryClient.tracer.startActiveSpan('OPEN_BROWSER', () => open(url, { newInstance: false }));\n }\n}\n\n/** Set an override for the browser opening behavior. `null` disables opening. */\nexport function overrideOpenBrowser(fn: typeof openBrowser | null): void {\n altOpenBrowser = fn;\n}\n\n/** Get the most recently opened URL (for tests) */\nexport function getLastOpenedUrl(): string | undefined {\n return lastOpenedUrl;\n}\n\n/** Reset the most recently opened URL (for tests) */\nexport function resetLastOpenedUrl(): void {\n lastOpenedUrl = undefined;\n}\n"]}
@@ -1,5 +1,6 @@
1
+ import type { ServerConfig } from '@ms-cloudpack/common-types';
1
2
  import type { ReusedOptions } from '../../../types/ReusedOptions.js';
2
- export interface StartOptions extends Pick<ReusedOptions, 'app' | 'cache' | 'login' | 'logBundleInfo' | 'logResolveMap' | 'mode'> {
3
+ export interface StartOptions extends Pick<ReusedOptions, 'app' | 'cache' | 'login' | 'logBundleInfo' | 'logResolveMap' | 'mode'>, Pick<ServerConfig, 'showOverlay'> {
3
4
  /** Whether to open the browser or a specific url to open the browser to (default true) */
4
5
  open?: boolean | string;
5
6
  /** Mostly for testing: custom port for the API server */
@@ -1 +1 @@
1
- {"version":3,"file":"StartOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/types/StartOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,WAAW,YACf,SAAQ,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,eAAe,GAAG,eAAe,GAAG,MAAM,CAAC;IACnG,0FAA0F;IAC1F,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAExB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAElC,gGAAgG;IAChG,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAElC,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACtC"}
1
+ {"version":3,"file":"StartOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/types/StartOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,WAAW,YACf,SAAQ,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,eAAe,GAAG,eAAe,GAAG,MAAM,CAAC,EACjG,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC;IACnC,0FAA0F;IAC1F,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAExB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAElC,gGAAgG;IAChG,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAElC,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"StartOptions.js","sourceRoot":"","sources":["../../../../src/commands/start/types/StartOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReusedOptions } from '../../../types/ReusedOptions.js';\n\nexport interface StartOptions\n extends Pick<ReusedOptions, 'app' | 'cache' | 'login' | 'logBundleInfo' | 'logResolveMap' | 'mode'> {\n /** Whether to open the browser or a specific url to open the browser to (default true) */\n open?: boolean | string;\n\n /** Mostly for testing: custom port for the API server */\n apiServerPort?: number | number[];\n\n /** Mostly for testing: custom port for the app server (also set in config via `server.port`) */\n appServerPort?: number | number[];\n\n /** Mostly for testing: custom port for the bundle server */\n bundleServerPort?: number | number[];\n}\n"]}
1
+ {"version":3,"file":"StartOptions.js","sourceRoot":"","sources":["../../../../src/commands/start/types/StartOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServerConfig } from '@ms-cloudpack/common-types';\nimport type { ReusedOptions } from '../../../types/ReusedOptions.js';\n\nexport interface StartOptions\n extends Pick<ReusedOptions, 'app' | 'cache' | 'login' | 'logBundleInfo' | 'logResolveMap' | 'mode'>,\n Pick<ServerConfig, 'showOverlay'> {\n /** Whether to open the browser or a specific url to open the browser to (default true) */\n open?: boolean | string;\n\n /** Mostly for testing: custom port for the API server */\n apiServerPort?: number | number[];\n\n /** Mostly for testing: custom port for the app server (also set in config via `server.port`) */\n appServerPort?: number | number[];\n\n /** Mostly for testing: custom port for the bundle server */\n bundleServerPort?: number | number[];\n}\n"]}
@@ -1,13 +1,12 @@
1
1
  import { Command, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';
2
2
  import type { CommandActionModule } from '../types/CommandAction.js';
3
- import type { ProgramOptions } from '../types/ProgramOptions.js';
4
3
  import type { SharedOptions } from '../types/SharedOptions.js';
5
4
  import { type CommandExecutorParams } from './CommandExecutor.js';
6
5
  /**
7
6
  * Parameters for creating a command.
8
7
  * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.
9
8
  */
10
- interface CloudpackCommandParams<TOptions extends object, TArguments extends object> extends Pick<CommandExecutorParams, 'discoverAppPaths'> {
9
+ interface CloudpackCommandParams<TOptions extends object, TArguments extends object> extends Partial<Pick<CommandExecutorParams<TOptions>, 'discoverAppPaths' | 'applyOptionsToConfig'>> {
11
10
  /** Command name */
12
11
  name: string;
13
12
  /** Command description */
@@ -58,14 +57,12 @@ interface CloudpackCommandParams<TOptions extends object, TArguments extends obj
58
57
  */
59
58
  export declare class CloudpackCommand<TOptions extends object, TArguments extends object> {
60
59
  private _command;
61
- private _programOptions;
62
- private _discoverAppPaths;
60
+ private _executorOptions;
63
61
  /**
64
62
  * This should only be used directly (outside this class) to create the top-level `program` command.
65
63
  * To add sub-commands, use `.addSubCommand` instead.
66
64
  */
67
- constructor(params: CloudpackCommandParams<TOptions, TArguments> & {
68
- programOptions: ProgramOptions;
65
+ constructor(params: CloudpackCommandParams<TOptions, TArguments> & Pick<CommandExecutorParams<TOptions>, 'programOptions'> & {
69
66
  /** This must be undefined for the top-level program command */
70
67
  parent?: Command;
71
68
  });
@@ -1 +1 @@
1
- {"version":3,"file":"CloudpackCommand.d.ts","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC/G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAmB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAOnF;;;GAGG;AACH,UAAU,sBAAsB,CAAC,QAAQ,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM,CACjF,SAAQ,IAAI,CAAC,qBAAqB,EAAE,kBAAkB,CAAC;IACvD,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IAEb,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAEpD,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE1C;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE3D,6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AgB,CAAC,QAAQ,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM;IAC9E,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,gBAAgB,CAGtB;IAEF;;;OAGG;gBAGD,MAAM,EAAE,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAAC,GAClD,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,GAAG;QACxD,+DAA+D;QAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB;IAwEL,8BAA8B;IACvB,aAAa,CAAC,aAAa,SAAS,MAAM,EAAE,eAAe,SAAS,MAAM,GAAG,KAAK,EACvF,MAAM,EAAE,sBAAsB,CAAC,aAAa,EAAE,eAAe,CAAC,GAC7D,gBAAgB,CAAC,aAAa,EAAE,eAAe,CAAC;IAQnD,qEAAqE;IACxD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAWjC,qGAAqG;IACrG,OAAO,CAAC,aAAa;IAMrB,iGAAiG;IACjG,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,UAAU;CAoCnB"}
@@ -14,8 +14,7 @@ import { CloudpackHelp, optionGroups } from './CloudpackHelp.js';
14
14
  */
15
15
  export class CloudpackCommand {
16
16
  _command;
17
- _programOptions;
18
- _discoverAppPaths;
17
+ _executorOptions;
19
18
  /**
20
19
  * This should only be used directly (outside this class) to create the top-level `program` command.
21
20
  * To add sub-commands, use `.addSubCommand` instead.
@@ -23,8 +22,11 @@ export class CloudpackCommand {
23
22
  constructor(
24
23
  // The extra options here shouldn't be exposed to the `createSubCommand` API
25
24
  params) {
26
- this._programOptions = params.programOptions;
27
- this._discoverAppPaths = params.discoverAppPaths;
25
+ this._executorOptions = {
26
+ programOptions: params.programOptions,
27
+ discoverAppPaths: params.discoverAppPaths,
28
+ applyOptionsToConfig: params.applyOptionsToConfig,
29
+ };
28
30
  const command = params.parent?.command(params.name) || new Command(params.name);
29
31
  this._command = command;
30
32
  command.version(params.programOptions.version);
@@ -77,7 +79,7 @@ export class CloudpackCommand {
77
79
  addSubCommand(params) {
78
80
  return new CloudpackCommand({
79
81
  ...params,
80
- programOptions: this._programOptions,
82
+ programOptions: this._executorOptions.programOptions,
81
83
  parent: this._command,
82
84
  });
83
85
  }
@@ -86,7 +88,7 @@ export class CloudpackCommand {
86
88
  if (this._command.parent) {
87
89
  throw new Error('Only the top-level program command can be run directly.');
88
90
  }
89
- await this._command.parseAsync(this._programOptions.argv);
91
+ await this._command.parseAsync(this._executorOptions.programOptions.argv);
90
92
  if (this._command.args.length === 0) {
91
93
  this._command.help();
92
94
  }
@@ -135,9 +137,8 @@ export class CloudpackCommand {
135
137
  args: processedArgs,
136
138
  options,
137
139
  execute,
138
- programOptions: this._programOptions,
139
140
  verb,
140
- discoverAppPaths: this._discoverAppPaths,
141
+ ...this._executorOptions,
141
142
  });
142
143
  await commandExecutor.execute();
143
144
  });
@@ -1 +1 @@
1
- {"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAI/G,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0DjE;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IACnB,QAAQ,CAAU;IAClB,eAAe,CAAiB;IAChC,iBAAiB,CAAmC;IAE5D;;;OAGG;IACH;IACE,4EAA4E;IAC5E,MAIC;QAED,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,iBAAiB,GA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,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,eAAe;gBACpC,IAAI;gBACJ,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;aACzC,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { CommandExecutor, type CommandExecutorParams } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { parseFeature } from './parseFeature.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { parseDefine } from './parseDefine.js';\nimport { CloudpackHelp, optionGroups } from './CloudpackHelp.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object>\n extends Pick<CommandExecutorParams, 'discoverAppPaths'> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /**\n * Options specific to this command. The record ensures that all options are available in the CLI.\n * Allow multiple options for the same key since commander supports it with negatable options.\n */\n options?: Record<keyof TOptions, Option | Option[]>; //\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n this._discoverAppPaths = params.discoverAppPaths;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n\n const isTopLevel = !params.parent;\n command.createHelp = () => new CloudpackHelp({ isTopLevel });\n // set the default help group for options\n command.optionsGroup(optionGroups.default);\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details in logging.').helpGroup(optionGroups.logging),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).')\n .conflicts('verbose')\n .helpGroup(optionGroups.logging),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.')\n .conflicts('verbose')\n .conflicts('debug')\n .helpGroup(optionGroups.logging),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.')\n .helpGroup(optionGroups.logging)\n .default(!environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI),\n logFile: new Option('--log-file', 'Write a log file with all console output.').helpGroup(optionGroups.logging),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ).helpGroup(optionGroups.common),\n config: new Option(\n '-c, --config <filename>',\n 'Custom config file name to use instead of cloudpack.config.json.',\n ).helpGroup(optionGroups.common),\n define: new Option('--define <key=value>', 'Define a global variable. Can be specified multiple times.')\n .helpGroup(optionGroups.common)\n .argParser(parseDefine),\n features: new Option('--features <featureNames...>', 'Enable experimental features.')\n .helpGroup(optionGroups.common)\n .argParser(parseFeature),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>): void {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option | Option[]>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, optionOrOptions] of Object.entries(options) as [keyof TAddOptions, Option | Option[]][]) {\n const optionArray = Array.isArray(optionOrOptions) ? optionOrOptions : [optionOrOptions];\n for (const option of optionArray) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>): void {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n discoverAppPaths: this._discoverAppPaths,\n });\n await commandExecutor.execute();\n });\n }\n}\n"]}
1
+ {"version":3,"file":"C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AiE;YACjE,iEAAiE;YACjE,MAAM,aAAa,GAAG,OAAO,CAAC,aAAyB,CAAC;YAExD,kEAAkE;YAClE,kGAAkG;YAClG,gGAAgG;YAChG,6EAA6E;YAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,EAA4B,CAAC;YAEpE,kGAAkG;YAClG,wBAAwB;YACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEpG,0CAA0C;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,IAAI;gBACJ,GAAG,IAAI,CAAC,gBAAgB;aACzB,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { CommandExecutor, type CommandExecutorParams } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { parseFeature } from './parseFeature.js';\nimport { parseDefine } from './parseDefine.js';\nimport { CloudpackHelp, optionGroups } from './CloudpackHelp.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object>\n extends Partial<Pick<CommandExecutorParams<TOptions>, 'discoverAppPaths' | 'applyOptionsToConfig'>> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /**\n * Options specific to this command. The record ensures that all options are available in the CLI.\n * Allow multiple options for the same key since commander supports it with negatable options.\n */\n options?: Record<keyof TOptions, Option | Option[]>; //\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _executorOptions: Pick<\n CommandExecutorParams<TOptions>,\n 'programOptions' | 'discoverAppPaths' | 'applyOptionsToConfig'\n >;\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 Pick<CommandExecutorParams<TOptions>, 'programOptions'> & {\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._executorOptions = {\n programOptions: params.programOptions,\n discoverAppPaths: params.discoverAppPaths,\n applyOptionsToConfig: params.applyOptionsToConfig,\n };\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n\n const isTopLevel = !params.parent;\n command.createHelp = () => new CloudpackHelp({ isTopLevel });\n // set the default help group for options\n command.optionsGroup(optionGroups.default);\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details in logging.').helpGroup(optionGroups.logging),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).')\n .conflicts('verbose')\n .helpGroup(optionGroups.logging),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.')\n .conflicts('verbose')\n .conflicts('debug')\n .helpGroup(optionGroups.logging),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.')\n .helpGroup(optionGroups.logging)\n .default(!environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI),\n logFile: new Option('--log-file', 'Write a log file with all console output.').helpGroup(optionGroups.logging),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ).helpGroup(optionGroups.common),\n config: new Option(\n '-c, --config <filename>',\n 'Custom config file name to use instead of cloudpack.config.json.',\n ).helpGroup(optionGroups.common),\n define: new Option('--define <key=value>', 'Define a global variable. Can be specified multiple times.')\n .helpGroup(optionGroups.common)\n .argParser(parseDefine),\n features: new Option('--features <featureNames...>', 'Enable experimental features.')\n .helpGroup(optionGroups.common)\n .argParser(parseFeature),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._executorOptions.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._executorOptions.programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>): void {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option | Option[]>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, optionOrOptions] of Object.entries(options) as [keyof TAddOptions, Option | Option[]][]) {\n const optionArray = Array.isArray(optionOrOptions) ? optionOrOptions : [optionOrOptions];\n for (const option of optionArray) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>): void {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n verb,\n ...this._executorOptions,\n });\n await commandExecutor.execute();\n });\n }\n}\n"]}
@@ -1,10 +1,10 @@
1
+ import type { ReadConfigOptions } from '@ms-cloudpack/config';
1
2
  import type { CommandAction, CommandExitParams } from '../types/CommandAction.js';
2
3
  import type { ProgramOptions } from '../types/ProgramOptions.js';
3
4
  import type { SharedOptions } from '../types/SharedOptions.js';
4
5
  import type { ReusedOptions } from '../types/ReusedOptions.js';
5
6
  import type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';
6
- export type BaseCommandExecutorOptions = SharedOptions & Pick<ReusedOptions, 'app'>;
7
- export interface CommandExecutorParams<TOptions extends BaseCommandExecutorOptions = BaseCommandExecutorOptions> {
7
+ export interface CommandExecutorParams<TOptions extends SharedOptions> {
8
8
  /** Command-specific arguments */
9
9
  args: string[];
10
10
  /** Command-specific and shared options. */
@@ -21,17 +21,23 @@ export interface CommandExecutorParams<TOptions extends BaseCommandExecutorOptio
21
21
  * (`cwd` will still be preferred if it has a `cloudpack.config.json`.)
22
22
  * See {@link AppPathDiscoveryMode} for details.
23
23
  */
24
- discoverAppPaths?: AppPathDiscoveryMode;
24
+ discoverAppPaths: AppPathDiscoveryMode | undefined;
25
+ /**
26
+ * Apply any command-specific CLI options that need to be passed through to `readConfig`.
27
+ * (Shared and reused options are applied automatically.)
28
+ */
29
+ applyOptionsToConfig: ((options: Omit<TOptions, keyof (SharedOptions & ReusedOptions)>) => Pick<ReadConfigOptions, 'extraServerConfig'> | undefined) | undefined;
25
30
  }
26
31
  /**
27
32
  * This class manages orchestration and shared state while executing a command.
28
33
  */
29
- export declare class CommandExecutor<TOptions extends BaseCommandExecutorOptions> {
34
+ export declare class CommandExecutor<TOptions extends SharedOptions> {
30
35
  private _options;
31
36
  private _execute;
32
37
  private _programOptions;
33
38
  private _verb;
34
39
  private _discoverAppPaths;
40
+ private _applyOptionsToConfig;
35
41
  private _reporter;
36
42
  private _autoDisposableList;
37
43
  private _hasCalledExit;
@@ -1 +1 @@
1
- {"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAqB,MAAM,2BAA2B,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAQ7E,MAAM,MAAM,0BAA0B,GAAG,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAEpF,MAAM,WAAW,qBAAqB,CAAC,QAAQ,SAAS,0BAA0B,GAAG,0BAA0B;IAC7G,iCAAiC;IACjC,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,2CAA2C;IAC3C,OAAO,EAAE,QAA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AAmB,CAAqB;IAChD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,YAAY,CAAC,CAAa;IAClC,OAAO,CAAC,sBAAsB,CAAC,CAAe;IAE9C,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAmC;WAE9C,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;gBASzD,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC;IAYnD,uBAAuB;IAEV,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA2ErC;;;OAGG;YACW,mBAAmB;IAuGjC,qEAAqE;IACrE,OAAO,CAAC,+BAA+B;YAgBzB,cAAc;IAkD5B,SAAS,CAAC,cAAc,QAAO,IAAI,CAgBjC;IAEF;;;OAGG;cACa,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;CAgCjE"}
@@ -21,6 +21,7 @@ export class CommandExecutor {
21
21
  _programOptions;
22
22
  _verb;
23
23
  _discoverAppPaths;
24
+ _applyOptionsToConfig;
24
25
  _reporter;
25
26
  _autoDisposableList;
26
27
  _hasCalledExit = false;
@@ -45,6 +46,7 @@ export class CommandExecutor {
45
46
  this._programOptions = params.programOptions;
46
47
  this._verb = params.verb;
47
48
  this._discoverAppPaths = params.discoverAppPaths;
49
+ this._applyOptionsToConfig = params.applyOptionsToConfig;
48
50
  this._reporter = new TaskReporter();
49
51
  this._autoDisposableList = new AutoDisposableList();
50
52
  }
@@ -127,12 +129,13 @@ export class CommandExecutor {
127
129
  let appPaths;
128
130
  if (this._discoverAppPaths) {
129
131
  // Search for cloudpack configs to determine the app path(s)
132
+ const { app, login } = this._options;
130
133
  const appPathsResult = this._discoverAppPaths === 'remote'
131
134
  ? await discoverRemoteAppPaths({
132
135
  options: {
133
- login: this._options.login,
136
+ login,
134
137
  cachePath: this._options.cachePath,
135
- desiredApp: this._options.app,
138
+ desiredApp: app,
136
139
  },
137
140
  context: {
138
141
  reporter: this._reporter,
@@ -141,7 +144,7 @@ export class CommandExecutor {
141
144
  : await discoverLocalAppPaths({
142
145
  cwd: this._programOptions.cwd,
143
146
  discover: this._discoverAppPaths,
144
- desiredApp: this._options.app,
147
+ desiredApp: app,
145
148
  });
146
149
  if (!Array.isArray(appPathsResult)) {
147
150
  // This means there was an error (or the user cancelled) while getting app paths.
@@ -153,14 +156,11 @@ export class CommandExecutor {
153
156
  // Just use the cwd
154
157
  appPaths = [this._programOptions.cwd];
155
158
  }
156
- const configOptions = this._getConfigOptionsFromCliOptions();
157
159
  // The task runner is shared between all apps so that task results can potentially be reused.
158
160
  const taskRunner = new TaskRunner();
159
161
  const readConfig = this._discoverAppPaths === 'remote' ? readRemoteConfigs : readLocalConfigs;
160
162
  const configs = await readConfig(appPaths, {
161
- ...configOptions,
162
- extraFeatures: this._options.features,
163
- extraDefineFlags: this._options.define,
163
+ ...this._getConfigOptionsFromCliOptions(),
164
164
  enableDefaultFeatures: true,
165
165
  });
166
166
  const helpMessages = new Set(Object.values(configs)
@@ -223,6 +223,9 @@ export class CommandExecutor {
223
223
  // Handle --bundler by passing it as a universal package override, which will be appended
224
224
  // to any user-provided packageSettings so that it takes precedence.
225
225
  extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,
226
+ extraFeatures: options.features,
227
+ extraDefineFlags: options.define,
228
+ ...(this._applyOptionsToConfig?.(this._options) || {}),
226
229
  };
227
230
  }
228
231
  async _initTelemetry(appName, config, telemetryApi) {
@@ -1 +1 @@
1
- {"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,GAAG,EACH,oBAAoB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K,CAAC;aACzB,CAAC,CAAC;QACL,CAAC;QAED,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3C,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC","sourcesContent":["import type { ReadConfigOptions } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { startTelemetry, type TelemetryApi, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { discoverRemoteAppPaths } from './discoverRemoteAppPaths.js';\nimport { discoverLocalAppPaths } from './discoverLocalAppPaths.js';\nimport { TaskRunner } from '@ms-cloudpack/api-server';\nimport { readLocalConfigs, type InvalidCloudpackConfigError } from './readLocalConfigs.js';\nimport { readRemoteConfigs } from './readRemoteConfigs.js';\nimport { getCliStartTime } from './getCliStartTime.js';\n\nexport type BaseCommandExecutorOptions = SharedOptions & Pick<ReusedOptions, 'app'>;\n\nexport interface CommandExecutorParams<TOptions extends BaseCommandExecutorOptions = BaseCommandExecutorOptions> {\n /** Command-specific arguments */\n args: string[];\n\n /** Command-specific and shared options. */\n options: TOptions;\n\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n\n /**\n * By default, the command will run against `cwd` (usually `process.cwd()`).\n * If this option is set, attempt to discover app path(s) instead.\n * (`cwd` will still be preferred if it has a `cloudpack.config.json`.)\n * See {@link AppPathDiscoveryMode} for details.\n */\n discoverAppPaths?: AppPathDiscoveryMode;\n}\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\n// 'app' is an optional reused option\nexport class CommandExecutor<TOptions extends BaseCommandExecutorOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _onInterrupt?: () => void;\n private _getMessageOnInterrupt?: () => string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances = new Set<CommandExecutor<any>>();\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = new Set();\n }\n\n constructor(params: CommandExecutorParams<TOptions>) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._discoverAppPaths = params.discoverAppPaths;\n this._reporter = new TaskReporter();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute(): Promise<void> {\n CommandExecutor._activeInstances.add(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n if (!environmentInfo.isJest) {\n process.on('SIGINT', this._sigintHandler);\n }\n\n const contexts = await this._initializeContexts();\n\n if (!Array.isArray(contexts)) {\n await this._exit(contexts);\n return;\n }\n\n const spanName = `${this._verb.toUpperCase().replace(/ /g, '_')}_EXECUTE`;\n const results: CommandExitParams[] = [];\n\n for (const context of contexts) {\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await context.telemetryClient.tracer.startActiveSpan(spanName, async (span) => {\n this._onInterrupt = () => {\n span.setAttribute('isInterrupted', true);\n span.end();\n };\n\n return this._execute({\n ...context,\n span,\n isMultiApp: contexts.length > 1,\n args: this._args,\n options: this._options,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n });\n if (result?.isInterrupted) {\n return await this._exit(result);\n }\n if (result) {\n results.push(result);\n } else if ((result as unknown) !== null) {\n // If the command returned null, this means it should keep running (e.g. start).\n // We disallow returning undefined to avoid accidents.\n throw new Error('Command executor must return exit options or null');\n }\n this._onInterrupt = undefined;\n }\n\n if (results.length) {\n // If one or more apps returned a result, exit.\n await this._exit({\n message: results.map((r) => r.message).join('\\n'),\n hasErrors: results.some((r) => r.hasErrors),\n // If any app returned a non-zero exit code, use that.\n exitCode: results.find(({ exitCode }) => !!exitCode)?.exitCode,\n });\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n const err = error as InvalidCloudpackConfigError;\n const message = err.isExpected\n ? err.message // Only show message for expected errors\n : err.stack || err.message || String(error); // Show full stack for unexpected errors\n\n await this._exit({\n hasErrors: true,\n message,\n });\n }\n }\n\n /**\n * Determine the app paths and initialize the context for each app.\n * @returns Context(s), or an exit options object if there was an error. (might also throw on error)\n */\n private async _initializeContexts(): Promise<AppCommandContext[] | CommandExitParams> {\n let appPaths: string[];\n\n if (this._discoverAppPaths) {\n // Search for cloudpack configs to determine the app path(s)\n const appPathsResult =\n this._discoverAppPaths === 'remote'\n ? await discoverRemoteAppPaths({\n options: {\n login: (this._options as unknown as Pick<ReusedOptions, 'login'>).login,\n cachePath: this._options.cachePath,\n desiredApp: this._options.app,\n },\n context: {\n reporter: this._reporter,\n },\n })\n : await discoverLocalAppPaths({\n cwd: this._programOptions.cwd,\n discover: this._discoverAppPaths,\n desiredApp: this._options.app,\n });\n if (!Array.isArray(appPathsResult)) {\n // This means there was an error (or the user cancelled) while getting app paths.\n return appPathsResult;\n }\n appPaths = appPathsResult;\n } else {\n // Just use the cwd\n appPaths = [this._programOptions.cwd];\n }\n\n const configOptions = this._getConfigOptionsFromCliOptions();\n\n // The task runner is shared between all apps so that task results can potentially be reused.\n const taskRunner = new TaskRunner();\n\n const readConfig = this._discoverAppPaths === 'remote' ? readRemoteConfigs : readLocalConfigs;\n const configs = await readConfig(appPaths, {\n ...configOptions,\n extraFeatures: this._options.features,\n extraDefineFlags: this._options.define,\n enableDefaultFeatures: true,\n });\n\n const helpMessages = new Set<string>(\n Object.values(configs)\n .filter((c) => c.helpMessage)\n .map((c) => c.helpMessage) as string[],\n );\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n logFile: !!this._options.logFile,\n cwd: this._programOptions.cwd,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n const contexts: AppCommandContext[] = [];\n\n const logLevel = this._options.verbose ? 'VERBOSE' : this._options.debug ? 'DEBUG' : undefined;\n if (!this._options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryApi = startTelemetry({\n productVersion: getVersion(import.meta.url),\n logLevel,\n serviceName: 'cli',\n });\n\n this._autoDisposableList.add({\n dispose: () => telemetryApi.shutdown(),\n });\n\n for (const appPath of Object.keys(configs)) {\n const config = configs[appPath];\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config, telemetryApi);\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n taskRunner,\n });\n }\n\n return contexts;\n }\n\n /** Translate certain CLI options into options for `readConfig()`. */\n private _getConfigOptionsFromCliOptions(): ReadConfigOptions {\n // These options don't exist for all commands, but that's fine.\n const options = this._options as Partial<ReusedOptions & SharedOptions>;\n return {\n mode: options.mode,\n logBundleInfo: options.logBundleInfo,\n configFileName: options.config,\n // Handle --bundler by passing it as a universal package override, which will be appended\n // to any user-provided packageSettings so that it takes precedence.\n extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,\n };\n }\n\n private async _initTelemetry(\n appName: string | undefined,\n config: CloudpackConfig,\n telemetryApi: TelemetryApi,\n ): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n\n const connectionString =\n this._programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\n\n const telemetryClient = await telemetryApi.createClient(connectionString);\n\n telemetryClient.tracer.startSpan('CLI_ENTRY', { startTime: getCliStartTime() }).end();\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode,\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = (): void => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n this._onInterrupt?.();\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams): Promise<never> {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt?.() || 'Interrupted by user' : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n await this._reporter.complete({\n summary: hasErrors ? red(message) : message,\n showHelp: exitCode !== 0,\n });\n }\n\n CommandExecutor._activeInstances.delete(this);\n process.off('SIGINT', this._sigintHandler);\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
1
+ {"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,O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C,8DAA8D;YAC9D,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;gBAC5B,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;gBAC3C,QAAQ,EAAE,QAAQ,KAAK,CAAC;aACzB,CAAC,CAAC;QACL,CAAC;QAED,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3C,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC","sourcesContent":["import type { ReadConfigOptions } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { startTelemetry, type TelemetryApi, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { discoverRemoteAppPaths } from './discoverRemoteAppPaths.js';\nimport { discoverLocalAppPaths } from './discoverLocalAppPaths.js';\nimport { TaskRunner } from '@ms-cloudpack/api-server';\nimport { readLocalConfigs, type InvalidCloudpackConfigError } from './readLocalConfigs.js';\nimport { readRemoteConfigs } from './readRemoteConfigs.js';\nimport { getCliStartTime } from './getCliStartTime.js';\n\nexport interface CommandExecutorParams<TOptions extends SharedOptions> {\n /** Command-specific arguments */\n args: string[];\n\n /** Command-specific and shared options. */\n options: TOptions;\n\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n\n /**\n * By default, the command will run against `cwd` (usually `process.cwd()`).\n * If this option is set, attempt to discover app path(s) instead.\n * (`cwd` will still be preferred if it has a `cloudpack.config.json`.)\n * See {@link AppPathDiscoveryMode} for details.\n */\n discoverAppPaths: AppPathDiscoveryMode | undefined;\n\n /**\n * Apply any command-specific CLI options that need to be passed through to `readConfig`.\n * (Shared and reused options are applied automatically.)\n */\n applyOptionsToConfig:\n | ((\n options: Omit<TOptions, keyof (SharedOptions & ReusedOptions)>,\n ) => Pick<ReadConfigOptions, 'extraServerConfig'> | undefined)\n | undefined;\n}\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\n// 'app' is an optional reused option\nexport class CommandExecutor<TOptions extends SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n private _applyOptionsToConfig: CommandExecutorParams<TOptions>['applyOptionsToConfig'];\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _onInterrupt?: () => void;\n private _getMessageOnInterrupt?: () => string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances = new Set<CommandExecutor<any>>();\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = new Set();\n }\n\n constructor(params: CommandExecutorParams<TOptions>) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._discoverAppPaths = params.discoverAppPaths;\n this._applyOptionsToConfig = params.applyOptionsToConfig;\n this._reporter = new TaskReporter();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute(): Promise<void> {\n CommandExecutor._activeInstances.add(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n if (!environmentInfo.isJest) {\n process.on('SIGINT', this._sigintHandler);\n }\n\n const contexts = await this._initializeContexts();\n\n if (!Array.isArray(contexts)) {\n await this._exit(contexts);\n return;\n }\n\n const spanName = `${this._verb.toUpperCase().replace(/ /g, '_')}_EXECUTE`;\n const results: CommandExitParams[] = [];\n\n for (const context of contexts) {\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await context.telemetryClient.tracer.startActiveSpan(spanName, async (span) => {\n this._onInterrupt = () => {\n span.setAttribute('isInterrupted', true);\n span.end();\n };\n\n return this._execute({\n ...context,\n span,\n isMultiApp: contexts.length > 1,\n args: this._args,\n options: this._options,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n });\n if (result?.isInterrupted) {\n return await this._exit(result);\n }\n if (result) {\n results.push(result);\n } else if ((result as unknown) !== null) {\n // If the command returned null, this means it should keep running (e.g. start).\n // We disallow returning undefined to avoid accidents.\n throw new Error('Command executor must return exit options or null');\n }\n this._onInterrupt = undefined;\n }\n\n if (results.length) {\n // If one or more apps returned a result, exit.\n await this._exit({\n message: results.map((r) => r.message).join('\\n'),\n hasErrors: results.some((r) => r.hasErrors),\n // If any app returned a non-zero exit code, use that.\n exitCode: results.find(({ exitCode }) => !!exitCode)?.exitCode,\n });\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n const err = error as InvalidCloudpackConfigError;\n const message = err.isExpected\n ? err.message // Only show message for expected errors\n : err.stack || err.message || String(error); // Show full stack for unexpected errors\n\n await this._exit({\n hasErrors: true,\n message,\n });\n }\n }\n\n /**\n * Determine the app paths and initialize the context for each app.\n * @returns Context(s), or an exit options object if there was an error. (might also throw on error)\n */\n private async _initializeContexts(): Promise<AppCommandContext[] | CommandExitParams> {\n let appPaths: string[];\n\n if (this._discoverAppPaths) {\n // Search for cloudpack configs to determine the app path(s)\n const { app, login } = this._options as unknown as Pick<ReusedOptions, 'app' | 'login'>;\n const appPathsResult =\n this._discoverAppPaths === 'remote'\n ? await discoverRemoteAppPaths({\n options: {\n login,\n cachePath: this._options.cachePath,\n desiredApp: app,\n },\n context: {\n reporter: this._reporter,\n },\n })\n : await discoverLocalAppPaths({\n cwd: this._programOptions.cwd,\n discover: this._discoverAppPaths,\n desiredApp: app,\n });\n if (!Array.isArray(appPathsResult)) {\n // This means there was an error (or the user cancelled) while getting app paths.\n return appPathsResult;\n }\n appPaths = appPathsResult;\n } else {\n // Just use the cwd\n appPaths = [this._programOptions.cwd];\n }\n\n // The task runner is shared between all apps so that task results can potentially be reused.\n const taskRunner = new TaskRunner();\n\n const readConfig = this._discoverAppPaths === 'remote' ? readRemoteConfigs : readLocalConfigs;\n const configs = await readConfig(appPaths, {\n ...this._getConfigOptionsFromCliOptions(),\n enableDefaultFeatures: true,\n });\n\n const helpMessages = new Set<string>(\n Object.values(configs)\n .filter((c) => c.helpMessage)\n .map((c) => c.helpMessage) as string[],\n );\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n logFile: !!this._options.logFile,\n cwd: this._programOptions.cwd,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n const contexts: AppCommandContext[] = [];\n\n const logLevel = this._options.verbose ? 'VERBOSE' : this._options.debug ? 'DEBUG' : undefined;\n if (!this._options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryApi = startTelemetry({\n productVersion: getVersion(import.meta.url),\n logLevel,\n serviceName: 'cli',\n });\n\n this._autoDisposableList.add({\n dispose: () => telemetryApi.shutdown(),\n });\n\n for (const appPath of Object.keys(configs)) {\n const config = configs[appPath];\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config, telemetryApi);\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n taskRunner,\n });\n }\n\n return contexts;\n }\n\n /** Translate certain CLI options into options for `readConfig()`. */\n private _getConfigOptionsFromCliOptions(): ReadConfigOptions {\n // These options don't exist for all commands, but that's fine.\n const options = this._options as Partial<ReusedOptions & SharedOptions>;\n return {\n mode: options.mode,\n logBundleInfo: options.logBundleInfo,\n configFileName: options.config,\n // Handle --bundler by passing it as a universal package override, which will be appended\n // to any user-provided packageSettings so that it takes precedence.\n extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,\n extraFeatures: options.features,\n extraDefineFlags: options.define,\n ...(this._applyOptionsToConfig?.(this._options) || {}),\n };\n }\n\n private async _initTelemetry(\n appName: string | undefined,\n config: CloudpackConfig,\n telemetryApi: TelemetryApi,\n ): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n\n const connectionString =\n this._programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\n\n const telemetryClient = await telemetryApi.createClient(connectionString);\n\n telemetryClient.tracer.startSpan('CLI_ENTRY', { startTime: getCliStartTime() }).end();\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode,\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = (): void => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n this._onInterrupt?.();\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams): Promise<never> {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt?.() || 'Interrupted by user' : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n await this._reporter.complete({\n summary: hasErrors ? red(message) : message,\n showHelp: exitCode !== 0,\n });\n }\n\n CommandExecutor._activeInstances.delete(this);\n process.off('SIGINT', this._sigintHandler);\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.77.1",
3
+ "version": "0.77.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",
@@ -18,24 +18,24 @@
18
18
  "cloudpack": "./bin/cloudpack.js"
19
19
  },
20
20
  "dependencies": {
21
- "@ms-cloudpack/api-server": "^0.64.16",
22
- "@ms-cloudpack/app-server": "^0.20.8",
23
- "@ms-cloudpack/bundler": "^0.25.29",
24
- "@ms-cloudpack/bundler-capabilities": "^0.2.38",
25
- "@ms-cloudpack/common-types": "^0.27.3",
26
- "@ms-cloudpack/config": "^0.38.0",
27
- "@ms-cloudpack/create-express-app": "^1.10.47",
21
+ "@ms-cloudpack/api-server": "^0.64.17",
22
+ "@ms-cloudpack/app-server": "^0.20.9",
23
+ "@ms-cloudpack/bundler": "^0.25.30",
24
+ "@ms-cloudpack/bundler-capabilities": "^0.2.39",
25
+ "@ms-cloudpack/common-types": "^0.27.4",
26
+ "@ms-cloudpack/config": "^0.38.1",
27
+ "@ms-cloudpack/create-express-app": "^1.10.48",
28
28
  "@ms-cloudpack/environment": "^0.1.1",
29
29
  "@ms-cloudpack/json-utilities": "^0.1.10",
30
- "@ms-cloudpack/link-proxy": "^0.2.30",
31
- "@ms-cloudpack/overlay": "^0.19.26",
32
- "@ms-cloudpack/package-utilities": "^12.3.24",
30
+ "@ms-cloudpack/link-proxy": "^0.2.31",
31
+ "@ms-cloudpack/overlay": "^0.19.27",
32
+ "@ms-cloudpack/package-utilities": "^12.3.25",
33
33
  "@ms-cloudpack/path-string-parsing": "^1.2.7",
34
- "@ms-cloudpack/path-utilities": "^3.1.18",
35
- "@ms-cloudpack/remote-cache": "^0.11.35",
36
- "@ms-cloudpack/setup-utilities": "^0.5.39",
34
+ "@ms-cloudpack/path-utilities": "^3.1.19",
35
+ "@ms-cloudpack/remote-cache": "^0.11.36",
36
+ "@ms-cloudpack/setup-utilities": "^0.5.40",
37
37
  "@ms-cloudpack/task-reporter": "^0.17.2",
38
- "@ms-cloudpack/telemetry": "^0.11.36",
38
+ "@ms-cloudpack/telemetry": "^0.11.37",
39
39
  "@yarnpkg/lockfile": "^1.1.0",
40
40
  "commander": "^14.0.0",
41
41
  "cross-spawn": "^7.0.3",
@@ -48,8 +48,8 @@
48
48
  "workspace-tools": "^0.38.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@ms-cloudpack/common-types": "^0.27.3",
52
- "@ms-cloudpack/common-types-browser": "^0.6.2",
51
+ "@ms-cloudpack/common-types": "^0.27.4",
52
+ "@ms-cloudpack/common-types-browser": "^0.6.3",
53
53
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
54
54
  "@ms-cloudpack/scripts": "^0.0.1",
55
55
  "@ms-cloudpack/test-utilities": "^0.5.0",
@@ -124,7 +124,8 @@
124
124
  }
125
125
  }
126
126
  ],
127
- "description": "The domain name of the server. If multiple domains are specified, the first one will be used as the primary domain used when opening the browser."
127
+ "description": "The domain name of the server. If multiple domains are specified, the first one will be used as the primary domain used when opening the browser.",
128
+ "default": "localhost"
128
129
  },
129
130
  "requestHeaders": {
130
131
  "type": "object",
@@ -149,7 +150,8 @@
149
150
  },
150
151
  "defaultPath": {
151
152
  "type": "string",
152
- "description": "The default path to use when opening the browser."
153
+ "description": "The default path under the domain to use when opening the browser.",
154
+ "default": ""
153
155
  },
154
156
  "https": {
155
157
  "anyOf": [
@@ -163,6 +165,16 @@
163
165
  ],
164
166
  "description": "The config settings for the https server. Paths to files are accepted for 'ca', 'cert', 'key', and 'pfx' settings. Everything else is passed directly to the https.createServer() method. If not provided, the server will use http."
165
167
  },
168
+ "showOverlay": {
169
+ "type": "string",
170
+ "enum": [
171
+ "always",
172
+ "errors-only",
173
+ "never"
174
+ ],
175
+ "description": "Whether to show the Cloudpack overlay (status badge and dialog) in the app UI.\n\nIt's not recommended to change this unless the overlay is interfering with UI elements or tests (and if it's only needed in a specific case, use the `--show-overlay <when>` CLI option).",
176
+ "default": "always"
177
+ },
166
178
  "routes": {
167
179
  "type": "array",
168
180
  "items": {
@@ -125,7 +125,8 @@
125
125
  }
126
126
  }
127
127
  ],
128
- "description": "The domain name of the server. If multiple domains are specified, the first one will be used as the primary domain used when opening the browser."
128
+ "description": "The domain name of the server. If multiple domains are specified, the first one will be used as the primary domain used when opening the browser.",
129
+ "default": "localhost"
129
130
  },
130
131
  "requestHeaders": {
131
132
  "type": "object",
@@ -150,7 +151,8 @@
150
151
  },
151
152
  "defaultPath": {
152
153
  "type": "string",
153
- "description": "The default path to use when opening the browser."
154
+ "description": "The default path under the domain to use when opening the browser.",
155
+ "default": ""
154
156
  },
155
157
  "https": {
156
158
  "anyOf": [
@@ -164,6 +166,16 @@
164
166
  ],
165
167
  "description": "The config settings for the https server. Paths to files are accepted for 'ca', 'cert', 'key', and 'pfx' settings. Everything else is passed directly to the https.createServer() method. If not provided, the server will use http."
166
168
  },
169
+ "showOverlay": {
170
+ "type": "string",
171
+ "enum": [
172
+ "always",
173
+ "errors-only",
174
+ "never"
175
+ ],
176
+ "description": "Whether to show the Cloudpack overlay (status badge and dialog) in the app UI.\n\nIt's not recommended to change this unless the overlay is interfering with UI elements or tests (and if it's only needed in a specific case, use the `--show-overlay <when>` CLI option).",
177
+ "default": "always"
178
+ },
167
179
  "routes": {
168
180
  "type": "array",
169
181
  "items": {