@ms-cloudpack/cli 0.31.7 → 0.32.0

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 (62) hide show
  1. package/lib/commands/init/evaluateImportsForOverrides.d.ts +4 -1
  2. package/lib/commands/init/evaluateImportsForOverrides.js +8 -3
  3. package/lib/commands/init/evaluateImportsForOverrides.js.map +1 -1
  4. package/lib/commands/init/evaluateImportsForOverrides.test.js +67 -0
  5. package/lib/commands/init/evaluateImportsForOverrides.test.js.map +1 -0
  6. package/lib/commands/init/index.js +1 -1
  7. package/lib/commands/init/index.js.map +1 -1
  8. package/lib/commands/init/init.js +10 -5
  9. package/lib/commands/init/init.js.map +1 -1
  10. package/lib/commands/init/init.test.js +1 -1
  11. package/lib/commands/init/init.test.js.map +1 -1
  12. package/lib/commands/start/appServer/createRoutes.d.ts +3 -1
  13. package/lib/commands/start/appServer/createRoutes.js.map +1 -1
  14. package/lib/commands/start/appServer/setHeaders.d.ts +2 -1
  15. package/lib/commands/start/appServer/setHeaders.js.map +1 -1
  16. package/lib/commands/start/appServer/startAppServer.d.ts +3 -1
  17. package/lib/commands/start/appServer/startAppServer.js.map +1 -1
  18. package/lib/commands/start/createBundleTask.d.ts +2 -1
  19. package/lib/commands/start/createBundleTask.js.map +1 -1
  20. package/lib/commands/start/start.js +4 -4
  21. package/lib/commands/start/start.js.map +1 -1
  22. package/lib/commands/start/startBundleServer.d.ts +3 -1
  23. package/lib/commands/start/startBundleServer.js.map +1 -1
  24. package/lib/common/createPackageOverrideTransform.d.ts +1 -1
  25. package/lib/common/createPackageOverrideTransform.js.map +1 -1
  26. package/lib/index.d.ts +3 -1
  27. package/lib/index.js.map +1 -1
  28. package/lib/initTelemetry.js +1 -1
  29. package/lib/initTelemetry.js.map +1 -1
  30. package/lib/types.d.ts +3 -135
  31. package/lib/types.js.map +1 -1
  32. package/package.json +6 -4
  33. package/lib/commands/start/TaskRunner.d.ts +0 -40
  34. package/lib/commands/start/TaskRunner.js +0 -119
  35. package/lib/commands/start/TaskRunner.js.map +0 -1
  36. package/lib/commands/start/addOverride.d.ts +0 -7
  37. package/lib/commands/start/addOverride.js +0 -63
  38. package/lib/commands/start/addOverride.js.map +0 -1
  39. package/lib/commands/start/addOverride.test.js +0 -254
  40. package/lib/commands/start/addOverride.test.js.map +0 -1
  41. package/lib/commands/start/startApiServer.d.ts +0 -19
  42. package/lib/commands/start/startApiServer.js +0 -303
  43. package/lib/commands/start/startApiServer.js.map +0 -1
  44. package/lib/commands/start/startWatcher.d.ts +0 -7
  45. package/lib/commands/start/startWatcher.js +0 -51
  46. package/lib/commands/start/startWatcher.js.map +0 -1
  47. package/lib/commands/start/taskRunner.test.d.ts +0 -1
  48. package/lib/commands/start/taskRunner.test.js +0 -80
  49. package/lib/commands/start/taskRunner.test.js.map +0 -1
  50. package/lib/commands/start/validateOverride.d.ts +0 -7
  51. package/lib/commands/start/validateOverride.js +0 -28
  52. package/lib/commands/start/validateOverride.js.map +0 -1
  53. package/lib/commands/start/validateOverride.test.d.ts +0 -1
  54. package/lib/commands/start/validateOverride.test.js +0 -137
  55. package/lib/commands/start/validateOverride.test.js.map +0 -1
  56. package/lib/common/config.d.ts +0 -31
  57. package/lib/common/config.js +0 -54
  58. package/lib/common/config.js.map +0 -1
  59. package/lib/common/configTemplate.d.ts +0 -13
  60. package/lib/common/configTemplate.js +0 -16
  61. package/lib/common/configTemplate.js.map +0 -1
  62. /package/lib/commands/{start/addOverride.test.d.ts → init/evaluateImportsForOverrides.test.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import type { CloudpackConfig } from '../types.js';
1
+ import type { CloudpackConfig } from '@ms-cloudpack/config';
2
2
  import type { PackageDefinitionTransform } from '@ms-cloudpack/bundler-types';
3
3
  /**
4
4
  * Creates a transform to be registered with a PackageDefinitions registry for overriding package.json definitions.
@@ -1 +1 @@
1
- {"version":3,"file":"createPackageOverrideTransform.js","sourceRoot":"","sources":["../../src/common/createPackageOverrideTransform.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAuB;IACpE,MAAM,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAEzC,OAAO,CAAC,iBAA8B,EAAE,EAAE;QACxC,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,iBAAiB,CAAC;QACtD,MAAM,eAAe,GAAG,mBAAmB,CAAC,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAE7E,IAAI,eAAe,EAAE;YACnB,OAAO;gBACL,GAAG,iBAAiB;gBACpB,GAAG,eAAe,CAAC,SAAS;aAC7B,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CloudpackConfig } from '../types.js';\nimport type { PackageJson, PackageDefinitionTransform } from '@ms-cloudpack/bundler-types';\nimport { findPackageOverride } from './findPackageOverride.js';\n\n/**\n * Creates a transform to be registered with a PackageDefinitions registry for overriding package.json definitions.\n */\nexport function createPackageOverrideTransform(config: CloudpackConfig): PackageDefinitionTransform {\n const { packageOverrides = [] } = config;\n\n return (packageDefinition: PackageJson) => {\n const { name = '', version = '' } = packageDefinition;\n const packageOverride = findPackageOverride(packageOverrides, name, version);\n\n if (packageOverride) {\n return {\n ...packageDefinition,\n ...packageOverride.overrides,\n };\n }\n\n return undefined;\n };\n}\n"]}
1
+ {"version":3,"file":"createPackageOverrideTransform.js","sourceRoot":"","sources":["../../src/common/createPackageOverrideTransform.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAuB;IACpE,MAAM,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAEzC,OAAO,CAAC,iBAA8B,EAAE,EAAE;QACxC,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,iBAAiB,CAAC;QACtD,MAAM,eAAe,GAAG,mBAAmB,CAAC,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAE7E,IAAI,eAAe,EAAE;YACnB,OAAO;gBACL,GAAG,iBAAiB;gBACpB,GAAG,eAAe,CAAC,SAAS;aAC7B,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/config';\nimport type { PackageJson, PackageDefinitionTransform } from '@ms-cloudpack/bundler-types';\nimport { findPackageOverride } from './findPackageOverride.js';\n\n/**\n * Creates a transform to be registered with a PackageDefinitions registry for overriding package.json definitions.\n */\nexport function createPackageOverrideTransform(config: CloudpackConfig): PackageDefinitionTransform {\n const { packageOverrides = [] } = config;\n\n return (packageDefinition: PackageJson) => {\n const { name = '', version = '' } = packageDefinition;\n const packageOverride = findPackageOverride(packageOverrides, name, version);\n\n if (packageOverride) {\n return {\n ...packageDefinition,\n ...packageOverride.overrides,\n };\n }\n\n return undefined;\n };\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -3,4 +3,6 @@
3
3
  * within the "./commands" folder.
4
4
  */
5
5
  export declare function main(): Promise<void>;
6
- export type { ApiServer, BundleRequest, BundleServer, BundleTaskOptions, CloudpackConfig, TelemetryConfig, CreateHtmlFunction, CreateHtmlOptions, CreateHtmlResult, CreateHtmlScript, DevServer, PackageOverride, Route, Session, SessionStats, Task, TaskDescription, TaskEndDescription, TaskError, TaskOptions, TaskStartDescription, Watcher, } from './types.js';
6
+ export type { BundleRequest, BundleServer, BundleTaskOptions, CreateHtmlFunction, CreateHtmlOptions, CreateHtmlResult, CreateHtmlScript, PackageOverride, Session, Watcher, } from './types.js';
7
+ export type { ApiServer, DevServer, Route, SessionStats, Task, TaskDescription, TaskEndDescription, TaskError, TaskOptions, TaskStartDescription, } from '@ms-cloudpack/api-server';
8
+ export type { CloudpackConfig, TelemetryConfig } from '@ms-cloudpack/config';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,QAAQ,EACR,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI;IACxB,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAErC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEzF,oDAAoD;IACpD,kBAAkB,CAAC;QACjB,aAAa;KACd,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,yEAAyE;IACzE,MAAM,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AE,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;IAExE,KAAK,MAAM,WAAW,IAAI,QAAQ,EAAE;QAClC,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAE9F,CAAC;QAEF,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KACvB;IAED,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,mEAAmE,CAAC,CAAC;IACrG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,kEAAkE,CAAC,CAAC;IAClG,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,gDAAgD,CAAC,CAAC;IAEnF,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7B,OAAO,CAAC,IAAI,EAAE,CAAC;KAChB;AACH,CAAC","sourcesContent":["import {\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n gradient,\n verboseLoggingConfig,\n} from '@ms-cloudpack/task-reporter';\nimport { Command } from 'commander';\nimport glob from 'glob';\nimport path from 'path';\nimport { fileURLToPath, pathToFileURL } from 'url';\nimport { getVersion } from './getVersion.js';\nimport { PerfMarkerCliEntry } from './performance/markers.js';\nimport { initTelemetry, setSharedTelemetryAttributes } from './initTelemetry.js';\nimport { setReporterOptions } from './reporter.js';\n\nconst currentPath = path.dirname(fileURLToPath(import.meta.url));\n\n/**\n * Entry point for the cloudpack CLI. Resolves all commands defined\n * within the \"./commands\" folder.\n */\nexport async function main() {\n performance.mark(PerfMarkerCliEntry);\n\n const program = new Command();\n const plainTextMode = process.argv.includes('--no-color') || process.argv.includes('-n');\n\n // Initialize the color setting as soon as possible.\n setReporterOptions({\n plainTextMode,\n });\n\n const version = getVersion();\n // the name \"Cloudpack\" preceed by an emoji representing sun behind cloud\n const productName = gradient(`Cloudpack`);\n const useDebugLogging = process.argv.includes('--debug') || process.argv.includes('-d');\n const verb = process.argv[2];\n const useVerboseLogging = process.argv.includes('--verbose') || process.argv.includes('-v') || verb === 'bundle';\n\n program.name(productName).version(version).usage('<command> [options]');\n\n setReporterOptions({\n productName,\n version,\n description: `Running \"${bold(process.argv.slice(2).join(' '))}\"`,\n ...defaultLoggingConfig,\n ...(useVerboseLogging && verboseLoggingConfig),\n ...(useDebugLogging && debugLoggingConfig),\n });\n\n await initTelemetry({\n useDebugLogging,\n useVerboseLogging,\n });\n\n setSharedTelemetryAttributes({\n verb,\n arguments: process.argv.slice(3).join(' '),\n environment: process.env.CI || process.env.TF_BUILD ? 'ci' : 'local',\n });\n\n const commands = glob.sync('commands/*/index.js', { cwd: currentPath });\n\n for (const commandPath of commands) {\n const command = (await import(pathToFileURL(path.resolve(currentPath, commandPath)).toString())) as {\n init: (cmd: Command) => void;\n };\n\n command.init(program);\n }\n\n program.option('-v, --verbose', 'Show additional details about the running tasks. (default: false)');\n program.option('-d, --debug', 'Show debug information (superset of --verbose). (default: false)');\n program.option('-n, --no-color', 'Disable colors in the output. (default: false)');\n\n program.parse(process.argv);\n\n if (program.args.length === 0) {\n program.help();\n }\n}\n\nexport type {\n ApiServer,\n BundleRequest,\n BundleServer,\n BundleTaskOptions,\n CloudpackConfig,\n TelemetryConfig,\n CreateHtmlFunction,\n CreateHtmlOptions,\n CreateHtmlResult,\n CreateHtmlScript,\n DevServer,\n PackageOverride,\n Route,\n Session,\n SessionStats,\n Task,\n TaskDescription,\n TaskEndDescription,\n TaskError,\n TaskOptions,\n TaskStartDescription,\n Watcher,\n} from './types.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,QAAQ,EACR,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAC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AO,CAAC,MAAM,CAAC,eAAe,EAAE,mEAAmE,CAAC,CAAC;IACrG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,kEAAkE,CAAC,CAAC;IAClG,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,gDAAgD,CAAC,CAAC;IAEnF,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7B,OAAO,CAAC,IAAI,EAAE,CAAC;KAChB;AACH,CAAC","sourcesContent":["import {\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n gradient,\n verboseLoggingConfig,\n} from '@ms-cloudpack/task-reporter';\nimport { Command } from 'commander';\nimport glob from 'glob';\nimport path from 'path';\nimport { fileURLToPath, pathToFileURL } from 'url';\nimport { getVersion } from './getVersion.js';\nimport { PerfMarkerCliEntry } from './performance/markers.js';\nimport { initTelemetry, setSharedTelemetryAttributes } from './initTelemetry.js';\nimport { setReporterOptions } from './reporter.js';\n\nconst currentPath = path.dirname(fileURLToPath(import.meta.url));\n\n/**\n * Entry point for the cloudpack CLI. Resolves all commands defined\n * within the \"./commands\" folder.\n */\nexport async function main() {\n performance.mark(PerfMarkerCliEntry);\n\n const program = new Command();\n const plainTextMode = process.argv.includes('--no-color') || process.argv.includes('-n');\n\n // Initialize the color setting as soon as possible.\n setReporterOptions({\n plainTextMode,\n });\n\n const version = getVersion();\n // the name \"Cloudpack\" preceed by an emoji representing sun behind cloud\n const productName = gradient(`Cloudpack`);\n const useDebugLogging = process.argv.includes('--debug') || process.argv.includes('-d');\n const verb = process.argv[2];\n const useVerboseLogging = process.argv.includes('--verbose') || process.argv.includes('-v') || verb === 'bundle';\n\n program.name(productName).version(version).usage('<command> [options]');\n\n setReporterOptions({\n productName,\n version,\n description: `Running \"${bold(process.argv.slice(2).join(' '))}\"`,\n ...defaultLoggingConfig,\n ...(useVerboseLogging && verboseLoggingConfig),\n ...(useDebugLogging && debugLoggingConfig),\n });\n\n await initTelemetry({\n useDebugLogging,\n useVerboseLogging,\n });\n\n setSharedTelemetryAttributes({\n verb,\n arguments: process.argv.slice(3).join(' '),\n environment: process.env.CI || process.env.TF_BUILD ? 'ci' : 'local',\n });\n\n const commands = glob.sync('commands/*/index.js', { cwd: currentPath });\n\n for (const commandPath of commands) {\n const command = (await import(pathToFileURL(path.resolve(currentPath, commandPath)).toString())) as {\n init: (cmd: Command) => void;\n };\n\n command.init(program);\n }\n\n program.option('-v, --verbose', 'Show additional details about the running tasks. (default: false)');\n program.option('-d, --debug', 'Show debug information (superset of --verbose). (default: false)');\n program.option('-n, --no-color', 'Disable colors in the output. (default: false)');\n\n program.parse(process.argv);\n\n if (program.args.length === 0) {\n program.help();\n }\n}\n\nexport type {\n BundleRequest,\n BundleServer,\n BundleTaskOptions,\n CreateHtmlFunction,\n CreateHtmlOptions,\n CreateHtmlResult,\n CreateHtmlScript,\n PackageOverride,\n Session,\n Watcher,\n} from './types.js';\n\nexport type {\n ApiServer,\n DevServer,\n Route,\n SessionStats,\n Task,\n TaskDescription,\n TaskEndDescription,\n TaskError,\n TaskOptions,\n TaskStartDescription,\n} from '@ms-cloudpack/api-server';\n\nexport type { CloudpackConfig, TelemetryConfig } from '@ms-cloudpack/config';\n"]}
@@ -1,4 +1,4 @@
1
- import { readConfig } from './common/config.js';
1
+ import { readConfig } from '@ms-cloudpack/config';
2
2
  import { getVersion } from './getVersion.js';
3
3
  import { createTelemetryClient } from '@ms-cloudpack/telemetry';
4
4
  import { registerPerformanceObservers } from './performance/registerPerformanceObservers.js';
@@ -1 +1 @@
1
- {"version":3,"file":"initTelemetry.js","sourceRoot":"","sources":["../src/initTelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAmC,qBAAqB,EAAE,MAAM,yBA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MAAM,UAAU,aAAa;IAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC;IAChB,OAAO,eAAe,EAAE,QAAQ,EAAE,CAAC;AACrC,CAAC","sourcesContent":["import { readConfig } from './common/config.js';\nimport { getVersion } from './getVersion.js';\nimport { type Span, type TelemetryClient, createTelemetryClient } from '@ms-cloudpack/telemetry';\nimport { registerPerformanceObservers } from './performance/registerPerformanceObservers.js';\n\nexport interface TelemetryInitOptions {\n useDebugLogging: boolean;\n useVerboseLogging: boolean;\n}\n\nlet telemetryClient: TelemetryClient | undefined;\nexport let rootSpan: Span | undefined;\n\n/**\n * Initialize the telemetry client, create the root span, register performance observers.\n * Telemetry will not be sent if no instrumentation key is found.\n * @param options - options to initialize telemetry\n * @returns\n */\nexport async function initTelemetry(options: TelemetryInitOptions) {\n const instrumentationKey =\n (await readConfig()).telemetry?.instrumentationKey || process.env.CLOUDPACK_TELEMETRY_INSTRUMENTATION_KEY;\n\n const logLevel = options.useVerboseLogging ? 'verbose' : options.useDebugLogging ? 'debug' : undefined;\n\n telemetryClient = await createTelemetryClient({\n productVersion: getVersion(),\n instrumentationKey,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n });\n\n // This is the root span for the CLI. It will be used to track the duration of the CLI execution.\n rootSpan = telemetryClient.getTracer()?.startSpan('CLI');\n\n if (rootSpan) {\n // Register performance observers to track performance metrics as events of CLI span.\n registerPerformanceObservers(rootSpan);\n }\n}\n\n/**\n * Adds shared attributes to all spans.\n * No-op if telemetry is not initialized.\n * @param attributes - key-value pair\n */\nexport function setSharedTelemetryAttributes(attributes: Record<string, string>) {\n for (const [key, value] of Object.entries(attributes)) {\n telemetryClient?.setSharedSpanAttribute(key, value);\n }\n}\n\n/**\n * Adds a shared attribute to all spans.\n * No-op if telemetry is not initialized.\n * @param key - key of the attribute\n * @param value - value of the attribute\n */\nexport function setSharedTelemetryAttribute(key: string, value: string) {\n telemetryClient?.setSharedSpanAttribute(key, value);\n}\n\n/**\n * Ends rootSpan and flushes all telemetry.\n * No-op if telemetry is not initialized.\n * @returns a promise that resolves when telemetry is flushed and shutdown.\n */\nexport function stopTelemetry() {\n rootSpan?.end();\n return telemetryClient?.shutdown();\n}\n"]}
1
+ {"version":3,"file":"initTelemetry.js","sourceRoot":"","sources":["../src/initTelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAmC,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAO7F,IAAI,eAA4C,CAAC;AACjD,MAAM,CAAC,IAAI,QAA0B,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,kBAAkB,GACtB,CAAC,MAAM,UAAU,EAAE,CAAC,CAAC,SAAS,EAAE,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC;IAE5G,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IAEvG,eAAe,GAAG,MAAM,qBAAqB,CAAC;QAC5C,cAAc,EAAE,UAAU,EAAE;QAC5B,kBAAkB;QAClB,QAAQ;QACR,gBAAgB,EAAE,WAAW;QAC7B,WAAW,EAAE,KAAK;KACnB,CAAC,CAAC;IAEH,iGAAiG;IACjG,QAAQ,GAAG,eAAe,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IAEzD,IAAI,QAAQ,EAAE;QACZ,qFAAqF;QACrF,4BAA4B,CAAC,QAAQ,CAAC,CAAC;KACxC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,UAAkC;IAC7E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACrD,eAAe,EAAE,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;KACrD;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,GAAW,EAAE,KAAa;IACpE,eAAe,EAAE,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC;IAChB,OAAO,eAAe,EAAE,QAAQ,EAAE,CAAC;AACrC,CAAC","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport { getVersion } from './getVersion.js';\nimport { type Span, type TelemetryClient, createTelemetryClient } from '@ms-cloudpack/telemetry';\nimport { registerPerformanceObservers } from './performance/registerPerformanceObservers.js';\n\nexport interface TelemetryInitOptions {\n useDebugLogging: boolean;\n useVerboseLogging: boolean;\n}\n\nlet telemetryClient: TelemetryClient | undefined;\nexport let rootSpan: Span | undefined;\n\n/**\n * Initialize the telemetry client, create the root span, register performance observers.\n * Telemetry will not be sent if no instrumentation key is found.\n * @param options - options to initialize telemetry\n * @returns\n */\nexport async function initTelemetry(options: TelemetryInitOptions) {\n const instrumentationKey =\n (await readConfig()).telemetry?.instrumentationKey || process.env.CLOUDPACK_TELEMETRY_INSTRUMENTATION_KEY;\n\n const logLevel = options.useVerboseLogging ? 'verbose' : options.useDebugLogging ? 'debug' : undefined;\n\n telemetryClient = await createTelemetryClient({\n productVersion: getVersion(),\n instrumentationKey,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n });\n\n // This is the root span for the CLI. It will be used to track the duration of the CLI execution.\n rootSpan = telemetryClient.getTracer()?.startSpan('CLI');\n\n if (rootSpan) {\n // Register performance observers to track performance metrics as events of CLI span.\n registerPerformanceObservers(rootSpan);\n }\n}\n\n/**\n * Adds shared attributes to all spans.\n * No-op if telemetry is not initialized.\n * @param attributes - key-value pair\n */\nexport function setSharedTelemetryAttributes(attributes: Record<string, string>) {\n for (const [key, value] of Object.entries(attributes)) {\n telemetryClient?.setSharedSpanAttribute(key, value);\n }\n}\n\n/**\n * Adds a shared attribute to all spans.\n * No-op if telemetry is not initialized.\n * @param key - key of the attribute\n * @param value - value of the attribute\n */\nexport function setSharedTelemetryAttribute(key: string, value: string) {\n telemetryClient?.setSharedSpanAttribute(key, value);\n}\n\n/**\n * Ends rootSpan and flushes all telemetry.\n * No-op if telemetry is not initialized.\n * @returns a promise that resolves when telemetry is flushed and shutdown.\n */\nexport function stopTelemetry() {\n rootSpan?.end();\n return telemetryClient?.shutdown();\n}\n"]}
package/lib/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ImportMap, ResolveMap } from '@ms-cloudpack/package-utilities';
2
2
  import type { BundleResult, PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
3
- import type { HttpsConfig } from '@ms-cloudpack/create-express-app';
3
+ import type { Route } from '@ms-cloudpack/api-server';
4
4
  export interface Session {
5
5
  /**
6
6
  * The session id, used for identifying
@@ -88,146 +88,14 @@ export interface BundleServer {
88
88
  port: number;
89
89
  close: () => Promise<void>;
90
90
  }
91
- export interface SessionStats {
92
- status: 'idle' | 'pending';
93
- remainingTasks: number;
94
- totalTasks: number;
95
- totalErrors: number;
96
- totalWarnings: number;
97
- }
98
- export interface ApiServer {
99
- url: string;
100
- port: number;
101
- notifyReload: () => void;
102
- addTask: <TReturn>(task: Task<TReturn>, options?: TaskOptions) => Promise<TReturn>;
103
- close: () => Promise<void>;
104
- }
105
- export interface Watcher {
106
- watch: (bundleRequest: BundleRequest) => void;
107
- }
108
- export interface TaskError {
109
- message: string;
110
- pluginName: string;
111
- stack: string;
112
- fileLocation: string;
113
- lineNumber: number;
114
- columnNumber: number;
115
- }
116
- export interface TaskStartDescription {
117
- id: string;
118
- name?: string;
119
- inputPath?: string;
120
- outputPath?: string;
121
- }
122
- export interface TaskEndDescription {
123
- id: string;
124
- errors?: TaskError[];
125
- warnings?: TaskError[];
126
- }
127
- export interface TaskDescription extends TaskStartDescription, TaskEndDescription {
128
- status: 'pending' | 'complete';
129
- startTime: number;
130
- durationMilliseconds?: number;
131
- lastUpdated?: number;
132
- }
133
- export interface Task<TReturn> {
134
- name: string;
135
- id: string;
136
- dir?: string;
137
- execute: () => Promise<TReturn | undefined>;
138
- clear?: () => void;
139
- watch?: boolean;
140
- dispose?: () => Promise<void>;
141
- onDispose?: () => void;
142
- getErrors?: () => TaskError[] | undefined;
143
- getStartDescription?: () => TaskStartDescription;
144
- getEndDescription?: (result: TReturn | undefined) => TaskEndDescription;
145
- }
146
- export interface TaskOptions {
147
- rerun?: boolean;
148
- watch?: () => void;
149
- }
150
91
  export interface PackageOverride {
151
92
  name: string;
152
93
  versionRequirement: string;
153
94
  isInternal?: boolean;
154
95
  overrides: PackageJson;
155
96
  }
156
- export interface Route {
157
- /**
158
- * The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also
159
- * use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.
160
- */
161
- match: string;
162
- /**
163
- * The path relative to the app root to static assets. If this is provided, renderScript/exportEntry
164
- * will be ignored.
165
- */
166
- staticPath?: string;
167
- /**
168
- * Path to a .js or .html file used for rendering the route. If a script is provided, it must
169
- * export a default function implementing `CreateHtmlFunction` defined in `@ms-cloudpack/cli`.
170
- */
171
- renderScript?: string;
172
- /**
173
- * The key in the exports map which represents the entry point app script for this route.
174
- * Default is '.', meaning the main package export key.
175
- */
176
- exportEntry?: string;
177
- }
178
- export interface DevServer {
179
- /**
180
- * The domain name of the server.
181
- */
182
- domain?: string;
183
- /**
184
- * The ports to be used by the server.
185
- * It can be a number or an array of numbers.
186
- * If ports are provided, an error will be thrown if none are available.
187
- * If no ports are provided, the server will attempt to find an available port.
188
- */
189
- port?: number | number[];
190
- /**
191
- * The config settings for the https server.
192
- * Paths to files are accepted for 'ca', 'cert', 'key', and 'pfx' settings.
193
- * Everything else is passed directly to the https.createServer() method.
194
- * If not provided, the server will use http.
195
- */
196
- https?: HttpsConfig;
197
- /**
198
- * If provided, will override where the publicDir is located, relative to the app package folder.
199
- * Defaults to `./public`. The same thing can be achieved with `routes`, using route: '*' and
200
- * staticPath: './public', so the `publicPath` setting may be removed in the future.
201
- */
202
- publicPath?: string;
203
- /**
204
- * If provided, will register routes with the dev server to host various pages.
205
- */
206
- routes?: Route[];
207
- }
208
- export interface TelemetryConfig {
209
- /**
210
- * Application Insights instrumentation key.
211
- */
212
- instrumentationKey: string;
213
- }
214
- /**
215
- * Per-application configuration for Cloudpack.
216
- */
217
- export interface CloudpackConfig {
218
- /**
219
- * An array of PackageOverride objects, used to provide overrides for packages without modifying their
220
- * definitions directly. This is primarily used for providing exports maps for packages that don't have them.
221
- */
222
- packageOverrides?: PackageOverride[];
223
- /**
224
- * A set of options for configuring how the dev server works.
225
- */
226
- devServer?: DevServer;
227
- /**
228
- * A set of options for configuring telemetry
229
- */
230
- telemetry?: TelemetryConfig;
97
+ export interface Watcher {
98
+ watch: (bundleRequest: BundleRequest) => void;
231
99
  }
232
100
  /**
233
101
  * The input options for a createHtml custom server render function.
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap, ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { BundleResult, PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { HttpsConfig } from '@ms-cloudpack/create-express-app';\n\nexport interface Session {\n /**\n * The session id, used for identifying\n */\n id: string;\n\n /**\n * The primary application path to monitor.\n */\n appPath: string;\n\n /**\n * The type of session controls how the code is served via start.\n * Web apps require app server and asset hosting, while libraries\n * only need a bundle service.\n */\n type: 'web-app' | 'library';\n\n /**\n * The mode of the session controls how the code is bundled. Library\n * mode bundles each package in isolation, while development and\n * production modes bundle the full app graph together. Library\n * mode is fastest but packages must be complaint for loading in\n * the browser.\n */\n mode: 'library' | 'development' | 'production';\n\n /**\n * Used to resolve packages in the dependency graph.\n */\n resolveMap: ResolveMap;\n\n /**\n * Reload sequence to ensure that the client is always\n * up to date with the latest changes.\n */\n sequence: number;\n\n /**\n * Get session version.\n * Used to force a hard refresh on the client.\n */\n getSessionVersion: () => number;\n\n /**\n * Used to increment the session version.\n * If version is undefined, the version will be incremented by 1.\n * If version is greater than the current version, the version will be set to the new value.\n */\n incrementSessionVersion: (version?: number) => void;\n\n /**\n * The name of the project folder.\n * Used to differentiate between multiple projects.\n */\n projectName: string;\n\n /**\n * The version of each target.\n * Used to force a client cache refresh on a single target.\n */\n targetVersions: Record<string, number>;\n\n /**\n * Increments the version for the given target.\n */\n incrementTargetVersion: (inputPath: string) => void;\n\n /**\n * The import map for the session.\n */\n getImportMap: () => ImportMap | undefined;\n\n setImportMap: (newImportMap: ImportMap) => ImportMap;\n}\n\n/**\n * Tracks a given bundle request and its result.\n */\nexport interface BundleRequest {\n id: string;\n packageName: string;\n version: string;\n packagePath: string;\n outputPath: string;\n isExternal: boolean;\n bundlerType?: string;\n result?: BundleResult;\n resultFromCache?: boolean;\n isRebuildRequired?: boolean;\n packages?: PackageDefinitionsCache;\n}\n\nexport interface BundleTaskOptions {\n force?: boolean;\n}\n\nexport interface BundleServer {\n url: string;\n port: number;\n close: () => Promise<void>;\n}\n\nexport interface SessionStats {\n status: 'idle' | 'pending';\n\n remainingTasks: number;\n totalTasks: number;\n\n totalErrors: number;\n totalWarnings: number;\n}\n\nexport interface ApiServer {\n url: string;\n port: number;\n\n notifyReload: () => void;\n\n addTask: <TReturn>(task: Task<TReturn>, options?: TaskOptions) => Promise<TReturn>;\n\n close: () => Promise<void>;\n}\n\nexport interface Watcher {\n watch: (bundleRequest: BundleRequest) => void;\n}\n\nexport interface TaskError {\n message: string;\n pluginName: string;\n stack: string;\n fileLocation: string;\n lineNumber: number;\n columnNumber: number;\n}\n\nexport interface TaskStartDescription {\n id: string;\n name?: string;\n inputPath?: string;\n outputPath?: string;\n}\n\nexport interface TaskEndDescription {\n id: string;\n errors?: TaskError[];\n warnings?: TaskError[];\n}\n\nexport interface TaskDescription extends TaskStartDescription, TaskEndDescription {\n status: 'pending' | 'complete';\n startTime: number;\n durationMilliseconds?: number;\n lastUpdated?: number;\n}\n\nexport interface Task<TReturn> {\n name: string;\n id: string;\n dir?: string;\n execute: () => Promise<TReturn | undefined>;\n clear?: () => void;\n watch?: boolean;\n dispose?: () => Promise<void>;\n onDispose?: () => void;\n getErrors?: () => TaskError[] | undefined;\n getStartDescription?: () => TaskStartDescription;\n getEndDescription?: (result: TReturn | undefined) => TaskEndDescription;\n}\n\nexport interface TaskOptions {\n rerun?: boolean;\n watch?: () => void;\n}\n\nexport interface PackageOverride {\n name: string;\n versionRequirement: string;\n isInternal?: boolean;\n overrides: PackageJson;\n}\n\nexport interface Route {\n /**\n * The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also\n * use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n */\n match: string;\n\n /**\n * The path relative to the app root to static assets. If this is provided, renderScript/exportEntry\n * will be ignored.\n */\n staticPath?: string;\n\n /**\n * Path to a .js or .html file used for rendering the route. If a script is provided, it must\n * export a default function implementing `CreateHtmlFunction` defined in `@ms-cloudpack/cli`.\n */\n renderScript?: string;\n\n /**\n * The key in the exports map which represents the entry point app script for this route.\n * Default is '.', meaning the main package export key.\n */\n exportEntry?: string;\n}\n\nexport interface DevServer {\n /**\n * The domain name of the server.\n */\n domain?: string;\n\n /**\n * The ports to be used by the server.\n * It can be a number or an array of numbers.\n * If ports are provided, an error will be thrown if none are available.\n * If no ports are provided, the server will attempt to find an available port.\n */\n port?: number | number[];\n\n /**\n * The config settings for the https server.\n * Paths to files are accepted for 'ca', 'cert', 'key', and 'pfx' settings.\n * Everything else is passed directly to the https.createServer() method.\n * If not provided, the server will use http.\n */\n https?: HttpsConfig;\n\n /**\n * If provided, will override where the publicDir is located, relative to the app package folder.\n * Defaults to `./public`. The same thing can be achieved with `routes`, using route: '*' and\n * staticPath: './public', so the `publicPath` setting may be removed in the future.\n */\n publicPath?: string;\n\n /**\n * If provided, will register routes with the dev server to host various pages.\n */\n routes?: Route[];\n}\n\nexport interface TelemetryConfig {\n /**\n * Application Insights instrumentation key.\n */\n instrumentationKey: string;\n}\n\n/**\n * Per-application configuration for Cloudpack.\n */\nexport interface CloudpackConfig {\n /**\n * An array of PackageOverride objects, used to provide overrides for packages without modifying their\n * definitions directly. This is primarily used for providing exports maps for packages that don't have them.\n */\n packageOverrides?: PackageOverride[];\n\n /**\n * A set of options for configuring how the dev server works.\n */\n devServer?: DevServer;\n\n /**\n * A set of options for configuring telemetry\n */\n telemetry?: TelemetryConfig;\n}\n\n/**\n * The input options for a createHtml custom server render function.\n */\nexport type CreateHtmlOptions = {\n session: Session;\n route: Route;\n baseUrl: string;\n definition: PackageJson;\n importMap: ImportMap;\n overlayScript: string | undefined;\n entryScript: string | undefined;\n inlineScripts: string[];\n};\n\n/**\n * The expected result of the createHtml custom server render function.\n */\nexport type CreateHtmlResult =\n | string\n | {\n html: string;\n statusCode: number;\n };\n\n/**\n * A custom server render function that can be used to override the default HTML response.\n */\nexport type CreateHtmlFunction = (options: CreateHtmlOptions) => Promise<CreateHtmlResult> | CreateHtmlResult;\n\n/**\n * The expected shape of the createHtml custom server render function script.\n */\nexport type CreateHtmlScript = { default: CreateHtmlFunction };\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap, ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { BundleResult, PackageJson, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { Route } from '@ms-cloudpack/api-server';\n\nexport interface Session {\n /**\n * The session id, used for identifying\n */\n id: string;\n\n /**\n * The primary application path to monitor.\n */\n appPath: string;\n\n /**\n * The type of session controls how the code is served via start.\n * Web apps require app server and asset hosting, while libraries\n * only need a bundle service.\n */\n type: 'web-app' | 'library';\n\n /**\n * The mode of the session controls how the code is bundled. Library\n * mode bundles each package in isolation, while development and\n * production modes bundle the full app graph together. Library\n * mode is fastest but packages must be complaint for loading in\n * the browser.\n */\n mode: 'library' | 'development' | 'production';\n\n /**\n * Used to resolve packages in the dependency graph.\n */\n resolveMap: ResolveMap;\n\n /**\n * Reload sequence to ensure that the client is always\n * up to date with the latest changes.\n */\n sequence: number;\n\n /**\n * Get session version.\n * Used to force a hard refresh on the client.\n */\n getSessionVersion: () => number;\n\n /**\n * Used to increment the session version.\n * If version is undefined, the version will be incremented by 1.\n * If version is greater than the current version, the version will be set to the new value.\n */\n incrementSessionVersion: (version?: number) => void;\n\n /**\n * The name of the project folder.\n * Used to differentiate between multiple projects.\n */\n projectName: string;\n\n /**\n * The version of each target.\n * Used to force a client cache refresh on a single target.\n */\n targetVersions: Record<string, number>;\n\n /**\n * Increments the version for the given target.\n */\n incrementTargetVersion: (inputPath: string) => void;\n\n /**\n * The import map for the session.\n */\n getImportMap: () => ImportMap | undefined;\n\n setImportMap: (newImportMap: ImportMap) => ImportMap;\n}\n\n/**\n * Tracks a given bundle request and its result.\n */\nexport interface BundleRequest {\n id: string;\n packageName: string;\n version: string;\n packagePath: string;\n outputPath: string;\n isExternal: boolean;\n bundlerType?: string;\n result?: BundleResult;\n resultFromCache?: boolean;\n isRebuildRequired?: boolean;\n packages?: PackageDefinitionsCache;\n}\n\nexport interface BundleTaskOptions {\n force?: boolean;\n}\n\nexport interface BundleServer {\n url: string;\n port: number;\n close: () => Promise<void>;\n}\n\nexport interface PackageOverride {\n name: string;\n versionRequirement: string;\n isInternal?: boolean;\n overrides: PackageJson;\n}\n\nexport interface Watcher {\n watch: (bundleRequest: BundleRequest) => void;\n}\n\n/**\n * The input options for a createHtml custom server render function.\n */\nexport type CreateHtmlOptions = {\n session: Session;\n route: Route;\n baseUrl: string;\n definition: PackageJson;\n importMap: ImportMap;\n overlayScript: string | undefined;\n entryScript: string | undefined;\n inlineScripts: string[];\n};\n\n/**\n * The expected result of the createHtml custom server render function.\n */\nexport type CreateHtmlResult =\n | string\n | {\n html: string;\n statusCode: number;\n };\n\n/**\n * A custom server render function that can be used to override the default HTML response.\n */\nexport type CreateHtmlFunction = (options: CreateHtmlOptions) => Promise<CreateHtmlResult> | CreateHtmlResult;\n\n/**\n * The expected shape of the createHtml custom server render function script.\n */\nexport type CreateHtmlScript = { default: CreateHtmlFunction };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.31.7",
3
+ "version": "0.32.0",
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",
@@ -16,16 +16,18 @@
16
16
  "cloudpack": "./bin/cloudpack.js"
17
17
  },
18
18
  "dependencies": {
19
- "@ms-cloudpack/bundler": "^0.11.17",
19
+ "@ms-cloudpack/api-server": "^0.2.0",
20
+ "@ms-cloudpack/bundler": "^0.11.18",
21
+ "@ms-cloudpack/config": "^0.2.0",
20
22
  "@ms-cloudpack/create-express-app": "^1.3.0",
21
23
  "@ms-cloudpack/data-bus": "^0.1.1",
22
24
  "@ms-cloudpack/json-utilities": "^0.0.5",
23
- "@ms-cloudpack/overlay": "^0.12.2",
25
+ "@ms-cloudpack/overlay": "^0.13.0",
24
26
  "@ms-cloudpack/package-utilities": "^2.3.10",
25
27
  "@ms-cloudpack/path-utilities": "^2.1.1",
26
28
  "@ms-cloudpack/path-string-parsing": "^1.0.1",
27
29
  "@ms-cloudpack/task-reporter": "^0.3.0",
28
- "@ms-cloudpack/telemetry": "^0.2.1",
30
+ "@ms-cloudpack/telemetry": "^0.2.2",
29
31
  "chokidar": "^3.5.3",
30
32
  "commander": "^10.0.0",
31
33
  "es-module-lexer": "^1.0.3",
@@ -1,40 +0,0 @@
1
- import type { Task, TaskOptions } from '../../types.js';
2
- /**
3
- * TaskRunner class manages the state of Tasks.
4
- * This class is to be called by the api server.
5
- */
6
- export declare class TaskRunner {
7
- private _queue;
8
- private _pendingTasks;
9
- private _completedTasks;
10
- private _requiresRerun;
11
- private _prevTasks;
12
- constructor();
13
- /**
14
- * The add method enqueues a Task and returns its Promise.
15
- * If a Task with the same id has already been processed,
16
- * it returns either the result or the promise.
17
- * Rerun flag forces the Task to be run again.
18
- */
19
- add<TReturn>(task: Task<TReturn>, options?: TaskOptions): Promise<TReturn>;
20
- /**
21
- * The reset method removes a task from the TaskRunner
22
- * and then adds it again through a previous execute function.
23
- *
24
- * This is useful for when a task needs to be forcibly rerun.
25
- *
26
- * It is intented to be used by the api server
27
- * to rerun a task when it is stuck or it failed.
28
- */
29
- reset<TReturn>(id: string): Promise<TReturn>;
30
- /**
31
- * The remove method disposes a task if available
32
- * and then removes it from the TaskRunner.
33
- *
34
- * This is useful when the state of a task needs to be cleared.
35
- *
36
- * It is intented to be used by the api server
37
- * to clear the TaskRunner's state before reloading the page.
38
- */
39
- remove(id: string): void;
40
- }
@@ -1,119 +0,0 @@
1
- import PQueue from 'p-queue';
2
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
- const log = (...messages) => {
4
- // console.log(`TaskRunner:`, ...messages);
5
- };
6
- /**
7
- * TaskRunner class manages the state of Tasks.
8
- * This class is to be called by the api server.
9
- */
10
- export class TaskRunner {
11
- constructor() {
12
- this._queue = new PQueue({ concurrency: 10 });
13
- this._pendingTasks = new Map();
14
- this._completedTasks = new Map();
15
- this._requiresRerun = new Set();
16
- this._prevTasks = new Map();
17
- }
18
- /**
19
- * The add method enqueues a Task and returns its Promise.
20
- * If a Task with the same id has already been processed,
21
- * it returns either the result or the promise.
22
- * Rerun flag forces the Task to be run again.
23
- */
24
- add(task, options) {
25
- const { name, id, execute } = task;
26
- const { rerun, watch } = options || {};
27
- watch?.();
28
- if (!this._prevTasks.get(id)) {
29
- this._prevTasks.set(id, task);
30
- }
31
- // Check if we are already completed the task with that id.
32
- const action = this._completedTasks.get(id);
33
- if (action !== undefined && !rerun) {
34
- log(`Previous action found, returning: "${name}:${id}"`);
35
- return Promise.resolve(action);
36
- }
37
- // Check if we are already running the task with that id.
38
- const pending = this._pendingTasks.get(id);
39
- if (pending !== undefined) {
40
- if (rerun) {
41
- this._requiresRerun.add(id);
42
- }
43
- log(`Previous action found, waiting: "${name}:${id}"`);
44
- return pending;
45
- }
46
- const resultPromise = (async () => {
47
- let taskResult;
48
- let taskError;
49
- let completed = false;
50
- do {
51
- // Delete from rerun list (if present).
52
- this._requiresRerun.delete(id);
53
- try {
54
- // TODO: possibly remove cast once this issue is resolved
55
- // https://github.com/sindresorhus/p-queue/issues/175
56
- taskResult = (await this._queue.add(execute));
57
- completed = true;
58
- }
59
- catch (err) {
60
- // Save the error--it will be thrown later if a rerun was not requested.
61
- taskError = err;
62
- }
63
- } while (this._requiresRerun.has(id));
64
- log(`Task finished: "${name}:${id}"`);
65
- // Delete from pending list.
66
- this._pendingTasks.delete(id);
67
- if (completed) {
68
- // Update finished Tasks.
69
- this._completedTasks.set(id, taskResult);
70
- // Resolve the promise.
71
- return taskResult;
72
- }
73
- // If the task never completed successfully, throw the error from earlier.
74
- throw taskError;
75
- })();
76
- this._pendingTasks.set(id, resultPromise);
77
- this._completedTasks.delete(id);
78
- return resultPromise;
79
- }
80
- /**
81
- * The reset method removes a task from the TaskRunner
82
- * and then adds it again through a previous execute function.
83
- *
84
- * This is useful for when a task needs to be forcibly rerun.
85
- *
86
- * It is intented to be used by the api server
87
- * to rerun a task when it is stuck or it failed.
88
- */
89
- reset(id) {
90
- this.remove(id);
91
- const prevTask = this._prevTasks.get(id);
92
- if (prevTask === undefined) {
93
- throw new Error(`Task not found: ${id}`);
94
- }
95
- return this.add(prevTask, { rerun: true });
96
- }
97
- /**
98
- * The remove method disposes a task if available
99
- * and then removes it from the TaskRunner.
100
- *
101
- * This is useful when the state of a task needs to be cleared.
102
- *
103
- * It is intented to be used by the api server
104
- * to clear the TaskRunner's state before reloading the page.
105
- */
106
- remove(id) {
107
- this._prevTasks
108
- .get(id)
109
- ?.dispose?.()
110
- .catch(() => {
111
- log(`Error disposing task: ${id}`);
112
- });
113
- this._prevTasks.get(id)?.clear?.();
114
- this._requiresRerun.delete(id);
115
- this._pendingTasks.delete(id);
116
- this._completedTasks.delete(id);
117
- }
118
- }
119
- //# sourceMappingURL=TaskRunner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TaskRunner.js","sourceRoot":"","sources":["../../../src/commands/start/TaskRunner.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAG7B,6DAA6D;AAC7D,MAAM,GAAG,GAAG,CAAC,GAAG,QAAmB,EAAE,EAAE;IACrC,2CAA2C;AAC7C,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,UAAU;IAUrB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAU,IAAmB,EAAE,OAAqB;QACrD,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACnC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QAEvC,KAAK,EAAE,EAAE,CAAC;QAEV,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAA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cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC9B,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["import PQueue from 'p-queue';\nimport type { Task, TaskOptions } from '../../types.js';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst log = (...messages: unknown[]) => {\n // console.log(`TaskRunner:`, ...messages);\n};\n\n/**\n * TaskRunner class manages the state of Tasks.\n * This class is to be called by the api server.\n */\nexport class TaskRunner {\n private _queue: PQueue;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _pendingTasks: Map<string, Promise<any>>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _completedTasks: Map<string, any>;\n private _requiresRerun: Set<string>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _prevTasks: Map<string, Task<any>>;\n\n constructor() {\n this._queue = new PQueue({ concurrency: 10 });\n this._pendingTasks = new Map();\n this._completedTasks = new Map();\n this._requiresRerun = new Set();\n this._prevTasks = new Map();\n }\n\n /**\n * The add method enqueues a Task and returns its Promise.\n * If a Task with the same id has already been processed,\n * it returns either the result or the promise.\n * Rerun flag forces the Task to be run again.\n */\n add<TReturn>(task: Task<TReturn>, options?: TaskOptions): Promise<TReturn> {\n const { name, id, execute } = task;\n const { rerun, watch } = options || {};\n\n watch?.();\n\n if (!this._prevTasks.get(id)) {\n this._prevTasks.set(id, task);\n }\n\n // Check if we are already completed the task with that id.\n const action = this._completedTasks.get(id) as TReturn | undefined;\n if (action !== undefined && !rerun) {\n log(`Previous action found, returning: \"${name}:${id}\"`);\n return Promise.resolve(action);\n }\n\n // Check if we are already running the task with that id.\n const pending = this._pendingTasks.get(id) as Promise<TReturn> | undefined;\n if (pending !== undefined) {\n if (rerun) {\n this._requiresRerun.add(id);\n }\n log(`Previous action found, waiting: \"${name}:${id}\"`);\n return pending;\n }\n\n const resultPromise = (async () => {\n let taskResult: TReturn | undefined;\n let taskError: unknown;\n let completed = false;\n\n do {\n // Delete from rerun list (if present).\n this._requiresRerun.delete(id);\n try {\n // TODO: possibly remove cast once this issue is resolved\n // https://github.com/sindresorhus/p-queue/issues/175\n taskResult = (await this._queue.add(execute)) as TReturn | undefined;\n completed = true;\n } catch (err) {\n // Save the error--it will be thrown later if a rerun was not requested.\n taskError = err;\n }\n } while (this._requiresRerun.has(id));\n\n log(`Task finished: \"${name}:${id}\"`);\n\n // Delete from pending list.\n this._pendingTasks.delete(id);\n\n if (completed) {\n // Update finished Tasks.\n this._completedTasks.set(id, taskResult);\n // Resolve the promise.\n return taskResult as TReturn;\n }\n\n // If the task never completed successfully, throw the error from earlier.\n throw taskError;\n })();\n\n this._pendingTasks.set(id, resultPromise);\n this._completedTasks.delete(id);\n\n return resultPromise;\n }\n\n /**\n * The reset method removes a task from the TaskRunner\n * and then adds it again through a previous execute function.\n *\n * This is useful for when a task needs to be forcibly rerun.\n *\n * It is intented to be used by the api server\n * to rerun a task when it is stuck or it failed.\n */\n reset<TReturn>(id: string): Promise<TReturn> {\n this.remove(id);\n const prevTask = this._prevTasks.get(id);\n if (prevTask === undefined) {\n throw new Error(`Task not found: ${id}`);\n }\n return <Promise<TReturn>>this.add(prevTask, { rerun: true });\n }\n\n /**\n * The remove method disposes a task if available\n * and then removes it from the TaskRunner.\n *\n * This is useful when the state of a task needs to be cleared.\n *\n * It is intented to be used by the api server\n * to clear the TaskRunner's state before reloading the page.\n */\n remove(id: string): void {\n this._prevTasks\n .get(id)\n ?.dispose?.()\n .catch(() => {\n log(`Error disposing task: ${id}`);\n });\n this._prevTasks.get(id)?.clear?.();\n this._requiresRerun.delete(id);\n this._pendingTasks.delete(id);\n this._completedTasks.delete(id);\n }\n}\n"]}
@@ -1,7 +0,0 @@
1
- import type { Session } from '../../types.js';
2
- export declare function addOverride({ session, packageName, importPath, filename, }: {
3
- session: Session;
4
- packageName: string;
5
- importPath: string;
6
- filename?: string;
7
- }): Promise<void>;
@@ -1,63 +0,0 @@
1
- import semver from 'semver';
2
- import { createPackageOverrideTransform } from '../../common/createPackageOverrideTransform.js';
3
- import { addExportsMapEntry, findResolveMapEntry, getExportsMap, PackageDefinitions, } from '@ms-cloudpack/package-utilities';
4
- import { slash } from '@ms-cloudpack/path-string-parsing';
5
- import { parseRequestInfo } from './parseRequestInfo.js';
6
- import { readConfig, writeConfig } from '../../common/config.js';
7
- export async function addOverride({ session, packageName, importPath, filename, }) {
8
- let definition = undefined;
9
- if (filename) {
10
- const requestPath = slash(new URL(filename).pathname);
11
- const { packageName: name, version } = parseRequestInfo(requestPath);
12
- definition = { name, version };
13
- }
14
- const entry = findResolveMapEntry({
15
- packageName,
16
- resolveMap: session.resolveMap,
17
- definition,
18
- });
19
- if (entry === undefined) {
20
- console.error(`Could not find entry of package ${packageName} in resolve map`);
21
- return;
22
- }
23
- const exports = (await getExportsMap(entry.path));
24
- await addExportsMapEntry({
25
- exports,
26
- packagePath: entry.path,
27
- importPath,
28
- });
29
- const packageOverride = {
30
- name: packageName,
31
- versionRequirement: entry.version,
32
- overrides: {
33
- exports,
34
- },
35
- };
36
- // Parse config if it exists.
37
- const cloudpackConfig = await readConfig(session.appPath);
38
- // Add package override to config.
39
- if (!cloudpackConfig.packageOverrides) {
40
- cloudpackConfig.packageOverrides = [packageOverride];
41
- }
42
- else {
43
- // Check if override already exists.
44
- const existingOverride = cloudpackConfig.packageOverrides.find((o) => o.name === packageOverride.name && semver.satisfies(packageOverride.versionRequirement, o.versionRequirement));
45
- if (existingOverride) {
46
- // Update existing override.
47
- existingOverride.overrides = packageOverride.overrides;
48
- }
49
- else {
50
- // Add new override.
51
- cloudpackConfig.packageOverrides.push(packageOverride);
52
- }
53
- }
54
- // Write config.
55
- await writeConfig(cloudpackConfig, session.appPath);
56
- console.debug(`Added override for ${packageName} to cloudpack config`);
57
- const override = {
58
- packageOverrides: [packageOverride],
59
- };
60
- // Initialize package overrides.
61
- PackageDefinitions.getInstance().registerTransform(createPackageOverrideTransform(override));
62
- }
63
- //# sourceMappingURL=addOverride.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addOverride.js","sourceRoot":"","sources":["../../../src/commands/start/addOverride.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAC;AAChG,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAChC,OAAO,EACP,WAAW,EACX,UAAU,EACV,QAAQ,GAMT;IACC,IAAI,UAAU,GAAG,SAAS,CAAC;IAE3B,IAAI,QAAQ,EAAE;QACZ,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;QACrE,UAAU,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAChC;IAED,MAAM,KAAK,GAAG,mBAAmB,CAAC;QAChC,WAAW;QACX,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,UAAU;KACX,CAAC,CAAC;IAEH,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,mCAAmC,WAAW,iBAAiB,CAAC,CAAC;QAC/E,OAAO;KACR;IAED,MAAM,OAAO,GAAG,CAAC,MAAM,aAAa,CAAC,KAAK,CAAC,IAAI,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,CAAC,CAAC;AAC/F,CAAC","sourcesContent":["import semver from 'semver';\nimport { createPackageOverrideTransform } from '../../common/createPackageOverrideTransform.js';\nimport {\n addExportsMapEntry,\n findResolveMapEntry,\n getExportsMap,\n PackageDefinitions,\n} from '@ms-cloudpack/package-utilities';\nimport type { CloudpackConfig, Session, PackageOverride } from '../../types.js';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport { parseRequestInfo } from './parseRequestInfo.js';\nimport { readConfig, writeConfig } from '../../common/config.js';\n\nexport async function addOverride({\n session,\n packageName,\n importPath,\n filename,\n}: {\n session: Session;\n packageName: string;\n importPath: string;\n filename?: string;\n}) {\n let definition = undefined;\n\n if (filename) {\n const requestPath = slash(new URL(filename).pathname);\n const { packageName: name, version } = parseRequestInfo(requestPath);\n definition = { name, version };\n }\n\n const entry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n definition,\n });\n\n if (entry === undefined) {\n console.error(`Could not find entry of package ${packageName} in resolve map`);\n return;\n }\n\n const exports = (await getExportsMap(entry.path)) as Record<string, Record<string, string>>;\n\n await addExportsMapEntry({\n exports,\n packagePath: entry.path,\n importPath,\n });\n\n const packageOverride: PackageOverride = {\n name: packageName,\n versionRequirement: entry.version,\n overrides: {\n exports,\n },\n };\n\n // Parse config if it exists.\n const cloudpackConfig = await readConfig(session.appPath);\n\n // Add package override to config.\n if (!cloudpackConfig.packageOverrides) {\n cloudpackConfig.packageOverrides = [packageOverride];\n } else {\n // Check if override already exists.\n const existingOverride = cloudpackConfig.packageOverrides.find(\n (o) =>\n o.name === packageOverride.name && semver.satisfies(packageOverride.versionRequirement, o.versionRequirement),\n );\n\n if (existingOverride) {\n // Update existing override.\n existingOverride.overrides = packageOverride.overrides;\n } else {\n // Add new override.\n cloudpackConfig.packageOverrides.push(packageOverride);\n }\n }\n\n // Write config.\n await writeConfig(cloudpackConfig, session.appPath);\n console.debug(`Added override for ${packageName} to cloudpack config`);\n\n const override: CloudpackConfig = {\n packageOverrides: [packageOverride],\n };\n\n // Initialize package overrides.\n PackageDefinitions.getInstance().registerTransform(createPackageOverrideTransform(override));\n}\n"]}