@ms-cloudpack/cli 0.38.0 → 0.38.2

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 (99) hide show
  1. package/lib/commands/bundle/bundle.d.ts +1 -1
  2. package/lib/commands/bundle/bundle.d.ts.map +1 -1
  3. package/lib/commands/bundle/bundle.js.map +1 -1
  4. package/lib/commands/bundle/index.js.map +1 -1
  5. package/lib/commands/bundle/{types.d.ts → types/BundleOptions.d.ts} +1 -1
  6. package/lib/commands/bundle/types/BundleOptions.d.ts.map +1 -0
  7. package/lib/commands/bundle/types/BundleOptions.js +2 -0
  8. package/lib/commands/bundle/types/BundleOptions.js.map +1 -0
  9. package/lib/commands/init/getImportsFromBundle.js.map +1 -1
  10. package/lib/commands/init/index.js.map +1 -1
  11. package/lib/commands/init/init.d.ts +1 -1
  12. package/lib/commands/init/init.d.ts.map +1 -1
  13. package/lib/commands/init/init.js.map +1 -1
  14. package/lib/commands/init/{types.d.ts → types/InitOptions.d.ts} +1 -1
  15. package/lib/commands/init/types/InitOptions.d.ts.map +1 -0
  16. package/lib/commands/init/types/InitOptions.js +2 -0
  17. package/lib/commands/init/types/InitOptions.js.map +1 -0
  18. package/lib/commands/start/appServer/createRoutes.d.ts +1 -1
  19. package/lib/commands/start/appServer/createRoutes.d.ts.map +1 -1
  20. package/lib/commands/start/appServer/createRoutes.js.map +1 -1
  21. package/lib/commands/start/appServer/getDefaultHtmlResponse.d.ts +2 -1
  22. package/lib/commands/start/appServer/getDefaultHtmlResponse.d.ts.map +1 -1
  23. package/lib/commands/start/appServer/getDefaultHtmlResponse.js.map +1 -1
  24. package/lib/commands/start/appServer/getHtmlResponse.d.ts +2 -1
  25. package/lib/commands/start/appServer/getHtmlResponse.d.ts.map +1 -1
  26. package/lib/commands/start/appServer/getHtmlResponse.js.map +1 -1
  27. package/lib/commands/start/appServer/startAppServer.d.ts +1 -1
  28. package/lib/commands/start/appServer/startAppServer.d.ts.map +1 -1
  29. package/lib/commands/start/appServer/startAppServer.js.map +1 -1
  30. package/lib/commands/start/createBundleRequestForPackage.d.ts +1 -1
  31. package/lib/commands/start/createBundleRequestForPackage.d.ts.map +1 -1
  32. package/lib/commands/start/createBundleRequestForPackage.js.map +1 -1
  33. package/lib/commands/start/createBundleTask.d.ts +2 -1
  34. package/lib/commands/start/createBundleTask.d.ts.map +1 -1
  35. package/lib/commands/start/createBundleTask.js.map +1 -1
  36. package/lib/commands/start/index.js.map +1 -1
  37. package/lib/commands/start/start.d.ts +1 -1
  38. package/lib/commands/start/start.d.ts.map +1 -1
  39. package/lib/commands/start/start.js.map +1 -1
  40. package/lib/commands/start/startBundleServer.d.ts +1 -1
  41. package/lib/commands/start/startBundleServer.d.ts.map +1 -1
  42. package/lib/commands/start/startBundleServer.js.map +1 -1
  43. package/lib/commands/start/{types.d.ts → types/StartOptions.d.ts} +1 -1
  44. package/lib/commands/start/types/StartOptions.d.ts.map +1 -0
  45. package/lib/commands/start/types/StartOptions.js +2 -0
  46. package/lib/commands/start/types/StartOptions.js.map +1 -0
  47. package/lib/index.d.ts +8 -1
  48. package/lib/index.d.ts.map +1 -1
  49. package/lib/index.js.map +1 -1
  50. package/lib/tasks/bundleTask.d.ts +2 -1
  51. package/lib/tasks/bundleTask.d.ts.map +1 -1
  52. package/lib/tasks/bundleTask.js.map +1 -1
  53. package/lib/tsdoc-metadata.json +1 -1
  54. package/lib/types/BundleRequest.d.ts +24 -0
  55. package/lib/types/BundleRequest.d.ts.map +1 -0
  56. package/lib/types/BundleRequest.js +2 -0
  57. package/lib/types/BundleRequest.js.map +1 -0
  58. package/lib/types/BundleServer.d.ts +6 -0
  59. package/lib/types/BundleServer.d.ts.map +1 -0
  60. package/lib/types/BundleServer.js +2 -0
  61. package/lib/types/BundleServer.js.map +1 -0
  62. package/lib/types/BundleTaskOptions.d.ts +4 -0
  63. package/lib/types/BundleTaskOptions.d.ts.map +1 -0
  64. package/lib/types/BundleTaskOptions.js +2 -0
  65. package/lib/types/BundleTaskOptions.js.map +1 -0
  66. package/lib/types/CreateHtmlFunction.d.ts +7 -0
  67. package/lib/types/CreateHtmlFunction.d.ts.map +1 -0
  68. package/lib/types/CreateHtmlFunction.js +2 -0
  69. package/lib/types/CreateHtmlFunction.js.map +1 -0
  70. package/lib/types/CreateHtmlOptions.d.ts +18 -0
  71. package/lib/types/CreateHtmlOptions.d.ts.map +1 -0
  72. package/lib/types/CreateHtmlOptions.js +2 -0
  73. package/lib/types/CreateHtmlOptions.js.map +1 -0
  74. package/lib/types/CreateHtmlResult.d.ts +8 -0
  75. package/lib/types/CreateHtmlResult.d.ts.map +1 -0
  76. package/lib/types/CreateHtmlResult.js +2 -0
  77. package/lib/types/CreateHtmlResult.js.map +1 -0
  78. package/lib/types/CreateHtmlScript.d.ts +8 -0
  79. package/lib/types/CreateHtmlScript.d.ts.map +1 -0
  80. package/lib/types/CreateHtmlScript.js +2 -0
  81. package/lib/types/CreateHtmlScript.js.map +1 -0
  82. package/lib/types/Watcher.d.ts +5 -0
  83. package/lib/types/Watcher.d.ts.map +1 -0
  84. package/lib/types/Watcher.js +2 -0
  85. package/lib/types/Watcher.js.map +1 -0
  86. package/package.json +7 -7
  87. package/lib/commands/bundle/types.d.ts.map +0 -1
  88. package/lib/commands/bundle/types.js +0 -2
  89. package/lib/commands/bundle/types.js.map +0 -1
  90. package/lib/commands/init/types.d.ts.map +0 -1
  91. package/lib/commands/init/types.js +0 -2
  92. package/lib/commands/init/types.js.map +0 -1
  93. package/lib/commands/start/types.d.ts.map +0 -1
  94. package/lib/commands/start/types.js +0 -2
  95. package/lib/commands/start/types.js.map +0 -1
  96. package/lib/types.d.ts +0 -68
  97. package/lib/types.d.ts.map +0 -1
  98. package/lib/types.js +0 -2
  99. package/lib/types.js.map +0 -1
@@ -1,3 +1,3 @@
1
- import type { BundleOptions } from './types.js';
1
+ import type { BundleOptions } from './types/BundleOptions.js';
2
2
  export declare function bundle(options?: BundleOptions): Promise<void>;
3
3
  //# 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,YAAY,CAAC;AAKhD,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;AAK9D,wBAAsB,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,iBAwBnD"}
@@ -1 +1 @@
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;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAuB;IAClD,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;IACpB,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.js';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport { reporter } from '../../reporter.js';\nimport type { BundleRequest } from '../../types.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;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAuB;IAClD,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;IACpB,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 { 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 +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.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":"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"]}
@@ -12,4 +12,4 @@ export interface BundleOptions {
12
12
  */
13
13
  outdir?: string;
14
14
  }
15
- //# sourceMappingURL=types.d.ts.map
15
+ //# sourceMappingURL=BundleOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BundleOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/bundle/types/BundleOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=BundleOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BundleOptions.js","sourceRoot":"","sources":["../../../../src/commands/bundle/types/BundleOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface BundleOptions {\n /**\n * Forces use of a specific bundler. 'ori' | 'rollup' | 'auto'. Defaults to \"auto\".\n */\n bundler?: string;\n\n /**\n * Disables source maps.\n */\n disableSourceMaps?: boolean;\n\n /**\n * Path to drop the bundle output, relative to current path. Defaults to \"dist\".\n */\n outdir?: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"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IAAI,EAAE,WAAW,EAAE,EAAE;QAC7D,OAAO,IAAI,CAAC,MAAM,CAChB,KAAK,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.js';\nimport { bundleTask } from '../../tasks/bundleTask.js';\nimport { bulletedList, formatPackageName } from '@ms-cloudpack/task-reporter';\n\n/**\n * Bundle the package and return the imports it depends on.\n */\nexport async function getImportsFromBundle(options: {\n packages: PackageDefinitionsCache;\n packagePath: string;\n definition: PackageJson;\n}): Promise<Map<string, Set<string>> | undefined> {\n const { packagePath, definition, packages } = options;\n const { outputPath, isExternal } = await getBundleDetails(packagePath);\n\n if (!isExternal && !definition.exports) {\n console.warn(`Package ${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(`Package ${path.join(packagePath, 'package.json')} does not have any entries.`);\n return;\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 ${importCount} imported package(s)` : undefined,\n details: importCount ? `${bulletedList(getImportsList(imports))}` : undefined,\n };\n });\n\n return imports;\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":"getImportsFromBundle.js","sourceRoot":"","sources":["../../../src/commands/init/getImportsFromBundle.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,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAE9E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAI1C;IACC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtD,MAAM,EAAE,UAAU,EAAE,UAAU,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AAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAClG,CAAC,IAAI,EAAE,CACT,CACF,CAAC;QAEF,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;QAEjC,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,WAAW,sBAAsB,CAAC,CAAC,CAAC,SAAS;YAC7E,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;SAC9E,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,cAAc,CAAC,OAAiC;IACvD,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE;QAC7D,OAAO,IAAI,CAAC,MAAM,CAChB,KAAK,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 } from '@ms-cloudpack/task-reporter';\n\n/**\n * Bundle the package and return the imports it depends on.\n */\nexport async function getImportsFromBundle(options: {\n packages: PackageDefinitionsCache;\n packagePath: string;\n definition: PackageJson;\n}): Promise<Map<string, Set<string>> | undefined> {\n const { packagePath, definition, packages } = options;\n const { outputPath, isExternal } = await getBundleDetails(packagePath);\n\n if (!isExternal && !definition.exports) {\n console.warn(`Package ${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(`Package ${path.join(packagePath, 'package.json')} does not have any entries.`);\n return;\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 ${importCount} imported package(s)` : undefined,\n details: importCount ? `${bulletedList(getImportsList(imports))}` : undefined,\n };\n });\n\n return imports;\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":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QA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QAEpE,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.js';\nimport { reporter } from '../../reporter.js';\nimport { red } 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 try {\n const { changeCount } = await init(options);\n\n if (reporter.hasErrors()) {\n hasErrors = true;\n completeReason = 'Some tasks failed.';\n } else {\n completeReason = changeCount\n ? `Updated \"${configFileName}\" with ${changeCount} change(s).`\n : 'Looks good, no changes required. :)';\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) : 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":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,8BAA8B;AAC9B,MAAM,UAAU,IAAI,CAAC,OAAgB;IACnC,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,CAAC;SAC7E,MAAM,CAAC,SAAS,EAAE,2CAA2C,CAAC;SAC9D,MAAM,CAAC,KAAK,EAAE,OAAoB,EAAE,EAAE;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;QAE3C,IAAI,cAAkC,CAAC;QACvC,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,IAAI;YACF,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YAE5C,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE;gBACxB,SAAS,GAAG,IAAI,CAAC;gBACjB,cAAc,GAAG,oBAAoB,CAAC;aACvC;iBAAM;gBACL,cAAc,GAAG,WAAW;oBAC1B,CAAC,CAAC,YAAY,cAAc,UAAU,WAAW,aAAa;oBAC9D,CAAC,CAAC,qCAAqC,CAAC;aAC3C;SACF;QAAC,OAAO,KAAK,EAAE;YACd,SAAS,GAAG,IAAI,CAAC;YACjB,cAAc,GAAG,qBAAsB,KAAe,CAAC,OAAO,IAAI,SAAS,EAAE,CAAC;SAC/E;QAED,MAAM,aAAa,EAAE,CAAC;QACtB,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;QAEpE,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 { red } 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 try {\n const { changeCount } = await init(options);\n\n if (reporter.hasErrors()) {\n hasErrors = true;\n completeReason = 'Some tasks failed.';\n } else {\n completeReason = changeCount\n ? `Updated \"${configFileName}\" with ${changeCount} change(s).`\n : 'Looks good, no changes required. :)';\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) : completeReason);\n\n process.exit(hasErrors ? 1 : 0);\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { InitOptions } from './types.js';
1
+ import type { InitOptions } from './types/InitOptions.js';
2
2
  /** Given the path, updates the Cloudpack config with overrides and project settings. */
3
3
  export declare function init(options: InitOptions): Promise<{
4
4
  changeCount: 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,YAAY,CAAC;AAE9C,wFAAwF;AACxF,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAqGjF"}
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,w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ACV,QAAQ;YACR,WAAW;YACX,sBAAsB;YACtB,iBAAiB;YACjB,OAAO;YACP,gBAAgB;YAChB,UAAU;SACX,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;YACjE,QAAQ,EAAE,QAAQ,CAAC,mBAAmB,EAAE;gBACtC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM;aAC3E,CAAC,CAAC;YACH,MAAM,KAAK,CACT,MAAM,CAAC,WAAW;gBAChB,CAAC,CAAC,oDAAoD;gBACtD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAC3C,CAAC;SACH;QAED,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC;KACnC;IAED,IAAI,OAAO,CAAC,GAAG,EAAE;QACf,MAAM,8BAA8B,CAAC,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC,CAAC;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;KACZ,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 { getImportsFromBundle } from './getImportsFromBundle.js';\nimport { patchAllInternalPackageExports } from './patchAllInternalPackageExports.js';\nimport type { InitOptions } from './types.js';\n\n/** Given the path, updates the Cloudpack config with overrides and project settings. */\nexport async function init(options: InitOptions): Promise<{ changeCount: number }> {\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\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 continue;\n }\n\n // Bundle the package and find the imports it depends on.\n const imports = await getImportsFromBundle({\n packagePath,\n definition,\n packages,\n });\n\n if (!imports) {\n console.info(`Skipping ${packagePath} evaluation due to no imports returned.`);\n continue;\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const result = await evaluateImportsForOverrides({\n definition,\n packages,\n packagePath,\n packagePathsToEvaluate,\n evaluatedPackages,\n imports,\n packageOverrides,\n resolveMap,\n });\n\n if (options.check && (result.changeCount || result.errors.length)) {\n rootSpan?.addEvent('INIT_CHECK_FAILED', {\n reason: result.changeCount ? 'Config needs to be updated.' : result.errors,\n });\n throw Error(\n result.changeCount\n ? 'Run \"cloudpack init --reset\" to update the config.'\n : result.errors.map((e) => e).join('\\n'),\n );\n }\n\n changeCount += result.changeCount;\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 };\n}\n"]}
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,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAGrF,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAoB;IAC7C,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,EAAE;QAChC,MAAM,KAAK,CAAC,wCAAwC,CAAC,CAAC;KACvD;IAED,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE;QAClC,MAAM,KAAK,CAAC,0CAA0C,CAAC,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AC,EAAE,gBAAgB,EAAE,EAAE,OAAO,CAAC,CAAC;SAC3D;KACF;IAED,OAAO;QACL,WAAW;KACZ,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 { getImportsFromBundle } from './getImportsFromBundle.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<{ changeCount: number }> {\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\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 continue;\n }\n\n // Bundle the package and find the imports it depends on.\n const imports = await getImportsFromBundle({\n packagePath,\n definition,\n packages,\n });\n\n if (!imports) {\n console.info(`Skipping ${packagePath} evaluation due to no imports returned.`);\n continue;\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const result = await evaluateImportsForOverrides({\n definition,\n packages,\n packagePath,\n packagePathsToEvaluate,\n evaluatedPackages,\n imports,\n packageOverrides,\n resolveMap,\n });\n\n if (options.check && (result.changeCount || result.errors.length)) {\n rootSpan?.addEvent('INIT_CHECK_FAILED', {\n reason: result.changeCount ? 'Config needs to be updated.' : result.errors,\n });\n throw Error(\n result.changeCount\n ? 'Run \"cloudpack init --reset\" to update the config.'\n : result.errors.map((e) => e).join('\\n'),\n );\n }\n\n changeCount += result.changeCount;\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 };\n}\n"]}
@@ -19,4 +19,4 @@ export interface InitOptions {
19
19
  */
20
20
  check?: boolean;
21
21
  }
22
- //# sourceMappingURL=types.d.ts.map
22
+ //# sourceMappingURL=InitOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=InitOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitOptions.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Defines the options for the \"init\" command.\n */\nexport interface InitOptions {\n /**\n * Whether to apply fixes to all identified issues in internal packages.\n */\n fix?: boolean;\n\n /**\n * Whether to ignore existing overrides when determining all entries.\n */\n reset?: boolean;\n\n /**\n * Current working directory.\n */\n cwd?: string;\n\n /**\n * Whether to fail on missing exports.\n */\n check?: boolean;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { PackageJson } from '@ms-cloudpack/bundler-types';
2
2
  import type { Express } from '@ms-cloudpack/create-express-app';
3
- import type { BundleServer } from '../../../types.js';
3
+ import type { BundleServer } from '../../../types/BundleServer.js';
4
4
  import type { ApiServer, Session } from '@ms-cloudpack/api-server';
5
5
  import type { CloudpackConfig } from '@ms-cloudpack/config';
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"createRoutes.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/createRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,kCAAkC,CAAC;AAKnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,GAAG,EACH,OAAO,EACP,UAAU,EACV,YAAY,EACZ,SAAS,EACT,MAAM,GACP,EAAE;IACD,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,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,QAiEA"}
1
+ {"version":3,"file":"createRoutes.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/createRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,kCAAkC,CAAC;AAKnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,GAAG,EACH,OAAO,EACP,UAAU,EACV,YAAY,EACZ,SAAS,EACT,MAAM,GACP,EAAE;IACD,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,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,QAiEA"}
@@ -1 +1 @@
1
- {"version":3,"file":"createRoutes.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/createRoutes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,sB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K,CAAC,CAAC,GAAG,EAAE,EAAE;oBACjB,OAAO,CAAC,KAAK,CAAE,GAAa,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;oBAC5C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAC;gBACpD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;KACF;AACH,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/bundler-types';\nimport type { Express, Request, Response } from '@ms-cloudpack/create-express-app';\nimport { express } from '@ms-cloudpack/create-express-app';\nimport { createImportMap } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport path from 'path';\nimport type { BundleServer } from '../../../types.js';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\nimport { getHtmlResponse } from './getHtmlResponse.js';\nimport { getInlineScripts } from './inlineScripts/getInlineScripts.js';\nimport { handleSessionVersion } from './handleSessionVersion.js';\nimport { log } from './log.js';\nimport { setHeaders } from './setHeaders.js';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\n/**\n * Creates the routes for the express app, considering how the config is defined.\n */\nexport function createRoutes({\n app,\n url,\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n}: {\n app: Express;\n url: string;\n session: Session;\n definition: PackageJson;\n bundleServer: BundleServer;\n apiServer: ApiServer;\n config: CloudpackConfig;\n}) {\n const routes = [...(config.devServer?.routes || [])];\n const hasDefaultRoute = routes.some((route) => route.match === '*' || route.match === '/');\n\n if (!hasDefaultRoute) {\n routes.push({\n match: '*',\n exportEntry: '.',\n });\n }\n\n for (const route of routes) {\n if (route.staticPath) {\n app.use(route.match, express.static(path.resolve(session.appPath, route.staticPath)));\n } else {\n app.get(route.match, (req: Request, res: Response) => {\n (async () => {\n // Build the import map if it hasn't been built yet for this session version.\n const sessionVersion = handleSessionVersion(session, req);\n const importMap =\n session.getImportMap() ||\n session.setImportMap(\n await createImportMap(session.resolveMap, bundleServer.url, {\n sessionVersion,\n targetVersions: session.targetVersions,\n }),\n );\n\n // Parse the request path, extension, grab the overlay script path.\n const requestPath = slash(req.path.substring(1));\n const requestExt = path.extname(requestPath);\n const overlayScript = importMap.imports['@ms-cloudpack/overlay'];\n const entryScript =\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n route.exportEntry && importMap.imports[slash(path.join(definition.name!, route.exportEntry))];\n\n // Set the apppropriate Cloudpack headers/cookies in the response.\n // TODO: setting the headers here prohibits cases where the page rendering is owned by existing server code\n // that can only accept changing the scripts. We should consider moving to a model where an initial script\n // fetch loads the import map and sets Cloudpack settings in local storage rather than headers/cookies.\n setHeaders({ res, session, apiServer });\n\n const inlineScripts = await getInlineScripts();\n const { html, statusCode } = await getHtmlResponse({\n route,\n baseUrl: url,\n importMap,\n overlayScript,\n entryScript,\n session,\n definition,\n inlineScripts,\n });\n\n // Send the result.\n res.status(statusCode).send(html).end();\n\n log(`App server: Request: ${requestPath}, ext: ${requestExt}`);\n })().catch((err) => {\n console.error((err as Error)?.stack || err);\n res.status(500).send(`Error loading app: ${err}`);\n });\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"createRoutes.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/createRoutes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU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AAC,CAAC;gBACpD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;KACF;AACH,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/bundler-types';\nimport type { Express, Request, Response } from '@ms-cloudpack/create-express-app';\nimport { express } from '@ms-cloudpack/create-express-app';\nimport { createImportMap } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport path from 'path';\nimport type { BundleServer } from '../../../types/BundleServer.js';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\nimport { getHtmlResponse } from './getHtmlResponse.js';\nimport { getInlineScripts } from './inlineScripts/getInlineScripts.js';\nimport { handleSessionVersion } from './handleSessionVersion.js';\nimport { log } from './log.js';\nimport { setHeaders } from './setHeaders.js';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\n/**\n * Creates the routes for the express app, considering how the config is defined.\n */\nexport function createRoutes({\n app,\n url,\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n}: {\n app: Express;\n url: string;\n session: Session;\n definition: PackageJson;\n bundleServer: BundleServer;\n apiServer: ApiServer;\n config: CloudpackConfig;\n}) {\n const routes = [...(config.devServer?.routes || [])];\n const hasDefaultRoute = routes.some((route) => route.match === '*' || route.match === '/');\n\n if (!hasDefaultRoute) {\n routes.push({\n match: '*',\n exportEntry: '.',\n });\n }\n\n for (const route of routes) {\n if (route.staticPath) {\n app.use(route.match, express.static(path.resolve(session.appPath, route.staticPath)));\n } else {\n app.get(route.match, (req: Request, res: Response) => {\n (async () => {\n // Build the import map if it hasn't been built yet for this session version.\n const sessionVersion = handleSessionVersion(session, req);\n const importMap =\n session.getImportMap() ||\n session.setImportMap(\n await createImportMap(session.resolveMap, bundleServer.url, {\n sessionVersion,\n targetVersions: session.targetVersions,\n }),\n );\n\n // Parse the request path, extension, grab the overlay script path.\n const requestPath = slash(req.path.substring(1));\n const requestExt = path.extname(requestPath);\n const overlayScript = importMap.imports['@ms-cloudpack/overlay'];\n const entryScript =\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n route.exportEntry && importMap.imports[slash(path.join(definition.name!, route.exportEntry))];\n\n // Set the apppropriate Cloudpack headers/cookies in the response.\n // TODO: setting the headers here prohibits cases where the page rendering is owned by existing server code\n // that can only accept changing the scripts. We should consider moving to a model where an initial script\n // fetch loads the import map and sets Cloudpack settings in local storage rather than headers/cookies.\n setHeaders({ res, session, apiServer });\n\n const inlineScripts = await getInlineScripts();\n const { html, statusCode } = await getHtmlResponse({\n route,\n baseUrl: url,\n importMap,\n overlayScript,\n entryScript,\n session,\n definition,\n inlineScripts,\n });\n\n // Send the result.\n res.status(statusCode).send(html).end();\n\n log(`App server: Request: ${requestPath}, ext: ${requestExt}`);\n })().catch((err) => {\n console.error((err as Error)?.stack || err);\n res.status(500).send(`Error loading app: ${err}`);\n });\n });\n }\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
- import type { CreateHtmlOptions, CreateHtmlResult } from '../../../types.js';
1
+ import type { CreateHtmlResult } from '../../../types/CreateHtmlResult.js';
2
+ import type { CreateHtmlOptions } from '../../../types/CreateHtmlOptions.js';
2
3
  /**
3
4
  * Return the default HTML response.
4
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultHtmlResponse.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getDefaultHtmlResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE7E;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,gBAAgB,CAc1F"}
1
+ {"version":3,"file":"getDefaultHtmlResponse.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getDefaultHtmlResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE7E;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,gBAAgB,CAc1F"}
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultHtmlResponse.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getDefaultHtmlResponse.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAE,UAAU,EAAqB;IACtE,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC;IAE5B,OAAO;QACL,iBAAiB;QACjB,kBAAkB;QAClB,QAAQ;QACR,YAAY,IAAI,UAAU;QAC1B,SAAS;QACT,QAAQ;QACR,uBAAuB;QACvB,SAAS;QACT,SAAS;KACV,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC","sourcesContent":["import type { CreateHtmlOptions, CreateHtmlResult } from '../../../types.js';\n\n/**\n * Return the default HTML response.\n */\nexport function getDefaultHtmlResponse({ definition }: CreateHtmlOptions): CreateHtmlResult {\n const { name } = definition;\n\n return [\n `<!DOCTYPE html>`,\n `<html lang=\"en\">`,\n `<head>`,\n ` <title>${name}</title>`,\n `</head>`,\n `<body>`,\n `<div id=\"root\"></div>`,\n `</body>`,\n `</html>`,\n ].join('\\n');\n}\n"]}
1
+ {"version":3,"file":"getDefaultHtmlResponse.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getDefaultHtmlResponse.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAE,UAAU,EAAqB;IACtE,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC;IAE5B,OAAO;QACL,iBAAiB;QACjB,kBAAkB;QAClB,QAAQ;QACR,YAAY,IAAI,UAAU;QAC1B,SAAS;QACT,QAAQ;QACR,uBAAuB;QACvB,SAAS;QACT,SAAS;KACV,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC","sourcesContent":["import type { CreateHtmlResult } from '../../../types/CreateHtmlResult.js';\nimport type { CreateHtmlOptions } from '../../../types/CreateHtmlOptions.js';\n\n/**\n * Return the default HTML response.\n */\nexport function getDefaultHtmlResponse({ definition }: CreateHtmlOptions): CreateHtmlResult {\n const { name } = definition;\n\n return [\n `<!DOCTYPE html>`,\n `<html lang=\"en\">`,\n `<head>`,\n ` <title>${name}</title>`,\n `</head>`,\n `<body>`,\n `<div id=\"root\"></div>`,\n `</body>`,\n `</html>`,\n ].join('\\n');\n}\n"]}
@@ -1,4 +1,5 @@
1
- import type { CreateHtmlOptions, CreateHtmlResult } from '../../../types.js';
1
+ import type { CreateHtmlResult } from '../../../types/CreateHtmlResult.js';
2
+ import type { CreateHtmlOptions } from '../../../types/CreateHtmlOptions.js';
2
3
  /**
3
4
  * Get the HTML response for the given route. If the route has a custom render script, use that.
4
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getHtmlResponse.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getHtmlResponse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAwC,MAAM,mBAAmB,CAAC;AAKnH;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CA2E5G"}
1
+ {"version":3,"file":"getHtmlResponse.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getHtmlResponse.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAK7E;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CA2E5G"}
@@ -1 +1 @@
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AAI;YACF,IAAI,GAAG,CAAC,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;SAC5D;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,+BAA+B,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC;SAC/D;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import path from 'path';\nimport { pathToFileURL } from 'url';\nimport type { CreateHtmlOptions, CreateHtmlResult, CreateHtmlFunction, CreateHtmlScript } from '../../../types.js';\nimport { getDefaultHtmlResponse } from './getDefaultHtmlResponse.js';\nimport { JSDOM } from 'jsdom';\nimport fsPromises from 'fs/promises';\n\n/**\n * Get the HTML response for the given route. If the route has a custom render script, use that.\n */\nexport async function getHtmlResponse(options: CreateHtmlOptions): Promise<Exclude<CreateHtmlResult, string>> {\n const { route, session, overlayScript, entryScript, inlineScripts } = options;\n let createHtml: CreateHtmlFunction = getDefaultHtmlResponse;\n\n if (route.renderScript) {\n const renderScriptPath = path.resolve(session.appPath, route.renderScript);\n let cacheBreakerQueryParam = `?t=${Date.now()}`;\n\n try {\n const { mtime } = await fsPromises.stat(path.resolve(session.appPath, route.renderScript));\n\n cacheBreakerQueryParam = `?t=${mtime.getTime()}`;\n } catch {\n /* no-op */\n }\n\n if (isHtml(renderScriptPath)) {\n createHtml = readStaticHtml;\n } else {\n // Get the html factory function from a script default export.\n const renderScriptUrl = pathToFileURL(renderScriptPath).toString();\n\n // Note: because there isn't a way to purge the require cache, we need to add a cache breaker query param to the\n // script path to ensure we get the latest version of the script. This could be improved by using the git hash of\n // the file if it exists, or a hash of the content, or even the timestamp of the file.\n try {\n createHtml = ((await import(renderScriptUrl + cacheBreakerQueryParam)) as CreateHtmlScript).default;\n } catch (e) {\n console.error(`Error importing render script at \"${renderScriptUrl}\":`, e);\n }\n }\n\n if (!createHtml) {\n console.error(`The render script at \"${renderScriptPath}\" does not export a default function.`);\n }\n }\n\n const htmlResult = await createHtml(options);\n let html = typeof htmlResult === 'string' ? htmlResult : htmlResult.html;\n const statusCode = typeof htmlResult === 'string' ? 200 : htmlResult.statusCode || 200;\n\n try {\n const htmlDocument = new JSDOM(html);\n const { document } = htmlDocument.window;\n\n // inject the import map.\n if (entryScript || overlayScript) {\n const script = document.createElement('script');\n script.type = 'importmap';\n script.innerHTML = JSON.stringify(session.getImportMap(), null, 2);\n document.head.prepend(script);\n }\n\n for (const inlineScript of inlineScripts) {\n const script = document.createElement('script');\n script.type = 'module';\n script.innerHTML = inlineScript;\n document.head.appendChild(script);\n }\n\n // inject the overlay script.\n addScript(document.head, overlayScript);\n\n // inject the entry script.\n addScript(document.head, entryScript);\n\n html = htmlDocument.serialize();\n } catch (e) {\n console.error(`Error parsing html response for rendering route \"${route.match}\"`, e);\n }\n\n return {\n html,\n statusCode,\n };\n}\n\n/**\n * Helper function to add a script to the document.\n */\nfunction addScript(parentElement: HTMLElement, url: string | undefined) {\n if (url) {\n const script = parentElement.ownerDocument.createElement('script');\n\n script.type = 'module';\n script.src = url;\n parentElement.appendChild(script);\n }\n}\n\nfunction isHtml(path: string): boolean {\n // path has an .htm or .html extension; case insensitive.\n return path.toLowerCase().match(/\\.htm(l)?$/) !== null;\n}\n\nasync function readStaticHtml(options: CreateHtmlOptions): Promise<string> {\n const { route } = options;\n let html = '';\n\n if (route.renderScript) {\n const htmlPath = path.resolve(options.session.appPath, route.renderScript);\n\n try {\n html = (await fsPromises.readFile(htmlPath, 'utf8')) || '';\n } catch (e) {\n console.error(`Error reading HTML file at \"${htmlPath}\".`, e);\n }\n }\n\n return html;\n}\n"]}
1
+ {"version":3,"file":"getHtmlResponse.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getHtmlResponse.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAKpC,OAAO,EAAE,sBAAsB,EAAE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CAAC;SAC/D;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import path from 'path';\nimport { pathToFileURL } from 'url';\nimport type { CreateHtmlScript } from '../../../types/CreateHtmlScript.js';\nimport type { CreateHtmlFunction } from '../../../types/CreateHtmlFunction.js';\nimport type { CreateHtmlResult } from '../../../types/CreateHtmlResult.js';\nimport type { CreateHtmlOptions } from '../../../types/CreateHtmlOptions.js';\nimport { getDefaultHtmlResponse } from './getDefaultHtmlResponse.js';\nimport { JSDOM } from 'jsdom';\nimport fsPromises from 'fs/promises';\n\n/**\n * Get the HTML response for the given route. If the route has a custom render script, use that.\n */\nexport async function getHtmlResponse(options: CreateHtmlOptions): Promise<Exclude<CreateHtmlResult, string>> {\n const { route, session, overlayScript, entryScript, inlineScripts } = options;\n let createHtml: CreateHtmlFunction = getDefaultHtmlResponse;\n\n if (route.renderScript) {\n const renderScriptPath = path.resolve(session.appPath, route.renderScript);\n let cacheBreakerQueryParam = `?t=${Date.now()}`;\n\n try {\n const { mtime } = await fsPromises.stat(path.resolve(session.appPath, route.renderScript));\n\n cacheBreakerQueryParam = `?t=${mtime.getTime()}`;\n } catch {\n /* no-op */\n }\n\n if (isHtml(renderScriptPath)) {\n createHtml = readStaticHtml;\n } else {\n // Get the html factory function from a script default export.\n const renderScriptUrl = pathToFileURL(renderScriptPath).toString();\n\n // Note: because there isn't a way to purge the require cache, we need to add a cache breaker query param to the\n // script path to ensure we get the latest version of the script. This could be improved by using the git hash of\n // the file if it exists, or a hash of the content, or even the timestamp of the file.\n try {\n createHtml = ((await import(renderScriptUrl + cacheBreakerQueryParam)) as CreateHtmlScript).default;\n } catch (e) {\n console.error(`Error importing render script at \"${renderScriptUrl}\":`, e);\n }\n }\n\n if (!createHtml) {\n console.error(`The render script at \"${renderScriptPath}\" does not export a default function.`);\n }\n }\n\n const htmlResult = await createHtml(options);\n let html = typeof htmlResult === 'string' ? htmlResult : htmlResult.html;\n const statusCode = typeof htmlResult === 'string' ? 200 : htmlResult.statusCode || 200;\n\n try {\n const htmlDocument = new JSDOM(html);\n const { document } = htmlDocument.window;\n\n // inject the import map.\n if (entryScript || overlayScript) {\n const script = document.createElement('script');\n script.type = 'importmap';\n script.innerHTML = JSON.stringify(session.getImportMap(), null, 2);\n document.head.prepend(script);\n }\n\n for (const inlineScript of inlineScripts) {\n const script = document.createElement('script');\n script.type = 'module';\n script.innerHTML = inlineScript;\n document.head.appendChild(script);\n }\n\n // inject the overlay script.\n addScript(document.head, overlayScript);\n\n // inject the entry script.\n addScript(document.head, entryScript);\n\n html = htmlDocument.serialize();\n } catch (e) {\n console.error(`Error parsing html response for rendering route \"${route.match}\"`, e);\n }\n\n return {\n html,\n statusCode,\n };\n}\n\n/**\n * Helper function to add a script to the document.\n */\nfunction addScript(parentElement: HTMLElement, url: string | undefined) {\n if (url) {\n const script = parentElement.ownerDocument.createElement('script');\n\n script.type = 'module';\n script.src = url;\n parentElement.appendChild(script);\n }\n}\n\nfunction isHtml(path: string): boolean {\n // path has an .htm or .html extension; case insensitive.\n return path.toLowerCase().match(/\\.htm(l)?$/) !== null;\n}\n\nasync function readStaticHtml(options: CreateHtmlOptions): Promise<string> {\n const { route } = options;\n let html = '';\n\n if (route.renderScript) {\n const htmlPath = path.resolve(options.session.appPath, route.renderScript);\n\n try {\n html = (await fsPromises.readFile(htmlPath, 'utf8')) || '';\n } catch (e) {\n console.error(`Error reading HTML file at \"${htmlPath}\".`, e);\n }\n }\n\n return html;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { BundleServer } from '../../../types.js';
1
+ import type { BundleServer } from '../../../types/BundleServer.js';
2
2
  import type { PackageJson } from '@ms-cloudpack/bundler-types';
3
3
  import type { CloudpackConfig } from '@ms-cloudpack/config';
4
4
  import type { ApiServer, Session } from '@ms-cloudpack/api-server';
@@ -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,mBAAmB,CAAC;AACtD,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;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 +1 @@
1
- {"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AAA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,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.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,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,5 +1,5 @@
1
1
  import type { Features } from '@ms-cloudpack/config';
2
2
  import type { ResolveMapEntry } from '@ms-cloudpack/package-utilities';
3
- import type { BundleRequest } from '../../types.js';
3
+ import type { BundleRequest } from '../../types/BundleRequest.js';
4
4
  export declare function createBundleRequestForPackage(packageEntry: ResolveMapEntry, features?: Features): Promise<BundleRequest>;
5
5
  //# sourceMappingURL=createBundleRequestForPackage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createBundleRequestForPackage.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createBundleRequestForPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,wBAAsB,6BAA6B,CACjD,YAAY,EAAE,eAAe,EAC7B,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,aAAa,CAAC,CAexB"}
1
+ {"version":3,"file":"createBundleRequestForPackage.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createBundleRequestForPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,wBAAsB,6BAA6B,CACjD,YAAY,EAAE,eAAe,EAC7B,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,aAAa,CAAC,CAexB"}
@@ -1 +1 @@
1
- {"version":3,"file":"createBundleRequestForPackage.js","sourceRoot":"","sources":["../../../src/commands/start/createBundleRequestForPackage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,YAA6B,EAC7B,QAAmB;IAEnB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC;IAC7C,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE1E,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,UAAU;QACV,UAAU;QACV,OAAO;QACP,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB;QAC9C,iBAAiB,EAAE,QAAQ,EAAE,mBAAmB;QAChD,2BAA2B,EAAE,QAAQ,EAAE,qBAAqB;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import type { Features } from '@ms-cloudpack/config';\nimport type { ResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { getBundleDetails } from '../../common/getBundleDetails.js';\nimport type { BundleRequest } from '../../types.js';\n\nexport async function createBundleRequestForPackage(\n packageEntry: ResolveMapEntry,\n features?: Features,\n): Promise<BundleRequest> {\n const { path, version, name } = packageEntry;\n const { bundleId, isExternal, outputPath } = await getBundleDetails(path);\n\n return {\n id: bundleId,\n packagePath: path,\n packageName: name,\n isExternal,\n outputPath,\n version,\n disableSourceMaps: features?.disableSourceMaps,\n enableFindImports: features?.enqueueDependencies,\n enableCacheInternalPackages: features?.cacheInternalPackages,\n };\n}\n"]}
1
+ {"version":3,"file":"createBundleRequestForPackage.js","sourceRoot":"","sources":["../../../src/commands/start/createBundleRequestForPackage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,YAA6B,EAC7B,QAAmB;IAEnB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC;IAC7C,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE1E,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,UAAU;QACV,UAAU;QACV,OAAO;QACP,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB;QAC9C,iBAAiB,EAAE,QAAQ,EAAE,mBAAmB;QAChD,2BAA2B,EAAE,QAAQ,EAAE,qBAAqB;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import type { Features } from '@ms-cloudpack/config';\nimport type { ResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { getBundleDetails } from '../../common/getBundleDetails.js';\nimport type { BundleRequest } from '../../types/BundleRequest.js';\n\nexport async function createBundleRequestForPackage(\n packageEntry: ResolveMapEntry,\n features?: Features,\n): Promise<BundleRequest> {\n const { path, version, name } = packageEntry;\n const { bundleId, isExternal, outputPath } = await getBundleDetails(path);\n\n return {\n id: bundleId,\n packagePath: path,\n packageName: name,\n isExternal,\n outputPath,\n version,\n disableSourceMaps: features?.disableSourceMaps,\n enableFindImports: features?.enqueueDependencies,\n enableCacheInternalPackages: features?.cacheInternalPackages,\n };\n}\n"]}
@@ -1,4 +1,5 @@
1
- import type { BundleRequest, BundleTaskOptions } from '../../types.js';
1
+ import type { BundleTaskOptions } from '../../types/BundleTaskOptions.js';
2
+ import type { BundleRequest } from '../../types/BundleRequest.js';
2
3
  import type { Task } from '@ms-cloudpack/api-server';
3
4
  /**
4
5
  * Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked
@@ -1 +1 @@
1
- {"version":3,"file":"createBundleTask.d.ts","sourceRoot":"","sources":["../../../src/commands/start/createBundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACvE,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,I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AE,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 { BundleRequest, BundleTaskOptions } from '../../types.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;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 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAGA,+BAA+B;AAC/B,MAAM,UAAU,IAAI,CAAC,OAAgB;IACnC,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,0DAA0D,CAAC;SACvE,MAAM,CAAC,mBAAmB,EAAE,6DAA6D,CAAC;SAC1F,MAAM,CAAC,4CAA4C,EAAE,+BAA+B,CAAC;SACrF,MAAM,CAAC,KAAK,EAAE,OAAqB,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["import type { Command } from 'commander';\nimport type { StartOptions } from './types.js';\n\n/* Defines the \"start\" verb. */\nexport function init(command: Command) {\n command\n .command('start')\n .description('Starts a web inner-loop from the current package folder.')\n .option('--log-resolve-map', 'Logs the resolve map to \"resolve-map.json\" for diagnostics.')\n .option('--features <featureName> [featureNames...]', 'Enable experimental features.')\n .action(async (options: StartOptions) => (await import('./start.js')).start(options));\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAGA,+BAA+B;AAC/B,MAAM,UAAU,IAAI,CAAC,OAAgB;IACnC,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,0DAA0D,CAAC;SACvE,MAAM,CAAC,mBAAmB,EAAE,6DAA6D,CAAC;SAC1F,MAAM,CAAC,4CAA4C,EAAE,+BAA+B,CAAC;SACrF,MAAM,CAAC,KAAK,EAAE,OAAqB,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["import type { Command } from 'commander';\nimport type { StartOptions } from './types/StartOptions.js';\n\n/* Defines the \"start\" verb. */\nexport function init(command: Command) {\n command\n .command('start')\n .description('Starts a web inner-loop from the current package folder.')\n .option('--log-resolve-map', 'Logs the resolve map to \"resolve-map.json\" for diagnostics.')\n .option('--features <featureName> [featureNames...]', 'Enable experimental features.')\n .action(async (options: StartOptions) => (await import('./start.js')).start(options));\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { StartOptions } from './types.js';
1
+ import type { StartOptions } from './types/StartOptions.js';
2
2
  /**
3
3
  * Defines the "start" verb entry point.
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAyB/C;;GAEG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,iBAsHhD"}
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAyB5D;;GAEG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,iBAsHhD"}
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC1F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,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AAC,CAAC,CAAC;aACjB;YAED,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,oBAAoB;QACpB,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;QAE1B,WAAW,CAAC,OAAO,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;QACpE,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YAC7B,sEAAsE;YACtE,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,GAAG,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;KACJ;IAAC,OAAO,GAAG,EAAE;QACZ,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC","sourcesContent":["import { writeJson } from '@ms-cloudpack/json-utilities';\nimport { PackageDefinitions, findResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport { createPackageOverrideTransform } from '../../common/createPackageOverrideTransform.js';\nimport { createSession } from './createSession.js';\nimport { openBrowser } from './openBrowser.js';\nimport type { Session } from '@ms-cloudpack/api-server';\nimport type { StartOptions } from './types.js';\nimport { reporter } from '../../reporter.js';\nimport { readConfig } from '@ms-cloudpack/config';\nimport type { Features } from '@ms-cloudpack/config';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport { setSharedTelemetryAttribute, stopTelemetry, rootSpan } from '../../initTelemetry.js';\nimport { createBundleRequestForPackage } from './createBundleRequestForPackage.js';\nimport { createBundleTask } from './createBundleTask.js';\nimport { mergeFeatures } from './mergeFeatures.js';\nimport { yellow } from '@ms-cloudpack/task-reporter';\n\nasync function createAppBundleTask(session: Session, packageName: string, features?: Features) {\n const packageEntry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n });\n\n if (!packageEntry) {\n throw new Error(`Could not find package ${packageName} in the resolve map.`);\n }\n const bundleRequest = await createBundleRequestForPackage(packageEntry, features);\n\n return createBundleTask(bundleRequest);\n}\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport async function start(options: StartOptions) {\n const appPath = process.cwd();\n\n try {\n // Parse config if it exists.\n const config = await readConfig(appPath);\n\n // Merge in any additional features from the command line.\n config.features = mergeFeatures({\n configFeatures: config.features,\n commandLineFeatures: options.features,\n });\n\n const featureNames = Object.keys(config.features);\n\n if (featureNames.length) {\n console.log(`Enabled features: ${featureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n // Initialize package overrides.\n PackageDefinitions.getInstance().registerTransform(createPackageOverrideTransform(config));\n\n // Make sure the package has a valid definition.\n const definition = await PackageDefinitions.getInstance().get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n if (!definition.name || !definition.version) {\n throw new Error(`The package.json at \"${appPath}\" did not have a name and/or version.`);\n }\n\n // Initialize session definition.\n const session = await createSession({ appPath, config });\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n setSharedTelemetryAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n const { startApiServer } = await import('@ms-cloudpack/api-server');\n\n // Start api server for tracking status and handling remote requests.\n const apiServer = await startApiServer({\n session,\n rootSpan,\n reporter,\n });\n\n // Kick off bundling app package as soon as api server is ready.\n void apiServer.addTask(await createAppBundleTask(session, definition.name, config.features));\n\n // Then start bundle and app servers for hosting the app.\n const { startBundleServer } = await import('./startBundleServer.js');\n const bundleServer = await startBundleServer({ session, apiServer });\n\n const { startAppServer } = await import('./appServer/startAppServer.js');\n const appServer = await startAppServer({\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n });\n\n const cleanup = async () => {\n for (const [name, server] of [\n ['appServer', appServer] as const,\n ['apiServer', apiServer] as const,\n ['bundleServer', bundleServer] as const,\n ]) {\n console.info(`Closing ${name}: ${server.url}`);\n try {\n await server.close();\n } catch (err) {\n console.warn('Error closing server:', err);\n }\n }\n\n // Complete the reporting and list pending tasks as aborted.\n reporter.complete();\n\n // Flush and close telemetry.\n await stopTelemetry();\n };\n\n // Setup cleanup and close things on completion.\n let sigintCount = 0;\n\n process.on('SIGINT', () => {\n sigintCount++;\n if (sigintCount > 1) {\n console.debug('Forcing exit');\n process.exit(1);\n }\n\n cleanup().finally(() => {\n process.exit(0);\n });\n });\n\n // Open the browser.\n const url = appServer.url;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n openBrowser(url).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', url);\n });\n } catch (err) {\n reporter.complete();\n process.exit(1);\n }\n}\n"]}
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC1F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,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C,CAAC;aACjB;YAED,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,oBAAoB;QACpB,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;QAE1B,WAAW,CAAC,OAAO,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;QACpE,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YAC7B,sEAAsE;YACtE,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,GAAG,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;KACJ;IAAC,OAAO,GAAG,EAAE;QACZ,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC","sourcesContent":["import { writeJson } from '@ms-cloudpack/json-utilities';\nimport { PackageDefinitions, findResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport { createPackageOverrideTransform } from '../../common/createPackageOverrideTransform.js';\nimport { createSession } from './createSession.js';\nimport { openBrowser } from './openBrowser.js';\nimport type { Session } from '@ms-cloudpack/api-server';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { reporter } from '../../reporter.js';\nimport { readConfig } from '@ms-cloudpack/config';\nimport type { Features } from '@ms-cloudpack/config';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport { setSharedTelemetryAttribute, stopTelemetry, rootSpan } from '../../initTelemetry.js';\nimport { createBundleRequestForPackage } from './createBundleRequestForPackage.js';\nimport { createBundleTask } from './createBundleTask.js';\nimport { mergeFeatures } from './mergeFeatures.js';\nimport { yellow } from '@ms-cloudpack/task-reporter';\n\nasync function createAppBundleTask(session: Session, packageName: string, features?: Features) {\n const packageEntry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n });\n\n if (!packageEntry) {\n throw new Error(`Could not find package ${packageName} in the resolve map.`);\n }\n const bundleRequest = await createBundleRequestForPackage(packageEntry, features);\n\n return createBundleTask(bundleRequest);\n}\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport async function start(options: StartOptions) {\n const appPath = process.cwd();\n\n try {\n // Parse config if it exists.\n const config = await readConfig(appPath);\n\n // Merge in any additional features from the command line.\n config.features = mergeFeatures({\n configFeatures: config.features,\n commandLineFeatures: options.features,\n });\n\n const featureNames = Object.keys(config.features);\n\n if (featureNames.length) {\n console.log(`Enabled features: ${featureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n // Initialize package overrides.\n PackageDefinitions.getInstance().registerTransform(createPackageOverrideTransform(config));\n\n // Make sure the package has a valid definition.\n const definition = await PackageDefinitions.getInstance().get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n if (!definition.name || !definition.version) {\n throw new Error(`The package.json at \"${appPath}\" did not have a name and/or version.`);\n }\n\n // Initialize session definition.\n const session = await createSession({ appPath, config });\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n setSharedTelemetryAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n const { startApiServer } = await import('@ms-cloudpack/api-server');\n\n // Start api server for tracking status and handling remote requests.\n const apiServer = await startApiServer({\n session,\n rootSpan,\n reporter,\n });\n\n // Kick off bundling app package as soon as api server is ready.\n void apiServer.addTask(await createAppBundleTask(session, definition.name, config.features));\n\n // Then start bundle and app servers for hosting the app.\n const { startBundleServer } = await import('./startBundleServer.js');\n const bundleServer = await startBundleServer({ session, apiServer });\n\n const { startAppServer } = await import('./appServer/startAppServer.js');\n const appServer = await startAppServer({\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n });\n\n const cleanup = async () => {\n for (const [name, server] of [\n ['appServer', appServer] as const,\n ['apiServer', apiServer] as const,\n ['bundleServer', bundleServer] as const,\n ]) {\n console.info(`Closing ${name}: ${server.url}`);\n try {\n await server.close();\n } catch (err) {\n console.warn('Error closing server:', err);\n }\n }\n\n // Complete the reporting and list pending tasks as aborted.\n reporter.complete();\n\n // Flush and close telemetry.\n await stopTelemetry();\n };\n\n // Setup cleanup and close things on completion.\n let sigintCount = 0;\n\n process.on('SIGINT', () => {\n sigintCount++;\n if (sigintCount > 1) {\n console.debug('Forcing exit');\n process.exit(1);\n }\n\n cleanup().finally(() => {\n process.exit(0);\n });\n });\n\n // Open the browser.\n const url = appServer.url;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n openBrowser(url).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', url);\n });\n } catch (err) {\n reporter.complete();\n process.exit(1);\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { ApiServer, Session } from '@ms-cloudpack/api-server';
2
- import type { BundleServer } from '../../types.js';
2
+ import type { BundleServer } from '../../types/BundleServer.js';
3
3
  /**
4
4
  * The bundle server handles package requests and returns bundled resources.
5
5
  * Resources are bundled on demand and cached locally to avoid re-bundling
@@ -1 +1 @@
1
- {"version":3,"file":"startBundleServer.d.ts","sourceRoot":"","sources":["../../../src/commands/start/startBundleServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQnD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,SAAS,GACV,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;CACtB,GAAG,OAAO,CAAC,YAAY,CAAC,CAsBxB"}
1
+ {"version":3,"file":"startBundleServer.d.ts","sourceRoot":"","sources":["../../../src/commands/start/startBundleServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAQhE;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,SAAS,GACV,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;CACtB,GAAG,OAAO,CAAC,YAAY,CAAC,CAsBxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"startBundleServer.js","sourceRoot":"","sources":["../../../src/commands/start/startBundleServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAA6C,MAAM,kCAAkC,CAAC;AAC/G,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEnD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,OAAO,EACP,SAAS,GAIV;IACC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAA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MAAM,6BAA6B,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC;gBAEtG,yEAAyE;gBACzE,KAAK,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;aAC9E;SACF;QAED,OAAO,CAAC,KAAK,CAAC,sBAAsB,WAAW,IAAI,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC;QAC1E,4BAA4B;QAC5B,IAAI,UAAU,CAAC,UAAU,EAAE;YACzB,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC;SAC5D;QAED,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;KAC1D;AACH,CAAC","sourcesContent":["import type { ApiServer, Session } from '@ms-cloudpack/api-server';\nimport { createExpressApp, type Express, type Request, type Response } from '@ms-cloudpack/create-express-app';\nimport { isExternalPackage, findResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport { isFolder } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport type { BundleServer } from '../../types.js';\nimport { createBundleRequestForPackage } from './createBundleRequestForPackage.js';\nimport { createBundleTask } from './createBundleTask.js';\nimport { parseRequestInfo } from './parseRequestInfo.js';\nimport { fileURLToPath } from 'url';\n\nconst currentPath = fileURLToPath(import.meta.url);\n\n/**\n * The bundle server handles package requests and returns bundled resources.\n * Resources are bundled on demand and cached locally to avoid re-bundling\n * on each request.\n */\nexport async function startBundleServer({\n session,\n apiServer,\n}: {\n session: Session;\n apiServer: ApiServer;\n}): Promise<BundleServer> {\n const { config } = session;\n const { port, close, url } = await createExpressApp({\n portRange: [5500, 5501, 5502, 5503],\n hostname: config.devServer?.domain,\n sslOptions: config.devServer?.https,\n setupCallback: (app: Express) => {\n // Set up the express app routes.\n app.get('*', (req, res) => {\n handleRequest(req, res, session, apiServer).catch((err) => {\n console.error((err as Error)?.stack || err);\n res.status(500).send(`Error bundling: ${err}`);\n });\n });\n },\n });\n\n return {\n close,\n port,\n url,\n };\n}\n\nasync function handleRequest(req: Request, res: Response, session: Session, apiServer: ApiServer) {\n const { resolveMap, config } = session;\n const { features = {} } = config;\n const requestPath = slash(req.path.substring(1));\n const force = req.query.force !== undefined;\n const { packageName, version, bundled, filePath } = parseRequestInfo(requestPath);\n const packageEntry = findResolveMapEntry({ packageName, version, resolveMap });\n\n if (!packageEntry) {\n // If the package is missing, invalid arguments.\n console.debug(`Response (404): Unrecognized package \"${packageName}\"`);\n res.status(404).send(`Unrecognized package \"${packageName}\".`);\n return;\n }\n\n console.debug(`Request: \"${packageName}@${version}${filePath}\"`);\n\n // If the package is missing, invalid arguments.\n if (!requestPath || !packageName) {\n console.debug(`Response (400): \"${packageName}@${version}${filePath}\"`);\n\n res.status(400).send(`Requests must be in the format \"/{packageName}@{version}/{type}/path/file.ext\".`);\n return;\n }\n\n // If the version is missing, redirect to the primary version.\n if (!version) {\n if (!packageEntry) {\n console.debug(`Response (404): Unrecognized package \"${packageName}\"`);\n\n res.status(404).send(`Unrecognized package \"${packageName}\".`);\n return;\n }\n\n res.redirect(`/${packageName}@${packageEntry.version}${filePath}`);\n return;\n }\n\n // If it's an unrecognized package, 404.\n if (!packageEntry) {\n console.debug(`Response (404): \"${packageName}@${version}${filePath}\"`);\n\n res\n .status(404)\n .send(`The requested package \"${packageName}@${version}${filePath}\" was not found in the resolve map.`);\n\n return;\n }\n\n // If we are accessing a non-bundled asset, return the file directly.\n if (!bundled) {\n const fullPath = path.join(packageEntry.path, filePath);\n\n if (fullPath.length < packageEntry.path.length) {\n console.debug(`Response (400): \"${packageName}@${version}${filePath}\"`);\n\n res.status(400).send(`Invalid file path.`);\n return;\n }\n\n console.debug(`Unbundled response returning: \"${packageName}@${version}${filePath}\"`);\n // If the package is external, set cache headers.\n if (isExternalPackage(packageEntry.path)) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n res.sendFile(path.join(packageEntry.path, filePath));\n return;\n }\n\n const taskResult = await createBundleRequestForPackage(packageEntry, features);\n\n // Set up for bundling.\n const rerun = !(await isFolder(taskResult.outputPath)) || force;\n\n if (features.useLage) {\n console.debug(`Trying to bundle \"${packageName}@${version}\" with lage task scheduler`);\n\n try {\n await apiServer.scheduleTask(\n taskResult,\n {\n // TODO: we may want to have away to let users add more types of tasks here\n bundle: path.resolve(currentPath, '../../tasks/bundleTaskWorker.js'),\n },\n { rerun },\n );\n\n console.debug(`Bundle returning: \"${packageName}@${version}${filePath}\"`);\n // Try to return the result.\n if (taskResult.isExternal) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n return res.sendFile(path.join(taskResult.outputPath, filePath));\n } catch (err) {\n return res.status(500).type('json').send(taskResult);\n }\n }\n\n console.debug(`Trying to bundle \"${packageName}@${version}\"`);\n\n const bundleTask = createBundleTask(taskResult, { force });\n await apiServer.addTask(bundleTask, { rerun });\n\n // At this point we should have a Task completed.\n if ((taskResult.result?.errors?.length || 0) > 0) {\n res.status(500).type('json').send(taskResult);\n } else {\n if (features.enqueueDependencies && taskResult.result?.dependencies) {\n // Enqueue all dependencies to be bundled.\n for (const dependency of taskResult.result.dependencies) {\n const dependencyBundleRequest = await createBundleRequestForPackage(resolveMap[dependency], features);\n\n // No need to await, we don't want to wait until the bundle is completed.\n void apiServer.addTask(createBundleTask(dependencyBundleRequest, { force }));\n }\n }\n\n console.debug(`Bundle returning: \"${packageName}@${version}${filePath}\"`);\n // Try to return the result.\n if (taskResult.isExternal) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n res.sendFile(path.join(taskResult.outputPath, filePath));\n }\n}\n"]}
1
+ {"version":3,"file":"startBundleServer.js","sourceRoot":"","sources":["../../../src/commands/start/startBundleServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAA6C,MAAM,kCAAkC,CAA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response } from '@ms-cloudpack/create-express-app';\nimport { isExternalPackage, findResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport { isFolder } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport type { BundleServer } from '../../types/BundleServer.js';\nimport { createBundleRequestForPackage } from './createBundleRequestForPackage.js';\nimport { createBundleTask } from './createBundleTask.js';\nimport { parseRequestInfo } from './parseRequestInfo.js';\nimport { fileURLToPath } from 'url';\n\nconst currentPath = fileURLToPath(import.meta.url);\n\n/**\n * The bundle server handles package requests and returns bundled resources.\n * Resources are bundled on demand and cached locally to avoid re-bundling\n * on each request.\n */\nexport async function startBundleServer({\n session,\n apiServer,\n}: {\n session: Session;\n apiServer: ApiServer;\n}): Promise<BundleServer> {\n const { config } = session;\n const { port, close, url } = await createExpressApp({\n portRange: [5500, 5501, 5502, 5503],\n hostname: config.devServer?.domain,\n sslOptions: config.devServer?.https,\n setupCallback: (app: Express) => {\n // Set up the express app routes.\n app.get('*', (req, res) => {\n handleRequest(req, res, session, apiServer).catch((err) => {\n console.error((err as Error)?.stack || err);\n res.status(500).send(`Error bundling: ${err}`);\n });\n });\n },\n });\n\n return {\n close,\n port,\n url,\n };\n}\n\nasync function handleRequest(req: Request, res: Response, session: Session, apiServer: ApiServer) {\n const { resolveMap, config } = session;\n const { features = {} } = config;\n const requestPath = slash(req.path.substring(1));\n const force = req.query.force !== undefined;\n const { packageName, version, bundled, filePath } = parseRequestInfo(requestPath);\n const packageEntry = findResolveMapEntry({ packageName, version, resolveMap });\n\n if (!packageEntry) {\n // If the package is missing, invalid arguments.\n console.debug(`Response (404): Unrecognized package \"${packageName}\"`);\n res.status(404).send(`Unrecognized package \"${packageName}\".`);\n return;\n }\n\n console.debug(`Request: \"${packageName}@${version}${filePath}\"`);\n\n // If the package is missing, invalid arguments.\n if (!requestPath || !packageName) {\n console.debug(`Response (400): \"${packageName}@${version}${filePath}\"`);\n\n res.status(400).send(`Requests must be in the format \"/{packageName}@{version}/{type}/path/file.ext\".`);\n return;\n }\n\n // If the version is missing, redirect to the primary version.\n if (!version) {\n if (!packageEntry) {\n console.debug(`Response (404): Unrecognized package \"${packageName}\"`);\n\n res.status(404).send(`Unrecognized package \"${packageName}\".`);\n return;\n }\n\n res.redirect(`/${packageName}@${packageEntry.version}${filePath}`);\n return;\n }\n\n // If it's an unrecognized package, 404.\n if (!packageEntry) {\n console.debug(`Response (404): \"${packageName}@${version}${filePath}\"`);\n\n res\n .status(404)\n .send(`The requested package \"${packageName}@${version}${filePath}\" was not found in the resolve map.`);\n\n return;\n }\n\n // If we are accessing a non-bundled asset, return the file directly.\n if (!bundled) {\n const fullPath = path.join(packageEntry.path, filePath);\n\n if (fullPath.length < packageEntry.path.length) {\n console.debug(`Response (400): \"${packageName}@${version}${filePath}\"`);\n\n res.status(400).send(`Invalid file path.`);\n return;\n }\n\n console.debug(`Unbundled response returning: \"${packageName}@${version}${filePath}\"`);\n // If the package is external, set cache headers.\n if (isExternalPackage(packageEntry.path)) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n res.sendFile(path.join(packageEntry.path, filePath));\n return;\n }\n\n const taskResult = await createBundleRequestForPackage(packageEntry, features);\n\n // Set up for bundling.\n const rerun = !(await isFolder(taskResult.outputPath)) || force;\n\n if (features.useLage) {\n console.debug(`Trying to bundle \"${packageName}@${version}\" with lage task scheduler`);\n\n try {\n await apiServer.scheduleTask(\n taskResult,\n {\n // TODO: we may want to have away to let users add more types of tasks here\n bundle: path.resolve(currentPath, '../../tasks/bundleTaskWorker.js'),\n },\n { rerun },\n );\n\n console.debug(`Bundle returning: \"${packageName}@${version}${filePath}\"`);\n // Try to return the result.\n if (taskResult.isExternal) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n return res.sendFile(path.join(taskResult.outputPath, filePath));\n } catch (err) {\n return res.status(500).type('json').send(taskResult);\n }\n }\n\n console.debug(`Trying to bundle \"${packageName}@${version}\"`);\n\n const bundleTask = createBundleTask(taskResult, { force });\n await apiServer.addTask(bundleTask, { rerun });\n\n // At this point we should have a Task completed.\n if ((taskResult.result?.errors?.length || 0) > 0) {\n res.status(500).type('json').send(taskResult);\n } else {\n if (features.enqueueDependencies && taskResult.result?.dependencies) {\n // Enqueue all dependencies to be bundled.\n for (const dependency of taskResult.result.dependencies) {\n const dependencyBundleRequest = await createBundleRequestForPackage(resolveMap[dependency], features);\n\n // No need to await, we don't want to wait until the bundle is completed.\n void apiServer.addTask(createBundleTask(dependencyBundleRequest, { force }));\n }\n }\n\n console.debug(`Bundle returning: \"${packageName}@${version}${filePath}\"`);\n // Try to return the result.\n if (taskResult.isExternal) {\n res.setHeader('Cache-Control', 'public, max-age=31536000');\n }\n\n res.sendFile(path.join(taskResult.outputPath, filePath));\n }\n}\n"]}
@@ -3,4 +3,4 @@ export interface StartOptions {
3
3
  sourcemap?: boolean;
4
4
  features?: string[];
5
5
  }
6
- //# sourceMappingURL=types.d.ts.map
6
+ //# sourceMappingURL=StartOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StartOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/types/StartOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StartOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StartOptions.js","sourceRoot":"","sources":["../../../../src/commands/start/types/StartOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface StartOptions {\n logResolveMap?: boolean;\n sourcemap?: boolean;\n features?: string[];\n}\n"]}