@ms-cloudpack/cli 0.72.56 → 0.72.57
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.js +7 -10
- package/lib/commands/bundle/execute.js.map +1 -1
- package/lib/commands/init/evaluatePath.js +10 -13
- package/lib/commands/init/evaluatePath.js.map +1 -1
- package/lib/commands/start/execute.d.ts.map +1 -1
- package/lib/commands/start/execute.js +2 -5
- package/lib/commands/start/execute.js.map +1 -1
- package/lib/commands/start/openBrowser.d.ts +4 -7
- package/lib/commands/start/openBrowser.d.ts.map +1 -1
- package/lib/commands/start/openBrowser.js +6 -3
- package/lib/commands/start/openBrowser.js.map +1 -1
- package/lib/commands/sync/execute.d.ts.map +1 -1
- package/lib/commands/sync/execute.js +6 -10
- package/lib/commands/sync/execute.js.map +1 -1
- package/lib/types/AppPathDiscoveryMode.d.ts +2 -1
- package/lib/types/AppPathDiscoveryMode.d.ts.map +1 -1
- package/lib/types/AppPathDiscoveryMode.js.map +1 -1
- package/lib/utilities/CommandExecutor.d.ts.map +1 -1
- package/lib/utilities/CommandExecutor.js +18 -6
- package/lib/utilities/CommandExecutor.js.map +1 -1
- package/lib/utilities/{discoverAppPaths.d.ts → discoverLocalAppPaths.d.ts} +4 -4
- package/lib/utilities/discoverLocalAppPaths.d.ts.map +1 -0
- package/lib/utilities/{discoverAppPaths.js → discoverLocalAppPaths.js} +3 -3
- package/lib/utilities/discoverLocalAppPaths.js.map +1 -0
- package/lib/utilities/discoverRemoteAppPaths.d.ts +17 -0
- package/lib/utilities/discoverRemoteAppPaths.d.ts.map +1 -0
- package/lib/utilities/discoverRemoteAppPaths.js +53 -0
- package/lib/utilities/discoverRemoteAppPaths.js.map +1 -0
- package/lib/utilities/getDefaultLogin.d.ts +3 -0
- package/lib/utilities/getDefaultLogin.d.ts.map +1 -0
- package/lib/utilities/getDefaultLogin.js +5 -0
- package/lib/utilities/getDefaultLogin.js.map +1 -0
- package/lib/utilities/reusedOptions.d.ts +1 -0
- package/lib/utilities/reusedOptions.d.ts.map +1 -1
- package/lib/utilities/reusedOptions.js +1 -1
- package/lib/utilities/reusedOptions.js.map +1 -1
- package/lib/utilities/selectItemFromPaginatedResults.d.ts +20 -0
- package/lib/utilities/selectItemFromPaginatedResults.d.ts.map +1 -0
- package/lib/utilities/selectItemFromPaginatedResults.js +60 -0
- package/lib/utilities/selectItemFromPaginatedResults.js.map +1 -0
- package/package.json +5 -5
- package/lib/utilities/discoverAppPaths.d.ts.map +0 -1
- package/lib/utilities/discoverAppPaths.js.map +0 -1
|
@@ -28,16 +28,13 @@ export const execute = async (params) => {
|
|
|
28
28
|
const outputPath = options.outdir ? path.resolve(packagePath, options.outdir) : undefined;
|
|
29
29
|
definition = await ctx.packages.get(packagePath);
|
|
30
30
|
const { result } = await ensurePackageBundled({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
ctx,
|
|
40
|
-
});
|
|
31
|
+
name: definition.name,
|
|
32
|
+
version: definition.version,
|
|
33
|
+
outputPath,
|
|
34
|
+
disableSourceMaps: options.disableSourceMaps,
|
|
35
|
+
shouldForce: true,
|
|
36
|
+
isIncremental: false,
|
|
37
|
+
}, ctx);
|
|
41
38
|
console.log('Output:', result.outputPath, '\n');
|
|
42
39
|
summaryData.recordResult(packagePath, result);
|
|
43
40
|
}
|
|
@@ -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;AAEzF,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,O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AAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;IAE1G,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC;IAExC,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,MAAM;QACzB,OAAO,EAAE,iBAAiB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;KACjE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport type { PackageJson } from '@ms-cloudpack/common-types';\nimport { yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\nimport { InitSummaryData } from '../init/InitSummaryData.js';\nimport { formatInitSummary } from '../init/formatInitSummary.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\n\nexport const execute: CommandAction<BundleOptions> = async (params) => {\n const { appPath, options, reporter, setInterruptMessageHandler } = params;\n\n console.log('Bundle mode:', yellow(options.mode));\n\n const ctx = await createPartialApiContext(params);\n\n const pathsToBundle = options.match ? getFilteredPackages(ctx.session.resolveMap, options.match) : [appPath];\n\n if (!pathsToBundle.length) {\n return {\n message: 'No matching packages found to bundle.',\n hasErrors: true,\n };\n }\n\n // Show completed bundle tasks so the user knows what's happening.\n reporter.setOptions({ ...reporter.getOptions(), showCompleted: true });\n\n // Use InitSummaryData for pretty formatting of errors and warnings at the end.\n const summaryData = new InitSummaryData({ appPath });\n\n for (const packagePath of pathsToBundle) {\n let definition: PackageJson | undefined;\n try {\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 definition = await ctx.packages.get(packagePath);\n\n const { result } = await ensurePackageBundled(\n {\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 summaryData.recordResult(packagePath, result);\n } catch (err) {\n summaryData.recordException({\n packagePath,\n error: err,\n source: 'bundle',\n context: 'bundling package',\n name: definition?.name,\n version: definition?.version,\n });\n }\n }\n\n setInterruptMessageHandler(() => formatInitSummary({ verb: 'bundle', summary: summaryData.summarize() }));\n\n const summary = summaryData.summarize();\n\n return {\n hasErrors: summary.failed,\n message: formatInitSummary({ verb: 'bundle', summary: summary }),\n };\n};\n"]}
|
|
@@ -18,19 +18,16 @@ export async function evaluatePath(options) {
|
|
|
18
18
|
console.debug(`Evaluating ${packagePath} with context ${JSON.stringify(importerContext)}`);
|
|
19
19
|
// Bundle the package and find the imports it depends on.
|
|
20
20
|
const { result } = await ensurePackageBundled({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
ctx,
|
|
33
|
-
});
|
|
21
|
+
name,
|
|
22
|
+
version,
|
|
23
|
+
isIncremental: false,
|
|
24
|
+
shouldGetBundleInfo: true,
|
|
25
|
+
shouldForce,
|
|
26
|
+
shouldRerun: shouldForce,
|
|
27
|
+
useHashAsId: isMultiApp,
|
|
28
|
+
priority,
|
|
29
|
+
disableCache: !initOptions.cache,
|
|
30
|
+
}, ctx);
|
|
34
31
|
// Record the results for the summary.
|
|
35
32
|
summaryData.recordResult(packagePath, result);
|
|
36
33
|
// If there were errors or no imports, return early.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluatePath.js","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC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yF;YACzF,MAAM,EAAE,cAAc,IAAI,qBAAqB,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,4BAA4B;SAC/G,CAAC,CAAC;QAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,eAAe;QACf,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import type { EnsurePackageBundledContext } from '@ms-cloudpack/api-server';\nimport type { CloudpackConfig, PackageImporterContext, ResolveMap } from '@ms-cloudpack/common-types';\nimport type { Span } from '@ms-cloudpack/telemetry';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\n\nimport { ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport { evaluateDynamicImports } from './evaluateDynamicImports.js';\n\n/**\n * A helper which given the packagePath, tries to evaluate the path by bundling things, finding imports,\n * and cross checking the imports with explicit exports. If any exports are missing, they are documented\n * in the generated config.\n */\nexport async function evaluatePath(options: {\n /** Path to evaluate. */\n packagePath: string;\n /** Info about how the parent package */\n importerContext: PackageImporterContext | undefined;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n appPath: string;\n resolveMap: ResolveMap;\n span: Span;\n initOptions: InitOptions;\n summaryData: InitSummaryData;\n ctx: EnsurePackageBundledContext;\n /** Whether init is running in a multi-app scenario. */\n isMultiApp: boolean;\n shouldForce: boolean;\n /** The priority of the package being evaluated. To be used in the task runner. */\n priority: number;\n}): Promise<{\n /** Map from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate?: Map<string, PackageImporterContext | undefined>;\n /** Package paths for which new exports were added, so the package should be re-processed. */\n pathsToRefresh?: Set<string>;\n /** Whether a fatal error was encountered. */\n shouldExit?: boolean;\n}> {\n const {\n packagePath,\n config,\n initOptions,\n span,\n resolveMap,\n summaryData,\n ctx,\n importerContext,\n shouldForce,\n isMultiApp,\n priority,\n appPath,\n } = options;\n const { packages } = ctx;\n const { features } = config;\n\n // This line is the reason we have to track the importerContext for packages to evaluate:\n // otherwise if a non-semver package is read here, we'd lose the modifications from the initial\n // time the package was read (and getNonSemverTransform was called) when building the resolve map.\n const definition = await packages.get(packagePath, { refresh: true, importerContext });\n const { name, version } = definition;\n\n console.debug(`Evaluating ${packagePath} with context ${JSON.stringify(importerContext)}`);\n\n // Bundle the package and find the imports it depends on.\n const { result } = await ensurePackageBundled(\n {\n name,\n version,\n isIncremental: false,\n shouldGetBundleInfo: true,\n shouldForce,\n shouldRerun: shouldForce,\n useHashAsId: isMultiApp,\n priority,\n disableCache: !initOptions.cache,\n },\n ctx,\n );\n\n // Record the results for the summary.\n summaryData.recordResult(packagePath, result);\n\n // If there were errors or no imports, return early.\n const { info } = result;\n if (result.errors?.length || !info) {\n return {};\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const {\n exportsChanges,\n includedDependenciesChanges,\n errors: evalErrors,\n pathsToEvaluate,\n pathsToRefresh,\n } = await evaluateImportsForOverrides({\n definition,\n packagePath,\n packages,\n info,\n config,\n resolveMap,\n importerContext,\n appPath,\n });\n\n if (evalErrors.length) {\n summaryData.addErrors(packagePath, evalErrors);\n }\n summaryData.recordGeneratedChanges(exportsChanges);\n summaryData.recordGeneratedChanges(includedDependenciesChanges);\n\n let dynamicImportsChanges: undefined | GeneratedPackageChanges[] = undefined;\n if (features?.evaluateDynamicImports) {\n const evaluatedDynamicImports = await evaluateDynamicImports({\n definition,\n packagePath,\n info,\n config,\n packages,\n importerContext,\n });\n\n const { pathsToEvaluate: dynamicImportPathsToEvaluate, pathsToRefresh: dynamicImportPathsToRefresh } =\n evaluatedDynamicImports;\n dynamicImportsChanges = evaluatedDynamicImports.dynamicImportsChanges;\n\n summaryData.recordGeneratedChanges(dynamicImportsChanges);\n\n for (const [evalPath, evalContext] of dynamicImportPathsToEvaluate.entries()) {\n pathsToEvaluate.set(evalPath, evalContext);\n }\n dynamicImportPathsToRefresh.forEach((path) => pathsToRefresh.add(path));\n }\n\n // Uncomment this when #1694 init does not cache packages correctly after editing config is fixed\n // and the heap does not reach the limit as almost every package is enqueued.\n // importPathsToEvaluate?.forEach((path) => pathsToEvaluate.set(path, importerContext));\n // importPathsToRefresh?.forEach((path) => pathsToRefresh.add(path));\n\n if (initOptions.check && (exportsChanges.length || evalErrors.length || dynamicImportsChanges?.length)) {\n span.addEvent('INIT_CHECK_FAILED', {\n // Don't log the specific errors to telemetry, as they may contain sensitive information.\n reason: exportsChanges || dynamicImportsChanges ? 'Config needs to be updated.' : 'Errors found with imports.',\n });\n\n return { shouldExit: true };\n }\n\n return {\n pathsToEvaluate,\n pathsToRefresh,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,CAwH/C,CAAC"}
|
|
@@ -50,10 +50,7 @@ export const execute = async (params) => {
|
|
|
50
50
|
}
|
|
51
51
|
const { apiServer } = apiServerResult;
|
|
52
52
|
// Kick off bundling app package as soon as api server is ready.
|
|
53
|
-
void ensurePackageBundled({
|
|
54
|
-
input: { name: definition.name, version: definition.version },
|
|
55
|
-
ctx: apiContext,
|
|
56
|
-
});
|
|
53
|
+
void ensurePackageBundled({ name: definition.name, version: definition.version }, apiContext);
|
|
57
54
|
// Then start bundle and app servers for hosting the app.
|
|
58
55
|
const { startServers } = await import('@ms-cloudpack/app-server');
|
|
59
56
|
const servers = await startServers({
|
|
@@ -103,7 +100,7 @@ export const execute = async (params) => {
|
|
|
103
100
|
// Use the default path from the config with the first domain.
|
|
104
101
|
urlToOpen = defaultUrl;
|
|
105
102
|
}
|
|
106
|
-
void openBrowser({
|
|
103
|
+
void openBrowser({ url: urlToOpen }, apiContext).catch((err) => {
|
|
107
104
|
console.warn('Error opening browser:', err?.stack || err);
|
|
108
105
|
console.warn('Please open the browser manually to:', defaultUrl);
|
|
109
106
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAsC,MAAM,0BAA0B,CAAC;AACtH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC1E,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;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,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,eAAe,EAAE,MAAM,oCAAoC,CAAC;AA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E,OAAO,EAAE,CAAC;IACtC,CAAC;AACH,CAAC;AAED,wBAAwB","sourcesContent":["import { createApiContext, ensurePackageBundled, type CloudpackServer, type Context } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { isExternalPackage, resolve } from '@ms-cloudpack/path-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 type { CommandAction } from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.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 { getCliStartTime } from '../../utilities/getCliStartTime.js';\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { appPath, config, options, autoDispose } = params;\n\n console.log('App path:', yellow(appPath));\n console.log('Bundle mode:', yellow(options.mode));\n\n await runPrerequisites(params);\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 shouldUseRemoteCache = config.features?.enableCloudHosted || config.features?.enableRemoteCacheDownloads;\n const apiContext = autoDispose(\n await createApiContext({\n ...params,\n remoteCacheClientLoginMethod: shouldUseRemoteCache ? options.login : undefined,\n overlayPath,\n }),\n );\n const { packages, session, telemetryClient } = 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 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 apiServerResult = await createApiServer(options, apiContext);\n if (apiServerResult.hasErrors) {\n return apiServerResult;\n }\n const { apiServer } = apiServerResult;\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 // Log the time elapsed from when the CLI started until the browser is ready to be opened.\n await telemetryClient.tracer.startActiveSpan(\n 'TIME_TO_OPEN_BROWSER',\n { startTime: getCliStartTime(), attributes: { open: options.open } },\n () => {\n // Open the browser.\n if (options.open === false) {\n console.log('Please open the browser manually to:', defaultUrl);\n } else {\n let urlToOpen: string;\n if (typeof options.open === 'string') {\n // If the string doesn't start with http or https, pick a protocol based on config.server.https\n if (!options.open.startsWith('http://') && !options.open.startsWith('https://')) {\n urlToOpen = `${config.server?.https ? 'https' : 'http'}://${options.open}`;\n } else {\n urlToOpen = options.open;\n }\n } else {\n // Use the default path from the config with the first domain.\n urlToOpen = defaultUrl;\n }\n\n void openBrowser({ options: { url: urlToOpen }, context: apiContext }).catch((err: unknown) => {\n console.warn('Error opening browser:', (err as Error | undefined)?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n }\n },\n );\n\n return null; // the command should keep running\n};\n\n/**\n * Create the API server, or return an error message if the server could not be created.\n */\nasync function createApiServer(\n options: StartOptions,\n apiContext: Context,\n): Promise<{ hasErrors: false; apiServer: CloudpackServer } | { hasErrors: true; message: 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 hasErrors: true,\n message:\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 const apiServer = await createCloudpackServer({ port: options.apiServerPort }, apiContext);\n return { hasErrors: false, apiServer };\n } catch (err) {\n let message: string;\n if ((err as { code: string }).code === 'EADDRNOTAVAIL' && server?.domain) {\n const primaryDomain = (Array.isArray(server.domain) ? server.domain : [server.domain])[0];\n message =\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 } else {\n message = `Error creating API server: ${(err as Error).stack || err}`;\n }\n return { hasErrors: true, message };\n }\n}\n\n// cspell:ignore Prereqs\n"]}
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAsC,MAAM,0BAA0B,CAAC;AACtH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,8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C,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1F,OAAO;gBACL,eAAe,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,mDAAmD;oBAC3F,QAAQ,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,0DAA0D;oBAC/F,oBAAoB,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,8BAA+B,GAAa,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;QACxE,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACtC,CAAC;AACH,CAAC;AAED,wBAAwB","sourcesContent":["import { createApiContext, ensurePackageBundled, type CloudpackServer, type Context } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { isExternalPackage, resolve } from '@ms-cloudpack/path-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 type { CommandAction } from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.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 { getCliStartTime } from '../../utilities/getCliStartTime.js';\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { appPath, config, options, autoDispose } = params;\n\n console.log('App path:', yellow(appPath));\n console.log('Bundle mode:', yellow(options.mode));\n\n await runPrerequisites(params);\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 shouldUseRemoteCache = config.features?.enableCloudHosted || config.features?.enableRemoteCacheDownloads;\n const apiContext = autoDispose(\n await createApiContext({\n ...params,\n remoteCacheClientLoginMethod: shouldUseRemoteCache ? options.login : undefined,\n overlayPath,\n }),\n );\n const { packages, session, telemetryClient } = 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 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 apiServerResult = await createApiServer(options, apiContext);\n if (apiServerResult.hasErrors) {\n return apiServerResult;\n }\n const { apiServer } = apiServerResult;\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({ name: definition.name, version: definition.version }, apiContext);\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 // Log the time elapsed from when the CLI started until the browser is ready to be opened.\n await telemetryClient.tracer.startActiveSpan(\n 'TIME_TO_OPEN_BROWSER',\n { startTime: getCliStartTime(), attributes: { open: options.open } },\n () => {\n // Open the browser.\n if (options.open === false) {\n console.log('Please open the browser manually to:', defaultUrl);\n } else {\n let urlToOpen: string;\n if (typeof options.open === 'string') {\n // If the string doesn't start with http or https, pick a protocol based on config.server.https\n if (!options.open.startsWith('http://') && !options.open.startsWith('https://')) {\n urlToOpen = `${config.server?.https ? 'https' : 'http'}://${options.open}`;\n } else {\n urlToOpen = options.open;\n }\n } else {\n // Use the default path from the config with the first domain.\n urlToOpen = defaultUrl;\n }\n\n void openBrowser({ url: urlToOpen }, apiContext).catch((err: unknown) => {\n console.warn('Error opening browser:', (err as Error | undefined)?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n }\n },\n );\n\n return null; // the command should keep running\n};\n\n/**\n * Create the API server, or return an error message if the server could not be created.\n */\nasync function createApiServer(\n options: StartOptions,\n apiContext: Context,\n): Promise<{ hasErrors: false; apiServer: CloudpackServer } | { hasErrors: true; message: 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 hasErrors: true,\n message:\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 const apiServer = await createCloudpackServer({ port: options.apiServerPort }, apiContext);\n return { hasErrors: false, apiServer };\n } catch (err) {\n let message: string;\n if ((err as { code: string }).code === 'EADDRNOTAVAIL' && server?.domain) {\n const primaryDomain = (Array.isArray(server.domain) ? server.domain : [server.domain])[0];\n message =\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 } else {\n message = `Error creating API server: ${(err as Error).stack || err}`;\n }\n return { hasErrors: true, message };\n }\n}\n\n// cspell:ignore Prereqs\n"]}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PartialContext } from '@ms-cloudpack/api-server';
|
|
2
2
|
/** Open the browser. */
|
|
3
|
-
export declare function openBrowser(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
context: Pick<Context, 'session' | 'telemetryClient'>;
|
|
8
|
-
}): Promise<void>;
|
|
3
|
+
export declare function openBrowser(options: {
|
|
4
|
+
url: string;
|
|
5
|
+
}, context: PartialContext<'telemetryClient', 'urls'>): Promise<void>;
|
|
9
6
|
/** Set an override for the browser opening behavior. `null` disables opening. */
|
|
10
7
|
export declare function overrideOpenBrowser(fn: typeof openBrowser | null): void;
|
|
11
8
|
/** Get the most recently opened URL (for tests) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openBrowser.d.ts","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"openBrowser.d.ts","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM/D,wBAAwB;AACxB,wBAAsB,WAAW,CAC/B,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC;CACb,EAED,OAAO,EAAE,cAAc,CAAC,iBAAiB,EAAE,MAAM,CAAC,GACjD,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,OAAO,WAAW,GAAG,IAAI,GAAG,IAAI,CAEvE;AAED,mDAAmD;AACnD,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD;AAED,qDAAqD;AACrD,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
|
|
@@ -2,11 +2,14 @@ import open from 'open';
|
|
|
2
2
|
let lastOpenedUrl;
|
|
3
3
|
let altOpenBrowser;
|
|
4
4
|
/** Open the browser. */
|
|
5
|
-
export async function openBrowser(
|
|
6
|
-
|
|
5
|
+
export async function openBrowser(options,
|
|
6
|
+
// urls aren't used directly in the function, but are used in a test via overrideOpenBrowser
|
|
7
|
+
context) {
|
|
8
|
+
const { url } = options;
|
|
9
|
+
const { telemetryClient } = context;
|
|
7
10
|
lastOpenedUrl = url;
|
|
8
11
|
if (altOpenBrowser) {
|
|
9
|
-
await altOpenBrowser(
|
|
12
|
+
await altOpenBrowser(options, context);
|
|
10
13
|
}
|
|
11
14
|
else if (altOpenBrowser !== null) {
|
|
12
15
|
// This span measures the time required to create a process for the browser, but it does not imply that the browser is fully open.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openBrowser.js","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,IAAI,aAAiC,CAAC;AACtC,IAAI,cAAqD,CAAC;AAE1D,wBAAwB;AACxB,MAAM,CAAC,KAAK,UAAU,WAAW,
|
|
1
|
+
{"version":3,"file":"openBrowser.js","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,IAAI,aAAiC,CAAC;AACtC,IAAI,cAAqD,CAAC;AAE1D,wBAAwB;AACxB,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAEC;AACD,4FAA4F;AAC5F,OAAkD;IAElD,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEpC,aAAa,GAAG,GAAG,CAAC;IACpB,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;SAAM,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QACnC,kIAAkI;QAClI,MAAM,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACxG,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,mBAAmB,CAAC,EAA6B;IAC/D,cAAc,GAAG,EAAE,CAAC;AACtB,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,kBAAkB;IAChC,aAAa,GAAG,SAAS,CAAC;AAC5B,CAAC","sourcesContent":["import type { PartialContext } from '@ms-cloudpack/api-server';\nimport open from 'open';\n\nlet lastOpenedUrl: string | undefined;\nlet altOpenBrowser: typeof openBrowser | null | undefined;\n\n/** Open the browser. */\nexport async function openBrowser(\n options: {\n url: string;\n },\n // urls aren't used directly in the function, but are used in a test via overrideOpenBrowser\n context: PartialContext<'telemetryClient', 'urls'>,\n): Promise<void> {\n const { url } = options;\n const { telemetryClient } = context;\n\n lastOpenedUrl = url;\n if (altOpenBrowser) {\n await altOpenBrowser(options, context);\n } else if (altOpenBrowser !== null) {\n // This span measures the time required to create a process for the browser, but it does not imply that the browser is fully open.\n await telemetryClient.tracer.startActiveSpan('OPEN_BROWSER', () => open(url, { newInstance: false }));\n }\n}\n\n/** Set an override for the browser opening behavior. `null` disables opening. */\nexport function overrideOpenBrowser(fn: typeof openBrowser | null): void {\n altOpenBrowser = fn;\n}\n\n/** Get the most recently opened URL (for tests) */\nexport function getLastOpenedUrl(): string | undefined {\n return lastOpenedUrl;\n}\n\n/** Reset the most recently opened URL (for tests) */\nexport function resetLastOpenedUrl(): void {\n lastOpenedUrl = undefined;\n}\n"]}
|
|
@@ -1 +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,CA2E9C,CAAC"}
|
|
@@ -25,21 +25,17 @@ export const execute = async (params) => {
|
|
|
25
25
|
message: 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
const ctx = await createPartialApiContext({
|
|
29
|
+
...params,
|
|
30
|
+
remoteCacheClientLoginMethod: login,
|
|
31
|
+
});
|
|
28
32
|
let syncResult;
|
|
29
33
|
if (upload) {
|
|
30
34
|
await runPrerequisites(params);
|
|
31
|
-
|
|
32
|
-
...params,
|
|
33
|
-
remoteCacheClientLoginMethod: login,
|
|
34
|
-
});
|
|
35
|
-
syncResult = await syncUpload({ input: undefined, ctx });
|
|
35
|
+
syncResult = await syncUpload({ login }, ctx);
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
|
-
|
|
39
|
-
...params,
|
|
40
|
-
remoteCacheClientLoginMethod: login,
|
|
41
|
-
});
|
|
42
|
-
syncResult = await syncDownload({ input: undefined, ctx });
|
|
38
|
+
syncResult = await syncDownload(undefined, ctx);
|
|
43
39
|
}
|
|
44
40
|
return {
|
|
45
41
|
message: `Sync completed with ${syncResult.success} successes, ${syncResult.failed} failures, ` +
|
|
@@ -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,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAGvE,SAAS,cAAc,CAAC,KAAc,EAAE,IAAY;IAClD,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAC1E,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAElC,IAAI,CAAC;QACH,gGAAgG;QAChG,OAAO,MAAM,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAA8B,EAAE;YAC7G,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;gBAClC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;YACzC,CAAC;YAED,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC;gBAC7C,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;gBACxC,OAAO,EAAE,OAAO,EAAE,4EAA4E,EAAE,C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C,CAAC,YAAY,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,CAAC,EACrF,CAAC;gBACD,OAAO;oBACL,OAAO,EAAE,GAAG,CAAC,oEAAoE,CAAC;oBAClF,QAAQ,EAAE,2BAA2B;iBACtC,CAAC;YACJ,CAAC;YAED,IAAI,cAAc,CAAC,KAAK,EAAE,oBAAoB,CAAC,EAAE,CAAC;gBAChD,OAAO;oBACL,OAAO,EAAE,GAAG,CAAC,+DAA+D,CAAC;oBAC7E,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;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, config, telemetryClient } = params;\n const { login, upload } = options;\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 const ctx = await createPartialApiContext({\n ...params,\n remoteCacheClientLoginMethod: login,\n });\n\n let syncResult: SyncResult;\n if (upload) {\n await runPrerequisites(params);\n\n syncResult = await syncUpload({ login }, ctx);\n } else {\n syncResult = await syncDownload(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,7 +8,8 @@
|
|
|
8
8
|
* - If `discover: 'single'`:
|
|
9
9
|
* - If a single app is found, return that.
|
|
10
10
|
* - If multiple apps are found, prompt the user to choose one.
|
|
11
|
+
* - If `discover: 'remote'`, the app will be discovered from the cloud.
|
|
11
12
|
* - If nothing is found, use `cwd` (unless `--app` is set and the name doesn't match).
|
|
12
13
|
*/
|
|
13
|
-
export type AppPathDiscoveryMode = 'single' | 'multi';
|
|
14
|
+
export type AppPathDiscoveryMode = 'single' | 'multi' | 'remote';
|
|
14
15
|
//# sourceMappingURL=AppPathDiscoveryMode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppPathDiscoveryMode.d.ts","sourceRoot":"","sources":["../../src/types/AppPathDiscoveryMode.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"AppPathDiscoveryMode.d.ts","sourceRoot":"","sources":["../../src/types/AppPathDiscoveryMode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC"}
|
|
@@ -1 +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
|
+
{"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 `discover: 'remote'`, the app will be discovered from the cloud.\n * - If nothing is found, use `cwd` (unless `--app` is set and the name doesn't match).\n */\nexport type AppPathDiscoveryMode = 'single' | 'multi' | 'remote';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAqB,MAAM,2BAA2B,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAK/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAqB,MAAM,2BAA2B,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAK/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAK7E,MAAM,MAAM,0BAA0B,GAAG,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAEpF,MAAM,WAAW,qBAAqB,CAAC,QAAQ,SAAS,0BAA0B,GAAG,0BAA0B;IAC7G,iCAAiC;IACjC,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,2CAA2C;IAC3C,OAAO,EAAE,QAAQ,CAAC;IAElB,uCAAuC;IACvC,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAEjC,0CAA0C;IAC1C,cAAc,EAAE,cAAc,CAAC;IAE/B,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAED;;GAEG;AAEH,qBAAa,eAAe,CAAC,QAAQ,SAAS,0BAA0B;IACtE,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,iBAAiB,CAAmC;IAC5D,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,YAAY,CAAC,CAAa;IAClC,OAAO,CAAC,sBAAsB,CAAC,CAAe;IAE9C,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAmC;WAE9C,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;gBASzD,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC;IAWnD,uBAAuB;IAEV,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAsErC;;;OAGG;YACW,mBAAmB;IAyGjC,qEAAqE;IACrE,OAAO,CAAC,+BAA+B;YAYzB,cAAc;IAyE5B,SAAS,CAAC,cAAc,QAAO,IAAI,CAgBjC;IAEF;;;OAGG;cACa,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;CAgCjE"}
|
|
@@ -7,7 +7,8 @@ import { AutoDisposableList } from './AutoDisposableList.js';
|
|
|
7
7
|
import { getVersion } from '@ms-cloudpack/package-utilities';
|
|
8
8
|
import { environmentInfo } from '@ms-cloudpack/environment';
|
|
9
9
|
import { getCliStartTime } from './getCliStartTime.js';
|
|
10
|
-
import {
|
|
10
|
+
import { discoverRemoteAppPaths } from './discoverRemoteAppPaths.js';
|
|
11
|
+
import { discoverLocalAppPaths } from './discoverLocalAppPaths.js';
|
|
11
12
|
import { TaskRunner } from '@ms-cloudpack/api-server';
|
|
12
13
|
/**
|
|
13
14
|
* This class manages orchestration and shared state while executing a command.
|
|
@@ -122,11 +123,22 @@ export class CommandExecutor {
|
|
|
122
123
|
let appPaths;
|
|
123
124
|
if (this._discoverAppPaths) {
|
|
124
125
|
// Search for cloudpack configs to determine the app path(s)
|
|
125
|
-
const appPathsResult =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
const appPathsResult = this._discoverAppPaths === 'remote'
|
|
127
|
+
? await discoverRemoteAppPaths({
|
|
128
|
+
options: {
|
|
129
|
+
login: this._options.login,
|
|
130
|
+
cachePath: this._options.cachePath,
|
|
131
|
+
desiredApp: this._options.app,
|
|
132
|
+
},
|
|
133
|
+
context: {
|
|
134
|
+
reporter: this._reporter,
|
|
135
|
+
},
|
|
136
|
+
})
|
|
137
|
+
: await discoverLocalAppPaths({
|
|
138
|
+
cwd: this._programOptions.cwd,
|
|
139
|
+
discover: this._discoverAppPaths,
|
|
140
|
+
desiredApp: this._options.app,
|
|
141
|
+
});
|
|
130
142
|
if (!Array.isArray(appPathsResult)) {
|
|
131
143
|
// This means there was an error (or the user cancelled) while getting app paths.
|
|
132
144
|
return appPathsResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,sBAAsB,CAAC;AAE1E,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;AAIxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yB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C;YAE3B,sCAAsC;YACtC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;YAEzC,8DAA8D;YAC9D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;gBACtB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;gBAC3C,QAAQ,EAAE,QAAQ,KAAK,CAAC;aACzB,CAAC,CAAC;QACL,CAAC;QAED,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3C,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;;AA3UD,yFAAyF;AAC1E,gCAAgB,GAAG,IAAI,GAAG,EAAwB,AAAlC,CAAmC","sourcesContent":["import { readConfig, type ReadConfigOptions } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { getCliStartTime } from './getCliStartTime.js';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { discoverAppPaths } from './discoverAppPaths.js';\nimport { TaskRunner } from '@ms-cloudpack/api-server';\n\nexport type BaseCommandExecutorOptions = SharedOptions & Pick<ReusedOptions, 'app'>;\n\nexport interface CommandExecutorParams<TOptions extends BaseCommandExecutorOptions = BaseCommandExecutorOptions> {\n /** Command-specific arguments */\n args: string[];\n\n /** Command-specific and shared options. */\n options: TOptions;\n\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n\n /**\n * By default, the command will run against `cwd` (usually `process.cwd()`).\n * If this option is set, attempt to discover app path(s) instead.\n * (`cwd` will still be preferred if it has a `cloudpack.config.json`.)\n * See {@link AppPathDiscoveryMode} for details.\n */\n discoverAppPaths?: AppPathDiscoveryMode;\n}\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\n// 'app' is an optional reused option\nexport class CommandExecutor<TOptions extends BaseCommandExecutorOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _onInterrupt?: () => void;\n private _getMessageOnInterrupt?: () => string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances = new Set<CommandExecutor<any>>();\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = new Set();\n }\n\n constructor(params: CommandExecutorParams<TOptions>) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._discoverAppPaths = params.discoverAppPaths;\n this._reporter = new TaskReporter();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute(): Promise<void> {\n CommandExecutor._activeInstances.add(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n if (!environmentInfo.isJest) {\n process.on('SIGINT', this._sigintHandler);\n }\n\n const contexts = await this._initializeContexts();\n\n if (!Array.isArray(contexts)) {\n await this._exit(contexts);\n return;\n }\n\n const spanName = `${this._verb.toUpperCase().replace(/ /g, '_')}_EXECUTE`;\n const results: CommandExitParams[] = [];\n\n for (const context of contexts) {\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await context.telemetryClient.tracer.startActiveSpan(spanName, async (span) => {\n this._onInterrupt = () => {\n span.setAttribute('isInterrupted', true);\n span.end();\n };\n\n return this._execute({\n ...context,\n span,\n isMultiApp: contexts.length > 1,\n args: this._args,\n options: this._options,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n });\n if (result?.isInterrupted) {\n return await this._exit(result);\n }\n if (result) {\n results.push(result);\n } else if ((result as unknown) !== null) {\n // If the command returned null, this means it should keep running (e.g. start).\n // We disallow returning undefined to avoid accidents.\n throw new Error('Command executor must return exit options or null');\n }\n this._onInterrupt = undefined;\n }\n\n if (results.length) {\n // If one or more apps returned a result, exit.\n await this._exit({\n message: results.map((r) => r.message).join('\\n'),\n hasErrors: results.some((r) => r.hasErrors),\n // If any app returned a non-zero exit code, use that.\n exitCode: results.find(({ exitCode }) => !!exitCode)?.exitCode,\n });\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: (error as Error).stack || (error as Error).message || String(error),\n });\n }\n }\n\n /**\n * Determine the app paths and initialize the context for each app.\n * @returns Context(s), or an exit options object if there was an error. (might also throw on error)\n */\n private async _initializeContexts(): Promise<AppCommandContext[] | CommandExitParams> {\n let appPaths: string[];\n\n if (this._discoverAppPaths) {\n // Search for cloudpack configs to determine the app path(s)\n const appPathsResult = await discoverAppPaths({\n cwd: this._programOptions.cwd,\n discover: this._discoverAppPaths,\n desiredApp: this._options.app,\n });\n if (!Array.isArray(appPathsResult)) {\n // This means there was an error (or the user cancelled) while getting app paths.\n return appPathsResult;\n }\n appPaths = appPathsResult;\n } else {\n // Just use the cwd\n appPaths = [this._programOptions.cwd];\n }\n\n const configOptions = this._getConfigOptionsFromCliOptions();\n\n // The task runner is shared between all apps so that task results can potentially be reused.\n const taskRunner = new TaskRunner();\n\n const 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, {\n ...configOptions,\n extraFeatures: this._options.features,\n });\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // eslint-disable-next-line no-restricted-properties -- 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 contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n taskRunner,\n });\n }\n\n return contexts;\n }\n\n /** Translate certain CLI options into options for `readConfig()`. */\n private _getConfigOptionsFromCliOptions(): ReadConfigOptions {\n // These options don't exist for all commands, but that's fine.\n const options = this._options as Partial<ReusedOptions & SharedOptions>;\n return {\n mode: options.mode,\n logBundleInfo: options.logBundleInfo,\n // Handle --bundler by passing it as a universal package override, which will be appended\n // to any user-provided packageSettings so that it takes precedence.\n extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,\n };\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString =\n programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\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 });\n\n void telemetryClient.tracer.startActiveSpan('CLI_ENTRY', { startTime: getCliStartTime() }, () => {\n // Retrieve the current telemetry context\n const activeContext = telemetryClient.context.active();\n\n /**\n * Sets the current context as the root context. This ensures that all spans created during this CLI execution\n * will be children of this root span, even though the root span is closed immediately. This helps group all\n * spans under a single root span for better traceability.\n *\n * Typically, the root span should remain open until the CLI exits. However, in environments like Codespaces,\n * the CLI might run indefinitely, which could leave the root span open indefinitely.\n *\n * To prevent this, the root span is closed immediately after it is set as the root context.\n */\n telemetryClient.setRootContext(activeContext);\n });\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode,\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = (): void => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n this._onInterrupt?.();\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams): Promise<never> {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt?.() || 'Interrupted by user' : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete({\n summary: hasErrors ? red(message) : message,\n showHelp: exitCode !== 0,\n });\n }\n\n CommandExecutor._activeInstances.delete(this);\n process.off('SIGINT', this._sigintHandler);\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,sBAAsB,CAAC;AAE1E,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;AAIxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AA6BtD;;GAEG;AACH,qCAAqC;AACrC,MAAM,OAAO,eAAe;IAgBnB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAyB;QACnD,4FAA4F;QAC5F,KAAK,MAAM,QAAQ,IAAI,eAAe,CAAC,gBAAgB,EAAE,CAAC;YACxD,MAAM,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,cAAc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BAC3C,QAAQ,EAAE,QAAQ,KAAK,CAAC;aACzB,CAAC,CAAC;QACL,CAAC;QAED,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3C,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;;AAvVD,yFAAyF;AAC1E,gCAAgB,GAAG,IAAI,GAAG,EAAwB,AAAlC,CAAmC","sourcesContent":["import { readConfig, type ReadConfigOptions } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { getCliStartTime } from './getCliStartTime.js';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { discoverRemoteAppPaths } from './discoverRemoteAppPaths.js';\nimport { discoverLocalAppPaths } from './discoverLocalAppPaths.js';\nimport { TaskRunner } from '@ms-cloudpack/api-server';\n\nexport type BaseCommandExecutorOptions = SharedOptions & Pick<ReusedOptions, 'app'>;\n\nexport interface CommandExecutorParams<TOptions extends BaseCommandExecutorOptions = BaseCommandExecutorOptions> {\n /** Command-specific arguments */\n args: string[];\n\n /** Command-specific and shared options. */\n options: TOptions;\n\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n\n /**\n * By default, the command will run against `cwd` (usually `process.cwd()`).\n * If this option is set, attempt to discover app path(s) instead.\n * (`cwd` will still be preferred if it has a `cloudpack.config.json`.)\n * See {@link AppPathDiscoveryMode} for details.\n */\n discoverAppPaths?: AppPathDiscoveryMode;\n}\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\n// 'app' is an optional reused option\nexport class CommandExecutor<TOptions extends BaseCommandExecutorOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _onInterrupt?: () => void;\n private _getMessageOnInterrupt?: () => string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances = new Set<CommandExecutor<any>>();\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = new Set();\n }\n\n constructor(params: CommandExecutorParams<TOptions>) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._discoverAppPaths = params.discoverAppPaths;\n this._reporter = new TaskReporter();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute(): Promise<void> {\n CommandExecutor._activeInstances.add(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n if (!environmentInfo.isJest) {\n process.on('SIGINT', this._sigintHandler);\n }\n\n const contexts = await this._initializeContexts();\n\n if (!Array.isArray(contexts)) {\n await this._exit(contexts);\n return;\n }\n\n const spanName = `${this._verb.toUpperCase().replace(/ /g, '_')}_EXECUTE`;\n const results: CommandExitParams[] = [];\n\n for (const context of contexts) {\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await context.telemetryClient.tracer.startActiveSpan(spanName, async (span) => {\n this._onInterrupt = () => {\n span.setAttribute('isInterrupted', true);\n span.end();\n };\n\n return this._execute({\n ...context,\n span,\n isMultiApp: contexts.length > 1,\n args: this._args,\n options: this._options,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n });\n if (result?.isInterrupted) {\n return await this._exit(result);\n }\n if (result) {\n results.push(result);\n } else if ((result as unknown) !== null) {\n // If the command returned null, this means it should keep running (e.g. start).\n // We disallow returning undefined to avoid accidents.\n throw new Error('Command executor must return exit options or null');\n }\n this._onInterrupt = undefined;\n }\n\n if (results.length) {\n // If one or more apps returned a result, exit.\n await this._exit({\n message: results.map((r) => r.message).join('\\n'),\n hasErrors: results.some((r) => r.hasErrors),\n // If any app returned a non-zero exit code, use that.\n exitCode: results.find(({ exitCode }) => !!exitCode)?.exitCode,\n });\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: (error as Error).stack || (error as Error).message || String(error),\n });\n }\n }\n\n /**\n * Determine the app paths and initialize the context for each app.\n * @returns Context(s), or an exit options object if there was an error. (might also throw on error)\n */\n private async _initializeContexts(): Promise<AppCommandContext[] | CommandExitParams> {\n let appPaths: string[];\n\n if (this._discoverAppPaths) {\n // Search for cloudpack configs to determine the app path(s)\n const appPathsResult =\n this._discoverAppPaths === 'remote'\n ? await discoverRemoteAppPaths({\n options: {\n login: (this._options as unknown as Pick<ReusedOptions, 'login'>).login,\n cachePath: this._options.cachePath,\n desiredApp: this._options.app,\n },\n context: {\n reporter: this._reporter,\n },\n })\n : await discoverLocalAppPaths({\n cwd: this._programOptions.cwd,\n discover: this._discoverAppPaths,\n desiredApp: this._options.app,\n });\n if (!Array.isArray(appPathsResult)) {\n // This means there was an error (or the user cancelled) while getting app paths.\n return appPathsResult;\n }\n appPaths = appPathsResult;\n } else {\n // Just use the cwd\n appPaths = [this._programOptions.cwd];\n }\n\n const configOptions = this._getConfigOptionsFromCliOptions();\n\n // The task runner is shared between all apps so that task results can potentially be reused.\n const taskRunner = new TaskRunner();\n\n const 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, {\n ...configOptions,\n extraFeatures: this._options.features,\n });\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // eslint-disable-next-line no-restricted-properties -- 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 contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n taskRunner,\n });\n }\n\n return contexts;\n }\n\n /** Translate certain CLI options into options for `readConfig()`. */\n private _getConfigOptionsFromCliOptions(): ReadConfigOptions {\n // These options don't exist for all commands, but that's fine.\n const options = this._options as Partial<ReusedOptions & SharedOptions>;\n return {\n mode: options.mode,\n logBundleInfo: options.logBundleInfo,\n // Handle --bundler by passing it as a universal package override, which will be appended\n // to any user-provided packageSettings so that it takes precedence.\n extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,\n };\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString =\n programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\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 });\n\n void telemetryClient.tracer.startActiveSpan('CLI_ENTRY', { startTime: getCliStartTime() }, () => {\n // Retrieve the current telemetry context\n const activeContext = telemetryClient.context.active();\n\n /**\n * Sets the current context as the root context. This ensures that all spans created during this CLI execution\n * will be children of this root span, even though the root span is closed immediately. This helps group all\n * spans under a single root span for better traceability.\n *\n * Typically, the root span should remain open until the CLI exits. However, in environments like Codespaces,\n * the CLI might run indefinitely, which could leave the root span open indefinitely.\n *\n * To prevent this, the root span is closed immediately after it is set as the root context.\n */\n telemetryClient.setRootContext(activeContext);\n });\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode,\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = (): void => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n this._onInterrupt?.();\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams): Promise<never> {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt?.() || 'Interrupted by user' : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete({\n summary: hasErrors ? red(message) : message,\n showHelp: exitCode !== 0,\n });\n }\n\n CommandExecutor._activeInstances.delete(this);\n process.off('SIGINT', this._sigintHandler);\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CommandExitParams } from '../types/CommandAction.js';
|
|
2
1
|
import type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';
|
|
2
|
+
import type { CommandExitParams } from '../types/CommandAction.js';
|
|
3
3
|
export type _AppPromptQuestionName = 'app';
|
|
4
4
|
/**
|
|
5
5
|
* Gets the appPath from which Cloudpack will run. If the CWD is a Cloudpack-enabled app,
|
|
@@ -9,14 +9,14 @@ export type _AppPromptQuestionName = 'app';
|
|
|
9
9
|
* @returns App path(s) (just one unless `discover: 'multi'`), or an exit options object if
|
|
10
10
|
* there was an error.
|
|
11
11
|
*/
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function discoverLocalAppPaths(params: {
|
|
13
13
|
/** Working directory to start from. */
|
|
14
14
|
cwd: string;
|
|
15
15
|
/**
|
|
16
16
|
* How to determine the app path(s). (`--app` in the docs refers to `desiredApp` here.)
|
|
17
17
|
* @default 'single'
|
|
18
18
|
*/
|
|
19
|
-
discover?: AppPathDiscoveryMode
|
|
19
|
+
discover?: Exclude<AppPathDiscoveryMode, 'remote'>;
|
|
20
20
|
/**
|
|
21
21
|
* Desired app name or substring, from the `--app` option.
|
|
22
22
|
* - If there's an exact match, only that app will be returned.
|
|
@@ -25,4 +25,4 @@ export declare function discoverAppPaths(params: {
|
|
|
25
25
|
*/
|
|
26
26
|
desiredApp?: string;
|
|
27
27
|
}): Promise<string[] | CommandExitParams>;
|
|
28
|
-
//# sourceMappingURL=
|
|
28
|
+
//# sourceMappingURL=discoverLocalAppPaths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverLocalAppPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/discoverLocalAppPaths.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE3C;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAClD,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;IAEnD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,CAiFxC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { appConfigFileName } from '@ms-cloudpack/config';
|
|
1
2
|
import { PackageDefinitions } from '@ms-cloudpack/package-utilities';
|
|
2
3
|
import glob from 'fast-glob';
|
|
3
4
|
import fs from 'fs';
|
|
4
5
|
import path from 'path';
|
|
5
6
|
import prompts from 'prompts';
|
|
6
|
-
import { appConfigFileName } from '@ms-cloudpack/config';
|
|
7
7
|
/**
|
|
8
8
|
* Gets the appPath from which Cloudpack will run. If the CWD is a Cloudpack-enabled app,
|
|
9
9
|
* we'll use that; otherwise, we'll scan for Cloudpack-enabled app and present the user
|
|
@@ -12,7 +12,7 @@ import { appConfigFileName } from '@ms-cloudpack/config';
|
|
|
12
12
|
* @returns App path(s) (just one unless `discover: 'multi'`), or an exit options object if
|
|
13
13
|
* there was an error.
|
|
14
14
|
*/
|
|
15
|
-
export async function
|
|
15
|
+
export async function discoverLocalAppPaths(params) {
|
|
16
16
|
const { cwd, desiredApp, discover } = params;
|
|
17
17
|
const multiApp = discover === 'multi';
|
|
18
18
|
if (!desiredApp && fs.existsSync(path.join(cwd, appConfigFileName))) {
|
|
@@ -77,4 +77,4 @@ export async function discoverAppPaths(params) {
|
|
|
77
77
|
}
|
|
78
78
|
return [response.app];
|
|
79
79
|
}
|
|
80
|
-
//# sourceMappingURL=
|
|
80
|
+
//# sourceMappingURL=discoverLocalAppPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverLocalAppPaths.js","sourceRoot":"","sources":["../../src/utilities/discoverLocalAppPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAO9B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAiB3C;IACC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAC7C,MAAM,QAAQ,GAAG,QAAQ,KAAK,OAAO,CAAC;IAEtC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC;QACpE,mFAAmF;QACnF,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAED,6EAA6E;IAC7E,MAAM,iBAAiB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,iBAAiB,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CACnH,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAC7C,CAAC;IAEF,IAAI,CAAC,iBAAiB,CA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M,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC;QAC5E,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QAED,6EAA6E;QAC7E,IAAI,QAAQ,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxC,yEAAyE;YACzE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED,kEAAkE;IAClE,0DAA0D;IAC1D,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAyB;QACrD,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,kCAAkC;QAC3C,OAAO,EAAE,UAAU;KACpB,CAAC,CAAC;IAEH,wDAAwD;IACxD,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAClB,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO,CAAC,QAAQ,CAAC,GAAa,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import { appConfigFileName } from '@ms-cloudpack/config';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport glob from 'fast-glob';\nimport fs from 'fs';\nimport path from 'path';\nimport prompts from 'prompts';\nimport type { Choice } from 'prompts';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport type { CommandExitParams } from '../types/CommandAction.js';\n\nexport type _AppPromptQuestionName = 'app';\n\n/**\n * Gets the appPath from which Cloudpack will run. If the CWD is a Cloudpack-enabled app,\n * we'll use that; otherwise, we'll scan for Cloudpack-enabled app and present the user\n * with a menu. If no apps are found, Cloudpack will just try to run in the CWD anyway.\n *\n * @returns App path(s) (just one unless `discover: 'multi'`), or an exit options object if\n * there was an error.\n */\nexport async function discoverLocalAppPaths(params: {\n /** Working directory to start from. */\n cwd: string;\n\n /**\n * How to determine the app path(s). (`--app` in the docs refers to `desiredApp` here.)\n * @default 'single'\n */\n discover?: Exclude<AppPathDiscoveryMode, 'remote'>;\n\n /**\n * Desired app name or substring, from the `--app` option.\n * - If there's an exact match, only that app will be returned.\n * - If multiple apps match a substring, see `discover` for behavior.\n * - If no match, it's an error.\n */\n desiredApp?: string;\n}): Promise<string[] | CommandExitParams> {\n const { cwd, desiredApp, discover } = params;\n const multiApp = discover === 'multi';\n\n if (!desiredApp && fs.existsSync(path.join(cwd, appConfigFileName))) {\n // If no specific app was requested, and the cwd is a cloudpack app, just use that.\n return [cwd];\n }\n\n // Get all cloudpack app paths based on the presence of cloudpack.config.json\n const cloudpackAppPaths = (glob.sync([`**/${appConfigFileName}`], { cwd, ignore: ['**/node_modules/**'] }) ?? []).map(\n (file) => path.join(cwd, path.dirname(file)),\n );\n\n if (!cloudpackAppPaths.length) {\n // Include the cwd if there are no configs found, since it's possible to run start or init\n // without a config.\n cloudpackAppPaths.push(cwd);\n }\n\n if (!desiredApp && (multiApp || cloudpackAppPaths.length === 1)) {\n // Return all apps found if we're in multi-app mode or only one app was found\n // (and no specific app was requested).\n return cloudpackAppPaths;\n }\n\n // Get each app's name and description, filtered by `desiredApp` if specified.\n // (These use Choice format in case they're later used in a prompt.)\n const packages = new PackageDefinitions();\n const appChoices = (\n await Promise.all<Omit<Choice, 'value'> & { value: string }>(\n cloudpackAppPaths.map(async (dir) => {\n const pkg = await packages.get(dir);\n return {\n title: pkg.name,\n description: pkg?.description ?? 'An awesome app that would be even more awesome with a proper description',\n value: dir,\n };\n }),\n )\n )\n .filter((choice) => !desiredApp || choice.title.includes(desiredApp))\n .sort((c1, c2) => c1.title.localeCompare(c2.title));\n\n // Figure out if there are any matches for `desiredApp`\n if (desiredApp) {\n if (!appChoices.length) {\n return {\n message: `No Cloudpack apps found matching the name \"${desiredApp}\".`,\n hasErrors: true,\n };\n }\n\n // Prefer an exact match\n const exactMatch = appChoices.find((choice) => choice.title === desiredApp);\n if (exactMatch) {\n return [exactMatch.value];\n }\n\n // If there's no exact match, it means at least one substring match was found\n if (multiApp || appChoices.length === 1) {\n // Return them all if we're in multi-app mode or only one match was found\n return appChoices.map((choice) => choice.value);\n }\n }\n\n // There are multiple candidates, so prompt the user to choose one\n // (implicitly, we're in single-app mode if we reach here)\n const response = await prompts<_AppPromptQuestionName>({\n type: 'select',\n name: 'app',\n message: 'Select the app you want to start',\n choices: appChoices,\n });\n\n // This will be undefined if the user cancels the prompt\n if (!response.app) {\n return { isInterrupted: true, message: '' };\n }\n\n return [response.app as string];\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CommandExitParams } from '../types/CommandAction.js';
|
|
2
|
+
import type { SharedOptions } from '../types/SharedOptions.js';
|
|
3
|
+
import type { ReusedOptions } from '../types/ReusedOptions.js';
|
|
4
|
+
import type { Context } from '@ms-cloudpack/api-server';
|
|
5
|
+
export declare function discoverRemoteAppPaths(params: {
|
|
6
|
+
context: Pick<Context, 'reporter'>;
|
|
7
|
+
options: {
|
|
8
|
+
/**
|
|
9
|
+
* Desired app name or substring, from the `--app` option.
|
|
10
|
+
* - If there's an exact match, only that app will be returned.
|
|
11
|
+
* - If multiple apps match a substring, see `discover` for behavior.
|
|
12
|
+
* - If no match, it's an error.
|
|
13
|
+
*/
|
|
14
|
+
desiredApp?: string;
|
|
15
|
+
} & Pick<SharedOptions, 'cachePath'> & Pick<ReusedOptions, 'login'>;
|
|
16
|
+
}): Promise<string[] | CommandExitParams>;
|
|
17
|
+
//# sourceMappingURL=discoverRemoteAppPaths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverRemoteAppPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/discoverRemoteAppPaths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,wBAAsB,sBAAsB,CAAC,MAAM,EAAE;IACnD,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACnC,OAAO,EAAE;QACP;;;;;WAKG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,GAClC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,CA2DxC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getCachePath } from '@ms-cloudpack/config';
|
|
2
|
+
import { selectItemFromPaginatedResults } from './selectItemFromPaginatedResults.js';
|
|
3
|
+
import { createNoOpTelemetryClient } from '@ms-cloudpack/telemetry';
|
|
4
|
+
export async function discoverRemoteAppPaths(params) {
|
|
5
|
+
const { options } = params;
|
|
6
|
+
const { desiredApp, login } = options;
|
|
7
|
+
const { createRemoteCacheClient, createAppRegistryClient } = await import('@ms-cloudpack/remote-cache');
|
|
8
|
+
const cachePath = await getCachePath(options.cachePath);
|
|
9
|
+
const context = {
|
|
10
|
+
...params.context,
|
|
11
|
+
telemetryClient: createNoOpTelemetryClient(),
|
|
12
|
+
};
|
|
13
|
+
const client = await createAppRegistryClient({
|
|
14
|
+
options: {
|
|
15
|
+
cachePath,
|
|
16
|
+
loginMethod: login,
|
|
17
|
+
},
|
|
18
|
+
context,
|
|
19
|
+
});
|
|
20
|
+
const app = await selectItemFromPaginatedResults({
|
|
21
|
+
message: 'Select the app you want to start',
|
|
22
|
+
getPage: (pageSettings) => client.getApps(desiredApp, pageSettings),
|
|
23
|
+
getTitle: (item) => item.name,
|
|
24
|
+
});
|
|
25
|
+
if (!app) {
|
|
26
|
+
return { isInterrupted: true, message: '' };
|
|
27
|
+
}
|
|
28
|
+
const version = await selectItemFromPaginatedResults({
|
|
29
|
+
message: `Select the version of ${app.name} you want to start`,
|
|
30
|
+
getPage: (pageSettings) => client.getVersions(app.name, pageSettings),
|
|
31
|
+
getTitle: (item) => item.version,
|
|
32
|
+
});
|
|
33
|
+
if (!version) {
|
|
34
|
+
return { isInterrupted: true, message: '' };
|
|
35
|
+
}
|
|
36
|
+
const remoteCacheClient = await createRemoteCacheClient({
|
|
37
|
+
context,
|
|
38
|
+
options: {
|
|
39
|
+
cachePath,
|
|
40
|
+
loginMethod: login,
|
|
41
|
+
storageAccount: version.storageAccount,
|
|
42
|
+
tenantId: version.tenantId,
|
|
43
|
+
container: version.container,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const downloadedAppPath = await remoteCacheClient.downloadFolder({
|
|
47
|
+
friendlyName: `${app.name}-${version.version}`,
|
|
48
|
+
id: version.resourceId,
|
|
49
|
+
path: version.localBundleFolderName,
|
|
50
|
+
});
|
|
51
|
+
return [downloadedAppPath];
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=discoverRemoteAppPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverRemoteAppPaths.js","sourceRoot":"","sources":["../../src/utilities/discoverRemoteAppPaths.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAGrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAY5C;IACC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAC3B,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEtC,MAAM,EAAE,u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,EAAE;YACP,SAAS;YACT,WAAW,EAAE,KAAK;YAClB,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B;KACF,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,MAAM,iBAAiB,CAAC,cAAc,CAAC;QAC/D,YAAY,EAAE,GAAG,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE;QAC9C,EAAE,EAAE,OAAO,CAAC,UAAU;QACtB,IAAI,EAAE,OAAO,CAAC,qBAAqB;KACpC,CAAC,CAAC;IAEH,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import type { AppRegistration, AppRegistrationVersion } from '@ms-cloudpack/remote-cache';\nimport type { CommandExitParams } from '../types/CommandAction.js';\nimport { getCachePath } from '@ms-cloudpack/config';\nimport { selectItemFromPaginatedResults } from './selectItemFromPaginatedResults.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\nimport { createNoOpTelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { Context } from '@ms-cloudpack/api-server';\n\nexport async function discoverRemoteAppPaths(params: {\n context: Pick<Context, 'reporter'>;\n options: {\n /**\n * Desired app name or substring, from the `--app` option.\n * - If there's an exact match, only that app will be returned.\n * - If multiple apps match a substring, see `discover` for behavior.\n * - If no match, it's an error.\n */\n desiredApp?: string;\n } & Pick<SharedOptions, 'cachePath'> &\n Pick<ReusedOptions, 'login'>;\n}): Promise<string[] | CommandExitParams> {\n const { options } = params;\n const { desiredApp, login } = options;\n\n const { createRemoteCacheClient, createAppRegistryClient } = await import('@ms-cloudpack/remote-cache');\n\n const cachePath = await getCachePath(options.cachePath);\n\n const context = {\n ...params.context,\n telemetryClient: createNoOpTelemetryClient(),\n };\n\n const client = await createAppRegistryClient({\n options: {\n cachePath,\n loginMethod: login,\n },\n context,\n });\n\n const app = await selectItemFromPaginatedResults<AppRegistration>({\n message: 'Select the app you want to start',\n getPage: (pageSettings) => client.getApps(desiredApp, pageSettings),\n getTitle: (item) => item.name,\n });\n\n if (!app) {\n return { isInterrupted: true, message: '' };\n }\n\n const version = await selectItemFromPaginatedResults<AppRegistrationVersion>({\n message: `Select the version of ${app.name} you want to start`,\n getPage: (pageSettings) => client.getVersions(app.name, pageSettings),\n getTitle: (item) => item.version,\n });\n\n if (!version) {\n return { isInterrupted: true, message: '' };\n }\n\n const remoteCacheClient = await createRemoteCacheClient({\n context,\n options: {\n cachePath,\n loginMethod: login,\n storageAccount: version.storageAccount,\n tenantId: version.tenantId,\n container: version.container,\n },\n });\n\n const downloadedAppPath = await remoteCacheClient.downloadFolder({\n friendlyName: `${app.name}-${version.version}`,\n id: version.resourceId,\n path: version.localBundleFolderName,\n });\n\n return [downloadedAppPath];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDefaultLogin.d.ts","sourceRoot":"","sources":["../../src/utilities/getDefaultLogin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,wBAAgB,eAAe,IAAI,WAAW,CAE7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDefaultLogin.js","sourceRoot":"","sources":["../../src/utilities/getDefaultLogin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,MAAM,UAAU,eAAe;IAC7B,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC;AAC3G,CAAC","sourcesContent":["import { environmentInfo } from '@ms-cloudpack/environment';\nimport type { LoginMethod } from '@ms-cloudpack/remote-cache';\n\nexport function getDefaultLogin(): LoginMethod {\n return environmentInfo.isCI ? 'azure-cli' : environmentInfo.isCodespaces ? 'device-code' : 'interactive';\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reusedOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,MAAM,EAAE,MAAM,WAAW,CAAC;AAKzD;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;;OAGG;6BACa;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;;uCAOT;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE;;IAOvD;;;OAGG;uCACuB,MAAM;6BAKhB;QAAE,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAA;KAAE;IAO5C,0BAA0B;;;CAQgD,CAAC"}
|
|
1
|
+
{"version":3,"file":"reusedOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,MAAM,EAAE,MAAM,WAAW,CAAC;AAKzD;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;;OAGG;6BACa;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;;uCAOT;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE;;IAOvD;;;OAGG;uCACuB,MAAM;6BAKhB;QAAE,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAA;KAAE;IAO5C,0BAA0B;;;CAQgD,CAAC;AAmB7E,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
|
|
@@ -48,7 +48,7 @@ function parseBundleMode(mode) {
|
|
|
48
48
|
throw new InvalidArgumentError(`Valid options are 'lib', 'dev', or 'prod'.`);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function getDefaultLogin() {
|
|
51
|
+
export function getDefaultLogin() {
|
|
52
52
|
return environmentInfo.isCI ? 'azure-cli' : environmentInfo.isCodespaces ? 'device-code' : 'interactive';
|
|
53
53
|
}
|
|
54
54
|
//# sourceMappingURL=reusedOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reusedOptions.js","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;;;OAGG;IACH,GAAG,EAAE,CAAC,OAA6B,EAAE,EAAE,CACrC,IAAI,MAAM,CACR,wBAAwB,EACxB,2BAA2B,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,GAAG;QACjF,wDAAwD,CAC3D;IACH,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,kBAAkB,EAAE,iCAAiC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IACtG,aAAa,EAAE,CAAC,OAAuC,EAAE,EAAE,CACzD,IAAI,MAAM,CACR,mBAAmB,EACnB,sGAAsG;QACpG,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,sEAAsE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC3G;IACH,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,mBAAmB,EAAE,4DAA4D,CAAC;IAClH;;;OAGG;IACH,KAAK,EAAE,CAAC,gBAAwB,EAAE,EAAE,CAClC,IAAI,MAAM,CACR,oBAAoB,EACpB,GAAG,gBAAgB,gEAAgE,CACpF,CAAC,SAAS,CAAC,UAAU,CAAC;IACzB,IAAI,EAAE,CAAC,OAAqC,EAAE,EAAE,CAC9C,IAAI,MAAM,CACR,eAAe,EACf,eAAe,OA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Ae,EAAE,EAAE,gFAAgF,CAAC;IACjH,+EAA+E;IAC/E,8DAA8D;CACY,CAAC;AAE7E,kFAAkF;AAClF,SAAS,eAAe,CAAC,IAAY;IACnC,QAAQ,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QAC3B,KAAK,KAAK,CAAC;QACX,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,KAAK,CAAC;QACX,KAAK,aAAa;YAChB,OAAO,aAAa,CAAC;QACvB,KAAK,MAAM,CAAC;QACZ,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB;YACE,MAAM,IAAI,oBAAoB,CAAC,4CAA4C,CAAC,CAAC;IACjF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC;AAC3G,CAAC","sourcesContent":["import { bundlerNames } from '@ms-cloudpack/bundler';\nimport type { BundleMode } from '@ms-cloudpack/common-types';\nimport { InvalidArgumentError, Option } from 'commander';\nimport { parseMatch } from './parseMatch.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\n\n/**\n * These options are used by multiple commands, but should be manually added.\n */\nexport const reusedOptions = {\n /**\n * Specific app(s) to target. NOTE: This will only be respected if the `program.addSubCommand` call\n * also sets `discoverAppPaths`.\n */\n app: (options?: { multi?: boolean }) =>\n new Option(\n '--app <appPackageName>',\n `Run Cloudpack targeting ${options?.multi ? 'specific app(s)' : 'a specific app'} ` +\n '(prefers an exact match, or falls back to substrings).',\n ),\n bundler: () => new Option('--bundler <name>', 'Force using a specific bundler.').choices(bundlerNames),\n logBundleInfo: (options?: { requiresNoCache?: boolean }) =>\n new Option(\n '--log-bundle-info',\n 'For each package, write log files in its output folder with bundle input, output, and analyzed info.' +\n (options?.requiresNoCache ? ' (Note: requires --no-cache option if bundle output already exists.)' : ''),\n ),\n logResolveMap: () => new Option('--log-resolve-map', 'Log the resolve map to \"resolve-map.json\" for diagnostics.'),\n /**\n * @param descriptionStart Start of description for this command, e.g. \"Bundle specific package(s)\"\n * (it will automatically include an optional version note and examples)\n */\n match: (descriptionStart: string) =>\n new Option(\n '--match <match...>',\n `${descriptionStart}, optionally with a version: e.g. \"foo\", \"@foo/*\", \"foo@1.2.3\"`,\n ).argParser(parseMatch),\n mode: (options: { action: 'bundle' | 'run' }) =>\n new Option(\n '--mode <mode>',\n `The mode to ${options.action === 'bundle' ? 'bundle the package' : 'run the app'} in. (library | production)`,\n )\n .argParser(parseBundleMode)\n .default('library'),\n /** `--no-cache` option */\n cache: () => new Option('--no-cache', 'Rebuild all packages, rather than using cached assets.'),\n login: () =>\n new Option('--login <method>', 'How to authenticate against the remote cache.')\n .choices(['interactive', 'azure-cli', 'device-code'])\n .default(getDefaultLogin(), '\"azure-cli\" in CI, \"device-code\" in Github Codespaces, \"interactive\" otherwise'),\n // Verify the type with `satisfies` to preserve individual function signatures.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} as const satisfies Record<keyof ReusedOptions, (...args: any[]) => Option>;\n\n/** Parse the session mode based on user input (e.g. --mode argument in start.) */\nfunction parseBundleMode(mode: string): BundleMode {\n switch (mode.toLowerCase()) {\n case 'lib':\n case 'library':\n return 'library';\n case 'dev':\n case 'development':\n return 'development';\n case 'prod':\n case 'production':\n return 'production';\n default:\n throw new InvalidArgumentError(`Valid options are 'lib', 'dev', or 'prod'.`);\n }\n}\n\nexport function getDefaultLogin(): string {\n return environmentInfo.isCI ? 'azure-cli' : environmentInfo.isCodespaces ? 'device-code' : 'interactive';\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PageSettings, PagedResult } from '@ms-cloudpack/remote-cache';
|
|
2
|
+
interface SelectItemsFromPaginatedResultsParams<T> {
|
|
3
|
+
/** The message to display to the user when selecting an item. */
|
|
4
|
+
message: string;
|
|
5
|
+
/** A function that fetches a page of items. */
|
|
6
|
+
getPage: (pageSettings: PageSettings) => Promise<PagedResult<T>>;
|
|
7
|
+
/** A function that returns a string to display for each item in the list. */
|
|
8
|
+
getTitle: (item: T) => string;
|
|
9
|
+
/** The default page size to use when fetching items. @default 10. */
|
|
10
|
+
defaultPageSize?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Presents an interactive prompt that lists accumulated items plus a "Load More" option.
|
|
14
|
+
* When "Load More" is selected, it fetches the next page and updates the list.
|
|
15
|
+
*
|
|
16
|
+
* @returns The entity selected by the user or null if nothing is chosen.
|
|
17
|
+
*/
|
|
18
|
+
export declare function selectItemFromPaginatedResults<T>(params: SelectItemsFromPaginatedResultsParams<T>): Promise<T | null>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=selectItemFromPaginatedResults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectItemFromPaginatedResults.d.ts","sourceRoot":"","sources":["../../src/utilities/selectItemFromPaginatedResults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAM5E,UAAU,qCAAqC,CAAC,CAAC;IAC/C,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAEhB,+CAA+C;IAC/C,OAAO,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjE,6EAA6E;IAC7E,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAE9B,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAAC,CAAC,EACpD,MAAM,EAAE,qCAAqC,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAsDnB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import prompts from 'prompts';
|
|
2
|
+
const loadMoreValue = 'load_more';
|
|
3
|
+
const moveUpCursor = '\x1b[1A';
|
|
4
|
+
/**
|
|
5
|
+
* Presents an interactive prompt that lists accumulated items plus a "Load More" option.
|
|
6
|
+
* When "Load More" is selected, it fetches the next page and updates the list.
|
|
7
|
+
*
|
|
8
|
+
* @returns The entity selected by the user or null if nothing is chosen.
|
|
9
|
+
*/
|
|
10
|
+
export async function selectItemFromPaginatedResults(params) {
|
|
11
|
+
const { message, getPage, getTitle, defaultPageSize = 10 } = params;
|
|
12
|
+
let continuationToken = undefined;
|
|
13
|
+
let accumulatedItems = [];
|
|
14
|
+
let response;
|
|
15
|
+
// Do-while loop to continue fetching pages until user selects an item or no more pages are available
|
|
16
|
+
do {
|
|
17
|
+
const previousLength = accumulatedItems.length;
|
|
18
|
+
// If no items have been loaded yet or if more pages exist, load the next page
|
|
19
|
+
if (accumulatedItems.length === 0 || continuationToken) {
|
|
20
|
+
const page = await getPage({ continuationToken, maxPageSize: defaultPageSize });
|
|
21
|
+
accumulatedItems = accumulatedItems.concat(page.items);
|
|
22
|
+
continuationToken = page.continuationToken;
|
|
23
|
+
}
|
|
24
|
+
const choices = accumulatedItems.map((item, index) => ({
|
|
25
|
+
title: getTitle(item),
|
|
26
|
+
value: index.toString(),
|
|
27
|
+
}));
|
|
28
|
+
// If more pages exist, add a "Load More" option at the end
|
|
29
|
+
if (continuationToken) {
|
|
30
|
+
choices.push({
|
|
31
|
+
title: 'Load More',
|
|
32
|
+
value: loadMoreValue,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// Display the selectable list
|
|
36
|
+
response = await prompts({
|
|
37
|
+
type: 'select',
|
|
38
|
+
name: 'selected',
|
|
39
|
+
message: continuationToken ? `${message} (or choose "Load More" to fetch more results)` : message,
|
|
40
|
+
choices,
|
|
41
|
+
initial: previousLength,
|
|
42
|
+
});
|
|
43
|
+
// Check if the user selected "Load More" or a valid item
|
|
44
|
+
if (response.selected === loadMoreValue) {
|
|
45
|
+
// Move the cursor up to overwrite the prompt with the new list
|
|
46
|
+
process.stdout.write(moveUpCursor);
|
|
47
|
+
}
|
|
48
|
+
else if (response.selected) {
|
|
49
|
+
// Return the chosen entity
|
|
50
|
+
return accumulatedItems[parseInt(response.selected)];
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// In case of no selection, return null
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
} while (continuationToken && response.selected === loadMoreValue);
|
|
57
|
+
// Return null if no valid selection was made
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=selectItemFromPaginatedResults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectItemFromPaginatedResults.js","sourceRoot":"","sources":["../../src/utilities/selectItemFromPaginatedResults.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,MAAM,aAAa,GAAG,WAAW,CAAC;AAClC,MAAM,YAAY,GAAG,SAAS,CAAC;AAgB/B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,MAAgD;IAEhD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IACpE,IAAI,iBAAiB,GAAuB,SAAS,CAAC;IACtD,IAAI,gBAAgB,GAAQ,EAAE,CAAC;IAC/B,IAAI,QAA8B,CAAC;IAEnC,qGAAqG;IACrG,GAAG,CAAC;QACF,MAAM,cAAc,GAAG,gBAAgB,CAAC,MAAM,CAAC;QAE/C,8EAA8E;QAC9E,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,IAAI,iBAAiB,EAAE,CAAC;YACvD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,EAAE,iBAAiB,EAAE,WAAW,EAAE,eAA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AO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { PageSettings, PagedResult } from '@ms-cloudpack/remote-cache';\nimport prompts from 'prompts';\n\nconst loadMoreValue = 'load_more';\nconst moveUpCursor = '\\x1b[1A';\n\ninterface SelectItemsFromPaginatedResultsParams<T> {\n /** The message to display to the user when selecting an item. */\n message: string;\n\n /** A function that fetches a page of items. */\n getPage: (pageSettings: PageSettings) => Promise<PagedResult<T>>;\n\n /** A function that returns a string to display for each item in the list. */\n getTitle: (item: T) => string;\n\n /** The default page size to use when fetching items. @default 10. */\n defaultPageSize?: number;\n}\n\n/**\n * Presents an interactive prompt that lists accumulated items plus a \"Load More\" option.\n * When \"Load More\" is selected, it fetches the next page and updates the list.\n *\n * @returns The entity selected by the user or null if nothing is chosen.\n */\nexport async function selectItemFromPaginatedResults<T>(\n params: SelectItemsFromPaginatedResultsParams<T>,\n): Promise<T | null> {\n const { message, getPage, getTitle, defaultPageSize = 10 } = params;\n let continuationToken: string | undefined = undefined;\n let accumulatedItems: T[] = [];\n let response: { selected: string };\n\n // Do-while loop to continue fetching pages until user selects an item or no more pages are available\n do {\n const previousLength = accumulatedItems.length;\n\n // If no items have been loaded yet or if more pages exist, load the next page\n if (accumulatedItems.length === 0 || continuationToken) {\n const page = await getPage({ continuationToken, maxPageSize: defaultPageSize });\n accumulatedItems = accumulatedItems.concat(page.items);\n continuationToken = page.continuationToken;\n }\n\n const choices = accumulatedItems.map((item, index) => ({\n title: getTitle(item),\n value: index.toString(),\n }));\n\n // If more pages exist, add a \"Load More\" option at the end\n if (continuationToken) {\n choices.push({\n title: 'Load More',\n value: loadMoreValue,\n });\n }\n\n // Display the selectable list\n response = await prompts({\n type: 'select',\n name: 'selected',\n message: continuationToken ? `${message} (or choose \"Load More\" to fetch more results)` : message,\n choices,\n initial: previousLength,\n });\n\n // Check if the user selected \"Load More\" or a valid item\n if (response.selected === loadMoreValue) {\n // Move the cursor up to overwrite the prompt with the new list\n process.stdout.write(moveUpCursor);\n } else if (response.selected) {\n // Return the chosen entity\n return accumulatedItems[parseInt(response.selected)];\n } else {\n // In case of no selection, return null\n return null;\n }\n } while (continuationToken && response.selected === loadMoreValue);\n\n // Return null if no valid selection was made\n return null;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.72.
|
|
3
|
+
"version": "0.72.57",
|
|
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,18 +10,18 @@
|
|
|
10
10
|
"cloudpack": "./bin/cloudpack.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ms-cloudpack/api-server": "^0.
|
|
14
|
-
"@ms-cloudpack/app-server": "^0.17.
|
|
13
|
+
"@ms-cloudpack/api-server": "^0.61.0",
|
|
14
|
+
"@ms-cloudpack/app-server": "^0.17.52",
|
|
15
15
|
"@ms-cloudpack/bundler": "^0.24.0",
|
|
16
16
|
"@ms-cloudpack/common-types": "^0.24.7",
|
|
17
17
|
"@ms-cloudpack/config": "^0.33.16",
|
|
18
18
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
19
19
|
"@ms-cloudpack/json-utilities": "^0.1.10",
|
|
20
|
-
"@ms-cloudpack/overlay": "^0.17.
|
|
20
|
+
"@ms-cloudpack/overlay": "^0.17.133",
|
|
21
21
|
"@ms-cloudpack/package-utilities": "^11.3.4",
|
|
22
22
|
"@ms-cloudpack/path-string-parsing": "^1.2.6",
|
|
23
23
|
"@ms-cloudpack/path-utilities": "^3.0.4",
|
|
24
|
-
"@ms-cloudpack/remote-cache": "^0.10.
|
|
24
|
+
"@ms-cloudpack/remote-cache": "^0.10.11",
|
|
25
25
|
"@ms-cloudpack/setup-utilities": "^0.5.14",
|
|
26
26
|
"@ms-cloudpack/task-reporter": "^0.15.1",
|
|
27
27
|
"@ms-cloudpack/telemetry": "^0.10.14",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discoverAppPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/discoverAppPaths.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE3C;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE;IAC7C,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAEhC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,CAiFxC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discoverAppPaths.js","sourceRoot":"","sources":["../../src/utilities/discoverAppPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAwB,MAAM,SAAS,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAKzD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAiBtC;IACC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAC7C,MAAM,QAAQ,GAAG,QAAQ,KAAK,OAAO,CAAC;IAEtC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,I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AAClC,CAAC","sourcesContent":["import { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport glob from 'fast-glob';\nimport fs from 'fs';\nimport path from 'path';\nimport prompts, { type Choice } from 'prompts';\nimport type { CommandExitParams } from '../types/CommandAction.js';\nimport { appConfigFileName } from '@ms-cloudpack/config';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\n\nexport type _AppPromptQuestionName = 'app';\n\n/**\n * Gets the appPath from which Cloudpack will run. If the CWD is a Cloudpack-enabled app,\n * we'll use that; otherwise, we'll scan for Cloudpack-enabled app and present the user\n * with a menu. If no apps are found, Cloudpack will just try to run in the CWD anyway.\n *\n * @returns App path(s) (just one unless `discover: 'multi'`), or an exit options object if\n * there was an error.\n */\nexport async function discoverAppPaths(params: {\n /** Working directory to start from. */\n cwd: string;\n\n /**\n * How to determine the app path(s). (`--app` in the docs refers to `desiredApp` here.)\n * @default 'single'\n */\n discover?: AppPathDiscoveryMode;\n\n /**\n * Desired app name or substring, from the `--app` option.\n * - If there's an exact match, only that app will be returned.\n * - If multiple apps match a substring, see `discover` for behavior.\n * - If no match, it's an error.\n */\n desiredApp?: string;\n}): Promise<string[] | CommandExitParams> {\n const { cwd, desiredApp, discover } = params;\n const multiApp = discover === 'multi';\n\n if (!desiredApp && fs.existsSync(path.join(cwd, appConfigFileName))) {\n // If no specific app was requested, and the cwd is a cloudpack app, just use that.\n return [cwd];\n }\n\n // Get all cloudpack app paths based on the presence of cloudpack.config.json\n const cloudpackAppPaths = (glob.sync([`**/${appConfigFileName}`], { cwd, ignore: ['**/node_modules/**'] }) ?? []).map(\n (file) => path.join(cwd, path.dirname(file)),\n );\n\n if (!cloudpackAppPaths.length) {\n // Include the cwd if there are no configs found, since it's possible to run start or init\n // without a config.\n cloudpackAppPaths.push(cwd);\n }\n\n if (!desiredApp && (multiApp || cloudpackAppPaths.length === 1)) {\n // Return all apps found if we're in multi-app mode or only one app was found\n // (and no specific app was requested).\n return cloudpackAppPaths;\n }\n\n // Get each app's name and description, filtered by `desiredApp` if specified.\n // (These use Choice format in case they're later used in a prompt.)\n const packages = new PackageDefinitions();\n const appChoices = (\n await Promise.all<Omit<Choice, 'value'> & { value: string }>(\n cloudpackAppPaths.map(async (dir) => {\n const pkg = await packages.get(dir);\n return {\n title: pkg.name,\n description: pkg?.description ?? 'An awesome app that would be even more awesome with a proper description',\n value: dir,\n };\n }),\n )\n )\n .filter((choice) => !desiredApp || choice.title.includes(desiredApp))\n .sort((c1, c2) => c1.title.localeCompare(c2.title));\n\n // Figure out if there are any matches for `desiredApp`\n if (desiredApp) {\n if (!appChoices.length) {\n return {\n message: `No Cloudpack apps found matching the name \"${desiredApp}\".`,\n hasErrors: true,\n };\n }\n\n // Prefer an exact match\n const exactMatch = appChoices.find((choice) => choice.title === desiredApp);\n if (exactMatch) {\n return [exactMatch.value];\n }\n\n // If there's no exact match, it means at least one substring match was found\n if (multiApp || appChoices.length === 1) {\n // Return them all if we're in multi-app mode or only one match was found\n return appChoices.map((choice) => choice.value);\n }\n }\n\n // There are multiple candidates, so prompt the user to choose one\n // (implicitly, we're in single-app mode if we reach here)\n const response = await prompts<_AppPromptQuestionName>({\n type: 'select',\n name: 'app',\n message: 'Select the app you want to start',\n choices: appChoices,\n });\n\n // This will be undefined if the user cancels the prompt\n if (!response.app) {\n return { isInterrupted: true, message: '' };\n }\n\n return [response.app as string];\n}\n"]}
|