@ms-cloudpack/cli 0.59.1 → 0.59.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/lib/commands/init/evaluateImportsForOverrides.d.ts.map +1 -1
  2. package/lib/commands/init/evaluateImportsForOverrides.js +17 -19
  3. package/lib/commands/init/evaluateImportsForOverrides.js.map +1 -1
  4. package/lib/commands/init/evaluatePath.d.ts +5 -0
  5. package/lib/commands/init/evaluatePath.d.ts.map +1 -1
  6. package/lib/commands/init/evaluatePath.js +7 -4
  7. package/lib/commands/init/evaluatePath.js.map +1 -1
  8. package/lib/commands/init/formatInitSummary.d.ts +7 -5
  9. package/lib/commands/init/formatInitSummary.d.ts.map +1 -1
  10. package/lib/commands/init/formatInitSummary.js +102 -77
  11. package/lib/commands/init/formatInitSummary.js.map +1 -1
  12. package/lib/commands/init/init.d.ts.map +1 -1
  13. package/lib/commands/init/init.js +19 -3
  14. package/lib/commands/init/init.js.map +1 -1
  15. package/lib/commands/init/types/InitPackageResult.d.ts +1 -0
  16. package/lib/commands/init/types/InitPackageResult.d.ts.map +1 -1
  17. package/lib/commands/init/types/InitPackageResult.js.map +1 -1
  18. package/lib/commands/init/verifyExports.d.ts.map +1 -1
  19. package/lib/commands/init/verifyExports.js +66 -21
  20. package/lib/commands/init/verifyExports.js.map +1 -1
  21. package/lib/commands/sync/execute.d.ts +1 -1
  22. package/lib/commands/sync/execute.d.ts.map +1 -1
  23. package/lib/commands/sync/execute.js +20 -5
  24. package/lib/commands/sync/execute.js.map +1 -1
  25. package/lib/types/CommandAction.d.ts +5 -1
  26. package/lib/types/CommandAction.d.ts.map +1 -1
  27. package/lib/types/CommandAction.js +3 -1
  28. package/lib/types/CommandAction.js.map +1 -1
  29. package/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"evaluateImportsForOverrides.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,WAAW,EAEZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAWlE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAMlF;;;GAGG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,sBAAsB,GAAG,SAAS,CAAC;CACrD,GAAG,OAAO,CAAC;IACV,kDAAkD;IAClD,cAAc,EAAE,uBAAuB,EAAE,CAAC;IAC1C,iEAAiE;IACjE,2BAA2B,EAAE,uBAAuB,EAAE,CAAC;IACvD,6BAA6B;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,6BAA6B;IAC7B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,4EAA4E;IAC5E,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC,CAAC;IACjE,6FAA6F;IAC7F,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC,CA0LD"}
1
+ {"version":3,"file":"evaluateImportsForOverrides.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,WAAW,EAEZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAWlE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAMlF;;;GAGG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,sBAAsB,GAAG,SAAS,CAAC;CACrD,GAAG,OAAO,CAAC;IACV,kDAAkD;IAClD,cAAc,EAAE,uBAAuB,EAAE,CAAC;IAC1C,iEAAiE;IACjE,2BAA2B,EAAE,uBAAuB,EAAE,CAAC;IACvD,6BAA6B;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,6BAA6B;IAC7B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,4EAA4E;IAC5E,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC,CAAC;IACjE,6FAA6F;IAC7F,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC,CAuLD"}
@@ -61,24 +61,22 @@ export async function evaluateImportsForOverrides(options) {
61
61
  }
62
62
  generatedPackageSettings.includedDependencies ??= [];
63
63
  // Add to includedDependencies if it is not already included.
64
- if (generatedPackageSettings.includedDependencies.includes(dependencyName)) {
65
- // TODO this seems wrong--it's skipping all further evaluation of the package
66
- continue;
64
+ if (!generatedPackageSettings.includedDependencies.includes(dependencyName)) {
65
+ generatedPackageSettings.includedDependencies.push(dependencyName);
66
+ includedDependenciesChanges.push({
67
+ name: packageName,
68
+ version: packageVersion,
69
+ path: packagePath,
70
+ changes: [
71
+ {
72
+ type: 'included-dependency',
73
+ change: dependencyName,
74
+ reason: `Imported by "${displayName}"`,
75
+ },
76
+ ],
77
+ });
78
+ pathsToRefresh.add(packagePath);
67
79
  }
68
- generatedPackageSettings.includedDependencies.push(dependencyName);
69
- includedDependenciesChanges.push({
70
- name: packageName,
71
- version: packageVersion,
72
- path: packagePath,
73
- changes: [
74
- {
75
- type: 'included-dependency',
76
- change: dependencyName,
77
- reason: `Imported by "${displayName}"`,
78
- },
79
- ],
80
- });
81
- pathsToRefresh.add(packagePath);
82
80
  }
83
81
  const { name, version } = dependencyDefinition;
84
82
  if (!name || !version) {
@@ -159,7 +157,7 @@ export async function evaluateImportsForOverrides(options) {
159
157
  errors.push({
160
158
  text,
161
159
  source: 'evaluate imports',
162
- location: { file: packagePath, line: 1, column: 0 },
160
+ location: { file: packagePath },
163
161
  });
164
162
  }
165
163
  }
@@ -182,7 +180,7 @@ function getMissingDepMessage(params) {
182
180
  return {
183
181
  text,
184
182
  source: 'evaluate imports',
185
- location: { file: path.join(packagePath, 'package.json'), line: 1, column: 0 },
183
+ location: { file: path.join(packagePath, 'package.json') },
186
184
  };
187
185
  }
188
186
  //# sourceMappingURL=evaluateImportsForOverrides.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"evaluateImportsForOverrides.js","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MA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AE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAEvE,IAAI,IAAY,CAAC;IACjB,IAAI,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;QAC9B,IAAI;YACF,sBAAsB,cAAc,2BAA2B,WAAW,KAAK;gBAC/E,2EAA2E;gBAC3E,iCAAiC,WAAW,wDAAwD;gBACpG,sDAAsD,CAAC;IAC3D,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,gBAAgB,cAAc,qBAAqB,WAAW,UACnE,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,iDACvD,yBAAyB,cAAc,uCAAuC,WAAW,IACvF,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,6CAA6C,WAAW,wBAAwB,CAAC,CAAC,CAAC,EAClH,GAAG,CAAC;IACN,CAAC;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,kBAAkB;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;KAC/E,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleInfo } from '@ms-cloudpack/api-server';\nimport type {\n BundleMessage,\n CloudpackConfig,\n PackageDefinitionsCache,\n PackageImporterContext,\n PackageJson,\n PackageSettings,\n} from '@ms-cloudpack/common-types';\nimport { getPackageSettings } from '@ms-cloudpack/config';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport {\n addExportsMapEntry,\n findResolveMapEntry,\n flattenExportsMap,\n getDependencies,\n getUnusedDependencies,\n getExportsMap,\n isExternalPackage,\n} from '@ms-cloudpack/package-utilities';\nimport { bulletedList, cyan } from '@ms-cloudpack/task-reporter';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport { isBuiltin } from 'module';\nimport { getConsumedPaths } from '@ms-cloudpack/api-server';\nimport { neverExclude } from './neverExclude.js';\nimport path from 'path';\n\n/**\n * Evaluate the imports depended on by a package to determine if missing exports map paths need to be added.\n * If so, updates package overrides in the config.\n */\nexport async function evaluateImportsForOverrides(options: {\n packages: PackageDefinitionsCache;\n info: BundleInfo;\n definition: PackageJson;\n packagePath: string;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n importerContext: PackageImporterContext | undefined;\n}): Promise<{\n /** Export changes made to the generated config */\n exportsChanges: GeneratedPackageChanges[];\n /** Included dependencies changes made to the generated config */\n includedDependenciesChanges: GeneratedPackageChanges[];\n /** Any errors encountered */\n errors: BundleMessage[];\n /** Any warnings generated */\n warnings: BundleMessage[];\n /** Map from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate: Map<string, PackageImporterContext | undefined>;\n /** Package paths for which new exports were added, so the package should be re-processed. */\n pathsToRefresh: Set<string>;\n}> {\n const { packages, info, definition, packagePath, config, resolveMap, importerContext } = options;\n\n const { name: packageName, version: packageVersion } = definition;\n const displayName = `${packageName}@${packageVersion}`;\n if (!packageName || !packageVersion) {\n throw new Error(`Package \"${displayName}\" is missing a name or version.`);\n }\n\n const exportsChanges: GeneratedPackageChanges[] = [];\n const includedDependenciesChanges: GeneratedPackageChanges[] = [];\n const errors: BundleMessage[] = [];\n const warnings: BundleMessage[] = [];\n const pathsToEvaluate = new Map<string, PackageImporterContext | undefined>();\n const pathsToRefresh = new Set<string>();\n const dependencies = getDependencies(definition);\n const unusedDependencies = getUnusedDependencies(definition);\n const consumedPaths = getConsumedPaths(info);\n\n // Iterate through imports and find their path from the resolve map.\n for (const [dependencyName, dependencyImportPaths] of Object.entries(consumedPaths)) {\n const resolveEntry = findResolveMapEntry({ definition, packageName: dependencyName, resolveMap });\n const dependencyPath = resolveEntry?.path;\n const dependencyDefinition = dependencyPath ? await packages.get(dependencyPath) : undefined;\n\n // If the dependency is not resolved, add an error.\n if (!dependencyPath || !dependencyDefinition) {\n errors.push(getMissingDepMessage({ dependencyName, displayName, issueType: 'not-found', packagePath }));\n // If the dependency is not resolved, we can't continue to evaluate it.\n continue;\n }\n\n // If the dependency is not listed, add to includedDependencies.\n if (!dependencies[dependencyName] && dependencyName !== definition.name && !neverExclude(dependencyName, config)) {\n // Survive from the case where it is not a dependency in the package.json\n // and it is resolvable, but warn the user.\n if (!unusedDependencies[dependencyName]) {\n warnings.push(getMissingDepMessage({ dependencyName, displayName, issueType: 'undeclared', packagePath }));\n }\n // Make sure to add the package to the list of packages to evaluate.\n pathsToEvaluate.set(packagePath, importerContext);\n\n // Add to includedDependencies\n const packageSettings = (config.generated.packageSettings ??= []);\n let { generatedPackageSettings } = getPackageSettings({\n config: { generated: { packageSettings } },\n name: packageName,\n version: packageVersion,\n firstMatch: true,\n });\n\n if (!generatedPackageSettings) {\n generatedPackageSettings = {\n match: isExternalPackage(packagePath) ? { name: packageName, version: `^${packageVersion}` } : packageName,\n };\n packageSettings.push(generatedPackageSettings);\n }\n\n generatedPackageSettings.includedDependencies ??= [];\n\n // Add to includedDependencies if it is not already included.\n if (generatedPackageSettings.includedDependencies.includes(dependencyName)) {\n // TODO this seems wrong--it's skipping all further evaluation of the package\n continue;\n }\n\n generatedPackageSettings.includedDependencies.push(dependencyName);\n\n includedDependenciesChanges.push({\n name: packageName,\n version: packageVersion,\n path: packagePath,\n changes: [\n {\n type: 'included-dependency',\n change: dependencyName,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n\n pathsToRefresh.add(packagePath);\n }\n\n const { name, version } = dependencyDefinition as Required<PackageJson>;\n if (!name || !version) {\n throw new Error(`Package \"${displayName}\" depends on \"${dependencyName}\" but it is missing a name or version.`);\n }\n\n let dependencyImporterContext: PackageImporterContext | undefined;\n const versionRequirement = dependencies[dependencyName];\n if (versionRequirement && definition.name && definition.version) {\n dependencyImporterContext = {\n parentName: definition.name,\n parentVersion: definition.version,\n importedName: dependencyName,\n versionRequirement,\n };\n }\n\n // Make sure to add the package to the list of packages to evaluate.\n pathsToEvaluate.set(dependencyPath, dependencyImporterContext);\n\n // Get the flattened bundle-able exports map for this dependency and iterate through our import paths to ensure nothing is missing.\n const exports = await getExportsMap({ packagePath: dependencyPath }, { packages, config });\n const flattenedExports = flattenExportsMap(exports);\n const packageSettings = (config.generated.packageSettings ??= []);\n let generatedPackageSettings: PackageSettings | undefined;\n // iterate through all the import paths.\n for (const dependencyImportPath of dependencyImportPaths) {\n if (flattenedExports[dependencyImportPath]) {\n continue;\n }\n\n // We are missing an import path. We need to add this entry to the exports map in package settings.\n generatedPackageSettings ??= getPackageSettings({\n config: { generated: { packageSettings } },\n name,\n version,\n firstMatch: true,\n }).generatedPackageSettings;\n\n if (!generatedPackageSettings) {\n if (isExternalPackage(dependencyPath)) {\n generatedPackageSettings = {\n match: { name, version: `^${version}` },\n exports: {},\n };\n } else {\n generatedPackageSettings = {\n match: name,\n exports: {},\n };\n }\n packageSettings.push(generatedPackageSettings);\n }\n\n generatedPackageSettings.exports ??= {};\n\n const addedEntry = await addExportsMapEntry(\n {\n exports: generatedPackageSettings.exports,\n packagePath: dependencyPath,\n importPath: dependencyImportPath,\n },\n { packages, config },\n );\n\n if (addedEntry) {\n exportsChanges.push({\n name: dependencyName,\n version: dependencyDefinition.version || '',\n path: dependencyPath,\n changes: [\n {\n type: 'added-export',\n change: dependencyImportPath,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n\n // Since we've found a missing export, we need to re-enqueue the dependency for evaluation.\n pathsToRefresh.add(dependencyPath);\n } else {\n const text =\n `An import couldn't be resolved to a physical file. ` +\n `Check that the import refers to a file that's exported by the package or adjust the \"${cyan(\n dependencyName,\n )}\" package version to one that supports this import path.\\n${bulletedList(\n [\n `Import: ${cyan(dependencyImportPath.replace('.', dependencyName))}`,\n `Resolved to: ${dependencyName}@${version} (${dependencyImportPath})`,\n ],\n 2,\n )}`;\n errors.push({\n text,\n source: 'evaluate imports',\n location: { file: packagePath, line: 1, column: 0 },\n });\n }\n }\n }\n\n return { exportsChanges, includedDependenciesChanges, errors, warnings, pathsToEvaluate, pathsToRefresh };\n}\n\nfunction getMissingDepMessage(params: {\n dependencyName: string;\n displayName: string;\n issueType: 'not-found' | 'undeclared';\n packagePath: string;\n}): BundleMessage {\n const { dependencyName, displayName, issueType, packagePath } = params;\n\n let text: string;\n if (isBuiltin(dependencyName)) {\n text =\n `The node built-in \"${dependencyName}\" is being imported by \"${displayName}\", ` +\n `but no browser-friendly version was found in the package's dependencies. ` +\n `This can be fixed by forcing \"${displayName}\" to use \"bundlerType\": \"rollup\" in package settings, ` +\n `or by adding a polyfill browser-friendly dependency.`;\n } else {\n text = `The package \"${dependencyName}\" is imported by \"${displayName}\", but ${\n issueType === 'not-found' ? \"it couldn't be found\" : \"it's not included in the package's dependencies\"\n }. Please ensure that \"${dependencyName}\" is listed in the dependencies of \"${displayName}\"${\n issueType === 'undeclared' ? ` or add it to \"includedDependencies\" for \"${displayName}\" in package settings.` : ''\n }.`;\n }\n\n return {\n text,\n source: 'evaluate imports',\n location: { file: path.join(packagePath, 'package.json'), line: 1, column: 0 },\n };\n}\n"]}
1
+ {"version":3,"file":"evaluateImportsForOverrides.js","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAG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AC9B,IAAI;YACF,sBAAsB,cAAc,2BAA2B,WAAW,KAAK;gBAC/E,2EAA2E;gBAC3E,iCAAiC,WAAW,wDAAwD;gBACpG,sDAAsD,CAAC;IAC3D,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,gBAAgB,cAAc,qBAAqB,WAAW,UACnE,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,iDACvD,yBAAyB,cAAc,uCAAuC,WAAW,IACvF,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,6CAA6C,WAAW,wBAAwB,CAAC,CAAC,CAAC,EAClH,GAAG,CAAC;IACN,CAAC;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,kBAAkB;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,EAAE;KAC3D,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleInfo } from '@ms-cloudpack/api-server';\nimport type {\n BundleMessage,\n CloudpackConfig,\n PackageDefinitionsCache,\n PackageImporterContext,\n PackageJson,\n PackageSettings,\n} from '@ms-cloudpack/common-types';\nimport { getPackageSettings } from '@ms-cloudpack/config';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport {\n addExportsMapEntry,\n findResolveMapEntry,\n flattenExportsMap,\n getDependencies,\n getUnusedDependencies,\n getExportsMap,\n isExternalPackage,\n} from '@ms-cloudpack/package-utilities';\nimport { bulletedList, cyan } from '@ms-cloudpack/task-reporter';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport { isBuiltin } from 'module';\nimport { getConsumedPaths } from '@ms-cloudpack/api-server';\nimport { neverExclude } from './neverExclude.js';\nimport path from 'path';\n\n/**\n * Evaluate the imports depended on by a package to determine if missing exports map paths need to be added.\n * If so, updates package overrides in the config.\n */\nexport async function evaluateImportsForOverrides(options: {\n packages: PackageDefinitionsCache;\n info: BundleInfo;\n definition: PackageJson;\n packagePath: string;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n importerContext: PackageImporterContext | undefined;\n}): Promise<{\n /** Export changes made to the generated config */\n exportsChanges: GeneratedPackageChanges[];\n /** Included dependencies changes made to the generated config */\n includedDependenciesChanges: GeneratedPackageChanges[];\n /** Any errors encountered */\n errors: BundleMessage[];\n /** Any warnings generated */\n warnings: BundleMessage[];\n /** Map from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate: Map<string, PackageImporterContext | undefined>;\n /** Package paths for which new exports were added, so the package should be re-processed. */\n pathsToRefresh: Set<string>;\n}> {\n const { packages, info, definition, packagePath, config, resolveMap, importerContext } = options;\n\n const { name: packageName, version: packageVersion } = definition;\n const displayName = `${packageName}@${packageVersion}`;\n if (!packageName || !packageVersion) {\n throw new Error(`Package \"${displayName}\" is missing a name or version.`);\n }\n\n const exportsChanges: GeneratedPackageChanges[] = [];\n const includedDependenciesChanges: GeneratedPackageChanges[] = [];\n const errors: BundleMessage[] = [];\n const warnings: BundleMessage[] = [];\n const pathsToEvaluate = new Map<string, PackageImporterContext | undefined>();\n const pathsToRefresh = new Set<string>();\n const dependencies = getDependencies(definition);\n const unusedDependencies = getUnusedDependencies(definition);\n const consumedPaths = getConsumedPaths(info);\n\n // Iterate through imports and find their path from the resolve map.\n for (const [dependencyName, dependencyImportPaths] of Object.entries(consumedPaths)) {\n const resolveEntry = findResolveMapEntry({ definition, packageName: dependencyName, resolveMap });\n const dependencyPath = resolveEntry?.path;\n const dependencyDefinition = dependencyPath ? await packages.get(dependencyPath) : undefined;\n\n // If the dependency is not resolved, add an error.\n if (!dependencyPath || !dependencyDefinition) {\n errors.push(getMissingDepMessage({ dependencyName, displayName, issueType: 'not-found', packagePath }));\n // If the dependency is not resolved, we can't continue to evaluate it.\n continue;\n }\n\n // If the dependency is not listed, add to includedDependencies.\n if (!dependencies[dependencyName] && dependencyName !== definition.name && !neverExclude(dependencyName, config)) {\n // Survive from the case where it is not a dependency in the package.json\n // and it is resolvable, but warn the user.\n if (!unusedDependencies[dependencyName]) {\n warnings.push(getMissingDepMessage({ dependencyName, displayName, issueType: 'undeclared', packagePath }));\n }\n // Make sure to add the package to the list of packages to evaluate.\n pathsToEvaluate.set(packagePath, importerContext);\n\n // Add to includedDependencies\n const packageSettings = (config.generated.packageSettings ??= []);\n let { generatedPackageSettings } = getPackageSettings({\n config: { generated: { packageSettings } },\n name: packageName,\n version: packageVersion,\n firstMatch: true,\n });\n\n if (!generatedPackageSettings) {\n generatedPackageSettings = {\n match: isExternalPackage(packagePath) ? { name: packageName, version: `^${packageVersion}` } : packageName,\n };\n packageSettings.push(generatedPackageSettings);\n }\n\n generatedPackageSettings.includedDependencies ??= [];\n\n // Add to includedDependencies if it is not already included.\n if (!generatedPackageSettings.includedDependencies.includes(dependencyName)) {\n generatedPackageSettings.includedDependencies.push(dependencyName);\n\n includedDependenciesChanges.push({\n name: packageName,\n version: packageVersion,\n path: packagePath,\n changes: [\n {\n type: 'included-dependency',\n change: dependencyName,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n\n pathsToRefresh.add(packagePath);\n }\n }\n\n const { name, version } = dependencyDefinition as Required<PackageJson>;\n if (!name || !version) {\n throw new Error(`Package \"${displayName}\" depends on \"${dependencyName}\" but it is missing a name or version.`);\n }\n\n let dependencyImporterContext: PackageImporterContext | undefined;\n const versionRequirement = dependencies[dependencyName];\n if (versionRequirement && definition.name && definition.version) {\n dependencyImporterContext = {\n parentName: definition.name,\n parentVersion: definition.version,\n importedName: dependencyName,\n versionRequirement,\n };\n }\n\n // Make sure to add the package to the list of packages to evaluate.\n pathsToEvaluate.set(dependencyPath, dependencyImporterContext);\n\n // Get the flattened bundle-able exports map for this dependency and iterate through our import paths to ensure nothing is missing.\n const exports = await getExportsMap({ packagePath: dependencyPath }, { packages, config });\n const flattenedExports = flattenExportsMap(exports);\n const packageSettings = (config.generated.packageSettings ??= []);\n let generatedPackageSettings: PackageSettings | undefined;\n // iterate through all the import paths.\n for (const dependencyImportPath of dependencyImportPaths) {\n if (flattenedExports[dependencyImportPath]) {\n continue;\n }\n\n // We are missing an import path. We need to add this entry to the exports map in package settings.\n generatedPackageSettings ??= getPackageSettings({\n config: { generated: { packageSettings } },\n name,\n version,\n firstMatch: true,\n }).generatedPackageSettings;\n\n if (!generatedPackageSettings) {\n if (isExternalPackage(dependencyPath)) {\n generatedPackageSettings = {\n match: { name, version: `^${version}` },\n exports: {},\n };\n } else {\n generatedPackageSettings = {\n match: name,\n exports: {},\n };\n }\n packageSettings.push(generatedPackageSettings);\n }\n\n generatedPackageSettings.exports ??= {};\n\n const addedEntry = await addExportsMapEntry(\n {\n exports: generatedPackageSettings.exports,\n packagePath: dependencyPath,\n importPath: dependencyImportPath,\n },\n { packages, config },\n );\n\n if (addedEntry) {\n exportsChanges.push({\n name: dependencyName,\n version: dependencyDefinition.version || '',\n path: dependencyPath,\n changes: [\n {\n type: 'added-export',\n change: dependencyImportPath,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n\n // Since we've found a missing export, we need to re-enqueue the dependency for evaluation.\n pathsToRefresh.add(dependencyPath);\n } else {\n const text =\n `An import couldn't be resolved to a physical file. ` +\n `Check that the import refers to a file that's exported by the package or adjust the \"${cyan(\n dependencyName,\n )}\" package version to one that supports this import path.\\n${bulletedList(\n [\n `Import: ${cyan(dependencyImportPath.replace('.', dependencyName))}`,\n `Resolved to: ${dependencyName}@${version} (${dependencyImportPath})`,\n ],\n 2,\n )}`;\n errors.push({\n text,\n source: 'evaluate imports',\n location: { file: packagePath },\n });\n }\n }\n }\n\n return { exportsChanges, includedDependenciesChanges, errors, warnings, pathsToEvaluate, pathsToRefresh };\n}\n\nfunction getMissingDepMessage(params: {\n dependencyName: string;\n displayName: string;\n issueType: 'not-found' | 'undeclared';\n packagePath: string;\n}): BundleMessage {\n const { dependencyName, displayName, issueType, packagePath } = params;\n\n let text: string;\n if (isBuiltin(dependencyName)) {\n text =\n `The node built-in \"${dependencyName}\" is being imported by \"${displayName}\", ` +\n `but no browser-friendly version was found in the package's dependencies. ` +\n `This can be fixed by forcing \"${displayName}\" to use \"bundlerType\": \"rollup\" in package settings, ` +\n `or by adding a polyfill browser-friendly dependency.`;\n } else {\n text = `The package \"${dependencyName}\" is imported by \"${displayName}\", but ${\n issueType === 'not-found' ? \"it couldn't be found\" : \"it's not included in the package's dependencies\"\n }. Please ensure that \"${dependencyName}\" is listed in the dependencies of \"${displayName}\"${\n issueType === 'undeclared' ? ` or add it to \"includedDependencies\" for \"${displayName}\" in package settings.` : ''\n }.`;\n }\n\n return {\n text,\n source: 'evaluate imports',\n location: { file: path.join(packagePath, 'package.json') },\n };\n}\n"]}
@@ -21,6 +21,11 @@ export declare function evaluatePath(options: {
21
21
  initOptions: InitOptions;
22
22
  summaryData: InitSummaryData;
23
23
  ctx: EnsurePackageBundledContext;
24
+ /** Whether init is running in a multi-app scenario. */
25
+ isMultiApp: boolean;
26
+ shouldForce: boolean;
27
+ /** The priority of the package being evaluated. To be used in the task runner. */
28
+ priority: number;
24
29
  }): Promise<{
25
30
  /** Map from new package path (to be evaluated) to info about the parent. */
26
31
  pathsToEvaluate?: Map<string, PackageImporterContext | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"evaluatePath.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAM1D;;;;GAIG;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AM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;IACjC,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,eAAe,CAAC;IAC7B,GAAG,EAAE,2BAA2B,CAAC;IACjC,uDAAuD;IACvD,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,kFAAkF;IAClF,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC;IACV,4EAA4E;IAC5E,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC,CAAC;IAClE,6FAA6F;IAC7F,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,6CAA6C;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC,CAoHD"}
@@ -7,7 +7,7 @@ import { optimizeDependencies } from './optimizeDependencies.js';
7
7
  * in the generated config.
8
8
  */
9
9
  export async function evaluatePath(options) {
10
- const { packagePath, config, initOptions, telemetryClient, resolveMap, summaryData, ctx, importerContext } = options;
10
+ const { packagePath, config, initOptions, telemetryClient, resolveMap, summaryData, ctx, importerContext, shouldForce, isMultiApp, priority, } = options;
11
11
  const { packages } = ctx;
12
12
  const { features } = config;
13
13
  // This line is the reason we have to track the importerContext for packages to evaluate:
@@ -26,18 +26,21 @@ export async function evaluatePath(options) {
26
26
  version,
27
27
  isIncremental: false,
28
28
  shouldGetBundleInfo: true,
29
- useHashAsId: true,
29
+ shouldForce,
30
+ shouldRerun: shouldForce,
31
+ useHashAsId: isMultiApp,
32
+ priority,
30
33
  },
31
34
  ctx,
32
35
  });
33
- const { errors, warnings, info } = result;
36
+ const { errors, warnings, info, outputPath } = result;
34
37
  // Record the results for the summary.
35
38
  const resultIdentifier = {
36
39
  name: definition.name || '',
37
40
  version: definition.version || '',
38
41
  path: packagePath,
39
42
  };
40
- summaryData.recordResult({ packageResult: { ...resultIdentifier, errors, warnings, info } });
43
+ summaryData.recordResult({ packageResult: { ...resultIdentifier, errors, warnings, info, outputPath } });
41
44
  // If there were errors or no imports, return early.
42
45
  if (errors?.length || !info) {
43
46
  return {};
@@ -1 +1 @@
1
- {"version":3,"file":"evaluatePath.js","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAYlC;IAQC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IACrH,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;IACzB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAE5B,yFAAyF;IACzF,+FAA+F;IAC/F,kGAAkG;IAClG,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;IACvF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,IAAI,EAAE,CAAC;IAE3C,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACrC,yGAAyG;QACzG,MAAM,IAAI,KAAK,CACb,GAAG,WAAW,gGAAgG,CAC/G,CAAC;IACJ,CAAC;IAED,yDAAyD;IACzD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,oBAAoB,CAAC;QAC5C,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;YACP,aAAa,EAAE,KAAK;Y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,oBAAoB,CACtD,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,EAC7C,EAAE,QAAQ,EAAE,MAAM,EAAE,CACrB,CAAC;QACF,WAAW,CAAC,sBAAsB,CAAC,2BAA2B,CAAC,CAAC;IAClE,CAAC;IAED,iGAAiG;IACjG,6EAA6E;IAC7E,wFAAwF;IACxF,qEAAqE;IAErE,IAAI,WAAW,CAAC,KAAK,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACtE,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,EAAE;YACrD,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SACvF,CAAC,CAAC;QAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,eAAe;QACf,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import type { EnsurePackageBundledContext } from '@ms-cloudpack/api-server';\nimport type { CloudpackConfig, PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport type { InitOptions } from './types/InitOptions.js';\n\nimport { ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport { optimizeDependencies } from './optimizeDependencies.js';\n\n/**\n * A helper which given the packagePath, tries to evaluate the path by bundling things, finding imports,\n * and cross checking the imports with explicit exports. If any exports are missing, they are documented\n * in the generated config.\n */\nexport async function evaluatePath(options: {\n /** Path to evaluate. */\n packagePath: string;\n /** Info about how the parent package */\n importerContext: PackageImporterContext | undefined;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n telemetryClient: TelemetryClient;\n initOptions: InitOptions;\n summaryData: InitSummaryData;\n ctx: EnsurePackageBundledContext;\n}): Promise<{\n /** Map from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate?: Map<string, PackageImporterContext | undefined>;\n /** Package paths for which new exports were added, so the package should be re-processed. */\n pathsToRefresh?: Set<string>;\n /** Whether a fatal error was encountered. */\n shouldExit?: boolean;\n}> {\n const { packagePath, config, initOptions, telemetryClient, resolveMap, summaryData, ctx, importerContext } = options;\n const { packages } = ctx;\n const { features } = config;\n\n // This line is the reason we have to track the importerContext for packages to evaluate:\n // otherwise if a non-semver package is read here, we'd lose the modifications from the initial\n // time the package was read (and getNonSemverTransform was called) when building the resolve map.\n const definition = await packages.get(packagePath, { refresh: true, importerContext });\n const { name, version } = definition || {};\n\n if (!definition || !name || !version) {\n // Unsure why a package would be missing a definition/name/version - we've built the resolve map already.\n throw new Error(\n `${packagePath} evaluation failed because the package.json with a name/version was not found or not readable.`,\n );\n }\n\n // Bundle the package and find the imports it depends on.\n const { result } = await ensurePackageBundled({\n input: {\n name,\n version,\n isIncremental: false,\n shouldGetBundleInfo: true,\n useHashAsId: true,\n },\n ctx,\n });\n\n const { errors, warnings, info } = result;\n\n // Record the results for the summary.\n const resultIdentifier = {\n name: definition.name || '',\n version: definition.version || '',\n path: packagePath,\n };\n\n summaryData.recordResult({ packageResult: { ...resultIdentifier, errors, warnings, info } });\n\n // If there were errors or no imports, return early.\n if (errors?.length || !info) {\n return {};\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const {\n exportsChanges,\n includedDependenciesChanges,\n errors: evalErrors,\n pathsToEvaluate,\n pathsToRefresh,\n } = await evaluateImportsForOverrides({\n definition,\n packagePath,\n packages,\n info,\n config,\n resolveMap,\n importerContext,\n });\n\n if (evalErrors.length) {\n summaryData.recordResult({\n packageResult: { ...resultIdentifier, errors: evalErrors },\n append: true,\n });\n }\n summaryData.recordGeneratedChanges(exportsChanges);\n summaryData.recordGeneratedChanges(includedDependenciesChanges);\n\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 if (features?.optimizeDependencies) {\n const excludedDependenciesChanges = optimizeDependencies(\n { definition, packagePath, info, resolveMap },\n { packages, config },\n );\n summaryData.recordGeneratedChanges(excludedDependenciesChanges);\n }\n\n // Uncomment this when #1694 init does not cache packages correctly after editing config is fixed\n // and the heap does not reach the limit as almost every package is enqueued.\n // importPathsToEvaluate?.forEach((path) => pathsToEvaluate.set(path, importerContext));\n // importPathsToRefresh?.forEach((path) => pathsToRefresh.add(path));\n\n if (initOptions.check && (exportsChanges.length || evalErrors.length)) {\n telemetryClient.rootSpan.addEvent('INIT_CHECK_FAILED', {\n reason: exportsChanges ? 'Config needs to be updated.' : evalErrors.map((e) => e.text),\n });\n\n return { shouldExit: true };\n }\n\n return {\n pathsToEvaluate,\n pathsToRefresh,\n };\n}\n"]}
1
+ {"version":3,"file":"evaluatePath.js","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAiBlC;IAQC,MAAM,EACJ,WAAW,EACX,MAAM,EACN,WAAW,EACX,eAAe,EACf,UAAU,EACV,WAAW,EACX,GAAG,EACH,eAAe,EACf,WAAW,EACX,UAAU,EACV,QAAQ,GACT,GAAG,OAAO,CAAC;IACZ,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;IACzB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAE5B,yFAAyF;IACz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L,eAAe;QACf,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import type { EnsurePackageBundledContext } from '@ms-cloudpack/api-server';\nimport type { CloudpackConfig, PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport type { InitOptions } from './types/InitOptions.js';\n\nimport { ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport { optimizeDependencies } from './optimizeDependencies.js';\n\n/**\n * A helper which given the packagePath, tries to evaluate the path by bundling things, finding imports,\n * and cross checking the imports with explicit exports. If any exports are missing, they are documented\n * in the generated config.\n */\nexport async function evaluatePath(options: {\n /** Path to evaluate. */\n packagePath: string;\n /** Info about how the parent package */\n importerContext: PackageImporterContext | undefined;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n telemetryClient: TelemetryClient;\n initOptions: InitOptions;\n summaryData: InitSummaryData;\n ctx: EnsurePackageBundledContext;\n /** Whether init is running in a multi-app scenario. */\n isMultiApp: boolean;\n shouldForce: boolean;\n /** The priority of the package being evaluated. To be used in the task runner. */\n priority: number;\n}): Promise<{\n /** Map from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate?: Map<string, PackageImporterContext | undefined>;\n /** Package paths for which new exports were added, so the package should be re-processed. */\n pathsToRefresh?: Set<string>;\n /** Whether a fatal error was encountered. */\n shouldExit?: boolean;\n}> {\n const {\n packagePath,\n config,\n initOptions,\n telemetryClient,\n resolveMap,\n summaryData,\n ctx,\n importerContext,\n shouldForce,\n isMultiApp,\n priority,\n } = options;\n const { packages } = ctx;\n const { features } = config;\n\n // This line is the reason we have to track the importerContext for packages to evaluate:\n // otherwise if a non-semver package is read here, we'd lose the modifications from the initial\n // time the package was read (and getNonSemverTransform was called) when building the resolve map.\n const definition = await packages.get(packagePath, { refresh: true, importerContext });\n const { name, version } = definition || {};\n\n if (!definition || !name || !version) {\n // Unsure why a package would be missing a definition/name/version - we've built the resolve map already.\n throw new Error(\n `${packagePath} evaluation failed because the package.json with a name/version was not found or not readable.`,\n );\n }\n\n // Bundle the package and find the imports it depends on.\n const { result } = await ensurePackageBundled({\n input: {\n name,\n version,\n isIncremental: false,\n shouldGetBundleInfo: true,\n shouldForce,\n shouldRerun: shouldForce,\n useHashAsId: isMultiApp,\n priority,\n },\n ctx,\n });\n\n const { errors, warnings, info, outputPath } = result;\n\n // Record the results for the summary.\n const resultIdentifier = {\n name: definition.name || '',\n version: definition.version || '',\n path: packagePath,\n };\n\n summaryData.recordResult({ packageResult: { ...resultIdentifier, errors, warnings, info, outputPath } });\n\n // If there were errors or no imports, return early.\n if (errors?.length || !info) {\n return {};\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const {\n exportsChanges,\n includedDependenciesChanges,\n errors: evalErrors,\n pathsToEvaluate,\n pathsToRefresh,\n } = await evaluateImportsForOverrides({\n definition,\n packagePath,\n packages,\n info,\n config,\n resolveMap,\n importerContext,\n });\n\n if (evalErrors.length) {\n summaryData.recordResult({\n packageResult: { ...resultIdentifier, errors: evalErrors },\n append: true,\n });\n }\n summaryData.recordGeneratedChanges(exportsChanges);\n summaryData.recordGeneratedChanges(includedDependenciesChanges);\n\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 if (features?.optimizeDependencies) {\n const excludedDependenciesChanges = optimizeDependencies(\n { definition, packagePath, info, resolveMap },\n { packages, config },\n );\n summaryData.recordGeneratedChanges(excludedDependenciesChanges);\n }\n\n // Uncomment this when #1694 init does not cache packages correctly after editing config is fixed\n // and the heap does not reach the limit as almost every package is enqueued.\n // importPathsToEvaluate?.forEach((path) => pathsToEvaluate.set(path, importerContext));\n // importPathsToRefresh?.forEach((path) => pathsToRefresh.add(path));\n\n if (initOptions.check && (exportsChanges.length || evalErrors.length)) {\n telemetryClient.rootSpan.addEvent('INIT_CHECK_FAILED', {\n reason: exportsChanges ? 'Config needs to be updated.' : evalErrors.map((e) => e.text),\n });\n\n return { shouldExit: true };\n }\n\n return {\n pathsToEvaluate,\n pathsToRefresh,\n };\n}\n"]}
@@ -1,11 +1,13 @@
1
1
  import type { InitOptions } from './types/InitOptions.js';
2
2
  import type { InitSummary } from './types/InitSummary.js';
3
- /**
4
- * Given an init summary and init options, returns a formatted string message to display to the user via console.
5
- */
6
- export declare function formatInitSummary(params: {
3
+ interface FormatInitSummaryParams {
7
4
  summaries: InitSummary[];
8
5
  options: InitOptions;
9
6
  isInterrupted?: boolean;
10
- }): string;
7
+ }
8
+ /**
9
+ * Given init summaries and init options, returns a formatted string message to display to the user via console.
10
+ */
11
+ export declare function formatInitSummary(params: FormatInitSummaryParams): string;
12
+ export {};
11
13
  //# sourceMappingURL=formatInitSummary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatInitSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,WAAW,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,UAoHpH"}
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;AAG1D,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,UAUhE"}
@@ -1,92 +1,117 @@
1
- import { bold, bulletedList, cyan, green, lightCyan, plural, red, yellow, formatTime, statusCharacter, } from '@ms-cloudpack/task-reporter';
1
+ import { bold, bulletedList, cyan, formatTime, green, indent, lightCyan, plural, red, statusCharacter, yellow, } from '@ms-cloudpack/task-reporter';
2
2
  import { formatLocation } from '@ms-cloudpack/path-utilities';
3
3
  /**
4
- * Given an init summary and init options, returns a formatted string message to display to the user via console.
4
+ * Given init summaries and init options, returns a formatted string message to display to the user via console.
5
5
  */
6
6
  export function formatInitSummary(params) {
7
7
  const { summaries, options, isInterrupted } = params;
8
- const summaryString = [];
9
8
  const isMultiApp = summaries.length > 1;
10
- for (const summary of summaries) {
11
- const { totalPackages, totalErrors, totalWarnings, totalChanges, totalRequiredChanges, packagesWithErrors, packagesWithWarnings, generatedFileUpdates, } = summary;
12
- const { check } = options;
13
- const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;
14
- // Report the "Summary" title if no errors or warnings are listed (seems redundant otherwise.
15
- if ((!packagesWithErrors.length && !packagesWithWarnings.length) || isMultiApp) {
16
- summaryString.push(bold(`==== Summary for ${summary.appPath}${incompleteText} ====`));
17
- }
18
- if (!isMultiApp) {
19
- // If there are required changes, updates will be "made" or "needed" with check,
20
- // else if the changes are not required, only report work done when updates are "made" (check is disabled).
21
- const updatesRequired = totalRequiredChanges || (totalChanges && !check);
22
- // Report work done to the generated file.
23
- if (!packagesWithErrors.length && updatesRequired) {
24
- summaryString.push(`Updates ${check || isInterrupted ? 'needed for' : 'made to'} ${cyan(`cloudpack.generated.json`)}:\n`);
25
- for (const packageUpdates of generatedFileUpdates) {
26
- const exportsUpdates = packageUpdates.changes.filter((u) => u.type === 'added-export');
27
- if (exportsUpdates.length) {
28
- summaryString.push(`${formatPackageName(packageUpdates)} - ${yellow(plural(exportsUpdates.length, 'path'))} missing from exports map`);
29
- summaryString.push(bulletedList(exportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ``}`)), '');
30
- }
31
- }
32
- }
33
- // Report packages with warnings.
34
- if (packagesWithWarnings.length) {
35
- summaryString.push(`${plural(packagesWithWarnings.length, 'package')} with ${yellow('warnings')}:\n`);
36
- let currentCount = 1;
37
- for (const packageWithWarnings of packagesWithWarnings) {
38
- summaryString.push(`${yellow(`${statusCharacter.warn} ${currentCount++}.`)} ${formatPackageName(packageWithWarnings)} - ${yellow(plural(packageWithWarnings.warnings.length, 'warning'))}, ${packageWithWarnings.path}:`);
39
- summaryString.push(formatBundleMessages(packageWithWarnings, false), '');
40
- }
41
- }
42
- }
43
- // Report packages with errors.
44
- if (packagesWithErrors.length) {
45
- summaryString.push(`${plural(packagesWithErrors.length, 'package')} ${red('failed')}:\n`);
46
- let currentCount = 1;
47
- for (const packageWithErrors of packagesWithErrors) {
48
- summaryString.push(`${red(`${statusCharacter.fail} ${currentCount++}.`)} ${formatPackageName(packageWithErrors)} - ${red(plural(packageWithErrors.errors.length, 'error'))}, ${packageWithErrors.path}:`);
49
- summaryString.push(formatBundleMessages(packageWithErrors, true), '');
50
- }
9
+ return (summaries
10
+ .map((summary) => formatSummary({ summary, options, isInterrupted, isMultiApp }))
11
+ .join('\n')
12
+ // replace >= 3 newlines with 2 newlines
13
+ .replace(/\n{3,}/g, '\n\n'));
14
+ }
15
+ /** Format a single app's init summary. */
16
+ function formatSummary(params) {
17
+ const { summary, options, isInterrupted, isMultiApp } = params;
18
+ const summaryString = [];
19
+ const { totalPackages, totalErrors, totalWarnings, totalChanges, totalRequiredChanges, packagesWithErrors, packagesWithWarnings, generatedFileUpdates, } = summary;
20
+ const { check } = options;
21
+ const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;
22
+ // Report the "Summary" title if no errors or warnings are listed (seems redundant otherwise.
23
+ if ((!packagesWithErrors.length && !packagesWithWarnings.length) || isMultiApp) {
24
+ summaryString.push(bold(`==== Summary for ${summary.appPath}${incompleteText} ====`));
25
+ }
26
+ if (!isMultiApp) {
27
+ // If there are required changes, updates will be "made" or "needed" with check,
28
+ // else if the changes are not required, only report work done when updates are "made" (check is disabled).
29
+ const updatesRequired = totalRequiredChanges || (totalChanges && !check);
30
+ // Report exports that were or should be added to the generated config.
31
+ if (!packagesWithErrors.length && updatesRequired) {
32
+ summaryString.push(formatAddedExports({ generatedFileUpdates, check }));
51
33
  }
52
- const blockingIssueCount = packagesWithErrors.length || 0;
53
- const requiresChanges = (check && totalRequiredChanges) || 0;
54
- // Add summary.
55
- summaryString.push(`${cyan(plural(totalPackages, 'total package'))} evaluated in ${formatTime(summary.duration)}${incompleteText}:`, bulletedList([
56
- requiresChanges ? `${red(plural(totalRequiredChanges, 'change'))} required` : undefined,
57
- `${green(plural(totalPackages - blockingIssueCount, 'package'))} built successfully${packagesWithWarnings.length
58
- ? ` (${yellow(plural(packagesWithWarnings.length, 'package'))} with warnings)`
59
- : ''}`,
60
- blockingIssueCount ? `${red(plural(blockingIssueCount, 'package'))} failed to build` : undefined,
61
- `Totals: ${totalErrors ? red(plural(totalErrors, 'error')) : '0 errors'}, ${totalWarnings ? yellow(plural(totalWarnings, 'warning')) : '0 warnings'}`,
62
- ].filter(Boolean)));
63
- if (isInterrupted) {
64
- summaryString.push('', yellow(bold('Process was interrupted before all tasks could complete.')));
34
+ // Report packages with warnings.
35
+ if (packagesWithWarnings.length) {
36
+ summaryString.push(formatPackageResults({ results: packagesWithWarnings, issueType: 'warnings' }), '');
65
37
  }
66
- else if (requiresChanges) {
67
- summaryString.push(`Run "${yellow('cloudpack init')}" in your application folder to apply changes to the ${cyan('cloudpack.generated.json')} file.`);
38
+ }
39
+ // Report packages with errors.
40
+ if (packagesWithErrors.length) {
41
+ summaryString.push(formatPackageResults({ results: packagesWithErrors, issueType: 'errors' }), '');
42
+ }
43
+ const blockingIssueCount = packagesWithErrors.length || 0;
44
+ const requiresChanges = (check && totalRequiredChanges) || 0;
45
+ // Add summary.
46
+ summaryString.push(`${cyan(plural(totalPackages, 'total package'))} evaluated in ${formatTime(summary.duration)}${incompleteText}:`, bulletedList([
47
+ requiresChanges ? `${red(plural(totalRequiredChanges, 'change'))} required` : undefined,
48
+ `${green(plural(totalPackages - blockingIssueCount, 'package'))} built successfully${packagesWithWarnings.length
49
+ ? ` (${yellow(plural(packagesWithWarnings.length, 'package'))} with warnings)`
50
+ : ''}`,
51
+ blockingIssueCount ? `${red(plural(blockingIssueCount, 'package'))} failed to build` : undefined,
52
+ `Totals: ${totalErrors ? red(plural(totalErrors, 'error')) : '0 errors'}, ${totalWarnings ? yellow(plural(totalWarnings, 'warning')) : '0 warnings'}`,
53
+ ].filter(Boolean)));
54
+ if (isInterrupted) {
55
+ summaryString.push('', yellow(bold('Process was interrupted before all tasks could complete.')));
56
+ }
57
+ else if (requiresChanges) {
58
+ summaryString.push(`Run "${yellow('cloudpack init')}" in your application folder to apply changes to the ${cyan('cloudpack.generated.json')} file.`);
59
+ }
60
+ summaryString.push('\n');
61
+ return summaryString.join('\n');
62
+ }
63
+ function formatAddedExports(params) {
64
+ const { generatedFileUpdates, check, isInterrupted } = params;
65
+ const summaryString = [];
66
+ for (const packageUpdates of generatedFileUpdates) {
67
+ const exportsUpdates = packageUpdates.changes.filter((u) => u.type === 'added-export');
68
+ if (exportsUpdates.length) {
69
+ const description = plural(exportsUpdates.length, 'path$s missing from exports map');
70
+ summaryString.push(formatPackageHeader({ ...packageUpdates, isError: false, description }), bulletedList(exportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)), '');
68
71
  }
69
- summaryString.push('\n');
70
72
  }
71
- return summaryString.filter((a) => a !== undefined).join('\n');
73
+ if (summaryString.length) {
74
+ summaryString.unshift(`Updates ${check || isInterrupted ? 'needed for' : 'made to'} ${cyan(`cloudpack.generated.json`)}:\n`);
75
+ }
76
+ return summaryString.join('\n');
72
77
  }
73
- /** Helper to format bundle messages. */
74
- function formatBundleMessages(result, formatErrors) {
75
- const messages = [];
76
- const unformattedMessages = (formatErrors ? result.errors : result.warnings) || [];
77
- for (const message of unformattedMessages) {
78
- const { location, text, source } = message;
79
- const issueType = formatErrors ? red('Error') : yellow('Warning');
80
- // Show the whole path so it can be easily opened with ctrl+click.
81
- // NOTE: location.file should be relative to the package path, not the app path.
82
- const filePath = location ? ` - ${formatLocation({ ...location, fromPath: result.path })} -` : '';
83
- messages.push(`${issueType} [${source}]:${filePath} ${text}`);
78
+ /** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */
79
+ function formatPackageResults(params) {
80
+ const { results, issueType } = params;
81
+ if (!results.length) {
82
+ return '';
84
83
  }
85
- return messages.length ? bulletedList(messages) : undefined;
84
+ const isError = issueType === 'errors';
85
+ const color = isError ? red : yellow;
86
+ const statusChar = bold(color(isError ? statusCharacter.error : statusCharacter.warn));
87
+ const summaryString = [bold(color(`${plural(results.length, 'package')} with ${issueType}:`)), ''];
88
+ for (const result of results) {
89
+ const unformattedMessages = result[issueType];
90
+ if (!unformattedMessages?.length) {
91
+ continue;
92
+ }
93
+ const description = plural(unformattedMessages.length, issueType.slice(0, -1) + '$s');
94
+ summaryString.push(formatPackageHeader({ ...result, isError, description }));
95
+ const messages = unformattedMessages.map(({ location, text, source }) => {
96
+ // Show the whole path so it can be easily opened with ctrl+click.
97
+ // NOTE: location.file should be relative to the package path, not the app path.
98
+ const filePath = location ? ` ${formatLocation({ ...location, fromPath: result.path })}` : '';
99
+ // Indent the message for readability.
100
+ return `[${source}]${filePath}\n${color(indent(text, 1))}`;
101
+ });
102
+ summaryString.push(bulletedList(messages, undefined, statusChar), '');
103
+ }
104
+ return summaryString.join('\n');
86
105
  }
87
- /** Helper to format package names. */
88
- function formatPackageName(packageIdentifier) {
89
- const { name, version } = packageIdentifier;
90
- return bold(lightCyan(`${name}@${version || `<no-version>`}`));
106
+ /**
107
+ * Helper to format the header for a list of issues in a package:
108
+ * status character, `name@version`, issue description, package path.
109
+ */
110
+ function formatPackageHeader(params) {
111
+ const { name, version, path: packagePath, description, isError } = params;
112
+ const color = isError ? red : yellow;
113
+ const statusChar = bold(color(isError ? statusCharacter.error : statusCharacter.warn));
114
+ const packageName = bold(lightCyan(`${name}@${version || `<unknown>`}`));
115
+ return `${packageName} - ${packagePath}\n${statusChar} ${bold(color(description))}`;
91
116
  }
92
117
  //# sourceMappingURL=formatInitSummary.js.map
@@ -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,KAAK,EACL,SAAS,EACT,MAAM,EACN,GAAG,EACH,MAAM,EACN,UAAU,EACV,eAAe,GAChB,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAmF;IACnH,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;IACrD,MAAM,aAAa,GAA2B,EAAE,CAAC;IACjD,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAExC,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;QAChC,MAAM,EACJ,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,GACrB,GAAG,OAAO,CAAC;QACZ,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAC1B,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAElE,6FAA6F;QAC7F,IAAI,CAAC,CAAC,kBAAkB,CAAC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CAAC,IAAI,CAAC,GAAG,SAAS,KAAK,MAAM,KAAK,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9D,CAAC;AAED,sCAAsC;AACtC,SAAS,iBAAiB,CAAC,iBAAwC;IACjE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC;IAE5C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,cAAc,EAAE,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import {\n bold,\n bulletedList,\n cyan,\n green,\n lightCyan,\n plural,\n red,\n yellow,\n formatTime,\n statusCharacter,\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';\n\n/**\n * Given an init summary and init options, returns a formatted string message to display to the user via console.\n */\nexport function formatInitSummary(params: { summaries: InitSummary[]; options: InitOptions; isInterrupted?: boolean }) {\n const { summaries, options, isInterrupted } = params;\n const summaryString: (string | undefined)[] = [];\n const isMultiApp = summaries.length > 1;\n\n for (const summary of summaries) {\n const {\n totalPackages,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates,\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 (!isMultiApp) {\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 work done to the generated file.\n if (!packagesWithErrors.length && updatesRequired) {\n summaryString.push(\n `Updates ${check || isInterrupted ? 'needed for' : 'made to'} ${cyan(`cloudpack.generated.json`)}:\\n`,\n );\n\n for (const packageUpdates of generatedFileUpdates) {\n const exportsUpdates = packageUpdates.changes.filter((u) => u.type === 'added-export');\n\n if (exportsUpdates.length) {\n summaryString.push(\n `${formatPackageName(packageUpdates)} - ${yellow(\n plural(exportsUpdates.length, 'path'),\n )} missing from exports map`,\n );\n summaryString.push(\n bulletedList(exportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ``}`)),\n '',\n );\n }\n }\n }\n\n // Report packages with warnings.\n if (packagesWithWarnings.length) {\n summaryString.push(`${plural(packagesWithWarnings.length, 'package')} with ${yellow('warnings')}:\\n`);\n let currentCount = 1;\n\n for (const packageWithWarnings of packagesWithWarnings) {\n summaryString.push(\n `${yellow(`${statusCharacter.warn} ${currentCount++}.`)} ${formatPackageName(packageWithWarnings)} - ${yellow(\n plural(packageWithWarnings.warnings.length, 'warning'),\n )}, ${packageWithWarnings.path}:`,\n );\n summaryString.push(formatBundleMessages(packageWithWarnings as InitPackageResult, false), '');\n }\n }\n }\n\n // Report packages with errors.\n if (packagesWithErrors.length) {\n summaryString.push(`${plural(packagesWithErrors.length, 'package')} ${red('failed')}:\\n`);\n let currentCount = 1;\n for (const packageWithErrors of packagesWithErrors) {\n summaryString.push(\n `${red(`${statusCharacter.fail} ${currentCount++}.`)} ${formatPackageName(packageWithErrors)} - ${red(\n plural(packageWithErrors.errors.length, 'error'),\n )}, ${packageWithErrors.path}:`,\n );\n summaryString.push(formatBundleMessages(packageWithErrors as InitPackageResult, true), '');\n }\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\n return summaryString.filter((a) => a !== undefined).join('\\n');\n}\n\n/** Helper to format bundle messages. */\nfunction formatBundleMessages(result: InitPackageResult, formatErrors: boolean) {\n const messages: string[] = [];\n const unformattedMessages = (formatErrors ? result.errors : result.warnings) || [];\n\n for (const message of unformattedMessages) {\n const { location, text, source } = message;\n const issueType = formatErrors ? red('Error') : yellow('Warning');\n\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 messages.push(`${issueType} [${source}]:${filePath} ${text}`);\n }\n\n return messages.length ? bulletedList(messages) : undefined;\n}\n\n/** Helper to format package names. */\nfunction formatPackageName(packageIdentifier: InitPackageIdentifier) {\n const { name, version } = packageIdentifier;\n\n return bold(lightCyan(`${name}@${version || `<no-version>`}`));\n}\n"]}
1
+ {"version":3,"file":"formatInitSummary.js","sourceRoot":"","sources":["../../../src/commands/init/formatInit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AI,MAAM,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,MAGC;IAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAC1E,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;IACrC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IACvF,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';\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 } = 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 (!isMultiApp) {\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 exports that were or should be added to the generated config.\n if (!packagesWithErrors.length && updatesRequired) {\n summaryString.push(formatAddedExports({ generatedFileUpdates, check }));\n }\n\n // Report packages with warnings.\n if (packagesWithWarnings.length) {\n summaryString.push(formatPackageResults({ results: packagesWithWarnings, issueType: 'warnings' }), '');\n }\n }\n\n // Report packages with errors.\n if (packagesWithErrors.length) {\n summaryString.push(formatPackageResults({ results: packagesWithErrors, issueType: 'errors' }), '');\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 formatAddedExports(\n params: Pick<InitSummary, 'generatedFileUpdates'> &\n Pick<InitOptions, 'check'> &\n Pick<FormatInitSummaryParams, 'isInterrupted'>,\n) {\n const { generatedFileUpdates, check, isInterrupted } = params;\n\n const summaryString: string[] = [];\n\n for (const packageUpdates of generatedFileUpdates) {\n const exportsUpdates = packageUpdates.changes.filter((u) => u.type === 'added-export');\n\n if (exportsUpdates.length) {\n const description = plural(exportsUpdates.length, 'path$s missing from exports map');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, isError: false, description }),\n bulletedList(exportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n }\n\n if (summaryString.length) {\n summaryString.unshift(\n `Updates ${check || isInterrupted ? 'needed for' : 'made to'} ${cyan(`cloudpack.generated.json`)}:\\n`,\n );\n }\n return summaryString.join('\\n');\n}\n\n/** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */\nfunction formatPackageResults(params: { results: InitPackageResult[]; issueType: 'errors' | 'warnings' }) {\n const { results, issueType } = params;\n if (!results.length) {\n return '';\n }\n\n const isError = issueType === 'errors';\n const color = isError ? red : yellow;\n const statusChar = bold(color(isError ? statusCharacter.error : statusCharacter.warn));\n\n const summaryString = [bold(color(`${plural(results.length, 'package')} with ${issueType}:`)), ''];\n\n for (const result of results) {\n const unformattedMessages = result[issueType];\n if (!unformattedMessages?.length) {\n continue;\n }\n\n const description = plural(unformattedMessages.length, issueType.slice(0, -1) + '$s');\n summaryString.push(formatPackageHeader({ ...result, isError, 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\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 isError: boolean;\n },\n) {\n const { name, version, path: packagePath, description, isError } = params;\n const color = isError ? red : yellow;\n const statusChar = bold(color(isError ? statusCharacter.error : statusCharacter.warn));\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.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAI1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMtE;;GAEG;AACH,wBAAsB,IAAI,CAAC,UAAU,EAAE;IACrC,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,YAAY,CAAC;IACvB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC/C,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAoBzB"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAI1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMtE;;GAEG;AACH,wBAAsB,IAAI,CAAC,UAAU,EAAE;IACrC,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,YAAY,CAAC;IACvB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC/C,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAqBzB"}
@@ -22,13 +22,14 @@ export async function init(parameters) {
22
22
  autoDispose,
23
23
  summaryData: appSummaries[appContext.appPath],
24
24
  taskRunner,
25
+ isMultiApp: contexts.length > 1,
25
26
  });
26
27
  summaries.push(summary);
27
28
  }
28
29
  return summaries;
29
30
  }
30
31
  async function initApp(params) {
31
- const { appContext, options, reporter, autoDispose, summaryData, taskRunner } = params;
32
+ const { appContext, options, reporter, autoDispose, summaryData, taskRunner, isMultiApp } = params;
32
33
  const { appPath, config, telemetryClient } = appContext;
33
34
  // Run prerequisites for the app.
34
35
  runPrerequisites({ config, cwd: appPath, telemetryClient });
@@ -52,6 +53,8 @@ async function initApp(params) {
52
53
  let pending = 0;
53
54
  let isExitingPrematurely = false;
54
55
  const visitedSet = new Set();
56
+ const refreshPaths = new Set();
57
+ const priorityMap = new Map();
55
58
  // Start with the app path or requested matches
56
59
  const initialPaths = options.match ? getFilteredPackages(resolveMap, options.match) : [appPath];
57
60
  if (!initialPaths.length) {
@@ -73,6 +76,11 @@ async function initApp(params) {
73
76
  }
74
77
  visitedSet.add(packagePath);
75
78
  pending++;
79
+ const shouldForce = refreshPaths.delete(packagePath);
80
+ // Get the priority value for this package path, defaults to 0.
81
+ const priority = priorityMap.get(packagePath) ?? 0;
82
+ // Lower priority of this package path by 1.
83
+ priorityMap.set(packagePath, priority - 1);
76
84
  // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.
77
85
  evaluatePath({
78
86
  packagePath,
@@ -83,15 +91,23 @@ async function initApp(params) {
83
91
  initOptions: options,
84
92
  summaryData,
85
93
  ctx: apiContext,
94
+ // No need to force if we're in a multi-app scenario
95
+ // as we'll re-evaluate packages if they are different since we use a different task id.
96
+ shouldForce: !isMultiApp && shouldForce,
97
+ isMultiApp,
98
+ priority,
86
99
  })
87
100
  .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {
88
101
  pending--;
89
102
  if (shouldExit) {
90
103
  isExitingPrematurely = true;
91
104
  }
92
- else if (pathsToEvaluate?.size && !options.match) {
93
- // If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them.
105
+ else if (pathsToEvaluate?.size) {
106
+ // If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them
107
+ // and add them to the refresh set so that on re-enqueuing we pass the `shouldRerun` flag through
108
+ // on single app runs.
94
109
  pathsToRefresh?.forEach((refreshPath) => {
110
+ refreshPaths.add(refreshPath);
95
111
  visitedSet.delete(refreshPath);
96
112
  });
97
113
  // Try to enqueue the new paths.
@@ -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;AAOpE,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;AAE7E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,UAU1B;IACC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC;IAE9E,MAAM,SAAS,GAAkB,EAAE,CAAC;IAEpC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;IAEpC,KAAK,MAAM,UAAU,IAAI,QAAQ,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC;YAC5B,UAAU;YACV,OAAO;YACP,QAAQ;YACR,WAAW;YACX,WAAW,EAAE,YAAY,CAAC,U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AAE,eAAe,GAAG,EAAE,EAAmB;IAC/D,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;QACvC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,SAAS;QACX,CAAC;QAED,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAmC,CAAC;QAErE,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CACnC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;aACzB,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CACvC,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { type Context, TaskRunner } from '@ms-cloudpack/api-server';\nimport type { GeneratedConfig, PackageJsonExportsObject, PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\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';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n contexts: AppCommandContext[];\n autoDispose: AutoDispose;\n reporter: TaskReporter;\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, reporter, 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 reporter,\n autoDispose,\n summaryData: appSummaries[appContext.appPath],\n taskRunner,\n });\n summaries.push(summary);\n }\n\n return summaries;\n}\n\nasync function initApp(params: {\n appContext: AppCommandContext;\n options: InitOptions;\n reporter: TaskReporter;\n autoDispose: AutoDispose;\n summaryData: InitSummaryData;\n taskRunner: TaskRunner;\n}): Promise<InitSummary> {\n const { appContext, options, reporter, autoDispose, summaryData, taskRunner } = params;\n const { appPath, config, telemetryClient } = appContext;\n\n // Run prerequisites for the app.\n runPrerequisites({ config, cwd: appPath, telemetryClient });\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 appPath,\n config,\n reporter,\n telemetryClient,\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 await new Promise<void>((resolve, reject) => {\n let pending = 0;\n let isExitingPrematurely = false;\n const visitedSet = new Set<string>();\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 reject(); // getFilteredPackages will log an error\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 continue;\n }\n\n visitedSet.add(packagePath);\n pending++;\n\n // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.\n evaluatePath({\n packagePath,\n importerContext,\n config,\n telemetryClient,\n resolveMap,\n initOptions: options,\n summaryData,\n ctx: apiContext,\n })\n .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {\n pending--;\n\n if (shouldExit) {\n isExitingPrematurely = true;\n } else if (pathsToEvaluate?.size && !options.match) {\n // If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them.\n pathsToRefresh?.forEach((refreshPath) => {\n visitedSet.delete(refreshPath);\n });\n\n // Try to enqueue the new paths.\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 reject(error);\n });\n }\n }\n });\n\n if (config.features?.verifyExports) {\n const packageResults = await verifyExports(summaryData.getResults(), apiContext);\n packageResults.forEach((packageResult) => summaryData.recordResult({ packageResult, append: true }));\n }\n\n const summary = summaryData.summarize(options);\n\n if (!options.check && summary.totalChanges && config.generated.packageSettings?.length) {\n sortExportKeys(config.generated);\n\n await writeGeneratedConfig(config.generated, appPath);\n }\n\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 return summary;\n}\n\nfunction sortExportKeys({ packageSettings = [] }: GeneratedConfig) {\n for (const settings of packageSettings) {\n if (!settings.exports) {\n continue;\n }\n\n const unsortedExports = settings.exports as PackageJsonExportsObject;\n\n settings.exports = Object.fromEntries(\n Object.keys(unsortedExports)\n .sort()\n .map((k) => [k, unsortedExports[k]]),\n );\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;AAOpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,mB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c,CAAC,EAAE,eAAe,GAAG,EAAE,EAAmB;IAC/D,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;QACvC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,SAAS;QACX,CAAC;QAED,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAmC,CAAC;QAErE,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CACnC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;aACzB,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CACvC,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { type Context, TaskRunner } from '@ms-cloudpack/api-server';\nimport type { GeneratedConfig, PackageJsonExportsObject, PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\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';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n contexts: AppCommandContext[];\n autoDispose: AutoDispose;\n reporter: TaskReporter;\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, reporter, 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 reporter,\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 reporter: TaskReporter;\n autoDispose: AutoDispose;\n summaryData: InitSummaryData;\n taskRunner: TaskRunner;\n isMultiApp: boolean;\n}): Promise<InitSummary> {\n const { appContext, options, reporter, autoDispose, summaryData, taskRunner, isMultiApp } = params;\n const { appPath, config, telemetryClient } = appContext;\n\n // Run prerequisites for the app.\n runPrerequisites({ config, cwd: appPath, telemetryClient });\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 appPath,\n config,\n reporter,\n telemetryClient,\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 await new Promise<void>((resolve, reject) => {\n let pending = 0;\n let isExitingPrematurely = false;\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 reject(); // getFilteredPackages will log an error\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 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 packagePath,\n importerContext,\n config,\n telemetryClient,\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 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 reject(error);\n });\n }\n }\n });\n\n if (config.features?.verifyExports) {\n const packageResults = await verifyExports(summaryData.getResults(), apiContext);\n packageResults.forEach((packageResult) => summaryData.recordResult({ packageResult, append: true }));\n }\n\n const summary = summaryData.summarize(options);\n\n if (!options.check && summary.totalChanges && config.generated.packageSettings?.length) {\n sortExportKeys(config.generated);\n\n await writeGeneratedConfig(config.generated, appPath);\n }\n\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 return summary;\n}\n\nfunction sortExportKeys({ packageSettings = [] }: GeneratedConfig) {\n for (const settings of packageSettings) {\n if (!settings.exports) {\n continue;\n }\n\n const unsortedExports = settings.exports as PackageJsonExportsObject;\n\n settings.exports = Object.fromEntries(\n Object.keys(unsortedExports)\n .sort()\n .map((k) => [k, unsortedExports[k]]),\n );\n }\n}\n"]}
@@ -5,5 +5,6 @@ export interface InitPackageResult extends InitPackageIdentifier {
5
5
  errors?: BundleMessage[];
6
6
  warnings?: BundleMessage[];
7
7
  info?: BundleInfo;
8
+ outputPath?: string;
8
9
  }
9
10
  //# sourceMappingURL=InitPackageResult.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InitPackageResult.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB"}
1
+ {"version":3,"file":"InitPackageResult.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"InitPackageResult.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResult.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMessage } from '@ms-cloudpack/common-types';\nimport type { InitPackageIdentifier } from './InitPackageIdentifier.js';\nimport type { BundleInfo } from '@ms-cloudpack/api-server';\n\nexport interface InitPackageResult extends InitPackageIdentifier {\n errors?: BundleMessage[];\n warnings?: BundleMessage[];\n info?: BundleInfo;\n}\n"]}
1
+ {"version":3,"file":"InitPackageResult.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitPackageResult.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMessage } from '@ms-cloudpack/common-types';\nimport type { InitPackageIdentifier } from './InitPackageIdentifier.js';\nimport type { BundleInfo } from '@ms-cloudpack/api-server';\n\nexport interface InitPackageResult extends InitPackageIdentifier {\n errors?: BundleMessage[];\n warnings?: BundleMessage[];\n info?: BundleInfo;\n outputPath?: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"verifyExports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGtE;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACjD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;CAClB,GACA,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAgG9B"}
1
+ {"version":3,"file":"verifyExports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAQ1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAItE;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACjD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;CAClB,GACA,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAgK9B"}
@@ -1,6 +1,7 @@
1
- import { findResolveMapEntry, flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';
1
+ import { findResolveMapEntry, getDependencies, getUnusedDependencies, getSourceEntry, } from '@ms-cloudpack/package-utilities';
2
2
  import path from 'path';
3
- import { bulletedList } from '@ms-cloudpack/task-reporter';
3
+ import { bulletedList, formatPackageName } from '@ms-cloudpack/task-reporter';
4
+ import semver from 'semver';
4
5
  /**
5
6
  * Checks that the imports/exports of packages match.
6
7
  * To be called before `summarize`.
@@ -15,14 +16,24 @@ export async function verifyExports(packageResults, context) {
15
16
  // Iterate through each package
16
17
  for (const [parentPath, parentResult] of Object.entries(packageResults)) {
17
18
  // Skip packages with build errors or no info
18
- if (!parentResult?.info || parentResult.errors?.length) {
19
+ if (!parentResult?.info || !parentResult.outputPath || parentResult.errors?.length) {
19
20
  continue;
20
21
  }
22
+ const parentDefinition = await packages.get(parentPath);
23
+ if (!parentDefinition) {
24
+ throw new Error(`Definition not found for package at path ${parentPath}`);
25
+ }
21
26
  /**
22
27
  * Mapping from imported dependency package ID (`name@version`) to import path
23
- * to export names missing from that file.
28
+ * to an object with export names missing from that file, the importString, and bundledFile.
24
29
  */
25
30
  const depsMissingExports = {};
31
+ const invalidSemver = {};
32
+ // Find the main entry point for the parent package to list as the importing bundle.
33
+ const importingBundle = path.join(parentResult.outputPath, parentResult.info?.['.']?.bundlePath || '');
34
+ // Find the main entry point for the parent package to list as the importing source.
35
+ const sourceMainEntry = await getSourceEntry({ entry: '.', inputPath: parentPath }, { packages, config });
36
+ const importingSource = path.join(parentPath, sourceMainEntry || '.');
26
37
  // Iterate through each entry path from the parent package
27
38
  for (const { consumes } of Object.values(parentResult.info)) {
28
39
  // Skip entries with no imports
@@ -32,14 +43,16 @@ export async function verifyExports(packageResults, context) {
32
43
  // Iterate through each imported package
33
44
  for (const { packageName: depName, importPath: depImportPath, names: consumedNames } of consumes) {
34
45
  const depResolveMapEntry = findResolveMapEntry({ packageName: depName, definition: parentResult, resolveMap });
35
- const depEntries = depResolveMapEntry &&
36
- packageResultsArray.find((r) => r.name === depResolveMapEntry.name && r.version === depResolveMapEntry.version)?.info;
46
+ const depResult = depResolveMapEntry &&
47
+ packageResultsArray.find((r) => r.name === depResolveMapEntry.name && r.version === depResolveMapEntry.version);
48
+ const depEntries = depResult?.info;
49
+ const depOutputPath = depResult?.outputPath;
37
50
  // Skip if we can't find the imported package in the resolve map, or there's no info about
38
51
  // its entries/exports.
39
- if (!depEntries) {
52
+ if (!depResolveMapEntry || !depEntries) {
40
53
  continue;
41
54
  }
42
- const importProduces = (depEntries[depImportPath] || depEntries[`${depImportPath}.js`])?.produces;
55
+ const importProduces = depEntries[depImportPath]?.produces;
43
56
  if (!importProduces || importProduces.includes('*')) {
44
57
  // Skip if the imported package has no entry for the import path, or if the import
45
58
  // produces `*` (everything) since we can't check that. (If the path is missing,
@@ -52,36 +65,68 @@ export async function verifyExports(packageResults, context) {
52
65
  continue;
53
66
  }
54
67
  // Figure out which actual file the exports appear to be missing from.
55
- const depExportsMap = await getExportsMap({ packagePath: depResolveMapEntry.path }, { packages, config });
56
- const depFlattenedExportsMap = flattenExportsMap(depExportsMap);
57
- // If the package is missing an exports map, assume the import path is the real path.
58
- const relativePath = depFlattenedExportsMap[depImportPath] || depImportPath;
68
+ const relativePath = (await getSourceEntry({ entry: depImportPath, inputPath: depResolveMapEntry.path }, { packages, config })) ||
69
+ // If the package is missing an exports map, assume the import path is the real path.
70
+ depImportPath;
59
71
  const filePath = path.join(depResolveMapEntry.path, relativePath);
60
72
  // Save the missing names for this path within the package.
61
73
  const depKey = `${depResolveMapEntry.name}@${depResolveMapEntry.version}`;
62
74
  depsMissingExports[depKey] ??= {};
63
- depsMissingExports[depKey][filePath] ??= new Set();
64
- missing.forEach((m) => depsMissingExports[depKey][filePath].add(m));
75
+ depsMissingExports[depKey][filePath] ??= {
76
+ missingNames: new Set(),
77
+ importName: depName,
78
+ importPath: depImportPath,
79
+ importVersion: depResolveMapEntry.version,
80
+ bundledFile: path.join(depOutputPath ?? '', depEntries[depImportPath]?.bundlePath),
81
+ };
82
+ missing.forEach((m) => depsMissingExports[depKey][filePath].missingNames.add(m));
83
+ // Check if the package satisfies the parent semver requirement.
84
+ const requiredVersion = !invalidSemver[depKey] &&
85
+ (getDependencies(parentDefinition)[depName] || getUnusedDependencies(parentDefinition)[depName]);
86
+ if (requiredVersion && !semver.satisfies(depResolveMapEntry.version, requiredVersion)) {
87
+ invalidSemver[depKey] = requiredVersion;
88
+ }
65
89
  }
66
90
  }
67
91
  const depErrors = Object.entries(depsMissingExports).map(([packageId, missing]) => {
68
92
  // We want a single error for each package, with a bulleted list of files with missing exports.
69
- const missingExportsForFiles = Object.entries(missing).map(([file, names]) => `${file}:\n${[...names].sort().join(', ')}`);
70
- return {
71
- text: `Imported names are missing from exports of external package ${packageId}:\n${bulletedList(missingExportsForFiles)}`,
93
+ const missingExportsForFiles = Object.entries(missing).map(([sourceFile, errorInfo]) => {
94
+ const { missingNames, importName, importPath, importVersion, bundledFile } = errorInfo;
95
+ const error = [
96
+ `Importing bundle: ${importingBundle}`,
97
+ `Importing source: ${importingSource}`,
98
+ `Exporting package: ${formatPackageName({ name: importName, version: importVersion })}${importPath === '.' ? '' : ` (imported path: "${importPath}")`}`,
99
+ `Exporting bundle: ${bundledFile}`,
100
+ `Exporting source: ${sourceFile}`,
101
+ `Missing export(s): { ${Array.from(missingNames).join(', ')} }`,
102
+ ];
103
+ if (!invalidSemver[packageId]) {
104
+ return error;
105
+ }
106
+ // If we have an invalid semver, add a note about that after exporting package.
107
+ const errorIndex = 3;
108
+ return [
109
+ ...error.slice(0, errorIndex),
110
+ `Incompatible version: ${formatPackageName({ name: importName, version: importVersion })} does not satisfy importer requirement "${invalidSemver[packageId]}"`,
111
+ ['If this was unexpected, make sure you installed dependencies after pulling the latest changes.'],
112
+ ...error.slice(errorIndex),
113
+ ];
114
+ });
115
+ return missingExportsForFiles.map((error) => ({
116
+ text: `A bundle imported names from another bundle which were not exported:\n${bulletedList(error)}\n`,
72
117
  source: 'verify exports',
73
118
  // Don't include a whole-message location here because that doesn't make sense for this error type,
74
119
  // and we already put full paths to individual problem files within the message.
75
- };
120
+ }));
76
121
  });
77
- if (depErrors.length) {
122
+ depErrors.forEach((errors) => {
78
123
  allErrors.push({
79
124
  name: parentResult.name,
80
125
  version: parentResult.version,
81
126
  path: parentPath,
82
- errors: depErrors,
127
+ errors,
83
128
  });
84
- }
129
+ });
85
130
  }
86
131
  return allErrors;
87
132
  }
@@ -1 +1 @@
1
- {"version":3,"file":"verifyExports.js","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,cAAiD,EACjD,OAGC;IAED,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,MAAM,mBAAmB,GAAG,MAAM,CAAC,M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AC,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE;YAChF,+FAA+F;YAC/F,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CACxD,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC/D,CAAC;YACF,OAAO;gBACL,IAAI,EAAE,+DAA+D,SAAS,MAAM,YAAY,CAAC,sBAAsB,CAAC,EAAE;gBAC1H,MAAM,EAAE,gBAAgB;gBACxB,mGAAmG;gBACnG,gFAAgF;aACjF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;YACrB,SAAS,CAAC,IAAI,CAAC;gBACb,IAAI,EAAE,YAAY,CAAC,IAAI;gBACvB,OAAO,EAAE,YAAY,CAAC,OAAO;gBAC7B,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,SAAS;aAClB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport { findResolveMapEntry, flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport { bulletedList } from '@ms-cloudpack/task-reporter';\n\n/**\n * Checks that the imports/exports of packages match.\n * To be called before `summarize`.\n * @param packageResults - The package results to check.\n * @param context - The context to use.\n */\nexport async function verifyExports(\n packageResults: Record<string, InitPackageResult>,\n context: {\n packages: PackageDefinitionsCache;\n session: Session;\n },\n): Promise<InitPackageResult[]> {\n const { packages, session } = context;\n const { config, resolveMap } = session;\n const allErrors: InitPackageResult[] = [];\n const packageResultsArray = Object.values(packageResults);\n\n // Iterate through each package\n for (const [parentPath, parentResult] of Object.entries(packageResults)) {\n // Skip packages with build errors or no info\n if (!parentResult?.info || parentResult.errors?.length) {\n continue;\n }\n\n /**\n * Mapping from imported dependency package ID (`name@version`) to import path\n * to export names missing from that file.\n */\n const depsMissingExports: Record<string, Record<string, Set<string>>> = {};\n\n // Iterate through each entry path from the parent package\n for (const { consumes } of Object.values(parentResult.info)) {\n // Skip entries with no imports\n if (!consumes?.length) {\n continue;\n }\n\n // Iterate through each imported package\n for (const { packageName: depName, importPath: depImportPath, names: consumedNames } of consumes) {\n const depResolveMapEntry = findResolveMapEntry({ packageName: depName, definition: parentResult, resolveMap });\n const depEntries =\n depResolveMapEntry &&\n packageResultsArray.find(\n (r) => r.name === depResolveMapEntry.name && r.version === depResolveMapEntry.version,\n )?.info;\n\n // Skip if we can't find the imported package in the resolve map, or there's no info about\n // its entries/exports.\n if (!depEntries) {\n continue;\n }\n\n const importProduces = (depEntries[depImportPath] || depEntries[`${depImportPath}.js`])?.produces;\n if (!importProduces || importProduces.includes('*')) {\n // Skip if the imported package has no entry for the import path, or if the import\n // produces `*` (everything) since we can't check that. (If the path is missing,\n // evaluateImportsForOverrides has already run and tried to fix it or reported an error.)\n continue;\n }\n\n // Find any missing names.\n const missing = consumedNames.filter(\n (namedImport) => namedImport !== '*' && !importProduces.includes(namedImport),\n );\n if (!missing.length) {\n continue;\n }\n\n // Figure out which actual file the exports appear to be missing from.\n const depExportsMap = await getExportsMap({ packagePath: depResolveMapEntry.path }, { packages, config });\n const depFlattenedExportsMap = flattenExportsMap(depExportsMap);\n // If the package is missing an exports map, assume the import path is the real path.\n const relativePath = depFlattenedExportsMap[depImportPath] || depImportPath;\n const filePath = path.join(depResolveMapEntry.path, relativePath);\n\n // Save the missing names for this path within the package.\n const depKey = `${depResolveMapEntry.name}@${depResolveMapEntry.version}`;\n depsMissingExports[depKey] ??= {};\n depsMissingExports[depKey][filePath] ??= new Set();\n missing.forEach((m) => depsMissingExports[depKey][filePath].add(m));\n }\n }\n\n const depErrors = Object.entries(depsMissingExports).map(([packageId, missing]) => {\n // We want a single error for each package, with a bulleted list of files with missing exports.\n const missingExportsForFiles = Object.entries(missing).map(\n ([file, names]) => `${file}:\\n${[...names].sort().join(', ')}`,\n );\n return {\n text: `Imported names are missing from exports of external package ${packageId}:\\n${bulletedList(missingExportsForFiles)}`,\n source: 'verify exports',\n // Don't include a whole-message location here because that doesn't make sense for this error type,\n // and we already put full paths to individual problem files within the message.\n };\n });\n\n if (depErrors.length) {\n allErrors.push({\n name: parentResult.name,\n version: parentResult.version,\n path: parentPath,\n errors: depErrors,\n });\n }\n }\n\n return allErrors;\n}\n"]}
1
+ {"version":3,"file":"verifyExports.js","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,cAAc,GACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAmB,MAAM,6BAA6B,CAAC;AAC/F,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,cAAiD,EACjD,OAGC;IAED,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAE1D,+BAA+B;IAC/B,KAAK,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QACxE,6CAA6C;QAC7C,IAAI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ACxB,mGAAmG;gBACnG,gFAAgF;aACjF,CAAC,CAAC,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAC3B,SAAS,CAAC,IAAI,CAAC;gBACb,IAAI,EAAE,YAAY,CAAC,IAAI;gBACvB,OAAO,EAAE,YAAY,CAAC,OAAO;gBAC7B,IAAI,EAAE,UAAU;gBAChB,MAAM;aACP,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport {\n findResolveMapEntry,\n getDependencies,\n getUnusedDependencies,\n getSourceEntry,\n} from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport { bulletedList, formatPackageName, type BulletList } from '@ms-cloudpack/task-reporter';\nimport semver from 'semver';\n\n/**\n * Checks that the imports/exports of packages match.\n * To be called before `summarize`.\n * @param packageResults - The package results to check.\n * @param context - The context to use.\n */\nexport async function verifyExports(\n packageResults: Record<string, InitPackageResult>,\n context: {\n packages: PackageDefinitionsCache;\n session: Session;\n },\n): Promise<InitPackageResult[]> {\n const { packages, session } = context;\n const { config, resolveMap } = session;\n const allErrors: InitPackageResult[] = [];\n const packageResultsArray = Object.values(packageResults);\n\n // Iterate through each package\n for (const [parentPath, parentResult] of Object.entries(packageResults)) {\n // Skip packages with build errors or no info\n if (!parentResult?.info || !parentResult.outputPath || parentResult.errors?.length) {\n continue;\n }\n\n const parentDefinition = await packages.get(parentPath);\n if (!parentDefinition) {\n throw new Error(`Definition not found for package at path ${parentPath}`);\n }\n\n /**\n * Mapping from imported dependency package ID (`name@version`) to import path\n * to an object with export names missing from that file, the importString, and bundledFile.\n */\n const depsMissingExports: Record<\n string,\n Record<\n string,\n {\n missingNames: Set<string>;\n importName: string;\n importPath: string;\n importVersion: string;\n bundledFile: string;\n }\n >\n > = {};\n const invalidSemver: Record<string, string> = {};\n\n // Find the main entry point for the parent package to list as the importing bundle.\n const importingBundle = path.join(parentResult.outputPath, parentResult.info?.['.']?.bundlePath || '');\n\n // Find the main entry point for the parent package to list as the importing source.\n const sourceMainEntry = await getSourceEntry({ entry: '.', inputPath: parentPath }, { packages, config });\n const importingSource = path.join(parentPath, sourceMainEntry || '.');\n\n // Iterate through each entry path from the parent package\n for (const { consumes } of Object.values(parentResult.info)) {\n // Skip entries with no imports\n if (!consumes?.length) {\n continue;\n }\n\n // Iterate through each imported package\n for (const { packageName: depName, importPath: depImportPath, names: consumedNames } of consumes) {\n const depResolveMapEntry = findResolveMapEntry({ packageName: depName, definition: parentResult, resolveMap });\n const depResult =\n depResolveMapEntry &&\n packageResultsArray.find(\n (r) => r.name === depResolveMapEntry.name && r.version === depResolveMapEntry.version,\n );\n\n const depEntries = depResult?.info;\n const depOutputPath = depResult?.outputPath;\n\n // Skip if we can't find the imported package in the resolve map, or there's no info about\n // its entries/exports.\n if (!depResolveMapEntry || !depEntries) {\n continue;\n }\n\n const importProduces = depEntries[depImportPath]?.produces;\n if (!importProduces || importProduces.includes('*')) {\n // Skip if the imported package has no entry for the import path, or if the import\n // produces `*` (everything) since we can't check that. (If the path is missing,\n // evaluateImportsForOverrides has already run and tried to fix it or reported an error.)\n continue;\n }\n\n // Find any missing names.\n const missing = consumedNames.filter(\n (namedImport) => namedImport !== '*' && !importProduces.includes(namedImport),\n );\n if (!missing.length) {\n continue;\n }\n\n // Figure out which actual file the exports appear to be missing from.\n const relativePath =\n (await getSourceEntry({ entry: depImportPath, inputPath: depResolveMapEntry.path }, { packages, config })) ||\n // If the package is missing an exports map, assume the import path is the real path.\n depImportPath;\n const filePath = path.join(depResolveMapEntry.path, relativePath);\n\n // Save the missing names for this path within the package.\n const depKey = `${depResolveMapEntry.name}@${depResolveMapEntry.version}`;\n depsMissingExports[depKey] ??= {};\n depsMissingExports[depKey][filePath] ??= {\n missingNames: new Set(),\n importName: depName,\n importPath: depImportPath,\n importVersion: depResolveMapEntry.version,\n bundledFile: path.join(depOutputPath ?? '', depEntries[depImportPath]?.bundlePath),\n };\n missing.forEach((m) => depsMissingExports[depKey][filePath].missingNames.add(m));\n\n // Check if the package satisfies the parent semver requirement.\n const requiredVersion =\n !invalidSemver[depKey] &&\n (getDependencies(parentDefinition)[depName] || getUnusedDependencies(parentDefinition)[depName]);\n if (requiredVersion && !semver.satisfies(depResolveMapEntry.version, requiredVersion)) {\n invalidSemver[depKey] = requiredVersion;\n }\n }\n }\n\n const depErrors = Object.entries(depsMissingExports).map(([packageId, missing]) => {\n // We want a single error for each package, with a bulleted list of files with missing exports.\n const missingExportsForFiles = Object.entries(missing).map(([sourceFile, errorInfo]) => {\n const { missingNames, importName, importPath, importVersion, bundledFile } = errorInfo;\n const error: BulletList = [\n `Importing bundle: ${importingBundle}`,\n `Importing source: ${importingSource}`,\n `Exporting package: ${formatPackageName({ name: importName, version: importVersion })}${importPath === '.' ? '' : ` (imported path: \"${importPath}\")`}`,\n `Exporting bundle: ${bundledFile}`,\n `Exporting source: ${sourceFile}`,\n `Missing export(s): { ${Array.from(missingNames).join(', ')} }`,\n ];\n\n if (!invalidSemver[packageId]) {\n return error;\n }\n\n // If we have an invalid semver, add a note about that after exporting package.\n const errorIndex = 3;\n return [\n ...error.slice(0, errorIndex),\n `Incompatible version: ${formatPackageName({ name: importName, version: importVersion })} does not satisfy importer requirement \"${invalidSemver[packageId]}\"`,\n ['If this was unexpected, make sure you installed dependencies after pulling the latest changes.'],\n ...error.slice(errorIndex),\n ];\n });\n\n return missingExportsForFiles.map((error) => ({\n text: `A bundle imported names from another bundle which were not exported:\\n${bulletedList(error)}\\n`,\n source: 'verify exports',\n // Don't include a whole-message location here because that doesn't make sense for this error type,\n // and we already put full paths to individual problem files within the message.\n }));\n });\n\n depErrors.forEach((errors) => {\n allErrors.push({\n name: parentResult.name,\n version: parentResult.version,\n path: parentPath,\n errors,\n });\n });\n }\n\n return allErrors;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import type { SyncOptions } from './types/SyncOptions.js';
2
- import type { CommandAction } from '../../types/CommandAction.js';
2
+ import { type CommandAction } from '../../types/CommandAction.js';
3
3
  export declare const execute: CommandAction<SyncOptions>;
4
4
  //# sourceMappingURL=execute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlE,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CAyD9C,CAAC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAqD,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAOrH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CAuE9C,CAAC"}
@@ -1,6 +1,9 @@
1
+ import { ExitCodeAuthenticationError, ExitCodeGenericError } from '../../types/CommandAction.js';
1
2
  import { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server';
2
3
  import { runPrerequisites } from '../../utilities/runPrerequisites.js';
3
4
  import { isSyncDisabledByUser } from './isSyncDisabledByUser.js';
5
+ import { RemoteCacheError } from '@ms-cloudpack/remote-cache';
6
+ import { red } from '@ms-cloudpack/task-reporter';
4
7
  export const execute = async (params) => {
5
8
  const { options, cwd, reporter, initialize, exit, autoDispose } = params;
6
9
  const { login, upload } = options;
@@ -11,14 +14,14 @@ export const execute = async (params) => {
11
14
  }
12
15
  if (isSyncDisabledByUser()) {
13
16
  telemetryClient.rootSpan.setAttribute('syncDisabled', true);
14
- await exit({ message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' });
15
- return;
17
+ return exit({ message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' });
16
18
  }
17
19
  try {
18
20
  const remoteCacheConfig = config.remoteCache;
19
21
  if (!remoteCacheConfig) {
20
- console.warn('Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.');
21
- return;
22
+ return exit({
23
+ message: 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',
24
+ });
22
25
  }
23
26
  const input = {
24
27
  loginMethod: login,
@@ -39,12 +42,24 @@ export const execute = async (params) => {
39
42
  }));
40
43
  await syncDownload({ input, ctx });
41
44
  }
42
- await exit({ message: 'Sync complete' });
45
+ return exit({ message: 'Sync complete' });
43
46
  }
44
47
  catch (error) {
45
48
  if (error instanceof Error) {
46
49
  telemetryClient.rootSpan.recordException(error);
47
50
  }
51
+ if (error instanceof RemoteCacheError && error.code === 'AUTH_ERROR') {
52
+ return exit({
53
+ message: red('Authentication error. Please check your credentials and try again.'),
54
+ exitCode: ExitCodeAuthenticationError,
55
+ });
56
+ }
57
+ if (error instanceof RemoteCacheError && error.code === 'CONNECTION_ERROR') {
58
+ return exit({
59
+ message: red('Connection error. Please check your connection and try again.'),
60
+ exitCode: ExitCodeGenericError,
61
+ });
62
+ }
48
63
  throw error;
49
64
  }
50
65
  };
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EA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AAoB,EAAE,eAAe,CAAC;aACtG,CAAC,CACH,CAAC;YACF,MAAM,UAAU,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CACvB,MAAM,uBAAuB,CAAC;gBAC5B,GAAG,iBAAiB;gBACpB,KAAK,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,eAAe,CAAC;aAChD,CAAC,CACH,CAAC;YACF,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,IAAI,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SyncOptions } from './types/SyncOptions.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { isSyncDisabledByUser } from './isSyncDisabledByUser.js';\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, cwd, reporter, initialize, exit, autoDispose } = params;\n const { login, upload } = options;\n const { config, telemetryClient } = await initialize({ appPath: cwd });\n\n if (!config.features?.syncBundles) {\n await exit({ message: 'Sync is disabled' });\n return;\n }\n\n if (isSyncDisabledByUser()) {\n telemetryClient.rootSpan.setAttribute('syncDisabled', true);\n await exit({ message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' });\n return;\n }\n\n try {\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n console.warn(\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n );\n return;\n }\n\n const input = {\n loginMethod: login,\n };\n\n const apiContextOptions = { appPath: cwd, config, reporter, telemetryClient };\n if (upload) {\n runPrerequisites({ config, cwd, telemetryClient });\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n await syncDownload({ input, ctx });\n }\n\n await exit({ message: 'Sync complete' });\n } catch (error) {\n if (error instanceof Error) {\n telemetryClient.rootSpan.recordException(error);\n }\n throw error;\n }\n};\n"]}
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAsB,MAAM,8BAA8B,CAAC;AACrH,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAElD,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACzE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,UAAU,CAAC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GAAG,iBAAiB;gBACpB,KAAK,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,eAAe,CAAC;aAChD,CAAC,CACH,CAAC;YACF,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;QAED,IAAI,KAAK,YAAY,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACrE,OAAO,IAAI,CAAC;gBACV,OAAO,EAAE,GAAG,CAAC,oEAAoE,CAAC;gBAClF,QAAQ,EAAE,2BAA2B;aACtC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,KAAK,YAAY,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;YAC3E,OAAO,IAAI,CAAC;gBACV,OAAO,EAAE,GAAG,CAAC,+DAA+D,CAAC;gBAC7E,QAAQ,EAAE,oBAAoB;aAC/B,CAAC,CAAC;QACL,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SyncOptions } from './types/SyncOptions.js';\nimport { ExitCodeAuthenticationError, ExitCodeGenericError, type CommandAction } from '../../types/CommandAction.js';\nimport { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { isSyncDisabledByUser } from './isSyncDisabledByUser.js';\nimport { RemoteCacheError } from '@ms-cloudpack/remote-cache';\nimport { red } from '@ms-cloudpack/task-reporter';\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, cwd, reporter, initialize, exit, autoDispose } = params;\n const { login, upload } = options;\n const { config, telemetryClient } = await initialize({ appPath: cwd });\n\n if (!config.features?.syncBundles) {\n await exit({ message: 'Sync is disabled' });\n return;\n }\n\n if (isSyncDisabledByUser()) {\n telemetryClient.rootSpan.setAttribute('syncDisabled', true);\n return exit({ message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' });\n }\n\n try {\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n return exit({\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 const apiContextOptions = { appPath: cwd, config, reporter, telemetryClient };\n if (upload) {\n runPrerequisites({ config, cwd, telemetryClient });\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n await syncDownload({ input, ctx });\n }\n\n return exit({ message: 'Sync complete' });\n } catch (error) {\n if (error instanceof Error) {\n telemetryClient.rootSpan.recordException(error);\n }\n\n if (error instanceof RemoteCacheError && error.code === 'AUTH_ERROR') {\n return exit({\n message: red('Authentication error. Please check your credentials and try again.'),\n exitCode: ExitCodeAuthenticationError,\n });\n }\n\n if (error instanceof RemoteCacheError && error.code === 'CONNECTION_ERROR') {\n return exit({\n message: red('Connection error. Please check your connection and try again.'),\n exitCode: ExitCodeGenericError,\n });\n }\n\n throw error;\n }\n};\n"]}
@@ -10,10 +10,14 @@ export type AppCommandContext = {
10
10
  telemetryClient: TelemetryClient;
11
11
  config: CloudpackConfig;
12
12
  };
13
+ export declare const ExitCodeSuccessful = 0;
14
+ export declare const ExitCodeGenericError = 1;
15
+ export declare const ExitCodeAuthenticationError = 2;
16
+ export type ExitCode = typeof ExitCodeSuccessful | typeof ExitCodeGenericError | typeof ExitCodeAuthenticationError;
13
17
  export interface CommandExitParams {
14
18
  message: string;
15
19
  hasErrors?: boolean;
16
- exitCode?: number;
20
+ exitCode?: ExitCode;
17
21
  }
18
22
  export interface CommandActionParams<TOptions extends object> {
19
23
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"CommandAction.d.ts","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,8EAA8E;AAC9E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,eAAe,CAAC;IACjC,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,MAAM;IAC1D;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,OAAO,EAAE,QAAQ,CAAC;IAElB;;;OAGG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,QAAQ,EAAE,YAAY,CAAC;IAEvB,WAAW,EAAE,WAAW,CAAC;IAEzB;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;;;;;;OAOG;IACH,UAAU,EAAE;QACV,CAAC,iBAAiB,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;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AM,aAAa,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,QAAQ,GAAG,aAAa,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/G,MAAM,MAAM,mBAAmB,CAAC,QAAQ,IAAI;IAC1C,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CAClC,CAAC"}
@@ -1,2 +1,4 @@
1
- export {};
1
+ export const ExitCodeSuccessful = 0;
2
+ export const ExitCodeGenericError = 1;
3
+ export const ExitCodeAuthenticationError = 2;
2
4
  //# sourceMappingURL=CommandAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommandAction.js","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"","sourcesContent":["import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/common-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { AutoDispose } from './AutoDispose.js';\nimport type { SharedOptions } from './SharedOptions.js';\n\n/** Context for running a command in a specific app (after initialization). */\nexport type AppCommandContext = {\n appPath: string;\n telemetryClient: TelemetryClient;\n config: CloudpackConfig;\n};\n\nexport interface CommandExitParams {\n message: string;\n hasErrors?: boolean;\n exitCode?: number;\n}\n\nexport interface CommandActionParams<TOptions extends object> {\n /**\n * Initial working directory (usually `process.cwd()` except in tests).\n * Note that this may differ from the `appPath` used by individual commands.\n */\n cwd: string;\n\n /**\n * Command-specific options, parsed from `process.argv`.\n * Types are generally defined in each command's `src/commands/<name>/types/<Name>Types.ts` module.\n * The command line options are defined in each command's `src/commands/<name>/index.ts` module.\n */\n options: TOptions;\n\n /**\n * Command-specific arguments. Arguments in commander are positional arguments that are not options.\n * For example, in `echo somestring`, `somestring` is an argument.\n */\n args: string[];\n\n reporter: TaskReporter;\n\n abortSignal: AbortSignal;\n\n /**\n * Function that can be called with any `Disposable`s that should be cleaned up automatically\n * when the program exits. (See `AutoDisposableList.add` for implementation.)\n */\n autoDispose: AutoDispose;\n\n /**\n * This should be called at or near the beginning of the action to initialize the config,\n * telemetry, and reporting. (See `CommandExecutor._initialize` for implementation.)\n * `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.\n *\n * If it is called with a single string, it returns `Promise<AppCommandContext>`\n * If it is called with a string[], it returns `Promise<AppCommandContext[]>`\n */\n initialize: {\n (initializeOptions: { appPath: string; overrideOptions?: Partial<SharedOptions> }): Promise<AppCommandContext>;\n (initializeOptions: { appPaths: string[]; overrideOptions?: Partial<SharedOptions> }): Promise<AppCommandContext[]>;\n };\n\n /**\n * This should be called at the end of the action to dispose resources, log completion,\n * and exit the program. (See `CommandExecutor._exit` for implementation.)\n */\n exit: (result: CommandExitParams) => Promise<void>;\n\n /**\n * Set a callback to get the message to display if ctrl+C is pressed.\n */\n setInterruptMessageHandler: (getMessage: () => string) => void;\n}\n\n/**\n * Command action function. This is the type of the `execute` function which should be exported\n * from each command's `src/commands/<name>/execute.ts` module.\n */\nexport type CommandAction<TOptions> = (params: CommandActionParams<TOptions & SharedOptions>) => Promise<void>;\n\nexport type CommandActionModule<TOptions> = {\n execute: CommandAction<TOptions>;\n};\n"]}
1
+ {"version":3,"file":"CommandAction.js","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC","sourcesContent":["import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/common-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { AutoDispose } from './AutoDispose.js';\nimport type { SharedOptions } from './SharedOptions.js';\n\n/** Context for running a command in a specific app (after initialization). */\nexport type AppCommandContext = {\n appPath: string;\n telemetryClient: TelemetryClient;\n config: CloudpackConfig;\n};\n\nexport const ExitCodeSuccessful = 0;\nexport const ExitCodeGenericError = 1;\nexport const ExitCodeAuthenticationError = 2;\nexport type ExitCode = typeof ExitCodeSuccessful | typeof ExitCodeGenericError | typeof ExitCodeAuthenticationError;\n\nexport interface CommandExitParams {\n message: string;\n hasErrors?: boolean;\n exitCode?: ExitCode;\n}\n\nexport interface CommandActionParams<TOptions extends object> {\n /**\n * Initial working directory (usually `process.cwd()` except in tests).\n * Note that this may differ from the `appPath` used by individual commands.\n */\n cwd: string;\n\n /**\n * Command-specific options, parsed from `process.argv`.\n * Types are generally defined in each command's `src/commands/<name>/types/<Name>Types.ts` module.\n * The command line options are defined in each command's `src/commands/<name>/index.ts` module.\n */\n options: TOptions;\n\n /**\n * Command-specific arguments. Arguments in commander are positional arguments that are not options.\n * For example, in `echo somestring`, `somestring` is an argument.\n */\n args: string[];\n\n reporter: TaskReporter;\n\n abortSignal: AbortSignal;\n\n /**\n * Function that can be called with any `Disposable`s that should be cleaned up automatically\n * when the program exits. (See `AutoDisposableList.add` for implementation.)\n */\n autoDispose: AutoDispose;\n\n /**\n * This should be called at or near the beginning of the action to initialize the config,\n * telemetry, and reporting. (See `CommandExecutor._initialize` for implementation.)\n * `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.\n *\n * If it is called with a single string, it returns `Promise<AppCommandContext>`\n * If it is called with a string[], it returns `Promise<AppCommandContext[]>`\n */\n initialize: {\n (initializeOptions: { appPath: string; overrideOptions?: Partial<SharedOptions> }): Promise<AppCommandContext>;\n (initializeOptions: { appPaths: string[]; overrideOptions?: Partial<SharedOptions> }): Promise<AppCommandContext[]>;\n };\n\n /**\n * This should be called at the end of the action to dispose resources, log completion,\n * and exit the program. (See `CommandExecutor._exit` for implementation.)\n */\n exit: (result: CommandExitParams) => Promise<void>;\n\n /**\n * Set a callback to get the message to display if ctrl+C is pressed.\n */\n setInterruptMessageHandler: (getMessage: () => string) => void;\n}\n\n/**\n * Command action function. This is the type of the `execute` function which should be exported\n * from each command's `src/commands/<name>/execute.ts` module.\n */\nexport type CommandAction<TOptions> = (params: CommandActionParams<TOptions & SharedOptions>) => Promise<void>;\n\nexport type CommandActionModule<TOptions> = {\n execute: CommandAction<TOptions>;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.59.1",
3
+ "version": "0.59.3",
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,18 +10,18 @@
10
10
  "cloudpack": "./bin/cloudpack.js"
11
11
  },
12
12
  "dependencies": {
13
- "@ms-cloudpack/api-server": "^0.37.0",
14
- "@ms-cloudpack/app-server": "^0.3.8",
15
- "@ms-cloudpack/bundle-server": "^0.2.52",
16
- "@ms-cloudpack/common-types": "^0.2.2",
17
- "@ms-cloudpack/config": "^0.19.1",
13
+ "@ms-cloudpack/api-server": "^0.37.2",
14
+ "@ms-cloudpack/app-server": "^0.3.10",
15
+ "@ms-cloudpack/bundle-server": "^0.2.54",
16
+ "@ms-cloudpack/common-types": "^0.2.3",
17
+ "@ms-cloudpack/config": "^0.19.3",
18
18
  "@ms-cloudpack/feature-flags": "^0.1.1",
19
19
  "@ms-cloudpack/json-utilities": "^0.1.4",
20
- "@ms-cloudpack/overlay": "^0.16.101",
21
- "@ms-cloudpack/package-utilities": "^7.1.3",
22
- "@ms-cloudpack/path-utilities": "^2.7.0",
23
- "@ms-cloudpack/remote-cache": "^0.6.4",
24
- "@ms-cloudpack/task-reporter": "^0.13.0",
20
+ "@ms-cloudpack/overlay": "^0.16.103",
21
+ "@ms-cloudpack/package-utilities": "^7.1.5",
22
+ "@ms-cloudpack/path-utilities": "^2.7.1",
23
+ "@ms-cloudpack/remote-cache": "^0.6.5",
24
+ "@ms-cloudpack/task-reporter": "^0.13.1",
25
25
  "@ms-cloudpack/telemetry": "^0.5.1",
26
26
  "@yarnpkg/lockfile": "^1.1.0",
27
27
  "commander": "^11.1.0",
@@ -34,7 +34,7 @@
34
34
  "workspace-tools": "^0.36.4"
35
35
  },
36
36
  "devDependencies": {
37
- "@ms-cloudpack/common-types": "^0.2.2",
37
+ "@ms-cloudpack/common-types": "^0.2.3",
38
38
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
39
39
  "@ms-cloudpack/scripts": "^0.0.1",
40
40
  "@ms-cloudpack/test-utilities": "^0.5.0",