@ms-cloudpack/cli 0.72.12 → 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.
Files changed (87) hide show
  1. package/lib/commands/bundle/execute.d.ts.map +1 -1
  2. package/lib/commands/bundle/execute.js +7 -8
  3. package/lib/commands/bundle/execute.js.map +1 -1
  4. package/lib/commands/cache/clean.d.ts.map +1 -1
  5. package/lib/commands/cache/clean.js +6 -11
  6. package/lib/commands/cache/clean.js.map +1 -1
  7. package/lib/commands/config/delete.js +4 -4
  8. package/lib/commands/config/delete.js.map +1 -1
  9. package/lib/commands/config/get.js +5 -5
  10. package/lib/commands/config/get.js.map +1 -1
  11. package/lib/commands/config/list.js +5 -5
  12. package/lib/commands/config/list.js.map +1 -1
  13. package/lib/commands/config/set.js +4 -4
  14. package/lib/commands/config/set.js.map +1 -1
  15. package/lib/commands/info/lockFile/execute.d.ts.map +1 -1
  16. package/lib/commands/info/lockFile/execute.js +10 -14
  17. package/lib/commands/info/lockFile/execute.js.map +1 -1
  18. package/lib/commands/info/nonSemverDeps/execute.d.ts.map +1 -1
  19. package/lib/commands/info/nonSemverDeps/execute.js +8 -10
  20. package/lib/commands/info/nonSemverDeps/execute.js.map +1 -1
  21. package/lib/commands/init/evaluatePath.d.ts +2 -2
  22. package/lib/commands/init/evaluatePath.d.ts.map +1 -1
  23. package/lib/commands/init/evaluatePath.js +2 -2
  24. package/lib/commands/init/evaluatePath.js.map +1 -1
  25. package/lib/commands/init/execute.js +4 -4
  26. package/lib/commands/init/execute.js.map +1 -1
  27. package/lib/commands/init/init.js +148 -146
  28. package/lib/commands/init/init.js.map +1 -1
  29. package/lib/commands/link/execute.d.ts.map +1 -1
  30. package/lib/commands/link/execute.js +8 -4
  31. package/lib/commands/link/execute.js.map +1 -1
  32. package/lib/commands/link/getSessionToLink.d.ts +5 -4
  33. package/lib/commands/link/getSessionToLink.d.ts.map +1 -1
  34. package/lib/commands/link/getSessionToLink.js +36 -20
  35. package/lib/commands/link/getSessionToLink.js.map +1 -1
  36. package/lib/commands/setup/execute.js +2 -2
  37. package/lib/commands/setup/execute.js.map +1 -1
  38. package/lib/commands/start/execute.d.ts.map +1 -1
  39. package/lib/commands/start/execute.js +37 -21
  40. package/lib/commands/start/execute.js.map +1 -1
  41. package/lib/commands/start/getStartingAppPath.d.ts +5 -2
  42. package/lib/commands/start/getStartingAppPath.d.ts.map +1 -1
  43. package/lib/commands/start/getStartingAppPath.js +36 -9
  44. package/lib/commands/start/getStartingAppPath.js.map +1 -1
  45. package/lib/commands/sync/execute.d.ts.map +1 -1
  46. package/lib/commands/sync/execute.js +43 -42
  47. package/lib/commands/sync/execute.js.map +1 -1
  48. package/lib/commands/unlink/execute.d.ts.map +1 -1
  49. package/lib/commands/unlink/execute.js +8 -4
  50. package/lib/commands/unlink/execute.js.map +1 -1
  51. package/lib/types/CommandAction.d.ts +14 -8
  52. package/lib/types/CommandAction.d.ts.map +1 -1
  53. package/lib/types/CommandAction.js.map +1 -1
  54. package/lib/utilities/CommandExecutor.d.ts +8 -4
  55. package/lib/utilities/CommandExecutor.d.ts.map +1 -1
  56. package/lib/utilities/CommandExecutor.js +58 -49
  57. package/lib/utilities/CommandExecutor.js.map +1 -1
  58. package/lib/utilities/parseMatch.d.ts.map +1 -1
  59. package/lib/utilities/parseMatch.js +5 -0
  60. package/lib/utilities/parseMatch.js.map +1 -1
  61. package/lib/utilities/runPrerequisites.js +1 -1
  62. package/lib/utilities/runPrerequisites.js.map +1 -1
  63. package/package.json +13 -13
  64. package/lib/commands/link/getSessionFromUser.d.ts +0 -9
  65. package/lib/commands/link/getSessionFromUser.d.ts.map +0 -1
  66. package/lib/commands/link/getSessionFromUser.js +0 -26
  67. package/lib/commands/link/getSessionFromUser.js.map +0 -1
  68. package/lib/commands/start/createPathToChoiceMap.d.ts +0 -16
  69. package/lib/commands/start/createPathToChoiceMap.d.ts.map +0 -1
  70. package/lib/commands/start/createPathToChoiceMap.js +0 -29
  71. package/lib/commands/start/createPathToChoiceMap.js.map +0 -1
  72. package/lib/commands/start/getAppPathFromUser.d.ts +0 -9
  73. package/lib/commands/start/getAppPathFromUser.d.ts.map +0 -1
  74. package/lib/commands/start/getAppPathFromUser.js +0 -28
  75. package/lib/commands/start/getAppPathFromUser.js.map +0 -1
  76. package/lib/commands/start/getMatchingApps.d.ts +0 -9
  77. package/lib/commands/start/getMatchingApps.d.ts.map +0 -1
  78. package/lib/commands/start/getMatchingApps.js +0 -10
  79. package/lib/commands/start/getMatchingApps.js.map +0 -1
  80. package/lib/performance/registerPerformanceObservers.d.ts +0 -7
  81. package/lib/performance/registerPerformanceObservers.d.ts.map +0 -1
  82. package/lib/performance/registerPerformanceObservers.js +0 -20
  83. package/lib/performance/registerPerformanceObservers.js.map +0 -1
  84. package/lib/utilities/stopServers.d.ts +0 -13
  85. package/lib/utilities/stopServers.d.ts.map +0 -1
  86. package/lib/utilities/stopServers.js +0 -18
  87. package/lib/utilities/stopServers.js.map +0 -1
@@ -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
- // Run prerequisites for the app.
36
- runPrerequisites(appContext);
37
- // If --reset is specified, reset the generated config.
38
- if (options.reset) {
39
- config.generated = {};
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
- enqueuePaths(new Map(initialPaths.map((packagePath) => [packagePath, undefined])));
63
- /**
64
- * Enqueue more paths.
65
- * @param newPaths Mapping from package path to importer context.
66
- */
67
- function enqueuePaths(newPaths) {
68
- if (isExitingPrematurely) {
69
- return;
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
- // Iterate through the given paths.
72
- for (const [packagePath, importerContext] of newPaths) {
73
- if (visitedSet.has(packagePath)) {
74
- console.debug(`Skipping ${packagePath} as it has already been visited.`);
75
- continue;
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
- visitedSet.add(packagePath);
78
- pending++;
79
- const shouldForce = refreshPaths.delete(packagePath);
80
- // Get the priority value for this package path, defaults to 0.
81
- const priority = priorityMap.get(packagePath) ?? 0;
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
- else if (pathsToEvaluate?.size) {
107
- // If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them
108
- // and add them to the refresh set so that on re-enqueuing we pass the `shouldRerun` flag through
109
- // on single app runs.
110
- pathsToRefresh?.forEach((refreshPath) => {
111
- refreshPaths.add(refreshPath);
112
- visitedSet.delete(refreshPath);
113
- });
114
- // Try to enqueue the new paths.
115
- console.debug(`Enqueuing paths found from ${packagePath}:\n` +
116
- bulletedList([...pathsToEvaluate].map(([newPath, newContext]) => `${newPath} ${JSON.stringify(newContext)}`)));
117
- enqueuePaths(pathsToEvaluate);
118
- }
119
- // If nothing is pending after this call, we're complete.
120
- if (!pending) {
121
- resolve();
122
- }
123
- })
124
- .catch((error) => {
125
- // Record the exception as an init error for the package.
126
- // This gives better context than a stack trace which could have come from any package.
127
- let prefix = `Error thrown while evaluating package`;
128
- if (importerContext) {
129
- prefix += ` (context: ${JSON.stringify(importerContext, null, 2).replace(/\s+/g, ' ')})`;
130
- }
131
- summaryData.addErrors(packagePath, [
132
- {
133
- text: `${prefix}:\n${error instanceof Error ? error.stack : error}`,
134
- source: 'init',
135
- },
136
- ]);
137
- // Don't immediately stop evaluation, but don't enqueue more paths.
138
- isExitingPrematurely = true;
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
- }).catch((error) => {
143
- // If there's an error thrown from some other part of the promise besides evaluatePath (not likely),
144
- // record it as an init error for the app instead of allowing it to propagate.
145
- // This allows the overall init summary and any other errors to be logged as usual.
146
- isExitingPrematurely = true;
147
- summaryData.addErrors(appPath, [
148
- {
149
- text: `Error thrown during init: ${error instanceof Error ? error.stack : error}`,
150
- source: 'init',
151
- },
152
- ]);
153
- });
154
- // Log the resolve map to a file if requested. Do this *after* the main init process in case
155
- // any additional deps were discovered and added.
156
- if (options.logResolveMap) {
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
- const summary = summaryData.summarize(options);
178
- // The feature "removeUnusedExports" doesn't (yet) write summary changes, but we still
179
- // want to write the generated config if that featureFlag is on.
180
- const hasSummaryChanges = config.features?.removeUnusedExports || summary.totalChanges;
181
- if (!options.check && hasSummaryChanges) {
182
- // Update the generated config: either write it if there are settings, or delete it if it
183
- // previously existed but is no longer needed.
184
- const generatedResult = await writeGeneratedConfig(config.generated, appPath);
185
- if (generatedResult === 'deleted') {
186
- summary.deletedGeneratedConfig = true;
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
- return summary;
190
+ return summary;
191
+ });
190
192
  }
191
193
  //# sourceMappingURL=init.js.map
@@ -1 +1 @@
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,CAAC;YAC5B,UAAU;YACV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CAAC,QAAQ,EAAE,oBAAoB,EAAE,CAAC;YAC1C,8DAA8D;YAC9D,mEAAmE;YACnE,6DAA6D;YAC7D,qBAAqB;YACrB,MAAM,2BAA2B,GAAG,MAAM,oBAAoB,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,UAAU,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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MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC9E,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;gBAClC,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;YACxC,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/link/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAO1D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CAuD9C,CAAC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/link/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAO1D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CA2D9C,CAAC"}
@@ -8,7 +8,7 @@ import path from 'path';
8
8
  */
9
9
  export const execute = async (params) => {
10
10
  // Use the current directory as the default package path.
11
- const { options, cwd: appPath, reporter, initialize, exit } = params;
11
+ const { options, cwd: appPath, reporter, initialize } = params;
12
12
  const { ignore: ignoredPackages, all: includeAll, ignoreResolutions, resolveStrategy, logResolveMap, cachePath, } = options;
13
13
  await initialize({ appPath });
14
14
  console.debug('Linking packages...');
@@ -16,7 +16,11 @@ export const execute = async (params) => {
16
16
  console.debug('Ignored packages:', ignoredPackages?.join(', ') || 'none');
17
17
  console.debug('Apply host resolutions:', !ignoreResolutions);
18
18
  console.debug('Resolve strategy:', resolveStrategy);
19
- const session = await getSessionToLink({ reporter, exit, cachePath });
19
+ const sessionResult = await getSessionToLink({ reporter, cachePath });
20
+ if (!sessionResult.session) {
21
+ return sessionResult;
22
+ }
23
+ const { session } = sessionResult;
20
24
  const client = await createCloudpackClient({ url: session.urls.apiServer, reporter });
21
25
  const includeMessage = includeAll ? ' including all internal paths' : '';
22
26
  const message = `Linking paths for ${session.projectName} at "${appPath}"${includeMessage}`;
@@ -35,7 +39,7 @@ export const execute = async (params) => {
35
39
  if (linkedPaths.find((p) => p.path === appPath) === undefined) {
36
40
  // Close down with an error.
37
41
  task.complete({ status: 'fail', message: `Failed to link paths.`, forceShow: true });
38
- await exit({ exitCode: 1, message: 'Failed to link paths.' });
42
+ return { hasErrors: true, message: 'Failed to link paths.' };
39
43
  }
40
44
  if (logResolveMap) {
41
45
  // Write the linked resolve map to disk.
@@ -44,6 +48,6 @@ export const execute = async (params) => {
44
48
  // Close down successfully.
45
49
  task.complete({ status: 'complete', message: `Linked paths`, forceShow: true });
46
50
  const linkSummary = formatLinkSummary({ session, resolveMap, linkedPaths, resolveStrategy });
47
- await exit({ exitCode: 0, message: linkSummary });
51
+ return { message: linkSummary };
48
52
  };
49
53
  //# sourceMappingURL=execute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/link/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,yDAAyD;IACzD,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IACrE,MAAM,EACJ,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,UAAU,EACf,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,SAAS,GACV,GAAG,OAAO,CAAC;IAEZ,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE9B,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;IAC5C,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC;IAC1E,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,iBAAiB,CAAC,CAAC;IAC7D,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;IAEpD,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,EAAE,QAAQ,EAAE,IAAI,EA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AAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChF,MAAM,WAAW,GAAG,iBAAiB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,CAAC;IAE7F,MAAM,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC","sourcesContent":["import type { CommandAction } from '../../types/CommandAction.js';\nimport type { LinkOptions } from './types/LinkOptions.js';\nimport { getSessionToLink } from './getSessionToLink.js';\nimport { createCloudpackClient } from '@ms-cloudpack/api-server';\nimport { formatLinkSummary } from './formatLinkSummary.js';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\n\n/**\n * Defines the \"link\" verb entry point.\n */\nexport const execute: CommandAction<LinkOptions> = async (params) => {\n // Use the current directory as the default package path.\n const { options, cwd: appPath, reporter, initialize, exit } = params;\n const {\n ignore: ignoredPackages,\n all: includeAll,\n ignoreResolutions,\n resolveStrategy,\n logResolveMap,\n cachePath,\n } = options;\n\n await initialize({ appPath });\n\n console.debug('Linking packages...');\n console.debug('Include all:', !!includeAll);\n console.debug('Ignored packages:', ignoredPackages?.join(', ') || 'none');\n console.debug('Apply host resolutions:', !ignoreResolutions);\n console.debug('Resolve strategy:', resolveStrategy);\n\n const session = await getSessionToLink({ reporter, exit, cachePath });\n const client = await createCloudpackClient({ url: session.urls.apiServer, reporter });\n\n const includeMessage = includeAll ? ' including all internal paths' : '';\n const message = `Linking paths for ${session.projectName} at \"${appPath}\"${includeMessage}`;\n const task = reporter.addTask(message);\n\n // Send request to api server to link paths.\n const { resolveMap, linkedPaths } = await client.linkPath.query({\n linkedPath: {\n path: appPath,\n ignoredPackages,\n includeAll,\n ignoreResolutions,\n resolveStrategy,\n },\n });\n await client.close();\n\n if (linkedPaths.find((p) => p.path === appPath) === undefined) {\n // Close down with an error.\n task.complete({ status: 'fail', message: `Failed to link paths.`, forceShow: true });\n await exit({ exitCode: 1, message: 'Failed to link paths.' });\n }\n\n if (logResolveMap) {\n // Write the linked resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map-linked.json'), resolveMap);\n }\n\n // Close down successfully.\n task.complete({ status: 'complete', message: `Linked paths`, forceShow: true });\n const linkSummary = formatLinkSummary({ session, resolveMap, linkedPaths, resolveStrategy });\n\n await exit({ exitCode: 0, message: linkSummary });\n};\n"]}
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/link/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,yDAAyD;IACzD,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC/D,MAAM,EACJ,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,UAAU,EACf,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,SAAS,GACV,GAAG,OAAO,CAAC;IAEZ,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE9B,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;IAC5C,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CA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,EAAE,IAAI,EAAE,CAAC,CAAC;QACrF,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;IAC/D,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,wCAAwC;QACxC,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,yBAAyB,CAAC,EAAE,UAAU,CAAC,CAAC;IAC7E,CAAC;IAED,2BAA2B;IAC3B,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChF,MAAM,WAAW,GAAG,iBAAiB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,CAAC;IAE7F,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAClC,CAAC,CAAC","sourcesContent":["import type { CommandAction } from '../../types/CommandAction.js';\nimport type { LinkOptions } from './types/LinkOptions.js';\nimport { getSessionToLink } from './getSessionToLink.js';\nimport { createCloudpackClient } from '@ms-cloudpack/api-server';\nimport { formatLinkSummary } from './formatLinkSummary.js';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\n\n/**\n * Defines the \"link\" verb entry point.\n */\nexport const execute: CommandAction<LinkOptions> = async (params) => {\n // Use the current directory as the default package path.\n const { options, cwd: appPath, reporter, initialize } = params;\n const {\n ignore: ignoredPackages,\n all: includeAll,\n ignoreResolutions,\n resolveStrategy,\n logResolveMap,\n cachePath,\n } = options;\n\n await initialize({ appPath });\n\n console.debug('Linking packages...');\n console.debug('Include all:', !!includeAll);\n console.debug('Ignored packages:', ignoredPackages?.join(', ') || 'none');\n console.debug('Apply host resolutions:', !ignoreResolutions);\n console.debug('Resolve strategy:', resolveStrategy);\n\n const sessionResult = await getSessionToLink({ reporter, cachePath });\n if (!sessionResult.session) {\n return sessionResult;\n }\n const { session } = sessionResult;\n const client = await createCloudpackClient({ url: session.urls.apiServer, reporter });\n\n const includeMessage = includeAll ? ' including all internal paths' : '';\n const message = `Linking paths for ${session.projectName} at \"${appPath}\"${includeMessage}`;\n const task = reporter.addTask(message);\n\n // Send request to api server to link paths.\n const { resolveMap, linkedPaths } = await client.linkPath.query({\n linkedPath: {\n path: appPath,\n ignoredPackages,\n includeAll,\n ignoreResolutions,\n resolveStrategy,\n },\n });\n await client.close();\n\n if (linkedPaths.find((p) => p.path === appPath) === undefined) {\n // Close down with an error.\n task.complete({ status: 'fail', message: `Failed to link paths.`, forceShow: true });\n return { hasErrors: true, message: 'Failed to link paths.' };\n }\n\n if (logResolveMap) {\n // Write the linked resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map-linked.json'), resolveMap);\n }\n\n // Close down successfully.\n task.complete({ status: 'complete', message: `Linked paths`, forceShow: true });\n const linkSummary = formatLinkSummary({ session, resolveMap, linkedPaths, resolveStrategy });\n\n return { message: linkSummary };\n};\n"]}
@@ -1,6 +1,6 @@
1
- import type { CommandActionParams } from '../../types/CommandAction.js';
2
- import type { TaskReporter } from '@ms-cloudpack/task-reporter';
3
1
  import type { Session } from '@ms-cloudpack/api-server';
2
+ import type { TaskReporter } from '@ms-cloudpack/task-reporter';
3
+ import type { CommandExitParams } from '../../types/CommandAction.js';
4
4
  type SessionWithRequiredApiServer = Session & {
5
5
  urls: {
6
6
  apiServer: string;
@@ -12,9 +12,10 @@ type SessionWithRequiredApiServer = Session & {
12
12
  */
13
13
  export declare function getSessionToLink(options: {
14
14
  reporter: TaskReporter;
15
- exit: CommandActionParams<object>['exit'];
16
15
  /** Cache path from CLI options */
17
16
  cachePath: string | undefined;
18
- }): Promise<SessionWithRequiredApiServer>;
17
+ }): Promise<CommandExitParams & {
18
+ session?: SessionWithRequiredApiServer;
19
+ }>;
19
20
  export {};
20
21
  //# sourceMappingURL=getSessionToLink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSessionToLink.d.ts","sourceRoot":"","sources":["../../../src/commands/link/getSessionToLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGxD,KAAK,4BAA4B,GAAG,OAAO,GAAG;IAAE,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAE9E;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1C,kCAAkC;IAClC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAwCxC"}
1
+ {"version":3,"file":"getSessionToLink.d.ts","sourceRoot":"","sources":["../../../src/commands/link/getSessionToLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGtE,KAAK,4BAA4B,GAAG,OAAO,GAAG;IAAE,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAE9E;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,QAAQ,EAAE,YAAY,CAAC;IACvB,kCAAkC;IAClC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,GAAG,OAAO,CAAC,iBAAiB,GAAG;IAAE,OAAO,CAAC,EAAE,4BAA4B,CAAA;CAAE,CAAC,CAwD1E"}
@@ -1,40 +1,56 @@
1
- import { getActiveSessions } from './getActiveSessions.js';
2
- import { getSessionFromUser } from './getSessionFromUser.js';
3
1
  import { getCachePath } from '@ms-cloudpack/config';
2
+ import prompts from 'prompts';
3
+ import { getActiveSessions } from './getActiveSessions.js';
4
4
  /**
5
5
  * Get a single active session to link packages.
6
6
  * The session must have an API server URL.
7
7
  */
8
8
  export async function getSessionToLink(options) {
9
- const { reporter, exit } = options;
9
+ const { reporter } = options;
10
10
  // Find the list of running sessions.
11
11
  const cachePath = await getCachePath(options.cachePath);
12
12
  const runningSessions = await getActiveSessions({ reporter, cachePath });
13
13
  if (runningSessions.length === 0) {
14
- await exit({
15
- exitCode: 1,
14
+ return {
15
+ hasErrors: true,
16
16
  message: 'No running sessions found. Please start a session using `cloudpack start` first.',
17
- });
17
+ };
18
18
  }
19
19
  console.debug(`Running sessions: ${runningSessions.map((session) => session.id).join(', ')}`);
20
- const runningSessionsMap = new Map(runningSessions.map((session) => [
21
- session.id,
22
- {
23
- title: session.projectName,
24
- description: session.config.appPath + ' ' + session.id,
25
- value: session,
26
- },
27
- ]));
28
20
  // Select a session to link packages.
29
- const session = await getSessionFromUser(runningSessionsMap);
21
+ let session;
22
+ if (runningSessions.length === 1) {
23
+ // Only one session, so use it automatically.
24
+ session = runningSessions[0];
25
+ }
26
+ else {
27
+ // Prompt the user to select a session.
28
+ const response = await prompts({
29
+ type: 'select',
30
+ name: 'value',
31
+ message: 'Select the app you want to link',
32
+ choices: runningSessions
33
+ .map((s) => ({
34
+ title: s.projectName,
35
+ description: s.config.appPath + ' ' + s.id,
36
+ value: s,
37
+ }))
38
+ .sort((s1, s2) => s1.title.localeCompare(s2.title)),
39
+ });
40
+ // value will be undefined if the user presses Ctrl+C
41
+ session = response.value;
42
+ }
43
+ if (!session) {
44
+ return { isInterrupted: true, message: '' };
45
+ }
30
46
  console.debug('Selected session:', session.id);
31
47
  if (!session.urls.apiServer) {
32
48
  // We should never get here, but just in case.
33
- await exit({
34
- exitCode: 1,
35
- message: 'The selected session does not have an API server URL.',
36
- });
49
+ return { hasErrors: true, message: 'The selected session does not have an API server URL.' };
37
50
  }
38
- return session;
51
+ return {
52
+ session: session,
53
+ message: '', // required by the type but not used
54
+ };
39
55
  }
40
56
  //# sourceMappingURL=getSessionToLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSessionToLink.js","sourceRoot":"","sources":["../../../src/commands/link/getSessionToLink.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAKtC;IACC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEnC,qCAAqC;IACrC,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACxD,MAAM,eAAe,GAAG,MAAM,iBAAiB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IAEzE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,CAAC;YACT,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,kFAAkF;SAC5F,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,qBAAqB,eAAe,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAE9F,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAChC,eAAe,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/B,OAAO,CAAC,EAAE;QACV;YACE,KAAK,EAAE,OAAO,CAAC,WAAW;YAC1B,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,GAAG,OAAO,CAAC,EAAE;YACtD,KAAK,EAAE,OAAO;SACf;KACF,CAAC,CACH,CAAC;IAEF,qCAAqC;IACrC,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IAC7D,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,MAAM,IAAI,CAAC;YACT,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,uDAAuD;SACjE,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAuC,CAAC;AACjD,CAAC","sourcesContent":["import type { CommandActionParams } from '../../types/CommandAction.js';\nimport { getActiveSessions } from './getActiveSessions.js';\nimport { getSessionFromUser } from './getSessionFromUser.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { Session } from '@ms-cloudpack/api-server';\nimport { getCachePath } from '@ms-cloudpack/config';\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 exit: CommandActionParams<object>['exit'];\n /** Cache path from CLI options */\n cachePath: string | undefined;\n}): Promise<SessionWithRequiredApiServer> {\n const { reporter, exit } = 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 await exit({\n exitCode: 1,\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 const runningSessionsMap = new Map(\n runningSessions.map((session) => [\n session.id,\n {\n title: session.projectName,\n description: session.config.appPath + ' ' + session.id,\n value: session,\n },\n ]),\n );\n\n // Select a session to link packages.\n const session = await getSessionFromUser(runningSessionsMap);\n console.debug('Selected session:', session.id);\n\n if (!session.urls.apiServer) {\n // We should never get here, but just in case.\n await exit({\n exitCode: 1,\n message: 'The selected session does not have an API server URL.',\n });\n }\n\n return session as SessionWithRequiredApiServer;\n}\n"]}
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,CAAC;IAE7B,qCAAqC;IACrC,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACxD,MAAM,eAAe,GAAG,MAAM,iBAAiB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IAEzE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO;YACL,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,kFAAkF;SAC5F,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,qBAAqB,eAAe,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAE9F,qCAAqC;IACrC,IAAI,OAA4B,CAAC;IAEjC,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,6CAA6C;QAC7C,OAAO,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,uCAAuC;QACvC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC;YAC7B,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,iCAAiC;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,7 +1,7 @@
1
1
  import { setup } from '@ms-cloudpack/setup-utilities';
2
2
  /** Executor for the "setup" verb */
3
3
  export const execute = async (params) => {
4
- const { cwd, initialize, exit } = params;
4
+ const { cwd, initialize } = params;
5
5
  const { config } = await initialize({ appPath: cwd });
6
6
  const { server = {} } = config;
7
7
  const { domain, https } = server;
@@ -12,6 +12,6 @@ export const execute = async (params) => {
12
12
  cwd,
13
13
  });
14
14
  }
15
- await exit({ message: 'Setup complete.' });
15
+ return { message: 'Setup complete.' };
16
16
  };
17
17
  //# sourceMappingURL=execute.js.map