@socketsecurity/cli 0.14.27 → 0.14.29
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 +9 -0
- package/bin/npm-cli.js +9 -0
- package/bin/npx-cli.js +9 -0
- package/bin/shadow/module-sync/npm +3 -0
- package/bin/shadow/module-sync/npx +3 -0
- package/bin/shadow/require/npm +3 -0
- package/bin/shadow/require/npx +3 -0
- package/dist/module-sync/cli.d.ts.map +1 -0
- package/dist/module-sync/cli.js +5256 -0
- package/dist/module-sync/constants.d.ts +15 -0
- package/dist/module-sync/constants.js +62 -0
- package/dist/module-sync/npm-cli.js +85 -0
- package/dist/{npm-injection.js → module-sync/npm-injection.js} +78 -92
- package/dist/module-sync/npx-cli.js +61 -0
- package/dist/{sdk.d.ts → module-sync/sdk.d.ts} +1 -5
- package/dist/module-sync/sdk.js +253 -0
- package/dist/require/cli.d.ts +3 -0
- package/dist/require/cli.d.ts.map +1 -0
- package/dist/{cli.js → require/cli.js} +72 -76
- package/dist/require/color-or-markdown.d.ts +23 -0
- package/dist/require/constants.d.ts +15 -0
- package/dist/require/constants.js +57 -0
- package/dist/require/errors.d.ts +7 -0
- package/dist/require/link.d.ts +2 -0
- package/dist/require/link.js +45 -0
- package/dist/require/npm-cli.d.ts +2 -0
- package/dist/{npm-cli.js → require/npm-cli.js} +12 -10
- package/dist/require/npm-injection.d.ts +1 -0
- package/dist/require/npm-injection.js +1830 -0
- package/dist/require/npx-cli.d.ts +2 -0
- package/dist/{npx-cli.js → require/npx-cli.js} +12 -12
- package/dist/require/path-resolve.d.ts +8 -0
- package/dist/require/path-resolve.js +183 -0
- package/dist/require/sdk.d.ts +9 -0
- package/dist/{sdk.js → require/sdk.js} +16 -36
- package/dist/require/settings.d.ts +9 -0
- package/dist/{vendor.js → require/vendor.js} +126 -13
- package/package.json +68 -36
- package/bin/npm +0 -2
- package/bin/npx +0 -2
- package/dist/cli.d.ts.map +0 -1
- /package/dist/{cli.d.ts → module-sync/cli.d.ts} +0 -0
- /package/dist/{color-or-markdown.d.ts → module-sync/color-or-markdown.d.ts} +0 -0
- /package/dist/{errors.d.ts → module-sync/errors.d.ts} +0 -0
- /package/dist/{link.d.ts → module-sync/link.d.ts} +0 -0
- /package/dist/{link.js → module-sync/link.js} +0 -0
- /package/dist/{npm-cli.d.ts → module-sync/npm-cli.d.ts} +0 -0
- /package/dist/{npm-injection.d.ts → module-sync/npm-injection.d.ts} +0 -0
- /package/dist/{npx-cli.d.ts → module-sync/npx-cli.d.ts} +0 -0
- /package/dist/{path-resolve.d.ts → module-sync/path-resolve.d.ts} +0 -0
- /package/dist/{path-resolve.js → module-sync/path-resolve.js} +0 -0
- /package/dist/{settings.d.ts → module-sync/settings.d.ts} +0 -0
|
@@ -2,25 +2,23 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var vendor = require('./vendor.js');
|
|
5
|
-
var require$$0 = require('node:fs');
|
|
6
5
|
var require$$1 = require('node:path');
|
|
7
6
|
var require$$1$1 = require('@npmcli/promise-spawn');
|
|
7
|
+
var constants = require('./constants.js');
|
|
8
8
|
var link = require('./link.js');
|
|
9
9
|
|
|
10
|
-
var npxCli$
|
|
10
|
+
var npxCli$2 = {};
|
|
11
11
|
|
|
12
|
-
var npxCli = {};
|
|
12
|
+
var npxCli$1 = {};
|
|
13
13
|
|
|
14
|
-
var _nodeFs = require$$0;
|
|
15
14
|
var _nodePath = require$$1;
|
|
16
15
|
var _promiseSpawn = require$$1$1;
|
|
16
|
+
var _constants = constants.constants;
|
|
17
17
|
var _link = link.link;
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const npxPath = (0, _link.installLinks)(_nodePath.join(realDirname, 'bin'), 'npx');
|
|
21
|
-
const injectionPath = _nodePath.join(realDirname, 'npm-injection.js');
|
|
18
|
+
const npxPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npx');
|
|
19
|
+
const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
|
|
22
20
|
process.exitCode = 1;
|
|
23
|
-
const spawnPromise = _promiseSpawn(process.execPath, ['--require', injectionPath, npxPath, ...process.argv.slice(2)], {
|
|
21
|
+
const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npxPath, ...process.argv.slice(2)], {
|
|
24
22
|
stdio: 'inherit'
|
|
25
23
|
});
|
|
26
24
|
spawnPromise.process.on('exit', (code, signal) => {
|
|
@@ -44,7 +42,7 @@ spawnPromise.process.on('exit', (code, signal) => {
|
|
|
44
42
|
return _npxCli.default;
|
|
45
43
|
}
|
|
46
44
|
});
|
|
47
|
-
var _npxCli = _interopRequireWildcard(npxCli, true);
|
|
45
|
+
var _npxCli = _interopRequireWildcard(npxCli$1, true);
|
|
48
46
|
Object.keys(_npxCli).forEach(function (key) {
|
|
49
47
|
if (key === "default" || key === "__esModule") return;
|
|
50
48
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -56,6 +54,8 @@ spawnPromise.process.on('exit', (code, signal) => {
|
|
|
56
54
|
}
|
|
57
55
|
});
|
|
58
56
|
});
|
|
59
|
-
} (npxCli$
|
|
57
|
+
} (npxCli$2));
|
|
58
|
+
|
|
59
|
+
var npxCli = /*@__PURE__*/vendor.getDefaultExportFromCjs(npxCli$2);
|
|
60
60
|
|
|
61
|
-
module.exports = npxCli
|
|
61
|
+
module.exports = npxCli;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SocketYml } from '@socketsecurity/config';
|
|
3
|
+
import { SocketSdkReturnType } from '@socketsecurity/sdk';
|
|
4
|
+
declare function directoryPatterns(): string[];
|
|
5
|
+
declare function findRoot(filepath: string): string | undefined;
|
|
6
|
+
declare function getPackageFiles(cwd: string, inputPaths: string[], config: SocketYml | undefined, supportedFiles: SocketSdkReturnType<'getReportSupportedFiles'>['data'], debugLog?: typeof console.error): Promise<string[]>;
|
|
7
|
+
declare function getPackageFilesFullScans(cwd: string, inputPaths: string[], supportedFiles: SocketSdkReturnType<'getReportSupportedFiles'>['data'], debugLog?: typeof console.error): Promise<string[]>;
|
|
8
|
+
export { directoryPatterns, findRoot, getPackageFiles, getPackageFilesFullScans };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var require$$1$1 = require('node:fs/promises');
|
|
4
|
+
var require$$1 = require('node:path');
|
|
5
|
+
var require$$2 = require('ignore');
|
|
6
|
+
var require$$3 = require('micromatch');
|
|
7
|
+
var require$$8 = require('tinyglobby');
|
|
8
|
+
|
|
9
|
+
var pathResolve = {};
|
|
10
|
+
|
|
11
|
+
var ignoreByDefault = {};
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(ignoreByDefault, "__esModule", {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
ignoreByDefault.directoryPatterns = directoryPatterns;
|
|
17
|
+
const ignoredDirs = [
|
|
18
|
+
// Taken from ignore-by-default:
|
|
19
|
+
// https://github.com/novemberborn/ignore-by-default/blob/v2.1.0/index.js
|
|
20
|
+
'.git',
|
|
21
|
+
// Git repository files, see <https://git-scm.com/>
|
|
22
|
+
'.log',
|
|
23
|
+
// Log files emitted by tools such as `tsserver`, see <https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29>
|
|
24
|
+
'.nyc_output',
|
|
25
|
+
// Temporary directory where nyc stores coverage data, see <https://github.com/bcoe/nyc>
|
|
26
|
+
'.sass-cache',
|
|
27
|
+
// Cache folder for node-sass, see <https://github.com/sass/node-sass>
|
|
28
|
+
'.yarn',
|
|
29
|
+
// Where node modules are installed when using Yarn, see <https://yarnpkg.com/>
|
|
30
|
+
'bower_components',
|
|
31
|
+
// Where Bower packages are installed, see <http://bower.io/>
|
|
32
|
+
'coverage',
|
|
33
|
+
// Standard output directory for code coverage reports, see <https://github.com/gotwarlost/istanbul>
|
|
34
|
+
'node_modules',
|
|
35
|
+
// Where Node modules are installed, see <https://nodejs.org/>
|
|
36
|
+
// Taken from globby:
|
|
37
|
+
// https://github.com/sindresorhus/globby/blob/v14.0.2/ignore.js#L11-L16
|
|
38
|
+
'flow-typed'];
|
|
39
|
+
const ignoredDirPatterns = ignoredDirs.map(i => `**/${i}`);
|
|
40
|
+
function directoryPatterns() {
|
|
41
|
+
return [...ignoredDirPatterns];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Object.defineProperty(pathResolve, "__esModule", {
|
|
45
|
+
value: true
|
|
46
|
+
});
|
|
47
|
+
pathResolve.findRoot = findRoot;
|
|
48
|
+
pathResolve.getPackageFiles = getPackageFiles;
|
|
49
|
+
pathResolve.getPackageFilesFullScans = getPackageFilesFullScans;
|
|
50
|
+
var _promises = require$$1$1;
|
|
51
|
+
var _nodePath = require$$1;
|
|
52
|
+
var _ignore = require$$2;
|
|
53
|
+
var _micromatch = require$$3;
|
|
54
|
+
var _tinyglobby = require$$8;
|
|
55
|
+
var _ignoreByDefault = ignoreByDefault;
|
|
56
|
+
async function filterGlobResultToSupportedFiles(entries, supportedFiles) {
|
|
57
|
+
const patterns = ['golang', 'npm', 'pypi'].reduce((r, n) => {
|
|
58
|
+
const supported = supportedFiles[n];
|
|
59
|
+
r.push(...(supported ? Object.values(supported).map(p => `**/${p.pattern}`) : []));
|
|
60
|
+
return r;
|
|
61
|
+
}, []);
|
|
62
|
+
return entries.filter(p => _micromatch.some(p, patterns));
|
|
63
|
+
}
|
|
64
|
+
async function globWithGitIgnore(patterns, options) {
|
|
65
|
+
const {
|
|
66
|
+
cwd = process.cwd(),
|
|
67
|
+
socketConfig,
|
|
68
|
+
...additionalOptions
|
|
69
|
+
} = {
|
|
70
|
+
__proto__: null,
|
|
71
|
+
...options
|
|
72
|
+
};
|
|
73
|
+
const projectIgnorePaths = socketConfig?.projectIgnorePaths;
|
|
74
|
+
const ignoreFiles = await (0, _tinyglobby.glob)(['**/.gitignore'], {
|
|
75
|
+
absolute: true,
|
|
76
|
+
cwd,
|
|
77
|
+
expandDirectories: true
|
|
78
|
+
});
|
|
79
|
+
const ignores = [...(0, _ignoreByDefault.directoryPatterns)(), ...(Array.isArray(projectIgnorePaths) ? ignoreFileLinesToGlobPatterns(projectIgnorePaths, _nodePath.join(cwd, '.gitignore'), cwd) : []), ...(await Promise.all(ignoreFiles.map(async filepath => ignoreFileToGlobPatterns(await _promises.readFile(filepath, 'utf8'), filepath, cwd)))).flat()];
|
|
80
|
+
const hasNegatedPattern = ignores.some(p => p.charCodeAt(0) === 33 /*'!'*/);
|
|
81
|
+
const globOptions = {
|
|
82
|
+
absolute: true,
|
|
83
|
+
cwd,
|
|
84
|
+
expandDirectories: false,
|
|
85
|
+
ignore: hasNegatedPattern ? [] : ignores,
|
|
86
|
+
...additionalOptions
|
|
87
|
+
};
|
|
88
|
+
const result = await (0, _tinyglobby.glob)(patterns, globOptions);
|
|
89
|
+
if (!hasNegatedPattern) {
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
const {
|
|
93
|
+
absolute
|
|
94
|
+
} = globOptions;
|
|
95
|
+
const filtered = _ignore().add(ignores).filter(absolute ? result.map(p => _nodePath.relative(cwd, p)) : result);
|
|
96
|
+
return absolute ? filtered.map(p => _nodePath.resolve(cwd, p)) : filtered;
|
|
97
|
+
}
|
|
98
|
+
function ignoreFileLinesToGlobPatterns(lines, filepath, cwd) {
|
|
99
|
+
const base = _nodePath.relative(cwd, _nodePath.dirname(filepath)).replace(/\\/g, '/');
|
|
100
|
+
const patterns = [];
|
|
101
|
+
for (let i = 0, {
|
|
102
|
+
length
|
|
103
|
+
} = lines; i < length; i += 1) {
|
|
104
|
+
const pattern = lines[i].trim();
|
|
105
|
+
if (pattern.length > 0 && pattern.charCodeAt(0) !== 35 /*'#'*/) {
|
|
106
|
+
patterns.push(ignorePatternToMinimatch(pattern.length && pattern.charCodeAt(0) === 33 /*'!'*/ ? `!${_nodePath.posix.join(base, pattern.slice(1))}` : _nodePath.posix.join(base, pattern)));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return patterns;
|
|
110
|
+
}
|
|
111
|
+
function ignoreFileToGlobPatterns(content, filepath, cwd) {
|
|
112
|
+
return ignoreFileLinesToGlobPatterns(content.split(/\r?\n/), filepath, cwd);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Based on `@eslint/compat` convertIgnorePatternToMinimatch.
|
|
116
|
+
// Apache v2.0 licensed
|
|
117
|
+
// Copyright Nicholas C. Zakas
|
|
118
|
+
// https://github.com/eslint/rewrite/blob/compat-v1.2.1/packages/compat/src/ignore-file.js#L28
|
|
119
|
+
function ignorePatternToMinimatch(pattern) {
|
|
120
|
+
const isNegated = pattern.startsWith('!');
|
|
121
|
+
const negatedPrefix = isNegated ? '!' : '';
|
|
122
|
+
const patternToTest = (isNegated ? pattern.slice(1) : pattern).trimEnd();
|
|
123
|
+
// Special cases.
|
|
124
|
+
if (patternToTest === '' || patternToTest === '**' || patternToTest === '/**' || patternToTest === '**') {
|
|
125
|
+
return `${negatedPrefix}${patternToTest}`;
|
|
126
|
+
}
|
|
127
|
+
const firstIndexOfSlash = patternToTest.indexOf('/');
|
|
128
|
+
const matchEverywherePrefix = firstIndexOfSlash === -1 || firstIndexOfSlash === patternToTest.length - 1 ? '**/' : '';
|
|
129
|
+
const patternWithoutLeadingSlash = firstIndexOfSlash === 0 ? patternToTest.slice(1) : patternToTest;
|
|
130
|
+
// Escape `{` and `(` because in gitignore patterns they are just
|
|
131
|
+
// literal characters without any specific syntactic meaning,
|
|
132
|
+
// while in minimatch patterns they can form brace expansion or extglob syntax.
|
|
133
|
+
//
|
|
134
|
+
// For example, gitignore pattern `src/{a,b}.js` ignores file `src/{a,b}.js`.
|
|
135
|
+
// But, the same minimatch pattern `src/{a,b}.js` ignores files `src/a.js` and `src/b.js`.
|
|
136
|
+
// Minimatch pattern `src/\{a,b}.js` is equivalent to gitignore pattern `src/{a,b}.js`.
|
|
137
|
+
const escapedPatternWithoutLeadingSlash = patternWithoutLeadingSlash.replaceAll(/(?=((?:\\.|[^{(])*))\1([{(])/guy, '$1\\$2');
|
|
138
|
+
const matchInsideSuffix = patternToTest.endsWith('/**') ? '/*' : '';
|
|
139
|
+
return `${negatedPrefix}${matchEverywherePrefix}${escapedPatternWithoutLeadingSlash}${matchInsideSuffix}`;
|
|
140
|
+
}
|
|
141
|
+
function pathsToPatterns(paths) {
|
|
142
|
+
return paths.map(p => p === '.' ? '**/*' : p);
|
|
143
|
+
}
|
|
144
|
+
function findRoot(filepath) {
|
|
145
|
+
let curPath = filepath;
|
|
146
|
+
while (true) {
|
|
147
|
+
if (_nodePath.basename(curPath) === 'npm') {
|
|
148
|
+
return curPath;
|
|
149
|
+
}
|
|
150
|
+
const parent = _nodePath.dirname(curPath);
|
|
151
|
+
if (parent === curPath) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
curPath = parent;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function getPackageFiles(cwd, inputPaths, config, supportedFiles, debugLog = () => {}) {
|
|
158
|
+
debugLog(`Globbed resolving ${inputPaths.length} paths:`, inputPaths);
|
|
159
|
+
|
|
160
|
+
// TODO: Does not support `~/` paths
|
|
161
|
+
const entries = await globWithGitIgnore(pathsToPatterns(inputPaths), {
|
|
162
|
+
cwd,
|
|
163
|
+
socketConfig: config
|
|
164
|
+
});
|
|
165
|
+
debugLog(`Globbed resolved ${inputPaths.length} paths to ${entries.length} paths:`, entries);
|
|
166
|
+
const packageFiles = await filterGlobResultToSupportedFiles(entries, supportedFiles);
|
|
167
|
+
debugLog(`Mapped ${entries.length} entries to ${packageFiles.length} files:`, packageFiles);
|
|
168
|
+
return packageFiles;
|
|
169
|
+
}
|
|
170
|
+
async function getPackageFilesFullScans(cwd, inputPaths, supportedFiles, debugLog = () => {}) {
|
|
171
|
+
debugLog(`Globbed resolving ${inputPaths.length} paths:`, inputPaths);
|
|
172
|
+
|
|
173
|
+
// TODO: Does not support `~/` paths
|
|
174
|
+
const entries = await globWithGitIgnore(pathsToPatterns(inputPaths), {
|
|
175
|
+
cwd
|
|
176
|
+
});
|
|
177
|
+
debugLog(`Globbed resolved ${inputPaths.length} paths to ${entries.length} paths:`, entries);
|
|
178
|
+
const packageFiles = await filterGlobResultToSupportedFiles(entries, supportedFiles);
|
|
179
|
+
debugLog(`Mapped ${entries.length} entries to ${packageFiles.length} files:`, packageFiles);
|
|
180
|
+
return packageFiles;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
exports.pathResolve = pathResolve;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SocketSdk } from '@socketsecurity/sdk';
|
|
3
|
+
declare function createDebugLogger(printDebugLogs?: boolean): typeof console.error;
|
|
4
|
+
declare function isErrnoException(value: unknown): value is NodeJS.ErrnoException;
|
|
5
|
+
declare function stringJoinWithSeparateFinalSeparator(list: (string | undefined)[], separator?: string): string;
|
|
6
|
+
declare const FREE_API_KEY = "sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api";
|
|
7
|
+
declare function getDefaultKey(): string | undefined;
|
|
8
|
+
declare function setupSdk(apiKey?: string | undefined, apiBaseUrl?: string | undefined, proxy?: string | undefined): Promise<SocketSdk>;
|
|
9
|
+
export { createDebugLogger, isErrnoException, stringJoinWithSeparateFinalSeparator, FREE_API_KEY, getDefaultKey, setupSdk };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var require$$0 = require('@socketsecurity/registry/lib/env');
|
|
4
3
|
var vendor = require('./vendor.js');
|
|
5
4
|
var require$$1 = require('yoctocolors-cjs');
|
|
6
|
-
var require$$1$3 = require('
|
|
7
|
-
var require$$
|
|
8
|
-
var require$$
|
|
9
|
-
var
|
|
10
|
-
var require$$
|
|
11
|
-
var require$$0$1 = require('node:fs');
|
|
5
|
+
var require$$1$3 = require('@inquirer/prompts');
|
|
6
|
+
var require$$2 = require('hpagent');
|
|
7
|
+
var require$$4 = require('@socketsecurity/sdk');
|
|
8
|
+
var constants = require('./constants.js');
|
|
9
|
+
var require$$0 = require('node:fs');
|
|
12
10
|
var require$$1$1 = require('node:os');
|
|
11
|
+
var require$$1$2 = require('node:path');
|
|
13
12
|
var require$$3 = require('@socketregistry/yocto-spinner');
|
|
14
13
|
|
|
15
14
|
var errors = {};
|
|
@@ -28,19 +27,6 @@ class InputError extends Error {
|
|
|
28
27
|
}
|
|
29
28
|
errors.InputError = InputError;
|
|
30
29
|
|
|
31
|
-
var constants = {};
|
|
32
|
-
|
|
33
|
-
Object.defineProperty(constants, "__esModule", {
|
|
34
|
-
value: true
|
|
35
|
-
});
|
|
36
|
-
constants.ENV = constants.API_V0_URL = void 0;
|
|
37
|
-
var _env = require$$0;
|
|
38
|
-
constants.API_V0_URL = 'https://api.socket.dev/v0';
|
|
39
|
-
constants.ENV = Object.freeze({
|
|
40
|
-
// Flag set by the optimize command to bypass the packagesHaveRiskyIssues check.
|
|
41
|
-
UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: (0, _env.envAsBoolean)(process.env['UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE'])
|
|
42
|
-
});
|
|
43
|
-
|
|
44
30
|
var colorOrMarkdown = {};
|
|
45
31
|
|
|
46
32
|
var _interopRequireDefault$1 = vendor.interopRequireDefault.default;
|
|
@@ -153,17 +139,17 @@ Object.defineProperty(settings$1, "__esModule", {
|
|
|
153
139
|
});
|
|
154
140
|
settings$1.getSetting = getSetting;
|
|
155
141
|
settings$1.updateSetting = updateSetting;
|
|
156
|
-
var _nodeFs = require$$0
|
|
142
|
+
var _nodeFs = require$$0;
|
|
157
143
|
var _nodeOs = require$$1$1;
|
|
158
|
-
var _nodePath
|
|
144
|
+
var _nodePath = require$$1$2;
|
|
159
145
|
var _yoctoSpinner = require$$3;
|
|
160
146
|
let dataHome = process.platform === 'win32' ? process.env['LOCALAPPDATA'] : process.env['XDG_DATA_HOME'];
|
|
161
147
|
if (!dataHome) {
|
|
162
148
|
if (process.platform === 'win32') throw new Error('missing %LOCALAPPDATA%');
|
|
163
149
|
const home = _nodeOs.homedir();
|
|
164
|
-
dataHome = _nodePath
|
|
150
|
+
dataHome = _nodePath.join(home, ...(process.platform === 'darwin' ? ['Library', 'Application Support'] : ['.local', 'share']));
|
|
165
151
|
}
|
|
166
|
-
const settingsPath = _nodePath
|
|
152
|
+
const settingsPath = _nodePath.join(dataHome, 'socket', 'settings');
|
|
167
153
|
let settings = {};
|
|
168
154
|
if ((0, _nodeFs.existsSync)(settingsPath)) {
|
|
169
155
|
const raw = (0, _nodeFs.readFileSync)(settingsPath, 'utf-8');
|
|
@@ -173,7 +159,7 @@ if ((0, _nodeFs.existsSync)(settingsPath)) {
|
|
|
173
159
|
_yoctoSpinner().warning(`Failed to parse settings at ${settingsPath}`);
|
|
174
160
|
}
|
|
175
161
|
} else {
|
|
176
|
-
(0, _nodeFs.mkdirSync)(_nodePath
|
|
162
|
+
(0, _nodeFs.mkdirSync)(_nodePath.dirname(settingsPath), {
|
|
177
163
|
recursive: true
|
|
178
164
|
});
|
|
179
165
|
}
|
|
@@ -199,16 +185,13 @@ Object.defineProperty(sdk, "__esModule", {
|
|
|
199
185
|
sdk.FREE_API_KEY = void 0;
|
|
200
186
|
sdk.getDefaultKey = getDefaultKey;
|
|
201
187
|
sdk.setupSdk = setupSdk;
|
|
202
|
-
var
|
|
203
|
-
var
|
|
204
|
-
var _prompts = require$$1$4;
|
|
205
|
-
var _hpagent = require$$4;
|
|
188
|
+
var _prompts = require$$1$3;
|
|
189
|
+
var _hpagent = require$$2;
|
|
206
190
|
var _isInteractive = _interopRequireDefault(vendor.isInteractive);
|
|
207
|
-
var _sdk = require$$
|
|
191
|
+
var _sdk = require$$4;
|
|
192
|
+
var _constants = constants.constants;
|
|
208
193
|
var _errors = errors;
|
|
209
194
|
var _settings = settings$1;
|
|
210
|
-
const distPath = __dirname;
|
|
211
|
-
const rootPath = _nodePath.resolve(distPath, '..');
|
|
212
195
|
sdk.FREE_API_KEY = 'sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api';
|
|
213
196
|
|
|
214
197
|
// This API key should be stored globally for the duration of the CLI execution
|
|
@@ -252,18 +235,15 @@ async function setupSdk(apiKey = getDefaultKey(), apiBaseUrl = getDefaultAPIBase
|
|
|
252
235
|
})
|
|
253
236
|
};
|
|
254
237
|
}
|
|
255
|
-
const packageJsonPath = _nodePath.join(rootPath, 'package.json');
|
|
256
|
-
const packageJson = await _promises.readFile(packageJsonPath, 'utf8');
|
|
257
238
|
const sdkOptions = {
|
|
258
239
|
agent,
|
|
259
240
|
baseUrl: apiBaseUrl,
|
|
260
|
-
userAgent: (0, _sdk.createUserAgentFromPkgJson)(
|
|
241
|
+
userAgent: (0, _sdk.createUserAgentFromPkgJson)(require(_constants.rootPkgJsonPath))
|
|
261
242
|
};
|
|
262
243
|
return new _sdk.SocketSdk(apiKey || '', sdkOptions);
|
|
263
244
|
}
|
|
264
245
|
|
|
265
246
|
exports.colorOrMarkdown = colorOrMarkdown;
|
|
266
|
-
exports.constants = constants;
|
|
267
247
|
exports.errors = errors;
|
|
268
248
|
exports.misc = misc;
|
|
269
249
|
exports.sdk = sdk;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface Settings {
|
|
2
|
+
apiKey?: string | null;
|
|
3
|
+
enforcedOrgs?: string[] | null;
|
|
4
|
+
apiBaseUrl?: string | null;
|
|
5
|
+
apiProxy?: string | null;
|
|
6
|
+
}
|
|
7
|
+
declare function getSetting<Key extends keyof Settings>(key: Key): Settings[Key];
|
|
8
|
+
declare function updateSetting<Key extends keyof Settings>(key: Key, value: Settings[Key]): void;
|
|
9
|
+
export { getSetting, updateSetting };
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var require$$1$1 = require('node:path');
|
|
4
3
|
var require$$8 = require('node:url');
|
|
5
4
|
var require$$0 = require('node:fs');
|
|
6
5
|
var require$$1 = require('node:os');
|
|
6
|
+
var require$$1$1 = require('node:path');
|
|
7
7
|
var require$$0$1 = require('node:process');
|
|
8
8
|
var require$$0$2 = require('node:util');
|
|
9
|
-
var require$$
|
|
10
|
-
var require$$
|
|
9
|
+
var require$$1$2 = require('node:tty');
|
|
10
|
+
var require$$2 = require('has-flag');
|
|
11
11
|
var require$$1$3 = require('node:fs/promises');
|
|
12
|
-
var require$$2$
|
|
13
|
-
var require$$2 = require('node:child_process');
|
|
12
|
+
var require$$2$2 = require('node:buffer');
|
|
13
|
+
var require$$2$1 = require('node:child_process');
|
|
14
14
|
|
|
15
15
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
16
|
+
function getDefaultExportFromCjs (x) {
|
|
17
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
var interopRequireWildcard = {};
|
|
17
21
|
|
|
18
22
|
var _typeof$1 = {};
|
|
@@ -9131,8 +9135,116 @@ ansiEscapes.iTerm = {
|
|
|
9131
9135
|
};
|
|
9132
9136
|
ansiEscapes$1.default = ansiEscapes;
|
|
9133
9137
|
|
|
9134
|
-
const
|
|
9135
|
-
const
|
|
9138
|
+
const os = require$$1;
|
|
9139
|
+
const tty = require$$1$2;
|
|
9140
|
+
const hasFlag$2 = require$$2;
|
|
9141
|
+
const {
|
|
9142
|
+
env
|
|
9143
|
+
} = process;
|
|
9144
|
+
let forceColor;
|
|
9145
|
+
if (hasFlag$2('no-color') || hasFlag$2('no-colors') || hasFlag$2('color=false') || hasFlag$2('color=never')) {
|
|
9146
|
+
forceColor = 0;
|
|
9147
|
+
} else if (hasFlag$2('color') || hasFlag$2('colors') || hasFlag$2('color=true') || hasFlag$2('color=always')) {
|
|
9148
|
+
forceColor = 1;
|
|
9149
|
+
}
|
|
9150
|
+
if ('FORCE_COLOR' in env) {
|
|
9151
|
+
if (env.FORCE_COLOR === 'true') {
|
|
9152
|
+
forceColor = 1;
|
|
9153
|
+
} else if (env.FORCE_COLOR === 'false') {
|
|
9154
|
+
forceColor = 0;
|
|
9155
|
+
} else {
|
|
9156
|
+
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
9157
|
+
}
|
|
9158
|
+
}
|
|
9159
|
+
function translateLevel(level) {
|
|
9160
|
+
if (level === 0) {
|
|
9161
|
+
return false;
|
|
9162
|
+
}
|
|
9163
|
+
return {
|
|
9164
|
+
level,
|
|
9165
|
+
hasBasic: true,
|
|
9166
|
+
has256: level >= 2,
|
|
9167
|
+
has16m: level >= 3
|
|
9168
|
+
};
|
|
9169
|
+
}
|
|
9170
|
+
function supportsColor$1(haveStream, streamIsTTY) {
|
|
9171
|
+
if (forceColor === 0) {
|
|
9172
|
+
return 0;
|
|
9173
|
+
}
|
|
9174
|
+
if (hasFlag$2('color=16m') || hasFlag$2('color=full') || hasFlag$2('color=truecolor')) {
|
|
9175
|
+
return 3;
|
|
9176
|
+
}
|
|
9177
|
+
if (hasFlag$2('color=256')) {
|
|
9178
|
+
return 2;
|
|
9179
|
+
}
|
|
9180
|
+
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
9181
|
+
return 0;
|
|
9182
|
+
}
|
|
9183
|
+
const min = forceColor || 0;
|
|
9184
|
+
if (env.TERM === 'dumb') {
|
|
9185
|
+
return min;
|
|
9186
|
+
}
|
|
9187
|
+
if (process.platform === 'win32') {
|
|
9188
|
+
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
9189
|
+
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
9190
|
+
const osRelease = os.release().split('.');
|
|
9191
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
9192
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
9193
|
+
}
|
|
9194
|
+
return 1;
|
|
9195
|
+
}
|
|
9196
|
+
if ('CI' in env) {
|
|
9197
|
+
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
9198
|
+
return 1;
|
|
9199
|
+
}
|
|
9200
|
+
return min;
|
|
9201
|
+
}
|
|
9202
|
+
if ('TEAMCITY_VERSION' in env) {
|
|
9203
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
9204
|
+
}
|
|
9205
|
+
if (env.COLORTERM === 'truecolor') {
|
|
9206
|
+
return 3;
|
|
9207
|
+
}
|
|
9208
|
+
if ('TERM_PROGRAM' in env) {
|
|
9209
|
+
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
9210
|
+
switch (env.TERM_PROGRAM) {
|
|
9211
|
+
case 'iTerm.app':
|
|
9212
|
+
return version >= 3 ? 3 : 2;
|
|
9213
|
+
case 'Apple_Terminal':
|
|
9214
|
+
return 2;
|
|
9215
|
+
// No default
|
|
9216
|
+
}
|
|
9217
|
+
}
|
|
9218
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
9219
|
+
return 2;
|
|
9220
|
+
}
|
|
9221
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
9222
|
+
return 1;
|
|
9223
|
+
}
|
|
9224
|
+
if ('COLORTERM' in env) {
|
|
9225
|
+
return 1;
|
|
9226
|
+
}
|
|
9227
|
+
return min;
|
|
9228
|
+
}
|
|
9229
|
+
function getSupportLevel(stream) {
|
|
9230
|
+
const level = supportsColor$1(stream, stream && stream.isTTY);
|
|
9231
|
+
return translateLevel(level);
|
|
9232
|
+
}
|
|
9233
|
+
var supportsColor_1 = {
|
|
9234
|
+
supportsColor: getSupportLevel,
|
|
9235
|
+
stdout: translateLevel(supportsColor$1(true, tty.isatty(1))),
|
|
9236
|
+
stderr: translateLevel(supportsColor$1(true, tty.isatty(2)))
|
|
9237
|
+
};
|
|
9238
|
+
|
|
9239
|
+
var hasFlag$1 = (flag, argv = process.argv) => {
|
|
9240
|
+
const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
|
|
9241
|
+
const position = argv.indexOf(prefix + flag);
|
|
9242
|
+
const terminatorPosition = argv.indexOf('--');
|
|
9243
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
9244
|
+
};
|
|
9245
|
+
|
|
9246
|
+
const supportsColor = supportsColor_1;
|
|
9247
|
+
const hasFlag = hasFlag$1;
|
|
9136
9248
|
function parseVersion(versionString) {
|
|
9137
9249
|
if (/^\d{3,4}$/.test(versionString)) {
|
|
9138
9250
|
// Env var doesn't always use dots. example: 4601 => 46.1.0
|
|
@@ -9379,7 +9491,7 @@ Object.defineProperty(defaultBrowserId$1, "__esModule", {
|
|
|
9379
9491
|
defaultBrowserId$1.default = defaultBrowserId;
|
|
9380
9492
|
var _nodeUtil$3 = require$$0$2;
|
|
9381
9493
|
var _nodeProcess$3 = require$$0$1;
|
|
9382
|
-
var _nodeChild_process$4 = require$$2;
|
|
9494
|
+
var _nodeChild_process$4 = require$$2$1;
|
|
9383
9495
|
const execFileAsync$3 = (0, _nodeUtil$3.promisify)(_nodeChild_process$4.execFile);
|
|
9384
9496
|
async function defaultBrowserId() {
|
|
9385
9497
|
if (_nodeProcess$3.platform !== 'darwin') {
|
|
@@ -9405,7 +9517,7 @@ runApplescript.runAppleScript = runAppleScript;
|
|
|
9405
9517
|
runApplescript.runAppleScriptSync = runAppleScriptSync;
|
|
9406
9518
|
var _nodeProcess$2 = require$$0$1;
|
|
9407
9519
|
var _nodeUtil$2 = require$$0$2;
|
|
9408
|
-
var _nodeChild_process$3 = require$$2;
|
|
9520
|
+
var _nodeChild_process$3 = require$$2$1;
|
|
9409
9521
|
const execFileAsync$2 = (0, _nodeUtil$2.promisify)(_nodeChild_process$3.execFile);
|
|
9410
9522
|
async function runAppleScript(script, {
|
|
9411
9523
|
humanReadableOutput = true
|
|
@@ -9451,7 +9563,7 @@ Object.defineProperty(windows, "__esModule", {
|
|
|
9451
9563
|
windows.UnknownBrowserError = void 0;
|
|
9452
9564
|
windows.default = defaultBrowser$1;
|
|
9453
9565
|
var _nodeUtil$1 = require$$0$2;
|
|
9454
|
-
var _nodeChild_process$2 = require$$2;
|
|
9566
|
+
var _nodeChild_process$2 = require$$2$1;
|
|
9455
9567
|
const execFileAsync$1 = (0, _nodeUtil$1.promisify)(_nodeChild_process$2.execFile);
|
|
9456
9568
|
|
|
9457
9569
|
// Windows doesn't have browser IDs in the same way macOS/Linux does so we give fake
|
|
@@ -9522,7 +9634,7 @@ Object.defineProperty(defaultBrowser$2, "__esModule", {
|
|
|
9522
9634
|
defaultBrowser$2.default = defaultBrowser;
|
|
9523
9635
|
var _nodeUtil = require$$0$2;
|
|
9524
9636
|
var _nodeProcess$1 = require$$0$1;
|
|
9525
|
-
var _nodeChild_process$1 = require$$2;
|
|
9637
|
+
var _nodeChild_process$1 = require$$2$1;
|
|
9526
9638
|
var _defaultBrowserId = defaultBrowserId$1;
|
|
9527
9639
|
var _bundleName = bundleName$1;
|
|
9528
9640
|
var _windows = windows;
|
|
@@ -9562,10 +9674,10 @@ Object.defineProperty(open$1, "__esModule", {
|
|
|
9562
9674
|
});
|
|
9563
9675
|
open$1.openApp = open$1.default = open$1.apps = void 0;
|
|
9564
9676
|
var _nodeProcess = require$$0$1;
|
|
9565
|
-
var _nodeBuffer = require$$2$
|
|
9677
|
+
var _nodeBuffer = require$$2$2;
|
|
9566
9678
|
var _nodePath = require$$1$1;
|
|
9567
9679
|
var _nodeUrl = require$$8;
|
|
9568
|
-
var _nodeChild_process = require$$2;
|
|
9680
|
+
var _nodeChild_process = require$$2$1;
|
|
9569
9681
|
var _promises = _interopRequireWildcard(require$$1$3, true);
|
|
9570
9682
|
var _isWsl = isWsl$1;
|
|
9571
9683
|
var _defineLazyProp = defineLazyProp;
|
|
@@ -9868,6 +9980,7 @@ open$1.default = open;
|
|
|
9868
9980
|
|
|
9869
9981
|
exports.build = build;
|
|
9870
9982
|
exports.dist = dist$1;
|
|
9983
|
+
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|
|
9871
9984
|
exports.interopRequireDefault = interopRequireDefault;
|
|
9872
9985
|
exports.interopRequireWildcard = interopRequireWildcard;
|
|
9873
9986
|
exports.isInteractive = isInteractive$1;
|