@socketsecurity/cli 0.7.2 → 0.8.2
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/README.md +2 -2
- package/lib/commands/info/index.js +3 -3
- package/lib/commands/login/index.js +121 -17
- package/lib/commands/logout/index.js +3 -0
- package/lib/commands/report/create.js +17 -16
- package/lib/commands/report/view.js +20 -5
- package/lib/flags/output.js +2 -2
- package/lib/shadow/link.cjs +12 -12
- package/lib/shadow/npm-injection.cjs +226 -255
- package/lib/shadow/tty-server.cjs +222 -0
- package/lib/utils/api-helpers.js +1 -3
- package/lib/utils/issue-rules.cjs +180 -0
- package/lib/utils/misc.js +1 -1
- package/lib/utils/path-resolve.js +59 -48
- package/lib/utils/sdk.js +55 -11
- package/lib/utils/settings.js +17 -5
- package/lib/utils/{type-helpers.js → type-helpers.cjs} +1 -1
- package/lib/utils/update-notifier.js +3 -0
- package/package.json +11 -15
package/lib/utils/settings.js
CHANGED
|
@@ -19,7 +19,11 @@ if (!dataHome) {
|
|
|
19
19
|
|
|
20
20
|
const settingsPath = path.join(dataHome, 'socket', 'settings')
|
|
21
21
|
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Record<string, boolean | {action: 'error' | 'warn' | 'ignore' | 'defer'}>} IssueRules
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** @type {{apiKey?: string | null, enforcedOrgs?: string[] | null, apiBaseUrl?: string | null, apiProxy?: string | null}} */
|
|
23
27
|
let settings = {}
|
|
24
28
|
|
|
25
29
|
if (fs.existsSync(settingsPath)) {
|
|
@@ -42,6 +46,8 @@ export function getSetting (key) {
|
|
|
42
46
|
return settings[key]
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
let pendingSave = false
|
|
50
|
+
|
|
45
51
|
/**
|
|
46
52
|
* @template {keyof typeof settings} Key
|
|
47
53
|
* @param {Key} key
|
|
@@ -50,8 +56,14 @@ export function getSetting (key) {
|
|
|
50
56
|
*/
|
|
51
57
|
export function updateSetting (key, value) {
|
|
52
58
|
settings[key] = value
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
if (!pendingSave) {
|
|
60
|
+
pendingSave = true
|
|
61
|
+
process.nextTick(() => {
|
|
62
|
+
pendingSave = false
|
|
63
|
+
fs.writeFileSync(
|
|
64
|
+
settingsPath,
|
|
65
|
+
Buffer.from(JSON.stringify(settings)).toString('base64')
|
|
66
|
+
)
|
|
67
|
+
})
|
|
68
|
+
}
|
|
57
69
|
}
|
|
@@ -6,6 +6,9 @@ import updateNotifier from 'update-notifier'
|
|
|
6
6
|
export function initUpdateNotifier () {
|
|
7
7
|
readFile(new URL('../../package.json', import.meta.url), 'utf8')
|
|
8
8
|
.then(rawPkg => {
|
|
9
|
+
/**
|
|
10
|
+
* @type {Exclude<Parameters<typeof updateNotifier>[0], undefined>['pkg']}
|
|
11
|
+
*/
|
|
9
12
|
const pkg = JSON.parse(rawPkg)
|
|
10
13
|
updateNotifier({ pkg }).notify()
|
|
11
14
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "CLI tool for Socket.dev",
|
|
5
5
|
"homepage": "http://github.com/SocketDev/socket-cli-js",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"engines": {
|
|
18
|
-
"node": "^
|
|
18
|
+
"node": "^16.13.0 || >=18.0.0"
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
21
21
|
"bin": {
|
|
@@ -31,36 +31,34 @@
|
|
|
31
31
|
"lib/shadow/**"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"check:dependency-check": "dependency-check '*.js' 'lib/shadow/*.cjs' '*.mjs' 'test/**/*.js' --no-dev",
|
|
34
|
+
"check:dependency-check": "dependency-check '*.js' 'lib/shadow/*.cjs' '*.mjs' 'test/**/*.js' --no-dev --ignore-module node:test --ignore-module node:assert/strict",
|
|
35
35
|
"check:installed-check": "installed-check -i eslint-plugin-jsdoc",
|
|
36
36
|
"check:lint": "eslint --report-unused-disable-directives .",
|
|
37
37
|
"check:tsc": "tsc",
|
|
38
38
|
"check:type-coverage": "type-coverage --detail --strict --at-least 95 --ignore-files 'test/*'",
|
|
39
39
|
"check": "run-p -c --aggregate-output check:*",
|
|
40
40
|
"prepare": "husky install",
|
|
41
|
-
"test:
|
|
41
|
+
"test:unit": "c8 --reporter=lcov --reporter text node --test",
|
|
42
42
|
"test-ci": "run-s test:*",
|
|
43
43
|
"test": "run-s check test:*"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@socketsecurity/eslint-config": "^3.0.1",
|
|
47
|
-
"@tsconfig/node14": "^1.0
|
|
47
|
+
"@tsconfig/node14": "^14.1.0",
|
|
48
48
|
"@types/chai": "^4.3.3",
|
|
49
49
|
"@types/chai-as-promised": "^7.1.5",
|
|
50
50
|
"@types/micromatch": "^4.0.2",
|
|
51
51
|
"@types/mocha": "^10.0.1",
|
|
52
52
|
"@types/mock-fs": "^4.13.1",
|
|
53
|
-
"@types/node": "^
|
|
53
|
+
"@types/node": "^20.4.2",
|
|
54
54
|
"@types/npm": "^7.19.0",
|
|
55
55
|
"@types/npmcli__arborist": "^5.6.1",
|
|
56
56
|
"@types/prompts": "^2.4.1",
|
|
57
57
|
"@types/update-notifier": "^6.0.2",
|
|
58
|
-
"@types/which": "^
|
|
58
|
+
"@types/which": "^3.0.0",
|
|
59
59
|
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
60
60
|
"@typescript-eslint/parser": "^5.51.0",
|
|
61
|
-
"c8": "^
|
|
62
|
-
"chai": "^4.3.6",
|
|
63
|
-
"chai-as-promised": "^7.1.1",
|
|
61
|
+
"c8": "^8.0.0",
|
|
64
62
|
"dependency-check": "^5.0.0-7",
|
|
65
63
|
"eslint": "^8.34.0",
|
|
66
64
|
"eslint-config-standard": "^17.0.0",
|
|
@@ -75,17 +73,16 @@
|
|
|
75
73
|
"eslint-plugin-unicorn": "^45.0.2",
|
|
76
74
|
"husky": "^8.0.1",
|
|
77
75
|
"installed-check": "^6.0.5",
|
|
78
|
-
"mocha": "^10.0.0",
|
|
79
76
|
"mock-fs": "^5.2.0",
|
|
80
77
|
"nock": "^13.3.0",
|
|
81
78
|
"npm-run-all2": "^6.0.2",
|
|
82
79
|
"type-coverage": "^2.24.1",
|
|
83
|
-
"typescript": "~
|
|
80
|
+
"typescript": "~5.1.6"
|
|
84
81
|
},
|
|
85
82
|
"dependencies": {
|
|
86
83
|
"@apideck/better-ajv-errors": "^0.3.6",
|
|
87
84
|
"@socketsecurity/config": "^2.0.0",
|
|
88
|
-
"@socketsecurity/sdk": "^0.
|
|
85
|
+
"@socketsecurity/sdk": "^0.7.2",
|
|
89
86
|
"chalk": "^5.1.2",
|
|
90
87
|
"globby": "^13.1.3",
|
|
91
88
|
"hpagent": "^1.2.0",
|
|
@@ -93,8 +90,7 @@
|
|
|
93
90
|
"ignore-by-default": "^2.1.0",
|
|
94
91
|
"is-interactive": "^2.0.0",
|
|
95
92
|
"is-unicode-supported": "^1.3.0",
|
|
96
|
-
"meow": "^
|
|
97
|
-
"micromatch": "^4.0.5",
|
|
93
|
+
"meow": "^12.0.1",
|
|
98
94
|
"ora": "^6.1.2",
|
|
99
95
|
"pony-cause": "^2.1.8",
|
|
100
96
|
"prompts": "^2.4.2",
|