@ms-cloudpack/cli 0.72.49 → 0.72.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/bundle/execute.d.ts.map +1 -1
- package/lib/commands/bundle/execute.js +3 -7
- package/lib/commands/bundle/execute.js.map +1 -1
- package/lib/commands/bundle/index.d.ts.map +1 -1
- package/lib/commands/bundle/index.js +1 -2
- package/lib/commands/bundle/index.js.map +1 -1
- package/lib/commands/bundle/types/BundleOptions.d.ts +1 -8
- package/lib/commands/bundle/types/BundleOptions.d.ts.map +1 -1
- package/lib/commands/bundle/types/BundleOptions.js.map +1 -1
- package/lib/commands/cache/clean.d.ts.map +1 -1
- package/lib/commands/cache/clean.js +1 -2
- package/lib/commands/cache/clean.js.map +1 -1
- package/lib/commands/config/delete.d.ts.map +1 -1
- package/lib/commands/config/delete.js +1 -2
- package/lib/commands/config/delete.js.map +1 -1
- package/lib/commands/config/get.d.ts.map +1 -1
- package/lib/commands/config/get.js +1 -2
- package/lib/commands/config/get.js.map +1 -1
- package/lib/commands/config/list.d.ts.map +1 -1
- package/lib/commands/config/list.js +1 -3
- package/lib/commands/config/list.js.map +1 -1
- package/lib/commands/config/set.d.ts.map +1 -1
- package/lib/commands/config/set.js +1 -2
- package/lib/commands/config/set.js.map +1 -1
- package/lib/commands/info/lockFile/execute.d.ts.map +1 -1
- package/lib/commands/info/lockFile/execute.js +1 -2
- package/lib/commands/info/lockFile/execute.js.map +1 -1
- package/lib/commands/info/nonSemverDeps/execute.js +2 -2
- package/lib/commands/info/nonSemverDeps/execute.js.map +1 -1
- package/lib/commands/init/execute.d.ts.map +1 -1
- package/lib/commands/init/execute.js +1 -10
- package/lib/commands/init/execute.js.map +1 -1
- package/lib/commands/init/index.d.ts.map +1 -1
- package/lib/commands/init/index.js +3 -0
- package/lib/commands/init/index.js.map +1 -1
- package/lib/commands/init/init.d.ts.map +1 -1
- package/lib/commands/init/init.js +149 -148
- package/lib/commands/init/init.js.map +1 -1
- package/lib/commands/init/types/InitOptions.d.ts +1 -1
- package/lib/commands/init/types/InitOptions.d.ts.map +1 -1
- package/lib/commands/init/types/InitOptions.js.map +1 -1
- package/lib/commands/link/execute.d.ts.map +1 -1
- package/lib/commands/link/execute.js +2 -2
- package/lib/commands/link/execute.js.map +1 -1
- package/lib/commands/setup/execute.d.ts.map +1 -1
- package/lib/commands/setup/execute.js +1 -2
- package/lib/commands/setup/execute.js.map +1 -1
- package/lib/commands/start/execute.d.ts.map +1 -1
- package/lib/commands/start/execute.js +3 -10
- package/lib/commands/start/execute.js.map +1 -1
- package/lib/commands/start/index.js +5 -2
- package/lib/commands/start/index.js.map +1 -1
- package/lib/commands/start/types/StartOptions.d.ts +1 -3
- package/lib/commands/start/types/StartOptions.d.ts.map +1 -1
- package/lib/commands/start/types/StartOptions.js.map +1 -1
- package/lib/commands/sync/execute.d.ts.map +1 -1
- package/lib/commands/sync/execute.js +2 -2
- package/lib/commands/sync/execute.js.map +1 -1
- package/lib/commands/unlink/execute.js +2 -2
- package/lib/commands/unlink/execute.js.map +1 -1
- package/lib/types/AppPathDiscoveryMode.d.ts +14 -0
- package/lib/types/AppPathDiscoveryMode.d.ts.map +1 -0
- package/lib/types/AppPathDiscoveryMode.js +2 -0
- package/lib/types/AppPathDiscoveryMode.js.map +1 -0
- package/lib/types/CommandAction.d.ts +5 -25
- package/lib/types/CommandAction.d.ts.map +1 -1
- package/lib/types/CommandAction.js.map +1 -1
- package/lib/types/ReusedOptions.d.ts +9 -0
- package/lib/types/ReusedOptions.d.ts.map +1 -1
- package/lib/types/ReusedOptions.js.map +1 -1
- package/lib/types/SharedOptions.d.ts +2 -2
- package/lib/types/SharedOptions.d.ts.map +1 -1
- package/lib/types/SharedOptions.js.map +1 -1
- package/lib/utilities/CloudpackCommand.d.ts +3 -1
- package/lib/utilities/CloudpackCommand.d.ts.map +1 -1
- package/lib/utilities/CloudpackCommand.js +4 -1
- package/lib/utilities/CloudpackCommand.js.map +1 -1
- package/lib/utilities/CommandExecutor.d.ts +19 -7
- package/lib/utilities/CommandExecutor.d.ts.map +1 -1
- package/lib/utilities/CommandExecutor.js +48 -26
- package/lib/utilities/CommandExecutor.js.map +1 -1
- package/lib/utilities/discoverAppPaths.d.ts +28 -0
- package/lib/utilities/discoverAppPaths.d.ts.map +1 -0
- package/lib/utilities/discoverAppPaths.js +80 -0
- package/lib/utilities/discoverAppPaths.js.map +1 -0
- package/lib/utilities/parseFeature.d.ts +6 -0
- package/lib/utilities/parseFeature.d.ts.map +1 -0
- package/lib/utilities/parseFeature.js +42 -0
- package/lib/utilities/parseFeature.js.map +1 -0
- package/lib/utilities/reusedOptions.d.ts +8 -0
- package/lib/utilities/reusedOptions.d.ts.map +1 -1
- package/lib/utilities/reusedOptions.js +8 -0
- package/lib/utilities/reusedOptions.js.map +1 -1
- package/package.json +6 -6
- package/lib/commands/start/getStartingAppPath.d.ts +0 -12
- package/lib/commands/start/getStartingAppPath.d.ts.map +0 -1
- package/lib/commands/start/getStartingAppPath.js +0 -60
- package/lib/commands/start/getStartingAppPath.js.map +0 -1
- package/lib/utilities/checkFeatures.d.ts +0 -12
- package/lib/utilities/checkFeatures.d.ts.map +0 -1
- package/lib/utilities/checkFeatures.js +0 -24
- package/lib/utilities/checkFeatures.js.map +0 -1
- package/lib/utilities/findCloudpackAppPaths.d.ts +0 -7
- package/lib/utilities/findCloudpackAppPaths.d.ts.map +0 -1
- package/lib/utilities/findCloudpackAppPaths.js +0 -12
- package/lib/utilities/findCloudpackAppPaths.js.map +0 -1
- package/lib/utilities/getConfigOptionsFromCliOptions.d.ts +0 -8
- package/lib/utilities/getConfigOptionsFromCliOptions.d.ts.map +0 -1
- package/lib/utilities/getConfigOptionsFromCliOptions.js +0 -14
- package/lib/utilities/getConfigOptionsFromCliOptions.js.map +0 -1
- package/lib/utilities/mergeFeatures.d.ts +0 -8
- package/lib/utilities/mergeFeatures.d.ts.map +0 -1
- package/lib/utilities/mergeFeatures.js +0 -16
- package/lib/utilities/mergeFeatures.js.map +0 -1
|
@@ -5,10 +5,10 @@ import { reusedOptions } from '../../utilities/reusedOptions.js';
|
|
|
5
5
|
export const init = (program) => {
|
|
6
6
|
program.addSubCommand({
|
|
7
7
|
name: 'start',
|
|
8
|
-
description: 'Starts a web inner-loop
|
|
8
|
+
description: 'Starts a web inner-loop for an app.',
|
|
9
9
|
options: {
|
|
10
10
|
mode: reusedOptions.mode({ action: 'run' }),
|
|
11
|
-
app:
|
|
11
|
+
app: reusedOptions.app(),
|
|
12
12
|
open: new Option('--no-open', 'Do not open the browser.'),
|
|
13
13
|
cache: reusedOptions.cache(),
|
|
14
14
|
logResolveMap: reusedOptions.logResolveMap(),
|
|
@@ -19,6 +19,9 @@ export const init = (program) => {
|
|
|
19
19
|
login: reusedOptions.login(),
|
|
20
20
|
},
|
|
21
21
|
getExecutor: () => import('./execute.js'),
|
|
22
|
+
// If cwd isn't a cloudpack app, discover other cloudpack apps and possibly prompt the user
|
|
23
|
+
// to choose one. Also handles --app.
|
|
24
|
+
discoverAppPaths: 'single',
|
|
22
25
|
});
|
|
23
26
|
};
|
|
24
27
|
function getPortOption(flags, name) {
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB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AU,CAAC,KAAa;IAC/B,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,oBAAoB,CAAC,wBAAwB,KAAK,GAAG,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,CAAC,GAAG,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,IAAI,KAAK,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/** 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 mode: reusedOptions.mode({ action: 'run' }),\n app: reusedOptions.app(),\n open: new Option('--no-open', 'Do not open the browser.'),\n cache: reusedOptions.cache(),\n logResolveMap: reusedOptions.logResolveMap(),\n logBundleInfo: reusedOptions.logBundleInfo({ requiresNoCache: true }),\n apiServerPort: getPortOption('--api-server-port <port>', 'API'),\n appServerPort: getPortOption('--app-server-port <port>', 'app'),\n bundleServerPort: getPortOption('--bundle-server-port <port>', 'bundle'),\n login: reusedOptions.login(),\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): Option {\n return new Option(flags, `Port to use for the ${name} server (single, comma-separated, or range with dash).`)\n .argParser(parsePorts)\n .hideHelp();\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,7 +1,5 @@
|
|
|
1
1
|
import type { ReusedOptions } from '../../../types/ReusedOptions.js';
|
|
2
|
-
export interface StartOptions extends Pick<ReusedOptions, 'cache' | 'login' | 'logBundleInfo' | 'logResolveMap' | 'mode'> {
|
|
3
|
-
/** Specifies which specific app to run, in the case of running `init` at a higher level in the repo. */
|
|
4
|
-
app?: string;
|
|
2
|
+
export interface StartOptions extends Pick<ReusedOptions, 'app' | 'cache' | 'login' | 'logBundleInfo' | 'logResolveMap' | 'mode'> {
|
|
5
3
|
/** Whether to open the browser (default true) */
|
|
6
4
|
open?: boolean;
|
|
7
5
|
/** 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,
|
|
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,iDAAiD;IACjD,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,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, 'cache' | 'login' | 'logBundleInfo' | 'logResolveMap' | 'mode'> {\n /**
|
|
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 (default true) */\n open?: boolean;\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAM1D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAM1D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CA+F9C,CAAC"}
|
|
@@ -7,9 +7,9 @@ function checkErrorCode(error, code) {
|
|
|
7
7
|
return error instanceof Error && 'code' in error && error.code === code;
|
|
8
8
|
}
|
|
9
9
|
export const execute = async (params) => {
|
|
10
|
-
const { options,
|
|
10
|
+
const { options, contexts, autoDispose } = params;
|
|
11
11
|
const { login, upload } = options;
|
|
12
|
-
const apiContextOptions =
|
|
12
|
+
const apiContextOptions = contexts[0];
|
|
13
13
|
const { config, telemetryClient } = apiContextOptions;
|
|
14
14
|
try {
|
|
15
15
|
// Await here to ensure that try-catch block catches any errors thrown inside the async function
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAmB,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE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AC;AACH,CAAC,CAAC","sourcesContent":["import { createPartialApiContext, syncDownload, syncUpload, type SyncResult } from '@ms-cloudpack/api-server';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { red } from '@ms-cloudpack/task-reporter';\nimport {\n ExitCodeAuthenticationError,\n ExitCodeGenericError,\n type CommandAction,\n type CommandExitParams,\n} from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\n\nfunction checkErrorCode(error: unknown, code: string): boolean {\n return error instanceof Error && 'code' in error && error.code === code;\n}\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, contexts, autoDispose } = params;\n const { login, upload } = options;\n const apiContextOptions = contexts[0];\n const { config, telemetryClient } = apiContextOptions;\n\n try {\n // Await here to ensure that try-catch block catches any errors thrown inside the async function\n return await telemetryClient.tracer.startActiveSpan('SYNC_EXECUTE', async (span): Promise<CommandExitParams> => {\n if (!config.features?.syncBundles) {\n return { message: 'Sync is disabled' };\n }\n\n if (!environmentInfo.cloudpack.isSyncEnabled) {\n span.setAttribute('syncDisabled', true);\n return { message: 'Sync is disabled by the user (CLOUDPACK_SYNC environment variable is set).' };\n }\n\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n return {\n message:\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n };\n }\n\n let syncResult: SyncResult;\n if (upload) {\n await runPrerequisites(apiContextOptions);\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: [\n 'bus',\n 'taskRunner',\n 'watcher',\n 'packages',\n 'session',\n 'packageImportPaths',\n 'packageHashes',\n 'remoteCacheClient',\n ],\n remoteCacheClientLoginMethod: login,\n }),\n );\n syncResult = await syncUpload({ input: undefined, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes', 'remoteCacheClient'],\n remoteCacheClientLoginMethod: login,\n }),\n );\n syncResult = await syncDownload({ input: undefined, ctx });\n }\n\n return {\n message:\n `Sync completed with ${syncResult.success} successes, ${syncResult.failed} failures, ` +\n `and ${syncResult['already-exist'] + syncResult['not-found']} items that did not require syncing.`,\n };\n });\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AuthenticationRequiredError' && error.message.includes('CrossPlatformLockError')) {\n return {\n message: red(\n `Cloudpack encountered an issue acquiring the authentication lock. It seems \"cloudpack sync\" may already ` +\n `be running in another process. Please wait for the other process to complete and then try again.`,\n ),\n exitCode: ExitCodeGenericError,\n };\n }\n if (\n error.name === 'AuthenticationRequiredError' ||\n ('statusCode' in error && (error.statusCode === '401' || error.statusCode === '403'))\n ) {\n return {\n message: red('Authentication error. Please check your credentials and try again.'),\n exitCode: ExitCodeAuthenticationError,\n };\n }\n\n if (checkErrorCode(error, 'REQUEST_SEND_ERROR')) {\n return {\n message: red('Connection error. Please check your connection and try again.'),\n exitCode: ExitCodeGenericError,\n };\n }\n }\n\n throw error;\n }\n};\n"]}
|
|
@@ -8,9 +8,9 @@ import path from 'path';
|
|
|
8
8
|
*/
|
|
9
9
|
export const execute = async (params) => {
|
|
10
10
|
// Use the current directory as the default package path.
|
|
11
|
-
const { options,
|
|
11
|
+
const { options, contexts, reporter } = params;
|
|
12
12
|
const { logResolveMap, cachePath } = options;
|
|
13
|
-
|
|
13
|
+
const { appPath } = contexts[0];
|
|
14
14
|
console.debug('Unlinking packages...');
|
|
15
15
|
const sessionResult = await getSessionToLink({ reporter, cachePath });
|
|
16
16
|
if (!sessionResult.session) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/unlink/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM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nlinkOptions.js';\nimport { getSessionToLink } from '../link/getSessionToLink.js';\nimport { createCloudpackClient } from '@ms-cloudpack/api-server';\nimport { formatLinkSummary } from '../link/formatLinkSummary.js';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\n\n/**\n * Defines the \"unlink\" verb entry point.\n */\nexport const execute: CommandAction<UnlinkOptions> = async (params) => {\n // Use the current directory as the default package path.\n const { options, contexts, reporter } = params;\n const { logResolveMap, cachePath } = options;\n const { appPath } = contexts[0];\n\n console.debug('Unlinking packages...');\n\n const sessionResult = await getSessionToLink({ reporter, cachePath });\n if (!sessionResult.session) {\n return sessionResult;\n }\n const { session } = sessionResult;\n const client = await createCloudpackClient({ url: session.urls.apiServer, reporter });\n\n const message = `Unlinking paths for ${session.projectName} at \"${appPath}\"`;\n const task = reporter.addTask(message);\n\n // Send request to api server to link paths.\n const { resolveMap, linkedPaths } = await client.unlinkPath.query({\n linkedPath: {\n path: appPath,\n },\n });\n await client.close();\n\n if (linkedPaths.some((p) => p.path === appPath)) {\n // Close down with an error.\n task.complete({ status: 'fail', message: `Failed to unlink paths.`, forceShow: true });\n return { hasErrors: true, message: 'Failed to unlink paths.' };\n }\n\n if (logResolveMap) {\n // Write the unlinked resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map-unlinked.json'), resolveMap);\n }\n\n // Close down successfully.\n task.complete({ status: 'complete', message: `Unlinked paths`, forceShow: true });\n const linkSummary = formatLinkSummary({ session, resolveMap, linkedPaths });\n\n return { message: linkSummary };\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How to discover the app path(s).
|
|
3
|
+
*
|
|
4
|
+
* - If `cwd` contains a `cloudpack.config.json` (and `--app` is not set), that will be
|
|
5
|
+
* the only app path.
|
|
6
|
+
* - Otherwise, glob for `cloudpack.config.json` under `cwd` (filtering by `--app` if set), then:
|
|
7
|
+
* - If `discover: 'multi'`, return all apps found.
|
|
8
|
+
* - If `discover: 'single'`:
|
|
9
|
+
* - If a single app is found, return that.
|
|
10
|
+
* - If multiple apps are found, prompt the user to choose one.
|
|
11
|
+
* - If nothing is found, use `cwd` (unless `--app` is set and the name doesn't match).
|
|
12
|
+
*/
|
|
13
|
+
export type AppPathDiscoveryMode = 'single' | 'multi';
|
|
14
|
+
//# sourceMappingURL=AppPathDiscoveryMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppPathDiscoveryMode.d.ts","sourceRoot":"","sources":["../../src/types/AppPathDiscoveryMode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppPathDiscoveryMode.js","sourceRoot":"","sources":["../../src/types/AppPathDiscoveryMode.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * How to discover the app path(s).\n *\n * - If `cwd` contains a `cloudpack.config.json` (and `--app` is not set), that will be\n * the only app path.\n * - Otherwise, glob for `cloudpack.config.json` under `cwd` (filtering by `--app` if set), then:\n * - If `discover: 'multi'`, return all apps found.\n * - If `discover: 'single'`:\n * - If a single app is found, return that.\n * - If multiple apps are found, prompt the user to choose one.\n * - If nothing is found, use `cwd` (unless `--app` is set and the name doesn't match).\n */\nexport type AppPathDiscoveryMode = 'single' | 'multi';\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LazyApiContextOptions } from '@ms-cloudpack/api-server';
|
|
2
|
-
import type { ReadConfigOptions } from '@ms-cloudpack/config';
|
|
3
2
|
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
4
3
|
import type { AutoDispose } from './AutoDispose.js';
|
|
5
4
|
import type { SharedOptions } from './SharedOptions.js';
|
|
@@ -8,11 +7,6 @@ import type { SharedOptions } from './SharedOptions.js';
|
|
|
8
7
|
* For convenience, this can be passed/spread directly to `createPartialApiContext`.
|
|
9
8
|
*/
|
|
10
9
|
export type AppCommandContext = Pick<LazyApiContextOptions, 'appPath' | 'cachePath' | 'config' | 'reporter' | 'telemetryClient'>;
|
|
11
|
-
/** Initialize options excluding `appPaths` */
|
|
12
|
-
export interface CommandInitializeOptions {
|
|
13
|
-
/** Additional options to merge in while reading the config. */
|
|
14
|
-
configOptions?: ReadConfigOptions;
|
|
15
|
-
}
|
|
16
10
|
export declare const ExitCodeSuccessful = 0;
|
|
17
11
|
export declare const ExitCodeGenericError = 1;
|
|
18
12
|
export declare const ExitCodeAuthenticationError = 2;
|
|
@@ -32,10 +26,12 @@ export interface CommandExitParams {
|
|
|
32
26
|
}
|
|
33
27
|
export interface CommandActionParams<TOptions extends object> {
|
|
34
28
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
29
|
+
* App paths and corresponding contexts.
|
|
30
|
+
*
|
|
31
|
+
* Unless `discoverAppPaths: 'multi'` was set during command initialization in `<command>/index.ts`,
|
|
32
|
+
* there will only be one path/context.
|
|
37
33
|
*/
|
|
38
|
-
|
|
34
|
+
contexts: AppCommandContext[];
|
|
39
35
|
/**
|
|
40
36
|
* Command-specific options, parsed from `process.argv`.
|
|
41
37
|
* Types are generally defined in each command's `src/commands/<name>/types/<Name>Types.ts` module.
|
|
@@ -54,22 +50,6 @@ export interface CommandActionParams<TOptions extends object> {
|
|
|
54
50
|
* when the program exits. (See `AutoDisposableList.add` for implementation.)
|
|
55
51
|
*/
|
|
56
52
|
autoDispose: AutoDispose;
|
|
57
|
-
/**
|
|
58
|
-
* This should be called at or near the beginning of the action to initialize the config,
|
|
59
|
-
* telemetry, and reporting. (See `CommandExecutor._initialize` for implementation.)
|
|
60
|
-
* `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.
|
|
61
|
-
*
|
|
62
|
-
* If it is called with a single string, it returns `Promise<AppCommandContext>`
|
|
63
|
-
* If it is called with a string[], it returns `Promise<AppCommandContext[]>`
|
|
64
|
-
*/
|
|
65
|
-
initialize: {
|
|
66
|
-
(initializeOptions: CommandInitializeOptions & {
|
|
67
|
-
appPath: string;
|
|
68
|
-
}): Promise<AppCommandContext>;
|
|
69
|
-
(initializeOptions: CommandInitializeOptions & {
|
|
70
|
-
appPaths: string[];
|
|
71
|
-
}): Promise<AppCommandContext[]>;
|
|
72
|
-
};
|
|
73
53
|
/**
|
|
74
54
|
* Set a callback to get the message to display if ctrl+C is pressed.
|
|
75
55
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandAction.d.ts","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"CommandAction.d.ts","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,qBAAqB,EACrB,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,iBAAiB,CACpE,CAAC;AAEF,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,MAAM,MAAM,QAAQ,GAAG,OAAO,kBAAkB,GAAG,OAAO,oBAAoB,GAAG,OAAO,2BAA2B,CAAC;AAEpH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,MAAM;IAC1D;;;;;OAKG;IACH,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAE9B;;;;OAIG;IACH,OAAO,EAAE,QAAQ,CAAC;IAElB;;;OAGG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,QAAQ,EAAE,YAAY,CAAC;IAEvB,WAAW,EAAE,WAAW,CAAC;IAEzB;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;OAEG;IACH,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;CAChE;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,CAAC,QAAQ,IAAI,CACpC,MAAM,EAAE,mBAAmB,CAAC,QAAQ,GAAG,aAAa,CAAC,KAClD,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;AAEvC,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":"
|
|
1
|
+
{"version":3,"file":"CommandAction.js","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC","sourcesContent":["import type { LazyApiContextOptions } from '@ms-cloudpack/api-server';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { AutoDispose } from './AutoDispose.js';\nimport type { SharedOptions } from './SharedOptions.js';\n\n/**\n * Context for running a command in a specific app (after initialization).\n * For convenience, this can be passed/spread directly to `createPartialApiContext`.\n */\nexport type AppCommandContext = Pick<\n LazyApiContextOptions,\n 'appPath' | 'cachePath' | 'config' | 'reporter' | 'telemetryClient'\n>;\n\nexport const ExitCodeSuccessful = 0;\nexport const ExitCodeGenericError = 1;\nexport const ExitCodeAuthenticationError = 2;\nexport type ExitCode = typeof ExitCodeSuccessful | typeof ExitCodeGenericError | typeof ExitCodeAuthenticationError;\n\nexport interface CommandExitParams {\n /**\n * Message to show on exit.\n * If `isInterrupted` is true, use an empty string (it will show a default interrupt message).\n */\n message: string;\n /** Whether there are errors. By default, checks the reporter for failed tasks. */\n hasErrors?: boolean;\n /** Exit code to use. Defaults to 1 if there are errors, 0 if not. */\n exitCode?: ExitCode;\n /** True if the user interrupted an operation (ctrl+C). Sets the message automatically. */\n isInterrupted?: true;\n}\n\nexport interface CommandActionParams<TOptions extends object> {\n /**\n * App paths and corresponding contexts.\n *\n * Unless `discoverAppPaths: 'multi'` was set during command initialization in `<command>/index.ts`,\n * there will only be one path/context.\n */\n contexts: AppCommandContext[];\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 * Set a callback to get the message to display if ctrl+C is pressed.\n */\n setInterruptMessageHandler: (getMessage: () => string) => void;\n}\n\n/**\n * Command action function (executor). This is the type of the `execute` function which should\n * be exported from each command's `src/commands/<name>/execute.ts` module.\n *\n * If it returns an object, the command wrapper will call the exit handler with that object.\n * If it returns null, it's assumed that this command is meant to keep running, such as `start`.\n */\nexport type CommandAction<TOptions> = (\n params: CommandActionParams<TOptions & SharedOptions>,\n) => Promise<CommandExitParams | null>;\n\nexport type CommandActionModule<TOptions> = {\n execute: CommandAction<TOptions>;\n};\n"]}
|
|
@@ -4,6 +4,15 @@ import type { LoginMethod } from '@ms-cloudpack/remote-cache';
|
|
|
4
4
|
* Types for options from `reusedOptions.ts` (pick the properties you need).
|
|
5
5
|
*/
|
|
6
6
|
export interface ReusedOptions extends Pick<CloudpackConfig, 'logBundleInfo' | 'mode'> {
|
|
7
|
+
/** Specifies which app to operate on, in the command is run at a higher level in the repo. */
|
|
8
|
+
app?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Force using a specific bundler (ori/rollup/rspack/webpack).
|
|
11
|
+
*
|
|
12
|
+
* Default is automatically choosing the bundler based on package contents, unless there any
|
|
13
|
+
* relevant package settings specify a bundler.
|
|
14
|
+
*/
|
|
15
|
+
bundler?: string;
|
|
7
16
|
/** Whether to use the cache */
|
|
8
17
|
cache?: boolean;
|
|
9
18
|
/** Writes the resolve map to `resolve-map.json`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReusedOptions.d.ts","sourceRoot":"","sources":["../../src/types/ReusedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,CAAC;IACpF,+BAA+B;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,oDAAoD;IACpD,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,kDAAkD;IAClD,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAE/B,mDAAmD;IACnD,KAAK,EAAE,WAAW,CAAC;CACpB"}
|
|
1
|
+
{"version":3,"file":"ReusedOptions.d.ts","sourceRoot":"","sources":["../../src/types/ReusedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,CAAC;IACpF,8FAA8F;IAC9F,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;;OAKG;IAGH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,oDAAoD;IACpD,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,kDAAkD;IAClD,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAE/B,mDAAmD;IACnD,KAAK,EAAE,WAAW,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReusedOptions.js","sourceRoot":"","sources":["../../src/types/ReusedOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { CloudpackConfig, PackageSettingsMatch } from '@ms-cloudpack/common-types';\nimport type { LoginMethod } from '@ms-cloudpack/remote-cache';\n\n/**\n * Types for options from `reusedOptions.ts` (pick the properties you need).\n */\nexport interface ReusedOptions extends Pick<CloudpackConfig, 'logBundleInfo' | 'mode'> {\n /** Whether to use the cache */\n cache?: boolean;\n\n /** Writes the resolve map to `resolve-map.json`. */\n logResolveMap?: boolean;\n\n /** Only evaluate/consider specific package(s). */\n match?: PackageSettingsMatch[];\n\n /** How to authenticate against the remote cache */\n login: LoginMethod;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ReusedOptions.js","sourceRoot":"","sources":["../../src/types/ReusedOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { CloudpackConfig, PackageSettingsMatch } from '@ms-cloudpack/common-types';\nimport type { LoginMethod } from '@ms-cloudpack/remote-cache';\n\n/**\n * Types for options from `reusedOptions.ts` (pick the properties you need).\n */\nexport interface ReusedOptions extends Pick<CloudpackConfig, 'logBundleInfo' | 'mode'> {\n /** Specifies which app to operate on, in the command is run at a higher level in the repo. */\n app?: string;\n\n /**\n * Force using a specific bundler (ori/rollup/rspack/webpack).\n *\n * Default is automatically choosing the bundler based on package contents, unless there any\n * relevant package settings specify a bundler.\n */\n // As of writing this is just used in BundleOptions, but having it here helps with typing of the\n // config option logic in CommandExecutor.\n bundler?: string;\n\n /** Whether to use the cache */\n cache?: boolean;\n\n /** Writes the resolve map to `resolve-map.json`. */\n logResolveMap?: boolean;\n\n /** Only evaluate/consider specific package(s). */\n match?: PackageSettingsMatch[];\n\n /** How to authenticate against the remote cache */\n login: LoginMethod;\n}\n"]}
|
|
@@ -19,9 +19,9 @@ export interface SharedOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
quiet?: boolean;
|
|
21
21
|
/**
|
|
22
|
-
* Experimental
|
|
22
|
+
* Experimental features to enable.
|
|
23
23
|
*/
|
|
24
|
-
features?: string
|
|
24
|
+
features?: Record<string, boolean>;
|
|
25
25
|
/**
|
|
26
26
|
* Custom cache folder to use for this run of the command.
|
|
27
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedOptions.d.ts","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"SharedOptions.d.ts","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedOptions.js","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Shared CLI options for all commands.\n */\nexport interface SharedOptions {\n /**\n * Whether to enable debug logging (superset of --verbose).\n */\n debug?: boolean;\n\n /**\n * Whether to enable verbose logging.\n */\n verbose?: boolean;\n\n /**\n * Whether to enable colors. Available on the command line as `--no-color`.\n */\n color?: boolean;\n\n /**\n * Whether to disable non-essential logging.\n */\n quiet?: boolean;\n\n /**\n * Experimental
|
|
1
|
+
{"version":3,"file":"SharedOptions.js","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Shared CLI options for all commands.\n */\nexport interface SharedOptions {\n /**\n * Whether to enable debug logging (superset of --verbose).\n */\n debug?: boolean;\n\n /**\n * Whether to enable verbose logging.\n */\n verbose?: boolean;\n\n /**\n * Whether to enable colors. Available on the command line as `--no-color`.\n */\n color?: boolean;\n\n /**\n * Whether to disable non-essential logging.\n */\n quiet?: boolean;\n\n /**\n * Experimental features to enable.\n */\n features?: Record<string, boolean>;\n\n /**\n * Custom cache folder to use for this run of the command.\n */\n cachePath?: string;\n}\n"]}
|
|
@@ -2,11 +2,12 @@ import { Command, Option, type AddHelpTextPosition, type Argument, type OutputCo
|
|
|
2
2
|
import type { CommandActionModule } from '../types/CommandAction.js';
|
|
3
3
|
import type { ProgramOptions } from '../types/ProgramOptions.js';
|
|
4
4
|
import type { SharedOptions } from '../types/SharedOptions.js';
|
|
5
|
+
import { type CommandExecutorSharedParams } from './CommandExecutor.js';
|
|
5
6
|
/**
|
|
6
7
|
* Parameters for creating a command.
|
|
7
8
|
* `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.
|
|
8
9
|
*/
|
|
9
|
-
interface CloudpackCommandParams<TOptions extends object, TArguments extends object> {
|
|
10
|
+
interface CloudpackCommandParams<TOptions extends object, TArguments extends object> extends CommandExecutorSharedParams {
|
|
10
11
|
/** Command name */
|
|
11
12
|
name: string;
|
|
12
13
|
/** Command description */
|
|
@@ -55,6 +56,7 @@ interface CloudpackCommandParams<TOptions extends object, TArguments extends obj
|
|
|
55
56
|
export declare class CloudpackCommand<TOptions extends object, TArguments extends object> {
|
|
56
57
|
private _command;
|
|
57
58
|
private _programOptions;
|
|
59
|
+
private _discoverAppPaths;
|
|
58
60
|
/**
|
|
59
61
|
* This should only be used directly (outside this class) to create the top-level `program` command.
|
|
60
62
|
* To add sub-commands, use `.addSubCommand` instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudpackCommand.d.ts","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,M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EpC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,aAAa,CAAC,GAAG,IAAI,CAAC;CACvD;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAgB,CAAC,QAAQ,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM;IAC9E,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,iBAAiB,CAAmC;IAE5D;;;OAGG;gBAGD,MAAM,EAAE,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG;QACrD,cAAc,EAAE,cAAc,CAAC;QAC/B,+DAA+D;QAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB;IAkDH,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;IAYnB,OAAO,CAAC,UAAU;CAqCnB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command, Help, Option } from 'commander';
|
|
2
2
|
import { CommandExecutor } from './CommandExecutor.js';
|
|
3
3
|
import { environmentInfo } from '@ms-cloudpack/environment';
|
|
4
|
+
import { parseFeature } from './parseFeature.js';
|
|
4
5
|
/**
|
|
5
6
|
* This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with
|
|
6
7
|
* Cloudpack-specific functionality and simpler APIs.
|
|
@@ -18,6 +19,7 @@ export class CloudpackCommand {
|
|
|
18
19
|
// The extra options here shouldn't be exposed to the `createSubCommand` API
|
|
19
20
|
params) {
|
|
20
21
|
this._programOptions = params.programOptions;
|
|
22
|
+
this._discoverAppPaths = params.discoverAppPaths;
|
|
21
23
|
const command = params.parent?.command(params.name) || new Command(params.name);
|
|
22
24
|
this._command = command;
|
|
23
25
|
command.version(params.programOptions.version);
|
|
@@ -45,7 +47,7 @@ export class CloudpackCommand {
|
|
|
45
47
|
color:
|
|
46
48
|
// In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)
|
|
47
49
|
new Option('-n, --no-color', 'Disable colors in the output.').default(!environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI),
|
|
48
|
-
features: new Option('--features <featureNames...>', 'Enable experimental features.'),
|
|
50
|
+
features: new Option('--features <featureNames...>', 'Enable experimental features.').argParser(parseFeature),
|
|
49
51
|
cachePath: new Option('--cache-path <path>', 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.'),
|
|
50
52
|
}, params.hideSharedOptions);
|
|
51
53
|
}
|
|
@@ -110,6 +112,7 @@ export class CloudpackCommand {
|
|
|
110
112
|
execute,
|
|
111
113
|
programOptions: this._programOptions,
|
|
112
114
|
verb,
|
|
115
|
+
discoverAppPaths: this._discoverAppPaths,
|
|
113
116
|
});
|
|
114
117
|
await commandExecutor.execute();
|
|
115
118
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAIrH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAsD5D;;;;;;;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,OA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AClC,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;AAED,MAAM,aAAc,SAAQ,IAAI;IAC9B,cAAc,CAAC,GAAY;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAE1C,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,WAAW,EAAE,CAAC;YAC/B,4EAA4E;YAC5E,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,SAAS,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { Command, Help, 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 } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\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. 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\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 command.allowExcessArguments(false);\n command.createHelp = () => new CloudpackHelp();\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 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 !environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI,\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.'),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ),\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>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, option] of Object.entries(options) as [keyof TAddOptions, Option][]) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\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 });\n await commandExecutor.execute();\n });\n }\n}\n\nclass CloudpackHelp extends Help {\n visibleOptions(cmd: Command): Option[] {\n const options = super.visibleOptions(cmd);\n\n if (cmd.name() !== 'cloudpack') {\n // Remove --version from help except at the top level (it's not very useful)\n return options.filter((option) => option.name() !== 'version');\n }\n\n return options;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAIrH,OAAO,EAAE,eAAe,EA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A6E;YAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,EAA4B,CAAC;YAEpE,kGAAkG;YAClG,wBAAwB;YACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEpG,0CAA0C;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,eAAe;gBACpC,IAAI;gBACJ,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;aACzC,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,aAAc,SAAQ,IAAI;IAC9B,cAAc,CAAC,GAAY;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAE1C,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,WAAW,EAAE,CAAC;YAC/B,4EAA4E;YAC5E,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,SAAS,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { Command, Help, 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 CommandExecutorSharedParams } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { parseFeature } from './parseFeature.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.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 CommandExecutorSharedParams {\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. 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 command.createHelp = () => new CloudpackHelp();\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 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 !environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI,\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.').argParser(parseFeature),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ),\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>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, option] of Object.entries(options) as [keyof TAddOptions, Option][]) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\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\nclass CloudpackHelp extends Help {\n visibleOptions(cmd: Command): Option[] {\n const options = super.visibleOptions(cmd);\n\n if (cmd.name() !== 'cloudpack') {\n // Remove --version from help except at the top level (it's not very useful)\n return options.filter((option) => option.name() !== 'version');\n }\n\n return options;\n }\n}\n"]}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import type { CommandAction, CommandExitParams } from '../types/CommandAction.js';
|
|
2
2
|
import type { ProgramOptions } from '../types/ProgramOptions.js';
|
|
3
3
|
import type { SharedOptions } from '../types/SharedOptions.js';
|
|
4
|
+
import type { ReusedOptions } from '../types/ReusedOptions.js';
|
|
5
|
+
import type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';
|
|
6
|
+
export interface CommandExecutorSharedParams {
|
|
7
|
+
/**
|
|
8
|
+
* By default, the command will run against `cwd` (usually `process.cwd()`).
|
|
9
|
+
* If this option is set, attempt to discover app path(s) instead.
|
|
10
|
+
* (`cwd` will still be preferred if it has a `cloudpack.config.json`.)
|
|
11
|
+
* See {@link AppPathDiscoveryMode} for details.
|
|
12
|
+
*/
|
|
13
|
+
discoverAppPaths?: AppPathDiscoveryMode;
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
16
|
* This class manages orchestration and shared state while executing a command.
|
|
6
17
|
*/
|
|
7
|
-
export declare class CommandExecutor<TOptions extends SharedOptions
|
|
18
|
+
export declare class CommandExecutor<TOptions extends SharedOptions & Pick<ReusedOptions, 'app'>> {
|
|
8
19
|
private _options;
|
|
9
20
|
private _execute;
|
|
10
21
|
private _programOptions;
|
|
11
22
|
private _verb;
|
|
23
|
+
private _discoverAppPaths;
|
|
12
24
|
private _reporter;
|
|
13
25
|
private _autoDisposableList;
|
|
14
26
|
private _abortController;
|
|
@@ -18,7 +30,7 @@ export declare class CommandExecutor<TOptions extends SharedOptions> {
|
|
|
18
30
|
private _getMessageOnInterrupt;
|
|
19
31
|
private static _activeInstances;
|
|
20
32
|
static exitAll(params: CommandExitParams): Promise<void>;
|
|
21
|
-
constructor(params: {
|
|
33
|
+
constructor(params: CommandExecutorSharedParams & {
|
|
22
34
|
/** Command-specific arguments */
|
|
23
35
|
args: string[];
|
|
24
36
|
/** Command-specific and shared options. */
|
|
@@ -33,12 +45,12 @@ export declare class CommandExecutor<TOptions extends SharedOptions> {
|
|
|
33
45
|
/** Run the command. */
|
|
34
46
|
execute(): Promise<void>;
|
|
35
47
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* the `execute` method must use `.bind(this)`.
|
|
39
|
-
* (An arrow function isn't possible here due to the overloaded method signature).
|
|
48
|
+
* Determine the app paths and initialize the context for each app.
|
|
49
|
+
* @returns Context(s), or an exit options object if there was an error. (might also throw on error)
|
|
40
50
|
*/
|
|
41
|
-
private
|
|
51
|
+
private _initializeContexts;
|
|
52
|
+
/** Translate certain CLI options into options for `readConfig()`. */
|
|
53
|
+
private _getConfigOptionsFromCliOptions;
|
|
42
54
|
private _initTelemetry;
|
|
43
55
|
protected _sigintHandler: () => void;
|
|
44
56
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAqB,MAAM,2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