socket 0.14.17 → 0.14.18
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 +22 -11
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1370,6 +1370,7 @@ async function addOverrides({
|
|
|
1370
1370
|
package: origPkgName,
|
|
1371
1371
|
version
|
|
1372
1372
|
} = data;
|
|
1373
|
+
const major = _semver.major(version);
|
|
1373
1374
|
for (const {
|
|
1374
1375
|
1: depObj
|
|
1375
1376
|
} of depEntries) {
|
|
@@ -1403,17 +1404,27 @@ async function addOverrides({
|
|
|
1403
1404
|
}) => {
|
|
1404
1405
|
const overrideExists = (0, _objects.hasOwn)(overrides, origPkgName);
|
|
1405
1406
|
if (overrideExists || lockIncludes(lockSrc, origPkgName)) {
|
|
1406
|
-
|
|
1407
|
-
// depends on unless both the dependency and the override itself share
|
|
1408
|
-
// the exact same spec. To make this limitation easier to deal with,
|
|
1409
|
-
// overrides may also be defined as a reference to a spec for a direct
|
|
1410
|
-
// dependency by prefixing the name of the package to match the version
|
|
1411
|
-
// of with a $.
|
|
1412
|
-
// https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
|
|
1413
|
-
const oldSpec = overrides[origPkgName];
|
|
1407
|
+
const oldSpec = overrideExists ? overrides[origPkgName] : undefined;
|
|
1414
1408
|
const depAlias = depAliasMap.get(origPkgName);
|
|
1415
|
-
|
|
1416
|
-
|
|
1409
|
+
let newSpec = `npm:${regPkgName}@^${pin ? version : major}`;
|
|
1410
|
+
let thisVersion = version;
|
|
1411
|
+
if (depAlias && type === 'npm') {
|
|
1412
|
+
// With npm one may not set an override for a package that one directly
|
|
1413
|
+
// depends on unless both the dependency and the override itself share
|
|
1414
|
+
// the exact same spec. To make this limitation easier to deal with,
|
|
1415
|
+
// overrides may also be defined as a reference to a spec for a direct
|
|
1416
|
+
// dependency by prefixing the name of the package to match the version
|
|
1417
|
+
// of with a $.
|
|
1418
|
+
// https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
|
|
1419
|
+
newSpec = `$${origPkgName}`;
|
|
1420
|
+
} else if (overrideExists && pin) {
|
|
1421
|
+
const thisSpec = oldSpec.startsWith('$') ? depAlias?.id ?? newSpec : oldSpec ?? newSpec;
|
|
1422
|
+
thisVersion = _semver.coerce(_npmPackageArg(thisSpec).rawSpec)?.version ?? version;
|
|
1423
|
+
if (_semver.major(thisVersion) !== major) {
|
|
1424
|
+
thisVersion = (await fetchPackageManifest(thisSpec))?.version ?? version;
|
|
1425
|
+
}
|
|
1426
|
+
newSpec = `npm:${regPkgName}@^${pin ? thisVersion : _semver.major(thisVersion)}`;
|
|
1427
|
+
}
|
|
1417
1428
|
if (newSpec !== oldSpec) {
|
|
1418
1429
|
if (overrideExists) {
|
|
1419
1430
|
state.updated.add(regPkgName);
|
|
@@ -1551,7 +1562,7 @@ const optimize = optimize$1.optimize = {
|
|
|
1551
1562
|
rootPath: pkgPath
|
|
1552
1563
|
}, state);
|
|
1553
1564
|
}
|
|
1554
|
-
const pkgJsonChanged = state.
|
|
1565
|
+
const pkgJsonChanged = state.added.size > 0 || state.updated.size > 0;
|
|
1555
1566
|
if (state.updated.size > 0) {
|
|
1556
1567
|
console.log(`Updated ${state.updated.size} Socket.dev optimized overrides ${state.added.size ? '.' : '🚀'}`);
|
|
1557
1568
|
}
|