socket 0.14.40 → 0.14.42
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/constants.d.ts +17 -9
- package/dist/constants.d.ts.map +1 -1
- package/dist/module-sync/cli.js +105 -164
- package/dist/module-sync/npm-injection.js +238 -313
- package/dist/module-sync/npm-paths.d.ts +14 -0
- package/dist/module-sync/{path-resolve.js → npm-paths.js} +149 -21
- package/dist/module-sync/path-resolve.d.ts +4 -5
- package/dist/module-sync/settings.d.ts +6 -1
- package/dist/module-sync/shadow-bin.js +9 -13
- package/dist/module-sync/socket-url.d.ts +17 -1
- package/dist/module-sync/socket-url.js +85 -6
- package/dist/require/cli.js +105 -164
- package/dist/require/npm-paths.js +3 -0
- package/dist/require/vendor.js +4 -16
- package/package.json +29 -21
- package/dist/require/path-resolve.js +0 -3
package/dist/constants.d.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import registryConstants from '@socketsecurity/registry/lib/constants';
|
|
2
2
|
type RegistryEnv = typeof registryConstants.ENV;
|
|
3
|
-
type
|
|
3
|
+
type RegistryInternals = (typeof registryConstants)['Symbol(kInternalsSymbol)'];
|
|
4
|
+
type Internals = Omit<RegistryInternals, 'getIPC'> & Readonly<{
|
|
5
|
+
getIPC: {
|
|
6
|
+
(): Promise<IPC>;
|
|
7
|
+
<K extends keyof IPC | undefined>(key?: K): Promise<K extends keyof IPC ? IPC[K] : IPC>;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
type ENV = RegistryEnv & Readonly<{
|
|
11
|
+
SOCKET_CLI_DEBUG: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
type IPC = Readonly<{
|
|
4
14
|
SOCKET_CLI_FIX_PACKAGE_LOCK_FILE: boolean;
|
|
5
15
|
SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE: boolean;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
}>;
|
|
17
|
+
type Constants = Omit<typeof registryConstants, 'Symbol(kInternalsSymbol)' | 'ENV' | 'IPC'> & {
|
|
18
|
+
readonly 'Symbol(kInternalsSymbol)': Internals;
|
|
9
19
|
readonly API_V0_URL: 'https://api.socket.dev/v0';
|
|
10
20
|
readonly BABEL_RUNTIME: '@babel/runtime';
|
|
11
21
|
readonly BINARY_LOCK_EXT: '.lockb';
|
|
12
22
|
readonly BUN: 'bun';
|
|
13
|
-
readonly ENV:
|
|
14
|
-
SOCKET_CLI_DEBUG: boolean;
|
|
15
|
-
};
|
|
23
|
+
readonly ENV: ENV;
|
|
16
24
|
readonly DIST_TYPE: 'module-sync' | 'require';
|
|
17
|
-
readonly IPC:
|
|
25
|
+
readonly IPC: IPC;
|
|
18
26
|
readonly LOCK_EXT: '.lock';
|
|
19
27
|
readonly MODULE_SYNC: 'module-sync';
|
|
20
28
|
readonly NPM_REGISTRY_URL: 'https://registry.npmjs.org';
|
|
@@ -38,7 +46,7 @@ type Constants = {
|
|
|
38
46
|
readonly rootPkgJsonPath: string;
|
|
39
47
|
readonly shadowBinPath: string;
|
|
40
48
|
readonly synpBinPath: string;
|
|
41
|
-
}
|
|
49
|
+
};
|
|
42
50
|
declare const constants: Constants;
|
|
43
51
|
export { constants as default };
|
|
44
52
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,MAAM,wCAAwC,CAAA;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,MAAM,wCAAwC,CAAA;AAWtE,KAAK,WAAW,GAAG,OAAO,iBAAiB,CAAC,GAAG,CAAA;AAE/C,KAAK,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,0BAA0B,CAAC,CAAA;AAE/E,KAAK,SAAS,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,GAChD,QAAQ,CAAC;IACP,MAAM,EAAE;QACN,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA;QAChB,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,SAAS,EAC9B,GAAG,CAAC,EAAE,CAAC,GACN,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;KAC/C,CAAA;CACF,CAAC,CAAA;AAEJ,KAAK,GAAG,GAAG,WAAW,GACpB,QAAQ,CAAC;IACP,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAC,CAAA;AAEJ,KAAK,GAAG,GAAG,QAAQ,CAAC;IAClB,gCAAgC,EAAE,OAAO,CAAA;IACzC,gDAAgD,EAAE,OAAO,CAAA;CAC1D,CAAC,CAAA;AAEF,KAAK,SAAS,GAAG,IAAI,CACnB,OAAO,iBAAiB,EACxB,0BAA0B,GAAG,KAAK,GAAG,KAAK,CAC3C,GAAG;IACF,QAAQ,CAAC,0BAA0B,EAAE,SAAS,CAAA;IAC9C,QAAQ,CAAC,UAAU,EAAE,2BAA2B,CAAA;IAChD,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAA;IACxC,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAA;IAClC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;IACjB,QAAQ,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;IACjB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAA;IACnC,QAAQ,CAAC,gBAAgB,EAAE,4BAA4B,CAAA;IACvD,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,kBAAkB,CAAA;IAC7C,QAAQ,CAAC,gCAAgC,EAAE,kCAAkC,CAAA;IAC7E,QAAQ,CAAC,qBAAqB,EAAE,gDAAgD,CAAA;IAChF,QAAQ,CAAC,gDAAgD,EAAE,kDAAkD,CAAA;IAC7G,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAA;IACjC,QAAQ,CAAC,YAAY,EAAE,cAAc,CAAA;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B,CAAA;AAyED,QAAA,MAAM,SAAS,WAiDd,CAAA"}
|
package/dist/module-sync/cli.js
CHANGED
|
@@ -24,14 +24,13 @@ var constants = require('./constants.js');
|
|
|
24
24
|
var spinner = require('@socketsecurity/registry/lib/spinner');
|
|
25
25
|
var spawn = _socketInterop(require('@npmcli/promise-spawn'));
|
|
26
26
|
var objects = require('@socketsecurity/registry/lib/objects');
|
|
27
|
-
var
|
|
27
|
+
var npmPaths = require('./npm-paths.js');
|
|
28
28
|
var meow = _socketInterop(require('meow'));
|
|
29
29
|
var registryConstants = require('@socketsecurity/registry/lib/constants');
|
|
30
30
|
var socketUrl = require('./socket-url.js');
|
|
31
31
|
var terminalLink = _socketInterop(require('terminal-link'));
|
|
32
32
|
var isInteractive = require('@socketregistry/is-interactive/index.cjs');
|
|
33
33
|
var prompts = require('@socketsecurity/registry/lib/prompts');
|
|
34
|
-
var fs$1 = require('node:fs/promises');
|
|
35
34
|
var npa = _socketInterop(require('npm-package-arg'));
|
|
36
35
|
var semver = _socketInterop(require('semver'));
|
|
37
36
|
var tinyglobby = _socketInterop(require('tinyglobby'));
|
|
@@ -44,6 +43,7 @@ var strings = require('@socketsecurity/registry/lib/strings');
|
|
|
44
43
|
var browserslist = _socketInterop(require('browserslist'));
|
|
45
44
|
var which = _socketInterop(require('which'));
|
|
46
45
|
var index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs');
|
|
46
|
+
var sorts = require('@socketsecurity/registry/lib/sorts');
|
|
47
47
|
var betterAjvErrors = _socketInterop(require('@apideck/better-ajv-errors'));
|
|
48
48
|
var config = require('@socketsecurity/config');
|
|
49
49
|
var os = require('node:os');
|
|
@@ -51,6 +51,7 @@ var readline = require('node:readline');
|
|
|
51
51
|
var readline$1 = require('node:readline/promises');
|
|
52
52
|
var open = _socketInterop(require('open'));
|
|
53
53
|
var chalkTable = _socketInterop(require('chalk-table'));
|
|
54
|
+
var fs$1 = require('node:fs/promises');
|
|
54
55
|
var ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'));
|
|
55
56
|
var GridLayout = _socketInterop(require('blessed-contrib/lib/layout/grid'));
|
|
56
57
|
var BarChart = _socketInterop(require('blessed-contrib/lib/widget/charts/bar'));
|
|
@@ -224,24 +225,30 @@ const {
|
|
|
224
225
|
} = constants;
|
|
225
226
|
function shadowNpmInstall(opts) {
|
|
226
227
|
const {
|
|
227
|
-
flags = [],
|
|
228
|
+
flags: flags_ = [],
|
|
228
229
|
ipc,
|
|
229
230
|
...spawnOptions
|
|
230
231
|
} = {
|
|
231
232
|
__proto__: null,
|
|
232
233
|
...opts
|
|
233
234
|
};
|
|
235
|
+
const flags = flags_.filter(f => f !== '--audit' && f !== '--fund' && f !== '--progress' && f !== '--no-audit' && f !== '--no-fund' && f !== '--no-progress');
|
|
234
236
|
const useIpc = objects.isObject(ipc);
|
|
235
|
-
const useDebug =
|
|
236
|
-
const
|
|
237
|
+
const useDebug = npmPaths.isDebug();
|
|
238
|
+
const spawnPromise = spawn(
|
|
237
239
|
// Lazily access constants.execPath.
|
|
238
240
|
constants.execPath, [
|
|
239
|
-
// Lazily access constants.
|
|
240
|
-
|
|
241
|
-
//
|
|
242
|
-
|
|
243
|
-
//
|
|
244
|
-
|
|
241
|
+
// Lazily access constants.nodeNoWarningsFlags.
|
|
242
|
+
...constants.nodeNoWarningsFlags, '--require',
|
|
243
|
+
// Lazily access constants.distPath.
|
|
244
|
+
path.join(constants.distPath, 'npm-injection.js'), npmPaths.getNpmBinPath(), 'install',
|
|
245
|
+
// Even though the '--silent' flag is passed npm will still run through
|
|
246
|
+
// code paths for 'audit' and 'fund' unless '--no-audit' and '--no-fund'
|
|
247
|
+
// flags are passed.
|
|
248
|
+
'--no-audit', '--no-fund',
|
|
249
|
+
// Add `--no-progress` flags to fix input being swallowed by the spinner
|
|
250
|
+
// when running the command with recent versions of npm.
|
|
251
|
+
'--no-progress', ...(useDebug || flags.some(f => f.startsWith('--loglevel') || f === '-d' || f === '--dd' || f === '--ddd' || f === '-q' || f === '--quiet' || f === '-s' || f === '--silent') ? [] : ['--silent']), ...flags], {
|
|
245
252
|
signal: abortSignal$3,
|
|
246
253
|
// Set stdio to include 'ipc'.
|
|
247
254
|
// See https://github.com/nodejs/node/blob/v23.6.0/lib/child_process.js#L161-L166
|
|
@@ -258,9 +265,9 @@ function shadowNpmInstall(opts) {
|
|
|
258
265
|
}
|
|
259
266
|
});
|
|
260
267
|
if (useIpc) {
|
|
261
|
-
|
|
268
|
+
spawnPromise.process.send(ipc);
|
|
262
269
|
}
|
|
263
|
-
return
|
|
270
|
+
return spawnPromise;
|
|
264
271
|
}
|
|
265
272
|
|
|
266
273
|
const {
|
|
@@ -335,47 +342,6 @@ const validationFlags = {
|
|
|
335
342
|
}
|
|
336
343
|
};
|
|
337
344
|
|
|
338
|
-
const {
|
|
339
|
-
API_V0_URL
|
|
340
|
-
} = constants;
|
|
341
|
-
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
342
|
-
// SocketSdkErrorType['error'] is not typed.
|
|
343
|
-
const resultErrorMessage = result.error?.message;
|
|
344
|
-
const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
|
|
345
|
-
if (result.status === 401 || result.status === 403) {
|
|
346
|
-
spinner.stop();
|
|
347
|
-
throw new socketUrl.AuthError(message);
|
|
348
|
-
}
|
|
349
|
-
spinner.error(`${colors.bgRed(colors.white('API returned an error:'))} ${message}`);
|
|
350
|
-
process$1.exit(1);
|
|
351
|
-
}
|
|
352
|
-
async function handleApiCall(value, description) {
|
|
353
|
-
let result;
|
|
354
|
-
try {
|
|
355
|
-
result = await value;
|
|
356
|
-
} catch (cause) {
|
|
357
|
-
throw new ponyCause.ErrorWithCause(`Failed ${description}`, {
|
|
358
|
-
cause
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
return result;
|
|
362
|
-
}
|
|
363
|
-
async function handleAPIError(code) {
|
|
364
|
-
if (code === 400) {
|
|
365
|
-
return 'One of the options passed might be incorrect.';
|
|
366
|
-
} else if (code === 403) {
|
|
367
|
-
return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
async function queryAPI(path, apiKey) {
|
|
371
|
-
return await fetch(`${API_V0_URL}/${path}`, {
|
|
372
|
-
method: 'GET',
|
|
373
|
-
headers: {
|
|
374
|
-
Authorization: `Basic ${btoa(`${apiKey}:${apiKey}`)}`
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
|
|
379
345
|
function objectSome(obj) {
|
|
380
346
|
for (const key in obj) {
|
|
381
347
|
if (obj[key]) {
|
|
@@ -392,31 +358,6 @@ function pick(input, keys) {
|
|
|
392
358
|
return result;
|
|
393
359
|
}
|
|
394
360
|
|
|
395
|
-
function getFlagListOutput(list, indent, {
|
|
396
|
-
keyPrefix = '--',
|
|
397
|
-
padName
|
|
398
|
-
} = {}) {
|
|
399
|
-
return getHelpListOutput({
|
|
400
|
-
...list
|
|
401
|
-
}, indent, {
|
|
402
|
-
keyPrefix,
|
|
403
|
-
padName
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
function getHelpListOutput(list, indent, {
|
|
407
|
-
keyPrefix = '',
|
|
408
|
-
padName = 18
|
|
409
|
-
} = {}) {
|
|
410
|
-
let result = '';
|
|
411
|
-
const names = Object.keys(list).sort();
|
|
412
|
-
for (const name of names) {
|
|
413
|
-
const rawDescription = list[name];
|
|
414
|
-
const description = (typeof rawDescription === 'object' ? rawDescription.description : rawDescription) || '';
|
|
415
|
-
result += ''.padEnd(indent) + (keyPrefix + name).padEnd(padName) + description + '\n';
|
|
416
|
-
}
|
|
417
|
-
return result.trim();
|
|
418
|
-
}
|
|
419
|
-
|
|
420
361
|
function stringJoinWithSeparateFinalSeparator(list, separator = ' and ') {
|
|
421
362
|
const values = list.filter(Boolean);
|
|
422
363
|
const {
|
|
@@ -432,6 +373,7 @@ function stringJoinWithSeparateFinalSeparator(list, separator = ' and ') {
|
|
|
432
373
|
return `${values.join(', ')}${separator}${finalValue}`;
|
|
433
374
|
}
|
|
434
375
|
|
|
376
|
+
// Ordered from most severe to least.
|
|
435
377
|
const SEVERITIES_BY_ORDER = ['critical', 'high', 'middle', 'low'];
|
|
436
378
|
function getDesiredSeverities(lowestToInclude) {
|
|
437
379
|
const result = [];
|
|
@@ -473,6 +415,72 @@ function getSeverityCount(issues, lowestToInclude) {
|
|
|
473
415
|
return severityCount;
|
|
474
416
|
}
|
|
475
417
|
|
|
418
|
+
const {
|
|
419
|
+
API_V0_URL
|
|
420
|
+
} = constants;
|
|
421
|
+
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
422
|
+
// SocketSdkErrorType['error'] is not typed.
|
|
423
|
+
const resultErrorMessage = result.error?.message;
|
|
424
|
+
const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
|
|
425
|
+
if (result.status === 401 || result.status === 403) {
|
|
426
|
+
spinner.stop();
|
|
427
|
+
throw new socketUrl.AuthError(message);
|
|
428
|
+
}
|
|
429
|
+
spinner.error(`${colors.bgRed(colors.white('API returned an error:'))} ${message}`);
|
|
430
|
+
process$1.exit(1);
|
|
431
|
+
}
|
|
432
|
+
async function handleApiCall(value, description) {
|
|
433
|
+
let result;
|
|
434
|
+
try {
|
|
435
|
+
result = await value;
|
|
436
|
+
} catch (cause) {
|
|
437
|
+
throw new ponyCause.ErrorWithCause(`Failed ${description}`, {
|
|
438
|
+
cause
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
return result;
|
|
442
|
+
}
|
|
443
|
+
async function handleAPIError(code) {
|
|
444
|
+
if (code === 400) {
|
|
445
|
+
return 'One of the options passed might be incorrect.';
|
|
446
|
+
} else if (code === 403) {
|
|
447
|
+
return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
async function queryAPI(path, apiKey) {
|
|
451
|
+
return await fetch(`${API_V0_URL}/${path}`, {
|
|
452
|
+
method: 'GET',
|
|
453
|
+
headers: {
|
|
454
|
+
Authorization: `Basic ${btoa(`${apiKey}:${apiKey}`)}`
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function getFlagListOutput(list, indent, {
|
|
460
|
+
keyPrefix = '--',
|
|
461
|
+
padName
|
|
462
|
+
} = {}) {
|
|
463
|
+
return getHelpListOutput({
|
|
464
|
+
...list
|
|
465
|
+
}, indent, {
|
|
466
|
+
keyPrefix,
|
|
467
|
+
padName
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
function getHelpListOutput(list, indent, {
|
|
471
|
+
keyPrefix = '',
|
|
472
|
+
padName = 18
|
|
473
|
+
} = {}) {
|
|
474
|
+
let result = '';
|
|
475
|
+
const names = Object.keys(list).sort();
|
|
476
|
+
for (const name of names) {
|
|
477
|
+
const rawDescription = list[name];
|
|
478
|
+
const description = (typeof rawDescription === 'object' ? rawDescription.description : rawDescription) || '';
|
|
479
|
+
result += ''.padEnd(indent) + (keyPrefix + name).padEnd(padName) + description + '\n';
|
|
480
|
+
}
|
|
481
|
+
return result.trim();
|
|
482
|
+
}
|
|
483
|
+
|
|
476
484
|
const {
|
|
477
485
|
NPM: NPM$4
|
|
478
486
|
} = registryConstants;
|
|
@@ -834,48 +842,6 @@ const npx = {
|
|
|
834
842
|
}
|
|
835
843
|
};
|
|
836
844
|
|
|
837
|
-
function existsSync(filepath) {
|
|
838
|
-
try {
|
|
839
|
-
return filepath ? fs.existsSync(filepath) : false;
|
|
840
|
-
} catch {}
|
|
841
|
-
return false;
|
|
842
|
-
}
|
|
843
|
-
async function findUp(name, {
|
|
844
|
-
cwd = process$1.cwd()
|
|
845
|
-
}) {
|
|
846
|
-
let dir = path.resolve(cwd);
|
|
847
|
-
const {
|
|
848
|
-
root
|
|
849
|
-
} = path.parse(dir);
|
|
850
|
-
const names = [name].flat();
|
|
851
|
-
while (dir && dir !== root) {
|
|
852
|
-
for (const name of names) {
|
|
853
|
-
const filePath = path.join(dir, name);
|
|
854
|
-
try {
|
|
855
|
-
// eslint-disable-next-line no-await-in-loop
|
|
856
|
-
const stats = await fs.promises.stat(filePath);
|
|
857
|
-
if (stats.isFile()) {
|
|
858
|
-
return filePath;
|
|
859
|
-
}
|
|
860
|
-
} catch {}
|
|
861
|
-
}
|
|
862
|
-
dir = path.dirname(dir);
|
|
863
|
-
}
|
|
864
|
-
return undefined;
|
|
865
|
-
}
|
|
866
|
-
async function readFileBinary(filepath, options) {
|
|
867
|
-
return await fs.promises.readFile(filepath, {
|
|
868
|
-
...options,
|
|
869
|
-
encoding: 'binary'
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
async function readFileUtf8(filepath, options) {
|
|
873
|
-
return await fs.promises.readFile(filepath, {
|
|
874
|
-
...options,
|
|
875
|
-
encoding: 'utf8'
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
|
-
|
|
879
845
|
const {
|
|
880
846
|
BINARY_LOCK_EXT,
|
|
881
847
|
BUN: BUN$1,
|
|
@@ -888,12 +854,6 @@ const {
|
|
|
888
854
|
YARN_CLASSIC: YARN_CLASSIC$1
|
|
889
855
|
} = constants;
|
|
890
856
|
const AGENTS = [BUN$1, NPM$2, PNPM$1, YARN_BERRY$1, YARN_CLASSIC$1, VLT$1];
|
|
891
|
-
const {
|
|
892
|
-
compare: alphanumericComparator
|
|
893
|
-
} = new Intl.Collator(undefined, {
|
|
894
|
-
numeric: true,
|
|
895
|
-
sensitivity: 'base'
|
|
896
|
-
});
|
|
897
857
|
const binByAgent = {
|
|
898
858
|
__proto__: null,
|
|
899
859
|
[BUN$1]: BUN$1,
|
|
@@ -951,8 +911,8 @@ const readLockFileByAgent = (() => {
|
|
|
951
911
|
return undefined;
|
|
952
912
|
};
|
|
953
913
|
}
|
|
954
|
-
const binaryReader = wrapReader(readFileBinary);
|
|
955
|
-
const defaultReader = wrapReader(async lockPath => await readFileUtf8(lockPath));
|
|
914
|
+
const binaryReader = wrapReader(socketUrl.readFileBinary);
|
|
915
|
+
const defaultReader = wrapReader(async lockPath => await socketUrl.readFileUtf8(lockPath));
|
|
956
916
|
return {
|
|
957
917
|
[BUN$1]: wrapReader(async (lockPath, agentExecPath) => {
|
|
958
918
|
const ext = path.extname(lockPath);
|
|
@@ -984,15 +944,15 @@ async function detect({
|
|
|
984
944
|
cwd = process$1.cwd(),
|
|
985
945
|
onUnknown
|
|
986
946
|
} = {}) {
|
|
987
|
-
let lockPath = await findUp(Object.keys(LOCKS), {
|
|
947
|
+
let lockPath = await socketUrl.findUp(Object.keys(LOCKS), {
|
|
988
948
|
cwd
|
|
989
949
|
});
|
|
990
950
|
let lockBasename = lockPath ? path.basename(lockPath) : undefined;
|
|
991
951
|
const isHiddenLockFile = lockBasename === '.package-lock.json';
|
|
992
|
-
const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await findUp('package.json', {
|
|
952
|
+
const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await socketUrl.findUp('package.json', {
|
|
993
953
|
cwd
|
|
994
954
|
});
|
|
995
|
-
const pkgPath = existsSync(pkgJsonPath) ? path.dirname(pkgJsonPath) : undefined;
|
|
955
|
+
const pkgPath = pkgJsonPath && fs.existsSync(pkgJsonPath) ? path.dirname(pkgJsonPath) : undefined;
|
|
996
956
|
const editablePkgJson = pkgPath ? await packages.readPackageJson(pkgPath, {
|
|
997
957
|
editable: true
|
|
998
958
|
}) : undefined;
|
|
@@ -1049,7 +1009,7 @@ async function detect({
|
|
|
1049
1009
|
}
|
|
1050
1010
|
const browserslistQuery = pkgJson['browserslist'];
|
|
1051
1011
|
if (Array.isArray(browserslistQuery)) {
|
|
1052
|
-
const browserslistTargets = browserslist(browserslistQuery).map(s => s.toLowerCase()).sort(
|
|
1012
|
+
const browserslistTargets = browserslist(browserslistQuery).map(s => s.toLowerCase()).sort(sorts.naturalCompare);
|
|
1053
1013
|
const browserslistNodeTargets = browserslistTargets.filter(v => v.startsWith('node ')).map(v => v.slice(5 /*'node '.length*/));
|
|
1054
1014
|
if (!targets.browser && browserslistTargets.length) {
|
|
1055
1015
|
targets.browser = browserslistTargets.length !== browserslistNodeTargets.length;
|
|
@@ -1475,11 +1435,11 @@ async function getWorkspaceGlobs(agent, pkgPath, pkgJson) {
|
|
|
1475
1435
|
let workspacePatterns;
|
|
1476
1436
|
if (agent === PNPM) {
|
|
1477
1437
|
for (const workspacePath of [path.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), path.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
|
|
1478
|
-
|
|
1438
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1439
|
+
const yml = await socketUrl.safeReadFile(workspacePath, 'utf8');
|
|
1440
|
+
if (yml) {
|
|
1479
1441
|
try {
|
|
1480
|
-
workspacePatterns = yaml.parse(
|
|
1481
|
-
// eslint-disable-next-line no-await-in-loop
|
|
1482
|
-
await fs$1.readFile(workspacePath, 'utf8'))?.packages;
|
|
1442
|
+
workspacePatterns = yaml.parse(yml)?.packages;
|
|
1483
1443
|
} catch {}
|
|
1484
1444
|
if (workspacePatterns) {
|
|
1485
1445
|
break;
|
|
@@ -1964,16 +1924,7 @@ async function setupCommand$j(name, description, argv, importMeta) {
|
|
|
1964
1924
|
cli.showHelp();
|
|
1965
1925
|
return;
|
|
1966
1926
|
}
|
|
1967
|
-
const {
|
|
1968
|
-
path: binPath
|
|
1969
|
-
} = await pathResolve.findBinPathDetails(binName$1);
|
|
1970
|
-
if (!binPath) {
|
|
1971
|
-
// The exit code 127 indicates that the command or binary being executed
|
|
1972
|
-
// could not be found.
|
|
1973
|
-
console.error(`Socket unable to locate ${binName$1}; ensure it is available in the PATH environment variable.`);
|
|
1974
|
-
process$1.exit(127);
|
|
1975
|
-
}
|
|
1976
|
-
const spawnPromise = spawn(binPath, argv, {
|
|
1927
|
+
const spawnPromise = spawn(npmPaths.getNpmBinPath(), argv, {
|
|
1977
1928
|
signal: abortSignal$1,
|
|
1978
1929
|
stdio: 'inherit'
|
|
1979
1930
|
});
|
|
@@ -2032,16 +1983,7 @@ async function setupCommand$i(name, description, argv, importMeta) {
|
|
|
2032
1983
|
cli.showHelp();
|
|
2033
1984
|
return;
|
|
2034
1985
|
}
|
|
2035
|
-
const {
|
|
2036
|
-
path: binPath
|
|
2037
|
-
} = await pathResolve.findBinPathDetails(binName);
|
|
2038
|
-
if (!binPath) {
|
|
2039
|
-
// The exit code 127 indicates that the command or binary being executed
|
|
2040
|
-
// could not be found.
|
|
2041
|
-
console.error(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable.`);
|
|
2042
|
-
process$1.exit(127);
|
|
2043
|
-
}
|
|
2044
|
-
const spawnPromise = spawn(binPath, argv, {
|
|
1986
|
+
const spawnPromise = spawn(npmPaths.getNpxBinPath(), argv, {
|
|
2045
1987
|
signal: abortSignal,
|
|
2046
1988
|
stdio: 'inherit'
|
|
2047
1989
|
});
|
|
@@ -2218,7 +2160,6 @@ const create$2 = {
|
|
|
2218
2160
|
}));
|
|
2219
2161
|
if (reportData) {
|
|
2220
2162
|
formatReportDataOutput(reportData, {
|
|
2221
|
-
includeAllIssues,
|
|
2222
2163
|
name,
|
|
2223
2164
|
outputJson,
|
|
2224
2165
|
outputMarkdown,
|
|
@@ -2330,7 +2271,7 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
2330
2271
|
cause
|
|
2331
2272
|
});
|
|
2332
2273
|
});
|
|
2333
|
-
const packagePaths = await
|
|
2274
|
+
const packagePaths = await npmPaths.getPackageFiles(cwd, cli.input, config$1, supportedFiles);
|
|
2334
2275
|
return {
|
|
2335
2276
|
config: config$1,
|
|
2336
2277
|
cwd,
|
|
@@ -2348,7 +2289,7 @@ async function createReport(packagePaths, {
|
|
|
2348
2289
|
cwd,
|
|
2349
2290
|
dryRun
|
|
2350
2291
|
}) {
|
|
2351
|
-
|
|
2292
|
+
npmPaths.debugLog('Uploading:', packagePaths.join(`\n${npmPaths.logSymbols.info} Uploading: `));
|
|
2352
2293
|
if (dryRun) {
|
|
2353
2294
|
return;
|
|
2354
2295
|
}
|
|
@@ -2718,7 +2659,7 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2718
2659
|
cause
|
|
2719
2660
|
});
|
|
2720
2661
|
});
|
|
2721
|
-
const packagePaths = await
|
|
2662
|
+
const packagePaths = await npmPaths.getPackageFilesFullScans(cwd, cli.input, supportedFiles);
|
|
2722
2663
|
const {
|
|
2723
2664
|
branch: branchName,
|
|
2724
2665
|
repo: repoName
|
|
@@ -3833,7 +3774,7 @@ const dependencies = {
|
|
|
3833
3774
|
}) {
|
|
3834
3775
|
const name = parentName + ' dependencies';
|
|
3835
3776
|
const input = setupCommand$3(name, dependencies.description, argv, importMeta);
|
|
3836
|
-
{
|
|
3777
|
+
if (input) {
|
|
3837
3778
|
await searchDeps(input);
|
|
3838
3779
|
}
|
|
3839
3780
|
}
|
|
@@ -4401,7 +4342,7 @@ const threatFeed = {
|
|
|
4401
4342
|
}) {
|
|
4402
4343
|
const name = `${parentName} threat-feed`;
|
|
4403
4344
|
const input = setupCommand(name, threatFeed.description, argv, importMeta);
|
|
4404
|
-
{
|
|
4345
|
+
if (input) {
|
|
4405
4346
|
const apiKey = socketUrl.getDefaultToken();
|
|
4406
4347
|
if (!apiKey) {
|
|
4407
4348
|
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
@@ -4622,7 +4563,7 @@ void (async () => {
|
|
|
4622
4563
|
} else {
|
|
4623
4564
|
errorTitle = 'Unexpected error with no details';
|
|
4624
4565
|
}
|
|
4625
|
-
console.error(`${
|
|
4566
|
+
console.error(`${npmPaths.logSymbols.error} ${colors.bgRed(colors.white(errorTitle + ':'))} ${errorMessage}`);
|
|
4626
4567
|
if (errorBody) {
|
|
4627
4568
|
console.error(`\n${errorBody}`);
|
|
4628
4569
|
}
|