@ms-cloudpack/cli 0.42.2 → 0.42.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"bundleAndGetImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACxF,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACpC,CAAC,CA4DD"}
1
+ {"version":3,"file":"bundleAndGetImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACxF,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACpC,CAAC,CA4DD"}
@@ -1,7 +1,6 @@
1
1
  import path from 'path';
2
2
  import { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';
3
- import { bundleTask, getBundleDetails } from '@ms-cloudpack/api-server';
4
- import { findImports } from './findImports.js';
3
+ import { bundleTask, getBundleDetails, findImports } from '@ms-cloudpack/api-server';
5
4
  import { prepareOutputPath } from '../../common/prepareOutputPath.js';
6
5
  import { formatPackageName } from '@ms-cloudpack/task-reporter';
7
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bundleAndGetImports.js","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAsB,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAqB,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGnF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAMzC;IAMC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACxE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,MAAM,gBAAgB,CAAC,EAAE,WAAW,EAAE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C7E,OAAO,GAAG,IAAI,GAAG,CACf,MAAM,CAAC,OAAO,CACZ,CAAC,MAAM,WAAW,CAChB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAClG,CAAC,IAAI,EAAE,CACT,CACF,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,UAAU;SACnB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM;QACrD,SAAS,EAAE,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM;QACjD,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\nimport { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';\nimport { bundleTask, getBundleDetails, type BundleRequest } from '@ms-cloudpack/api-server';\nimport { findImports } from './findImports.js';\nimport { prepareOutputPath } from '../../common/prepareOutputPath.js';\nimport type { PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { type TaskReporter, formatPackageName } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\n/**\n * Bundle the package and return the imports it depends on.\n */\nexport async function bundleAndGetImports(options: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n reporter: TaskReporter;\n packagePath: string;\n definition: PackageJson;\n}): Promise<{\n hasWarnings: boolean;\n hasErrors: boolean;\n /** Map from package name to set of required relative paths */\n imports?: Map<string, Set<string>>;\n}> {\n const { packagePath, definition, packages, reporter, config } = options;\n const { outputLocation, isExternal } = await getBundleDetails({ packagePath }, { packages });\n const outputPath = outputLocation.path;\n\n if (!isExternal && !definition.exports) {\n console.debug(`${path.join(packagePath, 'package.json')} does not have an \"exports\" field.`);\n }\n\n // Ensure outputPath exists and is empty.\n await prepareOutputPath(outputPath);\n\n // Determine entries.\n const entriesMap = await getEntriesMapFromPackage({ inputPath: packagePath }, { packages });\n\n if (!Object.keys(entriesMap).length) {\n console.warn(\n `${path.join(packagePath, 'package.json')} does not specify any entry points.`,\n isExternal\n ? ''\n : 'If this package contains code imported by other packages, please consider adding an \"exports\" field.',\n );\n return { hasWarnings: true, hasErrors: false };\n }\n\n const bundleRequest: BundleRequest = {\n id: packagePath,\n packageName: definition.name || '',\n version: definition.version || '',\n packagePath,\n outputPath,\n isExternal,\n packages,\n config,\n };\n\n await bundleTask({ bundleRequest, reporter, 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 return {\n status: 'complete',\n };\n });\n\n return {\n hasWarnings: !!bundleRequest.result?.warnings?.length,\n hasErrors: !!bundleRequest.result?.errors?.length,\n imports,\n };\n}\n"]}
1
+ {"version":3,"file":"bundleAndGetImports.js","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAsB,MAAM,0BAA0B,CAAC;AACzG,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAqB,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGnF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAMzC;IAMC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OA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AAM,QAAQ,CAAC,OAAO,CAAC,YAAY,iBAAiB,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE;QAC7E,OAAO,GAAG,IAAI,GAAG,CACf,MAAM,CAAC,OAAO,CACZ,CAAC,MAAM,WAAW,CAChB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAClG,CAAC,IAAI,EAAE,CACT,CACF,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,UAAU;SACnB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM;QACrD,SAAS,EAAE,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM;QACjD,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\nimport { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';\nimport { bundleTask, getBundleDetails, findImports, type BundleRequest } from '@ms-cloudpack/api-server';\nimport { prepareOutputPath } from '../../common/prepareOutputPath.js';\nimport type { PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { type TaskReporter, formatPackageName } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\n/**\n * Bundle the package and return the imports it depends on.\n */\nexport async function bundleAndGetImports(options: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n reporter: TaskReporter;\n packagePath: string;\n definition: PackageJson;\n}): Promise<{\n hasWarnings: boolean;\n hasErrors: boolean;\n /** Map from package name to set of required relative paths */\n imports?: Map<string, Set<string>>;\n}> {\n const { packagePath, definition, packages, reporter, config } = options;\n const { outputLocation, isExternal } = await getBundleDetails({ packagePath }, { packages });\n const outputPath = outputLocation.path;\n\n if (!isExternal && !definition.exports) {\n console.debug(`${path.join(packagePath, 'package.json')} does not have an \"exports\" field.`);\n }\n\n // Ensure outputPath exists and is empty.\n await prepareOutputPath(outputPath);\n\n // Determine entries.\n const entriesMap = await getEntriesMapFromPackage({ inputPath: packagePath }, { packages });\n\n if (!Object.keys(entriesMap).length) {\n console.warn(\n `${path.join(packagePath, 'package.json')} does not specify any entry points.`,\n isExternal\n ? ''\n : 'If this package contains code imported by other packages, please consider adding an \"exports\" field.',\n );\n return { hasWarnings: true, hasErrors: false };\n }\n\n const bundleRequest: BundleRequest = {\n id: packagePath,\n packageName: definition.name || '',\n version: definition.version || '',\n packagePath,\n outputPath,\n isExternal,\n packages,\n config,\n };\n\n await bundleTask({ bundleRequest, reporter, 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 return {\n status: 'complete',\n };\n });\n\n return {\n hasWarnings: !!bundleRequest.result?.warnings?.length,\n hasErrors: !!bundleRequest.result?.errors?.length,\n imports,\n };\n}\n"]}
@@ -83,9 +83,9 @@ function addScript(parentElement, url) {
83
83
  parentElement.appendChild(script);
84
84
  }
85
85
  }
86
- function isHtml(path) {
86
+ function isHtml(scriptPath) {
87
87
  // path has an .htm or .html extension; case insensitive.
88
- return path.toLowerCase().match(/\.htm(l)?$/) !== null;
88
+ return scriptPath.toLowerCase().match(/\.htm(l)?$/) !== null;
89
89
  }
90
90
  async function readStaticHtml(options) {
91
91
  const { route } = options;
@@ -1 +1 @@
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,E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AC,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 { 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
+ {"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,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,KAAK,EA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AAC","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(scriptPath: string): boolean {\n // path has an .htm or .html extension; case insensitive.\n return scriptPath.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"]}
@@ -26,9 +26,9 @@ export async function startAppServer({ session, bundleServer, apiServer, definit
26
26
  hostname: devServer?.domain,
27
27
  sslOptions: config.devServer?.https,
28
28
  // publicDir,
29
- setupCallback: (app, url) => createRoutes({
29
+ setupCallback: (app, appUrl) => createRoutes({
30
30
  app,
31
- url,
31
+ url: appUrl,
32
32
  session,
33
33
  definition,
34
34
  bundleServer,
@@ -1 +1 @@
1
- {"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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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/BundleServer.js';\nimport type { PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/bundler-types';\nimport { createRoutes } from './createRoutes.js';\nimport { exitIfPortUnavailable } from './exitIfPortUnavailable.js';\nimport { type TaskReporter, cyan } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\n\n/**\n * The app server hosts the appropriate routes for the web app, primarily returning html content\n * which loads resources from the bundle server.\n *\n * Separating the app server from the bundle service keeps the routes separate - the app server\n * can support whichever routes the app needs, while the bundle server can provide package\n * assets in various forms using its own routing.\n */\nexport async function startAppServer({\n session,\n bundleServer,\n apiServer,\n definition,\n config = {} as CloudpackConfig,\n packages,\n reporter,\n}: {\n session: Session;\n definition: PackageJson;\n bundleServer: BundleServer;\n apiServer: ApiServer;\n config: CloudpackConfig;\n packages: PackageDefinitionsCache;\n reporter: TaskReporter;\n}) {\n const { devServer = {} } = config || ({} as CloudpackConfig);\n\n // Read the port from the config file or default to array of ports.\n const requireSpecifiedPort = devServer?.port !== undefined;\n const ports = devServer?.port ?? [5000, 5001, 5002, 5003];\n\n // Directory to serve as plain static assets. Defaults to \"public\".\n // Can be overridden by setting the 'publicDir' option in the cloudpack config.\n // const publicDir = path.resolve(devServer.publicPath ?? 'public');\n\n const task = reporter.addTask(`Starting app server for \"${definition.name}\"`);\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 packages,\n }),\n });\n\n task.complete({ message: `Available @ ${cyan(url)}`, forceShow: true });\n\n return {\n close,\n port,\n url,\n };\n } catch (err: unknown) {\n task.complete({ status: 'fail', message: 'Failed to start app server', forceShow: true });\n exitIfPortUnavailable(err, session.projectName, ports);\n\n throw err;\n }\n}\n"]}
1
+ {"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/startAppServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAqB,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAItE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,EACV,MAAM,GAAG,EAAqB,EAC9B,QAAQ,EACR,QAAQ,GAST;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,4BAA4B,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;IAE9E,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,MAAM,EAAE,EAAE,CAC7B,YAAY,CAAC;gBACX,GAAG;gBACH,GAAG,EAAE,MAAM;gBACX,OAAO;gBACP,UAAU;gBACV,YAAY;gBACZ,SAAS;gBACT,MAAM;gBACN,QAAQ;aACT,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 { PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/bundler-types';\nimport { createRoutes } from './createRoutes.js';\nimport { exitIfPortUnavailable } from './exitIfPortUnavailable.js';\nimport { type TaskReporter, cyan } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\n\n/**\n * The app server hosts the appropriate routes for the web app, primarily returning html content\n * which loads resources from the bundle server.\n *\n * Separating the app server from the bundle service keeps the routes separate - the app server\n * can support whichever routes the app needs, while the bundle server can provide package\n * assets in various forms using its own routing.\n */\nexport async function startAppServer({\n session,\n bundleServer,\n apiServer,\n definition,\n config = {} as CloudpackConfig,\n packages,\n reporter,\n}: {\n session: Session;\n definition: PackageJson;\n bundleServer: BundleServer;\n apiServer: ApiServer;\n config: CloudpackConfig;\n packages: PackageDefinitionsCache;\n reporter: TaskReporter;\n}) {\n const { devServer = {} } = config || ({} as CloudpackConfig);\n\n // Read the port from the config file or default to array of ports.\n const requireSpecifiedPort = devServer?.port !== undefined;\n const ports = devServer?.port ?? [5000, 5001, 5002, 5003];\n\n // Directory to serve as plain static assets. Defaults to \"public\".\n // Can be overridden by setting the 'publicDir' option in the cloudpack config.\n // const publicDir = path.resolve(devServer.publicPath ?? 'public');\n\n const task = reporter.addTask(`Starting app server for \"${definition.name}\"`);\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, appUrl) =>\n createRoutes({\n app,\n url: appUrl,\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n packages,\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 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAmB1D,wBAAsB,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,iBAkBvE"}
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAmB1D,wBAAsB,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,iBA8BvE"}
@@ -17,8 +17,18 @@ export async function sync({ upload }, context) {
17
17
  let message = '';
18
18
  try {
19
19
  await setupReporting(context);
20
+ const config = context.config.remoteCache;
21
+ if (!config) {
22
+ console.warn('Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.');
23
+ return;
24
+ }
20
25
  const apiServer = await createApiServer(context);
21
- await apiServer.sync({ isUpload: upload });
26
+ if (upload) {
27
+ await apiServer.syncUpload(undefined);
28
+ }
29
+ else {
30
+ await apiServer.syncDownload(undefined);
31
+ }
22
32
  hasErrors = context.reporter.hasErrors();
23
33
  }
24
34
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,KAAK,UAAU,eAAe,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAe;IACvE,gCAAgC;IAChC,MAAM,QA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C,CAAC,CAAC,CAAC,CAAC;KACjC;AACH,CAAC","sourcesContent":["import { red } from '@ms-cloudpack/task-reporter';\nimport { rootSpan, stopTelemetry } from '../../initTelemetry.js';\nimport type { TaskContext } from '../../types/TaskContext.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\nimport { createSession } from '../start/createSession.js';\nimport { createPackageDefinitions } from '@ms-cloudpack/config';\nimport { setupReporting } from '../../setupReporting.js';\n\nasync function createApiServer({ appPath, config, reporter }: TaskContext) {\n // Initialize package overrides.\n const packages = createPackageDefinitions({ config });\n\n // Initialize session definition.\n const session = await createSession({ appPath, config }, { reporter, packages });\n\n const { createCloudpackServer } = await import('@ms-cloudpack/api-server');\n\n const server = await createCloudpackServer({ session, rootSpan, reporter, packages });\n\n return server;\n}\n\nexport async function sync({ upload }: SyncOptions, context: TaskContext) {\n let hasErrors = false;\n let message: string = '';\n try {\n await setupReporting(context);\n const apiServer = await createApiServer(context);\n\n await apiServer.sync({ isUpload: upload });\n\n hasErrors = context.reporter.hasErrors();\n } catch (error) {\n message = error instanceof Error ? error.message : '<Unknown error>';\n hasErrors = true;\n } finally {\n context.reporter.complete(hasErrors ? red(message) : message);\n await stopTelemetry();\n process.exit(hasErrors ? 1 : 0);\n }\n}\n"]}
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,KAAK,UAAU,eAAe,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAe;IACvE,gCAAgC;IAChC,MAAM,QAAQ,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AC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC9D,MAAM,aAAa,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACjC;AACH,CAAC","sourcesContent":["import { red } from '@ms-cloudpack/task-reporter';\nimport { rootSpan, stopTelemetry } from '../../initTelemetry.js';\nimport type { TaskContext } from '../../types/TaskContext.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\nimport { createSession } from '../start/createSession.js';\nimport { createPackageDefinitions } from '@ms-cloudpack/config';\nimport { setupReporting } from '../../setupReporting.js';\n\nasync function createApiServer({ appPath, config, reporter }: TaskContext) {\n // Initialize package overrides.\n const packages = createPackageDefinitions({ config });\n\n // Initialize session definition.\n const session = await createSession({ appPath, config }, { reporter, packages });\n\n const { createCloudpackServer } = await import('@ms-cloudpack/api-server');\n\n const server = await createCloudpackServer({ session, rootSpan, reporter, packages });\n\n return server;\n}\n\nexport async function sync({ upload }: SyncOptions, context: TaskContext) {\n let hasErrors = false;\n let message: string = '';\n try {\n await setupReporting(context);\n const config = context.config.remoteCache;\n if (!config) {\n console.warn(\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n );\n return;\n }\n\n const apiServer = await createApiServer(context);\n\n if (upload) {\n await apiServer.syncUpload(undefined);\n } else {\n await apiServer.syncDownload(undefined);\n }\n\n hasErrors = context.reporter.hasErrors();\n } catch (error) {\n message = error instanceof Error ? error.message : '<Unknown error>';\n hasErrors = true;\n } finally {\n context.reporter.complete(hasErrors ? red(message) : message);\n await stopTelemetry();\n process.exit(hasErrors ? 1 : 0);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveDependenciesTask.d.ts","sourceRoot":"","sources":["../../src/tasks/resolveDependenciesTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGlG;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B,EACD,OAAO,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,uBAAuB,CAAA;CAAE,uBA0CvE"}
1
+ {"version":3,"file":"resolveDependenciesTask.d.ts","sourceRoot":"","sources":["../../src/tasks/resolveDependenciesTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGlG;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B,EACD,OAAO,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,uBAAuB,CAAA;CAAE,uBAyCvE"}
@@ -18,7 +18,6 @@ export async function resolveDependenciesTask(options, context) {
18
18
  appPath,
19
19
  additionalPaths,
20
20
  linkedPaths,
21
- useStrictVersioning: false,
22
21
  }, {
23
22
  packages,
24
23
  });
@@ -1 +1 @@
1
- {"version":3,"file":"resolveDependenciesTask.js","sourceRoot":"","sources":["../../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AC,cAAc,EAAE;YAC/B,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE;gBACpE,QAAQ,CAAC,WAAW,CAAC,CAAC;aACvB;SACF;KACF;IAED,OAAO;QACL,WAAW;QACX,kBAAkB;KACnB,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { LinkedPath, ResolveMap, ResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { createResolveMap } from '@ms-cloudpack/package-utilities';\nimport { bold, bulletedList, cyan, yellow, type TaskReporter } from '@ms-cloudpack/task-reporter';\nimport { PerfMarkerCliEntry, PerfMeasurementTimeToResolveDependencies } from '../performance/markers.js';\n\n/**\n * Resolves the locations of dependencies and returns the resolve map, logging results\n * to the task reporter.\n */\nexport async function resolveDependenciesTask(\n options: {\n appPath: string;\n additionalPaths?: string[];\n linkedPaths?: LinkedPath[];\n },\n context: { reporter: TaskReporter; packages: PackageDefinitionsCache },\n) {\n const { appPath, additionalPaths, linkedPaths } = options;\n const { reporter, packages } = context;\n let resolveMap: ResolveMap | undefined;\n\n if (performance.getEntriesByName(PerfMarkerCliEntry).length) {\n performance.measure(PerfMeasurementTimeToResolveDependencies, PerfMarkerCliEntry);\n }\n // Grab the installed dependency locations.\n await reporter.runTask('Resolving dependencies', async () => {\n resolveMap = await createResolveMap(\n {\n appPath,\n additionalPaths,\n linkedPaths,\n useStrictVersioning: false,\n },\n {\n packages,\n },\n );\n\n const { allPackages, duplicatedPackages } = getPackagesFromResolveMap(resolveMap);\n const message = `Found ${cyan(allPackages.size)} total packages, ${\n duplicatedPackages.size ? `${yellow(duplicatedPackages.size)} with multiple versions.` : `no duplicates.`\n }`;\n const extended = bulletedList(\n Array.from(duplicatedPackages.entries()).map(\n ([name, versions]) => `${bold(name)}: ${Array.from(versions).join(', ')}`,\n ),\n );\n\n return {\n message,\n extended,\n forceShow: true,\n };\n });\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- will be defined after the task runs\n return resolveMap!;\n}\n\n/**\n * Given a resolveMap, returns a map of all packages and a map of packages with multiple versions.\n * This is used to log the results of the resolve task.\n */\nfunction getPackagesFromResolveMap(resolveMap: ResolveMap) {\n const allPackages = new Map<string, ResolveMapEntry>();\n const duplicatedPackages = new Map<string, Set<string>>();\n\n function addEntry(entry: ResolveMapEntry) {\n if (allPackages.has(entry.name)) {\n if (!duplicatedPackages.has(entry.name)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n duplicatedPackages.set(entry.name, new Set([allPackages.get(entry.name)!.version]));\n }\n const dupeSet = duplicatedPackages.get(entry.name);\n\n dupeSet?.add(entry.version);\n } else {\n allPackages.set(entry.name, entry);\n }\n }\n\n for (const currentEntry of Object.values(resolveMap)) {\n addEntry(currentEntry);\n\n if (currentEntry.scopedVersions) {\n for (const scopedEntry of Object.values(currentEntry.scopedVersions)) {\n addEntry(scopedEntry);\n }\n }\n }\n\n return {\n allPackages,\n duplicatedPackages,\n };\n}\n"]}
1
+ {"version":3,"file":"resolveDependenciesTask.js","sourceRoot":"","sources":["../../src/tasks/resolveDependenciesTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAqB,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,kBAAkB,EAAE,wCAAwC,EAAE,MAAM,2BAA2B,CAAC;AAEzG;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAIC,EACD,OAAsE;IAEtE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAC1D,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACvC,IAAI,UAAkC,CAAC;IAEvC,IAAI,WAAW,CAAC,gBAAg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AW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YAC/B,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBACvC,oEAAoE;gBACpE,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;aACrF;YACD,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAEnD,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SAC7B;aAAM;YACL,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACpC;IACH,CAAC;IAED,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;QACpD,QAAQ,CAAC,YAAY,CAAC,CAAC;QAEvB,IAAI,YAAY,CAAC,cAAc,EAAE;YAC/B,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE;gBACpE,QAAQ,CAAC,WAAW,CAAC,CAAC;aACvB;SACF;KACF;IAED,OAAO;QACL,WAAW;QACX,kBAAkB;KACnB,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { LinkedPath, ResolveMap, ResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { createResolveMap } from '@ms-cloudpack/package-utilities';\nimport { bold, bulletedList, cyan, yellow, type TaskReporter } from '@ms-cloudpack/task-reporter';\nimport { PerfMarkerCliEntry, PerfMeasurementTimeToResolveDependencies } from '../performance/markers.js';\n\n/**\n * Resolves the locations of dependencies and returns the resolve map, logging results\n * to the task reporter.\n */\nexport async function resolveDependenciesTask(\n options: {\n appPath: string;\n additionalPaths?: string[];\n linkedPaths?: LinkedPath[];\n },\n context: { reporter: TaskReporter; packages: PackageDefinitionsCache },\n) {\n const { appPath, additionalPaths, linkedPaths } = options;\n const { reporter, packages } = context;\n let resolveMap: ResolveMap | undefined;\n\n if (performance.getEntriesByName(PerfMarkerCliEntry).length) {\n performance.measure(PerfMeasurementTimeToResolveDependencies, PerfMarkerCliEntry);\n }\n // Grab the installed dependency locations.\n await reporter.runTask('Resolving dependencies', async () => {\n resolveMap = await createResolveMap(\n {\n appPath,\n additionalPaths,\n linkedPaths,\n },\n {\n packages,\n },\n );\n\n const { allPackages, duplicatedPackages } = getPackagesFromResolveMap(resolveMap);\n const message = `Found ${cyan(allPackages.size)} total packages, ${\n duplicatedPackages.size ? `${yellow(duplicatedPackages.size)} with multiple versions.` : `no duplicates.`\n }`;\n const extended = bulletedList(\n Array.from(duplicatedPackages.entries()).map(\n ([name, versions]) => `${bold(name)}: ${Array.from(versions).join(', ')}`,\n ),\n );\n\n return {\n message,\n extended,\n forceShow: true,\n };\n });\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- will be defined after the task runs\n return resolveMap!;\n}\n\n/**\n * Given a resolveMap, returns a map of all packages and a map of packages with multiple versions.\n * This is used to log the results of the resolve task.\n */\nfunction getPackagesFromResolveMap(resolveMap: ResolveMap) {\n const allPackages = new Map<string, ResolveMapEntry>();\n const duplicatedPackages = new Map<string, Set<string>>();\n\n function addEntry(entry: ResolveMapEntry) {\n if (allPackages.has(entry.name)) {\n if (!duplicatedPackages.has(entry.name)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n duplicatedPackages.set(entry.name, new Set([allPackages.get(entry.name)!.version]));\n }\n const dupeSet = duplicatedPackages.get(entry.name);\n\n dupeSet?.add(entry.version);\n } else {\n allPackages.set(entry.name, entry);\n }\n }\n\n for (const currentEntry of Object.values(resolveMap)) {\n addEntry(currentEntry);\n\n if (currentEntry.scopedVersions) {\n for (const scopedEntry of Object.values(currentEntry.scopedVersions)) {\n addEntry(scopedEntry);\n }\n }\n }\n\n return {\n allPackages,\n duplicatedPackages,\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.42.2",
3
+ "version": "0.42.4",
4
4
  "description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -11,20 +11,19 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@lage-run/target-graph": "^0.8.6",
14
- "@ms-cloudpack/api-server": "^0.12.2",
15
- "@ms-cloudpack/bundler": "^0.14.5",
16
- "@ms-cloudpack/config": "^0.11.0",
14
+ "@ms-cloudpack/api-server": "^0.13.1",
15
+ "@ms-cloudpack/bundler": "^0.14.7",
16
+ "@ms-cloudpack/config": "^0.11.1",
17
17
  "@ms-cloudpack/create-express-app": "^1.3.9",
18
18
  "@ms-cloudpack/json-utilities": "^0.0.7",
19
- "@ms-cloudpack/overlay": "^0.14.3",
20
- "@ms-cloudpack/package-utilities": "^5.1.0",
19
+ "@ms-cloudpack/overlay": "^0.14.5",
20
+ "@ms-cloudpack/package-utilities": "^5.1.1",
21
21
  "@ms-cloudpack/path-string-parsing": "^1.0.3",
22
22
  "@ms-cloudpack/path-utilities": "^2.3.2",
23
23
  "@ms-cloudpack/task-reporter": "^0.7.1",
24
24
  "@ms-cloudpack/telemetry": "^0.3.6",
25
25
  "commander": "^11.0.0",
26
26
  "cross-spawn": "^7.0.3",
27
- "es-module-lexer": "^1.0.3",
28
27
  "fs-extra": "^11.0.0",
29
28
  "glob": "^8.0.0",
30
29
  "glob-hasher": "^1.2.1",
@@ -1,6 +0,0 @@
1
- /**
2
- * Returns a dictionary where key is the package name and value is a set of required paths.
3
- * Eg. `{ '@fluentui/react': new Set([ '.', './lib/Button' ]) }`
4
- */
5
- export declare function findImports(filePaths: string[]): Promise<Record<string, Set<string>>>;
6
- //# sourceMappingURL=findImports.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/findImports.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAoE3F"}
@@ -1,73 +0,0 @@
1
- import { parse } from 'es-module-lexer';
2
- import fsPromises from 'fs/promises';
3
- import path from 'path';
4
- import { parseImportString } from '@ms-cloudpack/path-string-parsing';
5
- import { sourceExtensions } from '@ms-cloudpack/path-utilities';
6
- import { builtinModules } from 'module';
7
- /** Treat files with no extension as JS for purposes below */
8
- const allSourceExtensions = [...sourceExtensions, ''];
9
- /**
10
- * Returns a dictionary where key is the package name and value is a set of required paths.
11
- * Eg. `{ '@fluentui/react': new Set([ '.', './lib/Button' ]) }`
12
- */
13
- export async function findImports(filePaths) {
14
- const requiredExports = {};
15
- const visitedPaths = new Set(filePaths);
16
- const pathsToParse = [...filePaths];
17
- while (pathsToParse.length) {
18
- const filePath = pathsToParse.shift();
19
- // Ignore any non-JS/TS files such as SVGs and sourcemaps
20
- if (!filePath || !allSourceExtensions.includes(path.extname(filePath))) {
21
- continue;
22
- }
23
- const source = await fsPromises.readFile(filePath, 'utf-8');
24
- let rawImports;
25
- try {
26
- [rawImports] = parse(source);
27
- }
28
- catch (err) {
29
- // This could happen if the source file isn't valid JS
30
- // (unlikely after adding the check above to only attempt parsing JS/TS files)
31
- console.warn(`Failed to parse ${filePath}:`, err);
32
- continue;
33
- }
34
- const imports = Array.from(new Set(rawImports))
35
- .map((i) => {
36
- // The es-module-lexer returns entries where the "n" property equals the import source.
37
- // This includes the package name and path. For example, in this case:
38
- //
39
- // import { Button } from '@fluentui/react/lib/Button';
40
- //
41
- // The "n" property would be "@fluentui/react/lib/Button".
42
- // The "s" and "e" properties represent the start/end character positions of
43
- // the import source. The "ss" and "se" properties represent the start/end
44
- // character positions of the import specifier starting with "import". This
45
- // may be useful for determining if the import is sync or async.
46
- //
47
- // Currently when the import source is a backtick string, the "n" property
48
- // is undefined. This is a bug in es-module-lexer. We may need to handle this
49
- // at the javascript layer and expand it into multiple potential imports.
50
- if (!i.n) {
51
- console.debug(`Found an import that didn't parse correctly:\nFilename:\n${filePath}\n\nImport:\n${source.slice(i.s, i.e)}`);
52
- return undefined;
53
- }
54
- return parseImportString(i.n);
55
- })
56
- .filter(Boolean);
57
- for (const { packageName, importPath } of imports) {
58
- if (packageName?.startsWith('.')) {
59
- const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');
60
- if (!visitedPaths.has(localPath)) {
61
- visitedPaths.add(localPath);
62
- pathsToParse.push(localPath);
63
- }
64
- }
65
- else if (packageName && !packageName.startsWith('node:') && !builtinModules.includes(packageName)) {
66
- requiredExports[packageName] ??= new Set();
67
- requiredExports[packageName].add(importPath || '.');
68
- }
69
- }
70
- }
71
- return requiredExports;
72
- }
73
- //# sourceMappingURL=findImports.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findImports.js","sourceRoot":"","sources":["../../../src/commands/init/findImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAA2B,MAAM,mCAAmC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,6DAA6D;AAC7D,MAAM,mBAAmB,GAAG,CAAC,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,SAAmB;IACnD,MAAM,eAAe,GAAgC,EAAE,CAAC;IACxD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AAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC,CAAC;aACD,MAAM,CAAC,OAAO,CAAyB,CAAC;QAE3C,KAAK,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,OAAO,EAAE;YACjD,IAAI,WAAW,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE;gBAChC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;gBAEtF,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;oBAChC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;oBAC5B,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;iBAC9B;aACF;iBAAM,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACnG,eAAe,CAAC,WAAW,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;gBAC3C,eAAe,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;aACrD;SACF;KACF;IAED,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import { parse } from 'es-module-lexer';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { parseImportString, type ImportStringResult } from '@ms-cloudpack/path-string-parsing';\nimport { sourceExtensions } from '@ms-cloudpack/path-utilities';\nimport { builtinModules } from 'module';\n\n/** Treat files with no extension as JS for purposes below */\nconst allSourceExtensions = [...sourceExtensions, ''];\n\n/**\n * Returns a dictionary where key is the package name and value is a set of required paths.\n * Eg. `{ '@fluentui/react': new Set([ '.', './lib/Button' ]) }`\n */\nexport async function findImports(filePaths: string[]): Promise<Record<string, Set<string>>> {\n const requiredExports: Record<string, Set<string>> = {};\n const visitedPaths = new Set(filePaths);\n const pathsToParse: string[] = [...filePaths];\n\n while (pathsToParse.length) {\n const filePath = pathsToParse.shift();\n // Ignore any non-JS/TS files such as SVGs and sourcemaps\n if (!filePath || !allSourceExtensions.includes(path.extname(filePath))) {\n continue;\n }\n\n const source = await fsPromises.readFile(filePath, 'utf-8');\n let rawImports: ReturnType<typeof parse>[0];\n try {\n [rawImports] = parse(source);\n } catch (err) {\n // This could happen if the source file isn't valid JS\n // (unlikely after adding the check above to only attempt parsing JS/TS files)\n console.warn(`Failed to parse ${filePath}:`, err);\n continue;\n }\n const imports = Array.from(new Set(rawImports))\n .map((i) => {\n // The es-module-lexer returns entries where the \"n\" property equals the import source.\n // This includes the package name and path. For example, in this case:\n //\n // import { Button } from '@fluentui/react/lib/Button';\n //\n // The \"n\" property would be \"@fluentui/react/lib/Button\".\n // The \"s\" and \"e\" properties represent the start/end character positions of\n // the import source. The \"ss\" and \"se\" properties represent the start/end\n // character positions of the import specifier starting with \"import\". This\n // may be useful for determining if the import is sync or async.\n //\n // Currently when the import source is a backtick string, the \"n\" property\n // is undefined. This is a bug in es-module-lexer. We may need to handle this\n // at the javascript layer and expand it into multiple potential imports.\n if (!i.n) {\n console.debug(\n `Found an import that didn't parse correctly:\\nFilename:\\n${filePath}\\n\\nImport:\\n${source.slice(\n i.s,\n i.e,\n )}`,\n );\n return undefined;\n }\n\n return parseImportString(i.n);\n })\n .filter(Boolean) as ImportStringResult[];\n\n for (const { packageName, importPath } of imports) {\n if (packageName?.startsWith('.')) {\n const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');\n\n if (!visitedPaths.has(localPath)) {\n visitedPaths.add(localPath);\n pathsToParse.push(localPath);\n }\n } else if (packageName && !packageName.startsWith('node:') && !builtinModules.includes(packageName)) {\n requiredExports[packageName] ??= new Set();\n requiredExports[packageName].add(importPath || '.');\n }\n }\n }\n\n return requiredExports;\n}\n"]}