@socketsecurity/cli 0.14.40 → 0.14.41
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/module-sync/cli.js +83 -129
- package/dist/module-sync/npm-injection.js +208 -257
- package/dist/module-sync/settings.d.ts +6 -1
- package/dist/module-sync/socket-url.d.ts +17 -1
- package/dist/module-sync/socket-url.js +81 -2
- package/dist/require/cli.js +83 -129
- package/package.json +26 -20
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import config from '@socketsecurity/config';
|
|
1
2
|
interface Settings {
|
|
2
3
|
apiKey?: string | null;
|
|
3
4
|
enforcedOrgs?: string[] | null;
|
|
4
5
|
apiBaseUrl?: string | null;
|
|
5
6
|
apiProxy?: string | null;
|
|
6
7
|
}
|
|
8
|
+
declare function findSocketYmlSync(): {
|
|
9
|
+
path: string;
|
|
10
|
+
parsed: config.SocketYml;
|
|
11
|
+
} | null;
|
|
7
12
|
declare function getSetting<Key extends keyof Settings>(key: Key): Settings[Key];
|
|
8
13
|
declare function updateSetting<Key extends keyof Settings>(key: Key, value: Settings[Key]): void;
|
|
9
|
-
export { getSetting, updateSetting };
|
|
14
|
+
export { findSocketYmlSync, getSetting, updateSetting };
|
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { SocketSdk } from "@socketsecurity/sdk";
|
|
3
|
+
import { ObjectEncodingOptions, OpenMode, PathLike } from "node:fs";
|
|
4
|
+
import { promises as fs } from "node:fs";
|
|
5
|
+
import { readFileSync as fsReadFileSync } from "node:fs";
|
|
6
|
+
import { Abortable } from "node:events";
|
|
7
|
+
import { FileHandle } from "node:fs/promises";
|
|
2
8
|
import indentString from "@socketregistry/indent-string/index.cjs";
|
|
3
9
|
import { logSymbols } from "./logging.js";
|
|
4
10
|
declare function getDefaultToken(): string | undefined;
|
|
5
11
|
declare function getPublicToken(): string;
|
|
6
12
|
declare function setupSdk(apiToken?: string | undefined, apiBaseUrl?: string | undefined, proxy?: string | undefined): Promise<SocketSdk>;
|
|
13
|
+
declare function findUp(name: string | string[], { cwd }: {
|
|
14
|
+
cwd: string | undefined;
|
|
15
|
+
}): Promise<string | undefined>;
|
|
16
|
+
type ReadFileOptions = ObjectEncodingOptions & Abortable & {
|
|
17
|
+
flag?: OpenMode | undefined;
|
|
18
|
+
};
|
|
19
|
+
declare function readFileBinary(filepath: PathLike | FileHandle, options?: ReadFileOptions): Promise<Buffer>;
|
|
20
|
+
declare function readFileUtf8(filepath: PathLike | FileHandle, options?: ReadFileOptions): Promise<string>;
|
|
21
|
+
declare function safeReadFile(...args: Parameters<typeof fs.readFile>): ReturnType<typeof fs.readFile> | undefined;
|
|
22
|
+
declare function safeReadFileSync(...args: Parameters<typeof fsReadFileSync>): ReturnType<typeof fsReadFileSync> | undefined;
|
|
7
23
|
declare class ColorOrMarkdown {
|
|
8
24
|
useMarkdown: boolean;
|
|
9
25
|
constructor(useMarkdown: boolean);
|
|
@@ -21,4 +37,4 @@ declare class ColorOrMarkdown {
|
|
|
21
37
|
}
|
|
22
38
|
declare function getSocketDevAlertUrl(alertType: string): string;
|
|
23
39
|
declare function getSocketDevPackageOverviewUrl(eco: string, name: string, version?: string): string;
|
|
24
|
-
export { getDefaultToken, getPublicToken, setupSdk, ColorOrMarkdown, getSocketDevAlertUrl, getSocketDevPackageOverviewUrl };
|
|
40
|
+
export { getDefaultToken, getPublicToken, setupSdk, findUp, ReadFileOptions, readFileBinary, readFileUtf8, safeReadFile, safeReadFileSync, ColorOrMarkdown, getSocketDevAlertUrl, getSocketDevPackageOverviewUrl };
|
|
@@ -23,6 +23,7 @@ var sdk = require('@socketsecurity/sdk');
|
|
|
23
23
|
var fs = require('node:fs');
|
|
24
24
|
var os = require('node:os');
|
|
25
25
|
var path = require('node:path');
|
|
26
|
+
var config = require('@socketsecurity/config');
|
|
26
27
|
var constants = require('./constants.js');
|
|
27
28
|
|
|
28
29
|
class AuthError extends Error {}
|
|
@@ -85,6 +86,54 @@ class ColorOrMarkdown {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
async function findUp(name, {
|
|
90
|
+
cwd = process.cwd()
|
|
91
|
+
}) {
|
|
92
|
+
let dir = path.resolve(cwd);
|
|
93
|
+
const {
|
|
94
|
+
root
|
|
95
|
+
} = path.parse(dir);
|
|
96
|
+
const names = [name].flat();
|
|
97
|
+
while (dir && dir !== root) {
|
|
98
|
+
for (const name of names) {
|
|
99
|
+
const filePath = path.join(dir, name);
|
|
100
|
+
try {
|
|
101
|
+
// eslint-disable-next-line no-await-in-loop
|
|
102
|
+
const stats = await fs.promises.stat(filePath);
|
|
103
|
+
if (stats.isFile()) {
|
|
104
|
+
return filePath;
|
|
105
|
+
}
|
|
106
|
+
} catch {}
|
|
107
|
+
}
|
|
108
|
+
dir = path.dirname(dir);
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
async function readFileBinary(filepath, options) {
|
|
113
|
+
return await fs.promises.readFile(filepath, {
|
|
114
|
+
...options,
|
|
115
|
+
encoding: 'binary'
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
async function readFileUtf8(filepath, options) {
|
|
119
|
+
return await fs.promises.readFile(filepath, {
|
|
120
|
+
...options,
|
|
121
|
+
encoding: 'utf8'
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function safeReadFile(...args) {
|
|
125
|
+
try {
|
|
126
|
+
return fs.promises.readFile(...args);
|
|
127
|
+
} catch {}
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
function safeReadFileSync(...args) {
|
|
131
|
+
try {
|
|
132
|
+
return fs.readFileSync(...args);
|
|
133
|
+
} catch {}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
|
|
88
137
|
const LOCALAPPDATA = 'LOCALAPPDATA';
|
|
89
138
|
let _settings;
|
|
90
139
|
function getSettings() {
|
|
@@ -92,8 +141,8 @@ function getSettings() {
|
|
|
92
141
|
_settings = {};
|
|
93
142
|
const settingsPath = getSettingsPath();
|
|
94
143
|
if (settingsPath) {
|
|
95
|
-
|
|
96
|
-
|
|
144
|
+
const raw = safeReadFileSync(settingsPath, 'utf8');
|
|
145
|
+
if (raw) {
|
|
97
146
|
try {
|
|
98
147
|
Object.assign(_settings, JSON.parse(Buffer.from(raw, 'base64').toString()));
|
|
99
148
|
} catch {
|
|
@@ -131,6 +180,31 @@ function getSettingsPath() {
|
|
|
131
180
|
}
|
|
132
181
|
return _settingsPath;
|
|
133
182
|
}
|
|
183
|
+
function findSocketYmlSync() {
|
|
184
|
+
let prevDir = null;
|
|
185
|
+
let dir = process.cwd();
|
|
186
|
+
while (dir !== prevDir) {
|
|
187
|
+
let ymlPath = path.join(dir, 'socket.yml');
|
|
188
|
+
let yml = safeReadFileSync(ymlPath, 'utf8');
|
|
189
|
+
if (yml === undefined) {
|
|
190
|
+
ymlPath = path.join(dir, 'socket.yaml');
|
|
191
|
+
yml = safeReadFileSync(ymlPath, 'utf8');
|
|
192
|
+
}
|
|
193
|
+
if (typeof yml === 'string') {
|
|
194
|
+
try {
|
|
195
|
+
return {
|
|
196
|
+
path: ymlPath,
|
|
197
|
+
parsed: config.parseSocketConfig(yml)
|
|
198
|
+
};
|
|
199
|
+
} catch {
|
|
200
|
+
throw new Error(`Found file but was unable to parse ${ymlPath}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
prevDir = dir;
|
|
204
|
+
dir = path.join(dir, '..');
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
134
208
|
function getSetting(key) {
|
|
135
209
|
return getSettings()[key];
|
|
136
210
|
}
|
|
@@ -212,11 +286,16 @@ function getSocketDevPackageOverviewUrl(eco, name, version) {
|
|
|
212
286
|
exports.AuthError = AuthError;
|
|
213
287
|
exports.ColorOrMarkdown = ColorOrMarkdown;
|
|
214
288
|
exports.InputError = InputError;
|
|
289
|
+
exports.findSocketYmlSync = findSocketYmlSync;
|
|
290
|
+
exports.findUp = findUp;
|
|
215
291
|
exports.getDefaultToken = getDefaultToken;
|
|
216
292
|
exports.getPublicToken = getPublicToken;
|
|
217
293
|
exports.getSetting = getSetting;
|
|
218
294
|
exports.getSocketDevAlertUrl = getSocketDevAlertUrl;
|
|
219
295
|
exports.getSocketDevPackageOverviewUrl = getSocketDevPackageOverviewUrl;
|
|
220
296
|
exports.isErrnoException = isErrnoException;
|
|
297
|
+
exports.readFileBinary = readFileBinary;
|
|
298
|
+
exports.readFileUtf8 = readFileUtf8;
|
|
299
|
+
exports.safeReadFile = safeReadFile;
|
|
221
300
|
exports.setupSdk = setupSdk;
|
|
222
301
|
exports.updateSetting = updateSetting;
|
package/dist/require/cli.js
CHANGED
|
@@ -30,7 +30,6 @@ var socketUrl = require('./socket-url.js');
|
|
|
30
30
|
var terminalLink = _socketInterop(require('terminal-link'));
|
|
31
31
|
var isInteractive = require('@socketregistry/is-interactive/index.cjs');
|
|
32
32
|
var prompts = require('@socketsecurity/registry/lib/prompts');
|
|
33
|
-
var fs$1 = require('node:fs/promises');
|
|
34
33
|
var npa = _socketInterop(require('npm-package-arg'));
|
|
35
34
|
var semver = _socketInterop(require('semver'));
|
|
36
35
|
var tinyglobby = _socketInterop(require('tinyglobby'));
|
|
@@ -43,12 +42,14 @@ var strings = require('@socketsecurity/registry/lib/strings');
|
|
|
43
42
|
var browserslist = _socketInterop(require('browserslist'));
|
|
44
43
|
var which = _socketInterop(require('which'));
|
|
45
44
|
var index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs');
|
|
45
|
+
var sorts = require('@socketsecurity/registry/lib/sorts');
|
|
46
46
|
var betterAjvErrors = _socketInterop(require('@apideck/better-ajv-errors'));
|
|
47
47
|
var config = require('@socketsecurity/config');
|
|
48
48
|
var os = require('node:os');
|
|
49
49
|
var readline = require('node:readline');
|
|
50
50
|
var readline$1 = require('node:readline/promises');
|
|
51
51
|
var chalkTable = _socketInterop(require('chalk-table'));
|
|
52
|
+
var fs$1 = require('node:fs/promises');
|
|
52
53
|
var ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'));
|
|
53
54
|
var GridLayout = _socketInterop(require('blessed-contrib/lib/layout/grid'));
|
|
54
55
|
var BarChart = _socketInterop(require('blessed-contrib/lib/widget/charts/bar'));
|
|
@@ -236,10 +237,10 @@ function shadowNpmInstall(opts) {
|
|
|
236
237
|
constants.execPath, [
|
|
237
238
|
// Lazily access constants.rootBinPath.
|
|
238
239
|
path.join(constants.rootBinPath, 'npm-cli.js'), 'install',
|
|
239
|
-
// Even though the 'silent' flag is passed npm will still run through
|
|
240
|
-
// paths for 'audit' and 'fund' unless '--no-audit' and '--no-fund'
|
|
241
|
-
// are passed.
|
|
242
|
-
...(useDebug ? ['--no-audit', '--no-fund'] : ['silent', '--no-audit', '--no-fund']), ...flags], {
|
|
240
|
+
// Even though the '--silent' flag is passed npm will still run through
|
|
241
|
+
// code paths for 'audit' and 'fund' unless '--no-audit' and '--no-fund'
|
|
242
|
+
// flags are passed.
|
|
243
|
+
...(useDebug ? ['--no-audit', '--no-fund'] : ['--silent', '--no-audit', '--no-fund']), ...flags], {
|
|
243
244
|
signal: abortSignal$3,
|
|
244
245
|
// Set stdio to include 'ipc'.
|
|
245
246
|
// See https://github.com/nodejs/node/blob/v23.6.0/lib/child_process.js#L161-L166
|
|
@@ -333,47 +334,6 @@ const validationFlags = {
|
|
|
333
334
|
}
|
|
334
335
|
};
|
|
335
336
|
|
|
336
|
-
const {
|
|
337
|
-
API_V0_URL
|
|
338
|
-
} = constants;
|
|
339
|
-
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
340
|
-
// SocketSdkErrorType['error'] is not typed.
|
|
341
|
-
const resultErrorMessage = result.error?.message;
|
|
342
|
-
const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
|
|
343
|
-
if (result.status === 401 || result.status === 403) {
|
|
344
|
-
spinner.stop();
|
|
345
|
-
throw new socketUrl.AuthError(message);
|
|
346
|
-
}
|
|
347
|
-
spinner.error(`${colors.bgRed(colors.white('API returned an error:'))} ${message}`);
|
|
348
|
-
process$1.exit(1);
|
|
349
|
-
}
|
|
350
|
-
async function handleApiCall(value, description) {
|
|
351
|
-
let result;
|
|
352
|
-
try {
|
|
353
|
-
result = await value;
|
|
354
|
-
} catch (cause) {
|
|
355
|
-
throw new ponyCause.ErrorWithCause(`Failed ${description}`, {
|
|
356
|
-
cause
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
return result;
|
|
360
|
-
}
|
|
361
|
-
async function handleAPIError(code) {
|
|
362
|
-
if (code === 400) {
|
|
363
|
-
return 'One of the options passed might be incorrect.';
|
|
364
|
-
} else if (code === 403) {
|
|
365
|
-
return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
async function queryAPI(path, apiKey) {
|
|
369
|
-
return await fetch(`${API_V0_URL}/${path}`, {
|
|
370
|
-
method: 'GET',
|
|
371
|
-
headers: {
|
|
372
|
-
Authorization: `Basic ${btoa(`${apiKey}:${apiKey}`)}`
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
|
|
377
337
|
function objectSome(obj) {
|
|
378
338
|
for (const key in obj) {
|
|
379
339
|
if (obj[key]) {
|
|
@@ -390,31 +350,6 @@ function pick(input, keys) {
|
|
|
390
350
|
return result;
|
|
391
351
|
}
|
|
392
352
|
|
|
393
|
-
function getFlagListOutput(list, indent, {
|
|
394
|
-
keyPrefix = '--',
|
|
395
|
-
padName
|
|
396
|
-
} = {}) {
|
|
397
|
-
return getHelpListOutput({
|
|
398
|
-
...list
|
|
399
|
-
}, indent, {
|
|
400
|
-
keyPrefix,
|
|
401
|
-
padName
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
function getHelpListOutput(list, indent, {
|
|
405
|
-
keyPrefix = '',
|
|
406
|
-
padName = 18
|
|
407
|
-
} = {}) {
|
|
408
|
-
let result = '';
|
|
409
|
-
const names = Object.keys(list).sort();
|
|
410
|
-
for (const name of names) {
|
|
411
|
-
const rawDescription = list[name];
|
|
412
|
-
const description = (typeof rawDescription === 'object' ? rawDescription.description : rawDescription) || '';
|
|
413
|
-
result += ''.padEnd(indent) + (keyPrefix + name).padEnd(padName) + description + '\n';
|
|
414
|
-
}
|
|
415
|
-
return result.trim();
|
|
416
|
-
}
|
|
417
|
-
|
|
418
353
|
function stringJoinWithSeparateFinalSeparator(list, separator = ' and ') {
|
|
419
354
|
const values = list.filter(Boolean);
|
|
420
355
|
const {
|
|
@@ -430,6 +365,7 @@ function stringJoinWithSeparateFinalSeparator(list, separator = ' and ') {
|
|
|
430
365
|
return `${values.join(', ')}${separator}${finalValue}`;
|
|
431
366
|
}
|
|
432
367
|
|
|
368
|
+
// Ordered from most severe to least.
|
|
433
369
|
const SEVERITIES_BY_ORDER = ['critical', 'high', 'middle', 'low'];
|
|
434
370
|
function getDesiredSeverities(lowestToInclude) {
|
|
435
371
|
const result = [];
|
|
@@ -471,6 +407,72 @@ function getSeverityCount(issues, lowestToInclude) {
|
|
|
471
407
|
return severityCount;
|
|
472
408
|
}
|
|
473
409
|
|
|
410
|
+
const {
|
|
411
|
+
API_V0_URL
|
|
412
|
+
} = constants;
|
|
413
|
+
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
414
|
+
// SocketSdkErrorType['error'] is not typed.
|
|
415
|
+
const resultErrorMessage = result.error?.message;
|
|
416
|
+
const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
|
|
417
|
+
if (result.status === 401 || result.status === 403) {
|
|
418
|
+
spinner.stop();
|
|
419
|
+
throw new socketUrl.AuthError(message);
|
|
420
|
+
}
|
|
421
|
+
spinner.error(`${colors.bgRed(colors.white('API returned an error:'))} ${message}`);
|
|
422
|
+
process$1.exit(1);
|
|
423
|
+
}
|
|
424
|
+
async function handleApiCall(value, description) {
|
|
425
|
+
let result;
|
|
426
|
+
try {
|
|
427
|
+
result = await value;
|
|
428
|
+
} catch (cause) {
|
|
429
|
+
throw new ponyCause.ErrorWithCause(`Failed ${description}`, {
|
|
430
|
+
cause
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
return result;
|
|
434
|
+
}
|
|
435
|
+
async function handleAPIError(code) {
|
|
436
|
+
if (code === 400) {
|
|
437
|
+
return 'One of the options passed might be incorrect.';
|
|
438
|
+
} else if (code === 403) {
|
|
439
|
+
return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
async function queryAPI(path, apiKey) {
|
|
443
|
+
return await fetch(`${API_V0_URL}/${path}`, {
|
|
444
|
+
method: 'GET',
|
|
445
|
+
headers: {
|
|
446
|
+
Authorization: `Basic ${btoa(`${apiKey}:${apiKey}`)}`
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function getFlagListOutput(list, indent, {
|
|
452
|
+
keyPrefix = '--',
|
|
453
|
+
padName
|
|
454
|
+
} = {}) {
|
|
455
|
+
return getHelpListOutput({
|
|
456
|
+
...list
|
|
457
|
+
}, indent, {
|
|
458
|
+
keyPrefix,
|
|
459
|
+
padName
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
function getHelpListOutput(list, indent, {
|
|
463
|
+
keyPrefix = '',
|
|
464
|
+
padName = 18
|
|
465
|
+
} = {}) {
|
|
466
|
+
let result = '';
|
|
467
|
+
const names = Object.keys(list).sort();
|
|
468
|
+
for (const name of names) {
|
|
469
|
+
const rawDescription = list[name];
|
|
470
|
+
const description = (typeof rawDescription === 'object' ? rawDescription.description : rawDescription) || '';
|
|
471
|
+
result += ''.padEnd(indent) + (keyPrefix + name).padEnd(padName) + description + '\n';
|
|
472
|
+
}
|
|
473
|
+
return result.trim();
|
|
474
|
+
}
|
|
475
|
+
|
|
474
476
|
const {
|
|
475
477
|
NPM: NPM$4
|
|
476
478
|
} = registryConstants;
|
|
@@ -832,48 +834,6 @@ const npx = {
|
|
|
832
834
|
}
|
|
833
835
|
};
|
|
834
836
|
|
|
835
|
-
function existsSync(filepath) {
|
|
836
|
-
try {
|
|
837
|
-
return filepath ? fs.existsSync(filepath) : false;
|
|
838
|
-
} catch {}
|
|
839
|
-
return false;
|
|
840
|
-
}
|
|
841
|
-
async function findUp(name, {
|
|
842
|
-
cwd = process$1.cwd()
|
|
843
|
-
}) {
|
|
844
|
-
let dir = path.resolve(cwd);
|
|
845
|
-
const {
|
|
846
|
-
root
|
|
847
|
-
} = path.parse(dir);
|
|
848
|
-
const names = [name].flat();
|
|
849
|
-
while (dir && dir !== root) {
|
|
850
|
-
for (const name of names) {
|
|
851
|
-
const filePath = path.join(dir, name);
|
|
852
|
-
try {
|
|
853
|
-
// eslint-disable-next-line no-await-in-loop
|
|
854
|
-
const stats = await fs.promises.stat(filePath);
|
|
855
|
-
if (stats.isFile()) {
|
|
856
|
-
return filePath;
|
|
857
|
-
}
|
|
858
|
-
} catch {}
|
|
859
|
-
}
|
|
860
|
-
dir = path.dirname(dir);
|
|
861
|
-
}
|
|
862
|
-
return undefined;
|
|
863
|
-
}
|
|
864
|
-
async function readFileBinary(filepath, options) {
|
|
865
|
-
return await fs.promises.readFile(filepath, {
|
|
866
|
-
...options,
|
|
867
|
-
encoding: 'binary'
|
|
868
|
-
});
|
|
869
|
-
}
|
|
870
|
-
async function readFileUtf8(filepath, options) {
|
|
871
|
-
return await fs.promises.readFile(filepath, {
|
|
872
|
-
...options,
|
|
873
|
-
encoding: 'utf8'
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
|
|
877
837
|
const {
|
|
878
838
|
BINARY_LOCK_EXT,
|
|
879
839
|
BUN: BUN$1,
|
|
@@ -886,12 +846,6 @@ const {
|
|
|
886
846
|
YARN_CLASSIC: YARN_CLASSIC$1
|
|
887
847
|
} = constants;
|
|
888
848
|
const AGENTS = [BUN$1, NPM$2, PNPM$1, YARN_BERRY$1, YARN_CLASSIC$1, VLT$1];
|
|
889
|
-
const {
|
|
890
|
-
compare: alphanumericComparator
|
|
891
|
-
} = new Intl.Collator(undefined, {
|
|
892
|
-
numeric: true,
|
|
893
|
-
sensitivity: 'base'
|
|
894
|
-
});
|
|
895
849
|
const binByAgent = {
|
|
896
850
|
__proto__: null,
|
|
897
851
|
[BUN$1]: BUN$1,
|
|
@@ -949,8 +903,8 @@ const readLockFileByAgent = (() => {
|
|
|
949
903
|
return undefined;
|
|
950
904
|
};
|
|
951
905
|
}
|
|
952
|
-
const binaryReader = wrapReader(readFileBinary);
|
|
953
|
-
const defaultReader = wrapReader(async lockPath => await readFileUtf8(lockPath));
|
|
906
|
+
const binaryReader = wrapReader(socketUrl.readFileBinary);
|
|
907
|
+
const defaultReader = wrapReader(async lockPath => await socketUrl.readFileUtf8(lockPath));
|
|
954
908
|
return {
|
|
955
909
|
[BUN$1]: wrapReader(async (lockPath, agentExecPath) => {
|
|
956
910
|
const ext = path.extname(lockPath);
|
|
@@ -982,15 +936,15 @@ async function detect({
|
|
|
982
936
|
cwd = process$1.cwd(),
|
|
983
937
|
onUnknown
|
|
984
938
|
} = {}) {
|
|
985
|
-
let lockPath = await findUp(Object.keys(LOCKS), {
|
|
939
|
+
let lockPath = await socketUrl.findUp(Object.keys(LOCKS), {
|
|
986
940
|
cwd
|
|
987
941
|
});
|
|
988
942
|
let lockBasename = lockPath ? path.basename(lockPath) : undefined;
|
|
989
943
|
const isHiddenLockFile = lockBasename === '.package-lock.json';
|
|
990
|
-
const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await findUp('package.json', {
|
|
944
|
+
const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await socketUrl.findUp('package.json', {
|
|
991
945
|
cwd
|
|
992
946
|
});
|
|
993
|
-
const pkgPath = existsSync(pkgJsonPath) ? path.dirname(pkgJsonPath) : undefined;
|
|
947
|
+
const pkgPath = pkgJsonPath && fs.existsSync(pkgJsonPath) ? path.dirname(pkgJsonPath) : undefined;
|
|
994
948
|
const editablePkgJson = pkgPath ? await packages.readPackageJson(pkgPath, {
|
|
995
949
|
editable: true
|
|
996
950
|
}) : undefined;
|
|
@@ -1047,7 +1001,7 @@ async function detect({
|
|
|
1047
1001
|
}
|
|
1048
1002
|
const browserslistQuery = pkgJson['browserslist'];
|
|
1049
1003
|
if (Array.isArray(browserslistQuery)) {
|
|
1050
|
-
const browserslistTargets = browserslist(browserslistQuery).map(s => s.toLowerCase()).sort(
|
|
1004
|
+
const browserslistTargets = browserslist(browserslistQuery).map(s => s.toLowerCase()).sort(sorts.naturalCompare);
|
|
1051
1005
|
const browserslistNodeTargets = browserslistTargets.filter(v => v.startsWith('node ')).map(v => v.slice(5 /*'node '.length*/));
|
|
1052
1006
|
if (!targets.browser && browserslistTargets.length) {
|
|
1053
1007
|
targets.browser = browserslistTargets.length !== browserslistNodeTargets.length;
|
|
@@ -1473,11 +1427,11 @@ async function getWorkspaceGlobs(agent, pkgPath, pkgJson) {
|
|
|
1473
1427
|
let workspacePatterns;
|
|
1474
1428
|
if (agent === PNPM) {
|
|
1475
1429
|
for (const workspacePath of [path.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), path.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
|
|
1476
|
-
|
|
1430
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1431
|
+
const yml = await socketUrl.safeReadFile(workspacePath, 'utf8');
|
|
1432
|
+
if (yml) {
|
|
1477
1433
|
try {
|
|
1478
|
-
workspacePatterns = yaml.parse(
|
|
1479
|
-
// eslint-disable-next-line no-await-in-loop
|
|
1480
|
-
await fs$1.readFile(workspacePath, 'utf8'))?.packages;
|
|
1434
|
+
workspacePatterns = yaml.parse(yml)?.packages;
|
|
1481
1435
|
} catch {}
|
|
1482
1436
|
if (workspacePatterns) {
|
|
1483
1437
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/cli",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.41",
|
|
4
4
|
"description": "CLI tool for Socket.dev",
|
|
5
5
|
"homepage": "http://github.com/SocketDev/socket-cli",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,6 +43,9 @@
|
|
|
43
43
|
"check:lint": "eslint --report-unused-disable-directives .",
|
|
44
44
|
"check:tsc": "tsc",
|
|
45
45
|
"check:type-coverage": "type-coverage --detail --strict --at-least 95 --ignore-files 'test/*'",
|
|
46
|
+
"clean": "run-p --aggregate-output clean:*",
|
|
47
|
+
"clean:dist": "del-cli 'dist' 'test/dist'",
|
|
48
|
+
"clean:node_modules": "del-cli '**/node_modules'",
|
|
46
49
|
"knip:dependencies": "knip --dependencies",
|
|
47
50
|
"knip:exports": "knip --include exports,duplicates",
|
|
48
51
|
"lint": "oxlint -c=./.oxlintrc.json --ignore-path=./.prettierignore --tsconfig=./tsconfig.json .",
|
|
@@ -53,18 +56,20 @@
|
|
|
53
56
|
"test-ci": "run-s build:* test:*",
|
|
54
57
|
"test:unit": "tap-run",
|
|
55
58
|
"test:coverage:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
|
|
56
|
-
"test:coverage:merge": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/{module-sync,require}/*.js' --exclude 'dist/require/vendor.js' report"
|
|
59
|
+
"test:coverage:merge": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/{module-sync,require}/*.js' --exclude 'dist/require/vendor.js' report",
|
|
60
|
+
"update": "run-p --aggregate-output update:**",
|
|
61
|
+
"update:deps": "npx npm-check-updates"
|
|
57
62
|
},
|
|
58
63
|
"dependencies": {
|
|
59
64
|
"@apideck/better-ajv-errors": "^0.3.6",
|
|
60
|
-
"@cyclonedx/cdxgen": "^11.1.
|
|
65
|
+
"@cyclonedx/cdxgen": "^11.1.5",
|
|
61
66
|
"@npmcli/promise-spawn": "^8.0.2",
|
|
62
|
-
"@socketregistry/hyrious__bun.lockb": "^1.0.
|
|
67
|
+
"@socketregistry/hyrious__bun.lockb": "^1.0.12",
|
|
63
68
|
"@socketregistry/indent-string": "^1.0.9",
|
|
64
69
|
"@socketregistry/is-interactive": "^1.0.1",
|
|
65
70
|
"@socketregistry/is-unicode-supported": "^1.0.0",
|
|
66
71
|
"@socketsecurity/config": "^2.1.3",
|
|
67
|
-
"@socketsecurity/registry": "^1.0.
|
|
72
|
+
"@socketsecurity/registry": "^1.0.78",
|
|
68
73
|
"@socketsecurity/sdk": "^1.4.5",
|
|
69
74
|
"blessed": "^0.1.81",
|
|
70
75
|
"blessed-contrib": "^4.11.0",
|
|
@@ -79,7 +84,7 @@
|
|
|
79
84
|
"npm-package-arg": "^12.0.1",
|
|
80
85
|
"open": "^10.1.0",
|
|
81
86
|
"pony-cause": "^2.1.11",
|
|
82
|
-
"semver": "^7.
|
|
87
|
+
"semver": "^7.7.0",
|
|
83
88
|
"synp": "^1.9.14",
|
|
84
89
|
"terminal-link": "2.1.1",
|
|
85
90
|
"tiny-updater": "^3.5.3",
|
|
@@ -90,16 +95,16 @@
|
|
|
90
95
|
"yoctocolors-cjs": "^2.1.2"
|
|
91
96
|
},
|
|
92
97
|
"devDependencies": {
|
|
93
|
-
"@babel/core": "^7.26.
|
|
98
|
+
"@babel/core": "^7.26.7",
|
|
94
99
|
"@babel/plugin-proposal-export-default-from": "^7.25.9",
|
|
95
100
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
96
101
|
"@babel/plugin-transform-export-namespace-from": "^7.25.9",
|
|
97
102
|
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
98
|
-
"@babel/preset-env": "^7.26.
|
|
103
|
+
"@babel/preset-env": "^7.26.7",
|
|
99
104
|
"@babel/preset-typescript": "^7.26.0",
|
|
100
|
-
"@babel/runtime": "^7.26.
|
|
105
|
+
"@babel/runtime": "^7.26.7",
|
|
101
106
|
"@eslint/compat": "^1.2.5",
|
|
102
|
-
"@eslint/js": "^9.
|
|
107
|
+
"@eslint/js": "^9.19.0",
|
|
103
108
|
"@rollup/plugin-commonjs": "^28.0.2",
|
|
104
109
|
"@rollup/plugin-json": "^6.1.0",
|
|
105
110
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
@@ -111,7 +116,7 @@
|
|
|
111
116
|
"@types/micromatch": "^4.0.9",
|
|
112
117
|
"@types/mocha": "^10.0.10",
|
|
113
118
|
"@types/mock-fs": "^4.13.4",
|
|
114
|
-
"@types/node": "^22.
|
|
119
|
+
"@types/node": "^22.12.0",
|
|
115
120
|
"@types/npmcli__arborist": "^6.3.0",
|
|
116
121
|
"@types/npmcli__promise-spawn": "^6.0.3",
|
|
117
122
|
"@types/proc-log": "^3.0.4",
|
|
@@ -119,31 +124,32 @@
|
|
|
119
124
|
"@types/update-notifier": "^6.0.8",
|
|
120
125
|
"@types/which": "^3.0.4",
|
|
121
126
|
"@types/yargs-parser": "^21.0.3",
|
|
122
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
123
|
-
"@typescript-eslint/parser": "^8.
|
|
127
|
+
"@typescript-eslint/eslint-plugin": "^8.22.0",
|
|
128
|
+
"@typescript-eslint/parser": "^8.22.0",
|
|
124
129
|
"c8": "^10.1.3",
|
|
125
130
|
"custompatch": "^1.1.4",
|
|
126
|
-
"
|
|
127
|
-
"eslint
|
|
131
|
+
"del-cli": "^6.0.0",
|
|
132
|
+
"eslint": "^9.19.0",
|
|
133
|
+
"eslint-import-resolver-oxc": "^0.10.1",
|
|
128
134
|
"eslint-plugin-depend": "^0.12.0",
|
|
129
135
|
"eslint-plugin-import-x": "^4.6.1",
|
|
130
136
|
"eslint-plugin-n": "^17.15.1",
|
|
131
137
|
"eslint-plugin-sort-destructure-keys": "^2.0.0",
|
|
132
138
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
133
139
|
"husky": "^9.1.7",
|
|
134
|
-
"knip": "^5.
|
|
140
|
+
"knip": "^5.43.6",
|
|
135
141
|
"magic-string": "^0.30.17",
|
|
136
142
|
"mock-fs": "^5.4.1",
|
|
137
|
-
"nock": "^
|
|
143
|
+
"nock": "^14.0.0",
|
|
138
144
|
"npm-run-all2": "^7.0.2",
|
|
139
|
-
"oxlint": "0.15.
|
|
145
|
+
"oxlint": "0.15.8",
|
|
140
146
|
"prettier": "3.4.2",
|
|
141
147
|
"read-package-up": "^11.0.0",
|
|
142
|
-
"rollup": "4.
|
|
148
|
+
"rollup": "4.32.1",
|
|
143
149
|
"rollup-plugin-ts": "^3.4.5",
|
|
144
150
|
"type-coverage": "^2.29.7",
|
|
145
151
|
"typescript": "5.4.5",
|
|
146
|
-
"typescript-eslint": "^8.
|
|
152
|
+
"typescript-eslint": "^8.22.0",
|
|
147
153
|
"unplugin-purge-polyfills": "^0.0.7"
|
|
148
154
|
},
|
|
149
155
|
"overrides": {
|