@socketsecurity/cli 0.14.35 → 0.14.37
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/bin/cli.js +11 -7
- package/bin/npm-cli.js +2 -2
- package/bin/npx-cli.js +2 -2
- package/dist/constants.js +66 -22
- package/dist/module-sync/cli.js +212 -173
- package/dist/module-sync/constants.d.ts +9 -0
- package/dist/module-sync/constants.d.ts.map +1 -1
- package/dist/module-sync/npm-injection.js +1 -1
- package/dist/module-sync/path-resolve.d.ts +6 -1
- package/dist/module-sync/path-resolve.js +31 -4
- package/dist/module-sync/shadow-bin.d.ts +1 -1
- package/dist/module-sync/shadow-bin.js +17 -23
- package/dist/require/cli.js +212 -173
- package/dist/require/constants.d.ts.map +1 -1
- package/dist/require/npm-injection.js +1 -1
- package/dist/require/path-resolve.js +31 -4
- package/dist/require/shadow-bin.js +17 -23
- package/package.json +12 -12
package/dist/module-sync/cli.js
CHANGED
|
@@ -26,8 +26,8 @@ var sdk = require('./sdk.js');
|
|
|
26
26
|
var prompts = require('@socketsecurity/registry/lib/prompts');
|
|
27
27
|
var isInteractive = _socketInterop(require('is-interactive'));
|
|
28
28
|
var terminalLink = _socketInterop(require('terminal-link'));
|
|
29
|
-
var spawn = _socketInterop(require('@npmcli/promise-spawn'));
|
|
30
29
|
var fs$1 = require('node:fs/promises');
|
|
30
|
+
var spawn = _socketInterop(require('@npmcli/promise-spawn'));
|
|
31
31
|
var npa = _socketInterop(require('npm-package-arg'));
|
|
32
32
|
var semver = _socketInterop(require('semver'));
|
|
33
33
|
var tinyglobby = _socketInterop(require('tinyglobby'));
|
|
@@ -41,10 +41,9 @@ var strings = require('@socketsecurity/registry/lib/strings');
|
|
|
41
41
|
var browserslist = _socketInterop(require('browserslist'));
|
|
42
42
|
var which = _socketInterop(require('which'));
|
|
43
43
|
var hyrious__bun_lockb = require('@socketregistry/hyrious__bun.lockb');
|
|
44
|
-
var
|
|
44
|
+
var pathResolve = require('./path-resolve.js');
|
|
45
45
|
var betterAjvErrors = _socketInterop(require('@apideck/better-ajv-errors'));
|
|
46
46
|
var config = require('@socketsecurity/config');
|
|
47
|
-
var pathResolve = require('./path-resolve.js');
|
|
48
47
|
var homedir = require('node:os');
|
|
49
48
|
var readline = require('node:readline');
|
|
50
49
|
var node_process = require('node:process');
|
|
@@ -59,6 +58,8 @@ var util = require('node:util');
|
|
|
59
58
|
var TableWidget = _socketInterop(require('blessed-contrib/lib/widget/table'));
|
|
60
59
|
|
|
61
60
|
const {
|
|
61
|
+
NPM: NPM$4,
|
|
62
|
+
PNPM: PNPM$2,
|
|
62
63
|
cdxgenBinPath,
|
|
63
64
|
synpBinPath
|
|
64
65
|
} = constants;
|
|
@@ -71,7 +72,7 @@ const {
|
|
|
71
72
|
} = process.env;
|
|
72
73
|
const toLower = arg => arg.toLowerCase();
|
|
73
74
|
const arrayToLower = arg => arg.map(toLower);
|
|
74
|
-
const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs',
|
|
75
|
+
const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', NPM$4, PNPM$2, 'ts', 'tsx', 'typescript']);
|
|
75
76
|
const yargsConfig = {
|
|
76
77
|
configuration: {
|
|
77
78
|
'camel-case-expansion': false,
|
|
@@ -182,13 +183,13 @@ const cdxgen = {
|
|
|
182
183
|
let cleanupPackageLock = false;
|
|
183
184
|
if (yargv.type !== 'yarn' && nodejsPlatformTypes.has(yargv.type) && fs.existsSync('./yarn.lock')) {
|
|
184
185
|
if (fs.existsSync('./package-lock.json')) {
|
|
185
|
-
yargv.type =
|
|
186
|
+
yargv.type = NPM$4;
|
|
186
187
|
} else {
|
|
187
188
|
// Use synp to create a package-lock.json from the yarn.lock,
|
|
188
189
|
// based on the node_modules folder, for a more accurate SBOM.
|
|
189
190
|
try {
|
|
190
191
|
await npm$1.runBin(await fs.promises.realpath(synpBinPath), ['--source-file', './yarn.lock']);
|
|
191
|
-
yargv.type =
|
|
192
|
+
yargv.type = NPM$4;
|
|
192
193
|
cleanupPackageLock = true;
|
|
193
194
|
} catch {}
|
|
194
195
|
}
|
|
@@ -573,7 +574,7 @@ function formatScore(score) {
|
|
|
573
574
|
const {
|
|
574
575
|
SOCKET_PUBLIC_API_KEY
|
|
575
576
|
} = constants;
|
|
576
|
-
const description$
|
|
577
|
+
const description$5 = 'Socket API login';
|
|
577
578
|
const flags = {
|
|
578
579
|
apiBaseUrl: {
|
|
579
580
|
type: 'string',
|
|
@@ -588,7 +589,7 @@ function nonNullish(value) {
|
|
|
588
589
|
return value !== null && value !== undefined;
|
|
589
590
|
}
|
|
590
591
|
const login = {
|
|
591
|
-
description: description$
|
|
592
|
+
description: description$5,
|
|
592
593
|
async run(argv, importMeta, {
|
|
593
594
|
parentName
|
|
594
595
|
}) {
|
|
@@ -609,7 +610,7 @@ const login = {
|
|
|
609
610
|
$ ${name}
|
|
610
611
|
`, {
|
|
611
612
|
argv,
|
|
612
|
-
description: description$
|
|
613
|
+
description: description$5,
|
|
613
614
|
importMeta,
|
|
614
615
|
flags
|
|
615
616
|
});
|
|
@@ -685,9 +686,9 @@ const login = {
|
|
|
685
686
|
}
|
|
686
687
|
};
|
|
687
688
|
|
|
688
|
-
const description$
|
|
689
|
+
const description$4 = 'Socket API logout';
|
|
689
690
|
const logout = {
|
|
690
|
-
description: description$
|
|
691
|
+
description: description$4,
|
|
691
692
|
async run(argv, importMeta, {
|
|
692
693
|
parentName
|
|
693
694
|
}) {
|
|
@@ -702,7 +703,7 @@ const logout = {
|
|
|
702
703
|
$ ${name}
|
|
703
704
|
`, {
|
|
704
705
|
argv,
|
|
705
|
-
description: description$
|
|
706
|
+
description: description$4,
|
|
706
707
|
importMeta
|
|
707
708
|
});
|
|
708
709
|
let showHelp = cli.flags['help'];
|
|
@@ -722,58 +723,26 @@ const logout = {
|
|
|
722
723
|
};
|
|
723
724
|
|
|
724
725
|
const {
|
|
725
|
-
|
|
726
|
-
execPath: execPath$2,
|
|
727
|
-
rootBinPath: rootBinPath$2
|
|
726
|
+
NPM: NPM$3
|
|
728
727
|
} = constants;
|
|
729
|
-
const description$5 = 'npm wrapper functionality';
|
|
730
728
|
const npm = {
|
|
731
|
-
description:
|
|
732
|
-
async run(argv
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
// Lazily access constants.nodeNoWarningsFlags.
|
|
737
|
-
...constants.nodeNoWarningsFlags, wrapperPath, ...argv], {
|
|
738
|
-
signal: abortSignal$4,
|
|
739
|
-
stdio: 'inherit'
|
|
740
|
-
});
|
|
741
|
-
spawnPromise.process.on('exit', (code, signal) => {
|
|
742
|
-
if (signal) {
|
|
743
|
-
process.kill(process.pid, signal);
|
|
744
|
-
} else if (code !== null) {
|
|
745
|
-
process.exit(code);
|
|
746
|
-
}
|
|
747
|
-
});
|
|
748
|
-
await spawnPromise;
|
|
729
|
+
description: `${NPM$3} wrapper functionality`,
|
|
730
|
+
async run(argv) {
|
|
731
|
+
// Lazily access constants.distPath.
|
|
732
|
+
const shadowBin = require(`${constants.distPath}/shadow-bin.js`);
|
|
733
|
+
await shadowBin(NPM$3, argv);
|
|
749
734
|
}
|
|
750
735
|
};
|
|
751
736
|
|
|
752
737
|
const {
|
|
753
|
-
|
|
754
|
-
execPath: execPath$1,
|
|
755
|
-
rootBinPath: rootBinPath$1
|
|
738
|
+
NPX: NPX$1
|
|
756
739
|
} = constants;
|
|
757
|
-
const description$4 = 'npx wrapper functionality';
|
|
758
740
|
const npx = {
|
|
759
|
-
description:
|
|
760
|
-
async run(argv
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
// Lazily access constants.nodeNoWarningsFlags.
|
|
765
|
-
...constants.nodeNoWarningsFlags, wrapperPath, ...argv], {
|
|
766
|
-
abortSignal: abortSignal$3,
|
|
767
|
-
stdio: 'inherit'
|
|
768
|
-
});
|
|
769
|
-
spawnPromise.process.on('exit', (code, signal) => {
|
|
770
|
-
if (signal) {
|
|
771
|
-
process.kill(process.pid, signal);
|
|
772
|
-
} else if (code !== null) {
|
|
773
|
-
process.exit(code);
|
|
774
|
-
}
|
|
775
|
-
});
|
|
776
|
-
await spawnPromise;
|
|
741
|
+
description: `${NPX$1} wrapper functionality`,
|
|
742
|
+
async run(argv) {
|
|
743
|
+
// Lazily access constants.distPath.
|
|
744
|
+
const shadowBin = require(`${constants.distPath}/shadow-bin.js`);
|
|
745
|
+
await shadowBin(NPX$1, argv);
|
|
777
746
|
}
|
|
778
747
|
};
|
|
779
748
|
|
|
@@ -819,7 +788,17 @@ async function readFileUtf8(filepath, options) {
|
|
|
819
788
|
});
|
|
820
789
|
}
|
|
821
790
|
|
|
822
|
-
const
|
|
791
|
+
const {
|
|
792
|
+
BINARY_LOCK_EXT,
|
|
793
|
+
BUN: BUN$1,
|
|
794
|
+
LOCK_EXT: LOCK_EXT$1,
|
|
795
|
+
NPM: NPM$2,
|
|
796
|
+
PNPM: PNPM$1,
|
|
797
|
+
VLT: VLT$1,
|
|
798
|
+
YARN_BERRY: YARN_BERRY$1,
|
|
799
|
+
YARN_CLASSIC: YARN_CLASSIC$1
|
|
800
|
+
} = constants;
|
|
801
|
+
const AGENTS = [BUN$1, NPM$2, PNPM$1, YARN_BERRY$1, YARN_CLASSIC$1, VLT$1];
|
|
823
802
|
const {
|
|
824
803
|
compare: alphanumericComparator
|
|
825
804
|
} = new Intl.Collator(undefined, {
|
|
@@ -842,56 +821,64 @@ async function getAgentVersion(agentExecPath, cwd) {
|
|
|
842
821
|
} catch {}
|
|
843
822
|
return result;
|
|
844
823
|
}
|
|
824
|
+
|
|
825
|
+
// The order of LOCKS properties IS significant as it affects iteration order.
|
|
845
826
|
const LOCKS = {
|
|
846
|
-
|
|
827
|
+
[`bun${LOCK_EXT$1}`]: BUN$1,
|
|
828
|
+
[`bun${BINARY_LOCK_EXT}`]: BUN$1,
|
|
847
829
|
// If both package-lock.json and npm-shrinkwrap.json are present in the root
|
|
848
830
|
// of a project, npm-shrinkwrap.json will take precedence and package-lock.json
|
|
849
831
|
// will be ignored.
|
|
850
832
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#package-lockjson-vs-npm-shrinkwrapjson
|
|
851
|
-
'npm-shrinkwrap.json':
|
|
852
|
-
'package-lock.json':
|
|
853
|
-
'pnpm-lock.yaml':
|
|
854
|
-
'pnpm-lock.yml':
|
|
855
|
-
|
|
856
|
-
'vlt-lock.json':
|
|
857
|
-
//
|
|
833
|
+
'npm-shrinkwrap.json': NPM$2,
|
|
834
|
+
'package-lock.json': NPM$2,
|
|
835
|
+
'pnpm-lock.yaml': PNPM$1,
|
|
836
|
+
'pnpm-lock.yml': PNPM$1,
|
|
837
|
+
[`yarn${LOCK_EXT$1}`]: YARN_CLASSIC$1,
|
|
838
|
+
'vlt-lock.json': VLT$1,
|
|
839
|
+
// Lastly, look for a hidden lock file which is present if .npmrc has package-lock=false:
|
|
858
840
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#hidden-lockfiles
|
|
859
841
|
//
|
|
860
842
|
// Unlike the other LOCKS keys this key contains a directory AND filename so
|
|
861
843
|
// it has to be handled differently.
|
|
862
|
-
'node_modules/.package-lock.json':
|
|
844
|
+
'node_modules/.package-lock.json': NPM$2
|
|
863
845
|
};
|
|
864
846
|
const readLockFileByAgent = (() => {
|
|
865
847
|
function wrapReader(reader) {
|
|
866
|
-
return async (
|
|
848
|
+
return async (...args) => {
|
|
867
849
|
try {
|
|
868
|
-
return await reader(
|
|
850
|
+
return await reader(...args);
|
|
869
851
|
} catch {}
|
|
870
852
|
return undefined;
|
|
871
853
|
};
|
|
872
854
|
}
|
|
855
|
+
const binaryReader = wrapReader(readFileBinary);
|
|
873
856
|
const defaultReader = wrapReader(async lockPath => await readFileUtf8(lockPath));
|
|
874
857
|
return {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
} catch {
|
|
880
|
-
return undefined;
|
|
858
|
+
[BUN$1]: wrapReader(async (lockPath, agentExecPath) => {
|
|
859
|
+
const ext = path.extname(lockPath);
|
|
860
|
+
if (ext === LOCK_EXT$1) {
|
|
861
|
+
return await defaultReader(lockPath);
|
|
881
862
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
863
|
+
if (ext === BINARY_LOCK_EXT) {
|
|
864
|
+
const lockBuffer = await binaryReader(lockPath);
|
|
865
|
+
if (lockBuffer) {
|
|
866
|
+
try {
|
|
867
|
+
return hyrious__bun_lockb.parse(lockBuffer);
|
|
868
|
+
} catch {}
|
|
869
|
+
}
|
|
870
|
+
// To print a Yarn lockfile to your console without writing it to disk
|
|
871
|
+
// use `bun bun.lockb`.
|
|
872
|
+
// https://bun.sh/guides/install/yarnlock
|
|
873
|
+
return (await spawn(agentExecPath, [lockPath])).stdout.trim();
|
|
874
|
+
}
|
|
875
|
+
return undefined;
|
|
889
876
|
}),
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
877
|
+
[NPM$2]: defaultReader,
|
|
878
|
+
[PNPM$1]: defaultReader,
|
|
879
|
+
[VLT$1]: defaultReader,
|
|
880
|
+
[YARN_BERRY$1]: defaultReader,
|
|
881
|
+
[YARN_CLASSIC$1]: defaultReader
|
|
895
882
|
};
|
|
896
883
|
})();
|
|
897
884
|
async function detect({
|
|
@@ -901,7 +888,8 @@ async function detect({
|
|
|
901
888
|
let lockPath = await findUp(Object.keys(LOCKS), {
|
|
902
889
|
cwd
|
|
903
890
|
});
|
|
904
|
-
|
|
891
|
+
let lockBasename = lockPath ? path.basename(lockPath) : undefined;
|
|
892
|
+
const isHiddenLockFile = lockBasename === '.package-lock.json';
|
|
905
893
|
const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await findUp('package.json', {
|
|
906
894
|
cwd
|
|
907
895
|
});
|
|
@@ -926,20 +914,20 @@ async function detect({
|
|
|
926
914
|
}
|
|
927
915
|
}
|
|
928
916
|
}
|
|
929
|
-
if (agent === undefined && !isHiddenLockFile && typeof pkgJsonPath === 'string' && typeof
|
|
930
|
-
agent = LOCKS[
|
|
917
|
+
if (agent === undefined && !isHiddenLockFile && typeof pkgJsonPath === 'string' && typeof lockBasename === 'string') {
|
|
918
|
+
agent = LOCKS[lockBasename];
|
|
931
919
|
}
|
|
932
920
|
if (agent === undefined) {
|
|
933
|
-
agent =
|
|
921
|
+
agent = NPM$2;
|
|
934
922
|
onUnknown?.(pkgManager);
|
|
935
923
|
}
|
|
936
924
|
const agentExecPath = await getAgentExecPath(agent);
|
|
937
|
-
const npmExecPath = agent ===
|
|
925
|
+
const npmExecPath = agent === NPM$2 ? agentExecPath : await getAgentExecPath(NPM$2);
|
|
938
926
|
if (agentVersion === undefined) {
|
|
939
927
|
agentVersion = await getAgentVersion(agentExecPath, cwd);
|
|
940
928
|
}
|
|
941
|
-
if (agent ===
|
|
942
|
-
agent =
|
|
929
|
+
if (agent === YARN_CLASSIC$1 && (agentVersion?.major ?? 0) > 1) {
|
|
930
|
+
agent = YARN_BERRY$1;
|
|
943
931
|
}
|
|
944
932
|
const targets = {
|
|
945
933
|
browser: false,
|
|
@@ -947,7 +935,7 @@ async function detect({
|
|
|
947
935
|
};
|
|
948
936
|
let lockSrc;
|
|
949
937
|
// Lazily access constants.maintainedNodeVersions.
|
|
950
|
-
let minimumNodeVersion =
|
|
938
|
+
let minimumNodeVersion = constants.maintainedNodeVersions.previous;
|
|
951
939
|
if (pkgJson) {
|
|
952
940
|
const browserField = pkgJson.browser;
|
|
953
941
|
if (strings.isNonEmptyString(browserField) || objects.isObjectObject(browserField)) {
|
|
@@ -975,15 +963,17 @@ async function detect({
|
|
|
975
963
|
}
|
|
976
964
|
}
|
|
977
965
|
// Lazily access constants.maintainedNodeVersions.
|
|
978
|
-
targets.node =
|
|
966
|
+
targets.node = constants.maintainedNodeVersions.some(v => semver.satisfies(v, `>=${minimumNodeVersion}`));
|
|
979
967
|
lockSrc = typeof lockPath === 'string' ? await readLockFileByAgent[agent](lockPath, agentExecPath) : undefined;
|
|
980
968
|
} else {
|
|
969
|
+
lockBasename = undefined;
|
|
981
970
|
lockPath = undefined;
|
|
982
971
|
}
|
|
983
972
|
return {
|
|
984
973
|
agent,
|
|
985
974
|
agentExecPath,
|
|
986
975
|
agentVersion,
|
|
976
|
+
lockBasename,
|
|
987
977
|
lockPath,
|
|
988
978
|
lockSrc,
|
|
989
979
|
minimumNodeVersion,
|
|
@@ -996,7 +986,14 @@ async function detect({
|
|
|
996
986
|
}
|
|
997
987
|
|
|
998
988
|
const {
|
|
989
|
+
BUN,
|
|
990
|
+
LOCK_EXT,
|
|
991
|
+
NPM: NPM$1,
|
|
992
|
+
PNPM,
|
|
999
993
|
UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE,
|
|
994
|
+
VLT,
|
|
995
|
+
YARN_BERRY,
|
|
996
|
+
YARN_CLASSIC,
|
|
1000
997
|
abortSignal: abortSignal$2,
|
|
1001
998
|
execPath,
|
|
1002
999
|
rootBinPath
|
|
@@ -1004,63 +1001,68 @@ const {
|
|
|
1004
1001
|
const COMMAND_TITLE = 'Socket Optimize';
|
|
1005
1002
|
const OVERRIDES_FIELD_NAME = 'overrides';
|
|
1006
1003
|
const NPM_OVERRIDE_PR_URL = 'https://github.com/npm/cli/pull/7025';
|
|
1007
|
-
const PNPM_FIELD_NAME =
|
|
1008
|
-
const PNPM_WORKSPACE =
|
|
1004
|
+
const PNPM_FIELD_NAME = PNPM;
|
|
1005
|
+
const PNPM_WORKSPACE = `${PNPM}-workspace`;
|
|
1009
1006
|
const RESOLUTIONS_FIELD_NAME = 'resolutions';
|
|
1010
|
-
const manifestNpmOverrides = registry.getManifestData(
|
|
1007
|
+
const manifestNpmOverrides = registry.getManifestData(NPM$1);
|
|
1011
1008
|
const getOverridesDataByAgent = {
|
|
1012
|
-
|
|
1009
|
+
[BUN](pkgJson) {
|
|
1013
1010
|
const overrides = pkgJson?.resolutions ?? {};
|
|
1014
1011
|
return {
|
|
1015
|
-
type:
|
|
1012
|
+
type: YARN_BERRY,
|
|
1016
1013
|
overrides
|
|
1017
1014
|
};
|
|
1018
1015
|
},
|
|
1019
1016
|
// npm overrides documentation:
|
|
1020
1017
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides
|
|
1021
|
-
|
|
1018
|
+
[NPM$1](pkgJson) {
|
|
1022
1019
|
const overrides = pkgJson?.overrides ?? {};
|
|
1023
1020
|
return {
|
|
1024
|
-
type:
|
|
1021
|
+
type: NPM$1,
|
|
1025
1022
|
overrides
|
|
1026
1023
|
};
|
|
1027
1024
|
},
|
|
1028
1025
|
// pnpm overrides documentation:
|
|
1029
1026
|
// https://pnpm.io/package_json#pnpmoverrides
|
|
1030
|
-
|
|
1027
|
+
[PNPM](pkgJson) {
|
|
1031
1028
|
const overrides = pkgJson?.pnpm?.overrides ?? {};
|
|
1032
1029
|
return {
|
|
1033
|
-
type:
|
|
1030
|
+
type: PNPM,
|
|
1034
1031
|
overrides
|
|
1035
1032
|
};
|
|
1036
1033
|
},
|
|
1037
|
-
|
|
1034
|
+
[VLT](pkgJson) {
|
|
1038
1035
|
const overrides = pkgJson?.overrides ?? {};
|
|
1039
1036
|
return {
|
|
1040
|
-
type:
|
|
1037
|
+
type: VLT,
|
|
1041
1038
|
overrides
|
|
1042
1039
|
};
|
|
1043
1040
|
},
|
|
1044
1041
|
// Yarn resolutions documentation:
|
|
1045
1042
|
// https://yarnpkg.com/configuration/manifest#resolutions
|
|
1046
|
-
|
|
1043
|
+
[YARN_BERRY](pkgJson) {
|
|
1047
1044
|
const overrides = pkgJson?.resolutions ?? {};
|
|
1048
1045
|
return {
|
|
1049
|
-
type:
|
|
1046
|
+
type: YARN_BERRY,
|
|
1050
1047
|
overrides
|
|
1051
1048
|
};
|
|
1052
1049
|
},
|
|
1053
1050
|
// Yarn resolutions documentation:
|
|
1054
1051
|
// https://classic.yarnpkg.com/en/docs/selective-version-resolutions
|
|
1055
|
-
|
|
1052
|
+
[YARN_CLASSIC](pkgJson) {
|
|
1056
1053
|
const overrides = pkgJson?.resolutions ?? {};
|
|
1057
1054
|
return {
|
|
1058
|
-
type:
|
|
1055
|
+
type: YARN_CLASSIC,
|
|
1059
1056
|
overrides
|
|
1060
1057
|
};
|
|
1061
1058
|
}
|
|
1062
1059
|
};
|
|
1063
1060
|
const lockIncludesByAgent = (() => {
|
|
1061
|
+
function npmLockIncludes(lockSrc, name) {
|
|
1062
|
+
// Detects the package name in the following cases:
|
|
1063
|
+
// "name":
|
|
1064
|
+
return lockSrc.includes(`"${name}":`);
|
|
1065
|
+
}
|
|
1064
1066
|
function yarnLockIncludes(lockSrc, name) {
|
|
1065
1067
|
const escapedName = regexps.escapeRegExp(name);
|
|
1066
1068
|
return new RegExp(
|
|
@@ -1072,13 +1074,16 @@ const lockIncludesByAgent = (() => {
|
|
|
1072
1074
|
`(?<=(?:^\\s*|,\\s*)"?)${escapedName}(?=@)`, 'm').test(lockSrc);
|
|
1073
1075
|
}
|
|
1074
1076
|
return {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
//
|
|
1078
|
-
//
|
|
1079
|
-
|
|
1077
|
+
[BUN](lockSrc, name, lockBasename) {
|
|
1078
|
+
// This is a bit counterintuitive. When lockBasename ends with a .lockb
|
|
1079
|
+
// we treat it as a yarn.lock. When lockBasename ends with a .lock we
|
|
1080
|
+
// treat it as a package-lock.json. The bun.lock format is not identical
|
|
1081
|
+
// package-lock.json, however it close enough for npmLockIncludes to work.
|
|
1082
|
+
const lockScanner = lockBasename?.endsWith(LOCK_EXT) ? npmLockIncludes : yarnLockIncludes;
|
|
1083
|
+
return lockScanner(lockSrc, name);
|
|
1080
1084
|
},
|
|
1081
|
-
|
|
1085
|
+
[NPM$1]: npmLockIncludes,
|
|
1086
|
+
[PNPM](lockSrc, name) {
|
|
1082
1087
|
const escapedName = regexps.escapeRegExp(name);
|
|
1083
1088
|
return new RegExp(
|
|
1084
1089
|
// Detects the package name in the following cases:
|
|
@@ -1088,13 +1093,13 @@ const lockIncludesByAgent = (() => {
|
|
|
1088
1093
|
// name@
|
|
1089
1094
|
`(?<=^\\s*)(?:(['/])${escapedName}\\1|${escapedName}(?=[:@]))`, 'm').test(lockSrc);
|
|
1090
1095
|
},
|
|
1091
|
-
|
|
1096
|
+
[VLT](lockSrc, name) {
|
|
1092
1097
|
// Detects the package name in the following cases:
|
|
1093
1098
|
// "name"
|
|
1094
1099
|
return lockSrc.includes(`"${name}"`);
|
|
1095
1100
|
},
|
|
1096
|
-
|
|
1097
|
-
|
|
1101
|
+
[YARN_BERRY]: yarnLockIncludes,
|
|
1102
|
+
[YARN_CLASSIC]: yarnLockIncludes
|
|
1098
1103
|
};
|
|
1099
1104
|
})();
|
|
1100
1105
|
const updateManifestByAgent = (() => {
|
|
@@ -1154,16 +1159,16 @@ const updateManifestByAgent = (() => {
|
|
|
1154
1159
|
let insertIndex = -1;
|
|
1155
1160
|
let isPlacingHigher = false;
|
|
1156
1161
|
if (field === OVERRIDES_FIELD_NAME) {
|
|
1157
|
-
insertIndex = getLowestEntryIndex(entries, [
|
|
1162
|
+
insertIndex = getLowestEntryIndex(entries, [RESOLUTIONS_FIELD_NAME]);
|
|
1158
1163
|
if (insertIndex === -1) {
|
|
1159
1164
|
isPlacingHigher = true;
|
|
1160
|
-
insertIndex = getHighestEntryIndex(entries, [...depFields,
|
|
1165
|
+
insertIndex = getHighestEntryIndex(entries, [...depFields, PNPM]);
|
|
1161
1166
|
}
|
|
1162
1167
|
} else if (field === RESOLUTIONS_FIELD_NAME) {
|
|
1163
1168
|
isPlacingHigher = true;
|
|
1164
|
-
insertIndex = getHighestEntryIndex(entries, [...depFields,
|
|
1169
|
+
insertIndex = getHighestEntryIndex(entries, [...depFields, OVERRIDES_FIELD_NAME, PNPM]);
|
|
1165
1170
|
} else if (field === PNPM_FIELD_NAME) {
|
|
1166
|
-
insertIndex = getLowestEntryIndex(entries, [
|
|
1171
|
+
insertIndex = getLowestEntryIndex(entries, [OVERRIDES_FIELD_NAME, RESOLUTIONS_FIELD_NAME]);
|
|
1167
1172
|
if (insertIndex === -1) {
|
|
1168
1173
|
isPlacingHigher = true;
|
|
1169
1174
|
insertIndex = getHighestEntryIndex(entries, depFields);
|
|
@@ -1191,14 +1196,14 @@ const updateManifestByAgent = (() => {
|
|
|
1191
1196
|
updatePkgJson(editablePkgJson, RESOLUTIONS_FIELD_NAME, overrides);
|
|
1192
1197
|
}
|
|
1193
1198
|
return {
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1199
|
+
[BUN]: updateResolutions,
|
|
1200
|
+
[NPM$1]: updateOverrides,
|
|
1201
|
+
[PNPM](editablePkgJson, overrides) {
|
|
1197
1202
|
updatePkgJson(editablePkgJson, PNPM_FIELD_NAME, overrides);
|
|
1198
1203
|
},
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1204
|
+
[VLT]: updateOverrides,
|
|
1205
|
+
[YARN_BERRY]: updateResolutions,
|
|
1206
|
+
[YARN_CLASSIC]: updateResolutions
|
|
1202
1207
|
};
|
|
1203
1208
|
})();
|
|
1204
1209
|
const lsByAgent = (() => {
|
|
@@ -1252,7 +1257,7 @@ const lsByAgent = (() => {
|
|
|
1252
1257
|
return cleanupQueryStdout(stdout);
|
|
1253
1258
|
}
|
|
1254
1259
|
return {
|
|
1255
|
-
async
|
|
1260
|
+
async [BUN](agentExecPath, cwd) {
|
|
1256
1261
|
try {
|
|
1257
1262
|
// Bun does not support filtering by production packages yet.
|
|
1258
1263
|
// https://github.com/oven-sh/bun/issues/8283
|
|
@@ -1262,17 +1267,17 @@ const lsByAgent = (() => {
|
|
|
1262
1267
|
} catch {}
|
|
1263
1268
|
return '';
|
|
1264
1269
|
},
|
|
1265
|
-
async
|
|
1270
|
+
async [NPM$1](agentExecPath, cwd) {
|
|
1266
1271
|
return await npmQuery(agentExecPath, cwd);
|
|
1267
1272
|
},
|
|
1268
|
-
async
|
|
1273
|
+
async [PNPM](agentExecPath, cwd, options) {
|
|
1269
1274
|
const {
|
|
1270
1275
|
npmExecPath
|
|
1271
1276
|
} = {
|
|
1272
1277
|
__proto__: null,
|
|
1273
1278
|
...options
|
|
1274
1279
|
};
|
|
1275
|
-
if (npmExecPath && npmExecPath !==
|
|
1280
|
+
if (npmExecPath && npmExecPath !== NPM$1) {
|
|
1276
1281
|
const result = await npmQuery(npmExecPath, cwd);
|
|
1277
1282
|
if (result) {
|
|
1278
1283
|
return result;
|
|
@@ -1286,7 +1291,7 @@ const lsByAgent = (() => {
|
|
|
1286
1291
|
} catch {}
|
|
1287
1292
|
return parseableToQueryStdout(stdout);
|
|
1288
1293
|
},
|
|
1289
|
-
async
|
|
1294
|
+
async [VLT](agentExecPath, cwd) {
|
|
1290
1295
|
let stdout = '';
|
|
1291
1296
|
try {
|
|
1292
1297
|
stdout = (await spawn(agentExecPath, ['ls', '--view', 'human', ':not(.dev)'], {
|
|
@@ -1295,7 +1300,7 @@ const lsByAgent = (() => {
|
|
|
1295
1300
|
} catch {}
|
|
1296
1301
|
return cleanupQueryStdout(stdout);
|
|
1297
1302
|
},
|
|
1298
|
-
async
|
|
1303
|
+
async [YARN_BERRY](agentExecPath, cwd) {
|
|
1299
1304
|
try {
|
|
1300
1305
|
return (
|
|
1301
1306
|
// Yarn Berry does not support filtering by production packages yet.
|
|
@@ -1307,7 +1312,7 @@ const lsByAgent = (() => {
|
|
|
1307
1312
|
} catch {}
|
|
1308
1313
|
return '';
|
|
1309
1314
|
},
|
|
1310
|
-
async
|
|
1315
|
+
async [YARN_CLASSIC](agentExecPath, cwd) {
|
|
1311
1316
|
try {
|
|
1312
1317
|
// However, Yarn Classic does support it.
|
|
1313
1318
|
// https://github.com/yarnpkg/yarn/releases/tag/v1.0.0
|
|
@@ -1329,12 +1334,12 @@ const depsIncludesByAgent = (() => {
|
|
|
1329
1334
|
return stdout.includes(`"${name}"`);
|
|
1330
1335
|
}
|
|
1331
1336
|
return {
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1337
|
+
[BUN]: matchHumanStdout,
|
|
1338
|
+
[NPM$1]: matchQueryStdout,
|
|
1339
|
+
[PNPM]: matchQueryStdout,
|
|
1340
|
+
[VLT]: matchQueryStdout,
|
|
1341
|
+
[YARN_BERRY]: matchHumanStdout,
|
|
1342
|
+
[YARN_CLASSIC]: matchHumanStdout
|
|
1338
1343
|
};
|
|
1339
1344
|
})();
|
|
1340
1345
|
function createActionMessage(verb, overrideCount, workspaceCount) {
|
|
@@ -1365,7 +1370,7 @@ function getDependencyEntries(pkgJson) {
|
|
|
1365
1370
|
}
|
|
1366
1371
|
async function getWorkspaceGlobs(agent, pkgPath, pkgJson) {
|
|
1367
1372
|
let workspacePatterns;
|
|
1368
|
-
if (agent ===
|
|
1373
|
+
if (agent === PNPM) {
|
|
1369
1374
|
for (const workspacePath of [path.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), path.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
|
|
1370
1375
|
if (existsSync(workspacePath)) {
|
|
1371
1376
|
try {
|
|
@@ -1415,6 +1420,7 @@ function createAddOverridesState(initials) {
|
|
|
1415
1420
|
async function addOverrides({
|
|
1416
1421
|
agent,
|
|
1417
1422
|
agentExecPath,
|
|
1423
|
+
lockBasename,
|
|
1418
1424
|
lockSrc,
|
|
1419
1425
|
manifestEntries,
|
|
1420
1426
|
npmExecPath,
|
|
@@ -1440,20 +1446,24 @@ async function addOverrides({
|
|
|
1440
1446
|
const workspaceName = path.relative(rootPath, pkgPath);
|
|
1441
1447
|
const workspaceGlobs = await getWorkspaceGlobs(agent, pkgPath, pkgJson);
|
|
1442
1448
|
const isWorkspace = !!workspaceGlobs;
|
|
1443
|
-
if (isWorkspace && agent ===
|
|
1449
|
+
if (isWorkspace && agent === PNPM && npmExecPath === NPM$1 && !state.warnedPnpmWorkspaceRequiresNpm) {
|
|
1444
1450
|
state.warnedPnpmWorkspaceRequiresNpm = true;
|
|
1445
1451
|
console.warn(`⚠️ ${COMMAND_TITLE}: pnpm workspace support requires \`npm ls\`, falling back to \`pnpm list\``);
|
|
1446
1452
|
}
|
|
1447
1453
|
const thingToScan = isLockScanned ? lockSrc : await lsByAgent[agent](agentExecPath, pkgPath, {
|
|
1448
1454
|
npmExecPath
|
|
1449
1455
|
});
|
|
1456
|
+
// The AgentDepsIncludesFn and AgentLockIncludesFn types overlap in their
|
|
1457
|
+
// first two parameters. AgentLockIncludesFn accepts an optional third
|
|
1458
|
+
// parameter which AgentDepsIncludesFn will ignore so we cast thingScanner
|
|
1459
|
+
// as an AgentLockIncludesFn type.
|
|
1450
1460
|
const thingScanner = isLockScanned ? lockIncludesByAgent[agent] : depsIncludesByAgent[agent];
|
|
1451
1461
|
const depEntries = getDependencyEntries(pkgJson);
|
|
1452
1462
|
const overridesDataObjects = [];
|
|
1453
1463
|
if (pkgJson['private'] || isWorkspace) {
|
|
1454
1464
|
overridesDataObjects.push(getOverridesDataByAgent[agent](pkgJson));
|
|
1455
1465
|
} else {
|
|
1456
|
-
overridesDataObjects.push(getOverridesDataByAgent
|
|
1466
|
+
overridesDataObjects.push(getOverridesDataByAgent[NPM$1](pkgJson), getOverridesDataByAgent[YARN_CLASSIC](pkgJson));
|
|
1457
1467
|
}
|
|
1458
1468
|
if (spinner) {
|
|
1459
1469
|
spinner.text = `Adding overrides${workspaceName ? ` to ${workspaceName}` : ''}...`;
|
|
@@ -1502,13 +1512,13 @@ async function addOverrides({
|
|
|
1502
1512
|
type
|
|
1503
1513
|
}) => {
|
|
1504
1514
|
const overrideExists = objects.hasOwn(overrides, origPkgName);
|
|
1505
|
-
if (overrideExists || thingScanner(thingToScan, origPkgName)) {
|
|
1515
|
+
if (overrideExists || thingScanner(thingToScan, origPkgName, lockBasename)) {
|
|
1506
1516
|
const oldSpec = overrideExists ? overrides[origPkgName] : undefined;
|
|
1507
1517
|
const depAlias = depAliasMap.get(origPkgName);
|
|
1508
|
-
const regSpecStartsLike =
|
|
1518
|
+
const regSpecStartsLike = `${NPM$1}:${regPkgName}@`;
|
|
1509
1519
|
let newSpec = `${regSpecStartsLike}^${pin ? version : major}`;
|
|
1510
1520
|
let thisVersion = version;
|
|
1511
|
-
if (depAlias && type ===
|
|
1521
|
+
if (depAlias && type === NPM$1) {
|
|
1512
1522
|
// With npm one may not set an override for a package that one directly
|
|
1513
1523
|
// depends on unless both the dependency and the override itself share
|
|
1514
1524
|
// the exact same spec. To make this limitation easier to deal with,
|
|
@@ -1532,10 +1542,6 @@ async function addOverrides({
|
|
|
1532
1542
|
overrides[origPkgName] = newSpec;
|
|
1533
1543
|
const addedOrUpdated = overrideExists ? 'updated' : 'added';
|
|
1534
1544
|
state[addedOrUpdated].add(regPkgName);
|
|
1535
|
-
if (workspaceName) {
|
|
1536
|
-
const addedOrUpdatedIn = overrideExists ? 'updatedInWorkspaces' : 'addedInWorkspaces';
|
|
1537
|
-
state[addedOrUpdatedIn].add(workspaceName);
|
|
1538
|
-
}
|
|
1539
1545
|
}
|
|
1540
1546
|
}
|
|
1541
1547
|
});
|
|
@@ -1552,6 +1558,7 @@ async function addOverrides({
|
|
|
1552
1558
|
const otherState = await addOverrides({
|
|
1553
1559
|
agent,
|
|
1554
1560
|
agentExecPath,
|
|
1561
|
+
lockBasename,
|
|
1555
1562
|
lockSrc,
|
|
1556
1563
|
manifestEntries,
|
|
1557
1564
|
npmExecPath,
|
|
@@ -1599,6 +1606,7 @@ const optimize = {
|
|
|
1599
1606
|
agent,
|
|
1600
1607
|
agentExecPath,
|
|
1601
1608
|
agentVersion,
|
|
1609
|
+
lockBasename,
|
|
1602
1610
|
lockPath,
|
|
1603
1611
|
lockSrc,
|
|
1604
1612
|
minimumNodeVersion,
|
|
@@ -1616,12 +1624,12 @@ const optimize = {
|
|
|
1616
1624
|
console.error(`✖️ ${COMMAND_TITLE}: No supported Node or browser range detected`);
|
|
1617
1625
|
return;
|
|
1618
1626
|
}
|
|
1619
|
-
if (agent ===
|
|
1627
|
+
if (agent === VLT) {
|
|
1620
1628
|
console.error(`✖️ ${COMMAND_TITLE}: ${agent} does not support overrides. Soon, though ⚡`);
|
|
1621
1629
|
return;
|
|
1622
1630
|
}
|
|
1623
|
-
const lockName = lockPath ?
|
|
1624
|
-
if (lockSrc === undefined) {
|
|
1631
|
+
const lockName = lockPath ? lockBasename : 'lock file';
|
|
1632
|
+
if (lockBasename === undefined || lockSrc === undefined) {
|
|
1625
1633
|
console.error(`✖️ ${COMMAND_TITLE}: No ${lockName} found`);
|
|
1626
1634
|
return;
|
|
1627
1635
|
}
|
|
@@ -1633,7 +1641,7 @@ const optimize = {
|
|
|
1633
1641
|
console.error(`✖️ ${COMMAND_TITLE}: No package.json found`);
|
|
1634
1642
|
return;
|
|
1635
1643
|
}
|
|
1636
|
-
if (prod && (agent ===
|
|
1644
|
+
if (prod && (agent === BUN || agent === YARN_BERRY)) {
|
|
1637
1645
|
console.error(`✖️ ${COMMAND_TITLE}: --prod not supported for ${agent}${agentVersion ? `@${agentVersion.toString()}` : ''}`);
|
|
1638
1646
|
return;
|
|
1639
1647
|
}
|
|
@@ -1654,6 +1662,7 @@ const optimize = {
|
|
|
1654
1662
|
await addOverrides({
|
|
1655
1663
|
agent,
|
|
1656
1664
|
agentExecPath,
|
|
1665
|
+
lockBasename,
|
|
1657
1666
|
lockSrc,
|
|
1658
1667
|
manifestEntries,
|
|
1659
1668
|
npmExecPath,
|
|
@@ -1677,7 +1686,7 @@ const optimize = {
|
|
|
1677
1686
|
} else {
|
|
1678
1687
|
console.log('Congratulations! Already Socket.dev optimized 🎉');
|
|
1679
1688
|
}
|
|
1680
|
-
const isNpm = agent ===
|
|
1689
|
+
const isNpm = agent === NPM$1;
|
|
1681
1690
|
if (isNpm || pkgJsonChanged) {
|
|
1682
1691
|
// Always update package-lock.json until the npm overrides PR lands:
|
|
1683
1692
|
// https://github.com/npm/cli/pull/7025
|
|
@@ -1810,14 +1819,16 @@ Plan: ${o?.plan}
|
|
|
1810
1819
|
}
|
|
1811
1820
|
|
|
1812
1821
|
const {
|
|
1822
|
+
NPM,
|
|
1813
1823
|
abortSignal: abortSignal$1
|
|
1814
1824
|
} = constants;
|
|
1825
|
+
const binName$1 = NPM;
|
|
1815
1826
|
const rawNpm = {
|
|
1816
|
-
description:
|
|
1827
|
+
description: `Temporarily disable the Socket ${binName$1} wrapper`,
|
|
1817
1828
|
async run(argv, importMeta, {
|
|
1818
1829
|
parentName
|
|
1819
1830
|
}) {
|
|
1820
|
-
await setupCommand$j(`${parentName} raw
|
|
1831
|
+
await setupCommand$j(`${parentName} raw-${binName$1}`, rawNpm.description, argv, importMeta);
|
|
1821
1832
|
}
|
|
1822
1833
|
};
|
|
1823
1834
|
async function setupCommand$j(name, description, argv, importMeta) {
|
|
@@ -1827,7 +1838,7 @@ async function setupCommand$j(name, description, argv, importMeta) {
|
|
|
1827
1838
|
};
|
|
1828
1839
|
const cli = meow(`
|
|
1829
1840
|
Usage
|
|
1830
|
-
$ ${name}
|
|
1841
|
+
$ ${name} <${binName$1} command>
|
|
1831
1842
|
|
|
1832
1843
|
Options
|
|
1833
1844
|
${printFlagList(flags, 6)}
|
|
@@ -1848,13 +1859,26 @@ async function setupCommand$j(name, description, argv, importMeta) {
|
|
|
1848
1859
|
cli.showHelp();
|
|
1849
1860
|
return;
|
|
1850
1861
|
}
|
|
1851
|
-
const
|
|
1862
|
+
const {
|
|
1863
|
+
path: binPath
|
|
1864
|
+
} = await pathResolve.findBinPathDetails(binName$1);
|
|
1865
|
+
if (!binPath) {
|
|
1866
|
+
// The exit code 127 indicates that the command or binary being executed
|
|
1867
|
+
// could not be found.
|
|
1868
|
+
console.error(`Socket unable to locate ${binName$1}; ensure it is available in the PATH environment variable.`);
|
|
1869
|
+
process.exit(127);
|
|
1870
|
+
}
|
|
1871
|
+
const spawnPromise = spawn(binPath, argv, {
|
|
1852
1872
|
signal: abortSignal$1,
|
|
1853
1873
|
stdio: 'inherit'
|
|
1854
1874
|
});
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1875
|
+
// See https://nodejs.org/api/all.html#all_child_process_event-exit.
|
|
1876
|
+
spawnPromise.process.on('exit', (code, signalName) => {
|
|
1877
|
+
if (abortSignal$1.aborted) {
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
if (signalName) {
|
|
1881
|
+
process.kill(process.pid, signalName);
|
|
1858
1882
|
} else if (code !== null) {
|
|
1859
1883
|
process.exit(code);
|
|
1860
1884
|
}
|
|
@@ -1863,14 +1887,16 @@ async function setupCommand$j(name, description, argv, importMeta) {
|
|
|
1863
1887
|
}
|
|
1864
1888
|
|
|
1865
1889
|
const {
|
|
1890
|
+
NPX,
|
|
1866
1891
|
abortSignal
|
|
1867
1892
|
} = constants;
|
|
1893
|
+
const binName = NPX;
|
|
1868
1894
|
const rawNpx = {
|
|
1869
|
-
description:
|
|
1895
|
+
description: `Temporarily disable the Socket ${binName} wrapper`,
|
|
1870
1896
|
async run(argv, importMeta, {
|
|
1871
1897
|
parentName
|
|
1872
1898
|
}) {
|
|
1873
|
-
await setupCommand$i(`${parentName} raw
|
|
1899
|
+
await setupCommand$i(`${parentName} raw-${binName}`, rawNpx.description, argv, importMeta);
|
|
1874
1900
|
}
|
|
1875
1901
|
};
|
|
1876
1902
|
async function setupCommand$i(name, description, argv, importMeta) {
|
|
@@ -1880,7 +1906,7 @@ async function setupCommand$i(name, description, argv, importMeta) {
|
|
|
1880
1906
|
};
|
|
1881
1907
|
const cli = meow(`
|
|
1882
1908
|
Usage
|
|
1883
|
-
$ ${name}
|
|
1909
|
+
$ ${name} <${binName} command>
|
|
1884
1910
|
|
|
1885
1911
|
Options
|
|
1886
1912
|
${printFlagList(flags, 6)}
|
|
@@ -1901,13 +1927,26 @@ async function setupCommand$i(name, description, argv, importMeta) {
|
|
|
1901
1927
|
cli.showHelp();
|
|
1902
1928
|
return;
|
|
1903
1929
|
}
|
|
1904
|
-
const
|
|
1930
|
+
const {
|
|
1931
|
+
path: binPath
|
|
1932
|
+
} = await pathResolve.findBinPathDetails(binName);
|
|
1933
|
+
if (!binPath) {
|
|
1934
|
+
// The exit code 127 indicates that the command or binary being executed
|
|
1935
|
+
// could not be found.
|
|
1936
|
+
console.error(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable.`);
|
|
1937
|
+
process.exit(127);
|
|
1938
|
+
}
|
|
1939
|
+
const spawnPromise = spawn(binPath, argv, {
|
|
1905
1940
|
signal: abortSignal,
|
|
1906
1941
|
stdio: 'inherit'
|
|
1907
1942
|
});
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1943
|
+
// See https://nodejs.org/api/all.html#all_child_process_event-exit.
|
|
1944
|
+
spawnPromise.process.on('exit', (code, signalName) => {
|
|
1945
|
+
if (abortSignal.aborted) {
|
|
1946
|
+
return;
|
|
1947
|
+
}
|
|
1948
|
+
if (signalName) {
|
|
1949
|
+
process.kill(process.pid, signalName);
|
|
1911
1950
|
} else if (code !== null) {
|
|
1912
1951
|
process.exit(code);
|
|
1913
1952
|
}
|
|
@@ -3697,7 +3736,7 @@ const dependencies = {
|
|
|
3697
3736
|
}) {
|
|
3698
3737
|
const name = parentName + ' dependencies';
|
|
3699
3738
|
const input = setupCommand$3(name, dependencies.description, argv, importMeta);
|
|
3700
|
-
|
|
3739
|
+
{
|
|
3701
3740
|
await searchDeps(input);
|
|
3702
3741
|
}
|
|
3703
3742
|
}
|
|
@@ -4266,7 +4305,7 @@ const threatFeed = {
|
|
|
4266
4305
|
}) {
|
|
4267
4306
|
const name = `${parentName} threat-feed`;
|
|
4268
4307
|
const input = setupCommand(name, threatFeed.description, argv, importMeta);
|
|
4269
|
-
|
|
4308
|
+
{
|
|
4270
4309
|
const apiKey = sdk.getDefaultKey();
|
|
4271
4310
|
if (!apiKey) {
|
|
4272
4311
|
throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|