@socketsecurity/cli 0.14.7 → 0.14.8
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/dist/cli.js +21 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1263,6 +1263,7 @@ async function addOverrides({
|
|
|
1263
1263
|
if (overridesData) {
|
|
1264
1264
|
overridesDataObjects.push(overridesData);
|
|
1265
1265
|
}
|
|
1266
|
+
const aliasMap = new Map();
|
|
1266
1267
|
for (const {
|
|
1267
1268
|
1: data
|
|
1268
1269
|
} of availableOverrides) {
|
|
@@ -1274,20 +1275,36 @@ async function addOverrides({
|
|
|
1274
1275
|
for (const {
|
|
1275
1276
|
1: depObj
|
|
1276
1277
|
} of depEntries) {
|
|
1277
|
-
|
|
1278
|
+
let pkgSpec = depObj[origPkgName];
|
|
1278
1279
|
if (pkgSpec) {
|
|
1279
|
-
|
|
1280
|
+
// Add package aliases for direct dependencies to avoid npm EOVERRIDE errors.
|
|
1281
|
+
// https://docs.npmjs.com/cli/v8/using-npm/package-spec#aliases
|
|
1282
|
+
const overrideSpecPrefix = `npm:${regPkgName}@`;
|
|
1283
|
+
if (!pkgSpec.startsWith(overrideSpecPrefix)) {
|
|
1284
|
+
aliasMap.set(regPkgName, pkgSpec);
|
|
1285
|
+
} else {
|
|
1280
1286
|
packageNames.add(regPkgName);
|
|
1281
|
-
|
|
1287
|
+
pkgSpec = `${overrideSpecPrefix}^${version}`;
|
|
1288
|
+
depObj[origPkgName] = pkgSpec;
|
|
1282
1289
|
}
|
|
1290
|
+
aliasMap.set(origPkgName, pkgSpec);
|
|
1283
1291
|
}
|
|
1284
1292
|
}
|
|
1285
1293
|
for (const {
|
|
1294
|
+
type,
|
|
1286
1295
|
overrides
|
|
1287
1296
|
} of overridesDataObjects) {
|
|
1288
1297
|
if (overrides && !(0, _objects.hasOwn)(overrides, origPkgName) && lockIncludes(lockSrc, origPkgName)) {
|
|
1289
1298
|
packageNames.add(regPkgName);
|
|
1290
|
-
overrides[origPkgName] =
|
|
1299
|
+
overrides[origPkgName] =
|
|
1300
|
+
// With npm you may not set an override for a package that you directly
|
|
1301
|
+
// depend on unless both the dependency and the override itself share
|
|
1302
|
+
// the exact same spec. To make this limitation easier to deal with,
|
|
1303
|
+
// overrides may also be defined as a reference to a spec for a direct
|
|
1304
|
+
// dependency by prefixing the name of the package you wish the version
|
|
1305
|
+
// to match with a $.
|
|
1306
|
+
// https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
|
|
1307
|
+
type === 'npm' && aliasMap.has(origPkgName) && `$${origPkgName}` || `npm:${regPkgName}@^${_semver.major(version)}`;
|
|
1291
1308
|
}
|
|
1292
1309
|
}
|
|
1293
1310
|
}
|