@ms-cloudpack/cli 0.57.9 → 0.58.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/lib/commands/bundle/execute.d.ts.map +1 -1
  2. package/lib/commands/bundle/execute.js +14 -5
  3. package/lib/commands/bundle/execute.js.map +1 -1
  4. package/lib/commands/bundle/index.d.ts.map +1 -1
  5. package/lib/commands/bundle/index.js +2 -1
  6. package/lib/commands/bundle/index.js.map +1 -1
  7. package/lib/commands/bundle/types/BundleOptions.d.ts +4 -1
  8. package/lib/commands/bundle/types/BundleOptions.d.ts.map +1 -1
  9. package/lib/commands/bundle/types/BundleOptions.js.map +1 -1
  10. package/lib/commands/info/nonSemverDeps/getNonSemverDeps.js.map +1 -1
  11. package/lib/commands/init/evaluateImportsForOverrides.d.ts +1 -2
  12. package/lib/commands/init/evaluateImportsForOverrides.d.ts.map +1 -1
  13. package/lib/commands/init/evaluateImportsForOverrides.js.map +1 -1
  14. package/lib/commands/init/evaluatePath.d.ts +1 -2
  15. package/lib/commands/init/evaluatePath.d.ts.map +1 -1
  16. package/lib/commands/init/evaluatePath.js.map +1 -1
  17. package/lib/commands/init/execute.d.ts.map +1 -1
  18. package/lib/commands/init/execute.js +11 -5
  19. package/lib/commands/init/execute.js.map +1 -1
  20. package/lib/commands/init/formatInitSummary.d.ts +5 -1
  21. package/lib/commands/init/formatInitSummary.d.ts.map +1 -1
  22. package/lib/commands/init/formatInitSummary.js +16 -10
  23. package/lib/commands/init/formatInitSummary.js.map +1 -1
  24. package/lib/commands/init/init.d.ts +8 -2
  25. package/lib/commands/init/init.d.ts.map +1 -1
  26. package/lib/commands/init/init.js +5 -6
  27. package/lib/commands/init/init.js.map +1 -1
  28. package/lib/commands/init/neverExclude.d.ts +1 -1
  29. package/lib/commands/init/neverExclude.js.map +1 -1
  30. package/lib/commands/init/optimizeDependencies.d.ts +1 -2
  31. package/lib/commands/init/optimizeDependencies.d.ts.map +1 -1
  32. package/lib/commands/init/optimizeDependencies.js.map +1 -1
  33. package/lib/commands/init/types/InitPackageResult.d.ts +1 -1
  34. package/lib/commands/init/types/InitPackageResult.d.ts.map +1 -1
  35. package/lib/commands/init/types/InitPackageResult.js.map +1 -1
  36. package/lib/commands/init/types/InitPackageResultErrors.d.ts +1 -1
  37. package/lib/commands/init/types/InitPackageResultErrors.d.ts.map +1 -1
  38. package/lib/commands/init/types/InitPackageResultErrors.js.map +1 -1
  39. package/lib/commands/init/types/InitPackageResultWarnings.d.ts +1 -1
  40. package/lib/commands/init/types/InitPackageResultWarnings.d.ts.map +1 -1
  41. package/lib/commands/init/types/InitPackageResultWarnings.js.map +1 -1
  42. package/lib/commands/init/verifyExports.d.ts +1 -1
  43. package/lib/commands/init/verifyExports.d.ts.map +1 -1
  44. package/lib/commands/init/verifyExports.js.map +1 -1
  45. package/lib/commands/start/execute.js +1 -1
  46. package/lib/commands/start/execute.js.map +1 -1
  47. package/lib/commands/start/getStartingAppPath.js +1 -1
  48. package/lib/commands/start/getStartingAppPath.js.map +1 -1
  49. package/lib/commands/sync/execute.d.ts.map +1 -1
  50. package/lib/commands/sync/execute.js +4 -6
  51. package/lib/commands/sync/execute.js.map +1 -1
  52. package/lib/index.js +1 -1
  53. package/lib/index.js.map +1 -1
  54. package/lib/types/CommandAction.d.ts +20 -12
  55. package/lib/types/CommandAction.d.ts.map +1 -1
  56. package/lib/types/CommandAction.js.map +1 -1
  57. package/lib/types/CommandInitFunction.d.ts +1 -1
  58. package/lib/types/CommandInitFunction.d.ts.map +1 -1
  59. package/lib/types/CommandInitFunction.js.map +1 -1
  60. package/lib/utilities/AutoDisposableList.d.ts.map +1 -0
  61. package/lib/utilities/AutoDisposableList.js.map +1 -0
  62. package/lib/utilities/CloudpackCommand.d.ts.map +1 -0
  63. package/lib/utilities/CloudpackCommand.js.map +1 -0
  64. package/lib/{common → utilities}/CommandExecutor.d.ts +1 -0
  65. package/lib/utilities/CommandExecutor.d.ts.map +1 -0
  66. package/lib/{common → utilities}/CommandExecutor.js +12 -8
  67. package/lib/utilities/CommandExecutor.js.map +1 -0
  68. package/lib/{common → utilities}/checkFeatures.d.ts +1 -1
  69. package/lib/utilities/checkFeatures.d.ts.map +1 -0
  70. package/lib/{common → utilities}/checkFeatures.js +1 -1
  71. package/lib/utilities/checkFeatures.js.map +1 -0
  72. package/lib/{common → utilities}/findCloudpackAppPaths.d.ts +1 -1
  73. package/lib/utilities/findCloudpackAppPaths.d.ts.map +1 -0
  74. package/lib/{common → utilities}/findCloudpackAppPaths.js +1 -1
  75. package/lib/utilities/findCloudpackAppPaths.js.map +1 -0
  76. package/lib/utilities/getMergedFeatureFlags.d.ts +9 -0
  77. package/lib/utilities/getMergedFeatureFlags.d.ts.map +1 -0
  78. package/lib/{common → utilities}/getMergedFeatureFlags.js +5 -5
  79. package/lib/utilities/getMergedFeatureFlags.js.map +1 -0
  80. package/lib/utilities/mergeFeatures.d.ts +8 -0
  81. package/lib/utilities/mergeFeatures.d.ts.map +1 -0
  82. package/lib/{common → utilities}/mergeFeatures.js +3 -2
  83. package/lib/utilities/mergeFeatures.js.map +1 -0
  84. package/lib/{common → utilities}/runPrerequisites.d.ts +1 -1
  85. package/lib/utilities/runPrerequisites.d.ts.map +1 -0
  86. package/lib/utilities/runPrerequisites.js.map +1 -0
  87. package/package.json +9 -10
  88. package/lib/common/AutoDisposableList.d.ts.map +0 -1
  89. package/lib/common/AutoDisposableList.js.map +0 -1
  90. package/lib/common/CloudpackCommand.d.ts.map +0 -1
  91. package/lib/common/CloudpackCommand.js.map +0 -1
  92. package/lib/common/CommandExecutor.d.ts.map +0 -1
  93. package/lib/common/CommandExecutor.js.map +0 -1
  94. package/lib/common/checkFeatures.d.ts.map +0 -1
  95. package/lib/common/checkFeatures.js.map +0 -1
  96. package/lib/common/findCloudpackAppPaths.d.ts.map +0 -1
  97. package/lib/common/findCloudpackAppPaths.js.map +0 -1
  98. package/lib/common/findPackageOverride.d.ts +0 -6
  99. package/lib/common/findPackageOverride.d.ts.map +0 -1
  100. package/lib/common/findPackageOverride.js +0 -8
  101. package/lib/common/findPackageOverride.js.map +0 -1
  102. package/lib/common/getMergedFeatureFlags.d.ts +0 -6
  103. package/lib/common/getMergedFeatureFlags.d.ts.map +0 -1
  104. package/lib/common/getMergedFeatureFlags.js.map +0 -1
  105. package/lib/common/mergeFeatures.d.ts +0 -12
  106. package/lib/common/mergeFeatures.d.ts.map +0 -1
  107. package/lib/common/mergeFeatures.js.map +0 -1
  108. package/lib/common/runPrerequisites.d.ts.map +0 -1
  109. package/lib/common/runPrerequisites.js.map +0 -1
  110. /package/lib/{common → utilities}/AutoDisposableList.d.ts +0 -0
  111. /package/lib/{common → utilities}/AutoDisposableList.js +0 -0
  112. /package/lib/{common → utilities}/CloudpackCommand.d.ts +0 -0
  113. /package/lib/{common → utilities}/CloudpackCommand.js +0 -0
  114. /package/lib/{common → utilities}/runPrerequisites.js +0 -0
@@ -1,21 +1,20 @@
1
1
  import { createPartialApiContext } from '@ms-cloudpack/api-server';
2
2
  import { writeGeneratedConfig } from '@ms-cloudpack/config';
3
3
  import { bold, bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';
4
- import { InitSummaryData } from './InitSummaryData.js';
5
4
  import { evaluatePath } from './evaluatePath.js';
6
5
  import { verifyExports } from './verifyExports.js';
7
6
  import path from 'path';
8
7
  import { writeJson } from '@ms-cloudpack/json-utilities';
9
- import { runPrerequisites } from '../../common/runPrerequisites.js';
8
+ import { runPrerequisites } from '../../utilities/runPrerequisites.js';
10
9
  /**
11
10
  * Init execution function.
12
11
  */
13
12
  export async function init(parameters) {
14
- const { options, contexts, reporter, autoDispose } = parameters;
13
+ const { options, contexts, reporter, autoDispose, appSummaries } = parameters;
15
14
  const summaries = [];
16
15
  let taskRunner = undefined;
17
- for (const initContext of contexts) {
18
- const { appPath, config, telemetryClient } = initContext;
16
+ for (const appContext of contexts) {
17
+ const { appPath, config, telemetryClient } = appContext;
19
18
  // Run prerequisites for the app.
20
19
  runPrerequisites({ config, cwd: appPath, telemetryClient });
21
20
  // Don't allow --check and --reset together.
@@ -39,7 +38,7 @@ export async function init(parameters) {
39
38
  const resolveMap = apiContext.session.resolveMap;
40
39
  // Ensure config.generated.packageSettings is initialized.
41
40
  config.generated.packageSettings ??= [];
42
- const summaryData = new InitSummaryData(appPath);
41
+ const summaryData = appSummaries[appPath];
43
42
  await new Promise((resolve, reject) => {
44
43
  let pending = 0;
45
44
  let isExitingPrematurely = false;
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,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,kCAAkC,CAAC;AAEpE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,UAK1B;IACC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC;IAEhE,MAAM,SAAS,GAAG,EAAE,CAAC;IAErB,IAAI,UAAU,GAA2B,SAAS,CAAC;IAEnD,KAAK,MAAM,WAAW,IAAI,QAAQ,EAAE,CAAC;QACnC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,WAAW,CAAC;QAEz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edConfig, PackageJsonExportsObject } from '@ms-cloudpack/config-types';\nimport type { PackageImporterContext } from '@ms-cloudpack/bundler-types';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\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 { bold, bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';\nimport { InitSummaryData } from './InitSummaryData.js';\nimport { evaluatePath } from './evaluatePath.js';\nimport { verifyExports } from './verifyExports.js';\nimport type { InitContext } from '../../types/CommandAction.js';\nimport path from 'path';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { runPrerequisites } from '../../common/runPrerequisites.js';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n contexts: InitContext[];\n autoDispose: AutoDispose;\n reporter: TaskReporter;\n}): Promise<InitSummary[]> {\n const { options, contexts, reporter, autoDispose } = parameters;\n\n const summaries = [];\n\n let taskRunner: TaskRunner | undefined = undefined;\n\n for (const initContext of contexts) {\n const { appPath, config, telemetryClient } = initContext;\n\n // Run prerequisites for the app.\n runPrerequisites({ config, cwd: appPath, telemetryClient });\n\n // Don't allow --check and --reset together.\n if (options.check && options.reset) {\n throw Error('Cannot use --check and --reset together.');\n }\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 appPath,\n config,\n reporter,\n telemetryClient,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n taskRunner,\n });\n taskRunner ??= apiContext.taskRunner;\n autoDispose(apiContext);\n const resolveMap = apiContext.session.resolveMap;\n\n // Ensure config.generated.packageSettings is initialized.\n config.generated.packageSettings ??= [];\n\n const summaryData = new InitSummaryData(appPath);\n\n await new Promise<void>((resolve, reject) => {\n let pending = 0;\n let isExitingPrematurely = false;\n const visitedSet = new Set<string>();\n const refreshPaths = new Set<string>();\n\n // Start with the app path or requested matches\n enqueuePaths(getInitialPaths({ appPath, match: options.match, resolveMap, reporter }));\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 continue;\n }\n\n refreshPaths.delete(packagePath);\n\n visitedSet.add(packagePath);\n pending++;\n\n // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.\n evaluatePath({\n packagePath,\n importerContext,\n config,\n telemetryClient,\n resolveMap,\n initOptions: options,\n summaryData,\n ctx: apiContext,\n })\n .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {\n pending--;\n\n if (shouldExit) {\n isExitingPrematurely = true;\n } else if (pathsToEvaluate?.size && !options.match) {\n // If there are paths that need to be rebuilt, add them to the refresh set so that on re-enqueuing\n // we pass the `shouldRerun` flag through\n pathsToRefresh?.forEach((refreshPath) => {\n refreshPaths.add(refreshPath);\n visitedSet.delete(refreshPath);\n });\n\n // Try to enqueue the new paths.\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 reject(error);\n });\n }\n }\n });\n\n if (config.features?.verifyExports) {\n const packageResults = await verifyExports(summaryData.getResults(), apiContext);\n packageResults.forEach((packageResult) => summaryData.recordResult({ packageResult, append: true }));\n }\n\n const summary = summaryData.summarize(options);\n summaries.push(summary);\n\n if (!options.check && summary.totalChanges && config.generated.packageSettings?.length) {\n sortExportKeys(config.generated);\n\n await writeGeneratedConfig(config.generated, appPath);\n }\n\n if (options.logResolveMap) {\n reporter.log('\\nWriting resolve map to `resolve-map.json`.');\n await writeJson(path.join(appPath, 'resolve-map.json'), resolveMap);\n }\n }\n\n return summaries;\n}\n\n/**\n * Get initial package paths to process: either the app path, or packages matching `match` in the init options.\n */\nfunction getInitialPaths(params: {\n appPath: string;\n /** Only evaluate packages matching this string (from init options). */\n match: string | undefined;\n resolveMap: ResolveMap;\n reporter: TaskReporter;\n}): Map<string, PackageImporterContext | undefined> {\n const { appPath, match, resolveMap, reporter } = params;\n\n if (!match) {\n return new Map([[appPath, undefined]]);\n }\n\n // Find matching packages in the resolve map\n const resolveMapEntries = Object.values(resolveMap).filter((entry) => entry.name.includes(match));\n\n reporter.log(\n `\\nFound ${plural(resolveMapEntries.length, 'package')} matching \"${bold(match)}\":\\n`,\n bulletedList(resolveMapEntries.map((entry) => `${formatPackageName(entry)}: ${entry.path}`)),\n );\n\n return new Map(resolveMapEntries.map((entry) => [entry.path, undefined]));\n}\n\nfunction sortExportKeys({ packageSettings = [] }: GeneratedConfig) {\n for (const settings of packageSettings) {\n if (!settings.exports) {\n continue;\n }\n\n const unsortedExports = settings.exports as PackageJsonExportsObject;\n\n settings.exports = Object.fromEntries(\n Object.keys(unsortedExports)\n .sort()\n .map((k) => [k, unsortedExports[k]]),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE5F,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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QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,SAAS;QACX,CAAC;QAED,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAmC,CAAC;QAErE,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CACnC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;aACzB,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CACvC,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { Context, TaskRunner } from '@ms-cloudpack/api-server';\nimport type { GeneratedConfig, PackageJsonExportsObject, PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\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 { bold, bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';\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';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n contexts: AppCommandContext[];\n autoDispose: AutoDispose;\n reporter: TaskReporter;\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, reporter, autoDispose, appSummaries } = parameters;\n\n const summaries: InitSummary[] = [];\n\n let taskRunner: TaskRunner | undefined = undefined;\n\n for (const appContext of contexts) {\n const { appPath, config, telemetryClient } = appContext;\n\n // Run prerequisites for the app.\n runPrerequisites({ config, cwd: appPath, telemetryClient });\n\n // Don't allow --check and --reset together.\n if (options.check && options.reset) {\n throw Error('Cannot use --check and --reset together.');\n }\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 appPath,\n config,\n reporter,\n telemetryClient,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n taskRunner,\n });\n taskRunner ??= apiContext.taskRunner;\n autoDispose(apiContext);\n const resolveMap = apiContext.session.resolveMap;\n\n // Ensure config.generated.packageSettings is initialized.\n config.generated.packageSettings ??= [];\n\n const summaryData = appSummaries[appPath];\n\n await new Promise<void>((resolve, reject) => {\n let pending = 0;\n let isExitingPrematurely = false;\n const visitedSet = new Set<string>();\n const refreshPaths = new Set<string>();\n\n // Start with the app path or requested matches\n enqueuePaths(getInitialPaths({ appPath, match: options.match, resolveMap, reporter }));\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 continue;\n }\n\n refreshPaths.delete(packagePath);\n\n visitedSet.add(packagePath);\n pending++;\n\n // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.\n evaluatePath({\n packagePath,\n importerContext,\n config,\n telemetryClient,\n resolveMap,\n initOptions: options,\n summaryData,\n ctx: apiContext,\n })\n .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {\n pending--;\n\n if (shouldExit) {\n isExitingPrematurely = true;\n } else if (pathsToEvaluate?.size && !options.match) {\n // If there are paths that need to be rebuilt, add them to the refresh set so that on re-enqueuing\n // we pass the `shouldRerun` flag through\n pathsToRefresh?.forEach((refreshPath) => {\n refreshPaths.add(refreshPath);\n visitedSet.delete(refreshPath);\n });\n\n // Try to enqueue the new paths.\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 reject(error);\n });\n }\n }\n });\n\n if (config.features?.verifyExports) {\n const packageResults = await verifyExports(summaryData.getResults(), apiContext);\n packageResults.forEach((packageResult) => summaryData.recordResult({ packageResult, append: true }));\n }\n\n const summary = summaryData.summarize(options);\n summaries.push(summary);\n\n if (!options.check && summary.totalChanges && config.generated.packageSettings?.length) {\n sortExportKeys(config.generated);\n\n await writeGeneratedConfig(config.generated, appPath);\n }\n\n if (options.logResolveMap) {\n reporter.log('\\nWriting resolve map to `resolve-map.json`.');\n await writeJson(path.join(appPath, 'resolve-map.json'), resolveMap);\n }\n }\n\n return summaries;\n}\n\n/**\n * Get initial package paths to process: either the app path, or packages matching `match` in the init options.\n */\nfunction getInitialPaths(params: {\n appPath: string;\n /** Only evaluate packages matching this string (from init options). */\n match: string | undefined;\n resolveMap: ResolveMap;\n reporter: TaskReporter;\n}): Map<string, PackageImporterContext | undefined> {\n const { appPath, match, resolveMap, reporter } = params;\n\n if (!match) {\n return new Map([[appPath, undefined]]);\n }\n\n // Find matching packages in the resolve map\n const resolveMapEntries = Object.values(resolveMap).filter((entry) => entry.name.includes(match));\n\n reporter.log(\n `\\nFound ${plural(resolveMapEntries.length, 'package')} matching \"${bold(match)}\":\\n`,\n bulletedList(resolveMapEntries.map((entry) => `${formatPackageName(entry)}: ${entry.path}`)),\n );\n\n return new Map(resolveMapEntries.map((entry) => [entry.path, undefined]));\n}\n\nfunction sortExportKeys({ packageSettings = [] }: GeneratedConfig) {\n for (const settings of packageSettings) {\n if (!settings.exports) {\n continue;\n }\n\n const unsortedExports = settings.exports as PackageJsonExportsObject;\n\n settings.exports = Object.fromEntries(\n Object.keys(unsortedExports)\n .sort()\n .map((k) => [k, unsortedExports[k]]),\n );\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { CloudpackConfig } from '@ms-cloudpack/config-types';
1
+ import type { CloudpackConfig } from '@ms-cloudpack/common-types';
2
2
  /**
3
3
  * Checks if a package should never be excluded.
4
4
  * Uses the `neverExcludeDependencies` field in the config or the default list.
@@ -1 +1 @@
1
- {"version":3,"file":"neverExclude.js","sourceRoot":"","sources":["../../../src/commands/init/neverExclude.ts"],"names":[],"mappings":"AAEA,MAAM,+BAA+B,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,WAAmB,EAAE,MAAuB;IACvE,+FAA+F;IAC/F,MAAM,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,IAAI,+BAA+B,CAAC;IACpG,IAAI,wBAAwB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,wBAAwB,CAAC,MAAM,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,+BAA+B,CAAC,CAAC;IAClH,CAAC;IAED,OAAO,wBAAwB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/config-types';\n\nconst defaultNeverExcludeDependencies = ['tslib', '@babel/runtime'];\n\n/**\n * Checks if a package should never be excluded.\n * Uses the `neverExcludeDependencies` field in the config or the default list.\n * @param packageName Name of the package to check.\n * @param config Cloudpack configuration.\n * @returns True if the package should never be excluded.\n */\nexport function neverExclude(packageName: string, config: CloudpackConfig): boolean {\n // Set never exclude to the default if it is not set. Replace string '...' with default if set.\n const neverExcludeDependencies = config.neverExcludeDependencies ?? defaultNeverExcludeDependencies;\n if (neverExcludeDependencies.includes('...')) {\n neverExcludeDependencies.splice(neverExcludeDependencies.indexOf('...'), 1, ...defaultNeverExcludeDependencies);\n }\n\n return neverExcludeDependencies.includes(packageName);\n}\n"]}
1
+ {"version":3,"file":"neverExclude.js","sourceRoot":"","sources":["../../../src/commands/init/neverExclude.ts"],"names":[],"mappings":"AAEA,MAAM,+BAA+B,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,WAAmB,EAAE,MAAuB;IACvE,+FAA+F;IAC/F,MAAM,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,IAAI,+BAA+B,CAAC;IACpG,IAAI,wBAAwB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,wBAAwB,CAAC,MAAM,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,+BAA+B,CAAC,CAAC;IAClH,CAAC;IAED,OAAO,wBAAwB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/common-types';\n\nconst defaultNeverExcludeDependencies = ['tslib', '@babel/runtime'];\n\n/**\n * Checks if a package should never be excluded.\n * Uses the `neverExcludeDependencies` field in the config or the default list.\n * @param packageName Name of the package to check.\n * @param config Cloudpack configuration.\n * @returns True if the package should never be excluded.\n */\nexport function neverExclude(packageName: string, config: CloudpackConfig): boolean {\n // Set never exclude to the default if it is not set. Replace string '...' with default if set.\n const neverExcludeDependencies = config.neverExcludeDependencies ?? defaultNeverExcludeDependencies;\n if (neverExcludeDependencies.includes('...')) {\n neverExcludeDependencies.splice(neverExcludeDependencies.indexOf('...'), 1, ...defaultNeverExcludeDependencies);\n }\n\n return neverExcludeDependencies.includes(packageName);\n}\n"]}
@@ -1,7 +1,6 @@
1
1
  import { type ResolveMap } from '@ms-cloudpack/package-utilities';
2
2
  import { type BundleInfo } from '@ms-cloudpack/api-server';
3
- import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
4
- import type { CloudpackConfig, PackageJson } from '@ms-cloudpack/config-types';
3
+ import type { CloudpackConfig, PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/common-types';
5
4
  import type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';
6
5
  /**
7
6
  * Optimizes the dependencies of a package to determine if there are any missing or unused.
@@ -1 +1 @@
1
- {"version":3,"file":"optimizeDependencies.d.ts","sourceRoot":"","sources":["../../../src/commands/init/optimizeDependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAA2B,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAGlF;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE;IACP,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,UAAU,CAAC;CACxB,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;CACzB,GACA;IACD,iEAAiE;IACjE,2BAA2B,EAAE,uBAAuB,EAAE,CAAC;IACvD,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,4EAA4E;IAC5E,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,8GAA8G;IAC9G,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B,CAwEA"}
1
+ {"version":3,"file":"optimizeDependencies.d.ts","sourceRoot":"","sources":["../../../src/commands/init/optimizeDependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAA2B,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACxG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAGlF;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE;IACP,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,UAAU,CAAC;CACxB,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;CACzB,GACA;IACD,iEAAiE;IACjE,2BAA2B,EAAE,uBAAuB,EAAE,CAAC;IACvD,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,4EAA4E;IAC5E,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,8GAA8G;IAC9G,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B,CAwEA"}
@@ -1 +1 @@
1
- {"version":3,"file":"optimizeDependencies.js","sourceRoot":"","sources":["../../../src/commands/init/optimizeDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAmB,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAAE,uBAAuB,EAAmB,MAAM,0BAA0B,CAAC;AAIpF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAKC,EACD,OAGC;IAWD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,M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K,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE,EAAE;iBACxC,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,wBAAwB,GAAG;oBACzB,KAAK,EAAE,IAAI;iBACZ,CAAC;YACJ,CAAC;YACD,eAAe,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACjD,CAAC;QAED,wBAAwB,CAAC,oBAAoB,KAAK,EAAE,CAAC;QAErD,6DAA6D;QAC7D,IAAI,wBAAwB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YAC3E,SAAS;QACX,CAAC;QAED,wBAAwB,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAEnE,2BAA2B,CAAC,IAAI,CAAC;YAC/B,IAAI;YACJ,OAAO;YACP,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,qBAAqB;oBAC3B,MAAM,EAAE,cAAc;oBACtB,MAAM,EAAE,oBAAoB,WAAW,GAAG;iBAC3C;aACF;SACF,CAAC,CAAC;QAEH,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,2BAA2B,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AACpF,CAAC","sourcesContent":["import { getPackageSettings } from '@ms-cloudpack/config';\nimport { getDependencies, isExternalPackage, type ResolveMap } from '@ms-cloudpack/package-utilities';\nimport { getConsumedDependencies, type BundleInfo } from '@ms-cloudpack/api-server';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/config-types';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport { neverExclude } from './neverExclude.js';\n\n/**\n * Optimizes the dependencies of a package to determine if there are any missing or unused.\n * If so, adds the the missing dependencies to included and the unused dependencies to excluded.\n */\nexport function optimizeDependencies(\n options: {\n info: BundleInfo;\n definition: PackageJson;\n packagePath: string;\n resolveMap: ResolveMap;\n },\n context: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n },\n): {\n /** Excluded dependencies changes made to the generated config */\n excludedDependenciesChanges: GeneratedPackageChanges[];\n /** Any warnings encountered */\n warnings: string[];\n /** Set from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate: Set<string>;\n /** Package paths for which dependencies where included or excluded, so the package should be re-processed. */\n pathsToRefresh: Set<string>;\n} {\n const { info, definition, packagePath } = options;\n const { config } = context;\n const displayName = `${definition.name}@${definition.version}`;\n const excludedDependenciesChanges: GeneratedPackageChanges[] = [];\n const warnings: string[] = [];\n const pathsToEvaluate = new Set<string>();\n const pathsToRefresh = new Set<string>();\n\n const { name, version } = definition;\n if (!name || !version) {\n throw new Error(`Package \"${displayName}\" is missing a name or version.`);\n }\n\n const dependencies = getDependencies(definition);\n const consumedDependencies = getConsumedDependencies(info);\n\n // Iterate through dependencies and find unused.\n for (const dependencyName of Object.keys(dependencies)) {\n if (consumedDependencies.has(dependencyName) || neverExclude(dependencyName, config)) {\n continue;\n }\n\n pathsToEvaluate.add(packagePath);\n\n // Add to excludedDependencies\n const packageSettings = (config.generated.packageSettings ??= []);\n let generatedPackageSettings = getPackageSettings({\n config: { generated: { packageSettings } },\n name,\n version,\n firstMatch: true,\n }).generatedPackageSettings;\n\n if (!generatedPackageSettings) {\n if (isExternalPackage(packagePath)) {\n generatedPackageSettings = {\n match: { name, version: `^${version}` },\n };\n } else {\n generatedPackageSettings = {\n match: name,\n };\n }\n packageSettings.push(generatedPackageSettings);\n }\n\n generatedPackageSettings.excludedDependencies ??= [];\n\n // Add to includedDependencies if it is not already included.\n if (generatedPackageSettings.excludedDependencies.includes(dependencyName)) {\n continue;\n }\n\n generatedPackageSettings.excludedDependencies.push(dependencyName);\n\n excludedDependenciesChanges.push({\n name,\n version,\n path: packagePath,\n changes: [\n {\n type: 'excluded-dependency',\n change: dependencyName,\n reason: `Not imported by \"${displayName}\"`,\n },\n ],\n });\n\n pathsToRefresh.add(packagePath);\n }\n return { warnings, excludedDependenciesChanges, pathsToEvaluate, pathsToRefresh };\n}\n"]}
1
+ {"version":3,"file":"optimizeDependencies.js","sourceRoot":"","sources":["../../../src/commands/init/optimizeDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAmB,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAAE,uBAAuB,EAAmB,MAAM,0BAA0B,CAAC;AAGpF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAKC,EACD,OAGC;IAWD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,WAAW,GAAG,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;IAC/D,MAAM,2BAA2B,GAA8B,EAAE,CAAC;IAClE,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAC1C,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IAEzC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IACrC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,YAAY,WAAW,iCAAiC,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IACjD,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAE3D,gDAAgD;IAChD,KAAK,MAAM,cAAc,IAAI,MAA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,EAAE,cAAc;oBACtB,MAAM,EAAE,oBAAoB,WAAW,GAAG;iBAC3C;aACF;SACF,CAAC,CAAC;QAEH,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,2BAA2B,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AACpF,CAAC","sourcesContent":["import { getPackageSettings } from '@ms-cloudpack/config';\nimport { getDependencies, isExternalPackage, type ResolveMap } from '@ms-cloudpack/package-utilities';\nimport { getConsumedDependencies, type BundleInfo } from '@ms-cloudpack/api-server';\nimport type { CloudpackConfig, PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/common-types';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport { neverExclude } from './neverExclude.js';\n\n/**\n * Optimizes the dependencies of a package to determine if there are any missing or unused.\n * If so, adds the the missing dependencies to included and the unused dependencies to excluded.\n */\nexport function optimizeDependencies(\n options: {\n info: BundleInfo;\n definition: PackageJson;\n packagePath: string;\n resolveMap: ResolveMap;\n },\n context: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n },\n): {\n /** Excluded dependencies changes made to the generated config */\n excludedDependenciesChanges: GeneratedPackageChanges[];\n /** Any warnings encountered */\n warnings: string[];\n /** Set from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate: Set<string>;\n /** Package paths for which dependencies where included or excluded, so the package should be re-processed. */\n pathsToRefresh: Set<string>;\n} {\n const { info, definition, packagePath } = options;\n const { config } = context;\n const displayName = `${definition.name}@${definition.version}`;\n const excludedDependenciesChanges: GeneratedPackageChanges[] = [];\n const warnings: string[] = [];\n const pathsToEvaluate = new Set<string>();\n const pathsToRefresh = new Set<string>();\n\n const { name, version } = definition;\n if (!name || !version) {\n throw new Error(`Package \"${displayName}\" is missing a name or version.`);\n }\n\n const dependencies = getDependencies(definition);\n const consumedDependencies = getConsumedDependencies(info);\n\n // Iterate through dependencies and find unused.\n for (const dependencyName of Object.keys(dependencies)) {\n if (consumedDependencies.has(dependencyName) || neverExclude(dependencyName, config)) {\n continue;\n }\n\n pathsToEvaluate.add(packagePath);\n\n // Add to excludedDependencies\n const packageSettings = (config.generated.packageSettings ??= []);\n let generatedPackageSettings = getPackageSettings({\n config: { generated: { packageSettings } },\n name,\n version,\n firstMatch: true,\n }).generatedPackageSettings;\n\n if (!generatedPackageSettings) {\n if (isExternalPackage(packagePath)) {\n generatedPackageSettings = {\n match: { name, version: `^${version}` },\n };\n } else {\n generatedPackageSettings = {\n match: name,\n };\n }\n packageSettings.push(generatedPackageSettings);\n }\n\n generatedPackageSettings.excludedDependencies ??= [];\n\n // Add to includedDependencies if it is not already included.\n if (generatedPackageSettings.excludedDependencies.includes(dependencyName)) {\n continue;\n }\n\n generatedPackageSettings.excludedDependencies.push(dependencyName);\n\n excludedDependenciesChanges.push({\n name,\n version,\n path: packagePath,\n changes: [\n {\n type: 'excluded-dependency',\n change: dependencyName,\n reason: `Not imported by \"${displayName}\"`,\n },\n ],\n });\n\n pathsToRefresh.add(packagePath);\n }\n return { warnings, excludedDependenciesChanges, pathsToEvaluate, pathsToRefresh };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { BundleMessage } from '@ms-cloudpack/bundler-types';
1
+ import type { BundleMessage } from '@ms-cloudpack/common-types';
2
2
  import type { InitPackageIdentifier } from './InitPackageIdentifier.js';
3
3
  import type { BundleInfo } from '@ms-cloudpack/api-server';
4
4
  export interface InitPackageResult extends InitPackageIdentifier {
@@ -1 +1 @@
1
- {"version":3,"file":"InitPackageResult.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB"}
1
+ {"version":3,"file":"InitPackageResult.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"InitPackageResult.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResult.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMessage } from '@ms-cloudpack/bundler-types';\nimport type { InitPackageIdentifier } from './InitPackageIdentifier.js';\nimport type { BundleInfo } from '@ms-cloudpack/api-server';\n\nexport interface InitPackageResult extends InitPackageIdentifier {\n errors?: BundleMessage[];\n warnings?: BundleMessage[];\n info?: BundleInfo;\n}\n"]}
1
+ {"version":3,"file":"InitPackageResult.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResult.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMessage } from '@ms-cloudpack/common-types';\nimport type { InitPackageIdentifier } from './InitPackageIdentifier.js';\nimport type { BundleInfo } from '@ms-cloudpack/api-server';\n\nexport interface InitPackageResult extends InitPackageIdentifier {\n errors?: BundleMessage[];\n warnings?: BundleMessage[];\n info?: BundleInfo;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { BundleMessage } from '@ms-cloudpack/bundler-types';
1
+ import type { BundleMessage } from '@ms-cloudpack/common-types';
2
2
  import type { InitPackageIdentifier } from './InitPackageIdentifier.js';
3
3
  export interface InitPackageResultErrors extends InitPackageIdentifier {
4
4
  errors: BundleMessage[];
@@ -1 +1 @@
1
- {"version":3,"file":"InitPackageResultErrors.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResultErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB"}
1
+ {"version":3,"file":"InitPackageResultErrors.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResultErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"InitPackageResultErrors.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResultErrors.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMessage } from '@ms-cloudpack/bundler-types';\nimport type { InitPackageIdentifier } from './InitPackageIdentifier.js';\n\nexport interface InitPackageResultErrors extends InitPackageIdentifier {\n errors: BundleMessage[];\n}\n"]}
1
+ {"version":3,"file":"InitPackageResultErrors.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResultErrors.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMessage } from '@ms-cloudpack/common-types';\nimport type { InitPackageIdentifier } from './InitPackageIdentifier.js';\n\nexport interface InitPackageResultErrors extends InitPackageIdentifier {\n errors: BundleMessage[];\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { BundleMessage } from '@ms-cloudpack/bundler-types';
1
+ import type { BundleMessage } from '@ms-cloudpack/common-types';
2
2
  import type { InitPackageIdentifier } from './InitPackageIdentifier.js';
3
3
  export interface InitPackageResultWarnings extends InitPackageIdentifier {
4
4
  warnings: BundleMessage[];
@@ -1 +1 @@
1
- {"version":3,"file":"InitPackageResultWarnings.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResultWarnings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB;IACtE,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B"}
1
+ {"version":3,"file":"InitPackageResultWarnings.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResultWarnings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB;IACtE,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"InitPackageResultWarnings.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResultWarnings.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMessage } from '@ms-cloudpack/bundler-types';\nimport type { InitPackageIdentifier } from './InitPackageIdentifier.js';\n\nexport interface InitPackageResultWarnings extends InitPackageIdentifier {\n warnings: BundleMessage[];\n}\n"]}
1
+ {"version":3,"file":"InitPackageResultWarnings.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResultWarnings.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMessage } from '@ms-cloudpack/common-types';\nimport type { InitPackageIdentifier } from './InitPackageIdentifier.js';\n\nexport interface InitPackageResultWarnings extends InitPackageIdentifier {\n warnings: BundleMessage[];\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { InitPackageResult } from './types/InitPackageResult.js';
2
- import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
+ import type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';
3
3
  import type { Session } from '@ms-cloudpack//api-server';
4
4
  /**
5
5
  * Checks that the imports/exports of packages match.
@@ -1 +1 @@
1
- {"version":3,"file":"verifyExports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACjD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;CAClB,GACA,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAmH9B"}
1
+ {"version":3,"file":"verifyExports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACjD,OAAO,EAAE;IACP,QAAQ,E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CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,oBAAoB,EAAE,CAAC;YAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC3D,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;gBACvB,IAAI,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;aACvC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YAChC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,EAA2C;IAC/E,OAAO,gEAAgE,YAAY,CACjF,CAAC,sBAAsB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,QAAQ,EAAE,CAAC,EACjE,CAAC,CACF,IAAI,CAAC;AACR,CAAC","sourcesContent":["import { findResolveMapEntry, flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { bulletedList } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { Session } from '@ms-cloudpack//api-server';\n\n/**\n * Checks that the imports/exports of packages match.\n * To be called before `summarize`.\n * @param packageResults - The package results to check.\n * @param context - The context to use.\n */\nexport async function verifyExports(\n packageResults: Record<string, InitPackageResult>,\n context: {\n packages: PackageDefinitionsCache;\n session: Session;\n },\n): Promise<InitPackageResult[]> {\n const { packages, session } = context;\n const { config, resolveMap } = session;\n const allErrors: InitPackageResult[] = [];\n const packageResultsArray = Object.values(packageResults);\n\n // Iterate through each package\n for (const packagePath in packageResults) {\n const result = packageResults[packagePath];\n\n // Skip packages with errors\n if (!result || result.errors?.length) {\n continue;\n }\n\n const { info, name, version } = result;\n const definition = {\n name,\n version,\n path: packagePath,\n };\n\n const packageError: InitPackageResult = {\n ...definition,\n };\n // Makes sure that the errors array is initialized and typescript happy.\n packageError.errors = [];\n const missingExportsErrors: Record<string, Set<string>> = {};\n\n // Skip packages with no info\n if (!info?.entry) {\n continue;\n }\n\n // Iterate through each entry\n for (const [exportsEntry, required] of Object.entries(info.entry)) {\n const { consumes } = required;\n\n // Skip entries with no imports\n if (!consumes?.length) {\n continue;\n }\n\n // Iterate through each imported package\n for (const { packageName, importPath, names } of consumes) {\n const entry = findResolveMapEntry({ packageName, definition, resolveMap });\n\n // Skip if we can't find the imported package in the resolve map\n if (!entry) {\n continue;\n }\n\n const packageResult = packageResultsArray.find((r) => r.name === entry.name && r.version === entry.version);\n\n // Skip packages without information.\n if (!packageResult?.info?.entry) {\n continue;\n }\n\n let realImportPath: string;\n // Check if there is an entry for the import path.\n if (packageResult.info.entry[importPath]) {\n realImportPath = importPath;\n // Check again with '.js' extension.\n } else if (packageResult.info.entry[`${importPath}.js`]) {\n realImportPath = `${importPath}.js`;\n } else {\n // evaluateImportsForOverrides has already been run,\n // so if the export is missing it has tried to fix it and has already reported an error.\n // Skip if the imported package has no entry for the import path\n continue;\n }\n\n const { produces: importProduces } = packageResult.info.entry[realImportPath];\n\n // Skip if the import produces everything `*` because we can't check that.\n if (importProduces.includes('*')) {\n continue;\n }\n\n const missing = [];\n // Iterate through each imported name.\n for (const namedImport of names) {\n // Error if the imported name is not exported.\n if (namedImport !== '*' && !importProduces.includes(namedImport)) {\n missing.push(namedImport);\n }\n }\n\n // No missing exports found.\n if (!missing.length) {\n continue;\n }\n\n const exportsMapConsumed = await getExportsMap({ packagePath: entry.path }, { packages, config });\n const flattenedExportsMapConsumed = flattenExportsMap(exportsMapConsumed);\n const location = `\"${packageName}@${entry.version}\" (${path.join(entry.path, flattenedExportsMapConsumed[exportsEntry] || '')})`;\n missingExportsErrors[location] ??= new Set();\n missing.forEach((m) => missingExportsErrors[location].add(m));\n }\n }\n\n for (const location in missingExportsErrors) {\n const missing = Array.from(missingExportsErrors[location]);\n packageError.errors.push({\n text: errorText({ location, missing }),\n });\n }\n\n if (packageError.errors?.length) {\n allErrors.push(packageError);\n }\n }\n\n return allErrors;\n}\n\nfunction errorText({ location, missing }: { location: string; missing: string[] }) {\n return `Imported names are missing from external package's exports:\\n${bulletedList(\n [`Missing export(s): ${missing.join(', ')}`, `From: ${location}`],\n 2,\n )}\\n`;\n}\n"]}
1
+ {"version":3,"file":"verifyExports.js","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAKxB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,cAAiD,EACjD,OAGC;IAED,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAE1D,+BAA+B;IAC/B,KAAK,MAAM,WAAW,IAAI,cAAc,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;QAE3C,4BAA4B;QAC5B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YACrC,SAAS;QACX,CAAC;QAED,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QACvC,MAAM,UAAU,GAAG;YACjB,IAAI;YACJ,OAAO;YACP,IAAI,EAAE,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AC,QAAQ,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;gBAC7C,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,oBAAoB,EAAE,CAAC;YAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC3D,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;gBACvB,IAAI,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;aACvC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YAChC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,EAA2C;IAC/E,OAAO,gEAAgE,YAAY,CACjF,CAAC,sBAAsB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,QAAQ,EAAE,CAAC,EACjE,CAAC,CACF,IAAI,CAAC;AACR,CAAC","sourcesContent":["import { findResolveMapEntry, flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { bulletedList } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport type { Session } from '@ms-cloudpack//api-server';\n\n/**\n * Checks that the imports/exports of packages match.\n * To be called before `summarize`.\n * @param packageResults - The package results to check.\n * @param context - The context to use.\n */\nexport async function verifyExports(\n packageResults: Record<string, InitPackageResult>,\n context: {\n packages: PackageDefinitionsCache;\n session: Session;\n },\n): Promise<InitPackageResult[]> {\n const { packages, session } = context;\n const { config, resolveMap } = session;\n const allErrors: InitPackageResult[] = [];\n const packageResultsArray = Object.values(packageResults);\n\n // Iterate through each package\n for (const packagePath in packageResults) {\n const result = packageResults[packagePath];\n\n // Skip packages with errors\n if (!result || result.errors?.length) {\n continue;\n }\n\n const { info, name, version } = result;\n const definition = {\n name,\n version,\n path: packagePath,\n };\n\n const packageError: InitPackageResult = {\n ...definition,\n };\n // Makes sure that the errors array is initialized and typescript happy.\n packageError.errors = [];\n const missingExportsErrors: Record<string, Set<string>> = {};\n\n // Skip packages with no info\n if (!info?.entry) {\n continue;\n }\n\n // Iterate through each entry\n for (const [exportsEntry, required] of Object.entries(info.entry)) {\n const { consumes } = required;\n\n // Skip entries with no imports\n if (!consumes?.length) {\n continue;\n }\n\n // Iterate through each imported package\n for (const { packageName, importPath, names } of consumes) {\n const entry = findResolveMapEntry({ packageName, definition, resolveMap });\n\n // Skip if we can't find the imported package in the resolve map\n if (!entry) {\n continue;\n }\n\n const packageResult = packageResultsArray.find((r) => r.name === entry.name && r.version === entry.version);\n\n // Skip packages without information.\n if (!packageResult?.info?.entry) {\n continue;\n }\n\n let realImportPath: string;\n // Check if there is an entry for the import path.\n if (packageResult.info.entry[importPath]) {\n realImportPath = importPath;\n // Check again with '.js' extension.\n } else if (packageResult.info.entry[`${importPath}.js`]) {\n realImportPath = `${importPath}.js`;\n } else {\n // evaluateImportsForOverrides has already been run,\n // so if the export is missing it has tried to fix it and has already reported an error.\n // Skip if the imported package has no entry for the import path\n continue;\n }\n\n const { produces: importProduces } = packageResult.info.entry[realImportPath];\n\n // Skip if the import produces everything `*` because we can't check that.\n if (importProduces.includes('*')) {\n continue;\n }\n\n const missing = [];\n // Iterate through each imported name.\n for (const namedImport of names) {\n // Error if the imported name is not exported.\n if (namedImport !== '*' && !importProduces.includes(namedImport)) {\n missing.push(namedImport);\n }\n }\n\n // No missing exports found.\n if (!missing.length) {\n continue;\n }\n\n const exportsMapConsumed = await getExportsMap({ packagePath: entry.path }, { packages, config });\n const flattenedExportsMapConsumed = flattenExportsMap(exportsMapConsumed);\n const location = `\"${packageName}@${entry.version}\" (${path.join(entry.path, flattenedExportsMapConsumed[exportsEntry] || '')})`;\n missingExportsErrors[location] ??= new Set();\n missing.forEach((m) => missingExportsErrors[location].add(m));\n }\n }\n\n for (const location in missingExportsErrors) {\n const missing = Array.from(missingExportsErrors[location]);\n packageError.errors.push({\n text: errorText({ location, missing }),\n });\n }\n\n if (packageError.errors?.length) {\n allErrors.push(packageError);\n }\n }\n\n return allErrors;\n}\n\nfunction errorText({ location, missing }: { location: string; missing: string[] }) {\n return `Imported names are missing from external package's exports:\\n${bulletedList(\n [`Missing export(s): ${missing.join(', ')}`, `From: ${location}`],\n 2,\n )}\\n`;\n}\n"]}
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'url';
6
6
  import { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';
7
7
  import { getStartingAppPath } from './getStartingAppPath.js';
8
8
  import { openBrowser } from './openBrowser.js';
9
- import { runPrerequisites } from '../../common/runPrerequisites.js';
9
+ import { runPrerequisites } from '../../utilities/runPrerequisites.js';
10
10
  import { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';
11
11
  let exitFunction;
12
12
  /** Stop all started cloudpack instances, for testing */
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;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,EAAE,GAAG,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAClC,YAAY,GAAG,IAAI,CAAC;IAEpB,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,IAAI,EAAE,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAEpF,WAAW,CAAC,OAAO,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;IAEpE,oBAAoB;IACpB,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3B,WAAW,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACpC,sEAAsE;YACtE,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;AACH,CAAC,CAAC;AAEF,wBAAwB","sourcesContent":["import type { CommandAction, CommandActionParams } from '../../types/CommandAction.js';\nimport type { StartOptions } from './types/StartOptions.js';\n\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { resolve } from '@ms-cloudpack/package-utilities';\nimport { yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { openBrowser } from './openBrowser.js';\nimport { runPrerequisites } from '../../common/runPrerequisites.js';\nimport { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\n\nlet exitFunction: CommandActionParams<StartOptions>['exit'] | undefined;\n\n/** Stop all started cloudpack instances, for testing */\nexport async function stopServers() {\n if (exitFunction) {\n await exitFunction({ exitCode: 0, message: 'stopServers called' });\n exitFunction = undefined;\n }\n}\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { options, cwd, initialize, reporter, autoDispose, exit } = params;\n const appPath = await getStartingAppPath(cwd, options.app);\n const { config, telemetryClient } = await initialize({ appPath });\n\n console.log('App path:', yellow(appPath));\n\n runPrerequisites({ config, cwd: appPath, telemetryClient });\n\n const [apiContext] = autoDispose(\n await createPartialApiContext({\n appPath,\n config,\n reporter,\n telemetryClient,\n items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n overlayPath: await resolve('@ms-cloudpack/overlay', path.dirname(fileURLToPath(import.meta.url))),\n }),\n );\n const { packages, session, packageImportPaths } = apiContext;\n\n // Increment the session version if caching is disabled.\n if (options.cache === false) {\n session.incrementSessionVersion();\n }\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n if (!definition.name || !definition.version) {\n throw new Error(`The package.json at \"${appPath}\" did not have a name and/or version.`);\n }\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n telemetryClient.setSharedSpanAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n const { startApiServer } = await import('@ms-cloudpack/api-server');\n\n // Start api server for tracking status and handling remote requests.\n const apiServer = await startApiServer(apiContext);\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({\n input: { name: definition.name, version: definition.version },\n ctx: apiContext,\n });\n\n // Then start bundle and app servers for hosting the app.\n const { startBundleServer } = await import('@ms-cloudpack/bundle-server');\n const bundleServer = await startBundleServer({\n context: {\n ...apiContext,\n apiServer,\n disableCache: !options.cache,\n },\n });\n\n // Finally start the app server.\n const { startAppServer } = await import('@ms-cloudpack/app-server');\n const appServer = await startAppServer({\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n reporter,\n packages,\n packageImportPaths,\n packageHashes: apiContext.packageHashes,\n });\n\n const cleanup = async () => {\n const servers = [\n ['appServer', appServer] as const,\n ['apiServer', apiServer] as const,\n ['bundleServer', bundleServer] as const,\n ];\n\n await Promise.all(\n servers.map(async ([name, server]) => {\n console.info(`Closing ${name}: ${server.url}`);\n try {\n await server.close();\n console.info(`Closed ${name}: ${server.url}`);\n } catch (err) {\n console.warn('Error closing server:', err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n exitFunction = exit;\n\n const defaultUrl = new URL(config.devServer?.defaultPath || '', appServer.url).href;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n\n // Open the browser.\n if (options.open !== false) {\n openBrowser(defaultUrl).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n } else {\n console.log('Please open the browser manually to:', defaultUrl);\n }\n};\n\n// cspell:ignore Prereqs\n"]}
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,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AAC;IACJ,CAAC,CAAC;IAEF,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAClC,YAAY,GAAG,IAAI,CAAC;IAEpB,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,IAAI,EAAE,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAEpF,WAAW,CAAC,OAAO,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;IAEpE,oBAAoB;IACpB,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3B,WAAW,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACpC,sEAAsE;YACtE,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;AACH,CAAC,CAAC;AAEF,wBAAwB","sourcesContent":["import type { CommandAction, CommandActionParams } from '../../types/CommandAction.js';\nimport type { StartOptions } from './types/StartOptions.js';\n\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { resolve } from '@ms-cloudpack/package-utilities';\nimport { yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { openBrowser } from './openBrowser.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\n\nlet exitFunction: CommandActionParams<StartOptions>['exit'] | undefined;\n\n/** Stop all started cloudpack instances, for testing */\nexport async function stopServers() {\n if (exitFunction) {\n await exitFunction({ exitCode: 0, message: 'stopServers called' });\n exitFunction = undefined;\n }\n}\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { options, cwd, initialize, reporter, autoDispose, exit } = params;\n const appPath = await getStartingAppPath(cwd, options.app);\n const { config, telemetryClient } = await initialize({ appPath });\n\n console.log('App path:', yellow(appPath));\n\n runPrerequisites({ config, cwd: appPath, telemetryClient });\n\n const [apiContext] = autoDispose(\n await createPartialApiContext({\n appPath,\n config,\n reporter,\n telemetryClient,\n items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n overlayPath: await resolve('@ms-cloudpack/overlay', path.dirname(fileURLToPath(import.meta.url))),\n }),\n );\n const { packages, session, packageImportPaths } = apiContext;\n\n // Increment the session version if caching is disabled.\n if (options.cache === false) {\n session.incrementSessionVersion();\n }\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n if (!definition.name || !definition.version) {\n throw new Error(`The package.json at \"${appPath}\" did not have a name and/or version.`);\n }\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n telemetryClient.setSharedSpanAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n const { startApiServer } = await import('@ms-cloudpack/api-server');\n\n // Start api server for tracking status and handling remote requests.\n const apiServer = await startApiServer(apiContext);\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({\n input: { name: definition.name, version: definition.version },\n ctx: apiContext,\n });\n\n // Then start bundle and app servers for hosting the app.\n const { startBundleServer } = await import('@ms-cloudpack/bundle-server');\n const bundleServer = await startBundleServer({\n context: {\n ...apiContext,\n apiServer,\n disableCache: !options.cache,\n },\n });\n\n // Finally start the app server.\n const { startAppServer } = await import('@ms-cloudpack/app-server');\n const appServer = await startAppServer({\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n reporter,\n packages,\n packageImportPaths,\n packageHashes: apiContext.packageHashes,\n });\n\n const cleanup = async () => {\n const servers = [\n ['appServer', appServer] as const,\n ['apiServer', apiServer] as const,\n ['bundleServer', bundleServer] as const,\n ];\n\n await Promise.all(\n servers.map(async ([name, server]) => {\n console.info(`Closing ${name}: ${server.url}`);\n try {\n await server.close();\n console.info(`Closed ${name}: ${server.url}`);\n } catch (err) {\n console.warn('Error closing server:', err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n exitFunction = exit;\n\n const defaultUrl = new URL(config.devServer?.defaultPath || '', appServer.url).href;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n\n // Open the browser.\n if (options.open !== false) {\n openBrowser(defaultUrl).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n } else {\n console.log('Please open the browser manually to:', defaultUrl);\n }\n};\n\n// cspell:ignore Prereqs\n"]}
@@ -1,4 +1,4 @@
1
- import { findCloudpackAppPaths } from '../../common/findCloudpackAppPaths.js';
1
+ import { findCloudpackAppPaths } from '../../utilities/findCloudpackAppPaths.js';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { createPathToChoiceMap } from './createPathToChoiceMap.js';
@@ -1 +1 @@
1
- {"version":3,"file":"getStartingAppPath.js","sourceRoot":"","sources":["../../../src/commands/start/getStartingAppPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,GAAW,EAAE,UAAmB;IACvE,MAAM,iBAAiB,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAC/F,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,WAAW,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,GAAG,CAAC;IACb,CAAC;SAAM,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;SAAM,CAAC;QACN,MAAM,wBAAwB,GAAG,MAAM,qBAAqB,CAAC,WAAW,CAAC,CAAC;QAC1E,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;QAC/E,OAAO,OAAO,IAAI,GAAG,CAAC;IACxB,CAAC;AACH,CAAC","sourcesContent":["import { findCloudpackAppPaths } from '../../common/findCloudpackAppPaths.js';\nimport fs from 'fs';\nimport path from 'path';\nimport { createPathToChoiceMap } from './createPathToChoiceMap.js';\nimport { getAppPathFromUser } from './getAppPathFromUser.js';\n\n/**\n * Gets the appPath from which Cloudpack will start. If the CWD is a Cloudpack-enabled app,\n * we'll start there; otherwise, we'll scan for Cloudpack-enabled app and present the user\n * with a menu. If no app are found, Cloudpack will just try to start the CWD anyway.\n * @param cwd - The current working directory to start in when finding the starting app path\n * @param desiredApp - The app that should be started as specified via --app arg\n * @returns The app path of the app that Cloudpack should start\n */\nexport async function getStartingAppPath(cwd: string, desiredApp?: string) {\n const cwdIsCloudpackApp = fs.existsSync(path.resolve(path.join(cwd, 'cloudpack.config.json')));\n if (cwdIsCloudpackApp) {\n return cwd;\n }\n\n const folderPaths = findCloudpackAppPaths(cwd);\n if (folderPaths.length === 0) {\n return cwd;\n } else if (folderPaths.length === 1) {\n return folderPaths[0];\n } else {\n const pathToCloudpackConfigMap = await createPathToChoiceMap(folderPaths);\n const appPath = await getAppPathFromUser(pathToCloudpackConfigMap, desiredApp);\n return appPath ?? cwd;\n }\n}\n"]}
1
+ {"version":3,"file":"getStartingAppPath.js","sourceRoot":"","sources":["../../../src/commands/start/getStartingAppPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,GAAW,EAAE,UAAmB;IACvE,MAAM,iBAAiB,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAC/F,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,WAAW,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,GAAG,CAAC;IACb,CAAC;SAAM,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;SAAM,CAAC;QACN,MAAM,wBAAwB,GAAG,MAAM,qBAAqB,CAAC,WAAW,CAAC,CAAC;QAC1E,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;QAC/E,OAAO,OAAO,IAAI,GAAG,CAAC;IACxB,CAAC;AACH,CAAC","sourcesContent":["import { findCloudpackAppPaths } from '../../utilities/findCloudpackAppPaths.js';\nimport fs from 'fs';\nimport path from 'path';\nimport { createPathToChoiceMap } from './createPathToChoiceMap.js';\nimport { getAppPathFromUser } from './getAppPathFromUser.js';\n\n/**\n * Gets the appPath from which Cloudpack will start. If the CWD is a Cloudpack-enabled app,\n * we'll start there; otherwise, we'll scan for Cloudpack-enabled app and present the user\n * with a menu. If no app are found, Cloudpack will just try to start the CWD anyway.\n * @param cwd - The current working directory to start in when finding the starting app path\n * @param desiredApp - The app that should be started as specified via --app arg\n * @returns The app path of the app that Cloudpack should start\n */\nexport async function getStartingAppPath(cwd: string, desiredApp?: string) {\n const cwdIsCloudpackApp = fs.existsSync(path.resolve(path.join(cwd, 'cloudpack.config.json')));\n if (cwdIsCloudpackApp) {\n return cwd;\n }\n\n const folderPaths = findCloudpackAppPaths(cwd);\n if (folderPaths.length === 0) {\n return cwd;\n } else if (folderPaths.length === 1) {\n return folderPaths[0];\n } else {\n const pathToCloudpackConfigMap = await createPathToChoiceMap(folderPaths);\n const appPath = await getAppPathFromUser(pathToCloudpackConfigMap, desiredApp);\n return appPath ?? cwd;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlE,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CA2D9C,CAAC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlE,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CAyD9C,CAAC"}
@@ -1,19 +1,17 @@
1
1
  import { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server';
2
- import { runPrerequisites } from '../../common/runPrerequisites.js';
2
+ import { runPrerequisites } from '../../utilities/runPrerequisites.js';
3
3
  import { isSyncDisabledByUser } from './isSyncDisabledByUser.js';
4
4
  export const execute = async (params) => {
5
5
  const { options, cwd, reporter, initialize, exit, autoDispose } = params;
6
6
  const { login, upload } = options;
7
7
  const { config, telemetryClient } = await initialize({ appPath: cwd });
8
8
  if (!config.features?.syncBundles) {
9
- console.warn('Sync is disabled.');
10
- await exit({ exitCode: 0 });
9
+ await exit({ message: 'Sync is disabled' });
11
10
  return;
12
11
  }
13
12
  if (isSyncDisabledByUser()) {
14
13
  telemetryClient.rootSpan.setAttribute('syncDisabled', true);
15
- console.warn('CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.');
16
- await exit({ exitCode: 0 });
14
+ await exit({ message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' });
17
15
  return;
18
16
  }
19
17
  try {
@@ -41,7 +39,7 @@ export const execute = async (params) => {
41
39
  }));
42
40
  await syncDownload({ input, ctx });
43
41
  }
44
- await exit({ exitCode: 0 });
42
+ await exit({ message: 'Sync complete' });
45
43
  }
46
44
  catch (error) {
47
45
  if (error instanceof Error) {
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BA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E,eAAe,EAAE,CAAC,CAAC;YAEnD,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CACvB,MAAM,uBAAuB,CAAC;gBAC5B,GAAG,iBAAiB;gBACpB,KAAK,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,oBAAoB,EAAE,eAAe,CAAC;aACtG,CAAC,CACH,CAAC;YACF,MAAM,UAAU,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CACvB,MAAM,uBAAuB,CAAC;gBAC5B,GAAG,iBAAiB;gBACpB,KAAK,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,eAAe,CAAC;aAChD,CAAC,CACH,CAAC;YACF,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SyncOptions } from './types/SyncOptions.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server';\nimport { runPrerequisites } from '../../common/runPrerequisites.js';\nimport { isSyncDisabledByUser } from './isSyncDisabledByUser.js';\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, cwd, reporter, initialize, exit, autoDispose } = params;\n const { login, upload } = options;\n const { config, telemetryClient } = await initialize({ appPath: cwd });\n\n if (!config.features?.syncBundles) {\n console.warn('Sync is disabled.');\n await exit({ exitCode: 0 });\n return;\n }\n\n if (isSyncDisabledByUser()) {\n telemetryClient.rootSpan.setAttribute('syncDisabled', true);\n console.warn('CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.');\n await exit({ exitCode: 0 });\n return;\n }\n\n try {\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n console.warn(\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n );\n return;\n }\n\n const input = {\n loginMethod: login,\n };\n\n const apiContextOptions = { appPath: cwd, config, reporter, telemetryClient };\n if (upload) {\n runPrerequisites({ config, cwd, telemetryClient });\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n await syncDownload({ input, ctx });\n }\n\n await exit({ exitCode: 0 });\n } catch (error) {\n if (error instanceof Error) {\n telemetryClient.rootSpan.recordException(error);\n }\n throw error;\n }\n};\n"]}
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACzE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClC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AAC,GAAG,CAAC,GAAG,WAAW,CACvB,MAAM,uBAAuB,CAAC;gBAC5B,GAAG,iBAAiB;gBACpB,KAAK,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,eAAe,CAAC;aAChD,CAAC,CACH,CAAC;YACF,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,IAAI,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SyncOptions } from './types/SyncOptions.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { isSyncDisabledByUser } from './isSyncDisabledByUser.js';\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, cwd, reporter, initialize, exit, autoDispose } = params;\n const { login, upload } = options;\n const { config, telemetryClient } = await initialize({ appPath: cwd });\n\n if (!config.features?.syncBundles) {\n await exit({ message: 'Sync is disabled' });\n return;\n }\n\n if (isSyncDisabledByUser()) {\n telemetryClient.rootSpan.setAttribute('syncDisabled', true);\n await exit({ message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' });\n return;\n }\n\n try {\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n console.warn(\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n );\n return;\n }\n\n const input = {\n loginMethod: login,\n };\n\n const apiContextOptions = { appPath: cwd, config, reporter, telemetryClient };\n if (upload) {\n runPrerequisites({ config, cwd, telemetryClient });\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n await syncDownload({ input, ctx });\n }\n\n await exit({ message: 'Sync complete' });\n } catch (error) {\n if (error instanceof Error) {\n telemetryClient.rootSpan.recordException(error);\n }\n throw error;\n }\n};\n"]}
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ import { globSourceFiles } from '@ms-cloudpack/path-utilities';
3
3
  import path from 'path';
4
4
  import { fileURLToPath, pathToFileURL } from 'url';
5
5
  import { PerfMarkerCliEntry } from './performance/markers.js';
6
- import { CloudpackCommand } from './common/CloudpackCommand.js';
6
+ import { CloudpackCommand } from './utilities/CloudpackCommand.js';
7
7
  /**
8
8
  * Entry point for the cloudpack CLI.
9
9
  * Resolves all commands defined within the "./commands" folder.
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAUhE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,UAAgC,EAAE;IAC3D,MAAM,EACJ,IAAI,GAAG,OAAO,CAAC,IAAI;IACnB,6FAA6F;IAC7F,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EACnB,gBAAgB,EAChB,aAAa,GACd,GAAG,OAAO,CAAC;IAEZ,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAErC,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEnD,wDAAwD;IACxD,uEAAuE;IACvE,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC;QACnC,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,uFAAuF;QACpG,KAAK,EAAE,qBAAqB;QAC5B,aAAa;QACb,cAAc,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE;KACzD,CAAC,CAAC;IAEH,iCAAiC;IACjC,MAAM,YAAY,GAAG,kBAAkB,CAAC;IACxC,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACtE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,+BAA+B,UAAU,IAAI,YAAY,MAAM,CAAC,CAAC;IACnF,CAAC;IAED,KAAK,MAAM,WAAW,IAAI,QAAQ,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QACzD,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAsB,CAAC;QAEtE,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC","sourcesContent":["import { getDisplayVersion } from '@ms-cloudpack/package-utilities';\nimport { globSourceFiles } from '@ms-cloudpack/path-utilities';\nimport type { OutputConfiguration } from 'commander';\nimport path from 'path';\nimport { fileURLToPath, pathToFileURL } from 'url';\nimport type { CommandInitModule } from './types/CommandInitFunction.js';\nimport { PerfMarkerCliEntry } from './performance/markers.js';\nimport { CloudpackCommand } from './common/CloudpackCommand.js';\n\n/** Override options for tests */\nexport interface MainOptions {\n cwd?: string;\n disableTelemetry?: boolean;\n argv?: string[];\n outputOptions?: OutputConfiguration;\n}\n\n/**\n * Entry point for the cloudpack CLI.\n * Resolves all commands defined within the \"./commands\" folder.\n */\nexport async function main(options: Partial<MainOptions> = {}) {\n const {\n argv = process.argv,\n // eslint-disable-next-line no-restricted-properties -- this is where the default is supplied\n cwd = process.cwd(),\n disableTelemetry,\n outputOptions,\n } = options;\n\n performance.mark(PerfMarkerCliEntry);\n\n const version = getDisplayVersion(import.meta.url);\n\n // Create the top-level command and apply common options\n // (avoids \"unknown option\" errors if they're specified without a verb)\n const program = new CloudpackCommand({\n name: 'cloudpack',\n description: 'A tool for managing fast inner and outer looping in web apps. Requires a sub-command.',\n usage: '<command> [options]',\n outputOptions,\n programOptions: { cwd, version, argv, disableTelemetry },\n });\n\n // Get all the available commands\n const commandsGlob = 'commands/*/index';\n const commands = await globSourceFiles(import.meta.url, commandsGlob);\n if (!commands.length) {\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n throw new Error(`No commands found matching \"${currentDir}/${commandsGlob}.*\".`);\n }\n\n for (const commandPath of commands) {\n const commandUrl = pathToFileURL(commandPath).toString();\n const commandModule = (await import(commandUrl)) as CommandInitModule;\n\n commandModule.init(program);\n }\n\n await program.run();\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,aAAa,EAA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C,CAAC,QAAQ,EAAE,CAAC;QACzD,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAsB,CAAC;QAEtE,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC","sourcesContent":["import { getDisplayVersion } from '@ms-cloudpack/package-utilities';\nimport { globSourceFiles } from '@ms-cloudpack/path-utilities';\nimport type { OutputConfiguration } from 'commander';\nimport path from 'path';\nimport { fileURLToPath, pathToFileURL } from 'url';\nimport type { CommandInitModule } from './types/CommandInitFunction.js';\nimport { PerfMarkerCliEntry } from './performance/markers.js';\nimport { CloudpackCommand } from './utilities/CloudpackCommand.js';\n\n/** Override options for tests */\nexport interface MainOptions {\n cwd?: string;\n disableTelemetry?: boolean;\n argv?: string[];\n outputOptions?: OutputConfiguration;\n}\n\n/**\n * Entry point for the cloudpack CLI.\n * Resolves all commands defined within the \"./commands\" folder.\n */\nexport async function main(options: Partial<MainOptions> = {}) {\n const {\n argv = process.argv,\n // eslint-disable-next-line no-restricted-properties -- this is where the default is supplied\n cwd = process.cwd(),\n disableTelemetry,\n outputOptions,\n } = options;\n\n performance.mark(PerfMarkerCliEntry);\n\n const version = getDisplayVersion(import.meta.url);\n\n // Create the top-level command and apply common options\n // (avoids \"unknown option\" errors if they're specified without a verb)\n const program = new CloudpackCommand({\n name: 'cloudpack',\n description: 'A tool for managing fast inner and outer looping in web apps. Requires a sub-command.',\n usage: '<command> [options]',\n outputOptions,\n programOptions: { cwd, version, argv, disableTelemetry },\n });\n\n // Get all the available commands\n const commandsGlob = 'commands/*/index';\n const commands = await globSourceFiles(import.meta.url, commandsGlob);\n if (!commands.length) {\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n throw new Error(`No commands found matching \"${currentDir}/${commandsGlob}.*\".`);\n }\n\n for (const commandPath of commands) {\n const commandUrl = pathToFileURL(commandPath).toString();\n const commandModule = (await import(commandUrl)) as CommandInitModule;\n\n commandModule.init(program);\n }\n\n await program.run();\n}\n"]}
@@ -1,14 +1,20 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  import type { TaskReporter } from '@ms-cloudpack/task-reporter';
3
- import type { CloudpackConfig } from '@ms-cloudpack/config-types';
3
+ import type { CloudpackConfig } from '@ms-cloudpack/common-types';
4
4
  import type { TelemetryClient } from '@ms-cloudpack/telemetry';
5
5
  import type { AutoDispose } from './AutoDispose.js';
6
6
  import type { SharedOptions } from './SharedOptions.js';
7
- export type InitContext = {
7
+ /** Context for running a command in a specific app (after initialization). */
8
+ export type AppCommandContext = {
8
9
  appPath: string;
9
10
  telemetryClient: TelemetryClient;
10
11
  config: CloudpackConfig;
11
12
  };
13
+ export interface CommandExitParams {
14
+ message: string;
15
+ hasErrors?: boolean;
16
+ exitCode?: number;
17
+ }
12
18
  export interface CommandActionParams<TOptions extends object> {
13
19
  /**
14
20
  * Initial working directory (usually `process.cwd()` except in tests).
@@ -35,29 +41,31 @@ export interface CommandActionParams<TOptions extends object> {
35
41
  autoDispose: AutoDispose;
36
42
  /**
37
43
  * This should be called at or near the beginning of the action to initialize the config,
38
- * telemetry, and reporting. (See `createInitializeFunction` for implementation.)
44
+ * telemetry, and reporting. (See `CommandExecutor._initialize` for implementation.)
39
45
  * `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.
40
- * If it is called with a single string, it returns `Promise<InitContext>`
41
- * If it is called with a string[], it returns `Promise<InitContext[]>`
46
+ *
47
+ * If it is called with a single string, it returns `Promise<AppCommandContext>`
48
+ * If it is called with a string[], it returns `Promise<AppCommandContext[]>`
42
49
  */
43
50
  initialize: {
44
51
  (initializeOptions: {
45
52
  appPath: string;
46
53
  overrideOptions?: Partial<SharedOptions>;
47
- }): Promise<InitContext>;
54
+ }): Promise<AppCommandContext>;
48
55
  (initializeOptions: {
49
56
  appPaths: string[];
50
57
  overrideOptions?: Partial<SharedOptions>;
51
- }): Promise<InitContext[]>;
58
+ }): Promise<AppCommandContext[]>;
52
59
  };
53
60
  /**
54
61
  * This should be called at the end of the action to dispose resources, log completion,
55
- * and exit the program. (See `createExitFunction` for implementation.)
62
+ * and exit the program. (See `CommandExecutor._exit` for implementation.)
63
+ */
64
+ exit: (result: CommandExitParams) => Promise<void>;
65
+ /**
66
+ * Set a callback to get the message to display if ctrl+C is pressed.
56
67
  */
57
- exit: (result: {
58
- exitCode: number;
59
- message?: string;
60
- }) => Promise<void>;
68
+ setInterruptMessageHandler: (getMessage: () => string) => void;
61
69
  }
62
70
  /**
63
71
  * Command action function. This is the type of the `execute` function which should be exported
@@ -1 +1 @@
1
- {"version":3,"file":"CommandAction.d.ts","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,eAAe,CAAC;IACjC,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,MAAM;IAC1D;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,OAAO,EAAE,QAAQ,CAAC;IAElB;;;OAGG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,QAAQ,EAAE,YAAY,CAAC;IAEvB,WAAW,EAAE,WAAW,CAAC;IAEzB;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;;;;;OAMG;IACH,UAAU,EAAE;QACV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,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CAClC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandAction.js","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"","sourcesContent":["import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { AutoDispose } from './AutoDispose.js';\nimport type { SharedOptions } from './SharedOptions.js';\n\nexport type InitContext = {\n appPath: string;\n telemetryClient: TelemetryClient;\n config: CloudpackConfig;\n};\n\nexport interface CommandActionParams<TOptions extends object> {\n /**\n * Initial working directory (usually `process.cwd()` except in tests).\n * Note that this may differ from the `appPath` used by individual commands.\n */\n cwd: string;\n\n /**\n * Command-specific options, parsed from `process.argv`.\n * Types are generally defined in each command's `src/commands/<name>/types/<Name>Types.ts` module.\n * The command line options are defined in each command's `src/commands/<name>/index.ts` module.\n */\n options: TOptions;\n\n /**\n * Command-specific arguments. Arguments in commander are positional arguments that are not options.\n * For example, in `echo somestring`, `somestring` is an argument.\n */\n args: string[];\n\n reporter: TaskReporter;\n\n abortSignal: AbortSignal;\n\n /**\n * Function that can be called with any `Disposable`s that should be cleaned up automatically\n * when the program exits. (See `AutoDisposableList.add` for implementation.)\n */\n autoDispose: AutoDispose;\n\n /**\n * This should be called at or near the beginning of the action to initialize the config,\n * telemetry, and reporting. (See `createInitializeFunction` for implementation.)\n * `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.\n * If it is called with a single string, it returns `Promise<InitContext>`\n * If it is called with a string[], it returns `Promise<InitContext[]>`\n */\n initialize: {\n (initializeOptions: { appPath: string; overrideOptions?: Partial<SharedOptions> }): Promise<InitContext>;\n (initializeOptions: { appPaths: string[]; overrideOptions?: Partial<SharedOptions> }): Promise<InitContext[]>;\n };\n\n /**\n * This should be called at the end of the action to dispose resources, log completion,\n * and exit the program. (See `createExitFunction` for implementation.)\n */\n exit: (result: { exitCode: number; message?: string }) => Promise<void>;\n}\n\n/**\n * Command action function. This is the type of the `execute` function which should be exported\n * from each command's `src/commands/<name>/execute.ts` module.\n */\nexport type CommandAction<TOptions> = (params: CommandActionParams<TOptions & SharedOptions>) => Promise<void>;\n\nexport type CommandActionModule<TOptions> = {\n execute: CommandAction<TOptions>;\n};\n"]}
1
+ {"version":3,"file":"CommandAction.js","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"","sourcesContent":["import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/common-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { AutoDispose } from './AutoDispose.js';\nimport type { SharedOptions } from './SharedOptions.js';\n\n/** Context for running a command in a specific app (after initialization). */\nexport type AppCommandContext = {\n appPath: string;\n telemetryClient: TelemetryClient;\n config: CloudpackConfig;\n};\n\nexport interface CommandExitParams {\n message: string;\n hasErrors?: boolean;\n exitCode?: number;\n}\n\nexport interface CommandActionParams<TOptions extends object> {\n /**\n * Initial working directory (usually `process.cwd()` except in tests).\n * Note that this may differ from the `appPath` used by individual commands.\n */\n cwd: string;\n\n /**\n * Command-specific options, parsed from `process.argv`.\n * Types are generally defined in each command's `src/commands/<name>/types/<Name>Types.ts` module.\n * The command line options are defined in each command's `src/commands/<name>/index.ts` module.\n */\n options: TOptions;\n\n /**\n * Command-specific arguments. Arguments in commander are positional arguments that are not options.\n * For example, in `echo somestring`, `somestring` is an argument.\n */\n args: string[];\n\n reporter: TaskReporter;\n\n abortSignal: AbortSignal;\n\n /**\n * Function that can be called with any `Disposable`s that should be cleaned up automatically\n * when the program exits. (See `AutoDisposableList.add` for implementation.)\n */\n autoDispose: AutoDispose;\n\n /**\n * This should be called at or near the beginning of the action to initialize the config,\n * telemetry, and reporting. (See `CommandExecutor._initialize` for implementation.)\n * `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.\n *\n * If it is called with a single string, it returns `Promise<AppCommandContext>`\n * If it is called with a string[], it returns `Promise<AppCommandContext[]>`\n */\n initialize: {\n (initializeOptions: { appPath: string; overrideOptions?: Partial<SharedOptions> }): Promise<AppCommandContext>;\n (initializeOptions: { appPaths: string[]; overrideOptions?: Partial<SharedOptions> }): Promise<AppCommandContext[]>;\n };\n\n /**\n * This should be called at the end of the action to dispose resources, log completion,\n * and exit the program. (See `CommandExecutor._exit` for implementation.)\n */\n exit: (result: CommandExitParams) => Promise<void>;\n\n /**\n * Set a callback to get the message to display if ctrl+C is pressed.\n */\n setInterruptMessageHandler: (getMessage: () => string) => void;\n}\n\n/**\n * Command action function. This is the type of the `execute` function which should be exported\n * from each command's `src/commands/<name>/execute.ts` module.\n */\nexport type CommandAction<TOptions> = (params: CommandActionParams<TOptions & SharedOptions>) => Promise<void>;\n\nexport type CommandActionModule<TOptions> = {\n execute: CommandAction<TOptions>;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { CloudpackCommand } from '../common/CloudpackCommand.js';
1
+ import type { CloudpackCommand } from '../utilities/CloudpackCommand.js';
2
2
  /**
3
3
  * Initialize a command object for a sub-command.
4
4
  * This is the type for the `init` function exported by each `src/commands/<name>/index.ts` module.
@@ -1 +1 @@
1
- {"version":3,"file":"CommandInitFunction.d.ts","sourceRoot":"","sources":["../../src/types/CommandInitFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AAEtF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,mBAAmB,CAAC;CAC3B,CAAC"}
1
+ {"version":3,"file":"CommandInitFunction.d.ts","sourceRoot":"","sources":["../../src/types/CommandInitFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEzE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AAEtF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,mBAAmB,CAAC;CAC3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandInitFunction.js","sourceRoot":"","sources":["../../src/types/CommandInitFunction.ts"],"names":[],"mappings":"","sourcesContent":["import type { CloudpackCommand } from '../common/CloudpackCommand.js';\n\n/**\n * Initialize a command object for a sub-command.\n * This is the type for the `init` function exported by each `src/commands/<name>/index.ts` module.\n * @param program Command object for the program.\n */\nexport type CommandInitFunction = (program: CloudpackCommand<object, object>) => void;\n\n/**\n * Type for each `src/commands/<name>/index.ts` module.\n */\nexport type CommandInitModule = {\n init: CommandInitFunction;\n};\n"]}
1
+ {"version":3,"file":"CommandInitFunction.js","sourceRoot":"","sources":["../../src/types/CommandInitFunction.ts"],"names":[],"mappings":"","sourcesContent":["import type { CloudpackCommand } from '../utilities/CloudpackCommand.js';\n\n/**\n * Initialize a command object for a sub-command.\n * This is the type for the `init` function exported by each `src/commands/<name>/index.ts` module.\n * @param program Command object for the program.\n */\nexport type CommandInitFunction = (program: CloudpackCommand<object, object>) => void;\n\n/**\n * Type for each `src/commands/<name>/index.ts` module.\n */\nexport type CommandInitModule = {\n init: CommandInitFunction;\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoDisposableList.d.ts","sourceRoot":"","sources":["../../src/utilities/AutoDisposableList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAEzC,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE;IAKjC,OAAO;CAOrB"}