@ms-cloudpack/cli 0.72.29 → 0.72.31
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.
- package/lib/commands/init/InitSummaryData.d.ts.map +1 -1
- package/lib/commands/init/InitSummaryData.js.map +1 -1
- package/lib/commands/init/formatInitSummary.d.ts.map +1 -1
- package/lib/commands/init/formatInitSummary.js.map +1 -1
- package/lib/commands/init/init.js.map +1 -1
- package/lib/commands/link/formatLinkSummary.d.ts.map +1 -1
- package/lib/commands/link/formatLinkSummary.js.map +1 -1
- package/lib/commands/start/index.js.map +1 -1
- package/lib/commands/start/openBrowser.d.ts.map +1 -1
- package/lib/commands/start/openBrowser.js.map +1 -1
- package/lib/commands/start/trackSession.d.ts +1 -1
- package/lib/commands/start/trackSession.d.ts.map +1 -1
- package/lib/commands/start/trackSession.js.map +1 -1
- package/lib/commands/sync/execute.js.map +1 -1
- package/lib/commands/sync/index.d.ts.map +1 -1
- package/lib/commands/sync/index.js +1 -7
- package/lib/commands/sync/index.js.map +1 -1
- package/lib/main.d.ts.map +1 -1
- package/lib/main.js.map +1 -1
- package/lib/utilities/AutoDisposableList.d.ts.map +1 -1
- package/lib/utilities/AutoDisposableList.js.map +1 -1
- package/lib/utilities/CloudpackCommand.js.map +1 -1
- package/lib/utilities/CommandExecutor.d.ts +1 -1
- package/lib/utilities/CommandExecutor.d.ts.map +1 -1
- package/lib/utilities/CommandExecutor.js.map +1 -1
- package/lib/utilities/findCloudpackAppPaths.d.ts.map +1 -1
- package/lib/utilities/findCloudpackAppPaths.js.map +1 -1
- package/lib/utilities/getRepositoryName.d.ts.map +1 -1
- package/lib/utilities/getRepositoryName.js.map +1 -1
- package/lib/utilities/reusedOptions.d.ts +4 -4
- package/lib/utilities/reusedOptions.d.ts.map +1 -1
- package/lib/utilities/reusedOptions.js.map +1 -1
- package/lib/utilities/runPrerequisites.d.ts.map +1 -1
- package/lib/utilities/runPrerequisites.js.map +1 -1
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitSummaryData.d.ts","sourceRoot":"","sources":["../../../src/commands/init/InitSummaryData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAGlF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAGhE;;;;;;;GAOG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,iBAAiB,CAA0C;IACnE,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAS;gBAEb,OAAO,EAAE,MAAM;IAO3B;;OAEG;IACI,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAIpD;;OAEG;IACI,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI;IASpE;;;OAGG;IACI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAItD;;;;OAIG;IACI,sBAAsB,CAAC,UAAU,EAAE,uBAAuB,EAAE;
|
|
1
|
+
{"version":3,"file":"InitSummaryData.d.ts","sourceRoot":"","sources":["../../../src/commands/init/InitSummaryData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAGlF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAA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IAAI,CAAC,eAAe,CAAC,CAAC,MAAM;YACvD,YAAY;YACZ,WAAW;YACX,aAAa;YACb,YAAY;YACZ,oBAAoB;YACpB,MAAM,EAAE,WAAW,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,oBAAoB,GAAG,CAAC,CAAC;YACxE,kBAAkB;YAClB,oBAAoB;YACpB,oBAAoB,EAAE,aAAa;SACpC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { InitSummary } from './types/InitSummary.js';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport type { InitPackageResultWarnings } from './types/InitPackageResultWarnings.js';\nimport type { InitPackageResultErrors } from './types/InitPackageResultErrors.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { BundleMessage } from '@ms-cloudpack/common-types';\nimport { requiredChangeTypes } from './types/GeneratedChange.js';\n\n/**\n * Creates a summary tracking helper for the `init` verb to use to record statistics about results and needed\n * changes. The `record*` methods of the returned object will be used within init to add the stats, and the\n * `get` method will return the final tally. The resulting `InitSummary` object can be used in the `formatInitSummary`\n * helper to convert it to a string for the user.\n *\n * The `getMissingExportsMessage` method can be used to check that the imports/exports of packages match.\n */\nexport class InitSummaryData {\n private _packageResults: Record<string, InitPackageResult>;\n private _generatedUpdates: Record<string, GeneratedPackageChanges>;\n private _startTime: number;\n private _appPath: string;\n\n constructor(appPath: string) {\n this._packageResults = {};\n this._generatedUpdates = {};\n this._startTime = Date.now();\n this._appPath = appPath;\n }\n\n /**\n * Saves a package result.\n */\n public recordResult(result: InitPackageResult): void {\n this._packageResults[result.path] = result;\n }\n\n /**\n * Record more errors for a given package path.\n */\n public addErrors(packagePath: string, errors: BundleMessage[]): void {\n const packageResult = this._packageResults[packagePath];\n if (!packageResult) {\n throw new Error(`Package result not found for path ${packagePath}`);\n }\n\n packageResult.errors = [...(packageResult.errors || []), ...errors];\n }\n\n /**\n * Returns the package results.\n * @returns The package results.\n */\n public getResults(): Record<string, InitPackageResult> {\n return this._packageResults;\n }\n\n /**\n * Saves a generated file update.\n * @param allChanges - The generated file update to save.\n * @returns void.\n */\n public recordGeneratedChanges(allChanges: GeneratedPackageChanges[]) {\n for (const update of allChanges) {\n const { name, version, path, changes } = update;\n const updatesForPackage = (this._generatedUpdates[path] ??= { name, version, path, changes: [] });\n\n updatesForPackage.changes.push(...changes);\n }\n }\n\n /**\n * Returns the summary of the results.\n * @returns The summary of the results.\n */\n public summarize(options: Pick<InitOptions, 'check'>): InitSummary {\n const duration = Date.now() - this._startTime;\n let totalSuccess = 0;\n let totalErrors = 0;\n let totalWarnings = 0;\n let totalChanges = 0;\n let totalRequiredChanges = 0;\n const packagesWithErrors: InitPackageResultErrors[] = [];\n const packagesWithWarnings: InitPackageResultWarnings[] = [];\n\n for (const packageResult of Object.values(this._packageResults)) {\n if (packageResult.errors?.length) {\n packagesWithErrors.push(packageResult as InitPackageResultErrors);\n totalErrors += packageResult.errors.length;\n } else {\n totalSuccess++;\n }\n\n if (packageResult.warnings?.length) {\n packagesWithWarnings.push(packageResult as InitPackageResultWarnings);\n totalWarnings += packageResult.warnings.length;\n }\n }\n\n const sortedUpdates = Object.values(this._generatedUpdates).sort((a, b) => a.path.localeCompare(b.path));\n\n for (const updates of sortedUpdates) {\n totalChanges += updates.changes.length;\n totalRequiredChanges += updates.changes.filter((u) => requiredChangeTypes.includes(u.type)).length;\n updates.changes = updates.changes.sort((a, b) => a.change.localeCompare(b.change));\n }\n\n return {\n appPath: this._appPath,\n duration,\n totalPackages: Object.keys(this._packageResults).length,\n totalSuccess,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n failed: totalErrors > 0 || (!!options.check && totalRequiredChanges > 0),\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates: sortedUpdates,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InitSummaryData.js","sourceRoot":"","sources":["../../../src/commands/init/InitS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Y,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;YACvC,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;YACnG,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACrF,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,QAAQ;YACR,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM;YACvD,YAAY;YACZ,WAAW;YACX,aAAa;YACb,YAAY;YACZ,oBAAoB;YACpB,MAAM,EAAE,WAAW,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,oBAAoB,GAAG,CAAC,CAAC;YACxE,kBAAkB;YAClB,oBAAoB;YACpB,oBAAoB,EAAE,aAAa;SACpC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { InitSummary } from './types/InitSummary.js';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport type { InitPackageResultWarnings } from './types/InitPackageResultWarnings.js';\nimport type { InitPackageResultErrors } from './types/InitPackageResultErrors.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { BundleMessage } from '@ms-cloudpack/common-types';\nimport { requiredChangeTypes } from './types/GeneratedChange.js';\n\n/**\n * Creates a summary tracking helper for the `init` verb to use to record statistics about results and needed\n * changes. The `record*` methods of the returned object will be used within init to add the stats, and the\n * `get` method will return the final tally. The resulting `InitSummary` object can be used in the `formatInitSummary`\n * helper to convert it to a string for the user.\n *\n * The `getMissingExportsMessage` method can be used to check that the imports/exports of packages match.\n */\nexport class InitSummaryData {\n private _packageResults: Record<string, InitPackageResult>;\n private _generatedUpdates: Record<string, GeneratedPackageChanges>;\n private _startTime: number;\n private _appPath: string;\n\n constructor(appPath: string) {\n this._packageResults = {};\n this._generatedUpdates = {};\n this._startTime = Date.now();\n this._appPath = appPath;\n }\n\n /**\n * Saves a package result.\n */\n public recordResult(result: InitPackageResult): void {\n this._packageResults[result.path] = result;\n }\n\n /**\n * Record more errors for a given package path.\n */\n public addErrors(packagePath: string, errors: BundleMessage[]): void {\n const packageResult = this._packageResults[packagePath];\n if (!packageResult) {\n throw new Error(`Package result not found for path ${packagePath}`);\n }\n\n packageResult.errors = [...(packageResult.errors || []), ...errors];\n }\n\n /**\n * Returns the package results.\n * @returns The package results.\n */\n public getResults(): Record<string, InitPackageResult> {\n return this._packageResults;\n }\n\n /**\n * Saves a generated file update.\n * @param allChanges - The generated file update to save.\n * @returns void.\n */\n public recordGeneratedChanges(allChanges: GeneratedPackageChanges[]): void {\n for (const update of allChanges) {\n const { name, version, path, changes } = update;\n const updatesForPackage = (this._generatedUpdates[path] ??= { name, version, path, changes: [] });\n\n updatesForPackage.changes.push(...changes);\n }\n }\n\n /**\n * Returns the summary of the results.\n * @returns The summary of the results.\n */\n public summarize(options: Pick<InitOptions, 'check'>): InitSummary {\n const duration = Date.now() - this._startTime;\n let totalSuccess = 0;\n let totalErrors = 0;\n let totalWarnings = 0;\n let totalChanges = 0;\n let totalRequiredChanges = 0;\n const packagesWithErrors: InitPackageResultErrors[] = [];\n const packagesWithWarnings: InitPackageResultWarnings[] = [];\n\n for (const packageResult of Object.values(this._packageResults)) {\n if (packageResult.errors?.length) {\n packagesWithErrors.push(packageResult as InitPackageResultErrors);\n totalErrors += packageResult.errors.length;\n } else {\n totalSuccess++;\n }\n\n if (packageResult.warnings?.length) {\n packagesWithWarnings.push(packageResult as InitPackageResultWarnings);\n totalWarnings += packageResult.warnings.length;\n }\n }\n\n const sortedUpdates = Object.values(this._generatedUpdates).sort((a, b) => a.path.localeCompare(b.path));\n\n for (const updates of sortedUpdates) {\n totalChanges += updates.changes.length;\n totalRequiredChanges += updates.changes.filter((u) => requiredChangeTypes.includes(u.type)).length;\n updates.changes = updates.changes.sort((a, b) => a.change.localeCompare(b.change));\n }\n\n return {\n appPath: this._appPath,\n duration,\n totalPackages: Object.keys(this._packageResults).length,\n totalSuccess,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n failed: totalErrors > 0 || (!!options.check && totalRequiredChanges > 0),\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates: sortedUpdates,\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatInitSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAK1D,UAAU,uBAAuB;IAC/B,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"formatInitSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAK1D,UAAU,uBAAuB;IAC/B,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,CAUzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatInitSummary.js","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,EACN,SAAS,EACT,MAAM,EACN,GAAG,EACH,eAAe,EACf,MAAM,GACP,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAkD,MAAM,4BAA4B,CAAC;AAQjH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA+B;IAC/D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;IACrD,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACxC,OAAO,CACL,SAAS;SACN,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAC;SAChF,IAAI,CAAC,IAAI,CAAC;QACX,wCAAwC;SACvC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAC9B,CAAC;AACJ,CAAC;AAED,0CAA0C;AAC1C,SAAS,aAAa,CACpB,MAGC;IAED,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC/D,MAAM,aAAa,GAAa,EAAE,CAAC;IAEnC,MAAM,EACJ,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GACvB,GAAG,OAAO,CAAC;IACZ,MAAM,EAAE,KAAK,EAAE,GAAG,OAA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IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;AACtF,CAAC","sourcesContent":["import {\n bold,\n bulletedList,\n cyan,\n formatTime,\n green,\n indent,\n lightCyan,\n plural,\n red,\n statusCharacter,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitPackageIdentifier } from './types/InitPackageIdentifier.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitSummary } from './types/InitSummary.js';\nimport { formatLocation } from '@ms-cloudpack/path-utilities';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport { requiredChangeTypes, type GeneratedChange, type GeneratedChangeType } from './types/GeneratedChange.js';\n\ninterface FormatInitSummaryParams {\n summaries: InitSummary[];\n options: InitOptions;\n isInterrupted?: boolean;\n}\n\n/**\n * Given init summaries and init options, returns a formatted string message to display to the user via console.\n */\nexport function formatInitSummary(params: FormatInitSummaryParams) {\n const { summaries, options, isInterrupted } = params;\n const isMultiApp = summaries.length > 1;\n return (\n summaries\n .map((summary) => formatSummary({ summary, options, isInterrupted, isMultiApp }))\n .join('\\n')\n // replace >= 3 newlines with 2 newlines\n .replace(/\\n{3,}/g, '\\n\\n')\n );\n}\n\n/** Format a single app's init summary. */\nfunction formatSummary(\n params: Pick<FormatInitSummaryParams, 'options' | 'isInterrupted'> & {\n summary: InitSummary;\n isMultiApp: boolean;\n },\n): string {\n const { summary, options, isInterrupted, isMultiApp } = params;\n const summaryString: string[] = [];\n\n const {\n totalPackages,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates,\n deletedGeneratedConfig,\n } = summary;\n const { check } = options;\n const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;\n\n // Report the \"Summary\" title if no errors or warnings are listed (seems redundant otherwise.\n if ((!packagesWithErrors.length && !packagesWithWarnings.length) || isMultiApp) {\n summaryString.push(bold(`==== Summary for ${summary.appPath}${incompleteText} ====`));\n }\n\n // If there are required changes, updates will be \"made\" or \"needed\" with check,\n // else if the changes are not required, only report work done when updates are \"made\" (check is disabled).\n const updatesRequired = totalRequiredChanges || (totalChanges && !check);\n\n // Report updates that were or should be added to the generated config.\n if (!packagesWithErrors.length && updatesRequired) {\n summaryString.push(formatPackageUpdates({ generatedFileUpdates, check, isMultiApp }));\n }\n\n if (!isMultiApp) {\n // Report packages with warnings.\n if (packagesWithWarnings.length) {\n summaryString.push(formatPackageResults({ results: packagesWithWarnings, issueType: 'warn' }), '');\n }\n }\n\n // Report packages with errors.\n if (packagesWithErrors.length) {\n summaryString.push(formatPackageResults({ results: packagesWithErrors, issueType: 'error' }), '');\n }\n\n if (deletedGeneratedConfig) {\n summaryString.push(`Deleted the ${cyan('cloudpack.generated.json')} file because it is no longer needed.`, '');\n }\n\n const blockingIssueCount = packagesWithErrors.length || 0;\n const requiresChanges = (check && totalRequiredChanges) || 0;\n\n // Add summary.\n summaryString.push(\n `${cyan(plural(totalPackages, 'total package'))} evaluated in ${formatTime(summary.duration)}${incompleteText}:`,\n bulletedList(\n [\n requiresChanges ? `${red(plural(totalRequiredChanges, 'change'))} required` : undefined,\n `${green(plural(totalPackages - blockingIssueCount, 'package'))} built successfully${\n packagesWithWarnings.length\n ? ` (${yellow(plural(packagesWithWarnings.length, 'package'))} with warnings)`\n : ''\n }`,\n blockingIssueCount ? `${red(plural(blockingIssueCount, 'package'))} failed to build` : undefined,\n `Totals: ${totalErrors ? red(plural(totalErrors, 'error')) : '0 errors'}, ${totalWarnings ? yellow(plural(totalWarnings, 'warning')) : '0 warnings'}`,\n ].filter(Boolean),\n ),\n );\n\n if (isInterrupted) {\n summaryString.push('', yellow(bold('Process was interrupted before all tasks could complete.')));\n } else if (requiresChanges) {\n summaryString.push(\n `Run \"${yellow('cloudpack init')}\" in your application folder to apply changes to the ${cyan(\n 'cloudpack.generated.json',\n )} file.`,\n );\n }\n\n summaryString.push('\\n');\n\n return summaryString.join('\\n');\n}\n\nfunction formatPackageUpdates(\n params: Pick<InitSummary, 'generatedFileUpdates'> &\n Pick<InitOptions, 'check'> &\n Pick<FormatInitSummaryParams, 'isInterrupted'> & { isMultiApp: boolean },\n) {\n const { generatedFileUpdates, check, isInterrupted, isMultiApp } = params;\n // If we already made the updates, don't make them look like warnings.\n const type = check ? 'warn' : 'add';\n\n const summaryString: string[] = [];\n\n for (const packageUpdates of generatedFileUpdates) {\n const exportsUpdates = getChangesToShow({ type: 'added-export', packageUpdates, isMultiApp });\n\n if (exportsUpdates.length) {\n const description = plural(exportsUpdates.length, `path$s ${check ? 'missing from' : 'added to'} exports map`);\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(exportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const includedDependencies = getChangesToShow({ type: 'included-dependency-required', packageUpdates, isMultiApp });\n\n if (includedDependencies.length) {\n const description = plural(includedDependencies.length, 'dependency$s required to be included');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(includedDependencies.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const changedExports = getChangesToShow({ type: 'changed-export', packageUpdates, isMultiApp });\n\n if (changedExports.length) {\n const description = plural(changedExports.length, 'previously unused export path$s are now used');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(changedExports.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const dynamicImportsUpdates = getChangesToShow({ type: 'added-dynamic-import', packageUpdates, isMultiApp });\n\n if (dynamicImportsUpdates.length) {\n const description = plural(dynamicImportsUpdates.length, 'dynamic import$s added');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(dynamicImportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ``}`)),\n '',\n );\n }\n }\n\n if (summaryString.length) {\n summaryString.unshift(\n bold(`Updates ${check || isInterrupted ? 'needed for' : 'made to'} ${cyan(`cloudpack.generated.json`)}:\\n`),\n );\n }\n return summaryString.join('\\n');\n}\n\nfunction getChangesToShow(params: {\n packageUpdates: GeneratedPackageChanges;\n type: GeneratedChangeType;\n isMultiApp: boolean;\n}): GeneratedChange[] {\n const { packageUpdates, type, isMultiApp } = params;\n if (isMultiApp && !requiredChangeTypes.includes(type)) {\n return [];\n }\n return packageUpdates.changes.filter((u) => u.type === type);\n}\n\n/** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */\nfunction formatPackageResults(params: { results: InitPackageResult[]; issueType: 'error' | 'warn' }) {\n const { results, issueType } = params;\n if (!results.length) {\n return '';\n }\n\n const color = colorsByType[issueType];\n const messageType = issueType === 'error' ? 'errors' : 'warnings';\n const statusChar = bold(color(statusCharacter[issueType]));\n\n const summaryString = [bold(color(`${plural(results.length, 'package')} with ${messageType}:`)), ''];\n\n for (const result of results) {\n const unformattedMessages = result[messageType];\n if (!unformattedMessages?.length) {\n continue;\n }\n\n const description = plural(unformattedMessages.length, messageType.slice(0, -1) + '$s');\n summaryString.push(formatPackageHeader({ ...result, issueType, description }));\n\n const messages = unformattedMessages.map(({ location, text, source }) => {\n // Show the whole path so it can be easily opened with ctrl+click.\n // NOTE: location.file should be relative to the package path, not the app path.\n const filePath = location ? ` ${formatLocation({ ...location, fromPath: result.path })}` : '';\n // Indent the message for readability.\n return `[${source}]${filePath}\\n${color(indent(text, 1))}`;\n });\n\n summaryString.push(bulletedList(messages, undefined, statusChar), '');\n }\n\n return summaryString.join('\\n');\n}\n\nconst colorsByType = {\n error: red,\n warn: yellow,\n add: (str: string) => str,\n};\nconst statusByType = {\n error: statusCharacter.error,\n warn: statusCharacter.warn,\n add: '+',\n};\n\n/**\n * Helper to format the header for a list of issues in a package:\n * status character, `name@version`, issue description, package path.\n */\nfunction formatPackageHeader(\n params: InitPackageIdentifier & {\n description: string;\n issueType: 'error' | 'warn' | 'add';\n },\n) {\n const { name, version, path: packagePath, description, issueType } = params;\n const color = colorsByType[issueType];\n const statusChar = bold(color(statusByType[issueType]));\n const packageName = bold(lightCyan(`${name}@${version || `<unknown>`}`));\n\n return `${packageName} - ${packagePath}\\n${statusChar} ${bold(color(description))}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"formatInitSummary.js","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,EACN,SAAS,EACT,MAAM,EACN,GAAG,EACH,eAAe,EACf,MAAM,GACP,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAkD,MAAM,4BAA4B,CAAC;AAQjH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA+B;IAC/D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;IACrD,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACxC,OAAO,CACL,SAAS;SACN,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAC;SAChF,IAAI,CAAC,IAAI,CAAC;QACX,wCAAwC;SACvC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAC9B,CAAC;AACJ,CAAC;AAED,0CAA0C;AAC1C,SAAS,aAAa,CACpB,MAGC;IAED,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC/D,MAAM,aAAa,GAAa,EAAE,CAAC;IAEnC,MAAM,EACJ,aAAa,EACb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,CAAC;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC;IAEzE,OAAO,GAAG,WAAW,MAAM,WAAW,KAAK,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;AACtF,CAAC","sourcesContent":["import {\n bold,\n bulletedList,\n cyan,\n formatTime,\n green,\n indent,\n lightCyan,\n plural,\n red,\n statusCharacter,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitPackageIdentifier } from './types/InitPackageIdentifier.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitSummary } from './types/InitSummary.js';\nimport { formatLocation } from '@ms-cloudpack/path-utilities';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport { requiredChangeTypes, type GeneratedChange, type GeneratedChangeType } from './types/GeneratedChange.js';\n\ninterface FormatInitSummaryParams {\n summaries: InitSummary[];\n options: InitOptions;\n isInterrupted?: boolean;\n}\n\n/**\n * Given init summaries and init options, returns a formatted string message to display to the user via console.\n */\nexport function formatInitSummary(params: FormatInitSummaryParams): string {\n const { summaries, options, isInterrupted } = params;\n const isMultiApp = summaries.length > 1;\n return (\n summaries\n .map((summary) => formatSummary({ summary, options, isInterrupted, isMultiApp }))\n .join('\\n')\n // replace >= 3 newlines with 2 newlines\n .replace(/\\n{3,}/g, '\\n\\n')\n );\n}\n\n/** Format a single app's init summary. */\nfunction formatSummary(\n params: Pick<FormatInitSummaryParams, 'options' | 'isInterrupted'> & {\n summary: InitSummary;\n isMultiApp: boolean;\n },\n): string {\n const { summary, options, isInterrupted, isMultiApp } = params;\n const summaryString: string[] = [];\n\n const {\n totalPackages,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates,\n deletedGeneratedConfig,\n } = summary;\n const { check } = options;\n const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;\n\n // Report the \"Summary\" title if no errors or warnings are listed (seems redundant otherwise.\n if ((!packagesWithErrors.length && !packagesWithWarnings.length) || isMultiApp) {\n summaryString.push(bold(`==== Summary for ${summary.appPath}${incompleteText} ====`));\n }\n\n // If there are required changes, updates will be \"made\" or \"needed\" with check,\n // else if the changes are not required, only report work done when updates are \"made\" (check is disabled).\n const updatesRequired = totalRequiredChanges || (totalChanges && !check);\n\n // Report updates that were or should be added to the generated config.\n if (!packagesWithErrors.length && updatesRequired) {\n summaryString.push(formatPackageUpdates({ generatedFileUpdates, check, isMultiApp }));\n }\n\n if (!isMultiApp) {\n // Report packages with warnings.\n if (packagesWithWarnings.length) {\n summaryString.push(formatPackageResults({ results: packagesWithWarnings, issueType: 'warn' }), '');\n }\n }\n\n // Report packages with errors.\n if (packagesWithErrors.length) {\n summaryString.push(formatPackageResults({ results: packagesWithErrors, issueType: 'error' }), '');\n }\n\n if (deletedGeneratedConfig) {\n summaryString.push(`Deleted the ${cyan('cloudpack.generated.json')} file because it is no longer needed.`, '');\n }\n\n const blockingIssueCount = packagesWithErrors.length || 0;\n const requiresChanges = (check && totalRequiredChanges) || 0;\n\n // Add summary.\n summaryString.push(\n `${cyan(plural(totalPackages, 'total package'))} evaluated in ${formatTime(summary.duration)}${incompleteText}:`,\n bulletedList(\n [\n requiresChanges ? `${red(plural(totalRequiredChanges, 'change'))} required` : undefined,\n `${green(plural(totalPackages - blockingIssueCount, 'package'))} built successfully${\n packagesWithWarnings.length\n ? ` (${yellow(plural(packagesWithWarnings.length, 'package'))} with warnings)`\n : ''\n }`,\n blockingIssueCount ? `${red(plural(blockingIssueCount, 'package'))} failed to build` : undefined,\n `Totals: ${totalErrors ? red(plural(totalErrors, 'error')) : '0 errors'}, ${totalWarnings ? yellow(plural(totalWarnings, 'warning')) : '0 warnings'}`,\n ].filter(Boolean),\n ),\n );\n\n if (isInterrupted) {\n summaryString.push('', yellow(bold('Process was interrupted before all tasks could complete.')));\n } else if (requiresChanges) {\n summaryString.push(\n `Run \"${yellow('cloudpack init')}\" in your application folder to apply changes to the ${cyan(\n 'cloudpack.generated.json',\n )} file.`,\n );\n }\n\n summaryString.push('\\n');\n\n return summaryString.join('\\n');\n}\n\nfunction formatPackageUpdates(\n params: Pick<InitSummary, 'generatedFileUpdates'> &\n Pick<InitOptions, 'check'> &\n Pick<FormatInitSummaryParams, 'isInterrupted'> & { isMultiApp: boolean },\n): string {\n const { generatedFileUpdates, check, isInterrupted, isMultiApp } = params;\n // If we already made the updates, don't make them look like warnings.\n const type = check ? 'warn' : 'add';\n\n const summaryString: string[] = [];\n\n for (const packageUpdates of generatedFileUpdates) {\n const exportsUpdates = getChangesToShow({ type: 'added-export', packageUpdates, isMultiApp });\n\n if (exportsUpdates.length) {\n const description = plural(exportsUpdates.length, `path$s ${check ? 'missing from' : 'added to'} exports map`);\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(exportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const includedDependencies = getChangesToShow({ type: 'included-dependency-required', packageUpdates, isMultiApp });\n\n if (includedDependencies.length) {\n const description = plural(includedDependencies.length, 'dependency$s required to be included');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(includedDependencies.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const changedExports = getChangesToShow({ type: 'changed-export', packageUpdates, isMultiApp });\n\n if (changedExports.length) {\n const description = plural(changedExports.length, 'previously unused export path$s are now used');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(changedExports.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const dynamicImportsUpdates = getChangesToShow({ type: 'added-dynamic-import', packageUpdates, isMultiApp });\n\n if (dynamicImportsUpdates.length) {\n const description = plural(dynamicImportsUpdates.length, 'dynamic import$s added');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(dynamicImportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ``}`)),\n '',\n );\n }\n }\n\n if (summaryString.length) {\n summaryString.unshift(\n bold(`Updates ${check || isInterrupted ? 'needed for' : 'made to'} ${cyan(`cloudpack.generated.json`)}:\\n`),\n );\n }\n return summaryString.join('\\n');\n}\n\nfunction getChangesToShow(params: {\n packageUpdates: GeneratedPackageChanges;\n type: GeneratedChangeType;\n isMultiApp: boolean;\n}): GeneratedChange[] {\n const { packageUpdates, type, isMultiApp } = params;\n if (isMultiApp && !requiredChangeTypes.includes(type)) {\n return [];\n }\n return packageUpdates.changes.filter((u) => u.type === type);\n}\n\n/** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */\nfunction formatPackageResults(params: { results: InitPackageResult[]; issueType: 'error' | 'warn' }): string {\n const { results, issueType } = params;\n if (!results.length) {\n return '';\n }\n\n const color = colorsByType[issueType];\n const messageType = issueType === 'error' ? 'errors' : 'warnings';\n const statusChar = bold(color(statusCharacter[issueType]));\n\n const summaryString = [bold(color(`${plural(results.length, 'package')} with ${messageType}:`)), ''];\n\n for (const result of results) {\n const unformattedMessages = result[messageType];\n if (!unformattedMessages?.length) {\n continue;\n }\n\n const description = plural(unformattedMessages.length, messageType.slice(0, -1) + '$s');\n summaryString.push(formatPackageHeader({ ...result, issueType, description }));\n\n const messages = unformattedMessages.map(({ location, text, source }) => {\n // Show the whole path so it can be easily opened with ctrl+click.\n // NOTE: location.file should be relative to the package path, not the app path.\n const filePath = location ? ` ${formatLocation({ ...location, fromPath: result.path })}` : '';\n // Indent the message for readability.\n return `[${source}]${filePath}\\n${color(indent(text, 1))}`;\n });\n\n summaryString.push(bulletedList(messages, undefined, statusChar), '');\n }\n\n return summaryString.join('\\n');\n}\n\nconst colorsByType = {\n error: red,\n warn: yellow,\n add: (str: string) => str,\n};\nconst statusByType = {\n error: statusCharacter.error,\n warn: statusCharacter.warn,\n add: '+',\n};\n\n/**\n * Helper to format the header for a list of issues in a package:\n * status character, `name@version`, issue description, package path.\n */\nfunction formatPackageHeader(\n params: InitPackageIdentifier & {\n description: string;\n issueType: 'error' | 'warn' | 'add';\n },\n): string {\n const { name, version, path: packagePath, description, issueType } = params;\n const color = colorsByType[issueType];\n const statusChar = bold(color(statusByType[issueType]));\n const packageName = bold(lightCyan(`${name}@${version || `<unknown>`}`));\n\n return `${packageName} - ${packagePath}\\n${statusChar} ${bold(color(description))}`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAMpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,UAS1B;IACC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC;IAEpE,MAAM,SAAS,GAA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,SAAS,EAAE,OAAO,CAAC,CAAC;YAC9E,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;gBAClC,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;YACxC,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { type Context, TaskRunner } from '@ms-cloudpack/api-server';\nimport type { PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { AutoDispose } from '../../types/AutoDispose.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitSummary } from './types/InitSummary.js';\n\nimport { createPartialApiContext } from '@ms-cloudpack/api-server';\nimport { writeGeneratedConfig } from '@ms-cloudpack/config';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport { evaluatePath } from './evaluatePath.js';\nimport { verifyExports } from './verifyExports.js';\nimport type { AppCommandContext } from '../../types/CommandAction.js';\nimport path from 'path';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\nimport { optimizeDependencies } from './optimizeDependencies.js';\nimport { bulletedList } from '@ms-cloudpack/task-reporter';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n contexts: AppCommandContext[];\n autoDispose: AutoDispose;\n /**\n * App summary objects, created ahead of time so that a partial summary can be generated\n * if the process is interrupted.\n */\n appSummaries: Record<string, InitSummaryData>;\n}): Promise<InitSummary[]> {\n const { options, contexts, autoDispose, appSummaries } = parameters;\n\n const summaries: InitSummary[] = [];\n\n const taskRunner = new TaskRunner();\n\n for (const appContext of contexts) {\n const summary = await initApp({\n appContext,\n options,\n autoDispose,\n summaryData: appSummaries[appContext.appPath],\n taskRunner,\n isMultiApp: contexts.length > 1,\n });\n summaries.push(summary);\n }\n\n return summaries;\n}\n\nasync function initApp(params: {\n appContext: AppCommandContext;\n options: InitOptions;\n autoDispose: AutoDispose;\n summaryData: InitSummaryData;\n taskRunner: TaskRunner;\n isMultiApp: boolean;\n}): Promise<InitSummary> {\n const { appContext, options, autoDispose, summaryData, taskRunner, isMultiApp } = params;\n const { appPath, config, telemetryClient } = appContext;\n return telemetryClient.tracer.startActiveSpan('INIT_APP', async (span) => {\n // Run prerequisites for the app.\n await runPrerequisites(appContext);\n\n // If --reset is specified, reset the generated config.\n if (options.reset) {\n config.generated = {};\n }\n\n const apiContext: Context = await createPartialApiContext({\n ...appContext,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n taskRunner,\n });\n autoDispose(apiContext);\n const resolveMap = apiContext.session.resolveMap;\n\n // Ensure config.generated.packageSettings is initialized.\n config.generated.packageSettings ??= [];\n\n let isExitingPrematurely = false;\n\n await new Promise<void>((resolve) => {\n let pending = 0;\n const visitedSet = new Set<string>();\n const refreshPaths = new Set<string>();\n const priorityMap = new Map<string, number>();\n\n // Start with the app path or requested matches\n const initialPaths = options.match ? getFilteredPackages(resolveMap, options.match) : [appPath];\n if (!initialPaths.length) {\n summaryData.addErrors(appPath, [{ text: `No packages found matching ${options.match}`, source: 'init' }]);\n resolve();\n }\n\n enqueuePaths(new Map(initialPaths.map((packagePath) => [packagePath, undefined])));\n\n /**\n * Enqueue more paths.\n * @param newPaths Mapping from package path to importer context.\n */\n function enqueuePaths(newPaths: Map<string, PackageImporterContext | undefined>) {\n if (isExitingPrematurely) {\n return;\n }\n\n // Iterate through the given paths.\n for (const [packagePath, importerContext] of newPaths) {\n if (visitedSet.has(packagePath)) {\n console.debug(`Skipping ${packagePath} as it has already been visited.`);\n continue;\n }\n\n visitedSet.add(packagePath);\n pending++;\n\n const shouldForce = refreshPaths.delete(packagePath);\n\n // Get the priority value for this package path, defaults to 0.\n const priority = priorityMap.get(packagePath) ?? 0;\n // Lower priority of this package path by 1.\n priorityMap.set(packagePath, priority - 1);\n\n // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.\n evaluatePath({\n appPath,\n packagePath,\n importerContext,\n config,\n span,\n resolveMap,\n initOptions: options,\n summaryData,\n ctx: apiContext,\n // No need to force if we're in a multi-app scenario\n // as we'll re-evaluate packages if they are different since we use a different task id.\n shouldForce: !isMultiApp && shouldForce,\n isMultiApp,\n priority,\n })\n .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {\n pending--;\n\n if (shouldExit) {\n isExitingPrematurely = true;\n } else if (pathsToEvaluate?.size) {\n // If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them\n // and add them to the refresh set so that on re-enqueuing we pass the `shouldRerun` flag through\n // on single app runs.\n pathsToRefresh?.forEach((refreshPath) => {\n refreshPaths.add(refreshPath);\n visitedSet.delete(refreshPath);\n });\n\n // Try to enqueue the new paths.\n console.debug(\n `Enqueuing paths found from ${packagePath}:\\n` +\n bulletedList(\n [...pathsToEvaluate].map(([newPath, newContext]) => `${newPath} ${JSON.stringify(newContext)}`),\n ),\n );\n enqueuePaths(pathsToEvaluate);\n }\n\n // If nothing is pending after this call, we're complete.\n if (!pending) {\n resolve();\n }\n })\n .catch((error) => {\n // Record the exception as an init error for the package.\n // This gives better context than a stack trace which could have come from any package.\n let prefix = `Error thrown while evaluating package`;\n if (importerContext) {\n prefix += ` (context: ${JSON.stringify(importerContext, null, 2).replace(/\\s+/g, ' ')})`;\n }\n\n summaryData.addErrors(packagePath, [\n {\n text: `${prefix}:\\n${error instanceof Error ? error.stack : error}`,\n source: 'init',\n },\n ]);\n\n // Don't immediately stop evaluation, but don't enqueue more paths.\n isExitingPrematurely = true;\n });\n }\n }\n }).catch((error) => {\n // If there's an error thrown from some other part of the promise besides evaluatePath (not likely),\n // record it as an init error for the app instead of allowing it to propagate.\n // This allows the overall init summary and any other errors to be logged as usual.\n isExitingPrematurely = true;\n summaryData.addErrors(appPath, [\n {\n text: `Error thrown during init: ${error instanceof Error ? error.stack : error}`,\n source: 'init',\n },\n ]);\n });\n\n // Log the resolve map to a file if requested. Do this *after* the main init process in case\n // any additional deps were discovered and added.\n if (options.logResolveMap) {\n console.log('\\nWriting resolve map to `resolve-map.json`.');\n await writeJson(path.join(appPath, 'resolve-map.json'), resolveMap);\n }\n\n // Only do extra checks if there's not a major error already\n if (!isExitingPrematurely) {\n if (config.features?.optimizeDependencies) {\n // Conditionally scan dependency usage so that we can populate\n // include/excludeDependencies automatically, ensuring the dep list\n // is both minimal (remove unused deps) and complete (include\n // specific devDeps.)\n const excludedDependenciesChanges = await optimizeDependencies(summaryData.getResults(), apiContext);\n summaryData.recordGeneratedChanges(excludedDependenciesChanges);\n }\n\n if (config.features?.verifyExports) {\n const packageResults = await verifyExports(summaryData.getResults(), apiContext);\n for (const [packagePath, errors] of Object.entries(packageResults)) {\n summaryData.addErrors(packagePath, errors);\n }\n }\n }\n\n const summary = summaryData.summarize(options);\n\n // The feature \"removeUnusedExports\" doesn't (yet) write summary changes, but we still\n // want to write the generated config if that featureFlag is on.\n const hasSummaryChanges = config.features?.removeUnusedExports || summary.totalChanges;\n\n if (!options.check && hasSummaryChanges) {\n // Update the generated config: either write it if there are settings, or delete it if it\n // previously existed but is no longer needed.\n const generatedResult = await writeGeneratedConfig(config.generated, appPath);\n if (generatedResult === 'deleted') {\n summary.deletedGeneratedConfig = true;\n }\n }\n\n return summary;\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAMpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;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AC,CAAC;gBAC7C,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAE/C,sFAAsF;QACtF,gEAAgE;QAChE,MAAM,iBAAiB,GAAG,MAAM,CAAC,QAAQ,EAAE,mBAAmB,IAAI,OAAO,CAAC,YAAY,CAAC;QAEvF,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,iBAAiB,EAAE,CAAC;YACxC,yFAAyF;YACzF,8CAA8C;YAC9C,MAAM,eAAe,GAAG,MAAM,oBAAoB,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC9E,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;gBAClC,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;YACxC,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { type Context, TaskRunner } from '@ms-cloudpack/api-server';\nimport type { PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { AutoDispose } from '../../types/AutoDispose.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitSummary } from './types/InitSummary.js';\n\nimport { createPartialApiContext } from '@ms-cloudpack/api-server';\nimport { writeGeneratedConfig } from '@ms-cloudpack/config';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport { evaluatePath } from './evaluatePath.js';\nimport { verifyExports } from './verifyExports.js';\nimport type { AppCommandContext } from '../../types/CommandAction.js';\nimport path from 'path';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\nimport { optimizeDependencies } from './optimizeDependencies.js';\nimport { bulletedList } from '@ms-cloudpack/task-reporter';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n contexts: AppCommandContext[];\n autoDispose: AutoDispose;\n /**\n * App summary objects, created ahead of time so that a partial summary can be generated\n * if the process is interrupted.\n */\n appSummaries: Record<string, InitSummaryData>;\n}): Promise<InitSummary[]> {\n const { options, contexts, autoDispose, appSummaries } = parameters;\n\n const summaries: InitSummary[] = [];\n\n const taskRunner = new TaskRunner();\n\n for (const appContext of contexts) {\n const summary = await initApp({\n appContext,\n options,\n autoDispose,\n summaryData: appSummaries[appContext.appPath],\n taskRunner,\n isMultiApp: contexts.length > 1,\n });\n summaries.push(summary);\n }\n\n return summaries;\n}\n\nasync function initApp(params: {\n appContext: AppCommandContext;\n options: InitOptions;\n autoDispose: AutoDispose;\n summaryData: InitSummaryData;\n taskRunner: TaskRunner;\n isMultiApp: boolean;\n}): Promise<InitSummary> {\n const { appContext, options, autoDispose, summaryData, taskRunner, isMultiApp } = params;\n const { appPath, config, telemetryClient } = appContext;\n return telemetryClient.tracer.startActiveSpan('INIT_APP', async (span) => {\n // Run prerequisites for the app.\n await runPrerequisites(appContext);\n\n // If --reset is specified, reset the generated config.\n if (options.reset) {\n config.generated = {};\n }\n\n const apiContext: Context = await createPartialApiContext({\n ...appContext,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n taskRunner,\n });\n autoDispose(apiContext);\n const resolveMap = apiContext.session.resolveMap;\n\n // Ensure config.generated.packageSettings is initialized.\n config.generated.packageSettings ??= [];\n\n let isExitingPrematurely = false;\n\n await new Promise<void>((resolve) => {\n let pending = 0;\n const visitedSet = new Set<string>();\n const refreshPaths = new Set<string>();\n const priorityMap = new Map<string, number>();\n\n // Start with the app path or requested matches\n const initialPaths = options.match ? getFilteredPackages(resolveMap, options.match) : [appPath];\n if (!initialPaths.length) {\n summaryData.addErrors(appPath, [{ text: `No packages found matching ${options.match}`, source: 'init' }]);\n resolve();\n }\n\n enqueuePaths(new Map(initialPaths.map((packagePath) => [packagePath, undefined])));\n\n /**\n * Enqueue more paths.\n * @param newPaths Mapping from package path to importer context.\n */\n function enqueuePaths(newPaths: Map<string, PackageImporterContext | undefined>): void {\n if (isExitingPrematurely) {\n return;\n }\n\n // Iterate through the given paths.\n for (const [packagePath, importerContext] of newPaths) {\n if (visitedSet.has(packagePath)) {\n console.debug(`Skipping ${packagePath} as it has already been visited.`);\n continue;\n }\n\n visitedSet.add(packagePath);\n pending++;\n\n const shouldForce = refreshPaths.delete(packagePath);\n\n // Get the priority value for this package path, defaults to 0.\n const priority = priorityMap.get(packagePath) ?? 0;\n // Lower priority of this package path by 1.\n priorityMap.set(packagePath, priority - 1);\n\n // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.\n evaluatePath({\n appPath,\n packagePath,\n importerContext,\n config,\n span,\n resolveMap,\n initOptions: options,\n summaryData,\n ctx: apiContext,\n // No need to force if we're in a multi-app scenario\n // as we'll re-evaluate packages if they are different since we use a different task id.\n shouldForce: !isMultiApp && shouldForce,\n isMultiApp,\n priority,\n })\n .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {\n pending--;\n\n if (shouldExit) {\n isExitingPrematurely = true;\n } else if (pathsToEvaluate?.size) {\n // If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them\n // and add them to the refresh set so that on re-enqueuing we pass the `shouldRerun` flag through\n // on single app runs.\n pathsToRefresh?.forEach((refreshPath) => {\n refreshPaths.add(refreshPath);\n visitedSet.delete(refreshPath);\n });\n\n // Try to enqueue the new paths.\n console.debug(\n `Enqueuing paths found from ${packagePath}:\\n` +\n bulletedList(\n [...pathsToEvaluate].map(([newPath, newContext]) => `${newPath} ${JSON.stringify(newContext)}`),\n ),\n );\n enqueuePaths(pathsToEvaluate);\n }\n\n // If nothing is pending after this call, we're complete.\n if (!pending) {\n resolve();\n }\n })\n .catch((error) => {\n // Record the exception as an init error for the package.\n // This gives better context than a stack trace which could have come from any package.\n let prefix = `Error thrown while evaluating package`;\n if (importerContext) {\n prefix += ` (context: ${JSON.stringify(importerContext, null, 2).replace(/\\s+/g, ' ')})`;\n }\n\n summaryData.addErrors(packagePath, [\n {\n text: `${prefix}:\\n${error instanceof Error ? error.stack : error}`,\n source: 'init',\n },\n ]);\n\n // Don't immediately stop evaluation, but don't enqueue more paths.\n isExitingPrematurely = true;\n });\n }\n }\n }).catch((error) => {\n // If there's an error thrown from some other part of the promise besides evaluatePath (not likely),\n // record it as an init error for the app instead of allowing it to propagate.\n // This allows the overall init summary and any other errors to be logged as usual.\n isExitingPrematurely = true;\n summaryData.addErrors(appPath, [\n {\n text: `Error thrown during init: ${error instanceof Error ? error.stack : error}`,\n source: 'init',\n },\n ]);\n });\n\n // Log the resolve map to a file if requested. Do this *after* the main init process in case\n // any additional deps were discovered and added.\n if (options.logResolveMap) {\n console.log('\\nWriting resolve map to `resolve-map.json`.');\n await writeJson(path.join(appPath, 'resolve-map.json'), resolveMap);\n }\n\n // Only do extra checks if there's not a major error already\n if (!isExitingPrematurely) {\n if (config.features?.optimizeDependencies) {\n // Conditionally scan dependency usage so that we can populate\n // include/excludeDependencies automatically, ensuring the dep list\n // is both minimal (remove unused deps) and complete (include\n // specific devDeps.)\n const excludedDependenciesChanges = await optimizeDependencies(summaryData.getResults(), apiContext);\n summaryData.recordGeneratedChanges(excludedDependenciesChanges);\n }\n\n if (config.features?.verifyExports) {\n const packageResults = await verifyExports(summaryData.getResults(), apiContext);\n for (const [packagePath, errors] of Object.entries(packageResults)) {\n summaryData.addErrors(packagePath, errors);\n }\n }\n }\n\n const summary = summaryData.summarize(options);\n\n // The feature \"removeUnusedExports\" doesn't (yet) write summary changes, but we still\n // want to write the generated config if that featureFlag is on.\n const hasSummaryChanges = config.features?.removeUnusedExports || summary.totalChanges;\n\n if (!options.check && hasSummaryChanges) {\n // Update the generated config: either write it if there are settings, or delete it if it\n // previously existed but is no longer needed.\n const generatedResult = await writeGeneratedConfig(config.generated, appPath);\n if (generatedResult === 'deleted') {\n summary.deletedGeneratedConfig = true;\n }\n }\n\n return summary;\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatLinkSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/link/formatLinkSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,4BAA4B,CAAC;AAS1F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;CAC1C,
|
|
1
|
+
{"version":3,"file":"formatLinkSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/link/formatLinkSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,4BAA4B,CAAC;AAS1F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;CAC1C,GAAG,MAAM,CA4BT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatLinkSummary.js","sourceRoot":"","sources":["../../../src/commands/link/formatLinkSummary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"formatLinkSummary.js","sourceRoot":"","sources":["../../../src/commands/link/formatLinkSummary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAmB,MAAM,6BAA6B,CAAC;AAClF,OAAO,EACL,eAAe,EACf,mBAAmB,GAGpB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,UAAU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AI,CAAC,EAAE,CAAC;gBACzB,yFAAyF;gBACzF,oEAAoE;gBACpE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SACpC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC;SAChC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC;SACnB,IAAI,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport type { LinkedPath, ResolveMap, ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport { bulletedList, cyan, type BulletList } from '@ms-cloudpack/task-reporter';\nimport {\n diffResolveMaps,\n findResolveMapEntry,\n type DiffResolveMapsChanges,\n type DiffResolveMapsStats,\n} from '@ms-cloudpack/package-utilities';\n\nexport function formatLinkSummary(options: {\n session: Session;\n resolveMap: ResolveMap;\n linkedPaths: LinkedPath[];\n resolveStrategy?: 'dedupe' | 'duplicate';\n}): string {\n const { session, linkedPaths, resolveMap, resolveStrategy } = options;\n const differences = diffResolveMaps({ before: session.resolveMap, after: resolveMap });\n\n const linkedPathsMessage = linkedPaths.length\n ? [\n 'Linked paths:',\n bulletedList(\n linkedPaths\n .map((p) => p.path)\n .sort()\n .map((p) => cyan(p)),\n ),\n ]\n : ['No paths linked.'];\n\n const messages = [\n `Finished linking session: \"${session.projectName}\" (${session.id})`,\n '',\n ...linkedPathsMessage,\n '',\n `Resolve map differences:`,\n bulletedList(formatDiff(differences)),\n ...duplicatedMessages({ session, differences, resolveStrategy }),\n '',\n ];\n\n return messages.join('\\n');\n}\n\nfunction formatDiff(diff: DiffResolveMapsStats): BulletList {\n const messages = [];\n const added = formatDiffChanges(diff.added);\n const removed = formatDiffChanges(diff.removed);\n\n if (!added.length && !removed.length) {\n messages.push('No differences found');\n }\n\n if (added.length) {\n messages.push('Added:', added);\n }\n\n if (removed.length) {\n messages.push('Removed:', removed);\n }\n\n return messages;\n}\n\nfunction formatDiffChanges(changes: DiffResolveMapsChanges): BulletList {\n const messages = [];\n if (changes.linked.length) {\n messages.push('Linked:', changes.linked.map(formatEntry).sort());\n }\n\n if (changes.internal.length) {\n messages.push('Internal:', changes.internal.map(formatEntry).sort());\n }\n\n if (changes.external.length) {\n messages.push('External:', changes.external.map(formatEntry).sort());\n }\n\n return messages;\n}\n\nfunction formatEntry(entry: ResolveMapEntry): string {\n return `${entry.name}@${entry.version} (${entry.path})`;\n}\n\nfunction duplicatedMessages(options: {\n session: Session;\n differences: DiffResolveMapsStats;\n resolveStrategy?: 'dedupe' | 'duplicate';\n}): string[] {\n const { session, differences, resolveStrategy } = options;\n const duplicated = findDuplicates({ session, differences });\n\n return duplicated.length\n ? [\n '',\n `Warning:`,\n 'The following packages were duplicated by linking:',\n duplicated.join(', '),\n '',\n 'This could lead to unexpected behavior. Please review the linked paths and resolve map to ensure correctness.',\n ...(resolveStrategy == 'duplicate'\n ? ['Consider running link with `cloudpack link --resolve-strategy dedupe` to resolve these duplicates.']\n : []),\n ]\n : [];\n}\n\n/**\n * Find entries that were duplicated by linking.\n * This means that the package already existed in the resolve map,\n * and now there are more versions of the package than there were before.\n */\nfunction findDuplicates(options: { session: Session; differences: DiffResolveMapsStats }): string[] {\n const { session, differences } = options;\n const duplicated = new Map<string, number>();\n\n for (const packageType of Object.values(differences.added)) {\n for (const change of packageType as ResolveMapEntry[]) {\n const { name } = change;\n const entry = findResolveMapEntry({ packageName: name, resolveMap: session.resolveMap });\n if (entry) {\n duplicated.set(name, (duplicated.get(name) || 0) + 1);\n }\n }\n }\n\n for (const packageType of Object.values(differences.removed)) {\n for (const change of packageType as ResolveMapEntry[]) {\n const { name } = change;\n if (duplicated.has(name)) {\n // We already checked for existence in the resolve map, so we know this will be a number.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n duplicated.set(name, duplicated.get(name)! - 1);\n }\n }\n }\n\n return Array.from(duplicated.entries())\n .filter(([, value]) => value > 0)\n .map(([key]) => key)\n .sort();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,gCAAgC;AAChC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAe;QAClC,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,0DAA0D;QACvE,OAAO,EAAE;YACP,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;YAC3C,GAAG,EAAE,IAAI,MAAM,CACb,wBAAwB,EACxB,qGAAqG,CACtG;YACD,IAAI,EAAE,IAAI,MAAM,CAAC,WAAW,EAAE,0BAA0B,CAAC;YACzD,KAAK,EAAE,aAAa,CAAC,OAAO,EAAE;YAC9B,aAAa,EAAE,aAAa,CAAC,aAAa,EAAE;YAC5C,aAAa,EAAE,aAAa,CAAC,0BAA0B,EAAE,KAAK,CAAC;YAC/D,aAAa,EAAE,aAAa,CAAC,0BAA0B,EAAE,KAAK,CAAC;YAC/D,gBAAgB,EAAE,aAAa,CAAC,6BAA6B,EAAE,QAAQ,CAAC;SACzE;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa,EAAE,IAAY;IAChD,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE,uBAAuB,IAAI,wDAAwD,CAAC;SAC1G,SAAS,CAAC,UAAU,CAAC;SACrB,QAAQ,EAAE,CAAC;AAChB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,oBAAoB,CAAC,wBAAwB,KAAK,GAAG,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,CAAC,GAAG,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,oBAAoB,CAAC,qCAAqC,KAAK,GAAG,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { InvalidArgumentError, Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { portNumbers } from 'get-port';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n/** Defines the \"start\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<StartOptions>({\n name: 'start',\n description: 'Starts a web inner-loop from the current package folder.',\n options: {\n mode: reusedOptions.mode({ action: 'run' }),\n app: new Option(\n '--app <appPackageName>',\n 'Run Cloudpack targeting a specific app (only needed if running init at a higher level in the repo).',\n ),\n open: new Option('--no-open', 'Do not open the browser.'),\n cache: reusedOptions.noCache(),\n logResolveMap: reusedOptions.logResolveMap(),\n apiServerPort: getPortOption('--api-server-port <port>', 'API'),\n appServerPort: getPortOption('--app-server-port <port>', 'app'),\n bundleServerPort: getPortOption('--bundle-server-port <port>', 'bundle'),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n\nfunction getPortOption(flags: string, name: string) {\n return new Option(flags, `Port to use for the ${name} server (single, comma-separated, or range with dash).`)\n .argParser(parsePorts)\n .hideHelp();\n}\n\nfunction parsePorts(value: string): number[] {\n if (value.includes('-')) {\n const split = value.split('-');\n if (split.length !== 2) {\n throw new InvalidArgumentError(`Invalid port range: \"${value}\"`);\n }\n return [...portNumbers(parseNumber(split[0]), parseNumber(split[1]))];\n }\n\n return value.split(',').map(parseNumber);\n}\n\nfunction parseNumber(value: string) {\n value = value.trim();\n const parsed = parseInt(value, 10);\n if (isNaN(parsed)) {\n throw new InvalidArgumentError(`Port must be a number; received: \"${value}\"`);\n }\n return parsed;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,gCAAgC;AAChC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAe;QAClC,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,0DAA0D;QACvE,OAAO,EAAE;YACP,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC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AAC;AAC3C,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,oBAAoB,CAAC,qCAAqC,KAAK,GAAG,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { InvalidArgumentError, Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { portNumbers } from 'get-port';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n/** Defines the \"start\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<StartOptions>({\n name: 'start',\n description: 'Starts a web inner-loop from the current package folder.',\n options: {\n mode: reusedOptions.mode({ action: 'run' }),\n app: new Option(\n '--app <appPackageName>',\n 'Run Cloudpack targeting a specific app (only needed if running init at a higher level in the repo).',\n ),\n open: new Option('--no-open', 'Do not open the browser.'),\n cache: reusedOptions.noCache(),\n logResolveMap: reusedOptions.logResolveMap(),\n apiServerPort: getPortOption('--api-server-port <port>', 'API'),\n appServerPort: getPortOption('--app-server-port <port>', 'app'),\n bundleServerPort: getPortOption('--bundle-server-port <port>', 'bundle'),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n\nfunction getPortOption(flags: string, name: string): Option {\n return new Option(flags, `Port to use for the ${name} server (single, comma-separated, or range with dash).`)\n .argParser(parsePorts)\n .hideHelp();\n}\n\nfunction parsePorts(value: string): number[] {\n if (value.includes('-')) {\n const split = value.split('-');\n if (split.length !== 2) {\n throw new InvalidArgumentError(`Invalid port range: \"${value}\"`);\n }\n return [...portNumbers(parseNumber(split[0]), parseNumber(split[1]))];\n }\n\n return value.split(',').map(parseNumber);\n}\n\nfunction parseNumber(value: string): number {\n value = value.trim();\n const parsed = parseInt(value, 10);\n if (isNaN(parsed)) {\n throw new InvalidArgumentError(`Port must be a number; received: \"${value}\"`);\n }\n return parsed;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openBrowser.d.ts","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AAKA,wBAAwB;AACxB,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"openBrowser.d.ts","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AAKA,wBAAwB;AACxB,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK5D;AAED,8CAA8C;AAC9C,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,mDAAmD;AACnD,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openBrowser.js","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,IAAI,kBAAkB,GAAG,IAAI,CAAC;AAC9B,IAAI,aAAiC,CAAC;AAEtC,wBAAwB;AACxB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW;IAC3C,aAAa,GAAG,GAAG,CAAC;IACpB,IAAI,kBAAkB,EAAE,CAAC;QACvB,MAAM,IAAI,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,kBAAkB;IAChC,kBAAkB,GAAG,KAAK,CAAC;AAC7B,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import open from 'open';\n\nlet openBrowserEnabled = true;\nlet lastOpenedUrl: string | undefined;\n\n/** Open the browser. */\nexport async function openBrowser(url: string) {\n lastOpenedUrl = url;\n if (openBrowserEnabled) {\n await open(url, { newInstance: false });\n }\n}\n\n/** Disable opening the browser (for tests) */\nexport function disableOpenBrowser() {\n openBrowserEnabled = false;\n}\n\n/** Get the most recently opened URL (for tests) */\nexport function getLastOpenedUrl() {\n return lastOpenedUrl;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"openBrowser.js","sourceRoot":"","sources":["../../../src/commands/start/openBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,IAAI,kBAAkB,GAAG,IAAI,CAAC;AAC9B,IAAI,aAAiC,CAAC;AAEtC,wBAAwB;AACxB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW;IAC3C,aAAa,GAAG,GAAG,CAAC;IACpB,IAAI,kBAAkB,EAAE,CAAC;QACvB,MAAM,IAAI,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,kBAAkB;IAChC,kBAAkB,GAAG,KAAK,CAAC;AAC7B,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import open from 'open';\n\nlet openBrowserEnabled = true;\nlet lastOpenedUrl: string | undefined;\n\n/** Open the browser. */\nexport async function openBrowser(url: string): Promise<void> {\n lastOpenedUrl = url;\n if (openBrowserEnabled) {\n await open(url, { newInstance: false });\n }\n}\n\n/** Disable opening the browser (for tests) */\nexport function disableOpenBrowser(): void {\n openBrowserEnabled = false;\n}\n\n/** Get the most recently opened URL (for tests) */\nexport function getLastOpenedUrl(): string | undefined {\n return lastOpenedUrl;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trackSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMxD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO
|
|
1
|
+
{"version":3,"file":"trackSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMxD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAW5F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trackSession.js","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB;IACjD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAEpG,MAAM,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAE5C,OAAO;QACL,KAAK,CAAC,KAAK;YACT,+EAA+E;YAC/E,MAAM,EAAE,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport { getActiveSessionsPath } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { rm } from 'fs/promises';\nimport path from 'path';\n\n/**\n * Tracks active sessions to disk as they are started. This gives us a way to enumerate\n * all active sessions for scenarios like better error messages when sessions are already\n * running for a given path, or for the link verb where we want to manipulate an active\n * running session.\n */\nexport async function trackSession(session: Session) {\n const activeSessionPath = path.join(getActiveSessionsPath(session.cachePath), `${session.id}.json`);\n\n await writeJson(activeSessionPath, session);\n\n return {\n async close() {\n // Don't error if something has already deleted the file (most likely in tests)\n await rm(activeSessionPath, { force: true });\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"trackSession.js","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB;IACjD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAEpG,MAAM,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAE5C,OAAO;QACL,KAAK,CAAC,KAAK;YACT,+EAA+E;YAC/E,MAAM,EAAE,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport { getActiveSessionsPath } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { rm } from 'fs/promises';\nimport path from 'path';\n\n/**\n * Tracks active sessions to disk as they are started. This gives us a way to enumerate\n * all active sessions for scenarios like better error messages when sessions are already\n * running for a given path, or for the link verb where we want to manipulate an active\n * running session.\n */\nexport async function trackSession(session: Session): Promise<{ close: () => Promise<void> }> {\n const activeSessionPath = path.join(getActiveSessionsPath(session.cachePath), `${session.id}.json`);\n\n await writeJson(activeSessionPath, session);\n\n return {\n async close() {\n // Don't error if something has already deleted the file (most likely in tests)\n await rm(activeSessionPath, { force: true });\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAmB,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAGvE,SAAS,cAAc,CAAC,KAAc,EAAE,IAAY;IAClD,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAC1E,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACzD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,iBAAiB,GAAG,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7D,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,iBAAiB,CAAC;IACtD,IA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C;iBAChD,CAAC,CACH,CAAC;gBACF,UAAU,GAAG,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YAClD,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,uBAAuB,UAAU,CAAC,OAAO,eAAe,UAAU,CAAC,MAAM,kBAAkB,UAAU,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC,sCAAsC;aAChM,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,6BAA6B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;gBACrG,OAAO;oBACL,OAAO,EAAE,GAAG,CACV,oMAAoM,CACrM;oBACD,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC;YACJ,CAAC;YACD,IACE,KAAK,CAAC,IAAI,KAAK,6BAA6B;gBAC5C,CAAC,YAAY,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,CAAC,EACrF,CAAC;gBACD,OAAO;oBACL,OAAO,EAAE,GAAG,CAAC,oEAAoE,CAAC;oBAClF,QAAQ,EAAE,2BAA2B;iBACtC,CAAC;YACJ,CAAC;YAED,IAAI,cAAc,CAAC,KAAK,EAAE,oBAAoB,CAAC,EAAE,CAAC;gBAChD,OAAO;oBACL,OAAO,EAAE,GAAG,CAAC,+DAA+D,CAAC;oBAC7E,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { createPartialApiContext, syncDownload, syncUpload, type SyncResult } from '@ms-cloudpack/api-server';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { red } from '@ms-cloudpack/task-reporter';\nimport {\n ExitCodeAuthenticationError,\n ExitCodeGenericError,\n type CommandAction,\n type CommandExitParams,\n} from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\n\nfunction checkErrorCode(error: unknown, code: string) {\n return error instanceof Error && 'code' in error && error.code === code;\n}\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, cwd, initialize, autoDispose } = params;\n const { login, upload } = options;\n const apiContextOptions = await initialize({ appPath: cwd });\n const { config, telemetryClient } = apiContextOptions;\n try {\n // Await here to ensure that try-catch block catches any errors thrown inside the async function\n return await telemetryClient.tracer.startActiveSpan('SYNC_EXECUTE', async (span): Promise<CommandExitParams> => {\n if (!config.features?.syncBundles) {\n return { message: 'Sync is disabled' };\n }\n\n if (!environmentInfo.cloudpack.isSyncEnabled) {\n span.setAttribute('syncDisabled', true);\n return { message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' };\n }\n\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n return {\n message:\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n };\n }\n\n const input = {\n loginMethod: login,\n };\n\n let syncResult: SyncResult;\n if (upload) {\n await runPrerequisites(apiContextOptions);\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n syncResult = await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n syncResult = await syncDownload({ input, ctx });\n }\n\n return {\n message: `Sync completed with ${syncResult.success} successes, ${syncResult.failed} failures, and ${syncResult['already-exist'] + syncResult['not-found']} items that did not require syncing.`,\n };\n });\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AuthenticationRequiredError' && error.message.includes('CrossPlatformLockError')) {\n return {\n message: red(\n `Cloudpack encountered an issue acquiring authentication lock. It seems Cloudpack Sync may already be active in another process. Please wait for the current process to complete and then try again`,\n ),\n exitCode: ExitCodeGenericError,\n };\n }\n if (\n error.name === 'AuthenticationRequiredError' ||\n ('statusCode' in error && (error.statusCode === '401' || error.statusCode === '403'))\n ) {\n return {\n message: red('Authentication error. Please check your credentials and try again.'),\n exitCode: ExitCodeAuthenticationError,\n };\n }\n\n if (checkErrorCode(error, 'REQUEST_SEND_ERROR')) {\n return {\n message: red('Connection error. Please check your connection and try again.'),\n exitCode: ExitCodeGenericError,\n };\n }\n }\n\n throw error;\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAmB,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAGvE,SAAS,cAAc,CAAC,KAAc,EAAE,IAAY;IAClD,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAC1E,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACzD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,iBAAiB,GAAG,MAAM,UAAU,CAAC,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;AACH,CAAC,CAAC","sourcesContent":["import { createPartialApiContext, syncDownload, syncUpload, type SyncResult } from '@ms-cloudpack/api-server';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { red } from '@ms-cloudpack/task-reporter';\nimport {\n ExitCodeAuthenticationError,\n ExitCodeGenericError,\n type CommandAction,\n type CommandExitParams,\n} from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\n\nfunction checkErrorCode(error: unknown, code: string): boolean {\n return error instanceof Error && 'code' in error && error.code === code;\n}\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, cwd, initialize, autoDispose } = params;\n const { login, upload } = options;\n const apiContextOptions = await initialize({ appPath: cwd });\n const { config, telemetryClient } = apiContextOptions;\n try {\n // Await here to ensure that try-catch block catches any errors thrown inside the async function\n return await telemetryClient.tracer.startActiveSpan('SYNC_EXECUTE', async (span): Promise<CommandExitParams> => {\n if (!config.features?.syncBundles) {\n return { message: 'Sync is disabled' };\n }\n\n if (!environmentInfo.cloudpack.isSyncEnabled) {\n span.setAttribute('syncDisabled', true);\n return { message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' };\n }\n\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n return {\n message:\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n };\n }\n\n const input = {\n loginMethod: login,\n };\n\n let syncResult: SyncResult;\n if (upload) {\n await runPrerequisites(apiContextOptions);\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n syncResult = await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n syncResult = await syncDownload({ input, ctx });\n }\n\n return {\n message: `Sync completed with ${syncResult.success} successes, ${syncResult.failed} failures, and ${syncResult['already-exist'] + syncResult['not-found']} items that did not require syncing.`,\n };\n });\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AuthenticationRequiredError' && error.message.includes('CrossPlatformLockError')) {\n return {\n message: red(\n `Cloudpack encountered an issue acquiring authentication lock. It seems Cloudpack Sync may already be active in another process. Please wait for the current process to complete and then try again`,\n ),\n exitCode: ExitCodeGenericError,\n };\n }\n if (\n error.name === 'AuthenticationRequiredError' ||\n ('statusCode' in error && (error.statusCode === '401' || error.statusCode === '403'))\n ) {\n return {\n message: red('Authentication error. Please check your credentials and try again.'),\n exitCode: ExitCodeAuthenticationError,\n };\n }\n\n if (checkErrorCode(error, 'REQUEST_SEND_ERROR')) {\n return {\n message: red('Connection error. Please check your connection and try again.'),\n exitCode: ExitCodeGenericError,\n };\n }\n }\n\n throw error;\n }\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAQ9E,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,mBAclB,CAAC"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { Option } from 'commander';
|
|
2
2
|
import { environmentInfo } from '@ms-cloudpack/environment';
|
|
3
3
|
function getDefaultLogin() {
|
|
4
|
-
|
|
5
|
-
return 'azure-cli';
|
|
6
|
-
}
|
|
7
|
-
if (environmentInfo.isCodespaces) {
|
|
8
|
-
return 'device-code';
|
|
9
|
-
}
|
|
10
|
-
return 'interactive';
|
|
4
|
+
return environmentInfo.isCI ? 'azure-cli' : environmentInfo.isCodespaces ? 'device-code' : 'interactive';
|
|
11
5
|
}
|
|
12
6
|
/** Defines the "sync" verb. */
|
|
13
7
|
export const init = (program) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,SAAS,eAAe;IACtB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,SAAS,eAAe;IACtB,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC;AAC3G,CAAC;AAED,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAc;QACjC,IAAI,EAAE,MAAM;QACZ,WAAW,EACT,2CAA2C;YAC3C,2FAA2F;QAC7F,OAAO,EAAE;YACP,MAAM,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE,+DAA+D,CAAC;YAC/F,KAAK,EAAE,IAAI,MAAM,CAAC,kBAAkB,EAAE,+CAA+C,CAAC;iBACnF,OAAO,CAAC,CAAC,aAAa,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;iBACpD,OAAO,CAAC,eAAe,EAAE,EAAE,gFAAgF,CAAC;SAChH;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\n\nfunction getDefaultLogin(): string {\n return environmentInfo.isCI ? 'azure-cli' : environmentInfo.isCodespaces ? 'device-code' : 'interactive';\n}\n\n/** Defines the \"sync\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<SyncOptions>({\n name: 'sync',\n description:\n 'Syncs packages from/to the remote cache. ' +\n 'By default (without --upload) it will download any packages not found in the local cache.',\n options: {\n upload: new Option('--upload', 'Upload packages to the remote cache (instead of downloading).'),\n login: new Option('--login <method>', 'How to authenticate against the remote cache.')\n .choices(['interactive', 'azure-cli', 'device-code'])\n .default(getDefaultLogin(), '\"azure-cli\" in CI, \"device-code\" in Github Codespaces, \"interactive\" otherwise'),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
|
package/lib/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAOrD,iCAAiC;AACjC,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAOrD,iCAAiC;AACjC,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;I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AG,IAAI,gBAAgB,CAAC;QACnC,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,uFAAuF;QACpG,KAAK,EAAE,qBAAqB;QAC5B,aAAa;QACb,cAAc,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE;KACzD,CAAC,CAAC;IAEH,iCAAiC;IACjC,MAAM,YAAY,GAAG,kBAAkB,CAAC;IACxC,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACtE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,+BAA+B,UAAU,IAAI,YAAY,MAAM,CAAC,CAAC;IACnF,CAAC;IAED,KAAK,MAAM,WAAW,IAAI,QAAQ,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QACzD,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAsB,CAAC;QAEtE,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC","sourcesContent":["import { getDisplayVersion } from '@ms-cloudpack/package-utilities';\nimport { globSourceFiles } from '@ms-cloudpack/path-utilities';\nimport type { OutputConfiguration } from 'commander';\nimport path from 'path';\nimport { fileURLToPath, pathToFileURL } from 'url';\nimport type { CommandInitModule } from './types/CommandInitFunction.js';\nimport { PerfMarkerCliEntry } from './performance/markers.js';\nimport { CloudpackCommand } from './utilities/CloudpackCommand.js';\n\n/** Override options for tests */\nexport interface MainOptions {\n cwd?: string;\n disableTelemetry?: boolean;\n argv?: string[];\n outputOptions?: OutputConfiguration;\n}\n\n/**\n * Entry point for the cloudpack CLI.\n * Resolves all commands defined within the \"./commands\" folder.\n */\nexport async function main(options: Partial<MainOptions> = {}) {\n const {\n argv = [...process.argv],\n // eslint-disable-next-line no-restricted-properties -- this is where the default is supplied\n cwd = process.cwd(),\n disableTelemetry,\n outputOptions,\n } = options;\n\n performance.mark(PerfMarkerCliEntry);\n\n if (argv[3] === '--') {\n // Remove the \"--\" argument in case it's added by lage\n argv.splice(3, 1);\n }\n\n const version = getDisplayVersion(import.meta.url);\n\n // Create the top-level command and apply common options\n // (avoids \"unknown option\" errors if they're specified without a verb)\n const program = new CloudpackCommand({\n name: 'cloudpack',\n description: 'A tool for managing fast inner and outer looping in web apps. Requires a sub-command.',\n usage: '<command> [options]',\n outputOptions,\n programOptions: { cwd, version, argv, disableTelemetry },\n });\n\n // Get all the available commands\n const commandsGlob = 'commands/*/index';\n const commands = await globSourceFiles(import.meta.url, commandsGlob);\n if (!commands.length) {\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n throw new Error(`No commands found matching \"${currentDir}/${commandsGlob}.*\".`);\n }\n\n for (const commandPath of commands) {\n const commandUrl = pathToFileURL(commandPath).toString();\n const commandModule = (await import(commandUrl)) as CommandInitModule;\n\n commandModule.init(program);\n }\n\n await program.run();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAUnE;;;GAGG;AACH,MAAM,CA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W,CAAC,CAAC,QAAQ,EAAE,CAAC;QACzD,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAsB,CAAC;QAEtE,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC","sourcesContent":["import { getDisplayVersion } from '@ms-cloudpack/package-utilities';\nimport { globSourceFiles } from '@ms-cloudpack/path-utilities';\nimport type { OutputConfiguration } from 'commander';\nimport path from 'path';\nimport { fileURLToPath, pathToFileURL } from 'url';\nimport type { CommandInitModule } from './types/CommandInitFunction.js';\nimport { PerfMarkerCliEntry } from './performance/markers.js';\nimport { CloudpackCommand } from './utilities/CloudpackCommand.js';\n\n/** Override options for tests */\nexport interface MainOptions {\n cwd?: string;\n disableTelemetry?: boolean;\n argv?: string[];\n outputOptions?: OutputConfiguration;\n}\n\n/**\n * Entry point for the cloudpack CLI.\n * Resolves all commands defined within the \"./commands\" folder.\n */\nexport async function main(options: Partial<MainOptions> = {}): Promise<void> {\n const {\n argv = [...process.argv],\n // eslint-disable-next-line no-restricted-properties -- this is where the default is supplied\n cwd = process.cwd(),\n disableTelemetry,\n outputOptions,\n } = options;\n\n performance.mark(PerfMarkerCliEntry);\n\n if (argv[3] === '--') {\n // Remove the \"--\" argument in case it's added by lage\n argv.splice(3, 1);\n }\n\n const version = getDisplayVersion(import.meta.url);\n\n // Create the top-level command and apply common options\n // (avoids \"unknown option\" errors if they're specified without a verb)\n const program = new CloudpackCommand({\n name: 'cloudpack',\n description: 'A tool for managing fast inner and outer looping in web apps. Requires a sub-command.',\n usage: '<command> [options]',\n outputOptions,\n programOptions: { cwd, version, argv, disableTelemetry },\n });\n\n // Get all the available commands\n const commandsGlob = 'commands/*/index';\n const commands = await globSourceFiles(import.meta.url, commandsGlob);\n if (!commands.length) {\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n throw new Error(`No commands found matching \"${currentDir}/${commandsGlob}.*\".`);\n }\n\n for (const commandPath of commands) {\n const commandUrl = pathToFileURL(commandPath).toString();\n const commandModule = (await import(commandUrl)) as CommandInitModule;\n\n commandModule.init(program);\n }\n\n await program.run();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoDisposableList.d.ts","sourceRoot":"","sources":["../../src/utilities/AutoDisposableList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAEzC,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"AutoDisposableList.d.ts","sourceRoot":"","sources":["../../src/utilities/AutoDisposableList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAEzC,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;IAKvC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CActC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoDisposableList.js","sourceRoot":"","sources":["../../src/utilities/AutoDisposableList.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAkB;IAA/B;QACmB,gBAAW,GAAiB,EAAE,CAAC;IAqBlD,CAAC;IAnBQ,GAAG,CAAuB,GAAG,KAAU;QAC5C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACzB,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACxB,OAAO,CAAC,KAAK,CAAC,sBAAuB,GAAa,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC;YACnE,UAAU,EAAE,CAAC;QACf,CAAC,CAAC,CACH,CACF,CAAC;QACF,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,qBAAqB,UAAU,gBAAgB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { Disposable } from '../types/Disposable.js';\n\nexport class AutoDisposableList {\n private readonly disposables: Disposable[] = [];\n\n public add<T extends Disposable>(...items: T[]) {\n this.disposables.push(...items);\n return items;\n }\n\n public async dispose() {\n let errorCount = 0;\n await Promise.all(\n this.disposables.map((d) =>\n d.dispose().catch((err) => {\n console.error(`Failed to dispose: ${(err as Error).stack || err}`);\n errorCount++;\n }),\n ),\n );\n if (errorCount) {\n throw new Error(`Failed to dispose ${errorCount} disposable(s)`);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AutoDisposableList.js","sourceRoot":"","sources":["../../src/utilities/AutoDisposableList.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAkB;IAA/B;QACmB,gBAAW,GAAiB,EAAE,CAAC;IAqBlD,CAAC;IAnBQ,GAAG,CAAuB,GAAG,KAAU;QAC5C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACzB,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACxB,OAAO,CAAC,KAAK,CAAC,sBAAuB,GAAa,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC,CAAC;YACnE,UAAU,EAAE,CAAC;QACf,CAAC,CAAC,CACH,CACF,CAAC;QACF,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,qBAAqB,UAAU,gBAAgB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { Disposable } from '../types/Disposable.js';\n\nexport class AutoDisposableList {\n private readonly disposables: Disposable[] = [];\n\n public add<T extends Disposable>(...items: T[]): T[] {\n this.disposables.push(...items);\n return items;\n }\n\n public async dispose(): Promise<void> {\n let errorCount = 0;\n await Promise.all(\n this.disposables.map((d) =>\n d.dispose().catch((err) => {\n console.error(`Failed to dispose: ${(err as Error).stack || err}`);\n errorCount++;\n }),\n ),\n );\n if (errorCount) {\n throw new Error(`Failed to dispose ${errorCount} disposable(s)`);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAIrH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAsD5D;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IAI3B;;;OAGG;IACH;IACE,4EAA4E;IAC5E,MAIC;QAED,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;QAE7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChF,IAA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AAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,eAAe;gBACpC,IAAI;aACL,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,aAAc,SAAQ,IAAI;IAC9B,cAAc,CAAC,GAAY;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAE1C,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,WAAW,EAAE,CAAC;YAC/B,4EAA4E;YAC5E,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,SAAS,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { Command, Help, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { CommandExecutor } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n command.createHelp = () => new CloudpackHelp();\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details about the running tasks.'),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).').conflicts('verbose'),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.').default(\n !environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI,\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.'),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>) {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, option] of Object.entries(options) as [keyof TAddOptions, Option][]) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>) {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n });\n await commandExecutor.execute();\n });\n }\n}\n\nclass CloudpackHelp extends Help {\n visibleOptions(cmd: Command): Option[] {\n const options = super.visibleOptions(cmd);\n\n if (cmd.name() !== 'cloudpack') {\n // Remove --version from help except at the top level (it's not very useful)\n return options.filter((option) => option.name() !== 'version');\n }\n\n return options;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAIrH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAsD5D;;;;;;;GAOG;AACH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AC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEpG,0CAA0C;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,eAAe;gBACpC,IAAI;aACL,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,aAAc,SAAQ,IAAI;IAC9B,cAAc,CAAC,GAAY;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAE1C,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,WAAW,EAAE,CAAC;YAC/B,4EAA4E;YAC5E,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,SAAS,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { Command, Help, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { CommandExecutor } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n command.createHelp = () => new CloudpackHelp();\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details about the running tasks.'),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).').conflicts('verbose'),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.').default(\n !environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI,\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.'),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>): void {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, option] of Object.entries(options) as [keyof TAddOptions, Option][]) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>): void {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n });\n await commandExecutor.execute();\n });\n }\n}\n\nclass CloudpackHelp extends Help {\n visibleOptions(cmd: Command): Option[] {\n const options = super.visibleOptions(cmd);\n\n if (cmd.name() !== 'cloudpack') {\n // Remove --version from help except at the top level (it's not very useful)\n return options.filter((option) => option.name() !== 'version');\n }\n\n return options;\n }\n}\n"]}
|
|
@@ -45,6 +45,6 @@ export declare class CommandExecutor<TOptions extends SharedOptions> {
|
|
|
45
45
|
* Exit function called with the result returned by the command's execute function,
|
|
46
46
|
* or manually via `CommandExecutor.exitAll()` in tests.
|
|
47
47
|
*/
|
|
48
|
-
protected _exit(params: CommandExitParams): Promise<
|
|
48
|
+
protected _exit(params: CommandExitParams): Promise<never>;
|
|
49
49
|
}
|
|
50
50
|
//# sourceMappingURL=CommandExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAGlB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAO/D;;GAEG;AACH,qBAAa,eAAe,CAAC,QAAQ,SAAS,aAAa;IACzD,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,sBAAsB,CAA+B;IAE7D,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAA8B;WAEzC,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;gBASzD,MAAM,EAAE;QAClB,iCAAiC;QACjC,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,2CAA2C;QAC3C,OAAO,EAAE,QAAQ,CAAC;QAClB,uCAAuC;QACvC,OAA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M,CAAC;YACN,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAE3B,qDAAqD;YACrD,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAE9B,sCAAsC;YACtC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;YAEzC,MAAM,aAAa,GAAG,QAAQ,KAAK,CAAC,CAAC;YAErC,8DAA8D;YAC9D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC7E,CAAC;QAED,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;;AA3RD,yFAAyF;AAC1E,gCAAgB,GAA2B,EAAE,AAA7B,CAA8B","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type {\n CommandAction,\n CommandExitParams,\n AppCommandContext,\n CommandInitializeOptions,\n} from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { mergeFeatures } from './mergeFeatures.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\nexport class CommandExecutor<TOptions extends SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _abortController: AbortController;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _getMessageOnInterrupt = () => `Interrupted by user`;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances: CommandExecutor<any>[] = [];\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = [];\n }\n\n constructor(params: {\n /** Command-specific arguments */\n args: string[];\n /** Command-specific and shared options. */\n options: TOptions;\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n }) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._reporter = new TaskReporter();\n this._abortController = new AbortController();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute() {\n CommandExecutor._activeInstances.push(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n process.on('SIGINT', this._sigintHandler);\n\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await this._execute({\n args: this._args,\n options: this._options,\n cwd: this._programOptions.cwd,\n reporter: this._reporter,\n initialize: this._initialize.bind(this),\n abortSignal: this._abortController.signal,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n if (result) {\n await this._exit(result);\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: error instanceof Error ? error.stack || error.message : String(error),\n });\n }\n }\n\n /**\n * This is the `initialize` function passed to the command's execute function.\n * This function uses `this` to references several class members, which is why\n * the `execute` method must use `.bind(this)`.\n * (An arrow function isn't possible here due to the overloaded method signature).\n */\n private async _initialize(\n initializeParams: CommandInitializeOptions & { appPath: string },\n ): Promise<AppCommandContext>;\n private async _initialize(\n initializeParams: CommandInitializeOptions & { appPaths: string[] },\n ): Promise<AppCommandContext[]>;\n private async _initialize(\n initializeParams: CommandInitializeOptions & {\n appPath?: string;\n appPaths?: string[];\n },\n ): Promise<AppCommandContext | AppCommandContext[]> {\n const { appPath: singleAppPath, configOptions } = initializeParams;\n let { appPaths } = initializeParams;\n\n if (singleAppPath && appPaths) {\n throw Error('appPath and appPaths cannot both be specified at the same time');\n }\n if (!singleAppPath && !appPaths) {\n throw Error('one of appPath or appPaths must be specified');\n }\n\n if (!appPaths || appPaths.length === 0) {\n appPaths = singleAppPath ? [singleAppPath] : [];\n }\n\n const contexts: AppCommandContext[] = [];\n\n const helpMessages = new Set<string>();\n\n const configs: Record<string, CloudpackConfig> = {};\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, configOptions);\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // eslint-disable-next-line no-restricted-properties -- this will never be reached, but TypeScript doesn't know that\n process.exit(1);\n }\n if (config.helpMessage) {\n helpMessages.add(config.helpMessage);\n }\n\n configs[appPath] = config;\n }\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs[appPath];\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config);\n // Dispose the telemetry client when the app is closing\n this._autoDisposableList.add({\n dispose: () => telemetryClient.shutdown(),\n });\n\n // Merge in any additional features from the command line and remote feature flags.\n config.features = mergeFeatures({\n configFeatures: config.features,\n commandLineFeatures: this._options.features,\n });\n\n const featureErrors = checkFeatures({ configFeatures: config.features });\n\n // If there are any invalid features, warn the user and continue.\n if (featureErrors.length) {\n featureErrors.forEach((warning) => console.warn(warning));\n }\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n });\n }\n\n return singleAppPath ? contexts[0] : contexts;\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString =\n programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\n\n const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;\n if (!options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n connectionString,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n });\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode || 'library',\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = () => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams) {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt() : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Let the execute function know that we are exiting.\n this._abortController.abort();\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n const exitWithError = exitCode !== 0;\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete(hasErrors ? red(message) : message, exitWithError);\n }\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAA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;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;;AA3RD,yFAAyF;AAC1E,gCAAgB,GAA2B,EAAE,AAA7B,CAA8B","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type {\n CommandAction,\n CommandExitParams,\n AppCommandContext,\n CommandInitializeOptions,\n} from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { mergeFeatures } from './mergeFeatures.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\nexport class CommandExecutor<TOptions extends SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _abortController: AbortController;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _getMessageOnInterrupt = () => `Interrupted by user`;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances: CommandExecutor<any>[] = [];\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = [];\n }\n\n constructor(params: {\n /** Command-specific arguments */\n args: string[];\n /** Command-specific and shared options. */\n options: TOptions;\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n }) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._reporter = new TaskReporter();\n this._abortController = new AbortController();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute(): Promise<void> {\n CommandExecutor._activeInstances.push(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n process.on('SIGINT', this._sigintHandler);\n\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await this._execute({\n args: this._args,\n options: this._options,\n cwd: this._programOptions.cwd,\n reporter: this._reporter,\n initialize: this._initialize.bind(this),\n abortSignal: this._abortController.signal,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n if (result) {\n await this._exit(result);\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: error instanceof Error ? error.stack || error.message : String(error),\n });\n }\n }\n\n /**\n * This is the `initialize` function passed to the command's execute function.\n * This function uses `this` to references several class members, which is why\n * the `execute` method must use `.bind(this)`.\n * (An arrow function isn't possible here due to the overloaded method signature).\n */\n private async _initialize(\n initializeParams: CommandInitializeOptions & { appPath: string },\n ): Promise<AppCommandContext>;\n private async _initialize(\n initializeParams: CommandInitializeOptions & { appPaths: string[] },\n ): Promise<AppCommandContext[]>;\n private async _initialize(\n initializeParams: CommandInitializeOptions & {\n appPath?: string;\n appPaths?: string[];\n },\n ): Promise<AppCommandContext | AppCommandContext[]> {\n const { appPath: singleAppPath, configOptions } = initializeParams;\n let { appPaths } = initializeParams;\n\n if (singleAppPath && appPaths) {\n throw Error('appPath and appPaths cannot both be specified at the same time');\n }\n if (!singleAppPath && !appPaths) {\n throw Error('one of appPath or appPaths must be specified');\n }\n\n if (!appPaths || appPaths.length === 0) {\n appPaths = singleAppPath ? [singleAppPath] : [];\n }\n\n const contexts: AppCommandContext[] = [];\n\n const helpMessages = new Set<string>();\n\n const configs: Record<string, CloudpackConfig> = {};\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, configOptions);\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // eslint-disable-next-line no-restricted-properties -- this will never be reached, but TypeScript doesn't know that\n process.exit(1);\n }\n if (config.helpMessage) {\n helpMessages.add(config.helpMessage);\n }\n\n configs[appPath] = config;\n }\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs[appPath];\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config);\n // Dispose the telemetry client when the app is closing\n this._autoDisposableList.add({\n dispose: () => telemetryClient.shutdown(),\n });\n\n // Merge in any additional features from the command line and remote feature flags.\n config.features = mergeFeatures({\n configFeatures: config.features,\n commandLineFeatures: this._options.features,\n });\n\n const featureErrors = checkFeatures({ configFeatures: config.features });\n\n // If there are any invalid features, warn the user and continue.\n if (featureErrors.length) {\n featureErrors.forEach((warning) => console.warn(warning));\n }\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n });\n }\n\n return singleAppPath ? contexts[0] : contexts;\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString =\n programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\n\n const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;\n if (!options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n connectionString,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n });\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode || 'library',\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = (): void => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams): Promise<never> {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt() : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Let the execute function know that we are exiting.\n this._abortController.abort();\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n const exitWithError = exitCode !== 0;\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete(hasErrors ? red(message) : message, exitWithError);\n }\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findCloudpackAppPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/findCloudpackAppPaths.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"findCloudpackAppPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/findCloudpackAppPaths.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAIpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findCloudpackAppPaths.js","sourceRoot":"","sources":["../../src/utilities/findCloudpackAppPaths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAoB;IACxD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,0BAA0B,CAAC,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAC/G,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CACtD,CAAC;AACJ,CAAC","sourcesContent":["import glob from 'fast-glob';\nimport path from 'path';\n\n/**\n * Find folders in the repo containing a `cloudpack.config.json` file.\n * @param startingPath The path to start searching from when finding Cloudpack apps\n * @returns An array of app paths corresponding to all discovered Cloudpack apps\n */\nexport function findCloudpackAppPaths(startingPath: string) {\n return (glob.sync(['**/cloudpack.config.json'], { cwd: startingPath, ignore: ['**/node_modules/**'] }) ?? []).map(\n (file) => path.join(startingPath, path.dirname(file)),\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"findCloudpackAppPaths.js","sourceRoot":"","sources":["../../src/utilities/findCloudpackAppPaths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAoB;IACxD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,0BAA0B,CAAC,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAC/G,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CACtD,CAAC;AACJ,CAAC","sourcesContent":["import glob from 'fast-glob';\nimport path from 'path';\n\n/**\n * Find folders in the repo containing a `cloudpack.config.json` file.\n * @param startingPath The path to start searching from when finding Cloudpack apps\n * @returns An array of app paths corresponding to all discovered Cloudpack apps\n */\nexport function findCloudpackAppPaths(startingPath: string): string[] {\n return (glob.sync(['**/cloudpack.config.json'], { cwd: startingPath, ignore: ['**/node_modules/**'] }) ?? []).map(\n (file) => path.join(startingPath, path.dirname(file)),\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRepositoryName.d.ts","sourceRoot":"","sources":["../../src/utilities/getRepositoryName.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"getRepositoryName.d.ts","sourceRoot":"","sources":["../../src/utilities/getRepositoryName.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkBpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRepositoryName.js","sourceRoot":"","sources":["../../src/utilities/getRepositoryName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC;QACrD,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QAChE,MAAM,kBAAkB,GAAG,CAAC,MAAM,QAAQ,CAAC,mBAAmB,CAAC,CAAsB,CAAC;QACtF,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,kBAAkB,mBAAmB,GAAG,CAAC,CAAC;YACvD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,kBAAkB,CAAC,IAAI,CAAC;IACjC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CACV,0GAA0G,EAC1G,CAAC,CACF,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import { readJson } from '@ms-cloudpack/json-utilities';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\n\n/**\n * Gets the name of the workspace or git repository from the root package.json.\n * @returns The name of the workspace or repository. If the name is not found, undefined is returned.\n */\nexport async function getRepositoryName(appPath: string) {\n try {\n const rootPath = findProjectRoot(appPath) || appPath;\n const rootPackageJsonPath = path.join(rootPath, 'package.json');\n const packageJsonContent = (await readJson(rootPackageJsonPath)) as { name?: string };\n if (!packageJsonContent) {\n console.warn(`Could not read ${rootPackageJsonPath}.`);\n return undefined;\n }\n\n return packageJsonContent.name;\n } catch (e) {\n console.warn(\n 'An error occurred while getting repository name. This is not a critical error. You can continue to work.',\n e,\n );\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getRepositoryName.js","sourceRoot":"","sources":["../../src/utilities/getRepositoryName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC;QACrD,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QAChE,MAAM,kBAAkB,GAAG,CAAC,MAAM,QAAQ,CAAC,mBAAmB,CAAC,CAAsB,CAAC;QACtF,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,kBAAkB,mBAAmB,GAAG,CAAC,CAAC;YACvD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,kBAAkB,CAAC,IAAI,CAAC;IACjC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CACV,0GAA0G,EAC1G,CAAC,CACF,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import { readJson } from '@ms-cloudpack/json-utilities';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\n\n/**\n * Gets the name of the workspace or git repository from the root package.json.\n * @returns The name of the workspace or repository. If the name is not found, undefined is returned.\n */\nexport async function getRepositoryName(appPath: string): Promise<string | undefined> {\n try {\n const rootPath = findProjectRoot(appPath) || appPath;\n const rootPackageJsonPath = path.join(rootPath, 'package.json');\n const packageJsonContent = (await readJson(rootPackageJsonPath)) as { name?: string };\n if (!packageJsonContent) {\n console.warn(`Could not read ${rootPackageJsonPath}.`);\n return undefined;\n }\n\n return packageJsonContent.name;\n } catch (e) {\n console.warn(\n 'An error occurred while getting repository name. This is not a critical error. You can continue to work.',\n e,\n );\n return undefined;\n }\n}\n"]}
|
|
@@ -3,15 +3,15 @@ import { Option } from 'commander';
|
|
|
3
3
|
* These options are used by multiple commands, but should be manually added.
|
|
4
4
|
*/
|
|
5
5
|
export declare const reusedOptions: {
|
|
6
|
-
logResolveMap: () => Option;
|
|
6
|
+
readonly logResolveMap: () => Option;
|
|
7
7
|
/**
|
|
8
8
|
* @param descriptionStart Start of description for this command, e.g. "Bundle specific package(s)"
|
|
9
9
|
* (it will automatically include an optional version note and examples)
|
|
10
10
|
*/
|
|
11
|
-
match: (descriptionStart: string) => Option;
|
|
12
|
-
mode: (options: {
|
|
11
|
+
readonly match: (descriptionStart: string) => Option;
|
|
12
|
+
readonly mode: (options: {
|
|
13
13
|
action: "bundle" | "run";
|
|
14
14
|
}) => Option;
|
|
15
|
-
noCache: () => Option;
|
|
15
|
+
readonly noCache: () => Option;
|
|
16
16
|
};
|
|
17
17
|
//# sourceMappingURL=reusedOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reusedOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD;;GAEG;AACH,eAAO,MAAM,aAAa;;IAExB;;;OAGG;
|
|
1
|
+
{"version":3,"file":"reusedOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD;;GAEG;AACH,eAAO,MAAM,aAAa;;IAExB;;;OAGG;uCACuB,MAAM;6BAKhB;QAAE,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAA;KAAE;;CAQpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reusedOptions.js","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,mBAAmB,EAAE,4DAA4D,CAAC;IAClH;;;OAGG;IACH,KAAK,EAAE,CAAC,gBAAwB,EAAE,EAAE,CAClC,IAAI,MAAM,CACR,oBAAoB,EACpB,GAAG,gBAAgB,gEAAgE,CACpF,CAAC,SAAS,CAAC,UAAU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,EAAE,CAAC;QAC3B,KAAK,KAAK,CAAC;QACX,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,KAAK,CAAC;QACX,KAAK,aAAa;YAChB,OAAO,aAAa,CAAC;QACvB,KAAK,MAAM,CAAC;QACZ,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB;YACE,MAAM,IAAI,oBAAoB,CAAC,4CAA4C,CAAC,CAAC;IACjF,CAAC;AACH,CAAC","sourcesContent":["import type { BundleMode } from '@ms-cloudpack/common-types';\nimport { InvalidArgumentError, Option } from 'commander';\nimport { parseMatch } from './parseMatch.js';\n\n/**\n * These options are used by multiple commands, but should be manually added.\n */\nexport const reusedOptions = {\n logResolveMap: () => new Option('--log-resolve-map', 'Log the resolve map to \"resolve-map.json\" for diagnostics.'),\n /**\n * @param descriptionStart Start of description for this command, e.g. \"Bundle specific package(s)\"\n * (it will automatically include an optional version note and examples)\n */\n match: (descriptionStart: string) =>\n new Option(\n '--match <match...>',\n `${descriptionStart}, optionally with a version: e.g. \"foo\", \"@foo/*\", \"foo@1.2.3\"`,\n ).argParser(parseMatch),\n mode: (options: { action: 'bundle' | 'run' }) =>\n new Option(\n '--mode <mode>',\n `The mode to ${options.action === 'bundle' ? 'bundle the package' : 'run the app'} in. (library | production)`,\n )\n .argParser(parseBundleMode)\n .default('library'),\n noCache: () => new Option('--no-cache', 'Rebuild all packages, rather than using cached assets.'),\n} as const;\n\n/** Parse the session mode based on user input (e.g. --mode argument in start.) */\nfunction parseBundleMode(mode: string): BundleMode {\n switch (mode.toLowerCase()) {\n case 'lib':\n case 'library':\n return 'library';\n case 'dev':\n case 'development':\n return 'development';\n case 'prod':\n case 'production':\n return 'production';\n default:\n throw new InvalidArgumentError(`Valid options are 'lib', 'dev', or 'prod'.`);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runPrerequisites.d.ts","sourceRoot":"","sources":["../../src/utilities/runPrerequisites.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,eAAe,CAAC;CAClC,
|
|
1
|
+
{"version":3,"file":"runPrerequisites.d.ts","sourceRoot":"","sources":["../../src/utilities/runPrerequisites.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,eAAe,CAAC;CAClC,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runPrerequisites.js","sourceRoot":"","sources":["../../src/utilities/runPrerequisites.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,aAAa,CAAC;AAEhC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAItC;IACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACrE,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,CAAC;QACpC,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,SAAS,EAAE,CAAC;gBACxC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/common-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport spawn from 'cross-spawn';\n\n/**\n * Runs the pre-requisites specified in the given Cloudpack config\n * @param config - The Cloudpack config of containing a list of prerequisites to run\n */\nexport async function runPrerequisites(options: {\n config: CloudpackConfig | undefined;\n appPath: string;\n telemetryClient: TelemetryClient;\n}) {\n const { config, appPath, telemetryClient } = options;\n\n await telemetryClient.tracer.startActiveSpan('RUN_PREREQUISITES', () => {\n const dependsOn = config?.dependsOn;\n if (dependsOn) {\n for (const [command, args] of dependsOn) {\n spawn.sync(command, args, { stdio: 'inherit', cwd: appPath, shell: true });\n }\n }\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runPrerequisites.js","sourceRoot":"","sources":["../../src/utilities/runPrerequisites.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,aAAa,CAAC;AAEhC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAItC;IACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACrE,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,CAAC;QACpC,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,SAAS,EAAE,CAAC;gBACxC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/common-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport spawn from 'cross-spawn';\n\n/**\n * Runs the pre-requisites specified in the given Cloudpack config\n * @param config - The Cloudpack config of containing a list of prerequisites to run\n */\nexport async function runPrerequisites(options: {\n config: CloudpackConfig | undefined;\n appPath: string;\n telemetryClient: TelemetryClient;\n}): Promise<void> {\n const { config, appPath, telemetryClient } = options;\n\n await telemetryClient.tracer.startActiveSpan('RUN_PREREQUISITES', () => {\n const dependsOn = config?.dependsOn;\n if (dependsOn) {\n for (const [command, args] of dependsOn) {\n spawn.sync(command, args, { stdio: 'inherit', cwd: appPath, shell: true });\n }\n }\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.72.
|
|
3
|
+
"version": "0.72.31",
|
|
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",
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"cloudpack": "./bin/cloudpack.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ms-cloudpack/api-server": "^0.
|
|
14
|
-
"@ms-cloudpack/app-server": "^0.17.
|
|
15
|
-
"@ms-cloudpack/bundler": "^0.23.
|
|
16
|
-
"@ms-cloudpack/common-types": "^0.
|
|
17
|
-
"@ms-cloudpack/config": "^0.33.
|
|
13
|
+
"@ms-cloudpack/api-server": "^0.57.0",
|
|
14
|
+
"@ms-cloudpack/app-server": "^0.17.26",
|
|
15
|
+
"@ms-cloudpack/bundler": "^0.23.28",
|
|
16
|
+
"@ms-cloudpack/common-types": "^0.24.0",
|
|
17
|
+
"@ms-cloudpack/config": "^0.33.6",
|
|
18
18
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
19
|
-
"@ms-cloudpack/json-utilities": "^0.1.
|
|
20
|
-
"@ms-cloudpack/overlay": "^0.17.
|
|
21
|
-
"@ms-cloudpack/package-utilities": "^11.
|
|
19
|
+
"@ms-cloudpack/json-utilities": "^0.1.10",
|
|
20
|
+
"@ms-cloudpack/overlay": "^0.17.107",
|
|
21
|
+
"@ms-cloudpack/package-utilities": "^11.1.0",
|
|
22
22
|
"@ms-cloudpack/path-string-parsing": "^1.2.6",
|
|
23
|
-
"@ms-cloudpack/path-utilities": "^2.8.
|
|
24
|
-
"@ms-cloudpack/remote-cache": "^0.9.
|
|
25
|
-
"@ms-cloudpack/setup-utilities": "^0.5.
|
|
26
|
-
"@ms-cloudpack/task-reporter": "^0.14.
|
|
27
|
-
"@ms-cloudpack/telemetry": "^0.10.
|
|
23
|
+
"@ms-cloudpack/path-utilities": "^2.8.1",
|
|
24
|
+
"@ms-cloudpack/remote-cache": "^0.9.18",
|
|
25
|
+
"@ms-cloudpack/setup-utilities": "^0.5.7",
|
|
26
|
+
"@ms-cloudpack/task-reporter": "^0.14.8",
|
|
27
|
+
"@ms-cloudpack/telemetry": "^0.10.5",
|
|
28
28
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
29
29
|
"commander": "^11.1.0",
|
|
30
30
|
"cross-spawn": "^7.0.3",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"workspace-tools": "^0.38.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@ms-cloudpack/common-types": "^0.
|
|
40
|
+
"@ms-cloudpack/common-types": "^0.24.0",
|
|
41
41
|
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
42
42
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
43
43
|
"@ms-cloudpack/test-utilities": "^0.5.0",
|