@ms-cloudpack/cli 0.71.3 → 0.72.1
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 +9 -2
- 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 +2 -1
- package/lib/commands/bundle/index.js.map +1 -1
- package/lib/commands/start/execute.js +1 -1
- package/lib/commands/start/execute.js.map +1 -1
- package/lib/commands/start/trackSession.d.ts.map +1 -1
- package/lib/commands/start/trackSession.js +2 -1
- package/lib/commands/start/trackSession.js.map +1 -1
- package/lib/types/CommandAction.d.ts +9 -8
- package/lib/types/CommandAction.d.ts.map +1 -1
- package/lib/types/CommandAction.js.map +1 -1
- package/lib/utilities/CommandExecutor.d.ts.map +1 -1
- package/lib/utilities/CommandExecutor.js +14 -15
- package/lib/utilities/CommandExecutor.js.map +1 -1
- package/lib/utilities/getFilteredPackages.d.ts.map +1 -1
- package/lib/utilities/getFilteredPackages.js +11 -1
- package/lib/utilities/getFilteredPackages.js.map +1 -1
- package/package.json +7 -7
- package/lib/utilities/getMergedFeatureFlags.d.ts +0 -9
- package/lib/utilities/getMergedFeatureFlags.d.ts.map +0 -1
- package/lib/utilities/getMergedFeatureFlags.js +0 -32
- package/lib/utilities/getMergedFeatureFlags.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,CAiFhD,CAAC"}
|
|
@@ -4,7 +4,15 @@ import path from 'path';
|
|
|
4
4
|
import { getFilteredPackages } from '../../utilities/getFilteredPackages.js';
|
|
5
5
|
export const execute = async (params) => {
|
|
6
6
|
const { cwd: appPath, options, reporter, initialize, exit, autoDispose } = params;
|
|
7
|
-
const apiContextOptions = await initialize({
|
|
7
|
+
const apiContextOptions = await initialize({
|
|
8
|
+
appPath,
|
|
9
|
+
configOptions: {
|
|
10
|
+
mode: options.mode,
|
|
11
|
+
// Handle --bundler by passing it as a universal package override, which will be appended
|
|
12
|
+
// to any user-provided packageSettings so that it takes precedence.
|
|
13
|
+
extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
8
16
|
console.log('Bundle mode:', yellow(options.mode));
|
|
9
17
|
const [ctx] = autoDispose(await createPartialApiContext({
|
|
10
18
|
...apiContextOptions,
|
|
@@ -34,7 +42,6 @@ export const execute = async (params) => {
|
|
|
34
42
|
name: definition.name,
|
|
35
43
|
version: definition.version,
|
|
36
44
|
outputPath,
|
|
37
|
-
bundler: options.bundler,
|
|
38
45
|
disableSourceMaps: options.disableSourceMaps,
|
|
39
46
|
shouldForce: true,
|
|
40
47
|
isIncremental: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,IAAI,MA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C,IAAI;gBACrB,OAAO,EAAE,UAAU,CAAC,OAAO;gBAC3B,UAAU;gBACV,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;gBAC5C,WAAW,EAAE,IAAI;gBACjB,aAAa,EAAE,KAAK;aACrB;YACD,GAAG;SACJ,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAEhD,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YAC1B,kBAAkB,EAAE,CAAC;QACvB,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;YACnC,iBAAiB,EAAE,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,oBAAoB,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG;QACb,kBAAkB,IAAI,GAAG,CAAC,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;QACzE,iBAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,mCAAmC,CAAC,CAAC;QAC3F,oBAAoB,IAAI,MAAM,CAAC,oBAAoB,EAAE,qBAAqB,CAAC;KAC5E;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,IAAI,CAAC;QACT,OAAO,EAAE,YAAY,MAAM,IAAI;QAC/B,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACrC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { plural, red, yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\n\nexport const execute: CommandAction<BundleOptions> = async (params) => {\n const { cwd: appPath, options, reporter, initialize, exit, autoDispose } = params;\n const apiContextOptions = await initialize({\n appPath,\n configOptions: {\n mode: options.mode,\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 console.log('Bundle mode:', yellow(options.mode));\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'watcher', 'session', 'taskRunner', 'bus', 'packageImportPaths', 'packageHashes'],\n }),\n );\n\n const pathsToBundle = options.match ? getFilteredPackages(ctx.session.resolveMap, options.match) : [appPath];\n\n if (!pathsToBundle.length) {\n await exit({\n message: 'No matching packages found to bundle.',\n exitCode: 1,\n });\n return;\n }\n\n // Show completed bundle tasks so the user knows what's happening.\n reporter.setOptions({ ...reporter.getOptions(), showCompleted: true });\n\n let warnPackagesCount = 0;\n let errorPackagesCount = 0;\n let successPackagesCount = 0;\n\n for (const packagePath of pathsToBundle) {\n // If outdir is set, resolve relative to the package/app path.\n // Otherwise, use the default path under the cloudpack cache to stay consistent with init and start,\n // and to avoid potentially messing with the package's original output.\n const outputPath = options.outdir ? path.resolve(packagePath, options.outdir) : undefined;\n\n const definition = await ctx.packages.get(packagePath);\n\n const { result } = await ensurePackageBundled({\n input: {\n name: definition.name,\n version: definition.version,\n outputPath,\n disableSourceMaps: options.disableSourceMaps,\n shouldForce: true,\n isIncremental: false,\n },\n ctx,\n });\n\n console.log('Output:', result.outputPath, '\\n');\n\n if (result.errors?.length) {\n errorPackagesCount++;\n } else if (result.warnings?.length) {\n warnPackagesCount++;\n } else {\n successPackagesCount++;\n }\n }\n\n const status = [\n errorPackagesCount && red(plural(errorPackagesCount, 'package$s failed')),\n warnPackagesCount && yellow(plural(warnPackagesCount, 'package$s succeeded with warnings')),\n successPackagesCount && plural(successPackagesCount, 'package$s succeeded'),\n ]\n .filter(Boolean)\n .join(', ');\n\n await exit({\n message: `Bundling ${status}\\n`,\n exitCode: errorPackagesCount ? 1 : 0,\n });\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAK9E,iCAAiC;AACjC,eAAO,MAAM,IAAI,EAAE,mBAuBlB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { bundlerNames } from '@ms-cloudpack/bundler';
|
|
1
2
|
import { InvalidArgumentError, Option } from 'commander';
|
|
2
3
|
import { parseMatch } from '../../utilities/parseMatch.js';
|
|
3
4
|
import { reusedOptions } from '../../utilities/reusedOptions.js';
|
|
@@ -8,7 +9,7 @@ export const init = (program) => {
|
|
|
8
9
|
description: 'Bundles a package.',
|
|
9
10
|
options: {
|
|
10
11
|
mode: reusedOptions.mode({ action: 'bundle' }),
|
|
11
|
-
bundler: new Option('--bundler <name>', 'Force using a specific bundler.').choices(
|
|
12
|
+
bundler: new Option('--bundler <name>', 'Force using a specific bundler.').choices(bundlerNames),
|
|
12
13
|
match: new Option('--match <match...>', 'Bundle specific package(s), optionally with a version: e.g. "foo", "@foo/*", "foo@1.2.3"').argParser(parseMatch),
|
|
13
14
|
package: new Option('--package <package>').hideHelp().argParser(() => {
|
|
14
15
|
throw new InvalidArgumentError('Use --match instead of --package');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,a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,oBAAoB,CAAC,kCAAkC,CAAC,CAAC;YACrE,CAAC,CAAC;YACF,MAAM,EAAE,IAAI,MAAM,CAChB,iBAAiB,EACjB,yGAAyG;gBACvG,8CAA8C,CACjD;YACD,iBAAiB,EAAE,IAAI,MAAM,CAAC,uBAAuB,EAAE,sBAAsB,CAAC;SAC/E;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { bundlerNames } from '@ms-cloudpack/bundler';\nimport { InvalidArgumentError, Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport { parseMatch } from '../../utilities/parseMatch.js';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n/** Defines the \"bundle\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<BundleOptions>({\n name: 'bundle',\n description: 'Bundles a package.',\n options: {\n mode: reusedOptions.mode({ action: 'bundle' }),\n bundler: new Option('--bundler <name>', 'Force using a specific bundler.').choices(bundlerNames),\n match: new Option(\n '--match <match...>',\n 'Bundle specific package(s), optionally with a version: e.g. \"foo\", \"@foo/*\", \"foo@1.2.3\"',\n ).argParser(parseMatch),\n package: new Option('--package <package>').hideHelp().argParser(() => {\n throw new InvalidArgumentError('Use --match instead of --package');\n }),\n outdir: new Option(\n '--outdir <path>',\n 'Path for the bundle output, relative to current path (or the resolved path to --package if specified). ' +\n 'Default is a path under the cloudpack cache.',\n ),\n disableSourceMaps: new Option('--disable-source-maps', 'Disable source maps.'),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
|
|
@@ -19,7 +19,7 @@ export const execute = async (params) => {
|
|
|
19
19
|
const { options, cwd, initialize, autoDispose, exit } = params;
|
|
20
20
|
setStopServersFunction(exit);
|
|
21
21
|
const appPath = await getStartingAppPath(cwd, options.app);
|
|
22
|
-
const apiContextOptions = await initialize({ appPath, mode: options.mode });
|
|
22
|
+
const apiContextOptions = await initialize({ appPath, configOptions: { mode: options.mode } });
|
|
23
23
|
const { config, telemetryClient } = apiContextOptions;
|
|
24
24
|
console.log('App path:', yellow(appPath));
|
|
25
25
|
console.log('Bundle mode:', yellow(options.mode));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAgC,MAAM,0BAA0B,CAAC;AACvH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAgC,KAAK,EAAE,MAAM,EAAE,EAAE;IACnE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IA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K,eAAe,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;YACrD,MAAM,aAAa,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAE1F,OAAO,CACL,eAAe,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,mDAAmD;gBAC3F,QAAQ,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,0DAA0D;gBAC/F,oBAAoB,CACrB,CAAC;QACJ,CAAC;QAED,OAAO,8BAA+B,GAAa,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;IACrE,CAAC;AACH,CAAC;AAED,wBAAwB","sourcesContent":["import { createPartialApiContext, ensurePackageBundled, type ApiServer, type Context } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { isExternalPackage, resolve } from '@ms-cloudpack/package-utilities';\nimport { makeUrl } from '@ms-cloudpack/path-string-parsing';\nimport { cyan, yellow, bold } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { openBrowser } from './openBrowser.js';\nimport { trackSession } from './trackSession.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { getCertificate } from '@ms-cloudpack/setup-utilities';\nimport { setStopServersFunction } from '../../utilities/stopServers.js';\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { options, cwd, initialize, autoDispose, exit } = params;\n setStopServersFunction(exit);\n\n const appPath = await getStartingAppPath(cwd, options.app);\n const apiContextOptions = await initialize({ appPath, mode: options.mode });\n const { config, telemetryClient } = apiContextOptions;\n\n console.log('App path:', yellow(appPath));\n console.log('Bundle mode:', yellow(options.mode));\n\n runPrerequisites(apiContextOptions);\n\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n let overlayPath = await resolve('@ms-cloudpack/overlay', currentDir);\n\n // If overlay is an internal package, resolve the overlay from the current package's linked node modules\n // to \"externalize\" it, so that we always use the bundled version of the overlay instead of the source.\n if (overlayPath && !isExternalPackage(overlayPath)) {\n const cliPath = await resolve('@ms-cloudpack/cli', currentDir);\n overlayPath = cliPath ? path.join(cliPath, 'node_modules', '@ms-cloudpack/overlay') : undefined;\n }\n\n const [apiContext] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n overlayPath,\n }),\n );\n const { packages, session } = apiContext;\n\n // Increment the session version if caching is disabled.\n if (options.cache === false) {\n session.incrementSessionVersion();\n }\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n telemetryClient.setSharedSpanAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n // Start api server for tracking status and handling remote requests.\n const serverOrError = await createApiServer(options, apiContext);\n if (typeof serverOrError === 'string') {\n await exit({ exitCode: 1, message: serverOrError });\n return;\n }\n const apiServer = serverOrError;\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({\n input: { name: definition.name, version: definition.version },\n ctx: apiContext,\n });\n\n // Then start bundle and app servers for hosting the app.\n const { startServers } = await import('@ms-cloudpack/app-server');\n const servers = await startServers(\n {\n definition,\n bundleServerOptions: { disableCache: !options.cache, port: options.bundleServerPort },\n port: options.appServerPort,\n },\n apiContext,\n );\n\n // Save the session to active sessions.\n const sessionTracker = await trackSession(session);\n\n const cleanup = async () => {\n // Stop tracking the session.\n await sessionTracker.close();\n\n await Promise.all(\n Object.entries({ apiServer, ...servers }).map(async ([name, server]) => {\n if (!server) return;\n\n const desc = `${name} (${server.url})`;\n console.info(`Closing ${desc}`);\n try {\n await server.close();\n console.info(`Closed ${desc}`);\n } catch (err) {\n console.warn(`Error closing ${desc}:`, err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n\n const defaultUrl = makeUrl(config.server?.defaultPath || '', session.urls.appServer).href;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n\n // Open the browser.\n if (options.open !== false) {\n openBrowser(defaultUrl).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n } else {\n console.log('Please open the browser manually to:', defaultUrl);\n }\n};\n\n/**\n * Create the API server, or return an error message if the server could not be created.\n */\nasync function createApiServer(options: StartOptions, apiContext: Context): Promise<ApiServer | string> {\n const { session } = apiContext;\n const { config } = session;\n const { server, appPath } = config;\n\n // If a cert is needed, check that it exists.\n if (server?.https === true && !(await getCertificate({ domain: server?.domain, cwd: appPath }))) {\n return (\n `The local site is configured to use https in cloudpack.config.json, but is missing a cert.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to create the required certificate and try start again.\\n`\n );\n }\n\n const { createCloudpackServer } = await import('@ms-cloudpack/api-server');\n\n try {\n return await createCloudpackServer({ port: options.apiServerPort }, apiContext);\n } catch (err) {\n const error = err as { code: string };\n\n if (error.code === 'EADDRNOTAVAIL' && server?.domain) {\n const primaryDomain = (Array.isArray(server.domain) ? server.domain : [server.domain])[0];\n\n return (\n `The domain \"${cyan(bold(primaryDomain))}\" in cloudpack.config.json is not resolvable.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to add the appropriate entries to your hosts file and ` +\n `try start again.\\n`\n );\n }\n\n return `Error creating API server: ${(err as Error).stack || err}`;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AAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAE1F,OAAO,CACL,eAAe,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,mDAAmD;gBAC3F,QAAQ,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,0DAA0D;gBAC/F,oBAAoB,CACrB,CAAC;QACJ,CAAC;QAED,OAAO,8BAA+B,GAAa,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;IACrE,CAAC;AACH,CAAC;AAED,wBAAwB","sourcesContent":["import { createPartialApiContext, ensurePackageBundled, type ApiServer, type Context } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { isExternalPackage, resolve } from '@ms-cloudpack/package-utilities';\nimport { makeUrl } from '@ms-cloudpack/path-string-parsing';\nimport { cyan, yellow, bold } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { openBrowser } from './openBrowser.js';\nimport { trackSession } from './trackSession.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { getCertificate } from '@ms-cloudpack/setup-utilities';\nimport { setStopServersFunction } from '../../utilities/stopServers.js';\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { options, cwd, initialize, autoDispose, exit } = params;\n setStopServersFunction(exit);\n\n const appPath = await getStartingAppPath(cwd, options.app);\n const apiContextOptions = await initialize({ appPath, configOptions: { mode: options.mode } });\n const { config, telemetryClient } = apiContextOptions;\n\n console.log('App path:', yellow(appPath));\n console.log('Bundle mode:', yellow(options.mode));\n\n runPrerequisites(apiContextOptions);\n\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n let overlayPath = await resolve('@ms-cloudpack/overlay', currentDir);\n\n // If overlay is an internal package, resolve the overlay from the current package's linked node modules\n // to \"externalize\" it, so that we always use the bundled version of the overlay instead of the source.\n if (overlayPath && !isExternalPackage(overlayPath)) {\n const cliPath = await resolve('@ms-cloudpack/cli', currentDir);\n overlayPath = cliPath ? path.join(cliPath, 'node_modules', '@ms-cloudpack/overlay') : undefined;\n }\n\n const [apiContext] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n overlayPath,\n }),\n );\n const { packages, session } = apiContext;\n\n // Increment the session version if caching is disabled.\n if (options.cache === false) {\n session.incrementSessionVersion();\n }\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n telemetryClient.setSharedSpanAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n // Start api server for tracking status and handling remote requests.\n const serverOrError = await createApiServer(options, apiContext);\n if (typeof serverOrError === 'string') {\n await exit({ exitCode: 1, message: serverOrError });\n return;\n }\n const apiServer = serverOrError;\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({\n input: { name: definition.name, version: definition.version },\n ctx: apiContext,\n });\n\n // Then start bundle and app servers for hosting the app.\n const { startServers } = await import('@ms-cloudpack/app-server');\n const servers = await startServers(\n {\n definition,\n bundleServerOptions: { disableCache: !options.cache, port: options.bundleServerPort },\n port: options.appServerPort,\n },\n apiContext,\n );\n\n // Save the session to active sessions.\n const sessionTracker = await trackSession(session);\n\n const cleanup = async () => {\n // Stop tracking the session.\n await sessionTracker.close();\n\n await Promise.all(\n Object.entries({ apiServer, ...servers }).map(async ([name, server]) => {\n if (!server) return;\n\n const desc = `${name} (${server.url})`;\n console.info(`Closing ${desc}`);\n try {\n await server.close();\n console.info(`Closed ${desc}`);\n } catch (err) {\n console.warn(`Error closing ${desc}:`, err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n\n const defaultUrl = makeUrl(config.server?.defaultPath || '', session.urls.appServer).href;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n\n // Open the browser.\n if (options.open !== false) {\n openBrowser(defaultUrl).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n } else {\n console.log('Please open the browser manually to:', defaultUrl);\n }\n};\n\n/**\n * Create the API server, or return an error message if the server could not be created.\n */\nasync function createApiServer(options: StartOptions, apiContext: Context): Promise<ApiServer | string> {\n const { session } = apiContext;\n const { config } = session;\n const { server, appPath } = config;\n\n // If a cert is needed, check that it exists.\n if (server?.https === true && !(await getCertificate({ domain: server?.domain, cwd: appPath }))) {\n return (\n `The local site is configured to use https in cloudpack.config.json, but is missing a cert.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to create the required certificate and try start again.\\n`\n );\n }\n\n const { createCloudpackServer } = await import('@ms-cloudpack/api-server');\n\n try {\n return await createCloudpackServer({ port: options.apiServerPort }, apiContext);\n } catch (err) {\n const error = err as { code: string };\n\n if (error.code === 'EADDRNOTAVAIL' && server?.domain) {\n const primaryDomain = (Array.isArray(server.domain) ? server.domain : [server.domain])[0];\n\n return (\n `The domain \"${cyan(bold(primaryDomain))}\" in cloudpack.config.json is not resolvable.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to add the appropriate entries to your hosts file and ` +\n `try start again.\\n`\n );\n }\n\n return `Error creating API server: ${(err as Error).stack || err}`;\n }\n}\n\n// cspell:ignore Prereqs\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trackSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMxD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO;;
|
|
1
|
+
{"version":3,"file":"trackSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMxD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO;;GAWlD"}
|
|
@@ -13,7 +13,8 @@ export async function trackSession(session) {
|
|
|
13
13
|
await writeJson(activeSessionPath, session);
|
|
14
14
|
return {
|
|
15
15
|
async close() {
|
|
16
|
-
|
|
16
|
+
// Don't error if something has already deleted the file (most likely in tests)
|
|
17
|
+
await rm(activeSessionPath, { force: true });
|
|
17
18
|
},
|
|
18
19
|
};
|
|
19
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trackSession.js","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB;IACjD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAEpG,MAAM,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAE5C,OAAO;QACL,KAAK,CAAC,KAAK;YACT,MAAM,EAAE,CAAC,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"trackSession.js","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB;IACjD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAEpG,MAAM,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAE5C,OAAO;QACL,KAAK,CAAC,KAAK;YACT,+EAA+E;YAC/E,MAAM,EAAE,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport { getActiveSessionsPath } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { rm } from 'fs/promises';\nimport path from 'path';\n\n/**\n * Tracks active sessions to disk as they are started. This gives us a way to enumerate\n * all active sessions for scenarios like better error messages when sessions are already\n * running for a given path, or for the link verb where we want to manipulate an active\n * running session.\n */\nexport async function trackSession(session: Session) {\n const activeSessionPath = path.join(getActiveSessionsPath(session.cachePath), `${session.id}.json`);\n\n await writeJson(activeSessionPath, session);\n\n return {\n async close() {\n // Don't error if something has already deleted the file (most likely in tests)\n await rm(activeSessionPath, { force: true });\n },\n };\n}\n"]}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import type { LazyApiContextOptions } from '@ms-cloudpack/api-server';
|
|
2
|
+
import type { ReadConfigOptions } from '@ms-cloudpack/config';
|
|
1
3
|
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
2
|
-
import type { BundleMode } from '@ms-cloudpack/common-types';
|
|
3
4
|
import type { AutoDispose } from './AutoDispose.js';
|
|
4
5
|
import type { SharedOptions } from './SharedOptions.js';
|
|
5
|
-
import type { LazyApiContextOptions } from '@ms-cloudpack/api-server';
|
|
6
6
|
/**
|
|
7
7
|
* Context for running a command in a specific app (after initialization).
|
|
8
8
|
* For convenience, this can be passed/spread directly to `createPartialApiContext`.
|
|
9
9
|
*/
|
|
10
10
|
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
|
+
}
|
|
11
16
|
export declare const ExitCodeSuccessful = 0;
|
|
12
17
|
export declare const ExitCodeGenericError = 1;
|
|
13
18
|
export declare const ExitCodeAuthenticationError = 2;
|
|
@@ -50,15 +55,11 @@ export interface CommandActionParams<TOptions extends object> {
|
|
|
50
55
|
* If it is called with a string[], it returns `Promise<AppCommandContext[]>`
|
|
51
56
|
*/
|
|
52
57
|
initialize: {
|
|
53
|
-
(initializeOptions: {
|
|
58
|
+
(initializeOptions: CommandInitializeOptions & {
|
|
54
59
|
appPath: string;
|
|
55
|
-
mode?: BundleMode;
|
|
56
|
-
overrideOptions?: Partial<SharedOptions>;
|
|
57
60
|
}): Promise<AppCommandContext>;
|
|
58
|
-
(initializeOptions: {
|
|
61
|
+
(initializeOptions: CommandInitializeOptions & {
|
|
59
62
|
appPaths: string[];
|
|
60
|
-
mode?: BundleMode;
|
|
61
|
-
overrideOptions?: Partial<SharedOptions>;
|
|
62
63
|
}): Promise<AppCommandContext[]>;
|
|
63
64
|
};
|
|
64
65
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandAction.d.ts","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"AAAA,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,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,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,8CAA8C;AAC9C,MAAM,WAAW,wBAAwB;IACvC,+DAA+D;IAC/D,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,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,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,MAAM;IAC1D;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;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;;;;;;;OAOG;IACH,UAAU,EAAE;QACV,CAAC,iBAAiB,EAAE,wBAAwB,GAAG;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAChG,CAAC,iBAAiB,EAAE,wBAAwB,GAAG;YAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;SAAE,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;KACtG,CAAC;IAEF;;;OAGG;IACH,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD;;OAEG;IACH,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;CAChE;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,QAAQ,GAAG,aAAa,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/G,MAAM,MAAM,mBAAmB,CAAC,QAAQ,IAAI;IAC1C,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CAClC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandAction.js","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CommandAction.js","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"AAqBA,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 { ReadConfigOptions } from '@ms-cloudpack/config';\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\n/** Initialize options excluding `appPaths` */\nexport interface CommandInitializeOptions {\n /** Additional options to merge in while reading the config. */\n configOptions?: ReadConfigOptions;\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 message: string;\n hasErrors?: boolean;\n exitCode?: ExitCode;\n}\n\nexport interface CommandActionParams<TOptions extends object> {\n /**\n * Initial working directory (usually `process.cwd()` except in tests).\n * Note that this may differ from the `appPath` used by individual commands.\n */\n cwd: string;\n\n /**\n * Command-specific options, parsed from `process.argv`.\n * Types are generally defined in each command's `src/commands/<name>/types/<Name>Types.ts` module.\n * The command line options are defined in each command's `src/commands/<name>/index.ts` module.\n */\n options: TOptions;\n\n /**\n * Command-specific arguments. Arguments in commander are positional arguments that are not options.\n * For example, in `echo somestring`, `somestring` is an argument.\n */\n args: string[];\n\n reporter: TaskReporter;\n\n abortSignal: AbortSignal;\n\n /**\n * Function that can be called with any `Disposable`s that should be cleaned up automatically\n * when the program exits. (See `AutoDisposableList.add` for implementation.)\n */\n autoDispose: AutoDispose;\n\n /**\n * This should be called at or near the beginning of the action to initialize the config,\n * telemetry, and reporting. (See `CommandExecutor._initialize` for implementation.)\n * `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.\n *\n * If it is called with a single string, it returns `Promise<AppCommandContext>`\n * If it is called with a string[], it returns `Promise<AppCommandContext[]>`\n */\n initialize: {\n (initializeOptions: CommandInitializeOptions & { appPath: string }): Promise<AppCommandContext>;\n (initializeOptions: CommandInitializeOptions & { appPaths: string[] }): Promise<AppCommandContext[]>;\n };\n\n /**\n * This should be called at the end of the action to dispose resources, log completion,\n * and exit the program. (See `CommandExecutor._exit` for implementation.)\n */\n exit: (result: CommandExitParams) => Promise<void>;\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. This is the type of the `execute` function which should be exported\n * from each command's `src/commands/<name>/execute.ts` module.\n */\nexport type CommandAction<TOptions> = (params: CommandActionParams<TOptions & SharedOptions>) => Promise<void>;\n\nexport type CommandActionModule<TOptions> = {\n execute: CommandAction<TOptions>;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,aAAa,EAId,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAQ/D;;GAEG;AACH,qBAAa,eAAe,CAAC,QAAQ,SAAS,aAAa;IACzD,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,sBAAsB,CAA+B;gBAEjD,MAAM,EAAE;QAClB,iCAAiC;QACjC,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,2CAA2C;QAC3C,OAAO,EAAE,QAAQ,CAAC;QAClB,uCAAuC;QACvC,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;QACjC,0CAA0C;QAC1C,cAAc,EAAE,cAAc,CAAC;QAC/B,sDAAsD;QACtD,IAAI,EAAE,MAAM,CAAC;KACd;IAWD,uBAAuB;IAEV,OAAO;IA4CpB;;;;;OAKG;YACW,WAAW;YAgHX,cAAc;IA0D5B;;;OAGG;IACH,OAAO,CAAC,KAAK,CA4BX;CACH"}
|
|
@@ -7,9 +7,9 @@ import { registerPerformanceObservers } from '../performance/registerPerformance
|
|
|
7
7
|
import { isCIBuild } from '../utilities/isCIBuild.js';
|
|
8
8
|
import { AutoDisposableList } from './AutoDisposableList.js';
|
|
9
9
|
import { checkFeatures } from './checkFeatures.js';
|
|
10
|
-
import { getMergedFeatureFlags } from './getMergedFeatureFlags.js';
|
|
11
10
|
import { isCodespaces } from '../utilities/isCodespaces.js';
|
|
12
11
|
import { getVersion } from '@ms-cloudpack/package-utilities';
|
|
12
|
+
import { mergeFeatures } from './mergeFeatures.js';
|
|
13
13
|
/**
|
|
14
14
|
* This class manages orchestration and shared state while executing a command.
|
|
15
15
|
*/
|
|
@@ -97,7 +97,7 @@ export class CommandExecutor {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
async _initialize(initializeParams) {
|
|
100
|
-
const { appPath: singleAppPath,
|
|
100
|
+
const { appPath: singleAppPath, configOptions } = initializeParams;
|
|
101
101
|
let { appPaths } = initializeParams;
|
|
102
102
|
if (singleAppPath && appPaths) {
|
|
103
103
|
throw Error('appPath and appPaths cannot both be specified at the same time');
|
|
@@ -109,16 +109,12 @@ export class CommandExecutor {
|
|
|
109
109
|
appPaths = singleAppPath ? [singleAppPath] : [];
|
|
110
110
|
}
|
|
111
111
|
const contexts = [];
|
|
112
|
-
const actionOptions = {
|
|
113
|
-
...this._options,
|
|
114
|
-
...initializeParams.overrideOptions,
|
|
115
|
-
};
|
|
116
112
|
const helpMessages = new Set();
|
|
117
|
-
const configs =
|
|
113
|
+
const configs = {};
|
|
118
114
|
for (const appPath of appPaths) {
|
|
119
115
|
let config;
|
|
120
116
|
try {
|
|
121
|
-
config = await readConfig(appPath,
|
|
117
|
+
config = await readConfig(appPath, configOptions);
|
|
122
118
|
}
|
|
123
119
|
catch (err) {
|
|
124
120
|
await this._exit({
|
|
@@ -131,7 +127,7 @@ export class CommandExecutor {
|
|
|
131
127
|
if (config.helpMessage) {
|
|
132
128
|
helpMessages.add(config.helpMessage);
|
|
133
129
|
}
|
|
134
|
-
configs
|
|
130
|
+
configs[appPath] = config;
|
|
135
131
|
}
|
|
136
132
|
// Set reporter options and print the product info header
|
|
137
133
|
this._reporter.setOptions({
|
|
@@ -139,17 +135,17 @@ export class CommandExecutor {
|
|
|
139
135
|
version: this._programOptions.version,
|
|
140
136
|
description: () => `Running "${bold(this._programOptions.argv.slice(2).join(' '))}"`,
|
|
141
137
|
helpMessage: [...helpMessages].join('\n'),
|
|
142
|
-
plainTextMode: !
|
|
143
|
-
...(
|
|
138
|
+
plainTextMode: !this._options.color,
|
|
139
|
+
...(this._options.debug
|
|
144
140
|
? debugLoggingConfig
|
|
145
|
-
:
|
|
141
|
+
: this._options.verbose
|
|
146
142
|
? verboseLoggingConfig
|
|
147
|
-
:
|
|
143
|
+
: this._options.quiet
|
|
148
144
|
? noLoggingConfig
|
|
149
145
|
: defaultLoggingConfig),
|
|
150
146
|
});
|
|
151
147
|
for (const appPath of appPaths) {
|
|
152
|
-
const config = configs
|
|
148
|
+
const config = configs[appPath];
|
|
153
149
|
const definition = await readJson(path.join(appPath, 'package.json'));
|
|
154
150
|
const { name = path.basename(appPath) } = definition || {};
|
|
155
151
|
const telemetryClient = await this._initTelemetry(name, config);
|
|
@@ -158,7 +154,10 @@ export class CommandExecutor {
|
|
|
158
154
|
dispose: () => telemetryClient.shutdown(),
|
|
159
155
|
});
|
|
160
156
|
// Merge in any additional features from the command line and remote feature flags.
|
|
161
|
-
config.features =
|
|
157
|
+
config.features = mergeFeatures({
|
|
158
|
+
configFeatures: config.features,
|
|
159
|
+
commandLineFeatures: this._options.features,
|
|
160
|
+
});
|
|
162
161
|
const featureErrors = checkFeatures({ configFeatures: config.features });
|
|
163
162
|
// If there are any invalid features, warn the user and continue.
|
|
164
163
|
if (featureErrors.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,GAAG,EACH,oBAAoB,EACpB,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,yBAAyB,CAAC;AACtF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAI9F,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,eAAe;IAY1B,YAAY,MAWX;QAfO,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BACnB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBAClC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;gBAC7C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;gBACrC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,gCAAgC;aAC5D,CAAC;YAEF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBACxD,IAAI,KAAK,EAAE,CAAC;oBACV,eAAe,CAAC,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC;QACH,CAAC;QAED,qFAAqF;QACrF,4BAA4B,CAAC,eAAe,CAAC,CAAC;QAE9C,OAAO,eAAe,CAAC;IACzB,CAAC;CAmCF","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport type { BundleMode, 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 { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport { registerPerformanceObservers } from '../performance/registerPerformanceObservers.js';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport { getMergedFeatureFlags } from './getMergedFeatureFlags.js';\nimport { isCodespaces } from '../utilities/isCodespaces.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\nexport class CommandExecutor<TOptions extends SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _abortController: AbortController;\n private _hasCalledExit = false;\n private _args: string[];\n private _getMessageOnInterrupt = () => `Interrupted by user`;\n\n constructor(params: {\n /** Command-specific arguments */\n args: string[];\n /** Command-specific and shared options. */\n options: TOptions;\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n }) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._reporter = new TaskReporter();\n this._abortController = new AbortController();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute() {\n try {\n // Setup cleanup and close things on completion.\n let sigintCount = 0;\n\n // Handle SIGINT (Ctrl+C) gracefully.\n process.on('SIGINT', () => {\n sigintCount++;\n if (sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n process.exit(1);\n }\n\n // We are trying to exit gracefully.\n void this._exit({ message: this._getMessageOnInterrupt() });\n });\n\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n await this._execute({\n args: this._args,\n options: this._options,\n cwd: this._programOptions.cwd,\n reporter: this._reporter,\n initialize: this._initialize.bind(this),\n abortSignal: this._abortController.signal,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n exit: this._exit,\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: error instanceof Error ? error.stack || error.message : String(error),\n });\n }\n }\n\n /**\n * This is the `initialize` function passed to the command's execute function.\n * This function uses `this` to references several class members, which is why\n * the `execute` method must use `.bind(this)`.\n * (An arrow function isn't possible here due to the overloaded method signature).\n */\n private async _initialize(initializeParams: {\n appPath: string;\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext>;\n private async _initialize(initializeParams: {\n appPaths: string[];\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext[]>;\n private async _initialize(initializeParams: {\n appPath?: string;\n appPaths?: string[];\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext | AppCommandContext[]> {\n const { appPath: singleAppPath, mode } = initializeParams;\n let { appPaths } = initializeParams;\n\n if (singleAppPath && appPaths) {\n throw Error('appPath and appPaths cannot both be specified at the same time');\n }\n if (!singleAppPath && !appPaths) {\n throw Error('one of appPath or appPaths must be specified');\n }\n\n if (!appPaths || appPaths.length === 0) {\n appPaths = singleAppPath ? [singleAppPath] : [];\n }\n\n const contexts: AppCommandContext[] = [];\n\n const actionOptions: SharedOptions = {\n ...this._options,\n ...initializeParams.overrideOptions,\n };\n\n const helpMessages = new Set<string>();\n\n const configs = new Map<string, CloudpackConfig>();\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, mode);\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // this will never be reached, but TypeScript doesn't know that\n process.exit(1);\n }\n if (config.helpMessage) {\n helpMessages.add(config.helpMessage);\n }\n\n configs.set(appPath, config);\n }\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !actionOptions.color,\n ...(actionOptions.debug\n ? debugLoggingConfig\n : actionOptions.verbose\n ? verboseLoggingConfig\n : actionOptions.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs.get(appPath) as CloudpackConfig;\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config);\n // Dispose the telemetry client when the app is closing\n this._autoDisposableList.add({\n dispose: () => telemetryClient.shutdown(),\n });\n\n // Merge in any additional features from the command line and remote feature flags.\n config.features = await getMergedFeatureFlags({ config, actionOptions, appPath, appName: name });\n\n const featureErrors = checkFeatures({ configFeatures: config.features });\n\n // If there are any invalid features, warn the user and continue.\n if (featureErrors.length) {\n featureErrors.forEach((warning) => console.warn(warning));\n }\n\n const enabledFeatureNames = Object.entries(config.features)\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n telemetryClient.setSharedSpanAttribute('features', enabledFeatureNames);\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n });\n }\n\n return singleAppPath ? contexts[0] : contexts;\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString = programOptions.disableTelemetry\n ? undefined\n : config.telemetry?.connectionString || process.env.CLOUDPACK_TELEMETRY_CONNECTION_STRING;\n\n const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;\n if (!options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n connectionString,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n rootSpanName: 'CLI',\n });\n\n const isCI = isCIBuild();\n\n telemetryClient.setSharedSpanAttribute('verb', this._verb);\n telemetryClient.setSharedSpanAttribute('arguments', programOptions.argv.slice(3).join(' '));\n telemetryClient.setSharedSpanAttribute('environment', isCI ? 'ci' : isCodespaces() ? 'codespaces' : 'local');\n telemetryClient.setSharedSpanAttribute('appName', appName || '<unknown>');\n telemetryClient.setSharedSpanAttribute('mode', config.mode || 'library');\n\n if (process.env.CLOUDPACK_TELEMETRY_EXTERNAL_CORRELATION_ID) {\n telemetryClient.setSharedSpanAttribute(\n 'externalCorrelationId',\n process.env.CLOUDPACK_TELEMETRY_EXTERNAL_CORRELATION_ID,\n );\n }\n\n if (isCI) {\n const ciAttributes = {\n buildId: process.env.BUILD_BUILDID,\n definitionId: process.env.SYSTEM_DEFINITIONID,\n buildReason: process.env.BUILD_REASON,\n pullRequestId: process.env.SYSTEM_PULLREQUEST_PULLREQUESTID,\n };\n\n for (const [key, value] of Object.entries(ciAttributes)) {\n if (value) {\n telemetryClient.setSharedSpanAttribute(key, value);\n }\n }\n }\n\n // Register performance observers to track performance metrics as events of CLI span.\n registerPerformanceObservers(telemetryClient);\n\n return telemetryClient;\n }\n\n /**\n * This is the `exit` function passed to the command's execute function.\n * (It must be an arrow function to ensure the correct `this` context.)\n */\n private _exit = async (params: CommandExitParams) => {\n const { message, hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\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 (!process.env.JEST_WORKER_ID) {\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 // Let the execute function know that we are exiting.\n this._abortController.abort();\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n const exitWithError = exitCode !== 0;\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete(hasErrors ? red(message) : message, exitWithError);\n }\n\n process.exit(exitCode);\n };\n}\n"]}
|
|
1
|
+
{"version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BAA4B,CAAC,eAAe,CAAC,CAAC;QAE9C,OAAO,eAAe,CAAC;IACzB,CAAC;CAmCF","sourcesContent":["import { readConfig } 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 { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport { registerPerformanceObservers } from '../performance/registerPerformanceObservers.js';\nimport type {\n CommandAction,\n CommandExitParams,\n AppCommandContext,\n CommandInitializeOptions,\n} from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport { isCodespaces } from '../utilities/isCodespaces.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { mergeFeatures } from './mergeFeatures.js';\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\nexport class CommandExecutor<TOptions extends SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _abortController: AbortController;\n private _hasCalledExit = false;\n private _args: string[];\n private _getMessageOnInterrupt = () => `Interrupted by user`;\n\n constructor(params: {\n /** Command-specific arguments */\n args: string[];\n /** Command-specific and shared options. */\n options: TOptions;\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n }) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._reporter = new TaskReporter();\n this._abortController = new AbortController();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute() {\n try {\n // Setup cleanup and close things on completion.\n let sigintCount = 0;\n\n // Handle SIGINT (Ctrl+C) gracefully.\n process.on('SIGINT', () => {\n sigintCount++;\n if (sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n process.exit(1);\n }\n\n // We are trying to exit gracefully.\n void this._exit({ message: this._getMessageOnInterrupt() });\n });\n\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n await this._execute({\n args: this._args,\n options: this._options,\n cwd: this._programOptions.cwd,\n reporter: this._reporter,\n initialize: this._initialize.bind(this),\n abortSignal: this._abortController.signal,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n exit: this._exit,\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: error instanceof Error ? error.stack || error.message : String(error),\n });\n }\n }\n\n /**\n * This is the `initialize` function passed to the command's execute function.\n * This function uses `this` to references several class members, which is why\n * the `execute` method must use `.bind(this)`.\n * (An arrow function isn't possible here due to the overloaded method signature).\n */\n private async _initialize(\n initializeParams: CommandInitializeOptions & { appPath: string },\n ): Promise<AppCommandContext>;\n private async _initialize(\n initializeParams: CommandInitializeOptions & { appPaths: string[] },\n ): Promise<AppCommandContext[]>;\n private async _initialize(\n initializeParams: CommandInitializeOptions & {\n appPath?: string;\n appPaths?: string[];\n },\n ): Promise<AppCommandContext | AppCommandContext[]> {\n const { appPath: singleAppPath, configOptions } = initializeParams;\n let { appPaths } = initializeParams;\n\n if (singleAppPath && appPaths) {\n throw Error('appPath and appPaths cannot both be specified at the same time');\n }\n if (!singleAppPath && !appPaths) {\n throw Error('one of appPath or appPaths must be specified');\n }\n\n if (!appPaths || appPaths.length === 0) {\n appPaths = singleAppPath ? [singleAppPath] : [];\n }\n\n const contexts: AppCommandContext[] = [];\n\n const helpMessages = new Set<string>();\n\n const configs: Record<string, CloudpackConfig> = {};\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, configOptions);\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // this will never be reached, but TypeScript doesn't know that\n process.exit(1);\n }\n if (config.helpMessage) {\n helpMessages.add(config.helpMessage);\n }\n\n configs[appPath] = config;\n }\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\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);\n // Dispose the telemetry client when the app is closing\n this._autoDisposableList.add({\n dispose: () => telemetryClient.shutdown(),\n });\n\n // Merge in any additional features from the command line and remote feature flags.\n config.features = mergeFeatures({\n configFeatures: config.features,\n commandLineFeatures: this._options.features,\n });\n\n const featureErrors = checkFeatures({ configFeatures: config.features });\n\n // If there are any invalid features, warn the user and continue.\n if (featureErrors.length) {\n featureErrors.forEach((warning) => console.warn(warning));\n }\n\n const enabledFeatureNames = Object.entries(config.features)\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n telemetryClient.setSharedSpanAttribute('features', enabledFeatureNames);\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n });\n }\n\n return singleAppPath ? contexts[0] : contexts;\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString = programOptions.disableTelemetry\n ? undefined\n : config.telemetry?.connectionString || process.env.CLOUDPACK_TELEMETRY_CONNECTION_STRING;\n\n const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;\n if (!options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n connectionString,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n rootSpanName: 'CLI',\n });\n\n const isCI = isCIBuild();\n\n telemetryClient.setSharedSpanAttribute('verb', this._verb);\n telemetryClient.setSharedSpanAttribute('arguments', programOptions.argv.slice(3).join(' '));\n telemetryClient.setSharedSpanAttribute('environment', isCI ? 'ci' : isCodespaces() ? 'codespaces' : 'local');\n telemetryClient.setSharedSpanAttribute('appName', appName || '<unknown>');\n telemetryClient.setSharedSpanAttribute('mode', config.mode || 'library');\n\n if (process.env.CLOUDPACK_TELEMETRY_EXTERNAL_CORRELATION_ID) {\n telemetryClient.setSharedSpanAttribute(\n 'externalCorrelationId',\n process.env.CLOUDPACK_TELEMETRY_EXTERNAL_CORRELATION_ID,\n );\n }\n\n if (isCI) {\n const ciAttributes = {\n buildId: process.env.BUILD_BUILDID,\n definitionId: process.env.SYSTEM_DEFINITIONID,\n buildReason: process.env.BUILD_REASON,\n pullRequestId: process.env.SYSTEM_PULLREQUEST_PULLREQUESTID,\n };\n\n for (const [key, value] of Object.entries(ciAttributes)) {\n if (value) {\n telemetryClient.setSharedSpanAttribute(key, value);\n }\n }\n }\n\n // Register performance observers to track performance metrics as events of CLI span.\n registerPerformanceObservers(telemetryClient);\n\n return telemetryClient;\n }\n\n /**\n * This is the `exit` function passed to the command's execute function.\n * (It must be an arrow function to ensure the correct `this` context.)\n */\n private _exit = async (params: CommandExitParams) => {\n const { message, hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\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 (!process.env.JEST_WORKER_ID) {\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 // Let the execute function know that we are exiting.\n this._abortController.abort();\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n const exitWithError = exitCode !== 0;\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete(hasErrors ? red(message) : message, exitWithError);\n }\n\n process.exit(exitCode);\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFilteredPackages.d.ts","sourceRoot":"","sources":["../../src/utilities/getFilteredPackages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"getFilteredPackages.d.ts","sourceRoot":"","sources":["../../src/utilities/getFilteredPackages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,4BAA4B,CAAC;AAExF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,CA6BnG"}
|
|
@@ -5,7 +5,17 @@ import { bold, bulletedList, formatPackageName, plural } from '@ms-cloudpack/tas
|
|
|
5
5
|
*/
|
|
6
6
|
export function getFilteredPackages(resolveMap, match) {
|
|
7
7
|
// Find matching packages in the resolve map
|
|
8
|
-
const resolveMapEntries =
|
|
8
|
+
const resolveMapEntries = [];
|
|
9
|
+
for (const entry of Object.values(resolveMap)) {
|
|
10
|
+
if (checkMatch({ name: entry.name, version: entry.version, match })) {
|
|
11
|
+
resolveMapEntries.push(entry);
|
|
12
|
+
}
|
|
13
|
+
for (const scopedEntry of Object.values(entry.scopedVersions || {})) {
|
|
14
|
+
if (checkMatch({ name: scopedEntry.name, version: scopedEntry.version, match })) {
|
|
15
|
+
resolveMapEntries.push(scopedEntry);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
9
19
|
const matchArgsString = match
|
|
10
20
|
.map((m) => `"${bold(typeof m === 'object' ? `${m.name}@${m.version || '*'}` : m || '*')}"`)
|
|
11
21
|
.join(', ');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFilteredPackages.js","sourceRoot":"","sources":["../../src/utilities/getFilteredPackages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE5F;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAsB,EAAE,KAA6B;IACvF,4CAA4C;IAC5C,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"getFilteredPackages.js","sourceRoot":"","sources":["../../src/utilities/getFilteredPackages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE5F;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAsB,EAAE,KAA6B;IACvF,4CAA4C;IAC5C,MAAM,iBAAiB,GAAsB,EAAE,CAAC;IAEhD,KAAK,MAAM,KAAK,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IAAI,EAAE,CAAC,CAAC,CAC/F,CAAC;IACJ,CAAC;IAED,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import type { PackageSettingsMatch, ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport { checkMatch } from '@ms-cloudpack/config';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport { bold, bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';\n\n/**\n * Find packages in the resolve map that match the requested names and versions.\n */\nexport function getFilteredPackages(resolveMap: ResolveMap, match: PackageSettingsMatch[]): string[] {\n // Find matching packages in the resolve map\n const resolveMapEntries: ResolveMapEntry[] = [];\n\n for (const entry of Object.values(resolveMap)) {\n if (checkMatch({ name: entry.name, version: entry.version, match })) {\n resolveMapEntries.push(entry);\n }\n for (const scopedEntry of Object.values(entry.scopedVersions || {})) {\n if (checkMatch({ name: scopedEntry.name, version: scopedEntry.version, match })) {\n resolveMapEntries.push(scopedEntry);\n }\n }\n }\n\n const matchArgsString = match\n .map((m) => `\"${bold(typeof m === 'object' ? `${m.name}@${m.version || '*'}` : m || '*')}\"`)\n .join(', ');\n\n if (!resolveMapEntries.length) {\n console.error(`No packages found matching ${matchArgsString}`);\n } else {\n console.log(\n `\\nFound ${plural(resolveMapEntries.length, 'package')} matching ${matchArgsString}:\\n` +\n bulletedList(resolveMapEntries.map((entry) => `${formatPackageName(entry)}: ${entry.path}`)),\n );\n }\n\n return resolveMapEntries.map((entry) => entry.path);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.1",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"cloudpack": "./bin/cloudpack.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ms-cloudpack/api-server": "^0.
|
|
14
|
-
"@ms-cloudpack/app-server": "^0.16.
|
|
13
|
+
"@ms-cloudpack/api-server": "^0.54.1",
|
|
14
|
+
"@ms-cloudpack/app-server": "^0.16.5",
|
|
15
|
+
"@ms-cloudpack/bundler": "^0.23.2",
|
|
15
16
|
"@ms-cloudpack/common-types": "^0.21.0",
|
|
16
|
-
"@ms-cloudpack/config": "^0.
|
|
17
|
-
"@ms-cloudpack/feature-flags": "^0.1.1",
|
|
17
|
+
"@ms-cloudpack/config": "^0.31.1",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.7",
|
|
19
|
-
"@ms-cloudpack/overlay": "^0.17.
|
|
20
|
-
"@ms-cloudpack/package-utilities": "^10.2.
|
|
19
|
+
"@ms-cloudpack/overlay": "^0.17.77",
|
|
20
|
+
"@ms-cloudpack/package-utilities": "^10.2.1",
|
|
21
21
|
"@ms-cloudpack/path-string-parsing": "^1.2.4",
|
|
22
22
|
"@ms-cloudpack/path-utilities": "^2.7.46",
|
|
23
23
|
"@ms-cloudpack/remote-cache": "^0.8.13",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type CloudpackConfig, type Features } from '@ms-cloudpack/common-types';
|
|
2
|
-
import type { SharedOptions } from '../types/SharedOptions.js';
|
|
3
|
-
export declare function getMergedFeatureFlags(params: {
|
|
4
|
-
config: CloudpackConfig;
|
|
5
|
-
actionOptions: SharedOptions;
|
|
6
|
-
appPath: string;
|
|
7
|
-
appName: string | undefined;
|
|
8
|
-
}): Promise<Features>;
|
|
9
|
-
//# sourceMappingURL=getMergedFeatureFlags.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getMergedFeatureFlags.d.ts","sourceRoot":"","sources":["../../src/utilities/getMergedFeatureFlags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI/D,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAClD,MAAM,EAAE,eAAe,CAAC;IACxB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,GAAG,OAAO,CAAC,QAAQ,CAAC,CA+BpB"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { allFeatures } from '@ms-cloudpack/common-types';
|
|
2
|
-
import { downloadFeatureFlags, getFeatureFlags } from '@ms-cloudpack/feature-flags';
|
|
3
|
-
import { getRepositoryName } from '../utilities/getRepositoryName.js';
|
|
4
|
-
import { mergeFeatures } from './mergeFeatures.js';
|
|
5
|
-
export async function getMergedFeatureFlags(params) {
|
|
6
|
-
const { config, actionOptions, appPath, appName } = params;
|
|
7
|
-
const repositoryName = await getRepositoryName(appPath);
|
|
8
|
-
// Get the feature flags for the current application. (ie: cloudpack.@ms-cloudpack/onedrive-mock)
|
|
9
|
-
const remoteFeatureFlags = appName && repositoryName
|
|
10
|
-
? getFeatureFlags({
|
|
11
|
-
applicationName: `cloudpack.${appName}`,
|
|
12
|
-
repositoryName,
|
|
13
|
-
})
|
|
14
|
-
: {};
|
|
15
|
-
// remove invalid remove feature flags from remoteFeatureFlags
|
|
16
|
-
const validFeatures = new Set(Object.keys(allFeatures));
|
|
17
|
-
Object.keys(remoteFeatureFlags).forEach((key) => {
|
|
18
|
-
if (!validFeatures.has(key)) {
|
|
19
|
-
delete remoteFeatureFlags[key];
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
// Kick off an async download operation for feature flags.
|
|
23
|
-
// Downloaded feature flags will be used by the cloudpack in the next run.
|
|
24
|
-
void downloadFeatureFlags();
|
|
25
|
-
// Merge in any additional features from the command line.
|
|
26
|
-
return mergeFeatures({
|
|
27
|
-
remoteFeatureFlags,
|
|
28
|
-
configFeatures: config.features,
|
|
29
|
-
commandLineFeatures: actionOptions.features,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=getMergedFeatureFlags.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getMergedFeatureFlags.js","sourceRoot":"","sources":["../../src/utilities/getMergedFeatureFlags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuC,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAK3C;IACC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAC3D,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAExD,iGAAiG;IACjG,MAAM,kBAAkB,GACtB,OAAO,IAAI,cAAc;QACvB,CAAC,CAAC,eAAe,CAAC;YACd,eAAe,EAAE,aAAa,OAAO,EAAE;YACvC,cAAc;SACf,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;IAET,8DAA8D;IAC9D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAChE,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC9C,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,0DAA0D;IAC1D,0EAA0E;IAC1E,KAAK,oBAAoB,EAAE,CAAC;IAE5B,0DAA0D;IAC1D,OAAO,aAAa,CAAC;QACnB,kBAAkB;QAClB,cAAc,EAAE,MAAM,CAAC,QAAQ;QAC/B,mBAAmB,EAAE,aAAa,CAAC,QAAQ;KAC5C,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { allFeatures, type CloudpackConfig, type Features } from '@ms-cloudpack/common-types';\nimport { downloadFeatureFlags, getFeatureFlags } from '@ms-cloudpack/feature-flags';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { getRepositoryName } from '../utilities/getRepositoryName.js';\nimport { mergeFeatures } from './mergeFeatures.js';\n\nexport async function getMergedFeatureFlags(params: {\n config: CloudpackConfig;\n actionOptions: SharedOptions;\n appPath: string;\n appName: string | undefined;\n}): Promise<Features> {\n const { config, actionOptions, appPath, appName } = params;\n const repositoryName = await getRepositoryName(appPath);\n\n // Get the feature flags for the current application. (ie: cloudpack.@ms-cloudpack/onedrive-mock)\n const remoteFeatureFlags =\n appName && repositoryName\n ? getFeatureFlags({\n applicationName: `cloudpack.${appName}`,\n repositoryName,\n })\n : {};\n\n // remove invalid remove feature flags from remoteFeatureFlags\n const validFeatures = new Set<string>(Object.keys(allFeatures));\n Object.keys(remoteFeatureFlags).forEach((key) => {\n if (!validFeatures.has(key)) {\n delete remoteFeatureFlags[key];\n }\n });\n\n // Kick off an async download operation for feature flags.\n // Downloaded feature flags will be used by the cloudpack in the next run.\n void downloadFeatureFlags();\n\n // Merge in any additional features from the command line.\n return mergeFeatures({\n remoteFeatureFlags,\n configFeatures: config.features,\n commandLineFeatures: actionOptions.features,\n });\n}\n"]}
|