@ms-cloudpack/cli 0.74.13 → 0.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/init/evaluateDynamicImports.d.ts.map +1 -1
- package/lib/commands/init/evaluateDynamicImports.js +3 -0
- package/lib/commands/init/evaluateDynamicImports.js.map +1 -1
- package/lib/commands/init/verifyExports.d.ts.map +1 -1
- package/lib/commands/init/verifyExports.js +53 -29
- package/lib/commands/init/verifyExports.js.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateDynamicImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluateDynamicImports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAA4B,MAAM,4BAA4B,CAAC;AAExF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAElF;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE;IACP,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,EACD,OAAO,EAAE,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,GAC5C,OAAO,CAAC;IACT,qBAAqB,EAAE,uBAAuB,EAAE,CAAC;IACjD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,
|
|
1
|
+
{"version":3,"file":"evaluateDynamicImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluateDynamicImports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAA4B,MAAM,4BAA4B,CAAC;AAExF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAElF;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE;IACP,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,EACD,OAAO,EAAE,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,GAC5C,OAAO,CAAC;IACT,qBAAqB,EAAE,uBAAuB,EAAE,CAAC;IACjD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CAsDD"}
|
|
@@ -17,6 +17,9 @@ export async function evaluateDynamicImports(options, context) {
|
|
|
17
17
|
let shouldRefresh = false;
|
|
18
18
|
let generatedPackageSettings;
|
|
19
19
|
for (const entryInfo of Object.values(info)) {
|
|
20
|
+
if (!entryInfo) {
|
|
21
|
+
continue; // This is to make type-checking happy
|
|
22
|
+
}
|
|
20
23
|
for (const dynamicImport of entryInfo.dynamicImports || []) {
|
|
21
24
|
if (dynamicImport.packageName !== '.') {
|
|
22
25
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateDynamicImports.js","sourceRoot":"","sources":["../../../src/commands/init/evaluateDynamicImports.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AAGzE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAIC,EACD,OAA6C;IAM7C,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC;IAClE,MAAM,WAA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ACF;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import type { BundleInfo, PartialContext } from '@ms-cloudpack/api-server';\nimport type { PackageJson, GeneratedPackageSettings } from '@ms-cloudpack/common-types';\nimport { ensureGeneratedSettingsForPackage } from '@ms-cloudpack/config';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\n\n/**\n * Check for dynamic `import()` statements of relative paths, and add any files where those are\n * found to `GeneratedPackageSettings.dynamicImports`.\n */\nexport async function evaluateDynamicImports(\n options: {\n info: BundleInfo;\n definition: PackageJson;\n packagePath: string;\n },\n context: PartialContext<'packages', 'config'>,\n): Promise<{\n dynamicImportsChanges: GeneratedPackageChanges[];\n shouldReevaluate: boolean;\n shouldRefresh: boolean;\n}> {\n const { info, definition, packagePath } = options;\n const { packages, session } = context;\n const { config } = session;\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 dynamicImportsChanges: GeneratedPackageChanges[] = [];\n let shouldReevaluate = false;\n let shouldRefresh = false;\n let generatedPackageSettings: GeneratedPackageSettings | undefined;\n\n for (const entryInfo of Object.values(info)) {\n for (const dynamicImport of entryInfo.dynamicImports || []) {\n if (dynamicImport.packageName !== '.') {\n continue;\n }\n\n const { importOrigin } = dynamicImport;\n // TODO: does this actually need to re-evaluate if there are no new imports?\n shouldReevaluate = true;\n generatedPackageSettings ??= await ensureGeneratedSettingsForPackage({ packagePath }, { config, packages });\n if (generatedPackageSettings?.dynamicImports?.includes(importOrigin)) {\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.dynamicImports ??= [];\n generatedPackageSettings.dynamicImports.push(importOrigin);\n shouldRefresh = true;\n\n dynamicImportsChanges.push({\n name: packageName,\n version: packageVersion,\n path: packagePath,\n changes: [\n {\n type: 'added-dynamic-import',\n change: importOrigin,\n reason: `Found non-literal path in import().`,\n },\n ],\n });\n }\n }\n\n return { dynamicImportsChanges, shouldReevaluate, shouldRefresh };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"evaluateDynamicImports.js","sourceRoot":"","sources":["../../../src/commands/init/evaluateDynamicImports.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AAGzE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAIC,EACD,OAA6C;IAM7C,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC;IAClE,MAAM,WAAW,GAAG,GAAG,WAAW,IAAI,cAAc,EAAE,CAAC;IACvD,IAAI,CAAC,WAAW,IAAI,CAAC,cAAc,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,YAAY,WAAW,iCAAiC,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,qBAAqB,GAA8B,EAAE,CAAC;IAC5D,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,IAAI,aAAa,GAAG,KAAK,CAAC;IAC1B,IAAI,wBAA8D,CAAC;IAEnE,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS,CAAC,sCAAsC;QAClD,CAAC;QACD,KAAK,MAAM,aAAa,IAAI,SAAS,CAAC,cAAc,IAAI,EAAE,EAAE,CAAC;YAC3D,IAAI,aAAa,CAAC,WAAW,KAAK,GAAG,EAAE,CAAC;gBACtC,SAAS;YACX,CAAC;YAED,MAAM,EAAE,YAAY,EAAE,GAAG,aAAa,CAAC;YACvC,4EAA4E;YAC5E,gBAAgB,GAAG,IAAI,CAAC;YACxB,wBAAwB,KAAK,MAAM,iCAAiC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC5G,IAAI,wBAAwB,EAAE,cAAc,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBACrE,SAAS;YACX,CAAC;YAED,mGAAmG;YACnG,wBAAwB,CAAC,cAAc,KAAK,EAAE,CAAC;YAC/C,wBAAwB,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC3D,aAAa,GAAG,IAAI,CAAC;YAErB,qBAAqB,CAAC,IAAI,CAAC;gBACzB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,cAAc;gBACvB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,sBAAsB;wBAC5B,MAAM,EAAE,YAAY;wBACpB,MAAM,EAAE,qCAAqC;qBAC9C;iBACF;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import type { BundleInfo, PartialContext } from '@ms-cloudpack/api-server';\nimport type { PackageJson, GeneratedPackageSettings } from '@ms-cloudpack/common-types';\nimport { ensureGeneratedSettingsForPackage } from '@ms-cloudpack/config';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\n\n/**\n * Check for dynamic `import()` statements of relative paths, and add any files where those are\n * found to `GeneratedPackageSettings.dynamicImports`.\n */\nexport async function evaluateDynamicImports(\n options: {\n info: BundleInfo;\n definition: PackageJson;\n packagePath: string;\n },\n context: PartialContext<'packages', 'config'>,\n): Promise<{\n dynamicImportsChanges: GeneratedPackageChanges[];\n shouldReevaluate: boolean;\n shouldRefresh: boolean;\n}> {\n const { info, definition, packagePath } = options;\n const { packages, session } = context;\n const { config } = session;\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 dynamicImportsChanges: GeneratedPackageChanges[] = [];\n let shouldReevaluate = false;\n let shouldRefresh = false;\n let generatedPackageSettings: GeneratedPackageSettings | undefined;\n\n for (const entryInfo of Object.values(info)) {\n if (!entryInfo) {\n continue; // This is to make type-checking happy\n }\n for (const dynamicImport of entryInfo.dynamicImports || []) {\n if (dynamicImport.packageName !== '.') {\n continue;\n }\n\n const { importOrigin } = dynamicImport;\n // TODO: does this actually need to re-evaluate if there are no new imports?\n shouldReevaluate = true;\n generatedPackageSettings ??= await ensureGeneratedSettingsForPackage({ packagePath }, { config, packages });\n if (generatedPackageSettings?.dynamicImports?.includes(importOrigin)) {\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.dynamicImports ??= [];\n generatedPackageSettings.dynamicImports.push(importOrigin);\n shouldRefresh = true;\n\n dynamicImportsChanges.push({\n name: packageName,\n version: packageVersion,\n path: packagePath,\n changes: [\n {\n type: 'added-dynamic-import',\n change: importOrigin,\n reason: `Found non-literal path in import().`,\n },\n ],\n });\n }\n }\n\n return { dynamicImportsChanges, shouldReevaluate, shouldRefresh };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyExports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,4BAA4B,CAAC;AAGpC,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,cAAc,CAAC,UAAU,EAAE,QAAQ,GAAG,YAAY,CAAC,GAC3D,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"verifyExports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,4BAA4B,CAAC;AAGpC,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,cAAc,CAAC,UAAU,EAAE,QAAQ,GAAG,YAAY,CAAC,GAC3D,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC,CAmL1C"}
|
|
@@ -49,13 +49,17 @@ export async function verifyExports(packageResults, context) {
|
|
|
49
49
|
const sourceMainEntry = await getSourceEntry({ entry: '.', inputPath: parentPath }, { packages, config });
|
|
50
50
|
const importingSource = path.join(parentPath, sourceMainEntry || '.');
|
|
51
51
|
// Iterate through each entry path from the parent package
|
|
52
|
-
for (const
|
|
52
|
+
for (const parentInfo of Object.values(parentResult.info)) {
|
|
53
53
|
// Skip entries with no imports
|
|
54
|
-
if (!consumes?.length) {
|
|
54
|
+
if (!parentInfo?.consumes?.length) {
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
57
|
// Iterate through each imported package
|
|
58
|
-
for (const { packageName: depName, importPath: depImportPath, names: consumedNames } of consumes) {
|
|
58
|
+
for (const { packageName: depName, importPath: depImportPath, names: consumedNames } of parentInfo.consumes) {
|
|
59
|
+
// Skip imports from the current package or the same package name.
|
|
60
|
+
if (depName === '.' || depName === parentDefinition.name) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
59
63
|
const dependencyInfo = getDependencyInfo({
|
|
60
64
|
packageName: depName,
|
|
61
65
|
definition: parentDefinition,
|
|
@@ -75,6 +79,7 @@ export async function verifyExports(packageResults, context) {
|
|
|
75
79
|
continue;
|
|
76
80
|
}
|
|
77
81
|
const importProducesStarResult = await importProducesStar({
|
|
82
|
+
name: depName,
|
|
78
83
|
packagePath: depResolveMapEntry.path,
|
|
79
84
|
importPath: depImportPath,
|
|
80
85
|
info: depEntries,
|
|
@@ -101,7 +106,7 @@ export async function verifyExports(packageResults, context) {
|
|
|
101
106
|
importName: depName,
|
|
102
107
|
importPath: depImportPath,
|
|
103
108
|
importVersion: depResolveMapEntry.version,
|
|
104
|
-
bundledFile: path.join(depOutputPath ?? '', depEntries[depImportPath]?.bundlePath),
|
|
109
|
+
bundledFile: path.join(depOutputPath ?? '', depEntries[depImportPath]?.bundlePath || '.'),
|
|
105
110
|
};
|
|
106
111
|
missing.forEach((m) => depsMissingExports[depKey][filePath].missingNames.add(m));
|
|
107
112
|
// Check if the package satisfies the parent semver requirement.
|
|
@@ -143,7 +148,7 @@ export async function verifyExports(packageResults, context) {
|
|
|
143
148
|
return allErrors;
|
|
144
149
|
}
|
|
145
150
|
async function importProducesStar(params) {
|
|
146
|
-
const { packagePath, info, importPath, context, visited = new Set(), cache = {} } = params;
|
|
151
|
+
const { name, packagePath, info, importPath, context, visited = new Set(), cache = {} } = params;
|
|
147
152
|
const key = `${packagePath}${importPath}`;
|
|
148
153
|
// Check if the entry has already been visited to avoid cycles
|
|
149
154
|
if (visited.has(key)) {
|
|
@@ -157,33 +162,52 @@ async function importProducesStar(params) {
|
|
|
157
162
|
}
|
|
158
163
|
const { packages, resolveMap, packageResultsArray } = context;
|
|
159
164
|
let result = [];
|
|
165
|
+
if (!info[importPath]) {
|
|
166
|
+
// If the importPath is not found in the info, return an empty array.
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
160
169
|
// Iterate over the produced names
|
|
161
|
-
for (const
|
|
162
|
-
if (
|
|
163
|
-
// Extract the name and path from the format "*ImportString"
|
|
164
|
-
const { packageName: depName, importPath: depImportPath } = parseImportString(name.slice(1));
|
|
165
|
-
const dependencyInfo = getDependencyInfo({
|
|
166
|
-
packageName: depName,
|
|
167
|
-
definition: await packages.get(packagePath),
|
|
168
|
-
resolveMap,
|
|
169
|
-
packageResultsArray,
|
|
170
|
-
});
|
|
171
|
-
if (dependencyInfo) {
|
|
172
|
-
const { depResolveMapEntry, depResult } = dependencyInfo;
|
|
173
|
-
// Recursively aggregate the produced names from the other package
|
|
174
|
-
result = result.concat(await importProducesStar({
|
|
175
|
-
packagePath: depResolveMapEntry.path,
|
|
176
|
-
info: depResult.info,
|
|
177
|
-
importPath: depImportPath,
|
|
178
|
-
context,
|
|
179
|
-
visited,
|
|
180
|
-
}));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
170
|
+
for (const exportedName of info[importPath].produces) {
|
|
171
|
+
if (!exportedName.startsWith('*')) {
|
|
184
172
|
// Add the name to the result if it doesn't start with '*'
|
|
185
|
-
result.push(
|
|
173
|
+
result.push(exportedName);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
// Extract the name and path from the format "*ImportString"
|
|
177
|
+
const { packageName: depName, importPath: depImportPath } = parseImportString(exportedName.slice(1));
|
|
178
|
+
if (depName === name) {
|
|
179
|
+
// Reuse the current packagePath and info if it is an import from the same package.
|
|
180
|
+
result = result.concat(await importProducesStar({
|
|
181
|
+
name,
|
|
182
|
+
packagePath,
|
|
183
|
+
info,
|
|
184
|
+
importPath: depImportPath,
|
|
185
|
+
context,
|
|
186
|
+
visited,
|
|
187
|
+
cache,
|
|
188
|
+
}));
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const dependencyInfo = getDependencyInfo({
|
|
192
|
+
packageName: depName,
|
|
193
|
+
definition: await packages.get(packagePath),
|
|
194
|
+
resolveMap,
|
|
195
|
+
packageResultsArray,
|
|
196
|
+
});
|
|
197
|
+
if (!dependencyInfo) {
|
|
198
|
+
continue; // Skip if we can't find the imported package in the resolve map, or there's no info about its entries/exports.
|
|
186
199
|
}
|
|
200
|
+
const { depResolveMapEntry, depResult } = dependencyInfo;
|
|
201
|
+
// Recursively aggregate the produced names from the other package
|
|
202
|
+
result = result.concat(await importProducesStar({
|
|
203
|
+
name: depName,
|
|
204
|
+
packagePath: depResolveMapEntry.path,
|
|
205
|
+
info: depResult.info,
|
|
206
|
+
importPath: depImportPath,
|
|
207
|
+
context,
|
|
208
|
+
visited,
|
|
209
|
+
cache,
|
|
210
|
+
}));
|
|
187
211
|
}
|
|
188
212
|
cache[key] = result;
|
|
189
213
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyExports.js","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACvG,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,OAA4D;IAE5D,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,C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CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,KAAK,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAElH,0FAA0F;IAC1F,uBAAuB;IACvB,IAAI,CAAC,kBAAkB,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC;QAC5C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAoD,EAAE,CAAC;AACjG,CAAC","sourcesContent":["import type { BundleInfo, PartialContext } from '@ms-cloudpack/api-server';\nimport type {\n BundleMessage,\n PackageDefinitionsCache,\n PackageJson,\n ResolveMap,\n ResolveMapEntry,\n WithRequired,\n} from '@ms-cloudpack/common-types';\nimport { findResolveMapEntry, getDependencies, getSourceEntry } 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: PartialContext<'packages', 'config' | 'resolveMap'>,\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 ignoreMissingExports =\n getPackageSettings({\n name,\n version,\n userPackageSettings: config.packageSettings,\n includeBuiltIn: true,\n generatedPackageSettings: undefined,\n }).userPackageSettings?.ignoreMissingExports || {};\n\n if (ignoreMissingExports === true) {\n continue;\n }\n\n const parentDefinition = await packages.get(parentPath);\n const allParentDependencies = getDependencies(parentDefinition, { includeAll: true });\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 !ignoreMissingExports[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 = !invalidSemver[depKey] && allParentDependencies[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(params: {\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 { packagePath, info, importPath, context, visited = new Set(), cache = {} } = params;\n\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\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 // 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 || !depResult?.info) {\n return undefined;\n }\n\n return { depResolveMapEntry, depResult: depResult as WithRequired<InitPackageResult, 'info'> };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"verifyExports.js","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACvG,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,OAA4D;IAE5D,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;QA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;YACzB,OAAO;YACP,OAAO;YACP,KAAK;SACN,CAAC,CACH,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;IACpB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,iBAAiB,CAAC,OAK1B;IAMC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC;IAE7E,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IACxF,MAAM,SAAS,GACb,kBAAkB;QAClB,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,KAAK,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAElH,0FAA0F;IAC1F,uBAAuB;IACvB,IAAI,CAAC,kBAAkB,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC;QAC5C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAoD,EAAE,CAAC;AACjG,CAAC","sourcesContent":["import type { BundleInfo, PartialContext } from '@ms-cloudpack/api-server';\nimport type {\n BundleMessage,\n PackageDefinitionsCache,\n PackageJson,\n ResolveMap,\n ResolveMapEntry,\n WithRequired,\n} from '@ms-cloudpack/common-types';\nimport { findResolveMapEntry, getDependencies, getSourceEntry } 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: PartialContext<'packages', 'config' | 'resolveMap'>,\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 ignoreMissingExports =\n getPackageSettings({\n name,\n version,\n userPackageSettings: config.packageSettings,\n includeBuiltIn: true,\n generatedPackageSettings: undefined,\n }).userPackageSettings?.ignoreMissingExports || {};\n\n if (ignoreMissingExports === true) {\n continue;\n }\n\n const parentDefinition = await packages.get(parentPath);\n const allParentDependencies = getDependencies(parentDefinition, { includeAll: true });\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 parentInfo of Object.values(parentResult.info)) {\n // Skip entries with no imports\n if (!parentInfo?.consumes?.length) {\n continue;\n }\n\n // Iterate through each imported package\n for (const { packageName: depName, importPath: depImportPath, names: consumedNames } of parentInfo.consumes) {\n // Skip imports from the current package or the same package name.\n if (depName === '.' || depName === parentDefinition.name) {\n continue;\n }\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 name: depName,\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 !ignoreMissingExports[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 = !invalidSemver[depKey] && allParentDependencies[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(params: {\n name: string;\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 { name, packagePath, info, importPath, context, visited = new Set(), cache = {} } = params;\n\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 if (!info[importPath]) {\n // If the importPath is not found in the info, return an empty array.\n return result;\n }\n\n // Iterate over the produced names\n for (const exportedName of info[importPath].produces) {\n if (!exportedName.startsWith('*')) {\n // Add the name to the result if it doesn't start with '*'\n result.push(exportedName);\n continue;\n }\n\n // Extract the name and path from the format \"*ImportString\"\n const { packageName: depName, importPath: depImportPath } = parseImportString(exportedName.slice(1));\n\n if (depName === name) {\n // Reuse the current packagePath and info if it is an import from the same package.\n result = result.concat(\n await importProducesStar({\n name,\n packagePath,\n info,\n importPath: depImportPath,\n context,\n visited,\n cache,\n }),\n );\n continue;\n }\n\n const dependencyInfo = getDependencyInfo({\n packageName: depName,\n definition: await packages.get(packagePath),\n resolveMap,\n packageResultsArray,\n });\n\n if (!dependencyInfo) {\n continue; // Skip if we can't find the imported package in the resolve map, or there's no info about its entries/exports.\n }\n\n const { depResolveMapEntry, depResult } = dependencyInfo;\n\n // Recursively aggregate the produced names from the other package\n result = result.concat(\n await importProducesStar({\n name: depName,\n packagePath: depResolveMapEntry.path,\n info: depResult.info,\n importPath: depImportPath,\n context,\n visited,\n cache,\n }),\n );\n }\n\n cache[key] = result;\n return result;\n}\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 // 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 || !depResult?.info) {\n return undefined;\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.
|
|
3
|
+
"version": "0.75.0",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,24 +18,24 @@
|
|
|
18
18
|
"cloudpack": "./bin/cloudpack.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ms-cloudpack/api-server": "^0.63.
|
|
22
|
-
"@ms-cloudpack/app-server": "^0.18.
|
|
23
|
-
"@ms-cloudpack/bundler": "^0.25.
|
|
21
|
+
"@ms-cloudpack/api-server": "^0.63.11",
|
|
22
|
+
"@ms-cloudpack/app-server": "^0.18.14",
|
|
23
|
+
"@ms-cloudpack/bundler": "^0.25.13",
|
|
24
24
|
"@ms-cloudpack/bundler-capabilities": "^0.2.26",
|
|
25
25
|
"@ms-cloudpack/common-types": "^0.24.20",
|
|
26
|
-
"@ms-cloudpack/config": "^0.35.
|
|
27
|
-
"@ms-cloudpack/create-express-app": "^1.10.
|
|
26
|
+
"@ms-cloudpack/config": "^0.35.10",
|
|
27
|
+
"@ms-cloudpack/create-express-app": "^1.10.35",
|
|
28
28
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
29
29
|
"@ms-cloudpack/json-utilities": "^0.1.10",
|
|
30
|
-
"@ms-cloudpack/link-proxy": "^0.2.
|
|
31
|
-
"@ms-cloudpack/overlay": "^0.19.
|
|
32
|
-
"@ms-cloudpack/package-utilities": "^12.3.
|
|
30
|
+
"@ms-cloudpack/link-proxy": "^0.2.13",
|
|
31
|
+
"@ms-cloudpack/overlay": "^0.19.9",
|
|
32
|
+
"@ms-cloudpack/package-utilities": "^12.3.12",
|
|
33
33
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
34
|
-
"@ms-cloudpack/path-utilities": "^3.1.
|
|
35
|
-
"@ms-cloudpack/remote-cache": "^0.11.
|
|
34
|
+
"@ms-cloudpack/path-utilities": "^3.1.6",
|
|
35
|
+
"@ms-cloudpack/remote-cache": "^0.11.22",
|
|
36
36
|
"@ms-cloudpack/setup-utilities": "^0.5.27",
|
|
37
37
|
"@ms-cloudpack/task-reporter": "^0.17.0",
|
|
38
|
-
"@ms-cloudpack/telemetry": "^0.11.
|
|
38
|
+
"@ms-cloudpack/telemetry": "^0.11.24",
|
|
39
39
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
40
40
|
"commander": "^13.0.0",
|
|
41
41
|
"cross-spawn": "^7.0.3",
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"lib/**/!(*.test.*)"
|
|
74
74
|
],
|
|
75
75
|
"engines": {
|
|
76
|
-
"node": ">=
|
|
76
|
+
"node": ">=20.11.0"
|
|
77
77
|
}
|
|
78
78
|
}
|