@ms-cloudpack/cli 0.72.8 → 0.72.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"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,aAAa,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAQzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKtE;;;;;;GAMG;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,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC,CAuK1C"}
1
+ {"version":3,"file":"verifyExports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EAIxB,MAAM,4BAA4B,CAAC;AAQpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMtE;;;;;;GAMG;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,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC,CA6K1C"}
@@ -3,6 +3,7 @@ import path from 'path';
3
3
  import { bulletedList, formatPackageName } from '@ms-cloudpack/task-reporter';
4
4
  import { getPackageSettings } from '@ms-cloudpack/config';
5
5
  import semver from 'semver';
6
+ import { parseImportString } from '@ms-cloudpack/path-string-parsing';
6
7
  /**
7
8
  * Checks that the imports/exports of packages match.
8
9
  * To be called before `summarize`.
@@ -15,6 +16,7 @@ export async function verifyExports(packageResults, context) {
15
16
  const { config, resolveMap } = session;
16
17
  const allErrors = {};
17
18
  const packageResultsArray = Object.values(packageResults);
19
+ const importsCache = {};
18
20
  // Iterate through each package
19
21
  for (const parentResult of packageResultsArray) {
20
22
  // Skip packages with build errors or no info
@@ -53,26 +55,34 @@ export async function verifyExports(packageResults, context) {
53
55
  }
54
56
  // Iterate through each imported package
55
57
  for (const { packageName: depName, importPath: depImportPath, names: consumedNames } of consumes) {
56
- const depResolveMapEntry = findResolveMapEntry({ packageName: depName, definition: parentResult, resolveMap });
57
- const depResult = depResolveMapEntry &&
58
- packageResultsArray.find((r) => r.name === depResolveMapEntry.name && r.version === depResolveMapEntry.version);
59
- const depEntries = depResult?.info;
60
- const depOutputPath = depResult?.outputPath;
61
- // Skip if we can't find the imported package in the resolve map, or there's no info about
62
- // its entries/exports.
63
- if (!depResolveMapEntry || !depEntries) {
58
+ const dependencyInfo = getDependencyInfo({
59
+ packageName: depName,
60
+ definition: parentDefinition,
61
+ resolveMap,
62
+ packageResultsArray,
63
+ });
64
+ // We don't have enough info to check this dependency, so skip it.
65
+ if (!dependencyInfo) {
64
66
  continue;
65
67
  }
68
+ const { depResolveMapEntry, depResult } = dependencyInfo;
69
+ const { outputPath: depOutputPath, info: depEntries } = depResult;
66
70
  const importProduces = depEntries[depImportPath]?.produces;
67
- if (!importProduces || importProduces.includes('*')) {
68
- // Skip if the imported package has no entry for the import path, or if the import
69
- // produces `*` (everything) since we can't check that. (If the path is missing,
71
+ if (!importProduces) {
72
+ // Skip if the imported package has no entry for the import path. (If the path is missing,
70
73
  // evaluateImportsForOverrides has already run and tried to fix it or reported an error.)
71
74
  continue;
72
75
  }
76
+ const importProducesStarResult = await importProducesStar({
77
+ packagePath: depResolveMapEntry.path,
78
+ importPath: depImportPath,
79
+ info: depEntries,
80
+ context: { packages, resolveMap, packageResultsArray },
81
+ cache: importsCache,
82
+ });
73
83
  // Find any missing names.
74
84
  const missing = consumedNames.filter((namedImport) => namedImport !== '*' &&
75
- !importProduces.includes(namedImport) &&
85
+ !importProducesStarResult.includes(namedImport) &&
76
86
  !ignoredExports[depImportPath]?.includes(namedImport));
77
87
  if (!missing.length) {
78
88
  continue;
@@ -132,4 +142,62 @@ export async function verifyExports(packageResults, context) {
132
142
  }
133
143
  return allErrors;
134
144
  }
145
+ async function importProducesStar({ packagePath, info, importPath, context, visited = new Set(), cache = {}, }) {
146
+ const key = `${packagePath}${importPath}`;
147
+ // Check if the entry has already been visited to avoid cycles
148
+ if (visited.has(key)) {
149
+ return [];
150
+ }
151
+ // Mark the current entry as visited
152
+ visited.add(key);
153
+ const cachedResult = cache[key];
154
+ if (cachedResult) {
155
+ return cachedResult;
156
+ }
157
+ const { packages, resolveMap, packageResultsArray } = context;
158
+ let result = [];
159
+ // Iterate over the produced names
160
+ for (const name of info[importPath].produces) {
161
+ if (name.startsWith('*')) {
162
+ // Extract the name and path from the format "*ImportString"
163
+ const { packageName: depName, importPath: depImportPath } = parseImportString(name.slice(1));
164
+ const dependencyInfo = getDependencyInfo({
165
+ packageName: depName,
166
+ definition: await packages.get(packagePath),
167
+ resolveMap,
168
+ packageResultsArray,
169
+ });
170
+ if (dependencyInfo) {
171
+ const { depResolveMapEntry, depResult } = dependencyInfo;
172
+ // Recursively aggregate the produced names from the other package
173
+ result = result.concat(await importProducesStar({
174
+ packagePath: depResolveMapEntry.path,
175
+ info: depResult.info,
176
+ importPath: depImportPath,
177
+ context,
178
+ visited,
179
+ }));
180
+ }
181
+ }
182
+ else {
183
+ // Add the name to the result if it doesn't start with '*'
184
+ result.push(name);
185
+ }
186
+ }
187
+ cache[key] = result;
188
+ return result;
189
+ }
190
+ function getDependencyInfo(options) {
191
+ const { packageName, definition, resolveMap, packageResultsArray } = options;
192
+ const depResolveMapEntry = findResolveMapEntry({ packageName, definition, resolveMap });
193
+ const depResult = depResolveMapEntry &&
194
+ packageResultsArray.find((r) => r.name === depResolveMapEntry.name && r.version === depResolveMapEntry.version);
195
+ const depEntries = depResult?.info;
196
+ // Skip if we can't find the imported package in the resolve map, or there's no info about
197
+ // its entries/exports.
198
+ if (!depResolveMapEntry || !depEntries) {
199
+ return;
200
+ }
201
+ return { depResolveMapEntry, depResult: depResult };
202
+ }
135
203
  //# sourceMappingURL=verifyExports.js.map
@@ -1 +1 @@
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,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;;;;;GAMG;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,GAAoC,EAAE,CAAC;IACtD,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAE1D,+BAA+B;IAC/B,KAAK,MAAM,YAAY,IAAI,mBAAmB,EAAE,CAAC;QAC/C,6CAA6C;QAC7C,IAAI,CAAC,YAAY,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,IAAI,YAAY,CAAC,MAAM,EA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E,yEAAyE,YAAY,CAAC,KAAK,CAAC,IAAI;oBACtG,MAAM,EAAE,gBAAgB;oBACxB,mGAAmG;oBACnG,gFAAgF;iBACjF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,SAAS,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport type { BundleMessage, 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 { getPackageSettings } from '@ms-cloudpack/config';\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 * @returns Mapping from absolute package path to errors.\n */\nexport async function verifyExports(\n packageResults: Record<string, InitPackageResult>,\n context: {\n packages: PackageDefinitionsCache;\n session: Session;\n },\n): Promise<Record<string, BundleMessage[]>> {\n const { packages, session } = context;\n const { config, resolveMap } = session;\n const allErrors: Record<string, BundleMessage[]> = {};\n const packageResultsArray = Object.values(packageResults);\n\n // Iterate through each package\n for (const parentResult of packageResultsArray) {\n // Skip packages with build errors or no info\n if (!parentResult?.info || !parentResult.outputPath || parentResult.errors?.length) {\n continue;\n }\n\n // Skip packages with `ignoreMissingExports` set to true.\n const { name, version, path: parentPath } = parentResult;\n const { userPackageSettings } = getPackageSettings({\n name,\n version,\n userPackageSettings: config.packageSettings,\n generatedPackageSettings: config.generated.packageSettings,\n });\n if (userPackageSettings?.ignoreMissingExports === true) {\n continue;\n }\n const ignoredExports = userPackageSettings?.ignoreMissingExports || {};\n\n const parentDefinition = await packages.get(parentPath);\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) =>\n namedImport !== '*' &&\n !importProduces.includes(namedImport) &&\n !ignoredExports[depImportPath]?.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 errors: BundleMessage[] = [];\n\n for (const [packageId, missing] of Object.entries(depsMissingExports)) {\n // We want a single error for each package, with a bulleted list of files with missing exports.\n for (const [sourceFile, errorInfo] of Object.entries(missing)) {\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 // If we have an invalid semver, add a note about that after exporting package.\n error.splice(\n 3,\n 0,\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 );\n }\n\n errors.push({\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\n if (errors.length) {\n allErrors[parentPath] = errors;\n }\n }\n\n return allErrors;\n}\n"]}
1
+ {"version":3,"file":"verifyExports.js","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAQA,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,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;;;;;GAMG;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,GAAoC,EAAE,CAAC;IACtD,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC1D,MAAM,YAAY,GAA6B,EAAE,CAAC;IAElD,+BAA+B;IAC/B,KAAK,MAAM,YAAY,IAAI,mBAAmB,EAAE,CAAC;QAC/C,6CAA6C;QAC7C,IAAI,CAAC,YAAY,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,IAAI,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YACnF,SAAS;QACX,CAAC;QAED,yDAAyD;QACzD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,YAAY,CAAC;QACzD,MAAM,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\nimport type {\n BundleMessage,\n PackageDefinitionsCache,\n PackageJson,\n ResolveMap,\n ResolveMapEntry,\n} 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 { getPackageSettings } from '@ms-cloudpack/config';\nimport semver from 'semver';\nimport { parseImportString } from '@ms-cloudpack/path-string-parsing';\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 * @returns Mapping from absolute package path to errors.\n */\nexport async function verifyExports(\n packageResults: Record<string, InitPackageResult>,\n context: {\n packages: PackageDefinitionsCache;\n session: Session;\n },\n): Promise<Record<string, BundleMessage[]>> {\n const { packages, session } = context;\n const { config, resolveMap } = session;\n const allErrors: Record<string, BundleMessage[]> = {};\n const packageResultsArray = Object.values(packageResults);\n const importsCache: Record<string, string[]> = {};\n\n // Iterate through each package\n for (const parentResult of packageResultsArray) {\n // Skip packages with build errors or no info\n if (!parentResult?.info || !parentResult.outputPath || parentResult.errors?.length) {\n continue;\n }\n\n // Skip packages with `ignoreMissingExports` set to true.\n const { name, version, path: parentPath } = parentResult;\n const { userPackageSettings } = getPackageSettings({\n name,\n version,\n userPackageSettings: config.packageSettings,\n generatedPackageSettings: config.generated.packageSettings,\n });\n if (userPackageSettings?.ignoreMissingExports === true) {\n continue;\n }\n const ignoredExports = userPackageSettings?.ignoreMissingExports || {};\n\n const parentDefinition = await packages.get(parentPath);\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 dependencyInfo = getDependencyInfo({\n packageName: depName,\n definition: parentDefinition,\n resolveMap,\n packageResultsArray,\n });\n // We don't have enough info to check this dependency, so skip it.\n if (!dependencyInfo) {\n continue;\n }\n\n const { depResolveMapEntry, depResult } = dependencyInfo;\n const { outputPath: depOutputPath, info: depEntries } = depResult;\n\n const importProduces = depEntries[depImportPath]?.produces;\n if (!importProduces) {\n // Skip if the imported package has no entry for the import path. (If the path is missing,\n // evaluateImportsForOverrides has already run and tried to fix it or reported an error.)\n continue;\n }\n\n const importProducesStarResult = await importProducesStar({\n packagePath: depResolveMapEntry.path,\n importPath: depImportPath,\n info: depEntries,\n context: { packages, resolveMap, packageResultsArray },\n cache: importsCache,\n });\n\n // Find any missing names.\n const missing = consumedNames.filter(\n (namedImport) =>\n namedImport !== '*' &&\n !importProducesStarResult.includes(namedImport) &&\n !ignoredExports[depImportPath]?.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 errors: BundleMessage[] = [];\n\n for (const [packageId, missing] of Object.entries(depsMissingExports)) {\n // We want a single error for each package, with a bulleted list of files with missing exports.\n for (const [sourceFile, errorInfo] of Object.entries(missing)) {\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 // If we have an invalid semver, add a note about that after exporting package.\n error.splice(\n 3,\n 0,\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 );\n }\n\n errors.push({\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\n if (errors.length) {\n allErrors[parentPath] = errors;\n }\n }\n\n return allErrors;\n}\n\nasync function importProducesStar({\n packagePath,\n info,\n importPath,\n context,\n visited = new Set(),\n cache = {},\n}: {\n packagePath: string;\n info: BundleInfo;\n importPath: string;\n context: {\n packages: PackageDefinitionsCache;\n resolveMap: ResolveMap;\n packageResultsArray: InitPackageResult[];\n };\n visited?: Set<string>;\n cache?: Record<string, string[]>;\n}): Promise<string[]> {\n const key = `${packagePath}${importPath}`;\n // Check if the entry has already been visited to avoid cycles\n if (visited.has(key)) {\n return [];\n }\n\n // Mark the current entry as visited\n visited.add(key);\n\n const cachedResult = cache[key];\n if (cachedResult) {\n return cachedResult;\n }\n\n const { packages, resolveMap, packageResultsArray } = context;\n let result: string[] = [];\n\n // Iterate over the produced names\n for (const name of info[importPath].produces) {\n if (name.startsWith('*')) {\n // Extract the name and path from the format \"*ImportString\"\n const { packageName: depName, importPath: depImportPath } = parseImportString(name.slice(1));\n\n const dependencyInfo = getDependencyInfo({\n packageName: depName,\n definition: await packages.get(packagePath),\n resolveMap,\n packageResultsArray,\n });\n\n if (dependencyInfo) {\n const { depResolveMapEntry, depResult } = dependencyInfo;\n // Recursively aggregate the produced names from the other package\n result = result.concat(\n await importProducesStar({\n packagePath: depResolveMapEntry.path,\n info: depResult.info,\n importPath: depImportPath,\n context,\n visited,\n }),\n );\n }\n } else {\n // Add the name to the result if it doesn't start with '*'\n result.push(name);\n }\n }\n\n cache[key] = result;\n return result;\n}\n\ntype WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };\n\nfunction getDependencyInfo(options: {\n packageName: string;\n definition: PackageJson;\n resolveMap: ResolveMap;\n packageResultsArray: InitPackageResult[];\n}):\n | {\n depResult: WithRequired<InitPackageResult, 'info'>;\n depResolveMapEntry: ResolveMapEntry;\n }\n | undefined {\n const { packageName, definition, resolveMap, packageResultsArray } = options;\n\n const depResolveMapEntry = findResolveMapEntry({ packageName, definition, resolveMap });\n const depResult =\n depResolveMapEntry &&\n packageResultsArray.find((r) => r.name === depResolveMapEntry.name && r.version === depResolveMapEntry.version);\n\n const depEntries = depResult?.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 (!depResolveMapEntry || !depEntries) {\n return;\n }\n\n return { depResolveMapEntry, depResult: depResult as WithRequired<InitPackageResult, 'info'> };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.72.8",
3
+ "version": "0.72.10",
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,20 +10,20 @@
10
10
  "cloudpack": "./bin/cloudpack.js"
11
11
  },
12
12
  "dependencies": {
13
- "@ms-cloudpack/api-server": "^0.54.8",
14
- "@ms-cloudpack/app-server": "^0.17.3",
15
- "@ms-cloudpack/bundler": "^0.23.8",
16
- "@ms-cloudpack/common-types": "^0.23.0",
17
- "@ms-cloudpack/config": "^0.31.5",
13
+ "@ms-cloudpack/api-server": "^0.54.10",
14
+ "@ms-cloudpack/app-server": "^0.17.5",
15
+ "@ms-cloudpack/bundler": "^0.23.9",
16
+ "@ms-cloudpack/common-types": "^0.23.1",
17
+ "@ms-cloudpack/config": "^0.31.6",
18
18
  "@ms-cloudpack/json-utilities": "^0.1.8",
19
- "@ms-cloudpack/overlay": "^0.17.84",
20
- "@ms-cloudpack/package-utilities": "^10.2.5",
19
+ "@ms-cloudpack/overlay": "^0.17.86",
20
+ "@ms-cloudpack/package-utilities": "^10.2.6",
21
21
  "@ms-cloudpack/path-string-parsing": "^1.2.4",
22
- "@ms-cloudpack/path-utilities": "^2.7.49",
23
- "@ms-cloudpack/remote-cache": "^0.9.0",
24
- "@ms-cloudpack/setup-utilities": "^0.4.5",
22
+ "@ms-cloudpack/path-utilities": "^2.7.50",
23
+ "@ms-cloudpack/remote-cache": "^0.9.2",
24
+ "@ms-cloudpack/setup-utilities": "^0.4.6",
25
25
  "@ms-cloudpack/task-reporter": "^0.14.5",
26
- "@ms-cloudpack/telemetry": "^0.6.3",
26
+ "@ms-cloudpack/telemetry": "^0.7.0",
27
27
  "@yarnpkg/lockfile": "^1.1.0",
28
28
  "commander": "^11.1.0",
29
29
  "cross-spawn": "^7.0.3",
@@ -36,7 +36,7 @@
36
36
  "workspace-tools": "^0.37.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@ms-cloudpack/common-types": "^0.23.0",
39
+ "@ms-cloudpack/common-types": "^0.23.1",
40
40
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
41
41
  "@ms-cloudpack/scripts": "^0.0.1",
42
42
  "@ms-cloudpack/test-utilities": "^0.5.0",