@ms-cloudpack/cli 0.39.10 → 0.39.12

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 (79) hide show
  1. package/lib/commands/bundle/bundle.d.ts +4 -1
  2. package/lib/commands/bundle/bundle.d.ts.map +1 -1
  3. package/lib/commands/bundle/bundle.js +1 -2
  4. package/lib/commands/bundle/bundle.js.map +1 -1
  5. package/lib/commands/bundle/index.d.ts +2 -2
  6. package/lib/commands/bundle/index.d.ts.map +1 -1
  7. package/lib/commands/bundle/index.js +3 -3
  8. package/lib/commands/bundle/index.js.map +1 -1
  9. package/lib/commands/dashboard/index.d.ts +2 -2
  10. package/lib/commands/dashboard/index.d.ts.map +1 -1
  11. package/lib/commands/dashboard/index.js +2 -2
  12. package/lib/commands/dashboard/index.js.map +1 -1
  13. package/lib/commands/init/bundleAndGetImports.d.ts +2 -0
  14. package/lib/commands/init/bundleAndGetImports.d.ts.map +1 -1
  15. package/lib/commands/init/bundleAndGetImports.js +1 -2
  16. package/lib/commands/init/bundleAndGetImports.js.map +1 -1
  17. package/lib/commands/init/findImports.d.ts.map +1 -1
  18. package/lib/commands/init/findImports.js +15 -2
  19. package/lib/commands/init/findImports.js.map +1 -1
  20. package/lib/commands/init/index.d.ts +2 -2
  21. package/lib/commands/init/index.d.ts.map +1 -1
  22. package/lib/commands/init/index.js +4 -5
  23. package/lib/commands/init/index.js.map +1 -1
  24. package/lib/commands/init/init.d.ts +4 -1
  25. package/lib/commands/init/init.d.ts.map +1 -1
  26. package/lib/commands/init/init.js +3 -3
  27. package/lib/commands/init/init.js.map +1 -1
  28. package/lib/commands/start/appServer/startAppServer.d.ts +3 -1
  29. package/lib/commands/start/appServer/startAppServer.d.ts.map +1 -1
  30. package/lib/commands/start/appServer/startAppServer.js +1 -2
  31. package/lib/commands/start/appServer/startAppServer.js.map +1 -1
  32. package/lib/commands/start/createBundleTask.d.ts +2 -1
  33. package/lib/commands/start/createBundleTask.d.ts.map +1 -1
  34. package/lib/commands/start/createBundleTask.js +2 -2
  35. package/lib/commands/start/createBundleTask.js.map +1 -1
  36. package/lib/commands/start/createSession.d.ts +4 -1
  37. package/lib/commands/start/createSession.d.ts.map +1 -1
  38. package/lib/commands/start/createSession.js +2 -2
  39. package/lib/commands/start/createSession.js.map +1 -1
  40. package/lib/commands/start/index.d.ts +2 -2
  41. package/lib/commands/start/index.d.ts.map +1 -1
  42. package/lib/commands/start/index.js +3 -3
  43. package/lib/commands/start/index.js.map +1 -1
  44. package/lib/commands/start/start.d.ts +4 -1
  45. package/lib/commands/start/start.d.ts.map +1 -1
  46. package/lib/commands/start/start.js +4 -4
  47. package/lib/commands/start/start.js.map +1 -1
  48. package/lib/commands/start/startBundleServer.d.ts +3 -1
  49. package/lib/commands/start/startBundleServer.d.ts.map +1 -1
  50. package/lib/commands/start/startBundleServer.js +5 -5
  51. package/lib/commands/start/startBundleServer.js.map +1 -1
  52. package/lib/index.d.ts.map +1 -1
  53. package/lib/index.js +7 -10
  54. package/lib/index.js.map +1 -1
  55. package/lib/initReporter.d.ts +4 -0
  56. package/lib/initReporter.d.ts.map +1 -0
  57. package/lib/initReporter.js +7 -0
  58. package/lib/initReporter.js.map +1 -0
  59. package/lib/initTelemetry.d.ts +2 -1
  60. package/lib/initTelemetry.d.ts.map +1 -1
  61. package/lib/initTelemetry.js +4 -1
  62. package/lib/initTelemetry.js.map +1 -1
  63. package/lib/tasks/bundleTask.d.ts +3 -1
  64. package/lib/tasks/bundleTask.d.ts.map +1 -1
  65. package/lib/tasks/bundleTask.js +10 -5
  66. package/lib/tasks/bundleTask.js.map +1 -1
  67. package/lib/tasks/resolveDependenciesTask.d.ts +3 -0
  68. package/lib/tasks/resolveDependenciesTask.d.ts.map +1 -1
  69. package/lib/tasks/resolveDependenciesTask.js +1 -2
  70. package/lib/tasks/resolveDependenciesTask.js.map +1 -1
  71. package/lib/types/CommandFunction.d.ts +7 -0
  72. package/lib/types/CommandFunction.d.ts.map +1 -0
  73. package/lib/types/CommandFunction.js +2 -0
  74. package/lib/types/CommandFunction.js.map +1 -0
  75. package/package.json +8 -8
  76. package/lib/reporter.d.ts +0 -5
  77. package/lib/reporter.d.ts.map +0 -1
  78. package/lib/reporter.js +0 -9
  79. package/lib/reporter.js.map +0 -1
@@ -1,3 +1,6 @@
1
1
  import type { BundleOptions } from './types/BundleOptions.js';
2
- export declare function bundle(options?: BundleOptions): Promise<void>;
2
+ import type { TaskReporter } from '@ms-cloudpack/task-reporter';
3
+ export declare function bundle(options: BundleOptions, { reporter }: {
4
+ reporter: TaskReporter;
5
+ }): Promise<void>;
3
6
  //# sourceMappingURL=bundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D,wBAAsB,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,iBAwBnD"}
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,iBAyB5F"}
@@ -1,8 +1,7 @@
1
1
  import { bundleTask } from '../../tasks/bundleTask.js';
2
2
  import path from 'path';
3
3
  import { PackageDefinitions } from '@ms-cloudpack/package-utilities';
4
- import { reporter } from '../../reporter.js';
5
- export async function bundle(options) {
4
+ export async function bundle(options, { reporter }) {
6
5
  const { bundler: bundlerType, outdir = 'dist/browser-esm', disableSourceMaps } = options || {};
7
6
  const packagePath = process.cwd();
8
7
  const definition = await PackageDefinitions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AAC;AACnE,CAAC","sourcesContent":["import { bundleTask } from '../../tasks/bundleTask.js';\nimport path from 'path';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport { reporter } from '../../reporter.js';\nimport type { BundleRequest } from '../../types/BundleRequest.js';\n\nexport async function bundle(options?: BundleOptions) {\n const { bundler: bundlerType, outdir = 'dist/browser-esm', disableSourceMaps } = options || {};\n const packagePath = process.cwd();\n const definition = await PackageDefinitions.getInstance().get(packagePath);\n const { name = 'unknown', version = '0.0.0' } = definition || {};\n const outputPath = path.resolve(packagePath, outdir);\n const bundleRequest: BundleRequest = {\n id: 'bundle',\n packageName: name,\n version,\n packagePath,\n outputPath,\n isExternal: true,\n bundlerType,\n disableSourceMaps,\n };\n\n await bundleTask({\n bundleRequest,\n options: { force: true },\n });\n\n reporter.complete();\n process.exit(bundleRequest.result?.errors?.length === 0 ? 0 : 1);\n}\n"]}
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAIrE,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB,EAAE,EAAE,QAAQ,EAA8B;IAC3F,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC/F,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3E,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,UAAU,IAAI,EAAE,CAAC;IACjE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACrD,MAAM,aAAa,GAAkB;QACnC,EAAE,EAAE,QAAQ;QACZ,WAAW,EAAE,IAAI;QACjB,OAAO;QACP,WAAW;QACX,UAAU;QACV,UAAU,EAAE,IAAI;QAChB,WAAW;QACX,iBAAiB;KAClB,CAAC;IAEF,MAAM,UAAU,CAAC;QACf,aAAa;QACb,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;KACzB,CAAC,CAAC;IAEH,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAEpB,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { bundleTask } from '../../tasks/bundleTask.js';\nimport path from 'path';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport type { BundleRequest } from '../../types/BundleRequest.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\n\nexport async function bundle(options: BundleOptions, { reporter }: { reporter: TaskReporter }) {\n const { bundler: bundlerType, outdir = 'dist/browser-esm', disableSourceMaps } = options || {};\n const packagePath = process.cwd();\n const definition = await PackageDefinitions.getInstance().get(packagePath);\n const { name = 'unknown', version = '0.0.0' } = definition || {};\n const outputPath = path.resolve(packagePath, outdir);\n const bundleRequest: BundleRequest = {\n id: 'bundle',\n packageName: name,\n version,\n packagePath,\n outputPath,\n isExternal: true,\n bundlerType,\n disableSourceMaps,\n };\n\n await bundleTask({\n bundleRequest,\n options: { force: true },\n });\n\n reporter.complete();\n\n process.exit(bundleRequest.result?.errors?.length === 0 ? 0 : 1);\n}\n"]}
@@ -1,3 +1,3 @@
1
- import type { Command } from 'commander';
2
- export declare function init(command: Command): void;
1
+ import type { CommandFunction } from '../../types/CommandFunction.js';
2
+ export declare const init: CommandFunction;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,QAOpC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,eAAO,MAAM,IAAI,EAAE,eAOlB,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { bundle } from './bundle.js';
2
- export function init(command) {
2
+ export const init = ({ command, reporter }) => {
3
3
  command
4
4
  .command('bundle')
5
5
  .option('--bundler <name>', 'Forces use of a specific bundler.')
6
6
  .option('--outdir <path>', 'Path to drop the bundle output, relative to current path.')
7
7
  .description('Bundles a package.')
8
- .action((options) => bundle(options));
9
- }
8
+ .action((bundleOptions) => bundle(bundleOptions, { reporter }));
9
+ };
10
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,MAAM,UAAU,IAAI,CAAC,OAAgB;IACnC,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,CAAC,OAAsB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACzD,CAAC","sourcesContent":["import type { Command } from 'commander';\nimport { bundle } from './bundle.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\n\nexport function init(command: Command) {\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((options: BundleOptions) => bundle(options));\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,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,CAAC,CAAC,aAA4B,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC","sourcesContent":["import { bundle } from './bundle.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport type { CommandFunction } from '../../types/CommandFunction.js';\n\nexport const init: CommandFunction = ({ command, reporter }) => {\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((bundleOptions: BundleOptions) => bundle(bundleOptions, { reporter }));\n};\n"]}
@@ -1,3 +1,3 @@
1
- import type { Command } from 'commander';
2
- export declare function init(command: Command): void;
1
+ import type { CommandFunction } from '../../types/CommandFunction.js';
2
+ export declare const init: CommandFunction;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,QAKpC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,eAAO,MAAM,IAAI,EAAE,eAKlB,CAAC"}
@@ -1,7 +1,7 @@
1
- export function init(command) {
1
+ export const init = ({ command }) => {
2
2
  command
3
3
  .command('dashboard')
4
4
  .description('Shows the dashboard.')
5
5
  .action(() => console.log('i am showing the dashboard.'));
6
- }
6
+ };
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/dashboard/index.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,IAAI,CAAC,OAAgB;IACnC,OAAO;SACJ,OAAO,CAAC,WAAW,CAAC;SACpB,WAAW,CAAC,sBAAsB,CAAC;SACnC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import type { Command } from 'commander';\n\nexport function init(command: Command) {\n command\n .command('dashboard')\n .description('Shows the dashboard.')\n .action(() => console.log('i am showing the dashboard.'));\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/dashboard/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IACnD,OAAO;SACJ,OAAO,CAAC,WAAW,CAAC;SACpB,WAAW,CAAC,sBAAsB,CAAC;SACnC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC","sourcesContent":["import type { CommandFunction } from '../../types/CommandFunction.js';\n\nexport const init: CommandFunction = ({ command }) => {\n command\n .command('dashboard')\n .description('Shows the dashboard.')\n .action(() => console.log('i am showing the dashboard.'));\n};\n"]}
@@ -1,9 +1,11 @@
1
1
  import type { PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
+ import { type TaskReporter } from '@ms-cloudpack/task-reporter';
2
3
  /**
3
4
  * Bundle the package and return the imports it depends on.
4
5
  */
5
6
  export declare function bundleAndGetImports(options: {
6
7
  packages: PackageDefinitionsCache;
8
+ reporter: TaskReporter;
7
9
  packagePath: string;
8
10
  definition: PackageJson;
9
11
  }): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"bundleAndGetImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAMxF;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACpC,CAAC,CAiED"}
1
+ {"version":3,"file":"bundleAndGetImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAGxF,OAAO,EAAE,KAAK,YAAY,EAA2C,MAAM,6BAA6B,CAAC;AAEzG;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACpC,CAAC,CAiED"}
@@ -3,14 +3,13 @@ import { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';
3
3
  import { getBundleDetails } from '../../common/getBundleDetails.js';
4
4
  import { findImports } from './findImports.js';
5
5
  import { prepareOutputPath } from '../../common/prepareOutputPath.js';
6
- import { reporter } from '../../reporter.js';
7
6
  import { bundleTask } from '../../tasks/bundleTask.js';
8
7
  import { bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';
9
8
  /**
10
9
  * Bundle the package and return the imports it depends on.
11
10
  */
12
11
  export async function bundleAndGetImports(options) {
13
- const { packagePath, definition, packages } = options;
12
+ const { packagePath, definition, packages, reporter } = options;
14
13
  const { outputPath, isExternal } = await getBundleDetails(packagePath);
15
14
  if (!isExternal && !definition.exports) {
16
15
  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;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,E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AK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAC5C,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,WAAW,GAAG,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,EAAE,CAC9E,CACF,CAAC;IACJ,CAAC,EAAE,EAAc,CAAC,CAAC;AACrB,CAAC","sourcesContent":["import path from 'path';\nimport { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';\nimport { getBundleDetails } from '../../common/getBundleDetails.js';\nimport { findImports } from './findImports.js';\nimport { prepareOutputPath } from '../../common/prepareOutputPath.js';\nimport type { PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { reporter } from '../../reporter.js';\nimport type { BundleRequest } from '../../types/BundleRequest.js';\nimport { bundleTask } from '../../tasks/bundleTask.js';\nimport { bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';\n\n/**\n * Bundle the package and return the imports it depends on.\n */\nexport async function bundleAndGetImports(options: {\n packages: PackageDefinitionsCache;\n packagePath: string;\n definition: PackageJson;\n}): Promise<{\n hasWarnings: boolean;\n hasErrors: boolean;\n /** Map from package name to set of required relative paths */\n imports?: Map<string, Set<string>>;\n}> {\n const { packagePath, definition, packages } = options;\n const { outputPath, isExternal } = await getBundleDetails(packagePath);\n\n if (!isExternal && !definition.exports) {\n console.debug(`${path.join(packagePath, 'package.json')} does not have an \"exports\" field.`);\n }\n\n // Ensure outputPath exists and is empty.\n await prepareOutputPath(outputPath);\n\n // Determine entries.\n const entriesMap = await getEntriesMapFromPackage({\n inputPath: packagePath,\n packages,\n });\n\n if (!Object.keys(entriesMap).length) {\n console.warn(\n `${path.join(packagePath, 'package.json')} does not specify any entry points.`,\n isExternal\n ? ''\n : 'If this package contains code imported by other packages, please consider adding an \"exports\" field.',\n );\n return { hasWarnings: true, hasErrors: false };\n }\n\n const bundleRequest: BundleRequest = {\n id: packagePath,\n packageName: definition.name || '',\n version: definition.version || '',\n packagePath,\n outputPath,\n isExternal,\n packages,\n };\n\n await bundleTask({ bundleRequest, options: { force: true } });\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(\n bundleRequest.result?.outputFiles?.map((file) => path.resolve(outputPath, file.outputPath)) || [],\n )) || {},\n ),\n );\n\n const importCount = imports.size;\n\n return {\n status: 'complete',\n message: importCount ? `Found ${plural(importCount, 'imported package')}` : undefined,\n details: importCount ? `${bulletedList(getImportsList(imports))}` : undefined,\n };\n });\n\n return {\n hasWarnings: !!bundleRequest.result?.warnings?.length,\n hasErrors: !!bundleRequest.result?.errors?.length,\n imports,\n };\n}\n\nfunction getImportsList(imports: Map<string, Set<string>>): string[] {\n return Array.from(imports.keys()).reduce((list, packageName) => {\n return list.concat(\n Array.from(imports.get(packageName) || []).map(\n (importPath) => `${packageName}${importPath === '.' ? '' : `/${importPath}`}`,\n ),\n );\n }, [] as string[]);\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,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAGtE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAqB,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAEzG;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,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G,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,EAAE,CAC9E,CACF,CAAC;IACJ,CAAC,EAAE,EAAc,CAAC,CAAC;AACrB,CAAC","sourcesContent":["import path from 'path';\nimport { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';\nimport { getBundleDetails } from '../../common/getBundleDetails.js';\nimport { findImports } from './findImports.js';\nimport { prepareOutputPath } from '../../common/prepareOutputPath.js';\nimport type { PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { BundleRequest } from '../../types/BundleRequest.js';\nimport { bundleTask } from '../../tasks/bundleTask.js';\nimport { type TaskReporter, bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';\n\n/**\n * Bundle the package and return the imports it depends on.\n */\nexport async function bundleAndGetImports(options: {\n packages: PackageDefinitionsCache;\n reporter: TaskReporter;\n packagePath: string;\n definition: PackageJson;\n}): Promise<{\n hasWarnings: boolean;\n hasErrors: boolean;\n /** Map from package name to set of required relative paths */\n imports?: Map<string, Set<string>>;\n}> {\n const { packagePath, definition, packages, reporter } = options;\n const { outputPath, isExternal } = await getBundleDetails(packagePath);\n\n if (!isExternal && !definition.exports) {\n console.debug(`${path.join(packagePath, 'package.json')} does not have an \"exports\" field.`);\n }\n\n // Ensure outputPath exists and is empty.\n await prepareOutputPath(outputPath);\n\n // Determine entries.\n const entriesMap = await getEntriesMapFromPackage({\n inputPath: packagePath,\n packages,\n });\n\n if (!Object.keys(entriesMap).length) {\n console.warn(\n `${path.join(packagePath, 'package.json')} does not specify any entry points.`,\n isExternal\n ? ''\n : 'If this package contains code imported by other packages, please consider adding an \"exports\" field.',\n );\n return { hasWarnings: true, hasErrors: false };\n }\n\n const bundleRequest: BundleRequest = {\n id: packagePath,\n packageName: definition.name || '',\n version: definition.version || '',\n packagePath,\n outputPath,\n isExternal,\n packages,\n };\n\n await bundleTask({ bundleRequest, options: { force: true } });\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(\n bundleRequest.result?.outputFiles?.map((file) => path.resolve(outputPath, file.outputPath)) || [],\n )) || {},\n ),\n );\n\n const importCount = imports.size;\n\n return {\n status: 'complete',\n message: importCount ? `Found ${plural(importCount, 'imported package')}` : undefined,\n details: importCount ? `${bulletedList(getImportsList(imports))}` : undefined,\n };\n });\n\n return {\n hasWarnings: !!bundleRequest.result?.warnings?.length,\n hasErrors: !!bundleRequest.result?.errors?.length,\n imports,\n };\n}\n\nfunction getImportsList(imports: Map<string, Set<string>>): string[] {\n return Array.from(imports.keys()).reduce((list, packageName) => {\n return list.concat(\n Array.from(imports.get(packageName) || []).map(\n (importPath) => `${packageName}${importPath === '.' ? '' : `/${importPath}`}`,\n ),\n );\n }, [] as string[]);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"findImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/findImports.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CA2D3F"}
1
+ {"version":3,"file":"findImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/findImports.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAoE3F"}
@@ -2,7 +2,10 @@ import { parse } from 'es-module-lexer';
2
2
  import fsPromises from 'fs/promises';
3
3
  import path from 'path';
4
4
  import { parseImportString } from '@ms-cloudpack/path-string-parsing';
5
+ import { sourceExtensions } from '@ms-cloudpack/path-utilities';
5
6
  import { builtinModules } from 'module';
7
+ /** Treat files with no extension as JS for purposes below */
8
+ const allSourceExtensions = [...sourceExtensions, ''];
6
9
  /**
7
10
  * Returns a dictionary where key is the package name and value is a set of required paths.
8
11
  * Eg. `{ '@fluentui/react': new Set([ '.', './lib/Button' ]) }`
@@ -13,11 +16,21 @@ export async function findImports(filePaths) {
13
16
  const pathsToParse = [...filePaths];
14
17
  while (pathsToParse.length) {
15
18
  const filePath = pathsToParse.shift();
16
- if (!filePath) {
19
+ // Ignore any non-JS/TS files such as SVGs
20
+ if (!filePath || !allSourceExtensions.includes(path.extname(filePath))) {
17
21
  continue;
18
22
  }
19
23
  const source = await fsPromises.readFile(filePath, 'utf-8');
20
- const [rawImports] = parse(source);
24
+ let rawImports;
25
+ try {
26
+ [rawImports] = parse(source);
27
+ }
28
+ catch (err) {
29
+ // This could happen if the source file isn't valid JS
30
+ // (unlikely after adding the check above to only attempt parsing JS/TS files)
31
+ console.warn(`Failed to parse ${filePath}:`, err);
32
+ continue;
33
+ }
21
34
  const imports = Array.from(new Set(rawImports))
22
35
  .map((i) => {
23
36
  // The es-module-lexer returns entries where the "n" property equals the import source.
@@ -1 +1 @@
1
- {"version":3,"file":"findImports.js","sourceRoot":"","sources":["../../../src/commands/init/findImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAA2B,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,SAAmB;IACnD,MAAM,eAAe,GAAgC,EAAE,CAAC;IACxD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,YAAY,GAAa,CAAC,GAAG,SAAS,CAAC,CAAC;IAE9C,OAAO,YAAY,CAAC,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AAE;oBAChC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;oBAC5B,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;iBAC9B;aACF;iBAAM,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACnG,eAAe,CAAC,WAAW,MAA3B,eAAe,CAAC,WAAW,IAAM,IAAI,GAAG,EAAE,EAAC;gBAC3C,eAAe,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;aACrD;SACF;KACF;IAED,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import { parse } from 'es-module-lexer';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { parseImportString, type ImportStringResult } from '@ms-cloudpack/path-string-parsing';\nimport { builtinModules } from 'module';\n\n/**\n * Returns a dictionary where key is the package name and value is a set of required paths.\n * Eg. `{ '@fluentui/react': new Set([ '.', './lib/Button' ]) }`\n */\nexport async function findImports(filePaths: string[]): Promise<Record<string, Set<string>>> {\n const requiredExports: Record<string, Set<string>> = {};\n const visitedPaths = new Set(filePaths);\n const pathsToParse: string[] = [...filePaths];\n\n while (pathsToParse.length) {\n const filePath = pathsToParse.shift();\n if (!filePath) {\n continue;\n }\n\n const source = await fsPromises.readFile(filePath, 'utf-8');\n const [rawImports] = parse(source);\n const imports = Array.from(new Set(rawImports))\n .map((i) => {\n // The es-module-lexer returns entries where the \"n\" property equals the import source.\n // This includes the package name and path. For example, in this case:\n //\n // import { Button } from '@fluentui/react/lib/Button';\n //\n // The \"n\" property would be \"@fluentui/react/lib/Button\".\n // The \"s\" and \"e\" properties represent the start/end character positions of\n // the import source. The \"ss\" and \"se\" properties represent the start/end\n // character positions of the import specifier starting with \"import\". This\n // may be useful for determining if the import is sync or async.\n //\n // Currently when the import source is a backtick string, the \"n\" property\n // is undefined. This is a bug in es-module-lexer. We may need to handle this\n // at the javascript layer and expand it into multiple potential imports.\n if (!i.n) {\n console.debug(\n `Found an import that didn't parse correctly:\\nFilename:\\n${filePath}\\n\\nImport:\\n${source.slice(\n i.s,\n i.e,\n )}`,\n );\n return undefined;\n }\n\n return parseImportString(i.n);\n })\n .filter(Boolean) as ImportStringResult[];\n\n for (const { packageName, importPath } of imports) {\n if (packageName?.startsWith('.')) {\n const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');\n\n if (!visitedPaths.has(localPath)) {\n visitedPaths.add(localPath);\n pathsToParse.push(localPath);\n }\n } else if (packageName && !packageName.startsWith('node:') && !builtinModules.includes(packageName)) {\n requiredExports[packageName] ||= new Set();\n requiredExports[packageName].add(importPath || '.');\n }\n }\n }\n\n return requiredExports;\n}\n"]}
1
+ {"version":3,"file":"findImports.js","sourceRoot":"","sources":["../../../src/commands/init/findImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAA2B,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,6DAA6D;AAC7D,MAAM,mBAAmB,GAAG,CAAC,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,SAAmB;IACnD,MAAM,eAAe,GAAgC,EAAE,CAAC;IACxD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,YAAY,GAAa,CAAC,GAAG,SAAS,CAAC,CAAC;IAE9C,OAAO,YAAY,CAAC,MAAM,EAAE;QAC1B,MAAM,QAAQ,GAAG,YAAY,CAAC,KAA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,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE;gBAChC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;gBAEtF,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;oBAChC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;oBAC5B,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;iBAC9B;aACF;iBAAM,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACnG,eAAe,CAAC,WAAW,MAA3B,eAAe,CAAC,WAAW,IAAM,IAAI,GAAG,EAAE,EAAC;gBAC3C,eAAe,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;aACrD;SACF;KACF;IAED,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import { parse } from 'es-module-lexer';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { parseImportString, type ImportStringResult } from '@ms-cloudpack/path-string-parsing';\nimport { sourceExtensions } from '@ms-cloudpack/path-utilities';\nimport { builtinModules } from 'module';\n\n/** Treat files with no extension as JS for purposes below */\nconst allSourceExtensions = [...sourceExtensions, ''];\n\n/**\n * Returns a dictionary where key is the package name and value is a set of required paths.\n * Eg. `{ '@fluentui/react': new Set([ '.', './lib/Button' ]) }`\n */\nexport async function findImports(filePaths: string[]): Promise<Record<string, Set<string>>> {\n const requiredExports: Record<string, Set<string>> = {};\n const visitedPaths = new Set(filePaths);\n const pathsToParse: string[] = [...filePaths];\n\n while (pathsToParse.length) {\n const filePath = pathsToParse.shift();\n // Ignore any non-JS/TS files such as SVGs\n if (!filePath || !allSourceExtensions.includes(path.extname(filePath))) {\n continue;\n }\n\n const source = await fsPromises.readFile(filePath, 'utf-8');\n let rawImports: ReturnType<typeof parse>[0];\n try {\n [rawImports] = parse(source);\n } catch (err) {\n // This could happen if the source file isn't valid JS\n // (unlikely after adding the check above to only attempt parsing JS/TS files)\n console.warn(`Failed to parse ${filePath}:`, err);\n continue;\n }\n const imports = Array.from(new Set(rawImports))\n .map((i) => {\n // The es-module-lexer returns entries where the \"n\" property equals the import source.\n // This includes the package name and path. For example, in this case:\n //\n // import { Button } from '@fluentui/react/lib/Button';\n //\n // The \"n\" property would be \"@fluentui/react/lib/Button\".\n // The \"s\" and \"e\" properties represent the start/end character positions of\n // the import source. The \"ss\" and \"se\" properties represent the start/end\n // character positions of the import specifier starting with \"import\". This\n // may be useful for determining if the import is sync or async.\n //\n // Currently when the import source is a backtick string, the \"n\" property\n // is undefined. This is a bug in es-module-lexer. We may need to handle this\n // at the javascript layer and expand it into multiple potential imports.\n if (!i.n) {\n console.debug(\n `Found an import that didn't parse correctly:\\nFilename:\\n${filePath}\\n\\nImport:\\n${source.slice(\n i.s,\n i.e,\n )}`,\n );\n return undefined;\n }\n\n return parseImportString(i.n);\n })\n .filter(Boolean) as ImportStringResult[];\n\n for (const { packageName, importPath } of imports) {\n if (packageName?.startsWith('.')) {\n const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');\n\n if (!visitedPaths.has(localPath)) {\n visitedPaths.add(localPath);\n pathsToParse.push(localPath);\n }\n } else if (packageName && !packageName.startsWith('node:') && !builtinModules.includes(packageName)) {\n requiredExports[packageName] ||= new Set();\n requiredExports[packageName].add(importPath || '.');\n }\n }\n }\n\n return requiredExports;\n}\n"]}
@@ -1,3 +1,3 @@
1
- import type { Command } from 'commander';
2
- export declare function init(command: Command): void;
1
+ import type { CommandFunction } from '../../types/CommandFunction.js';
2
+ export declare const init: CommandFunction;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzC,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,QAkDpC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE,eAAO,MAAM,IAAI,EAAE,eAkDlB,CAAC"}
@@ -1,22 +1,21 @@
1
- import { reporter } from '../../reporter.js';
2
1
  import { plural, red, yellow } from '@ms-cloudpack/task-reporter';
3
2
  import { configFileName } from '@ms-cloudpack/config';
4
3
  import { stopTelemetry } from '../../initTelemetry.js';
5
4
  /* Defines the "init" verb. */
6
- export function init(command) {
5
+ export const init = ({ command, reporter }) => {
7
6
  command
8
7
  .command('init')
9
8
  .description('Initializes a given app project and defines the necessary configuration overrides to make an existing app compatible with Cloudpack.')
10
9
  .option('--fix', 'Applies fixes to all identified issues in internal packages.')
11
10
  .option('--reset', 'Ignores existing overrides when determining all entries.')
12
11
  .option('--check', 'Fails if any package exports are missing.')
13
- .action(async (options) => {
12
+ .action(async (options, context) => {
14
13
  const { init } = await import('./init.js');
15
14
  let completeReason;
16
15
  let hasErrors = false;
17
16
  let hasWarnings = false;
18
17
  try {
19
- const { changeCount, errorPkgCount, warningPkgCount, successPkgCount } = await init(options);
18
+ const { changeCount, errorPkgCount, warningPkgCount, successPkgCount } = await init(options, context);
20
19
  hasErrors = errorPkgCount > 0;
21
20
  hasWarnings = warningPkgCount > 0;
22
21
  const totalCount = errorPkgCount + warningPkgCount + successPkgCount;
@@ -46,5 +45,5 @@ export function init(command) {
46
45
  reporter.complete(hasErrors ? red(completeReason) : hasWarnings ? yellow(completeReason) : completeReason);
47
46
  process.exit(hasErrors ? 1 : 0);
48
47
  });
49
- }
48
+ };
50
49
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","s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,UAAU,kCAAkC;wBACjF,SAAS,IAAI,GAAG,aAAa,uBAAuB;wBACpD,WAAW,IAAI,GAAG,eAAe,yBAAyB;qBAC3D;yBACE,MAAM,CAAC,OAAO,CAAC;yBACf,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;aACxB;iBAAM;gBACL,cAAc,GAAG,OAAO,UAAU,gCAAgC,CAAC;aACpE;YAED,IAAI,WAAW,EAAE;gBACf,cAAc,IAAI,gBAAgB,cAAc,UAAU,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC;aAC5F;SACF;QAAC,OAAO,KAAK,EAAE;YACd,SAAS,GAAG,IAAI,CAAC;YACjB,cAAc,GAAG,qBAAsB,KAAe,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC;SAC3E;QAED,MAAM,aAAa,EAAE,CAAC;QACtB,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;QAE3G,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Command } from 'commander';\nimport type { InitOptions } from './types/InitOptions.js';\nimport { reporter } from '../../reporter.js';\nimport { plural, red, yellow } from '@ms-cloudpack/task-reporter';\nimport { configFileName } from '@ms-cloudpack/config';\nimport { stopTelemetry } from '../../initTelemetry.js';\n\n/* Defines the \"init\" verb. */\nexport function init(command: Command) {\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('--fix', 'Applies fixes to all identified issues in internal packages.')\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) => {\n const { init } = await import('./init.js');\n\n let completeReason: string | undefined;\n let hasErrors = false;\n let hasWarnings = false;\n try {\n const { changeCount, errorPkgCount, warningPkgCount, successPkgCount } = await init(options);\n\n hasErrors = errorPkgCount > 0;\n hasWarnings = warningPkgCount > 0;\n\n const totalCount = errorPkgCount + warningPkgCount + successPkgCount;\n\n if (hasErrors || hasWarnings) {\n const successPct = ((successPkgCount / totalCount) * 100).toFixed(1);\n completeReason =\n [\n `${successPkgCount}/${totalCount} (${successPct}%) packages bundled successfully`,\n hasErrors && `${errorPkgCount} packages with errors`,\n hasWarnings && `${warningPkgCount} packages with warnings`,\n ]\n .filter(Boolean)\n .join('\\n') + '\\n';\n } else {\n completeReason = `All ${totalCount} packages bundled successfully`;\n }\n\n if (changeCount) {\n completeReason += `\\n\\nUpdated \"${configFileName}\" with ${plural(changeCount, 'change')}.`;\n }\n } catch (error) {\n hasErrors = true;\n completeReason = `Unexpected error: ${(error as Error).message || error}`;\n }\n\n await stopTelemetry();\n reporter.complete(hasErrors ? red(completeReason) : hasWarnings ? yellow(completeReason) : completeReason);\n\n process.exit(hasErrors ? 1 : 0);\n });\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,8BAA8B;AAC9B,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC7D,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CACV,sIAAsI,CACvI;SACA,MAAM,CAAC,OAAO,EAAE,8DAA8D,CAAC;SAC/E,MAAM,CAAC,SAAS,EAAE,0DAA0D,C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OAAO,IAAI,KAAK,EAAE,CAAC;SAC3E;QAED,MAAM,aAAa,EAAE,CAAC;QACtB,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;QAE3G,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import type { InitOptions } from './types/InitOptions.js';\nimport { type TaskReporter, plural, red, yellow } from '@ms-cloudpack/task-reporter';\nimport { configFileName } from '@ms-cloudpack/config';\nimport { stopTelemetry } from '../../initTelemetry.js';\nimport type { CommandFunction } from '../../types/CommandFunction.js';\n\n/* Defines the \"init\" verb. */\nexport const init: CommandFunction = ({ command, reporter }) => {\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('--fix', 'Applies fixes to all identified issues in internal packages.')\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, context: { reporter: TaskReporter }) => {\n const { init } = await import('./init.js');\n\n let completeReason: string | undefined;\n let hasErrors = false;\n let hasWarnings = false;\n try {\n const { changeCount, errorPkgCount, warningPkgCount, successPkgCount } = await init(options, context);\n\n hasErrors = errorPkgCount > 0;\n hasWarnings = warningPkgCount > 0;\n\n const totalCount = errorPkgCount + warningPkgCount + successPkgCount;\n\n if (hasErrors || hasWarnings) {\n const successPct = ((successPkgCount / totalCount) * 100).toFixed(1);\n completeReason =\n [\n `${successPkgCount}/${totalCount} (${successPct}%) packages bundled successfully`,\n hasErrors && `${errorPkgCount} packages with errors`,\n hasWarnings && `${warningPkgCount} packages with warnings`,\n ]\n .filter(Boolean)\n .join('\\n') + '\\n';\n } else {\n completeReason = `All ${totalCount} packages bundled successfully`;\n }\n\n if (changeCount) {\n completeReason += `\\n\\nUpdated \"${configFileName}\" with ${plural(changeCount, 'change')}.`;\n }\n } catch (error) {\n hasErrors = true;\n completeReason = `Unexpected error: ${(error as Error).message || error}`;\n }\n\n await stopTelemetry();\n reporter.complete(hasErrors ? red(completeReason) : hasWarnings ? yellow(completeReason) : completeReason);\n\n process.exit(hasErrors ? 1 : 0);\n });\n};\n"]}
@@ -1,6 +1,9 @@
1
1
  import type { InitOptions } from './types/InitOptions.js';
2
+ import type { TaskReporter } from '@ms-cloudpack/task-reporter';
2
3
  /** Given the path, updates the Cloudpack config with overrides and project settings. */
3
- export declare function init(options: InitOptions): Promise<{
4
+ export declare function init(options: InitOptions, { reporter }: {
5
+ reporter: TaskReporter;
6
+ }): Promise<{
4
7
  changeCount: number;
5
8
  errorPkgCount: number;
6
9
  warningPkgCount: number;
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,wFAAwF;AACxF,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAiHD"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,wFAAwF;AACxF,wBAAsB,IAAI,CACxB,OAAO,EAAE,WAAW,EACpB,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,GACvC,OAAO,CAAC;IACT,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAiHD"}
@@ -7,7 +7,7 @@ import { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';
7
7
  import { bundleAndGetImports } from './bundleAndGetImports.js';
8
8
  import { patchAllInternalPackageExports } from './patchAllInternalPackageExports.js';
9
9
  /** Given the path, updates the Cloudpack config with overrides and project settings. */
10
- export async function init(options) {
10
+ export async function init(options, { reporter }) {
11
11
  if (options.check && options.fix) {
12
12
  throw Error('Cannot use --check and --fix together.');
13
13
  }
@@ -20,7 +20,7 @@ export async function init(options) {
20
20
  const packages = new PackageDefinitions();
21
21
  packages.registerTransform(createPackageOverrideTransform({ packageOverrides }));
22
22
  // Try to resolve dependencies.
23
- const resolveMap = (await resolveDependenciesTask({ appPath, packages }));
23
+ const resolveMap = (await resolveDependenciesTask({ appPath, packages }, { reporter }));
24
24
  if (!resolveMap) {
25
25
  throw new Error("Couldn't resolve dependencies.");
26
26
  }
@@ -46,7 +46,7 @@ export async function init(options) {
46
46
  continue;
47
47
  }
48
48
  // Bundle the package and find the imports it depends on.
49
- const bundleResult = await bundleAndGetImports({ packagePath, definition, packages });
49
+ const bundleResult = await bundleAndGetImports({ packagePath, definition, packages, reporter });
50
50
  if (!bundleResult.imports) {
51
51
  // This is expected if the package just doesn't import anything else.
52
52
  console.info(`${packagePath} has no additional imports to evaluate.`);
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,8BA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D;KACF;IAED,OAAO;QACL,WAAW;QACX,aAAa;QACb,eAAe;QACf,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageOverride } from '@ms-cloudpack/config';\nimport { generatedConfigFileName, readConfig, writeGeneratedConfig } from '@ms-cloudpack/config';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport { createPackageOverrideTransform } from '../../common/createPackageOverrideTransform.js';\nimport { rootSpan } from '../../initTelemetry.js';\nimport { resolveDependenciesTask } from '../../tasks/resolveDependenciesTask.js';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport { bundleAndGetImports } from './bundleAndGetImports.js';\nimport { patchAllInternalPackageExports } from './patchAllInternalPackageExports.js';\nimport type { InitOptions } from './types/InitOptions.js';\n\n/** Given the path, updates the Cloudpack config with overrides and project settings. */\nexport async function init(options: InitOptions): Promise<{\n changeCount: number;\n errorPkgCount: number;\n warningPkgCount: number;\n successPkgCount: number;\n}> {\n if (options.check && options.fix) {\n throw Error('Cannot use --check and --fix together.');\n }\n\n if (options.check && options.reset) {\n throw Error('Cannot use --check and --reset together.');\n }\n\n const appPath = options.cwd || process.cwd();\n const config = await readConfig(appPath);\n const packageOverrides: PackageOverride[] = (!options.reset && config.packageOverrides) || [];\n const packages = new PackageDefinitions();\n\n packages.registerTransform(createPackageOverrideTransform({ packageOverrides }));\n\n // Try to resolve dependencies.\n const resolveMap = (await resolveDependenciesTask({ appPath, packages })) as ResolveMap;\n\n if (!resolveMap) {\n throw new Error(\"Couldn't resolve dependencies.\");\n }\n\n const packagePathsToEvaluate = new Set<string>([appPath]);\n const evaluatedPackages = new Set<string>();\n let changeCount = 0;\n let errorPkgCount = 0;\n let warningPkgCount = 0;\n let successPkgCount = 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 errorPkgCount++;\n continue;\n }\n\n // Bundle the package and find the imports it depends on.\n const bundleResult = await bundleAndGetImports({ packagePath, definition, packages });\n\n if (!bundleResult.imports) {\n // This is expected if the package just doesn't import anything else.\n console.info(`${packagePath} has no additional imports to evaluate.`);\n bundleResult.hasErrors ? errorPkgCount++ : bundleResult.hasWarnings ? warningPkgCount++ : successPkgCount++;\n continue;\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const overridesResult = await evaluateImportsForOverrides({\n definition,\n packages,\n packagePathsToEvaluate,\n evaluatedPackages,\n imports: bundleResult.imports,\n packageOverrides,\n resolveMap,\n });\n\n if (options.check && (overridesResult.changeCount || overridesResult.errors.length)) {\n rootSpan?.addEvent('INIT_CHECK_FAILED', {\n reason: overridesResult.changeCount ? 'Config needs to be updated.' : overridesResult.errors,\n });\n throw Error(\n overridesResult.changeCount\n ? 'Run \"cloudpack init --reset\" to update the config.'\n : overridesResult.errors.map((e) => e).join('\\n'),\n );\n }\n\n changeCount += overridesResult.changeCount;\n\n bundleResult.hasErrors || overridesResult.errors.length\n ? errorPkgCount++\n : bundleResult.hasWarnings\n ? warningPkgCount++\n : successPkgCount++;\n }\n\n if (options.fix) {\n await patchAllInternalPackageExports({ resolveMap, packageOverrides });\n }\n\n if (changeCount) {\n // Log the results to a file.\n console.log(\n `Writing updates to \"${generatedConfigFileName}\". If you're in a git repo, this file should be committed with your project.`,\n );\n\n if (packageOverrides.length) {\n await writeGeneratedConfig({ packageOverrides }, appPath);\n }\n }\n\n return {\n changeCount,\n errorPkgCount,\n warningPkgCount,\n successPkgCount,\n };\n}\n"]}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],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;KACxE;IAED,IAAI,WAAW,EAAE;QACf,6BAA6B;QAC7B,OAAO,CAAC,GAAG,CACT,uBAAuB,uBAAuB,8EAA8E,CAC7H,CAAC;QAEF,IAAI,gBAAgB,CAAC,MAAM,EAAE;YAC3B,MAAM,oBAAoB,CAAC,EAAE,gBAAgB,EAAE,EAAE,OAAO,CAAC,CAAC;SAC3D;KACF;IAED,OAAO;QACL,WAAW;QACX,aAAa;QACb,eAAe;QACf,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageOverride } from '@ms-cloudpack/config';\nimport { generatedConfigFileName, readConfig, writeGeneratedConfig } from '@ms-cloudpack/config';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport { createPackageOverrideTransform } from '../../common/createPackageOverrideTransform.js';\nimport { rootSpan } from '../../initTelemetry.js';\nimport { resolveDependenciesTask } from '../../tasks/resolveDependenciesTask.js';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport { bundleAndGetImports } from './bundleAndGetImports.js';\nimport { patchAllInternalPackageExports } from './patchAllInternalPackageExports.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\n\n/** Given the path, updates the Cloudpack config with overrides and project settings. */\nexport async function init(\n options: InitOptions,\n { reporter }: { reporter: TaskReporter },\n): Promise<{\n changeCount: number;\n errorPkgCount: number;\n warningPkgCount: number;\n successPkgCount: number;\n}> {\n if (options.check && options.fix) {\n throw Error('Cannot use --check and --fix together.');\n }\n\n if (options.check && options.reset) {\n throw Error('Cannot use --check and --reset together.');\n }\n\n const appPath = options.cwd || process.cwd();\n const config = await readConfig(appPath);\n const packageOverrides: PackageOverride[] = (!options.reset && config.packageOverrides) || [];\n const packages = new PackageDefinitions();\n\n packages.registerTransform(createPackageOverrideTransform({ packageOverrides }));\n\n // Try to resolve dependencies.\n const resolveMap = (await resolveDependenciesTask({ appPath, packages }, { reporter })) as ResolveMap;\n\n if (!resolveMap) {\n throw new Error(\"Couldn't resolve dependencies.\");\n }\n\n const packagePathsToEvaluate = new Set<string>([appPath]);\n const evaluatedPackages = new Set<string>();\n let changeCount = 0;\n let errorPkgCount = 0;\n let warningPkgCount = 0;\n let successPkgCount = 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 errorPkgCount++;\n continue;\n }\n\n // Bundle the package and find the imports it depends on.\n const bundleResult = await bundleAndGetImports({ packagePath, definition, packages, reporter });\n\n if (!bundleResult.imports) {\n // This is expected if the package just doesn't import anything else.\n console.info(`${packagePath} has no additional imports to evaluate.`);\n bundleResult.hasErrors ? errorPkgCount++ : bundleResult.hasWarnings ? warningPkgCount++ : successPkgCount++;\n continue;\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const overridesResult = await evaluateImportsForOverrides({\n definition,\n packages,\n packagePathsToEvaluate,\n evaluatedPackages,\n imports: bundleResult.imports,\n packageOverrides,\n resolveMap,\n });\n\n if (options.check && (overridesResult.changeCount || overridesResult.errors.length)) {\n rootSpan?.addEvent('INIT_CHECK_FAILED', {\n reason: overridesResult.changeCount ? 'Config needs to be updated.' : overridesResult.errors,\n });\n throw Error(\n overridesResult.changeCount\n ? 'Run \"cloudpack init --reset\" to update the config.'\n : overridesResult.errors.map((e) => e).join('\\n'),\n );\n }\n\n changeCount += overridesResult.changeCount;\n\n bundleResult.hasErrors || overridesResult.errors.length\n ? errorPkgCount++\n : bundleResult.hasWarnings\n ? warningPkgCount++\n : successPkgCount++;\n }\n\n if (options.fix) {\n await patchAllInternalPackageExports({ resolveMap, packageOverrides });\n }\n\n if (changeCount) {\n // Log the results to a file.\n console.log(\n `Writing updates to \"${generatedConfigFileName}\". If you're in a git repo, this file should be committed with your project.`,\n );\n\n if (packageOverrides.length) {\n await writeGeneratedConfig({ packageOverrides }, appPath);\n }\n }\n\n return {\n changeCount,\n errorPkgCount,\n warningPkgCount,\n successPkgCount,\n };\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { BundleServer } from '../../../types/BundleServer.js';
2
2
  import type { PackageJson } from '@ms-cloudpack/bundler-types';
3
+ import { type TaskReporter } from '@ms-cloudpack/task-reporter';
3
4
  import type { CloudpackConfig } from '@ms-cloudpack/config';
4
5
  import type { ApiServer, Session } from '@ms-cloudpack/api-server';
5
6
  /**
@@ -10,12 +11,13 @@ import type { ApiServer, Session } from '@ms-cloudpack/api-server';
10
11
  * can support whichever routes the app needs, while the bundle server can provide package
11
12
  * assets in various forms using its own routing.
12
13
  */
13
- export declare function startAppServer({ session, bundleServer, apiServer, definition, config, }: {
14
+ export declare function startAppServer({ session, bundleServer, apiServer, definition, config, reporter, }: {
14
15
  session: Session;
15
16
  definition: PackageJson;
16
17
  bundleServer: BundleServer;
17
18
  apiServer: ApiServer;
18
19
  config: CloudpackConfig;
20
+ reporter: TaskReporter;
19
21
  }): Promise<{
20
22
  close: () => Promise<void>;
21
23
  port: number;
@@ -1 +1 @@
1
- {"version":3,"file":"startAppServer.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAK/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,EACV,MAA8B,GAC/B,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;CACzB;;;;GA6CA"}
1
+ {"version":3,"file":"startAppServer.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,KAAK,YAAY,EAAQ,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,EACV,MAA8B,EAC9B,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,YAAY,CAAC;CACxB;;;;GA6CA"}
@@ -1,7 +1,6 @@
1
1
  import { createExpressApp } from '@ms-cloudpack/create-express-app';
2
2
  import { createRoutes } from './createRoutes.js';
3
3
  import { exitIfPortUnavailable } from './exitIfPortUnavailable.js';
4
- import { reporter } from '../../../reporter.js';
5
4
  import { cyan } from '@ms-cloudpack/task-reporter';
6
5
  /**
7
6
  * The app server hosts the appropriate routes for the web app, primarily returning html content
@@ -11,7 +10,7 @@ import { cyan } from '@ms-cloudpack/task-reporter';
11
10
  * can support whichever routes the app needs, while the bundle server can provide package
12
11
  * assets in various forms using its own routing.
13
12
  */
14
- export async function startAppServer({ session, bundleServer, apiServer, definition, config = {}, }) {
13
+ export async function startAppServer({ session, bundleServer, apiServer, definition, config = {}, reporter, }) {
15
14
  const { devServer = {} } = config || {};
16
15
  // Read the port from the config file or default to array of ports.
17
16
  const requireSpecifiedPort = devServer?.port !== undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAInD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,EACV,MAAM,GAAG,EAAqB,GAO/B;IACC,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,MAAM,IAAK,EAAsB,CAAC;IAE7D,mEAAmE;IACnE,MAAM,oBAAoB,GAAG,SAAS,EAAE,IAAI,KAAK,SAAS,CAAC;IAC3D,MAAM,KAAK,GAAG,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAE1D,mEAAmE;IACnE,+EAA+E;IAC/E,oEAAoE;IAEpE,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAErD,IAAI;QACF,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,gBAAgB,CAAC;YAClD,SAAS,EAAE,KAAK;YAChB,oBAAoB;YACpB,QAAQ,EAAE,SAAS,EAAE,MAAM;YAC3B,UAAU,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK;YACnC,cAAc;YACd,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAC1B,YAAY,CAAC;gBACX,GAAG;gBACH,GAAG;gBACH,OAAO;gBACP,UAAU;gBACV,YAAY;gBACZ,SAAS;gBACT,MAAM;aACP,CAAC;SACL,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,eAAe,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAExE,OAAO;YACL,KAAK;YACL,IAAI;YACJ,GAAG;SACJ,CAAC;KACH;IAAC,OAAO,GAAY,EAAE;QACrB,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,4BAA4B,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1F,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAEvD,MAAM,GAAG,CAAC;KACX;AACH,CAAC","sourcesContent":["import { createExpressApp } from '@ms-cloudpack/create-express-app';\nimport type { BundleServer } from '../../../types/BundleServer.js';\nimport type { PackageJson } from '@ms-cloudpack/bundler-types';\nimport { createRoutes } from './createRoutes.js';\nimport { exitIfPortUnavailable } from './exitIfPortUnavailable.js';\nimport { reporter } from '../../../reporter.js';\nimport { cyan } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\n\n/**\n * The app server hosts the appropriate routes for the web app, primarily returning html content\n * which loads resources from the bundle server.\n *\n * Separating the app server from the bundle service keeps the routes separate - the app server\n * can support whichever routes the app needs, while the bundle server can provide package\n * assets in various forms using its own routing.\n */\nexport async function startAppServer({\n session,\n bundleServer,\n apiServer,\n definition,\n config = {} as CloudpackConfig,\n}: {\n session: Session;\n definition: PackageJson;\n bundleServer: BundleServer;\n apiServer: ApiServer;\n config: CloudpackConfig;\n}) {\n const { devServer = {} } = config || ({} as CloudpackConfig);\n\n // Read the port from the config file or default to array of ports.\n const requireSpecifiedPort = devServer?.port !== undefined;\n const ports = devServer?.port ?? [5000, 5001, 5002, 5003];\n\n // Directory to serve as plain static assets. Defaults to \"public\".\n // Can be overridden by setting the 'publicDir' option in the cloudpack config.\n // const publicDir = path.resolve(devServer.publicPath ?? 'public');\n\n const task = reporter.addTask('Starting app server');\n\n try {\n const { close, port, url } = await createExpressApp({\n portRange: ports,\n requireSpecifiedPort,\n hostname: devServer?.domain,\n sslOptions: config.devServer?.https,\n // publicDir,\n setupCallback: (app, url) =>\n createRoutes({\n app,\n url,\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n }),\n });\n\n task.complete({ message: `Available @ ${cyan(url)}`, forceShow: true });\n\n return {\n close,\n port,\n url,\n };\n } catch (err: unknown) {\n task.complete({ status: 'fail', message: 'Failed to start app server', forceShow: true });\n exitIfPortUnavailable(err, session.projectName, ports);\n\n throw err;\n }\n}\n"]}
1
+ {"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAqB,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAItE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,EACV,MAAM,GAAG,EAAqB,EAC9B,QAAQ,GAQT;IACC,MAAM,EAAE,SAAS,GAAG,EAA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} from '@ms-cloudpack/create-express-app';\nimport type { BundleServer } from '../../../types/BundleServer.js';\nimport type { PackageJson } from '@ms-cloudpack/bundler-types';\nimport { createRoutes } from './createRoutes.js';\nimport { exitIfPortUnavailable } from './exitIfPortUnavailable.js';\nimport { type TaskReporter, cyan } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\n\n/**\n * The app server hosts the appropriate routes for the web app, primarily returning html content\n * which loads resources from the bundle server.\n *\n * Separating the app server from the bundle service keeps the routes separate - the app server\n * can support whichever routes the app needs, while the bundle server can provide package\n * assets in various forms using its own routing.\n */\nexport async function startAppServer({\n session,\n bundleServer,\n apiServer,\n definition,\n config = {} as CloudpackConfig,\n reporter,\n}: {\n session: Session;\n definition: PackageJson;\n bundleServer: BundleServer;\n apiServer: ApiServer;\n config: CloudpackConfig;\n reporter: TaskReporter;\n}) {\n const { devServer = {} } = config || ({} as CloudpackConfig);\n\n // Read the port from the config file or default to array of ports.\n const requireSpecifiedPort = devServer?.port !== undefined;\n const ports = devServer?.port ?? [5000, 5001, 5002, 5003];\n\n // Directory to serve as plain static assets. Defaults to \"public\".\n // Can be overridden by setting the 'publicDir' option in the cloudpack config.\n // const publicDir = path.resolve(devServer.publicPath ?? 'public');\n\n const task = reporter.addTask('Starting app server');\n\n try {\n const { close, port, url } = await createExpressApp({\n portRange: ports,\n requireSpecifiedPort,\n hostname: devServer?.domain,\n sslOptions: config.devServer?.https,\n // publicDir,\n setupCallback: (app, url) =>\n createRoutes({\n app,\n url,\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n }),\n });\n\n task.complete({ message: `Available @ ${cyan(url)}`, forceShow: true });\n\n return {\n close,\n port,\n url,\n };\n } catch (err: unknown) {\n task.complete({ status: 'fail', message: 'Failed to start app server', forceShow: true });\n exitIfPortUnavailable(err, session.projectName, ports);\n\n throw err;\n }\n}\n"]}
@@ -1,9 +1,10 @@
1
1
  import type { BundleTaskOptions } from '../../types/BundleTaskOptions.js';
2
2
  import type { BundleRequest } from '../../types/BundleRequest.js';
3
3
  import type { Task } from '@ms-cloudpack/api-server';
4
+ import type { TaskReporter } from '@ms-cloudpack/task-reporter';
4
5
  /**
5
6
  * Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked
6
7
  * remotely (e.g. in the browser) and allows the user to cancel tasks.
7
8
  */
8
- export declare function createBundleTask(bundleRequest: BundleRequest, options?: BundleTaskOptions): Task<BundleRequest>;
9
+ export declare function createBundleTask(bundleRequest: BundleRequest, options?: BundleTaskOptions, reporter?: TaskReporter): Task<BundleRequest>;
9
10
  //# sourceMappingURL=createBundleTask.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createBundleTask.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createBundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAiC,MAAM,0BAA0B,CAAC;AAKpF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC,aAAa,CAAC,CAoC/G"}
1
+ {"version":3,"file":"createBundleTask.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createBundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAiC,MAAM,0BAA0B,CAAC;AAIpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,EAC3B,QAAQ,CAAC,EAAE,YAAY,GACtB,IAAI,CAAC,aAAa,CAAC,CAoCrB"}
@@ -5,7 +5,7 @@ import { bundleTask } from '../../tasks/bundleTask.js';
5
5
  * Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked
6
6
  * remotely (e.g. in the browser) and allows the user to cancel tasks.
7
7
  */
8
- export function createBundleTask(bundleRequest, options) {
8
+ export function createBundleTask(bundleRequest, options, reporter) {
9
9
  const { id, packageName, version, outputPath, packagePath, isExternal } = bundleRequest;
10
10
  return {
11
11
  name: `Bundle ${packageName}@${version}`,
@@ -13,7 +13,7 @@ export function createBundleTask(bundleRequest, options) {
13
13
  dir: `${path.join(packagePath, 'src')}`,
14
14
  watch: !isExternal,
15
15
  async execute() {
16
- await bundleTask({ bundleRequest, options });
16
+ await bundleTask({ bundleRequest, options, reporter });
17
17
  return bundleRequest;
18
18
  },
19
19
  clear: () => {
@@ -1 +1 @@
1
- {"version":3,"file":"createBundleTask.js","sourceRoot":"","sources":["../../../src/commands/start/createBundleTask.ts"],"names":[],"mappings":"AAGA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,aAA4B,EAAE,OAA2B;IACxF,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC;IAExF,OAAO;QACL,IAAI,EAAE,UAAU,WAAW,IAAI,OAAO,EAAE;QACxC,EAAE;QACF,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE;QACvC,KAAK,EAAE,CAAC,UAAU;QAClB,KAAK,CAAC,OAAO;YACX,MAAM,UAAU,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;YAE7C,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;YAClC,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC;YACjC,gFAAgF;YAChF,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;QACpC,CAAC;QACD,SAAS,EAAE,GAAG,EAAE,CAAW,aAAa,CAAC,MAAM,EAAE,MAAsB;QACvE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;YAC1B,EAAE;YACF,IAAI,EAAE,UAAU,WAAW,IAAI,OAAO,EAAE;YACxC,SAAS,EAAE,WAAW,IAAI,EAAE;YAC5B,UAAU;SACX,CAAC;QACF,iBAAiB,EAAE,CAAC,UAAU,EAAE,EAAE,CAChC,CAAC;YACC,EAAE;YACF,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM;YAClC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ;SAChB,CAAA;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleTaskOptions } from '../../types/BundleTaskOptions.js';\nimport type { BundleRequest } from '../../types/BundleRequest.js';\nimport type { Task, TaskEndDescription, TaskError } from '@ms-cloudpack/api-server';\nimport path from 'path';\nimport fs from 'fs';\nimport { bundleTask } from '../../tasks/bundleTask.js';\n\n/**\n * Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked\n * remotely (e.g. in the browser) and allows the user to cancel tasks.\n */\nexport function createBundleTask(bundleRequest: BundleRequest, options?: BundleTaskOptions): Task<BundleRequest> {\n const { id, packageName, version, outputPath, packagePath, isExternal } = bundleRequest;\n\n return {\n name: `Bundle ${packageName}@${version}`,\n id,\n dir: `${path.join(packagePath, 'src')}`,\n watch: !isExternal,\n async execute(): Promise<BundleRequest> {\n await bundleTask({ bundleRequest, options });\n\n return bundleRequest;\n },\n clear: () => {\n bundleRequest.result?.dispose?.();\n bundleRequest.result = undefined;\n // eslint-disable-next-line no-restricted-syntax -- this function can't be async\n fs.rmSync(outputPath, { recursive: true, force: true });\n },\n onDispose: () => {\n bundleRequest.result?.dispose?.();\n },\n getErrors: () => (<unknown>bundleRequest.result?.errors) as TaskError[],\n getStartDescription: () => ({\n id,\n name: `Bundle ${packageName}@${version}`,\n inputPath: packagePath || '',\n outputPath,\n }),\n getEndDescription: (taskResult) =>\n ({\n id,\n errors: taskResult?.result?.errors,\n warnings: taskResult?.result?.warnings,\n } as TaskEndDescription),\n };\n}\n"]}
1
+ {"version":3,"file":"createBundleTask.js","sourceRoot":"","sources":["../../../src/commands/start/createBundleTask.ts"],"names":[],"mappings":"AAGA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,aAA4B,EAC5B,OAA2B,EAC3B,QAAuB;IAEvB,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC;IAExF,OAAO;QACL,IAAI,EAAE,UAAU,WAAW,IAAI,OAAO,EAAE;QACxC,EAAE;QACF,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE;QACvC,KAAK,EAAE,CAAC,UAAU;QAClB,KAAK,CAAC,OAAO;YACX,MAAM,UAAU,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;YAEvD,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;YAClC,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC;YACjC,gFAAgF;YAChF,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;QACpC,CAAC;QACD,SAAS,EAAE,GAAG,EAAE,CAAW,aAAa,CAAC,MAAM,EAAE,MAAsB;QACvE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;YAC1B,EAAE;YACF,IAAI,EAAE,UAAU,WAAW,IAAI,OAAO,EAAE;YACxC,SAAS,EAAE,WAAW,IAAI,EAAE;YAC5B,UAAU;SACX,CAAC;QACF,iBAAiB,EAAE,CAAC,UAAU,EAAE,EAAE,CAChC,CAAC;YACC,EAAE;YACF,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM;YAClC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ;SAChB,CAAA;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleTaskOptions } from '../../types/BundleTaskOptions.js';\nimport type { BundleRequest } from '../../types/BundleRequest.js';\nimport type { Task, TaskEndDescription, TaskError } from '@ms-cloudpack/api-server';\nimport path from 'path';\nimport fs from 'fs';\nimport { bundleTask } from '../../tasks/bundleTask.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\n\n/**\n * Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked\n * remotely (e.g. in the browser) and allows the user to cancel tasks.\n */\nexport function createBundleTask(\n bundleRequest: BundleRequest,\n options?: BundleTaskOptions,\n reporter?: TaskReporter,\n): Task<BundleRequest> {\n const { id, packageName, version, outputPath, packagePath, isExternal } = bundleRequest;\n\n return {\n name: `Bundle ${packageName}@${version}`,\n id,\n dir: `${path.join(packagePath, 'src')}`,\n watch: !isExternal,\n async execute(): Promise<BundleRequest> {\n await bundleTask({ bundleRequest, options, reporter });\n\n return bundleRequest;\n },\n clear: () => {\n bundleRequest.result?.dispose?.();\n bundleRequest.result = undefined;\n // eslint-disable-next-line no-restricted-syntax -- this function can't be async\n fs.rmSync(outputPath, { recursive: true, force: true });\n },\n onDispose: () => {\n bundleRequest.result?.dispose?.();\n },\n getErrors: () => (<unknown>bundleRequest.result?.errors) as TaskError[],\n getStartDescription: () => ({\n id,\n name: `Bundle ${packageName}@${version}`,\n inputPath: packagePath || '',\n outputPath,\n }),\n getEndDescription: (taskResult) =>\n ({\n id,\n errors: taskResult?.result?.errors,\n warnings: taskResult?.result?.warnings,\n } as TaskEndDescription),\n };\n}\n"]}
@@ -1,8 +1,11 @@
1
1
  import type { Session } from '@ms-cloudpack/api-server';
2
2
  import type { CloudpackConfig } from '@ms-cloudpack/config';
3
+ import type { TaskReporter } from '@ms-cloudpack/task-reporter';
3
4
  export interface SessionOptions {
4
5
  appPath: string;
5
6
  config: CloudpackConfig;
6
7
  }
7
- export declare function createSession(options: SessionOptions): Promise<Session>;
8
+ export declare function createSession(options: SessionOptions, context: {
9
+ reporter: TaskReporter;
10
+ }): Promise<Session>;
8
11
  //# sourceMappingURL=createSession.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createSession.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAY5D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAsD7E"}
1
+ {"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createSession.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAQ5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAyDlH"}
@@ -8,14 +8,14 @@ import { getLocalCachePath } from '../../common/getCachePath.js';
8
8
  import { resolveDependenciesTask } from '../../tasks/resolveDependenciesTask.js';
9
9
  const dashboardPackageName = '@ms-cloudpack/overlay';
10
10
  const dashboardPackagePath = (await resolve(dashboardPackageName, path.dirname(fileURLToPath(import.meta.url)))) || '';
11
- export async function createSession(options) {
11
+ export async function createSession(options, context) {
12
12
  const { appPath, config } = options;
13
13
  const projectName = path.basename(appPath);
14
14
  const id = uuid();
15
15
  const resolveMap = await resolveDependenciesTask({
16
16
  appPath,
17
17
  additionalPaths: [dashboardPackagePath],
18
- });
18
+ }, context);
19
19
  if (!resolveMap) {
20
20
  throw new Error('Could not resolve dependencies.');
21
21
  }