@walkeros/cli 3.3.0-next-1776098542393 → 3.3.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/CHANGELOG.md +3 -3
- package/dist/cli.js +15195 -15249
- package/dist/index.js +102 -28
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -966,6 +966,15 @@ async function withTimeout(promise, ms, errorMessage) {
|
|
|
966
966
|
function getPackageDirectory(baseDir, packageName) {
|
|
967
967
|
return path8.join(baseDir, "node_modules", packageName);
|
|
968
968
|
}
|
|
969
|
+
function getNestedPackageDirectory(baseDir, consumerName, nestedPackageName) {
|
|
970
|
+
return path8.join(
|
|
971
|
+
baseDir,
|
|
972
|
+
"node_modules",
|
|
973
|
+
consumerName,
|
|
974
|
+
"node_modules",
|
|
975
|
+
nestedPackageName
|
|
976
|
+
);
|
|
977
|
+
}
|
|
969
978
|
async function collectAllSpecs(packages, logger, configDir, overrides = {}) {
|
|
970
979
|
const allSpecs = /* @__PURE__ */ new Map();
|
|
971
980
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -1094,11 +1103,12 @@ async function collectAllSpecs(packages, logger, configDir, overrides = {}) {
|
|
|
1094
1103
|
return allSpecs;
|
|
1095
1104
|
}
|
|
1096
1105
|
function resolveVersionConflicts(allSpecs, logger) {
|
|
1097
|
-
const
|
|
1106
|
+
const topLevel = /* @__PURE__ */ new Map();
|
|
1107
|
+
const nested = [];
|
|
1098
1108
|
for (const [name, specs] of allSpecs) {
|
|
1099
1109
|
const localSpec = specs.find((s) => s.localPath);
|
|
1100
1110
|
if (localSpec) {
|
|
1101
|
-
|
|
1111
|
+
topLevel.set(name, {
|
|
1102
1112
|
name,
|
|
1103
1113
|
version: "local",
|
|
1104
1114
|
localPath: localSpec.localPath
|
|
@@ -1124,6 +1134,7 @@ function resolveVersionConflicts(allSpecs, logger) {
|
|
|
1124
1134
|
const directSpecs = activeSpecs.filter((s) => s.source === "direct");
|
|
1125
1135
|
const directExact = directSpecs.find((s) => semver2.valid(s.spec) !== null);
|
|
1126
1136
|
let chosenVersion;
|
|
1137
|
+
const alreadyNested = /* @__PURE__ */ new Set();
|
|
1127
1138
|
if (directExact) {
|
|
1128
1139
|
chosenVersion = directExact.spec;
|
|
1129
1140
|
} else if (directSpecs.length > 0) {
|
|
@@ -1132,9 +1143,14 @@ function resolveVersionConflicts(allSpecs, logger) {
|
|
|
1132
1143
|
const exactVersions = activeSpecs.filter((s) => semver2.valid(s.spec) !== null).map((s) => s.spec);
|
|
1133
1144
|
const uniqueExact = [...new Set(exactVersions)];
|
|
1134
1145
|
if (uniqueExact.length > 1) {
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
)
|
|
1146
|
+
const sorted = [...uniqueExact].sort(semver2.rcompare);
|
|
1147
|
+
chosenVersion = sorted[0];
|
|
1148
|
+
for (let i2 = 1; i2 < sorted.length; i2++) {
|
|
1149
|
+
const loserVersion = sorted[i2];
|
|
1150
|
+
const consumers = activeSpecs.filter((s) => s.spec === loserVersion).map((s) => s.from);
|
|
1151
|
+
nested.push({ name, version: loserVersion, consumers });
|
|
1152
|
+
alreadyNested.add(loserVersion);
|
|
1153
|
+
}
|
|
1138
1154
|
} else if (uniqueExact.length === 1) {
|
|
1139
1155
|
chosenVersion = uniqueExact[0];
|
|
1140
1156
|
} else {
|
|
@@ -1150,6 +1166,9 @@ function resolveVersionConflicts(allSpecs, logger) {
|
|
|
1150
1166
|
logger.warn(
|
|
1151
1167
|
`${name}@${chosenVersion} differs from peer constraint ${spec.spec} (from ${spec.from})`
|
|
1152
1168
|
);
|
|
1169
|
+
} else if (!alreadyNested.has(spec.spec)) {
|
|
1170
|
+
nested.push({ name, version: spec.spec, consumers: [spec.from] });
|
|
1171
|
+
alreadyNested.add(spec.spec);
|
|
1153
1172
|
}
|
|
1154
1173
|
}
|
|
1155
1174
|
} else {
|
|
@@ -1161,17 +1180,27 @@ function resolveVersionConflicts(allSpecs, logger) {
|
|
|
1161
1180
|
`${name}@${chosenVersion} may not satisfy peer constraint ${spec.spec} (from ${spec.from})`
|
|
1162
1181
|
);
|
|
1163
1182
|
} else {
|
|
1164
|
-
|
|
1165
|
-
`Version conflict: ${name}@${chosenVersion} does not satisfy ${spec.spec} required by ${spec.from}`
|
|
1166
|
-
);
|
|
1183
|
+
nested.push({ name, version: spec.spec, consumers: [spec.from] });
|
|
1167
1184
|
}
|
|
1168
1185
|
}
|
|
1169
1186
|
}
|
|
1170
1187
|
}
|
|
1171
1188
|
}
|
|
1172
|
-
|
|
1189
|
+
topLevel.set(name, { name, version: chosenVersion });
|
|
1173
1190
|
}
|
|
1174
|
-
|
|
1191
|
+
const consolidatedMap = /* @__PURE__ */ new Map();
|
|
1192
|
+
for (const entry of nested) {
|
|
1193
|
+
const key = `${entry.name}@${entry.version}`;
|
|
1194
|
+
const existing = consolidatedMap.get(key);
|
|
1195
|
+
if (existing) {
|
|
1196
|
+
for (const c2 of entry.consumers) {
|
|
1197
|
+
if (!existing.consumers.includes(c2)) existing.consumers.push(c2);
|
|
1198
|
+
}
|
|
1199
|
+
} else {
|
|
1200
|
+
consolidatedMap.set(key, { ...entry, consumers: [...entry.consumers] });
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
return { topLevel, nested: [...consolidatedMap.values()] };
|
|
1175
1204
|
}
|
|
1176
1205
|
async function downloadPackages(packages, targetDir, logger, useCache = true, configDir, tmpDir, overrides = {}) {
|
|
1177
1206
|
const packagePaths = /* @__PURE__ */ new Map();
|
|
@@ -1184,13 +1213,13 @@ async function downloadPackages(packages, targetDir, logger, useCache = true, co
|
|
|
1184
1213
|
configDir,
|
|
1185
1214
|
overrides
|
|
1186
1215
|
);
|
|
1187
|
-
const
|
|
1216
|
+
const { topLevel, nested } = resolveVersionConflicts(allSpecs, logger);
|
|
1188
1217
|
await fs7.ensureDir(targetDir);
|
|
1189
1218
|
const localPackageMap = /* @__PURE__ */ new Map();
|
|
1190
1219
|
for (const pkg of packages) {
|
|
1191
1220
|
if (pkg.path) localPackageMap.set(pkg.name, pkg.path);
|
|
1192
1221
|
}
|
|
1193
|
-
for (const [name, pkg] of
|
|
1222
|
+
for (const [name, pkg] of topLevel) {
|
|
1194
1223
|
if (pkg.localPath || localPackageMap.has(name)) {
|
|
1195
1224
|
const localPath = pkg.localPath || localPackageMap.get(name);
|
|
1196
1225
|
const localPkg = await resolveLocalPackage(
|
|
@@ -1248,6 +1277,48 @@ async function downloadPackages(packages, targetDir, logger, useCache = true, co
|
|
|
1248
1277
|
throw new Error(`Failed to download ${packageSpec}: ${error}`);
|
|
1249
1278
|
}
|
|
1250
1279
|
}
|
|
1280
|
+
for (const nestedPkg of nested) {
|
|
1281
|
+
let resolvedSpec = `${nestedPkg.name}@${nestedPkg.version}`;
|
|
1282
|
+
if (!semver2.valid(nestedPkg.version)) {
|
|
1283
|
+
try {
|
|
1284
|
+
const manifest = await withTimeout(
|
|
1285
|
+
pacote.manifest(resolvedSpec, PACOTE_OPTS),
|
|
1286
|
+
PACKAGE_DOWNLOAD_TIMEOUT_MS,
|
|
1287
|
+
`Manifest fetch timed out: ${resolvedSpec}`
|
|
1288
|
+
);
|
|
1289
|
+
const resolved = manifest.version;
|
|
1290
|
+
resolvedSpec = `${nestedPkg.name}@${resolved}`;
|
|
1291
|
+
} catch (error) {
|
|
1292
|
+
throw new Error(
|
|
1293
|
+
`Failed to resolve nested dependency ${resolvedSpec}: ${error}`
|
|
1294
|
+
);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
for (const consumer of nestedPkg.consumers) {
|
|
1298
|
+
const nestedDir = getNestedPackageDirectory(
|
|
1299
|
+
targetDir,
|
|
1300
|
+
consumer,
|
|
1301
|
+
nestedPkg.name
|
|
1302
|
+
);
|
|
1303
|
+
try {
|
|
1304
|
+
await fs7.ensureDir(path8.dirname(nestedDir));
|
|
1305
|
+
const cacheDir = process.env.NPM_CACHE_DIR || getTmpPath(tmpDir, "cache", "npm");
|
|
1306
|
+
await withTimeout(
|
|
1307
|
+
pacote.extract(resolvedSpec, nestedDir, {
|
|
1308
|
+
...PACOTE_OPTS,
|
|
1309
|
+
cache: cacheDir
|
|
1310
|
+
}),
|
|
1311
|
+
PACKAGE_DOWNLOAD_TIMEOUT_MS,
|
|
1312
|
+
`Nested package download timed out: ${resolvedSpec}`
|
|
1313
|
+
);
|
|
1314
|
+
logger.debug(`Nested: ${resolvedSpec} under ${consumer}`);
|
|
1315
|
+
} catch (error) {
|
|
1316
|
+
throw new Error(
|
|
1317
|
+
`Failed to install nested ${resolvedSpec} for ${consumer}: ${error}`
|
|
1318
|
+
);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1251
1322
|
return packagePaths;
|
|
1252
1323
|
}
|
|
1253
1324
|
async function getCachedPackagePath(pkg, tmpDir) {
|
|
@@ -1932,7 +2003,7 @@ function detectExplicitCodeImports(flowSettings) {
|
|
|
1932
2003
|
}
|
|
1933
2004
|
return explicitCodeImports;
|
|
1934
2005
|
}
|
|
1935
|
-
async function generateImportStatements(packages, destinationPackages, sourcePackages, transformerPackages, storePackages, explicitCodeImports, packagePaths) {
|
|
2006
|
+
async function generateImportStatements(packages, destinationPackages, sourcePackages, transformerPackages, storePackages, explicitCodeImports, packagePaths, withDev) {
|
|
1936
2007
|
const importStatements = [];
|
|
1937
2008
|
const usedPackages = /* @__PURE__ */ new Set([
|
|
1938
2009
|
...destinationPackages,
|
|
@@ -1978,21 +2049,23 @@ async function generateImportStatements(packages, destinationPackages, sourcePac
|
|
|
1978
2049
|
}
|
|
1979
2050
|
}
|
|
1980
2051
|
const devExportEntries = [];
|
|
1981
|
-
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
2052
|
+
if (withDev) {
|
|
2053
|
+
for (const packageName of usedPackages) {
|
|
2054
|
+
const localPath = packagePaths.get(packageName);
|
|
2055
|
+
if (!localPath) continue;
|
|
2056
|
+
try {
|
|
2057
|
+
const pkgJsonPath = path10.join(localPath, "package.json");
|
|
2058
|
+
const pkgJson = await fs9.readJSON(pkgJsonPath);
|
|
2059
|
+
const exports = pkgJson.exports;
|
|
2060
|
+
if (exports && typeof exports === "object" && "./dev" in exports) {
|
|
2061
|
+
const varName = `__dev_${packageNameToVariable(packageName)}`;
|
|
2062
|
+
importStatements.push(
|
|
2063
|
+
`import * as ${varName} from '${packageName}/dev';`
|
|
2064
|
+
);
|
|
2065
|
+
devExportEntries.push(`'${packageName}': ${varName}`);
|
|
2066
|
+
}
|
|
2067
|
+
} catch {
|
|
1994
2068
|
}
|
|
1995
|
-
} catch {
|
|
1996
2069
|
}
|
|
1997
2070
|
}
|
|
1998
2071
|
return { importStatements, devExportEntries };
|
|
@@ -2065,7 +2138,8 @@ async function createEntryPoint(flowSettings, buildOptions, packagePaths) {
|
|
|
2065
2138
|
transformerPackages,
|
|
2066
2139
|
storePackages,
|
|
2067
2140
|
explicitCodeImports,
|
|
2068
|
-
packagePaths
|
|
2141
|
+
packagePaths,
|
|
2142
|
+
buildOptions.skipWrapper === true
|
|
2069
2143
|
);
|
|
2070
2144
|
const importsCode = importStatements.join("\n");
|
|
2071
2145
|
const hasFlow = Object.values(flowSettings.sources || {}).some(
|