@ms-cloudpack/cli 0.45.3 → 0.46.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 (134) hide show
  1. package/lib/commands/bundle/execute.d.ts +4 -0
  2. package/lib/commands/bundle/execute.d.ts.map +1 -0
  3. package/lib/commands/bundle/{bundle.js → execute.js} +14 -15
  4. package/lib/commands/bundle/execute.js.map +1 -0
  5. package/lib/commands/bundle/index.d.ts.map +1 -1
  6. package/lib/commands/bundle/index.js +4 -2
  7. package/lib/commands/bundle/index.js.map +1 -1
  8. package/lib/commands/init/bundleAndGetImports.d.ts.map +1 -1
  9. package/lib/commands/init/bundleAndGetImports.js +3 -1
  10. package/lib/commands/init/bundleAndGetImports.js.map +1 -1
  11. package/lib/commands/init/execute.d.ts +5 -0
  12. package/lib/commands/init/execute.d.ts.map +1 -0
  13. package/lib/commands/init/execute.js +14 -0
  14. package/lib/commands/init/execute.js.map +1 -0
  15. package/lib/commands/init/index.d.ts.map +1 -1
  16. package/lib/commands/init/index.js +4 -2
  17. package/lib/commands/init/index.js.map +1 -1
  18. package/lib/commands/init/init.d.ts +11 -5
  19. package/lib/commands/init/init.d.ts.map +1 -1
  20. package/lib/commands/init/init.js +79 -102
  21. package/lib/commands/init/init.js.map +1 -1
  22. package/lib/commands/start/{start.d.ts → execute.d.ts} +3 -3
  23. package/lib/commands/start/execute.d.ts.map +1 -0
  24. package/lib/commands/start/execute.js +127 -0
  25. package/lib/commands/start/execute.js.map +1 -0
  26. package/lib/commands/start/index.d.ts.map +1 -1
  27. package/lib/commands/start/index.js +4 -2
  28. package/lib/commands/start/index.js.map +1 -1
  29. package/lib/commands/start/startBundleServer.d.ts +1 -1
  30. package/lib/commands/start/startBundleServer.d.ts.map +1 -1
  31. package/lib/commands/start/startBundleServer.js +6 -19
  32. package/lib/commands/start/startBundleServer.js.map +1 -1
  33. package/lib/commands/sync/execute.d.ts +4 -0
  34. package/lib/commands/sync/execute.d.ts.map +1 -0
  35. package/lib/commands/sync/execute.js +31 -0
  36. package/lib/commands/sync/execute.js.map +1 -0
  37. package/lib/commands/sync/index.d.ts.map +1 -1
  38. package/lib/commands/sync/index.js +4 -5
  39. package/lib/commands/sync/index.js.map +1 -1
  40. package/lib/common/AutoDisposableList.d.ts +7 -0
  41. package/lib/common/AutoDisposableList.d.ts.map +1 -0
  42. package/lib/common/AutoDisposableList.js +17 -0
  43. package/lib/common/AutoDisposableList.js.map +1 -0
  44. package/lib/common/createCommandActionFunction.d.ts +14 -0
  45. package/lib/common/createCommandActionFunction.d.ts.map +1 -0
  46. package/lib/common/createCommandActionFunction.js +66 -0
  47. package/lib/common/createCommandActionFunction.js.map +1 -0
  48. package/lib/common/createExitFunction.d.ts +12 -0
  49. package/lib/common/createExitFunction.d.ts.map +1 -0
  50. package/lib/common/createExitFunction.js +17 -0
  51. package/lib/common/createExitFunction.js.map +1 -0
  52. package/lib/common/createInitializeFunction.d.ts +10 -0
  53. package/lib/common/createInitializeFunction.d.ts.map +1 -0
  54. package/lib/common/createInitializeFunction.js +21 -0
  55. package/lib/common/createInitializeFunction.js.map +1 -0
  56. package/lib/index.d.ts +1 -1
  57. package/lib/index.d.ts.map +1 -1
  58. package/lib/index.js +6 -5
  59. package/lib/index.js.map +1 -1
  60. package/lib/initTelemetry.js +1 -1
  61. package/lib/initTelemetry.js.map +1 -1
  62. package/lib/performance/markers.d.ts +0 -16
  63. package/lib/performance/markers.d.ts.map +1 -1
  64. package/lib/performance/markers.js +0 -16
  65. package/lib/performance/markers.js.map +1 -1
  66. package/lib/performance/registerPerformanceObservers.d.ts +2 -2
  67. package/lib/performance/registerPerformanceObservers.d.ts.map +1 -1
  68. package/lib/performance/registerPerformanceObservers.js +5 -8
  69. package/lib/performance/registerPerformanceObservers.js.map +1 -1
  70. package/lib/setupReporting.d.ts +7 -2
  71. package/lib/setupReporting.d.ts.map +1 -1
  72. package/lib/setupReporting.js +3 -2
  73. package/lib/setupReporting.js.map +1 -1
  74. package/lib/tasks/bundleTaskWorker.d.ts.map +1 -1
  75. package/lib/tasks/bundleTaskWorker.js +6 -2
  76. package/lib/tasks/bundleTaskWorker.js.map +1 -1
  77. package/lib/types/AutoDispose.d.ts +3 -0
  78. package/lib/types/AutoDispose.d.ts.map +1 -0
  79. package/lib/types/AutoDispose.js +2 -0
  80. package/lib/types/AutoDispose.js.map +1 -0
  81. package/lib/types/CommandAction.d.ts +21 -0
  82. package/lib/types/CommandAction.d.ts.map +1 -0
  83. package/lib/types/CommandAction.js +2 -0
  84. package/lib/types/CommandAction.js.map +1 -0
  85. package/lib/types/CommandContext.d.ts +10 -0
  86. package/lib/types/CommandContext.d.ts.map +1 -0
  87. package/lib/types/CommandContext.js +2 -0
  88. package/lib/types/CommandContext.js.map +1 -0
  89. package/lib/types/CommandFunction.d.ts +2 -2
  90. package/lib/types/CommandFunction.d.ts.map +1 -1
  91. package/lib/types/CommandFunction.js.map +1 -1
  92. package/lib/types/CreateCommandActionOptions.d.ts +7 -0
  93. package/lib/types/CreateCommandActionOptions.d.ts.map +1 -0
  94. package/lib/types/CreateCommandActionOptions.js +2 -0
  95. package/lib/types/CreateCommandActionOptions.js.map +1 -0
  96. package/lib/types/Disposable.d.ts +4 -0
  97. package/lib/types/Disposable.d.ts.map +1 -0
  98. package/lib/types/Disposable.js +2 -0
  99. package/lib/types/Disposable.js.map +1 -0
  100. package/package.json +8 -11
  101. package/lib/commands/bundle/bundle.d.ts +0 -4
  102. package/lib/commands/bundle/bundle.d.ts.map +0 -1
  103. package/lib/commands/bundle/bundle.js.map +0 -1
  104. package/lib/commands/start/parseRequestInfo.d.ts +0 -7
  105. package/lib/commands/start/parseRequestInfo.d.ts.map +0 -1
  106. package/lib/commands/start/parseRequestInfo.js +0 -14
  107. package/lib/commands/start/parseRequestInfo.js.map +0 -1
  108. package/lib/commands/start/start.d.ts.map +0 -1
  109. package/lib/commands/start/start.js +0 -149
  110. package/lib/commands/start/start.js.map +0 -1
  111. package/lib/commands/sync/sync.d.ts +0 -4
  112. package/lib/commands/sync/sync.d.ts.map +0 -1
  113. package/lib/commands/sync/sync.js +0 -53
  114. package/lib/commands/sync/sync.js.map +0 -1
  115. package/lib/common/createPartialApiContext.d.ts +0 -14
  116. package/lib/common/createPartialApiContext.d.ts.map +0 -1
  117. package/lib/common/createPartialApiContext.js +0 -101
  118. package/lib/common/createPartialApiContext.js.map +0 -1
  119. package/lib/common/createSession.d.ts +0 -13
  120. package/lib/common/createSession.d.ts.map +0 -1
  121. package/lib/common/createSession.js +0 -62
  122. package/lib/common/createSession.js.map +0 -1
  123. package/lib/common/prepareOutputPath.d.ts +0 -5
  124. package/lib/common/prepareOutputPath.d.ts.map +0 -1
  125. package/lib/common/prepareOutputPath.js +0 -14
  126. package/lib/common/prepareOutputPath.js.map +0 -1
  127. package/lib/tasks/resolveDependenciesTask.d.ts +0 -16
  128. package/lib/tasks/resolveDependenciesTask.d.ts.map +0 -1
  129. package/lib/tasks/resolveDependenciesTask.js +0 -69
  130. package/lib/tasks/resolveDependenciesTask.js.map +0 -1
  131. package/lib/types/TaskContext.d.ts +0 -8
  132. package/lib/types/TaskContext.d.ts.map +0 -1
  133. package/lib/types/TaskContext.js +0 -2
  134. package/lib/types/TaskContext.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ import type { CommandAction } from '../../types/CommandAction.js';
2
+ import type { BundleOptions } from './types/BundleOptions.js';
3
+ export declare const execute: CommandAction<BundleOptions>;
4
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,CAuChD,CAAC"}
@@ -1,16 +1,16 @@
1
- import { setupReporting } from '../../setupReporting.js';
2
- import { ensurePackageBundled } from '@ms-cloudpack/api-server/apis';
1
+ import { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server/apis';
3
2
  import path from 'path';
4
- import { createPartialApiContext } from '../../common/createPartialApiContext.js';
5
- export async function bundle(options, context) {
3
+ export const execute = async ({ options, cwd, reporter, initialize, exit, autoDispose, }) => {
4
+ const { config, telemetryClient } = await initialize(cwd);
5
+ const packagePath = cwd;
6
6
  const { bundler: bundlerType, outdir = 'dist/browser-esm', disableSourceMaps } = options;
7
- const { reporter, appPath: packagePath } = context;
8
- const telemetryClient = await setupReporting(context);
9
- const ctx = await createPartialApiContext({
10
- ...context,
7
+ const [ctx] = autoDispose(await createPartialApiContext({
8
+ appPath: packagePath,
9
+ config,
10
+ reporter,
11
11
  telemetryClient,
12
12
  items: ['packages', 'watcher', 'session', 'taskRunner', 'bus'],
13
- });
13
+ }));
14
14
  const definition = await ctx.packages.get(packagePath);
15
15
  const { result } = await ensurePackageBundled({
16
16
  input: {
@@ -22,10 +22,9 @@ export async function bundle(options, context) {
22
22
  },
23
23
  ctx,
24
24
  });
25
- await ctx.dispose();
26
- await telemetryClient.shutdown();
27
- reporter.complete();
28
- process.exit(result?.errors?.length === 0 ? 0 : 1);
29
- }
25
+ await exit({
26
+ exitCode: result?.errors?.length === 0 ? 0 : 1,
27
+ });
28
+ };
30
29
  // cspell:ignore outdir
31
- //# sourceMappingURL=bundle.js.map
30
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,OAAO,GAAiC,KAAK,EAAE,EAC1D,OAAO,EACP,GAAG,EACH,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,WAAW,GACZ,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,GAAG,CAAC;IAExB,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IAEzF,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CACvB,MAAM,uBAAuB,CAAC;QAC5B,OAAO,EAAE,WAAW;QACpB,MAAM;QACN,QAAQ;QACR,eAAe;QACf,KAAK,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC;KAC/D,CAAC,CACH,CAAC;IAEF,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEvD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,oBAAoB,CAAC;QAC5C,KAAK,EAAE;YACL,IAAI,EAAE,UAAU,EAAE,IAAI,IAAI,WAAW;YACrC,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,OAAO;YACvC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC;YAC7C,WAAW;YACX,iBAAiB;SAClB;QACD,GAAG;KACJ,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC;QACT,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/C,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,uBAAuB","sourcesContent":["import type { CommandAction } from '../../types/CommandAction.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\n\nimport { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server/apis';\nimport path from 'path';\n\nexport const execute: CommandAction<BundleOptions> = async ({\n options,\n cwd,\n reporter,\n initialize,\n exit,\n autoDispose,\n}) => {\n const { config, telemetryClient } = await initialize(cwd);\n const packagePath = cwd;\n\n const { bundler: bundlerType, outdir = 'dist/browser-esm', disableSourceMaps } = options;\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n appPath: packagePath,\n config,\n reporter,\n telemetryClient,\n items: ['packages', 'watcher', 'session', 'taskRunner', 'bus'],\n }),\n );\n\n const definition = await ctx.packages.get(packagePath);\n\n const { result } = await ensurePackageBundled({\n input: {\n name: definition?.name ?? '<unknown>',\n version: definition?.version ?? '0.0.0',\n outputPath: path.resolve(packagePath, outdir),\n bundlerType,\n disableSourceMaps,\n },\n ctx,\n });\n\n await exit({\n exitCode: result?.errors?.length === 0 ? 0 : 1,\n });\n};\n\n// cspell:ignore outdir\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,eAAO,MAAM,IAAI,EAAE,eAOlB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,eAAO,MAAM,IAAI,EAAE,eAWlB,CAAC"}
@@ -1,9 +1,11 @@
1
- export const init = (command, context) => {
1
+ export const init = (command, createAction) => {
2
2
  command
3
3
  .command('bundle')
4
4
  .option('--bundler <name>', 'Forces use of a specific bundler.')
5
5
  .option('--outdir <path>', 'Path to drop the bundle output, relative to current path.')
6
6
  .description('Bundles a package.')
7
- .action(async (bundleOptions) => (await import('./bundle.js')).bundle(bundleOptions, context));
7
+ .action(createAction(() => ({
8
+ execute: import('./execute.js'),
9
+ })));
8
10
  };
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IACxD,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,MAAM,CAAC,kBAAkB,EAAE,mCAAmC,CAAC;SAC/D,MAAM,CAAC,iBAAiB,EAAE,2DAA2D,CAAC;SACtF,WAAW,CAAC,oBAAoB,CAAC;SACjC,MAAM,CAAC,KAAK,EAAE,aAA4B,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;AAClH,CAAC,CAAC","sourcesContent":["import type { BundleOptions } from './types/BundleOptions.js';\nimport type { CommandFunction } from '../../types/CommandFunction.js';\n\nexport const init: CommandFunction = (command, context) => {\n command\n .command('bundle')\n .option('--bundler <name>', 'Forces use of a specific bundler.')\n .option('--outdir <path>', 'Path to drop the bundle output, relative to current path.')\n .description('Bundles a package.')\n .action(async (bundleOptions: BundleOptions) => (await import('./bundle.js')).bundle(bundleOptions, context));\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE;IAC7D,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,MAAM,CAAC,kBAAkB,EAAE,mCAAmC,CAAC;SAC/D,MAAM,CAAC,iBAAiB,EAAE,2DAA2D,CAAC;SACtF,WAAW,CAAC,oBAAoB,CAAC;SACjC,MAAM,CACL,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC,cAAc,CAAC;KAChC,CAAC,CAAC,CACJ,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { CommandFunction } from '../../types/CommandFunction.js';\n\nexport const init: CommandFunction = (command, createAction) => {\n command\n .command('bundle')\n .option('--bundler <name>', 'Forces use of a specific bundler.')\n .option('--outdir <path>', 'Path to drop the bundle output, relative to current path.')\n .description('Bundles a package.')\n .action(\n createAction(() => ({\n execute: import('./execute.js'),\n })),\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bundleAndGetImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACvG,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;IACxB,GAAG,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;CACxD,GAAG,OAAO,CAAC;IACV,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,8DAA8D;IAC9D,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACnC,CAAC,CA6DD"}
1
+ {"version":3,"file":"bundleAndGetImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACvG,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;IACxB,GAAG,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;CACxD,GAAG,OAAO,CAAC;IACV,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,8DAA8D;IAC9D,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACnC,CAAC,CA+DD"}
@@ -8,7 +8,9 @@ import { ensurePackageBundled } from '@ms-cloudpack/api-server/apis';
8
8
  */
9
9
  export async function bundleAndGetImports(options) {
10
10
  const { packagePath, definition, packages, reporter, ctx } = options;
11
- const { outputLocation, isExternal } = await getBundleDetails({ packagePath }, { packages });
11
+ const { session } = ctx;
12
+ const { resolveMap } = session;
13
+ const { outputLocation, isExternal } = await getBundleDetails({ packagePath }, { packages, resolveMap });
12
14
  const outputPath = outputLocation.path;
13
15
  if (!isExternal && !definition.exports) {
14
16
  console.debug(`${path.join(packagePath, 'package.json')} does not have an "exports" field.`);
@@ -1 +1 @@
1
- {"version":3,"file":"bundleAndGetImports.js","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACj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BACtF;aACF;SACF,CAAC;KACH;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,oBAAoB,CAAC;QAC5C,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;SACR;QACD,GAAG;KACJ,CAAC,CAAC;IAEH,yCAAyC;IACzC,IAAI,OAA6C,CAAC;IAElD,MAAM,QAAQ,CAAC,OAAO,CAAC,YAAY,iBAAiB,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE;QAC7E,OAAO,GAAG,IAAI,GAAG,CACf,MAAM,CAAC,OAAO,CACZ,CAAC,MAAM,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAC/G,CACF,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,UAAU;SACnB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,EAAE;QAChC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;QAC5B,OAAO,EAAE,OAAO,IAAI,IAAI,GAAG,EAAuB;KACnD,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\nimport { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';\nimport { getBundleDetails, findImports } from '@ms-cloudpack/api-server';\nimport type { PackageJson, PackageDefinitionsCache, BundleMessage } from '@ms-cloudpack/bundler-types';\nimport { type TaskReporter, formatPackageName } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport { ensurePackageBundled } from '@ms-cloudpack/api-server/apis';\n\n/**\n * Bundle the package and return the imports it depends on.\n */\nexport async function bundleAndGetImports(options: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n reporter: TaskReporter;\n packagePath: string;\n definition: PackageJson;\n ctx: Parameters<typeof ensurePackageBundled>[0]['ctx'];\n}): Promise<{\n warnings: BundleMessage[];\n errors: BundleMessage[];\n /** Map from package name to set of required relative paths */\n imports: Map<string, Set<string>>;\n}> {\n const { packagePath, definition, packages, reporter, ctx } = options;\n const { outputLocation, isExternal } = await getBundleDetails({ packagePath }, { packages });\n const outputPath = outputLocation.path;\n\n if (!isExternal && !definition.exports) {\n console.debug(`${path.join(packagePath, 'package.json')} does not have an \"exports\" field.`);\n }\n\n const { name, version } = definition;\n\n if (!name || !version) {\n throw new Error(`Package at \"${packagePath}\" does not have a name or version.`);\n }\n\n // Determine entries.\n const entriesMap = await getEntriesMapFromPackage({ inputPath: packagePath }, { packages });\n\n if (!Object.keys(entriesMap).length) {\n return {\n imports: new Map<string, Set<string>>(),\n errors: [],\n warnings: [\n {\n text: `No valid entry points were found when evaluating ${path.join(\n packagePath,\n 'package.json',\n )}. Check that has an exports, main, or module entry and the referenced files exist.`,\n },\n ],\n };\n }\n\n const { result } = await ensurePackageBundled({\n input: {\n name,\n version,\n },\n ctx,\n });\n\n // For each outputFile, find all imports.\n let imports: Map<string, Set<string>> | undefined;\n\n await reporter.runTask(`Evaluate ${formatPackageName(definition)}`, async () => {\n imports = new Map(\n Object.entries(\n (await findImports(result?.outputFiles?.map((file) => path.resolve(outputPath, file.outputPath)) || [])) || {},\n ),\n );\n\n return {\n status: 'complete',\n };\n });\n\n return {\n warnings: result?.warnings || [],\n errors: result?.errors || [],\n imports: imports || new Map<string, Set<string>>(),\n };\n}\n"]}
1
+ {"version":3,"file":"bundleAndGetImports.js","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAqB,iBAAiB,EAAE,MA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oFAAoF;iBACtF;aACF;SACF,CAAC;KACH;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,oBAAoB,CAAC;QAC5C,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;SACR;QACD,GAAG;KACJ,CAAC,CAAC;IAEH,yCAAyC;IACzC,IAAI,OAA6C,CAAC;IAElD,MAAM,QAAQ,CAAC,OAAO,CAAC,YAAY,iBAAiB,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE;QAC7E,OAAO,GAAG,IAAI,GAAG,CACf,MAAM,CAAC,OAAO,CACZ,CAAC,MAAM,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAC/G,CACF,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,UAAU;SACnB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,EAAE;QAChC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;QAC5B,OAAO,EAAE,OAAO,IAAI,IAAI,GAAG,EAAuB;KACnD,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\nimport { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';\nimport { getBundleDetails, findImports } from '@ms-cloudpack/api-server';\nimport type { PackageJson, PackageDefinitionsCache, BundleMessage } from '@ms-cloudpack/bundler-types';\nimport { type TaskReporter, formatPackageName } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport { ensurePackageBundled } from '@ms-cloudpack/api-server/apis';\n\n/**\n * Bundle the package and return the imports it depends on.\n */\nexport async function bundleAndGetImports(options: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n reporter: TaskReporter;\n packagePath: string;\n definition: PackageJson;\n ctx: Parameters<typeof ensurePackageBundled>[0]['ctx'];\n}): Promise<{\n warnings: BundleMessage[];\n errors: BundleMessage[];\n /** Map from package name to set of required relative paths */\n imports: Map<string, Set<string>>;\n}> {\n const { packagePath, definition, packages, reporter, ctx } = options;\n const { session } = ctx;\n const { resolveMap } = session;\n const { outputLocation, isExternal } = await getBundleDetails({ packagePath }, { packages, resolveMap });\n const outputPath = outputLocation.path;\n\n if (!isExternal && !definition.exports) {\n console.debug(`${path.join(packagePath, 'package.json')} does not have an \"exports\" field.`);\n }\n\n const { name, version } = definition;\n\n if (!name || !version) {\n throw new Error(`Package at \"${packagePath}\" does not have a name or version.`);\n }\n\n // Determine entries.\n const entriesMap = await getEntriesMapFromPackage({ inputPath: packagePath }, { packages });\n\n if (!Object.keys(entriesMap).length) {\n return {\n imports: new Map<string, Set<string>>(),\n errors: [],\n warnings: [\n {\n text: `No valid entry points were found when evaluating ${path.join(\n packagePath,\n 'package.json',\n )}. Check that has an exports, main, or module entry and the referenced files exist.`,\n },\n ],\n };\n }\n\n const { result } = await ensurePackageBundled({\n input: {\n name,\n version,\n },\n ctx,\n });\n\n // For each outputFile, find all imports.\n let imports: Map<string, Set<string>> | undefined;\n\n await reporter.runTask(`Evaluate ${formatPackageName(definition)}`, async () => {\n imports = new Map(\n Object.entries(\n (await findImports(result?.outputFiles?.map((file) => path.resolve(outputPath, file.outputPath)) || [])) || {},\n ),\n );\n\n return {\n status: 'complete',\n };\n });\n\n return {\n warnings: result?.warnings || [],\n errors: result?.errors || [],\n imports: imports || new Map<string, Set<string>>(),\n };\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { InitOptions } from './types/InitOptions.js';
2
+ import type { CommandAction } from '../../types/CommandAction.js';
3
+ /** Given the path, updates the Cloudpack config with overrides and project settings. */
4
+ export declare const execute: CommandAction<InitOptions>;
5
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/init/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE,wFAAwF;AACxF,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CAmB9C,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { init } from './init.js';
2
+ import { formatInitSummary } from './formatInitSummary.js';
3
+ /** Given the path, updates the Cloudpack config with overrides and project settings. */
4
+ export const execute = async ({ options, cwd, initialize, reporter, exit, autoDispose, }) => {
5
+ const { config, telemetryClient } = await initialize(cwd);
6
+ const summary = await init({ options, appPath: cwd, config, reporter, autoDispose, telemetryClient });
7
+ const message = formatInitSummary(summary, options);
8
+ const hasErrors = summary.totalErrors > 0;
9
+ await exit({
10
+ exitCode: hasErrors ? 1 : 0,
11
+ message,
12
+ });
13
+ };
14
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/init/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,EACxD,OAAO,EACP,GAAG,EACH,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,WAAW,GACZ,EAAE,EAAE;IACH,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IAE1D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,CAAC;IAEtG,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC;IAE1C,MAAM,IAAI,CAAC;QACT,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { InitOptions } from './types/InitOptions.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { init } from './init.js';\nimport { formatInitSummary } from './formatInitSummary.js';\n\n/** Given the path, updates the Cloudpack config with overrides and project settings. */\nexport const execute: CommandAction<InitOptions> = async ({\n options,\n cwd,\n initialize,\n reporter,\n exit,\n autoDispose,\n}) => {\n const { config, telemetryClient } = await initialize(cwd);\n\n const summary = await init({ options, appPath: cwd, config, reporter, autoDispose, telemetryClient });\n\n const message = formatInitSummary(summary, options);\n const hasErrors = summary.totalErrors > 0;\n\n await exit({\n exitCode: hasErrors ? 1 : 0,\n message,\n });\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,eASlB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,eAalB,CAAC"}
@@ -1,10 +1,12 @@
1
1
  /** Defines the "init" verb. */
2
- export const init = (command, context) => {
2
+ export const init = (command, createAction) => {
3
3
  command
4
4
  .command('init')
5
5
  .description('Initializes a given app project and defines the necessary configuration overrides to make an existing app compatible with Cloudpack.')
6
6
  .option('--reset', 'Ignores existing overrides when determining all entries.')
7
7
  .option('--check', 'Fails if any package exports are missing.')
8
- .action(async (options) => (await import('./init.js')).init(options, context));
8
+ .action(createAction(() => ({
9
+ execute: import('./execute.js'),
10
+ })));
9
11
  };
10
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAGA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IACxD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CACV,sIAAsI,CACvI;SACA,MAAM,CAAC,SAAS,EAAE,0DAA0D,CAAC;SAC7E,MAAM,CAAC,SAAS,EAAE,2CAA2C,CAAC;SAC9D,MAAM,CAAC,KAAK,EAAE,OAAoB,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAChG,CAAC,CAAC","sourcesContent":["import type { InitOptions } from './types/InitOptions.js';\nimport type { CommandFunction } from '../../types/CommandFunction.js';\n\n/** Defines the \"init\" verb. */\nexport const init: CommandFunction = (command, context) => {\n command\n .command('init')\n .description(\n 'Initializes a given app project and defines the necessary configuration overrides to make an existing app compatible with Cloudpack.',\n )\n .option('--reset', 'Ignores existing overrides when determining all entries.')\n .option('--check', 'Fails if any package exports are missing.')\n .action(async (options: InitOptions) => (await import('./init.js')).init(options, context));\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAEA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE;IAC7D,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CACV,sIAAsI,CACvI;SACA,MAAM,CAAC,SAAS,EAAE,0DAA0D,CAAC;SAC7E,MAAM,CAAC,SAAS,EAAE,2CAA2C,CAAC;SAC9D,MAAM,CACL,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC,cAAc,CAAC;KAChC,CAAC,CAAC,CACJ,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { CommandFunction } from '../../types/CommandFunction.js';\n\n/** Defines the \"init\" verb. */\nexport const init: CommandFunction = (command, createAction) => {\n command\n .command('init')\n .description(\n 'Initializes a given app project and defines the necessary configuration overrides to make an existing app compatible with Cloudpack.',\n )\n .option('--reset', 'Ignores existing overrides when determining all entries.')\n .option('--check', 'Fails if any package exports are missing.')\n .action(\n createAction(() => ({\n execute: import('./execute.js'),\n })),\n );\n};\n"]}
@@ -1,12 +1,18 @@
1
- import type { TaskContext } from '../../types/TaskContext.js';
2
1
  import type { InitOptions } from './types/InitOptions.js';
3
2
  import type { InitSummary } from './types/InitSummary.js';
3
+ import { type CloudpackConfig } from '@ms-cloudpack/config';
4
+ import type { TaskReporter } from '@ms-cloudpack/task-reporter';
5
+ import type { AutoDispose } from '../../types/AutoDispose.js';
4
6
  import type { TelemetryClient } from '@ms-cloudpack/telemetry';
5
- /** Given the path, updates the Cloudpack config with overrides and project settings. */
6
- export declare function init(options: InitOptions, context: TaskContext): Promise<void>;
7
7
  /**
8
8
  * Actual init operation (minus the completion logging).
9
- * Exported for testing only.
10
9
  */
11
- export declare function initInternal(options: InitOptions, context: TaskContext, telemetryClient: TelemetryClient): Promise<InitSummary>;
10
+ export declare function init(parameters: {
11
+ options: InitOptions;
12
+ appPath: string;
13
+ config: CloudpackConfig;
14
+ autoDispose: AutoDispose;
15
+ reporter: TaskReporter;
16
+ telemetryClient: TelemetryClient;
17
+ }): Promise<InitSummary>;
12
18
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAS1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,wFAAwF;AACxF,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBpF;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,EACpB,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,WAAW,CAAC,CAmHtB"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIlF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;GAEG;AACH,wBAAsB,IAAI,CAAC,UAAU,EAAE;IACrC,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,eAAe,CAAC;IACxB,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;CAClC,GAAG,OAAO,CAAC,WAAW,CAAC,CAoHvB"}
@@ -1,125 +1,102 @@
1
- import { createPartialApiContext } from '../../common/createPartialApiContext.js';
1
+ import { createPartialApiContext } from '@ms-cloudpack/api-server/apis';
2
2
  import { writeGeneratedConfig } from '@ms-cloudpack/config';
3
- import { setupReporting } from '../../setupReporting.js';
4
3
  import { bundleAndGetImports } from './bundleAndGetImports.js';
5
4
  import { InitSummaryData } from './InitSummaryData.js';
6
5
  import { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';
7
- import { formatInitSummary } from './formatInitSummary.js';
8
- /** Given the path, updates the Cloudpack config with overrides and project settings. */
9
- export async function init(options, context) {
10
- const { reporter } = context;
11
- let hasErrors = false;
12
- const telemetryClient = await setupReporting(context);
13
- try {
14
- const summary = await initInternal(options, context, telemetryClient);
15
- reporter.complete(formatInitSummary(summary, options));
16
- hasErrors = summary.totalErrors > 0;
17
- }
18
- catch (error) {
19
- reporter.complete(`Unexpected error: ${error.stack || error}`);
20
- hasErrors = true;
21
- }
22
- await telemetryClient.shutdown();
23
- process.exit(hasErrors ? 1 : 0);
24
- }
25
6
  /**
26
7
  * Actual init operation (minus the completion logging).
27
- * Exported for testing only.
28
8
  */
29
- export async function initInternal(options, context, telemetryClient) {
30
- const { appPath, reporter } = context;
9
+ export async function init(parameters) {
10
+ const { options, appPath, config, reporter, autoDispose, telemetryClient } = parameters;
31
11
  const summaryData = new InitSummaryData();
32
- const ctx = await createPartialApiContext({
33
- ...context,
12
+ const [ctx] = autoDispose(await createPartialApiContext({
13
+ appPath,
14
+ config,
15
+ reporter,
34
16
  telemetryClient,
35
17
  items: ['bus', 'taskRunner', 'watcher', 'packages', 'session'],
36
- });
18
+ }));
37
19
  const { packages, session } = ctx;
38
- const { resolveMap, config } = session;
39
- try {
40
- if (options.check && options.reset) {
41
- throw Error('Cannot use --check and --reset together.');
20
+ const { resolveMap } = session;
21
+ if (options.check && options.reset) {
22
+ throw Error('Cannot use --check and --reset together.');
23
+ }
24
+ // If --reset is specified we ignore generated config.
25
+ if (options.reset) {
26
+ config.generated = {};
27
+ }
28
+ const generatedConfig = config.generated;
29
+ generatedConfig.packageSettings ??= [];
30
+ const packagePathsToEvaluate = new Set([appPath]);
31
+ const evaluatedPackages = new Set();
32
+ let totalChangeCount = 0;
33
+ while (packagePathsToEvaluate.size) {
34
+ const packagePath = packagePathsToEvaluate.values().next().value;
35
+ packagePathsToEvaluate.delete(packagePath);
36
+ // Skip already-visited packages.
37
+ if (!packagePath || evaluatedPackages.has(packagePath)) {
38
+ continue;
42
39
  }
43
- // If --reset is specified we ignore generated config.
44
- if (options.reset) {
45
- config.generated = {};
40
+ evaluatedPackages.add(packagePath);
41
+ const definition = await packages.get(packagePath, { refresh: true });
42
+ if (!definition) {
43
+ // This is very weird and probably won't happen.
44
+ console.error(`Skipping ${packagePath} evaluation because the package.json was not found or not readable.`);
45
+ continue;
46
46
  }
47
- const generatedConfig = config.generated;
48
- generatedConfig.packageSettings ??= [];
49
- const packagePathsToEvaluate = new Set([appPath]);
50
- const evaluatedPackages = new Set();
51
- let totalChangeCount = 0;
52
- while (packagePathsToEvaluate.size) {
53
- const packagePath = packagePathsToEvaluate.values().next().value;
54
- packagePathsToEvaluate.delete(packagePath);
55
- // Skip already-visited packages.
56
- if (!packagePath || evaluatedPackages.has(packagePath)) {
57
- continue;
58
- }
59
- evaluatedPackages.add(packagePath);
60
- const definition = await packages.get(packagePath, { refresh: true });
61
- if (!definition) {
62
- // This is very weird and probably won't happen.
63
- console.error(`Skipping ${packagePath} evaluation because the package.json was not found or not readable.`);
64
- continue;
65
- }
66
- // Bundle the package and find the imports it depends on.
67
- const { errors, warnings, imports } = await bundleAndGetImports({
68
- packagePath,
47
+ // Bundle the package and find the imports it depends on.
48
+ const { errors, warnings, imports } = await bundleAndGetImports({
49
+ packagePath,
50
+ definition,
51
+ packages,
52
+ reporter,
53
+ config,
54
+ ctx,
55
+ });
56
+ // Record the results for the summary.
57
+ const resultIdentifier = {
58
+ name: definition.name || '',
59
+ version: definition.version || '',
60
+ path: packagePath,
61
+ };
62
+ summaryData.recordResult({
63
+ ...resultIdentifier,
64
+ errors,
65
+ warnings,
66
+ });
67
+ // If no errors came from the bundle attempt, move on to evaluating the imports.
68
+ if (errors.length === 0) {
69
+ // Given the package imports, find the missing exports maps and update packageOverrides.
70
+ const { changes, errors: evalErrors } = await evaluateImportsForOverrides({
69
71
  definition,
72
+ packagePath,
70
73
  packages,
71
- reporter,
72
- config,
73
- ctx,
74
+ packagePathsToEvaluate,
75
+ evaluatedPackages,
76
+ imports,
77
+ generatedConfig,
78
+ resolveMap,
74
79
  });
75
- // Record the results for the summary.
76
- const resultIdentifier = {
77
- name: definition.name || '',
78
- version: definition.version || '',
79
- path: packagePath,
80
- };
81
- summaryData.recordResult({
82
- ...resultIdentifier,
83
- errors,
84
- warnings,
85
- });
86
- // If no errors came from the bundle attempt, move on to evaluating the imports.
87
- if (errors.length === 0) {
88
- // Given the package imports, find the missing exports maps and update packageOverrides.
89
- const { changes, errors: evalErrors } = await evaluateImportsForOverrides({
90
- definition,
91
- packagePath,
92
- packages,
93
- packagePathsToEvaluate,
94
- evaluatedPackages,
95
- imports,
96
- generatedConfig,
97
- resolveMap,
80
+ if (evalErrors.length) {
81
+ summaryData.recordResult({
82
+ ...resultIdentifier,
83
+ errors: evalErrors.map((text) => ({ text })),
98
84
  });
99
- if (evalErrors.length) {
100
- summaryData.recordResult({
101
- ...resultIdentifier,
102
- errors: evalErrors.map((text) => ({ text })),
103
- });
104
- }
105
- else {
106
- summaryData.recordGeneratedChanges(changes);
107
- }
108
- if (options.check && (changes.length || evalErrors.length)) {
109
- telemetryClient.rootSpan.addEvent('INIT_CHECK_FAILED', {
110
- reason: changes.length ? 'Config needs to be updated.' : evalErrors,
111
- });
112
- return summaryData.summarize();
113
- }
114
- totalChangeCount += changes.length;
115
85
  }
116
- }
117
- if (totalChangeCount && generatedConfig.packageSettings?.length) {
118
- await writeGeneratedConfig(generatedConfig, appPath);
86
+ else {
87
+ summaryData.recordGeneratedChanges(changes);
88
+ }
89
+ if (options.check && (changes.length || evalErrors.length)) {
90
+ telemetryClient.rootSpan.addEvent('INIT_CHECK_FAILED', {
91
+ reason: changes.length ? 'Config needs to be updated.' : evalErrors,
92
+ });
93
+ return summaryData.summarize();
94
+ }
95
+ totalChangeCount += changes.length;
119
96
  }
120
97
  }
121
- finally {
122
- await ctx.dispose?.();
98
+ if (totalChangeCount && generatedConfig.packageSettings?.length) {
99
+ await writeGeneratedConfig(generatedConfig, appPath);
123
100
  }
124
101
  return summaryData.summarize();
125
102
  }
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAoB,EAAE,OAAoB;IACnE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,MAAM,eAAe,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAEtD,IAAI;QACF,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QAEtE,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACvD,SAAS,GAAG,OAAO,CAAC,WAAW,GAAG,CAAC,CAAC;KACrC;IAAC,OAAO,KAAK,EAAE;QACd,QAAQ,CA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,QAAQ;oBACR,sBAAsB;oBACtB,iBAAiB;oBACjB,OAAO;oBACP,eAAe;oBACf,UAAU;iBACX,CAAC,CAAC;gBAEH,IAAI,UAAU,CAAC,MAAM,EAAE;oBACrB,WAAW,CAAC,YAAY,CAAC;wBACvB,GAAG,gBAAgB;wBACnB,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;qBAC7C,CAAC,CAAC;iBACJ;qBAAM;oBACL,WAAW,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;iBAC7C;gBAED,IAAI,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE;oBAC1D,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,EAAE;wBACrD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,UAAU;qBACpE,CAAC,CAAC;oBAEH,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;iBAChC;gBAED,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;aACpC;SACF;QAED,IAAI,gBAAgB,IAAI,eAAe,CAAC,eAAe,EAAE,MAAM,EAAE;YAC/D,MAAM,oBAAoB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;SACtD;KACF;YAAS;QACR,MAAM,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;KACvB;IAED,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;AACjC,CAAC","sourcesContent":["import type { TaskContext } from '../../types/TaskContext.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitSummary } from './types/InitSummary.js';\n\nimport { createPartialApiContext } from '../../common/createPartialApiContext.js';\nimport { writeGeneratedConfig } from '@ms-cloudpack/config';\nimport { setupReporting } from '../../setupReporting.js';\nimport { bundleAndGetImports } from './bundleAndGetImports.js';\nimport { InitSummaryData } from './InitSummaryData.js';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport { formatInitSummary } from './formatInitSummary.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\n\n/** Given the path, updates the Cloudpack config with overrides and project settings. */\nexport async function init(options: InitOptions, context: TaskContext): Promise<void> {\n const { reporter } = context;\n let hasErrors = false;\n\n const telemetryClient = await setupReporting(context);\n\n try {\n const summary = await initInternal(options, context, telemetryClient);\n\n reporter.complete(formatInitSummary(summary, options));\n hasErrors = summary.totalErrors > 0;\n } catch (error) {\n reporter.complete(`Unexpected error: ${(error as Error).stack || error}`);\n hasErrors = true;\n }\n\n await telemetryClient.shutdown();\n\n process.exit(hasErrors ? 1 : 0);\n}\n\n/**\n * Actual init operation (minus the completion logging).\n * Exported for testing only.\n */\nexport async function initInternal(\n options: InitOptions,\n context: TaskContext,\n telemetryClient: TelemetryClient,\n): Promise<InitSummary> {\n const { appPath, reporter } = context;\n const summaryData = new InitSummaryData();\n const ctx = await createPartialApiContext({\n ...context,\n telemetryClient,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session'],\n });\n const { packages, session } = ctx;\n const { resolveMap, config } = session;\n\n try {\n if (options.check && options.reset) {\n throw Error('Cannot use --check and --reset together.');\n }\n\n // If --reset is specified we ignore generated config.\n if (options.reset) {\n config.generated = {};\n }\n\n const generatedConfig = config.generated;\n\n generatedConfig.packageSettings ??= [];\n\n const packagePathsToEvaluate = new Set<string>([appPath]);\n const evaluatedPackages = new Set<string>();\n let totalChangeCount = 0;\n\n while (packagePathsToEvaluate.size) {\n const packagePath = packagePathsToEvaluate.values().next().value as string;\n\n packagePathsToEvaluate.delete(packagePath);\n\n // Skip already-visited packages.\n if (!packagePath || evaluatedPackages.has(packagePath)) {\n continue;\n }\n\n evaluatedPackages.add(packagePath);\n\n const definition = await packages.get(packagePath, { refresh: true });\n\n if (!definition) {\n // This is very weird and probably won't happen.\n console.error(`Skipping ${packagePath} evaluation because the package.json was not found or not readable.`);\n continue;\n }\n\n // Bundle the package and find the imports it depends on.\n const { errors, warnings, imports } = await bundleAndGetImports({\n packagePath,\n definition,\n packages,\n reporter,\n config,\n ctx,\n });\n\n // Record the results for the summary.\n const resultIdentifier = {\n name: definition.name || '',\n version: definition.version || '',\n path: packagePath,\n };\n\n summaryData.recordResult({\n ...resultIdentifier,\n errors,\n warnings,\n });\n\n // If no errors came from the bundle attempt, move on to evaluating the imports.\n if (errors.length === 0) {\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const { changes, errors: evalErrors } = await evaluateImportsForOverrides({\n definition,\n packagePath,\n packages,\n packagePathsToEvaluate,\n evaluatedPackages,\n imports,\n generatedConfig,\n resolveMap,\n });\n\n if (evalErrors.length) {\n summaryData.recordResult({\n ...resultIdentifier,\n errors: evalErrors.map((text) => ({ text })),\n });\n } else {\n summaryData.recordGeneratedChanges(changes);\n }\n\n if (options.check && (changes.length || evalErrors.length)) {\n telemetryClient.rootSpan.addEvent('INIT_CHECK_FAILED', {\n reason: changes.length ? 'Config needs to be updated.' : evalErrors,\n });\n\n return summaryData.summarize();\n }\n\n totalChangeCount += changes.length;\n }\n }\n\n if (totalChangeCount && generatedConfig.packageSettings?.length) {\n await writeGeneratedConfig(generatedConfig, appPath);\n }\n } finally {\n await ctx.dispose?.();\n }\n\n return summaryData.summarize();\n}\n"]}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAwB,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAK/E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAA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CAAC;iBAC7C,CAAC,CAAC;aACJ;iBAAM;gBACL,WAAW,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;aAC7C;YAED,IAAI,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE;gBAC1D,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,EAAE;oBACrD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,UAAU;iBACpE,CAAC,CAAC;gBAEH,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;aAChC;YAED,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;SACpC;KACF;IAED,IAAI,gBAAgB,IAAI,eAAe,CAAC,eAAe,EAAE,MAAM,EAAE;QAC/D,MAAM,oBAAoB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;KACtD;IAED,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;AACjC,CAAC","sourcesContent":["import type { InitOptions } from './types/InitOptions.js';\nimport type { InitSummary } from './types/InitSummary.js';\n\nimport { createPartialApiContext } from '@ms-cloudpack/api-server/apis';\nimport { writeGeneratedConfig, type CloudpackConfig } from '@ms-cloudpack/config';\nimport { bundleAndGetImports } from './bundleAndGetImports.js';\nimport { InitSummaryData } from './InitSummaryData.js';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { AutoDispose } from '../../types/AutoDispose.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\n\n/**\n * Actual init operation (minus the completion logging).\n */\nexport async function init(parameters: {\n options: InitOptions;\n appPath: string;\n config: CloudpackConfig;\n autoDispose: AutoDispose;\n reporter: TaskReporter;\n telemetryClient: TelemetryClient;\n}): Promise<InitSummary> {\n const { options, appPath, config, reporter, autoDispose, telemetryClient } = parameters;\n const summaryData = new InitSummaryData();\n const [ctx] = autoDispose(\n await createPartialApiContext({\n appPath,\n config,\n reporter,\n telemetryClient,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session'],\n }),\n );\n\n const { packages, session } = ctx;\n const { resolveMap } = session;\n\n if (options.check && options.reset) {\n throw Error('Cannot use --check and --reset together.');\n }\n\n // If --reset is specified we ignore generated config.\n if (options.reset) {\n config.generated = {};\n }\n\n const generatedConfig = config.generated;\n\n generatedConfig.packageSettings ??= [];\n\n const packagePathsToEvaluate = new Set<string>([appPath]);\n const evaluatedPackages = new Set<string>();\n let totalChangeCount = 0;\n\n while (packagePathsToEvaluate.size) {\n const packagePath = packagePathsToEvaluate.values().next().value as string;\n\n packagePathsToEvaluate.delete(packagePath);\n\n // Skip already-visited packages.\n if (!packagePath || evaluatedPackages.has(packagePath)) {\n continue;\n }\n\n evaluatedPackages.add(packagePath);\n\n const definition = await packages.get(packagePath, { refresh: true });\n\n if (!definition) {\n // This is very weird and probably won't happen.\n console.error(`Skipping ${packagePath} evaluation because the package.json was not found or not readable.`);\n continue;\n }\n\n // Bundle the package and find the imports it depends on.\n const { errors, warnings, imports } = await bundleAndGetImports({\n packagePath,\n definition,\n packages,\n reporter,\n config,\n ctx,\n });\n\n // Record the results for the summary.\n const resultIdentifier = {\n name: definition.name || '',\n version: definition.version || '',\n path: packagePath,\n };\n\n summaryData.recordResult({\n ...resultIdentifier,\n errors,\n warnings,\n });\n\n // If no errors came from the bundle attempt, move on to evaluating the imports.\n if (errors.length === 0) {\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const { changes, errors: evalErrors } = await evaluateImportsForOverrides({\n definition,\n packagePath,\n packages,\n packagePathsToEvaluate,\n evaluatedPackages,\n imports,\n generatedConfig,\n resolveMap,\n });\n\n if (evalErrors.length) {\n summaryData.recordResult({\n ...resultIdentifier,\n errors: evalErrors.map((text) => ({ text })),\n });\n } else {\n summaryData.recordGeneratedChanges(changes);\n }\n\n if (options.check && (changes.length || evalErrors.length)) {\n telemetryClient.rootSpan.addEvent('INIT_CHECK_FAILED', {\n reason: changes.length ? 'Config needs to be updated.' : evalErrors,\n });\n\n return summaryData.summarize();\n }\n\n totalChangeCount += changes.length;\n }\n }\n\n if (totalChangeCount && generatedConfig.packageSettings?.length) {\n await writeGeneratedConfig(generatedConfig, appPath);\n }\n\n return summaryData.summarize();\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import type { StartOptions } from './types/StartOptions.js';
2
- import type { TaskContext } from '../../types/TaskContext.js';
2
+ import type { CommandAction } from '../../types/CommandAction.js';
3
3
  /** Stop all started cloudpack instances, for testing */
4
4
  export declare function stopServers(): Promise<void>;
5
5
  /**
6
6
  * Defines the "start" verb entry point.
7
7
  */
8
- export declare function start(options: StartOptions, context: TaskContext): Promise<void>;
9
- //# sourceMappingURL=start.d.ts.map
8
+ export declare const execute: CommandAction<StartOptions>;
9
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAgBlE,wDAAwD;AACxD,wBAAsB,WAAW,kBAKhC;AAsBD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,CAiH/C,CAAC"}