@ms-cloudpack/cli 0.72.13 → 0.72.14
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 +1 -1
- package/lib/commands/bundle/execute.js.map +1 -1
- package/lib/commands/init/evaluatePath.d.ts +2 -2
- package/lib/commands/init/evaluatePath.d.ts.map +1 -1
- package/lib/commands/init/evaluatePath.js +2 -2
- package/lib/commands/init/evaluatePath.js.map +1 -1
- package/lib/commands/init/init.js +148 -146
- package/lib/commands/init/init.js.map +1 -1
- package/lib/commands/link/getSessionToLink.js +1 -1
- package/lib/commands/link/getSessionToLink.js.map +1 -1
- package/lib/commands/start/execute.d.ts.map +1 -1
- package/lib/commands/start/execute.js +14 -4
- package/lib/commands/start/execute.js.map +1 -1
- package/lib/commands/start/getStartingAppPath.d.ts +5 -2
- package/lib/commands/start/getStartingAppPath.d.ts.map +1 -1
- package/lib/commands/start/getStartingAppPath.js +36 -9
- package/lib/commands/start/getStartingAppPath.js.map +1 -1
- package/lib/commands/sync/execute.d.ts.map +1 -1
- package/lib/commands/sync/execute.js +35 -33
- package/lib/commands/sync/execute.js.map +1 -1
- package/lib/types/CommandAction.d.ts +8 -0
- package/lib/types/CommandAction.d.ts.map +1 -1
- package/lib/types/CommandAction.js.map +1 -1
- package/lib/utilities/CommandExecutor.d.ts +2 -0
- package/lib/utilities/CommandExecutor.d.ts.map +1 -1
- package/lib/utilities/CommandExecutor.js +19 -22
- package/lib/utilities/CommandExecutor.js.map +1 -1
- package/lib/utilities/runPrerequisites.js +1 -1
- package/lib/utilities/runPrerequisites.js.map +1 -1
- package/package.json +7 -7
- package/lib/commands/start/createPathToChoiceMap.d.ts +0 -16
- package/lib/commands/start/createPathToChoiceMap.d.ts.map +0 -1
- package/lib/commands/start/createPathToChoiceMap.js +0 -29
- package/lib/commands/start/createPathToChoiceMap.js.map +0 -1
- package/lib/commands/start/getAppPathFromUser.d.ts +0 -9
- package/lib/commands/start/getAppPathFromUser.d.ts.map +0 -1
- package/lib/commands/start/getAppPathFromUser.js +0 -28
- package/lib/commands/start/getAppPathFromUser.js.map +0 -1
- package/lib/commands/start/getMatchingApps.d.ts +0 -9
- package/lib/commands/start/getMatchingApps.d.ts.map +0 -1
- package/lib/commands/start/getMatchingApps.js +0 -10
- package/lib/commands/start/getMatchingApps.js.map +0 -1
- package/lib/performance/registerPerformanceObservers.d.ts +0 -7
- package/lib/performance/registerPerformanceObservers.d.ts.map +0 -1
- package/lib/performance/registerPerformanceObservers.js +0 -20
- package/lib/performance/registerPerformanceObservers.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAE7E,MAAM,CAAC,MAAM,OAAO,GAAiC,KAAK,EAAE,MAAM,EAAE,EAAE;IACpE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAC5E,MAAM,iBAAiB,GAAG,MAAM,UAAU,CAAC;QACzC,OAAO;QACP,aAAa,EAAE;YACb,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,yFAAyF;YACzF,oEAAoE;YACpE,oBAAoB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;SAC/F;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,GAA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ural, red, yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\n\nexport const execute: CommandAction<BundleOptions> = async (params) => {\n const { cwd: appPath, options, reporter, initialize, autoDispose } = params;\n const apiContextOptions = await initialize({\n appPath,\n configOptions: {\n mode: options.mode,\n // Handle --bundler by passing it as a universal package override, which will be appended\n // to any user-provided packageSettings so that it takes precedence.\n extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,\n },\n });\n\n console.log('Bundle mode:', yellow(options.mode));\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'watcher', 'session', 'taskRunner', 'bus', 'packageImportPaths', 'packageHashes'],\n }),\n );\n\n const pathsToBundle = options.match ? getFilteredPackages(ctx.session.resolveMap, options.match) : [appPath];\n\n if (!pathsToBundle.length) {\n 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 let warnPackagesCount = 0;\n let errorPackagesCount = 0;\n let successPackagesCount = 0;\n\n for (const packagePath of pathsToBundle) {\n // If outdir is set, resolve relative to the package/app path.\n // Otherwise, use the default path under the cloudpack cache to stay consistent with init and start,\n // and to avoid potentially messing with the package's original output.\n const outputPath = options.outdir ? path.resolve(packagePath, options.outdir) : undefined;\n\n const definition = await ctx.packages.get(packagePath);\n\n const { result } = await ensurePackageBundled({\n input: {\n name: definition.name,\n version: definition.version,\n outputPath,\n disableSourceMaps: options.disableSourceMaps,\n shouldForce: true,\n isIncremental: false,\n },\n ctx,\n });\n\n console.log('Output:', result.outputPath, '\\n');\n\n if (result.errors?.length) {\n errorPackagesCount++;\n } else if (result.warnings?.length) {\n warnPackagesCount++;\n } else {\n successPackagesCount++;\n }\n }\n\n const status = [\n errorPackagesCount && red(plural(errorPackagesCount, 'package$s failed')),\n warnPackagesCount && yellow(plural(warnPackagesCount, 'package$s succeeded with warnings')),\n successPackagesCount && plural(successPackagesCount, 'package$s succeeded'),\n ]\n .filter(Boolean)\n .join(', ');\n\n return {\n message: `Bundling ${status}\\n`,\n hasErrors: !!errorPackagesCount,\n };\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EnsurePackageBundledContext } from '@ms-cloudpack/api-server';
|
|
2
2
|
import type { CloudpackConfig, PackageImporterContext } from '@ms-cloudpack/common-types';
|
|
3
3
|
import type { ResolveMap } from '@ms-cloudpack/package-utilities';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Span } from '@ms-cloudpack/telemetry';
|
|
5
5
|
import type { InitSummaryData } from './InitSummaryData.js';
|
|
6
6
|
import type { InitOptions } from './types/InitOptions.js';
|
|
7
7
|
/**
|
|
@@ -18,7 +18,7 @@ export declare function evaluatePath(options: {
|
|
|
18
18
|
config: CloudpackConfig;
|
|
19
19
|
appPath: string;
|
|
20
20
|
resolveMap: ResolveMap;
|
|
21
|
-
|
|
21
|
+
span: Span;
|
|
22
22
|
initOptions: InitOptions;
|
|
23
23
|
summaryData: InitSummaryData;
|
|
24
24
|
ctx: EnsurePackageBundledContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluatePath.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"evaluatePath.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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atePath(options) {
|
|
10
|
-
const { packagePath, config, initOptions,
|
|
10
|
+
const { packagePath, config, initOptions, span, resolveMap, summaryData, ctx, importerContext, shouldForce, isMultiApp, priority, appPath, } = options;
|
|
11
11
|
const { packages } = ctx;
|
|
12
12
|
const { features } = config;
|
|
13
13
|
// This line is the reason we have to track the importerContext for packages to evaluate:
|
|
@@ -77,7 +77,7 @@ export async function evaluatePath(options) {
|
|
|
77
77
|
// importPathsToEvaluate?.forEach((path) => pathsToEvaluate.set(path, importerContext));
|
|
78
78
|
// importPathsToRefresh?.forEach((path) => pathsToRefresh.add(path));
|
|
79
79
|
if (initOptions.check && (exportsChanges.length || evalErrors.length || dynamicImportsChanges?.length)) {
|
|
80
|
-
|
|
80
|
+
span.addEvent('INIT_CHECK_FAILED', {
|
|
81
81
|
// Don't log the specific errors to telemetry, as they may contain sensitive information.
|
|
82
82
|
reason: exportsChanges || dynamicImportsChanges ? 'Config needs to be updated.' : 'Errors found with imports.',
|
|
83
83
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluatePath.js","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAkBlC;IAQC,MAAM,EACJ,WAAW,EACX,MAAM,EACN,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"evaluatePath.js","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,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c,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,iGAAiG;IACjG,6EAA6E;IAC7E,wFAAwF;IACxF,qEAAqE;IAErE,IAAI,WAAW,CAAC,KAAK,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,IAAI,qBAAqB,EAAE,MAAM,CAAC,EAAE,CAAC;QACvG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,EAAE;YACjC,yFAAyF;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 } from '@ms-cloudpack/common-types';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\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 input: {\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 const { errors, warnings, info, outputPath } = result;\n\n // Record the results for the summary.\n summaryData.recordResult({ name, version, path: packagePath, errors, warnings, info, outputPath });\n\n // If there were errors or no imports, return early.\n if (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"]}
|
|
@@ -32,160 +32,162 @@ export async function init(parameters) {
|
|
|
32
32
|
async function initApp(params) {
|
|
33
33
|
const { appContext, options, autoDispose, summaryData, taskRunner, isMultiApp } = params;
|
|
34
34
|
const { appPath, config, telemetryClient } = appContext;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const apiContext = await createPartialApiContext({
|
|
42
|
-
...appContext,
|
|
43
|
-
items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],
|
|
44
|
-
taskRunner,
|
|
45
|
-
});
|
|
46
|
-
autoDispose(apiContext);
|
|
47
|
-
const resolveMap = apiContext.session.resolveMap;
|
|
48
|
-
// Ensure config.generated.packageSettings is initialized.
|
|
49
|
-
config.generated.packageSettings ??= [];
|
|
50
|
-
let isExitingPrematurely = false;
|
|
51
|
-
await new Promise((resolve) => {
|
|
52
|
-
let pending = 0;
|
|
53
|
-
const visitedSet = new Set();
|
|
54
|
-
const refreshPaths = new Set();
|
|
55
|
-
const priorityMap = new Map();
|
|
56
|
-
// Start with the app path or requested matches
|
|
57
|
-
const initialPaths = options.match ? getFilteredPackages(resolveMap, options.match) : [appPath];
|
|
58
|
-
if (!initialPaths.length) {
|
|
59
|
-
summaryData.addErrors(appPath, [{ text: `No packages found matching ${options.match}`, source: 'init' }]);
|
|
60
|
-
resolve();
|
|
35
|
+
return telemetryClient.tracer.startActiveSpan('INIT_APP', async (span) => {
|
|
36
|
+
// Run prerequisites for the app.
|
|
37
|
+
runPrerequisites(appContext);
|
|
38
|
+
// If --reset is specified, reset the generated config.
|
|
39
|
+
if (options.reset) {
|
|
40
|
+
config.generated = {};
|
|
61
41
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
42
|
+
const apiContext = await createPartialApiContext({
|
|
43
|
+
...appContext,
|
|
44
|
+
items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],
|
|
45
|
+
taskRunner,
|
|
46
|
+
});
|
|
47
|
+
autoDispose(apiContext);
|
|
48
|
+
const resolveMap = apiContext.session.resolveMap;
|
|
49
|
+
// Ensure config.generated.packageSettings is initialized.
|
|
50
|
+
config.generated.packageSettings ??= [];
|
|
51
|
+
let isExitingPrematurely = false;
|
|
52
|
+
await new Promise((resolve) => {
|
|
53
|
+
let pending = 0;
|
|
54
|
+
const visitedSet = new Set();
|
|
55
|
+
const refreshPaths = new Set();
|
|
56
|
+
const priorityMap = new Map();
|
|
57
|
+
// Start with the app path or requested matches
|
|
58
|
+
const initialPaths = options.match ? getFilteredPackages(resolveMap, options.match) : [appPath];
|
|
59
|
+
if (!initialPaths.length) {
|
|
60
|
+
summaryData.addErrors(appPath, [{ text: `No packages found matching ${options.match}`, source: 'init' }]);
|
|
61
|
+
resolve();
|
|
70
62
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
enqueuePaths(new Map(initialPaths.map((packagePath) => [packagePath, undefined])));
|
|
64
|
+
/**
|
|
65
|
+
* Enqueue more paths.
|
|
66
|
+
* @param newPaths Mapping from package path to importer context.
|
|
67
|
+
*/
|
|
68
|
+
function enqueuePaths(newPaths) {
|
|
69
|
+
if (isExitingPrematurely) {
|
|
70
|
+
return;
|
|
76
71
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// Lower priority of this package path by 1.
|
|
83
|
-
priorityMap.set(packagePath, priority - 1);
|
|
84
|
-
// Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.
|
|
85
|
-
evaluatePath({
|
|
86
|
-
appPath,
|
|
87
|
-
packagePath,
|
|
88
|
-
importerContext,
|
|
89
|
-
config,
|
|
90
|
-
telemetryClient,
|
|
91
|
-
resolveMap,
|
|
92
|
-
initOptions: options,
|
|
93
|
-
summaryData,
|
|
94
|
-
ctx: apiContext,
|
|
95
|
-
// No need to force if we're in a multi-app scenario
|
|
96
|
-
// as we'll re-evaluate packages if they are different since we use a different task id.
|
|
97
|
-
shouldForce: !isMultiApp && shouldForce,
|
|
98
|
-
isMultiApp,
|
|
99
|
-
priority,
|
|
100
|
-
})
|
|
101
|
-
.then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {
|
|
102
|
-
pending--;
|
|
103
|
-
if (shouldExit) {
|
|
104
|
-
isExitingPrematurely = true;
|
|
72
|
+
// Iterate through the given paths.
|
|
73
|
+
for (const [packagePath, importerContext] of newPaths) {
|
|
74
|
+
if (visitedSet.has(packagePath)) {
|
|
75
|
+
console.debug(`Skipping ${packagePath} as it has already been visited.`);
|
|
76
|
+
continue;
|
|
105
77
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
78
|
+
visitedSet.add(packagePath);
|
|
79
|
+
pending++;
|
|
80
|
+
const shouldForce = refreshPaths.delete(packagePath);
|
|
81
|
+
// Get the priority value for this package path, defaults to 0.
|
|
82
|
+
const priority = priorityMap.get(packagePath) ?? 0;
|
|
83
|
+
// Lower priority of this package path by 1.
|
|
84
|
+
priorityMap.set(packagePath, priority - 1);
|
|
85
|
+
// Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.
|
|
86
|
+
evaluatePath({
|
|
87
|
+
appPath,
|
|
88
|
+
packagePath,
|
|
89
|
+
importerContext,
|
|
90
|
+
config,
|
|
91
|
+
span,
|
|
92
|
+
resolveMap,
|
|
93
|
+
initOptions: options,
|
|
94
|
+
summaryData,
|
|
95
|
+
ctx: apiContext,
|
|
96
|
+
// No need to force if we're in a multi-app scenario
|
|
97
|
+
// as we'll re-evaluate packages if they are different since we use a different task id.
|
|
98
|
+
shouldForce: !isMultiApp && shouldForce,
|
|
99
|
+
isMultiApp,
|
|
100
|
+
priority,
|
|
101
|
+
})
|
|
102
|
+
.then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {
|
|
103
|
+
pending--;
|
|
104
|
+
if (shouldExit) {
|
|
105
|
+
isExitingPrematurely = true;
|
|
106
|
+
}
|
|
107
|
+
else if (pathsToEvaluate?.size) {
|
|
108
|
+
// If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them
|
|
109
|
+
// and add them to the refresh set so that on re-enqueuing we pass the `shouldRerun` flag through
|
|
110
|
+
// on single app runs.
|
|
111
|
+
pathsToRefresh?.forEach((refreshPath) => {
|
|
112
|
+
refreshPaths.add(refreshPath);
|
|
113
|
+
visitedSet.delete(refreshPath);
|
|
114
|
+
});
|
|
115
|
+
// Try to enqueue the new paths.
|
|
116
|
+
console.debug(`Enqueuing paths found from ${packagePath}:\n` +
|
|
117
|
+
bulletedList([...pathsToEvaluate].map(([newPath, newContext]) => `${newPath} ${JSON.stringify(newContext)}`)));
|
|
118
|
+
enqueuePaths(pathsToEvaluate);
|
|
119
|
+
}
|
|
120
|
+
// If nothing is pending after this call, we're complete.
|
|
121
|
+
if (!pending) {
|
|
122
|
+
resolve();
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
.catch((error) => {
|
|
126
|
+
// Record the exception as an init error for the package.
|
|
127
|
+
// This gives better context than a stack trace which could have come from any package.
|
|
128
|
+
let prefix = `Error thrown while evaluating package`;
|
|
129
|
+
if (importerContext) {
|
|
130
|
+
prefix += ` (context: ${JSON.stringify(importerContext, null, 2).replace(/\s+/g, ' ')})`;
|
|
131
|
+
}
|
|
132
|
+
summaryData.addErrors(packagePath, [
|
|
133
|
+
{
|
|
134
|
+
text: `${prefix}:\n${error instanceof Error ? error.stack : error}`,
|
|
135
|
+
source: 'init',
|
|
136
|
+
},
|
|
137
|
+
]);
|
|
138
|
+
// Don't immediately stop evaluation, but don't enqueue more paths.
|
|
139
|
+
isExitingPrematurely = true;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
140
142
|
}
|
|
143
|
+
}).catch((error) => {
|
|
144
|
+
// If there's an error thrown from some other part of the promise besides evaluatePath (not likely),
|
|
145
|
+
// record it as an init error for the app instead of allowing it to propagate.
|
|
146
|
+
// This allows the overall init summary and any other errors to be logged as usual.
|
|
147
|
+
isExitingPrematurely = true;
|
|
148
|
+
summaryData.addErrors(appPath, [
|
|
149
|
+
{
|
|
150
|
+
text: `Error thrown during init: ${error instanceof Error ? error.stack : error}`,
|
|
151
|
+
source: 'init',
|
|
152
|
+
},
|
|
153
|
+
]);
|
|
154
|
+
});
|
|
155
|
+
// Log the resolve map to a file if requested. Do this *after* the main init process in case
|
|
156
|
+
// any additional deps were discovered and added.
|
|
157
|
+
if (options.logResolveMap) {
|
|
158
|
+
console.log('\nWriting resolve map to `resolve-map.json`.');
|
|
159
|
+
await writeJson(path.join(appPath, 'resolve-map.json'), resolveMap);
|
|
141
160
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
console.log('\nWriting resolve map to `resolve-map.json`.');
|
|
158
|
-
await writeJson(path.join(appPath, 'resolve-map.json'), resolveMap);
|
|
159
|
-
}
|
|
160
|
-
// Only do extra checks if there's not a major error already
|
|
161
|
-
if (!isExitingPrematurely) {
|
|
162
|
-
if (config.features?.optimizeDependencies) {
|
|
163
|
-
// Conditionally scan dependency usage so that we can populate
|
|
164
|
-
// include/excludeDependencies automatically, ensuring the dep list
|
|
165
|
-
// is both minimal (remove unused deps) and complete (include
|
|
166
|
-
// specific devDeps.)
|
|
167
|
-
const excludedDependenciesChanges = await optimizeDependencies(summaryData.getResults(), apiContext);
|
|
168
|
-
summaryData.recordGeneratedChanges(excludedDependenciesChanges);
|
|
169
|
-
}
|
|
170
|
-
if (config.features?.verifyExports) {
|
|
171
|
-
const packageResults = await verifyExports(summaryData.getResults(), apiContext);
|
|
172
|
-
for (const [packagePath, errors] of Object.entries(packageResults)) {
|
|
173
|
-
summaryData.addErrors(packagePath, errors);
|
|
161
|
+
// Only do extra checks if there's not a major error already
|
|
162
|
+
if (!isExitingPrematurely) {
|
|
163
|
+
if (config.features?.optimizeDependencies) {
|
|
164
|
+
// Conditionally scan dependency usage so that we can populate
|
|
165
|
+
// include/excludeDependencies automatically, ensuring the dep list
|
|
166
|
+
// is both minimal (remove unused deps) and complete (include
|
|
167
|
+
// specific devDeps.)
|
|
168
|
+
const excludedDependenciesChanges = await optimizeDependencies(summaryData.getResults(), apiContext);
|
|
169
|
+
summaryData.recordGeneratedChanges(excludedDependenciesChanges);
|
|
170
|
+
}
|
|
171
|
+
if (config.features?.verifyExports) {
|
|
172
|
+
const packageResults = await verifyExports(summaryData.getResults(), apiContext);
|
|
173
|
+
for (const [packagePath, errors] of Object.entries(packageResults)) {
|
|
174
|
+
summaryData.addErrors(packagePath, errors);
|
|
175
|
+
}
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
178
|
+
const summary = summaryData.summarize(options);
|
|
179
|
+
// The feature "removeUnusedExports" doesn't (yet) write summary changes, but we still
|
|
180
|
+
// want to write the generated config if that featureFlag is on.
|
|
181
|
+
const hasSummaryChanges = config.features?.removeUnusedExports || summary.totalChanges;
|
|
182
|
+
if (!options.check && hasSummaryChanges) {
|
|
183
|
+
// Update the generated config: either write it if there are settings, or delete it if it
|
|
184
|
+
// previously existed but is no longer needed.
|
|
185
|
+
const generatedResult = await writeGeneratedConfig(config.generated, appPath);
|
|
186
|
+
if (generatedResult === 'deleted') {
|
|
187
|
+
summary.deletedGeneratedConfig = true;
|
|
188
|
+
}
|
|
187
189
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
return summary;
|
|
191
|
+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AAU,CAAC,CAAC;YACrG,WAAW,CAAC,sBAAsB,CAAC,2BAA2B,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAC;YACnC,MAAM,cAAc,GAAG,MAAM,aAAa,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,UAAU,CAAC,CAAC;YACjF,KAAK,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;gBACnE,WAAW,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAE/C,sFAAsF;IACtF,gEAAgE;IAChE,MAAM,iBAAiB,GAAG,MAAM,CAAC,QAAQ,EAAE,mBAAmB,IAAI,OAAO,CAAC,YAAY,CAAC;IAEvF,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,iBAAiB,EAAE,CAAC;QACxC,yFAAyF;QACzF,8CAA8C;QAC9C,MAAM,eAAe,GAAG,MAAM,oBAAoB,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC9E,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YAClC,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;QACxC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { type Context, TaskRunner } from '@ms-cloudpack/api-server';\nimport type { PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { AutoDispose } from '../../types/AutoDispose.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitSummary } from './types/InitSummary.js';\n\nimport { createPartialApiContext } from '@ms-cloudpack/api-server';\nimport { writeGeneratedConfig } from '@ms-cloudpack/config';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport { evaluatePath } from './evaluatePath.js';\nimport { verifyExports } from './verifyExports.js';\nimport type { AppCommandContext } from '../../types/CommandAction.js';\nimport path from 'path';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\nimport { optimizeDependencies } from './optimizeDependencies.js';\nimport { bulletedList } from '@ms-cloudpack/task-reporter';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n contexts: AppCommandContext[];\n autoDispose: AutoDispose;\n /**\n * App summary objects, created ahead of time so that a partial summary can be generated\n * if the process is interrupted.\n */\n appSummaries: Record<string, InitSummaryData>;\n}): Promise<InitSummary[]> {\n const { options, contexts, autoDispose, appSummaries } = parameters;\n\n const summaries: InitSummary[] = [];\n\n const taskRunner = new TaskRunner();\n\n for (const appContext of contexts) {\n const summary = await initApp({\n appContext,\n options,\n autoDispose,\n summaryData: appSummaries[appContext.appPath],\n taskRunner,\n isMultiApp: contexts.length > 1,\n });\n summaries.push(summary);\n }\n\n return summaries;\n}\n\nasync function initApp(params: {\n appContext: AppCommandContext;\n options: InitOptions;\n autoDispose: AutoDispose;\n summaryData: InitSummaryData;\n taskRunner: TaskRunner;\n isMultiApp: boolean;\n}): Promise<InitSummary> {\n const { appContext, options, autoDispose, summaryData, taskRunner, isMultiApp } = params;\n const { appPath, config, telemetryClient } = appContext;\n\n // Run prerequisites for the app.\n runPrerequisites(appContext);\n\n // If --reset is specified, reset the generated config.\n if (options.reset) {\n config.generated = {};\n }\n\n const apiContext: Context = await createPartialApiContext({\n ...appContext,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n taskRunner,\n });\n autoDispose(apiContext);\n const resolveMap = apiContext.session.resolveMap;\n\n // Ensure config.generated.packageSettings is initialized.\n config.generated.packageSettings ??= [];\n\n let isExitingPrematurely = false;\n\n await new Promise<void>((resolve) => {\n let pending = 0;\n const visitedSet = new Set<string>();\n const refreshPaths = new Set<string>();\n const priorityMap = new Map<string, number>();\n\n // Start with the app path or requested matches\n const initialPaths = options.match ? getFilteredPackages(resolveMap, options.match) : [appPath];\n if (!initialPaths.length) {\n summaryData.addErrors(appPath, [{ text: `No packages found matching ${options.match}`, source: 'init' }]);\n resolve();\n }\n\n enqueuePaths(new Map(initialPaths.map((packagePath) => [packagePath, undefined])));\n\n /**\n * Enqueue more paths.\n * @param newPaths Mapping from package path to importer context.\n */\n function enqueuePaths(newPaths: Map<string, PackageImporterContext | undefined>) {\n if (isExitingPrematurely) {\n return;\n }\n\n // Iterate through the given paths.\n for (const [packagePath, importerContext] of newPaths) {\n if (visitedSet.has(packagePath)) {\n console.debug(`Skipping ${packagePath} as it has already been visited.`);\n continue;\n }\n\n visitedSet.add(packagePath);\n pending++;\n\n const shouldForce = refreshPaths.delete(packagePath);\n\n // Get the priority value for this package path, defaults to 0.\n const priority = priorityMap.get(packagePath) ?? 0;\n // Lower priority of this package path by 1.\n priorityMap.set(packagePath, priority - 1);\n\n // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.\n evaluatePath({\n appPath,\n packagePath,\n importerContext,\n config,\n telemetryClient,\n resolveMap,\n initOptions: options,\n summaryData,\n ctx: apiContext,\n // No need to force if we're in a multi-app scenario\n // as we'll re-evaluate packages if they are different since we use a different task id.\n shouldForce: !isMultiApp && shouldForce,\n isMultiApp,\n priority,\n })\n .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {\n pending--;\n\n if (shouldExit) {\n isExitingPrematurely = true;\n } else if (pathsToEvaluate?.size) {\n // If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them\n // and add them to the refresh set so that on re-enqueuing we pass the `shouldRerun` flag through\n // on single app runs.\n pathsToRefresh?.forEach((refreshPath) => {\n refreshPaths.add(refreshPath);\n visitedSet.delete(refreshPath);\n });\n\n // Try to enqueue the new paths.\n console.debug(\n `Enqueuing paths found from ${packagePath}:\\n` +\n bulletedList(\n [...pathsToEvaluate].map(([newPath, newContext]) => `${newPath} ${JSON.stringify(newContext)}`),\n ),\n );\n enqueuePaths(pathsToEvaluate);\n }\n\n // If nothing is pending after this call, we're complete.\n if (!pending) {\n resolve();\n }\n })\n .catch((error) => {\n // Record the exception as an init error for the package.\n // This gives better context than a stack trace which could have come from any package.\n let prefix = `Error thrown while evaluating package`;\n if (importerContext) {\n prefix += ` (context: ${JSON.stringify(importerContext, null, 2).replace(/\\s+/g, ' ')})`;\n }\n\n summaryData.addErrors(packagePath, [\n {\n text: `${prefix}:\\n${error instanceof Error ? error.stack : error}`,\n source: 'init',\n },\n ]);\n\n // Don't immediately stop evaluation, but don't enqueue more paths.\n isExitingPrematurely = true;\n });\n }\n }\n }).catch((error) => {\n // If there's an error thrown from some other part of the promise besides evaluatePath (not likely),\n // record it as an init error for the app instead of allowing it to propagate.\n // This allows the overall init summary and any other errors to be logged as usual.\n isExitingPrematurely = true;\n summaryData.addErrors(appPath, [\n {\n text: `Error thrown during init: ${error instanceof Error ? error.stack : error}`,\n source: 'init',\n },\n ]);\n });\n\n // Log the resolve map to a file if requested. Do this *after* the main init process in case\n // any additional deps were discovered and added.\n if (options.logResolveMap) {\n console.log('\\nWriting resolve map to `resolve-map.json`.');\n await writeJson(path.join(appPath, 'resolve-map.json'), resolveMap);\n }\n\n // Only do extra checks if there's not a major error already\n if (!isExitingPrematurely) {\n if (config.features?.optimizeDependencies) {\n // Conditionally scan dependency usage so that we can populate\n // include/excludeDependencies automatically, ensuring the dep list\n // is both minimal (remove unused deps) and complete (include\n // specific devDeps.)\n const excludedDependenciesChanges = await optimizeDependencies(summaryData.getResults(), apiContext);\n summaryData.recordGeneratedChanges(excludedDependenciesChanges);\n }\n\n if (config.features?.verifyExports) {\n const packageResults = await verifyExports(summaryData.getResults(), apiContext);\n for (const [packagePath, errors] of Object.entries(packageResults)) {\n summaryData.addErrors(packagePath, errors);\n }\n }\n }\n\n const summary = summaryData.summarize(options);\n\n // The feature \"removeUnusedExports\" doesn't (yet) write summary changes, but we still\n // want to write the generated config if that featureFlag is on.\n const hasSummaryChanges = config.features?.removeUnusedExports || summary.totalChanges;\n\n if (!options.check && hasSummaryChanges) {\n // Update the generated config: either write it if there are settings, or delete it if it\n // previously existed but is no longer needed.\n const generatedResult = await writeGeneratedConfig(config.generated, appPath);\n if (generatedResult === 'deleted') {\n summary.deletedGeneratedConfig = true;\n }\n }\n\n return summary;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAMpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,UAS1B;IACC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC;IAEpE,MAAM,SAAS,GAAkB,EAAE,CAAC;IAEpC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;IAEpC,KAAK,MAAM,UAAU,IAAI,QAAQ,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,MAAM,OAAO,CAA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AAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { type Context, TaskRunner } from '@ms-cloudpack/api-server';\nimport type { PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { AutoDispose } from '../../types/AutoDispose.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitSummary } from './types/InitSummary.js';\n\nimport { createPartialApiContext } from '@ms-cloudpack/api-server';\nimport { writeGeneratedConfig } from '@ms-cloudpack/config';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport { evaluatePath } from './evaluatePath.js';\nimport { verifyExports } from './verifyExports.js';\nimport type { AppCommandContext } from '../../types/CommandAction.js';\nimport path from 'path';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\nimport { optimizeDependencies } from './optimizeDependencies.js';\nimport { bulletedList } from '@ms-cloudpack/task-reporter';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n contexts: AppCommandContext[];\n autoDispose: AutoDispose;\n /**\n * App summary objects, created ahead of time so that a partial summary can be generated\n * if the process is interrupted.\n */\n appSummaries: Record<string, InitSummaryData>;\n}): Promise<InitSummary[]> {\n const { options, contexts, autoDispose, appSummaries } = parameters;\n\n const summaries: InitSummary[] = [];\n\n const taskRunner = new TaskRunner();\n\n for (const appContext of contexts) {\n const summary = await initApp({\n appContext,\n options,\n autoDispose,\n summaryData: appSummaries[appContext.appPath],\n taskRunner,\n isMultiApp: contexts.length > 1,\n });\n summaries.push(summary);\n }\n\n return summaries;\n}\n\nasync function initApp(params: {\n appContext: AppCommandContext;\n options: InitOptions;\n autoDispose: AutoDispose;\n summaryData: InitSummaryData;\n taskRunner: TaskRunner;\n isMultiApp: boolean;\n}): Promise<InitSummary> {\n const { appContext, options, autoDispose, summaryData, taskRunner, isMultiApp } = params;\n const { appPath, config, telemetryClient } = appContext;\n return telemetryClient.tracer.startActiveSpan('INIT_APP', async (span) => {\n // Run prerequisites for the app.\n runPrerequisites(appContext);\n\n // If --reset is specified, reset the generated config.\n if (options.reset) {\n config.generated = {};\n }\n\n const apiContext: Context = await createPartialApiContext({\n ...appContext,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n taskRunner,\n });\n autoDispose(apiContext);\n const resolveMap = apiContext.session.resolveMap;\n\n // Ensure config.generated.packageSettings is initialized.\n config.generated.packageSettings ??= [];\n\n let isExitingPrematurely = false;\n\n await new Promise<void>((resolve) => {\n let pending = 0;\n const visitedSet = new Set<string>();\n const refreshPaths = new Set<string>();\n const priorityMap = new Map<string, number>();\n\n // Start with the app path or requested matches\n const initialPaths = options.match ? getFilteredPackages(resolveMap, options.match) : [appPath];\n if (!initialPaths.length) {\n summaryData.addErrors(appPath, [{ text: `No packages found matching ${options.match}`, source: 'init' }]);\n resolve();\n }\n\n enqueuePaths(new Map(initialPaths.map((packagePath) => [packagePath, undefined])));\n\n /**\n * Enqueue more paths.\n * @param newPaths Mapping from package path to importer context.\n */\n function enqueuePaths(newPaths: Map<string, PackageImporterContext | undefined>) {\n if (isExitingPrematurely) {\n return;\n }\n\n // Iterate through the given paths.\n for (const [packagePath, importerContext] of newPaths) {\n if (visitedSet.has(packagePath)) {\n console.debug(`Skipping ${packagePath} as it has already been visited.`);\n continue;\n }\n\n visitedSet.add(packagePath);\n pending++;\n\n const shouldForce = refreshPaths.delete(packagePath);\n\n // Get the priority value for this package path, defaults to 0.\n const priority = priorityMap.get(packagePath) ?? 0;\n // Lower priority of this package path by 1.\n priorityMap.set(packagePath, priority - 1);\n\n // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.\n evaluatePath({\n appPath,\n packagePath,\n importerContext,\n config,\n span,\n resolveMap,\n initOptions: options,\n summaryData,\n ctx: apiContext,\n // No need to force if we're in a multi-app scenario\n // as we'll re-evaluate packages if they are different since we use a different task id.\n shouldForce: !isMultiApp && shouldForce,\n isMultiApp,\n priority,\n })\n .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {\n pending--;\n\n if (shouldExit) {\n isExitingPrematurely = true;\n } else if (pathsToEvaluate?.size) {\n // If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them\n // and add them to the refresh set so that on re-enqueuing we pass the `shouldRerun` flag through\n // on single app runs.\n pathsToRefresh?.forEach((refreshPath) => {\n refreshPaths.add(refreshPath);\n visitedSet.delete(refreshPath);\n });\n\n // Try to enqueue the new paths.\n console.debug(\n `Enqueuing paths found from ${packagePath}:\\n` +\n bulletedList(\n [...pathsToEvaluate].map(([newPath, newContext]) => `${newPath} ${JSON.stringify(newContext)}`),\n ),\n );\n enqueuePaths(pathsToEvaluate);\n }\n\n // If nothing is pending after this call, we're complete.\n if (!pending) {\n resolve();\n }\n })\n .catch((error) => {\n // Record the exception as an init error for the package.\n // This gives better context than a stack trace which could have come from any package.\n let prefix = `Error thrown while evaluating package`;\n if (importerContext) {\n prefix += ` (context: ${JSON.stringify(importerContext, null, 2).replace(/\\s+/g, ' ')})`;\n }\n\n summaryData.addErrors(packagePath, [\n {\n text: `${prefix}:\\n${error instanceof Error ? error.stack : error}`,\n source: 'init',\n },\n ]);\n\n // Don't immediately stop evaluation, but don't enqueue more paths.\n isExitingPrematurely = true;\n });\n }\n }\n }).catch((error) => {\n // If there's an error thrown from some other part of the promise besides evaluatePath (not likely),\n // record it as an init error for the app instead of allowing it to propagate.\n // This allows the overall init summary and any other errors to be logged as usual.\n isExitingPrematurely = true;\n summaryData.addErrors(appPath, [\n {\n text: `Error thrown during init: ${error instanceof Error ? error.stack : error}`,\n source: 'init',\n },\n ]);\n });\n\n // Log the resolve map to a file if requested. Do this *after* the main init process in case\n // any additional deps were discovered and added.\n if (options.logResolveMap) {\n console.log('\\nWriting resolve map to `resolve-map.json`.');\n await writeJson(path.join(appPath, 'resolve-map.json'), resolveMap);\n }\n\n // Only do extra checks if there's not a major error already\n if (!isExitingPrematurely) {\n if (config.features?.optimizeDependencies) {\n // Conditionally scan dependency usage so that we can populate\n // include/excludeDependencies automatically, ensuring the dep list\n // is both minimal (remove unused deps) and complete (include\n // specific devDeps.)\n const excludedDependenciesChanges = await optimizeDependencies(summaryData.getResults(), apiContext);\n summaryData.recordGeneratedChanges(excludedDependenciesChanges);\n }\n\n if (config.features?.verifyExports) {\n const packageResults = await verifyExports(summaryData.getResults(), apiContext);\n for (const [packagePath, errors] of Object.entries(packageResults)) {\n summaryData.addErrors(packagePath, errors);\n }\n }\n }\n\n const summary = summaryData.summarize(options);\n\n // The feature \"removeUnusedExports\" doesn't (yet) write summary changes, but we still\n // want to write the generated config if that featureFlag is on.\n const hasSummaryChanges = config.features?.removeUnusedExports || summary.totalChanges;\n\n if (!options.check && hasSummaryChanges) {\n // Update the generated config: either write it if there are settings, or delete it if it\n // previously existed but is no longer needed.\n const generatedResult = await writeGeneratedConfig(config.generated, appPath);\n if (generatedResult === 'deleted') {\n summary.deletedGeneratedConfig = true;\n }\n }\n\n return summary;\n });\n}\n"]}
|
|
@@ -41,7 +41,7 @@ export async function getSessionToLink(options) {
|
|
|
41
41
|
session = response.value;
|
|
42
42
|
}
|
|
43
43
|
if (!session) {
|
|
44
|
-
return { message: '
|
|
44
|
+
return { isInterrupted: true, message: '' };
|
|
45
45
|
}
|
|
46
46
|
console.debug('Selected session:', session.id);
|
|
47
47
|
if (!session.urls.apiServer) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSessionToLink.js","sourceRoot":"","sources":["../../../src/commands/link/getSessionToLink.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAI3D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAItC;IACC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,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AAiC;YAC1C,OAAO,EAAE,eAAe;iBACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACX,KAAK,EAAE,CAAC,CAAC,WAAW;gBACpB,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE;gBAC1C,KAAK,EAAE,CAAC;aACT,CAAC,CAAC;iBACF,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;SACtD,CAAC,CAAC;QAEH,qDAAqD;QACrD,OAAO,GAAG,QAAQ,CAAC,KAA4B,CAAC;IAClD,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC9C,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAE/C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,8CAA8C;QAC9C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,uDAAuD,EAAE,CAAC;IAC/F,CAAC;IAED,OAAO;QACL,OAAO,EAAE,OAAuC;QAChD,OAAO,EAAE,EAAE,EAAE,oCAAoC;KAClD,CAAC;AACJ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport { getCachePath } from '@ms-cloudpack/config';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport prompts from 'prompts';\nimport type { CommandExitParams } from '../../types/CommandAction.js';\nimport { getActiveSessions } from './getActiveSessions.js';\n\ntype SessionWithRequiredApiServer = Session & { urls: { apiServer: string } };\n\n/**\n * Get a single active session to link packages.\n * The session must have an API server URL.\n */\nexport async function getSessionToLink(options: {\n reporter: TaskReporter;\n /** Cache path from CLI options */\n cachePath: string | undefined;\n}): Promise<CommandExitParams & { session?: SessionWithRequiredApiServer }> {\n const { reporter } = options;\n\n // Find the list of running sessions.\n const cachePath = await getCachePath(options.cachePath);\n const runningSessions = await getActiveSessions({ reporter, cachePath });\n\n if (runningSessions.length === 0) {\n return {\n hasErrors: true,\n message: 'No running sessions found. Please start a session using `cloudpack start` first.',\n };\n }\n\n console.debug(`Running sessions: ${runningSessions.map((session) => session.id).join(', ')}`);\n\n // Select a session to link packages.\n let session: Session | undefined;\n\n if (runningSessions.length === 1) {\n // Only one session, so use it automatically.\n session = runningSessions[0];\n } else {\n // Prompt the user to select a session.\n const response = await prompts({\n type: 'select',\n name: 'value',\n message: 'Select the app you want to link',\n choices: runningSessions\n .map((s) => ({\n title: s.projectName,\n description: s.config.appPath + ' ' + s.id,\n value: s,\n }))\n .sort((s1, s2) => s1.title.localeCompare(s2.title)),\n });\n\n // value will be undefined if the user presses Ctrl+C\n session = response.value as Session | undefined;\n }\n\n if (!session) {\n return { isInterrupted: true, message: '' };\n }\n\n console.debug('Selected session:', session.id);\n\n if (!session.urls.apiServer) {\n // We should never get here, but just in case.\n return { hasErrors: true, message: 'The selected session does not have an API server URL.' };\n }\n\n return {\n session: session as SessionWithRequiredApiServer,\n message: '', // required by the type but not used\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D;;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":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,CAsH/C,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { makeUrl } from '@ms-cloudpack/path-string-parsing';
|
|
|
5
5
|
import { cyan, yellow, bold } from '@ms-cloudpack/task-reporter';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
|
-
import { PerfMarkerCliEntry
|
|
8
|
+
import { PerfMarkerCliEntry } from '../../performance/markers.js';
|
|
9
9
|
import { runPrerequisites } from '../../utilities/runPrerequisites.js';
|
|
10
10
|
import { getStartingAppPath } from './getStartingAppPath.js';
|
|
11
11
|
import { openBrowser } from './openBrowser.js';
|
|
@@ -16,9 +16,13 @@ import { getCertificate } from '@ms-cloudpack/setup-utilities';
|
|
|
16
16
|
*/
|
|
17
17
|
export const execute = async (params) => {
|
|
18
18
|
const { options, cwd, initialize, autoDispose } = params;
|
|
19
|
-
const
|
|
19
|
+
const appPathResult = await getStartingAppPath(cwd, options.app);
|
|
20
|
+
if (typeof appPathResult !== 'string') {
|
|
21
|
+
return appPathResult;
|
|
22
|
+
}
|
|
23
|
+
const appPath = appPathResult;
|
|
20
24
|
const apiContextOptions = await initialize({ appPath, configOptions: { mode: options.mode } });
|
|
21
|
-
const { config } = apiContextOptions;
|
|
25
|
+
const { config, telemetryClient } = apiContextOptions;
|
|
22
26
|
console.log('App path:', yellow(appPath));
|
|
23
27
|
console.log('Bundle mode:', yellow(options.mode));
|
|
24
28
|
runPrerequisites(apiContextOptions);
|
|
@@ -85,7 +89,13 @@ export const execute = async (params) => {
|
|
|
85
89
|
};
|
|
86
90
|
autoDispose({ dispose: cleanup });
|
|
87
91
|
const defaultUrl = makeUrl(config.server?.defaultPath || '', session.urls.appServer).href;
|
|
88
|
-
performance.
|
|
92
|
+
const cliEntryMarker = performance.getEntriesByName(PerfMarkerCliEntry, 'mark')[0];
|
|
93
|
+
if (cliEntryMarker) {
|
|
94
|
+
telemetryClient.tracer.startSpan('TIME_TO_OPEN_BROWSER', { startTime: cliEntryMarker.startTime }).end();
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
throw new Error('TIME_TO_OPEN_BROWSER marker not found');
|
|
98
|
+
}
|
|
89
99
|
// Open the browser.
|
|
90
100
|
if (options.open !== false) {
|
|
91
101
|
openBrowser(defaultUrl).catch((err) => {
|