@socketsecurity/lib 3.0.2 → 3.0.4
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/CHANGELOG.md +21 -1
- package/dist/abort.js +60 -1
- package/dist/abort.js.map +2 -2
- package/dist/agent.js +289 -1
- package/dist/agent.js.map +2 -2
- package/dist/ansi.js +60 -1
- package/dist/ansi.js.map +2 -2
- package/dist/argv/flags.js +282 -1
- package/dist/argv/flags.js.map +2 -2
- package/dist/argv/parse.js +171 -1
- package/dist/argv/parse.js.map +2 -2
- package/dist/arrays.js +85 -1
- package/dist/arrays.js.map +2 -2
- package/dist/bin.js +419 -5
- package/dist/bin.js.map +2 -2
- package/dist/cacache.js +139 -1
- package/dist/cacache.js.map +2 -2
- package/dist/cache-with-ttl.js +223 -1
- package/dist/cache-with-ttl.js.map +2 -2
- package/dist/constants/agents.js +126 -1
- package/dist/constants/agents.js.map +2 -2
- package/dist/constants/core.js +57 -2
- package/dist/constants/core.js.map +2 -2
- package/dist/constants/encoding.js +48 -1
- package/dist/constants/encoding.js.map +2 -2
- package/dist/constants/github.js +30 -1
- package/dist/constants/github.js.map +2 -2
- package/dist/constants/licenses.js +66 -1
- package/dist/constants/licenses.js.map +2 -2
- package/dist/constants/node.js +185 -1
- package/dist/constants/node.js.map +2 -2
- package/dist/constants/packages.js +128 -1
- package/dist/constants/packages.js.map +2 -2
- package/dist/constants/paths.js +150 -1
- package/dist/constants/paths.js.map +2 -2
- package/dist/constants/platform.js +41 -1
- package/dist/constants/platform.js.map +2 -2
- package/dist/constants/process.js +52 -1
- package/dist/constants/process.js.map +2 -2
- package/dist/constants/socket.js +102 -1
- package/dist/constants/socket.js.map +2 -2
- package/dist/constants/testing.js +36 -1
- package/dist/constants/testing.js.map +2 -2
- package/dist/constants/time.js +39 -1
- package/dist/constants/time.js.map +2 -2
- package/dist/constants/typescript.js +54 -1
- package/dist/constants/typescript.js.map +2 -2
- package/dist/cover/code.js +135 -1
- package/dist/cover/code.js.map +2 -2
- package/dist/cover/formatters.js +101 -11
- package/dist/cover/formatters.js.map +2 -2
- package/dist/cover/type.js +63 -1
- package/dist/cover/type.js.map +2 -2
- package/dist/cover/types.js +15 -1
- package/dist/cover/types.js.map +2 -2
- package/dist/debug.js +337 -2
- package/dist/debug.js.map +2 -2
- package/dist/dlx-binary.js +408 -7
- package/dist/dlx-binary.js.map +2 -2
- package/dist/dlx-package.js +278 -7
- package/dist/dlx-package.js.map +2 -2
- package/dist/dlx.js +214 -7
- package/dist/dlx.js.map +3 -3
- package/dist/effects/pulse-frames.js +64 -1
- package/dist/effects/pulse-frames.js.map +2 -2
- package/dist/effects/text-shimmer.js +174 -1
- package/dist/effects/text-shimmer.js.map +2 -2
- package/dist/effects/types.js +15 -1
- package/dist/effects/types.js.map +2 -2
- package/dist/effects/ultra.js +61 -1
- package/dist/effects/ultra.js.map +2 -2
- package/dist/env/ci.js +31 -1
- package/dist/env/ci.js.map +2 -2
- package/dist/env/debug.js +30 -1
- package/dist/env/debug.js.map +2 -2
- package/dist/env/github.js +65 -1
- package/dist/env/github.js.map +2 -2
- package/dist/env/helpers.js +47 -1
- package/dist/env/helpers.js.map +2 -2
- package/dist/env/home.js +30 -1
- package/dist/env/home.js.map +2 -2
- package/dist/env/locale.js +40 -1
- package/dist/env/locale.js.map +2 -2
- package/dist/env/node-auth-token.js +30 -1
- package/dist/env/node-auth-token.js.map +2 -2
- package/dist/env/node-env.js +30 -1
- package/dist/env/node-env.js.map +2 -2
- package/dist/env/npm.js +50 -1
- package/dist/env/npm.js.map +2 -2
- package/dist/env/package-manager.js +73 -1
- package/dist/env/package-manager.js.map +2 -2
- package/dist/env/path.js +30 -1
- package/dist/env/path.js.map +2 -2
- package/dist/env/pre-commit.js +31 -1
- package/dist/env/pre-commit.js.map +2 -2
- package/dist/env/rewire.js +72 -1
- package/dist/env/rewire.js.map +2 -2
- package/dist/env/shell.js +30 -1
- package/dist/env/shell.js.map +2 -2
- package/dist/env/socket-cli-shadow.js +51 -1
- package/dist/env/socket-cli-shadow.js.map +2 -2
- package/dist/env/socket-cli.js +86 -1
- package/dist/env/socket-cli.js.map +2 -2
- package/dist/env/socket.js +101 -1
- package/dist/env/socket.js.map +2 -2
- package/dist/env/temp-dir.js +40 -1
- package/dist/env/temp-dir.js.map +2 -2
- package/dist/env/term.js +30 -1
- package/dist/env/term.js.map +2 -2
- package/dist/env/test.js +43 -1
- package/dist/env/test.js.map +2 -2
- package/dist/env/windows.js +45 -1
- package/dist/env/windows.js.map +2 -2
- package/dist/env/xdg.js +40 -1
- package/dist/env/xdg.js.map +2 -2
- package/dist/env.js +170 -1
- package/dist/env.js.map +2 -2
- package/dist/external/@socketregistry/packageurl-js.js +12 -2
- package/dist/fs.js +670 -7
- package/dist/fs.js.map +2 -2
- package/dist/functions.js +68 -1
- package/dist/functions.js.map +2 -2
- package/dist/git.js +329 -2
- package/dist/git.js.map +2 -2
- package/dist/github.js +202 -1
- package/dist/github.js.map +2 -2
- package/dist/globs.js +149 -1
- package/dist/globs.js.map +2 -2
- package/dist/http-request.js +335 -3
- package/dist/http-request.js.map +2 -2
- package/dist/index.js +69 -1
- package/dist/index.js.map +2 -2
- package/dist/ipc.js +244 -1
- package/dist/ipc.js.map +2 -2
- package/dist/json.js +73 -1
- package/dist/json.js.map +2 -2
- package/dist/links/index.js +60 -1
- package/dist/links/index.js.map +2 -2
- package/dist/logger.js +1383 -6
- package/dist/logger.js.map +2 -2
- package/dist/maintained-node-versions.js +35 -1
- package/dist/maintained-node-versions.js.map +2 -2
- package/dist/memoization.js +210 -1
- package/dist/memoization.js.map +2 -2
- package/dist/objects.js +311 -1
- package/dist/objects.js.map +3 -3
- package/dist/packages/editable.js +356 -9
- package/dist/packages/editable.js.map +2 -2
- package/dist/packages/exports.js +162 -1
- package/dist/packages/exports.js.map +2 -2
- package/dist/packages/isolation.js +187 -1
- package/dist/packages/isolation.js.map +2 -2
- package/dist/packages/licenses.js +214 -1
- package/dist/packages/licenses.js.map +2 -2
- package/dist/packages/manifest.js +190 -1
- package/dist/packages/manifest.js.map +2 -2
- package/dist/packages/normalize.js +132 -1
- package/dist/packages/normalize.js.map +2 -2
- package/dist/packages/operations.js +320 -1
- package/dist/packages/operations.js.map +2 -2
- package/dist/packages/paths.js +53 -1
- package/dist/packages/paths.js.map +2 -2
- package/dist/packages/provenance.js +178 -1
- package/dist/packages/provenance.js.map +2 -2
- package/dist/packages/specs.js +83 -1
- package/dist/packages/specs.js.map +2 -2
- package/dist/packages/validation.js +51 -1
- package/dist/packages/validation.js.map +2 -2
- package/dist/packages.js +129 -1
- package/dist/packages.js.map +2 -2
- package/dist/path.js +446 -1
- package/dist/path.js.map +2 -2
- package/dist/paths/rewire.js +79 -1
- package/dist/paths/rewire.js.map +2 -2
- package/dist/paths.js +190 -1
- package/dist/paths.js.map +2 -2
- package/dist/performance.js +216 -15
- package/dist/performance.js.map +2 -2
- package/dist/process-lock.js +287 -8
- package/dist/process-lock.js.map +2 -2
- package/dist/promise-queue.js +109 -1
- package/dist/promise-queue.js.map +2 -2
- package/dist/promises.js +267 -1
- package/dist/promises.js.map +2 -2
- package/dist/prompts/index.js +45 -1
- package/dist/prompts/index.js.map +2 -2
- package/dist/prompts.js +58 -1
- package/dist/prompts.js.map +2 -2
- package/dist/regexps.js +30 -1
- package/dist/regexps.js.map +2 -2
- package/dist/sea.js +44 -1
- package/dist/sea.js.map +2 -2
- package/dist/shadow.js +58 -1
- package/dist/shadow.js.map +2 -2
- package/dist/signal-exit.js +248 -1
- package/dist/signal-exit.js.map +2 -2
- package/dist/sorts.js +94 -1
- package/dist/sorts.js.map +2 -2
- package/dist/spawn.js +200 -1
- package/dist/spawn.js.map +2 -2
- package/dist/spinner.js +965 -1
- package/dist/spinner.js.map +3 -3
- package/dist/ssri.js +71 -1
- package/dist/ssri.js.map +2 -2
- package/dist/stdio/clear.js +82 -1
- package/dist/stdio/clear.js.map +2 -2
- package/dist/stdio/divider.js +89 -3
- package/dist/stdio/divider.js.map +2 -2
- package/dist/stdio/footer.js +94 -2
- package/dist/stdio/footer.js.map +2 -2
- package/dist/stdio/header.js +100 -2
- package/dist/stdio/header.js.map +2 -2
- package/dist/stdio/mask.js +207 -5
- package/dist/stdio/mask.js.map +2 -2
- package/dist/stdio/progress.js +209 -2
- package/dist/stdio/progress.js.map +2 -2
- package/dist/stdio/prompts.js +88 -1
- package/dist/stdio/prompts.js.map +2 -2
- package/dist/stdio/stderr.js +89 -2
- package/dist/stdio/stderr.js.map +2 -2
- package/dist/stdio/stdout.js +103 -2
- package/dist/stdio/stdout.js.map +2 -2
- package/dist/streams.js +78 -1
- package/dist/streams.js.map +2 -2
- package/dist/strings.js +251 -3
- package/dist/strings.js.map +2 -2
- package/dist/suppress-warnings.js +98 -1
- package/dist/suppress-warnings.js.map +2 -2
- package/dist/tables.js +128 -3
- package/dist/tables.js.map +2 -2
- package/dist/temporary-executor.js +53 -1
- package/dist/temporary-executor.js.map +2 -2
- package/dist/themes/context.js +71 -1
- package/dist/themes/context.js.map +3 -3
- package/dist/themes/index.d.ts +2 -2
- package/dist/themes/index.js +57 -1
- package/dist/themes/index.js.map +3 -3
- package/dist/themes/themes.d.ts +5 -5
- package/dist/themes/themes.js +204 -1
- package/dist/themes/themes.js.map +3 -3
- package/dist/themes/types.js +15 -1
- package/dist/themes/types.js.map +2 -2
- package/dist/themes/utils.js +116 -1
- package/dist/themes/utils.js.map +2 -2
- package/dist/types.js +59 -1
- package/dist/types.js.map +2 -2
- package/dist/url.js +142 -1
- package/dist/url.js.map +2 -2
- package/dist/utils/get-ipc.js +58 -1
- package/dist/utils/get-ipc.js.map +2 -2
- package/dist/validation/json-parser.js +127 -1
- package/dist/validation/json-parser.js.map +2 -2
- package/dist/validation/types.js +15 -1
- package/dist/validation/types.js.map +2 -2
- package/dist/versions.js +154 -1
- package/dist/versions.js.map +2 -2
- package/dist/words.js +50 -1
- package/dist/words.js.map +2 -2
- package/dist/zod.js +27 -1
- package/dist/zod.js.map +2 -2
- package/package.json +2 -2
package/dist/fs.js
CHANGED
|
@@ -1,9 +1,672 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var fs_exports = {};
|
|
20
|
+
__export(fs_exports, {
|
|
21
|
+
findUp: () => findUp,
|
|
22
|
+
findUpSync: () => findUpSync,
|
|
23
|
+
invalidatePathCache: () => invalidatePathCache,
|
|
24
|
+
isDir: () => isDir,
|
|
25
|
+
isDirEmptySync: () => isDirEmptySync,
|
|
26
|
+
isDirSync: () => isDirSync,
|
|
27
|
+
isSymLinkSync: () => isSymLinkSync,
|
|
28
|
+
readDirNames: () => readDirNames,
|
|
29
|
+
readDirNamesSync: () => readDirNamesSync,
|
|
30
|
+
readFileBinary: () => readFileBinary,
|
|
31
|
+
readFileBinarySync: () => readFileBinarySync,
|
|
32
|
+
readFileUtf8: () => readFileUtf8,
|
|
33
|
+
readFileUtf8Sync: () => readFileUtf8Sync,
|
|
34
|
+
readJson: () => readJson,
|
|
35
|
+
readJsonSync: () => readJsonSync,
|
|
36
|
+
safeDelete: () => safeDelete,
|
|
37
|
+
safeDeleteSync: () => safeDeleteSync,
|
|
38
|
+
safeMkdir: () => safeMkdir,
|
|
39
|
+
safeMkdirSync: () => safeMkdirSync,
|
|
40
|
+
safeReadFile: () => safeReadFile,
|
|
41
|
+
safeReadFileSync: () => safeReadFileSync,
|
|
42
|
+
safeStats: () => safeStats,
|
|
43
|
+
safeStatsSync: () => safeStatsSync,
|
|
44
|
+
uniqueSync: () => uniqueSync,
|
|
45
|
+
validateFiles: () => validateFiles,
|
|
46
|
+
writeJson: () => writeJson,
|
|
47
|
+
writeJsonSync: () => writeJsonSync
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(fs_exports);
|
|
50
|
+
var import_process = require("#constants/process");
|
|
51
|
+
var import_arrays = require("./arrays");
|
|
52
|
+
var import_globs = require("./globs");
|
|
53
|
+
var import_json = require("./json");
|
|
54
|
+
var import_objects = require("./objects");
|
|
55
|
+
var import_path = require("./path");
|
|
56
|
+
var import_rewire = require("./paths/rewire");
|
|
57
|
+
var import_sorts = require("./sorts");
|
|
58
|
+
const abortSignal = (0, import_process.getAbortSignal)();
|
|
59
|
+
const defaultRemoveOptions = (0, import_objects.objectFreeze)({
|
|
60
|
+
__proto__: null,
|
|
61
|
+
force: true,
|
|
62
|
+
maxRetries: 3,
|
|
63
|
+
recursive: true,
|
|
64
|
+
retryDelay: 200
|
|
65
|
+
});
|
|
66
|
+
let _fs;
|
|
67
|
+
// @__NO_SIDE_EFFECTS__
|
|
68
|
+
function getFs() {
|
|
69
|
+
if (_fs === void 0) {
|
|
70
|
+
_fs = require("node:fs");
|
|
71
|
+
}
|
|
72
|
+
return _fs;
|
|
73
|
+
}
|
|
74
|
+
let _path;
|
|
75
|
+
// @__NO_SIDE_EFFECTS__
|
|
76
|
+
function getPath() {
|
|
77
|
+
if (_path === void 0) {
|
|
78
|
+
_path = require("node:path");
|
|
79
|
+
}
|
|
80
|
+
return _path;
|
|
81
|
+
}
|
|
82
|
+
// @__NO_SIDE_EFFECTS__
|
|
83
|
+
function innerReadDirNames(dirents, dirname, options) {
|
|
84
|
+
const {
|
|
85
|
+
ignore,
|
|
86
|
+
includeEmpty = true,
|
|
87
|
+
sort = true
|
|
88
|
+
} = { __proto__: null, ...options };
|
|
89
|
+
const path = /* @__PURE__ */ getPath();
|
|
90
|
+
const names = dirents.filter(
|
|
91
|
+
(d) => d.isDirectory() && (includeEmpty || !/* @__PURE__ */ isDirEmptySync(path.join(dirname || d.parentPath, d.name), {
|
|
92
|
+
ignore
|
|
93
|
+
}))
|
|
94
|
+
).map((d) => d.name);
|
|
95
|
+
return sort ? names.sort(import_sorts.naturalCompare) : names;
|
|
96
|
+
}
|
|
97
|
+
// @__NO_SIDE_EFFECTS__
|
|
98
|
+
function stringify(json, EOL, finalEOL, replacer, spaces = 2) {
|
|
99
|
+
const EOF = finalEOL ? EOL : "";
|
|
100
|
+
const str = JSON.stringify(json, replacer, spaces);
|
|
101
|
+
return `${str.replace(/\n/g, EOL)}${EOF}`;
|
|
102
|
+
}
|
|
103
|
+
// @__NO_SIDE_EFFECTS__
|
|
104
|
+
async function findUp(name, options) {
|
|
105
|
+
const { cwd = process.cwd(), signal = abortSignal } = {
|
|
106
|
+
__proto__: null,
|
|
107
|
+
...options
|
|
108
|
+
};
|
|
109
|
+
let { onlyDirectories = false, onlyFiles = true } = {
|
|
110
|
+
__proto__: null,
|
|
111
|
+
...options
|
|
112
|
+
};
|
|
113
|
+
if (onlyDirectories) {
|
|
114
|
+
onlyFiles = false;
|
|
115
|
+
}
|
|
116
|
+
if (onlyFiles) {
|
|
117
|
+
onlyDirectories = false;
|
|
118
|
+
}
|
|
119
|
+
const fs = /* @__PURE__ */ getFs();
|
|
120
|
+
const path = /* @__PURE__ */ getPath();
|
|
121
|
+
let dir = path.resolve(cwd);
|
|
122
|
+
const { root } = path.parse(dir);
|
|
123
|
+
const names = (0, import_arrays.isArray)(name) ? name : [name];
|
|
124
|
+
while (dir && dir !== root) {
|
|
125
|
+
for (const n of names) {
|
|
126
|
+
if (signal?.aborted) {
|
|
127
|
+
return void 0;
|
|
128
|
+
}
|
|
129
|
+
const thePath = path.join(dir, n);
|
|
130
|
+
try {
|
|
131
|
+
const stats = await fs.promises.stat(thePath);
|
|
132
|
+
if (!onlyDirectories && stats.isFile()) {
|
|
133
|
+
return (0, import_path.normalizePath)(thePath);
|
|
134
|
+
}
|
|
135
|
+
if (!onlyFiles && stats.isDirectory()) {
|
|
136
|
+
return (0, import_path.normalizePath)(thePath);
|
|
137
|
+
}
|
|
138
|
+
} catch {
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
dir = path.dirname(dir);
|
|
142
|
+
}
|
|
143
|
+
return void 0;
|
|
144
|
+
}
|
|
145
|
+
// @__NO_SIDE_EFFECTS__
|
|
146
|
+
function findUpSync(name, options) {
|
|
147
|
+
const { cwd = process.cwd(), stopAt } = {
|
|
148
|
+
__proto__: null,
|
|
149
|
+
...options
|
|
150
|
+
};
|
|
151
|
+
let { onlyDirectories = false, onlyFiles = true } = {
|
|
152
|
+
__proto__: null,
|
|
153
|
+
...options
|
|
154
|
+
};
|
|
155
|
+
if (onlyDirectories) {
|
|
156
|
+
onlyFiles = false;
|
|
157
|
+
}
|
|
158
|
+
if (onlyFiles) {
|
|
159
|
+
onlyDirectories = false;
|
|
160
|
+
}
|
|
161
|
+
const fs = /* @__PURE__ */ getFs();
|
|
162
|
+
const path = /* @__PURE__ */ getPath();
|
|
163
|
+
let dir = path.resolve(cwd);
|
|
164
|
+
const { root } = path.parse(dir);
|
|
165
|
+
const stopDir = stopAt ? path.resolve(stopAt) : void 0;
|
|
166
|
+
const names = (0, import_arrays.isArray)(name) ? name : [name];
|
|
167
|
+
while (dir && dir !== root) {
|
|
168
|
+
if (stopDir && dir === stopDir) {
|
|
169
|
+
for (const n of names) {
|
|
170
|
+
const thePath = path.join(dir, n);
|
|
171
|
+
try {
|
|
172
|
+
const stats = fs.statSync(thePath);
|
|
173
|
+
if (!onlyDirectories && stats.isFile()) {
|
|
174
|
+
return (0, import_path.normalizePath)(thePath);
|
|
175
|
+
}
|
|
176
|
+
if (!onlyFiles && stats.isDirectory()) {
|
|
177
|
+
return (0, import_path.normalizePath)(thePath);
|
|
178
|
+
}
|
|
179
|
+
} catch {
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return void 0;
|
|
183
|
+
}
|
|
184
|
+
for (const n of names) {
|
|
185
|
+
const thePath = path.join(dir, n);
|
|
186
|
+
try {
|
|
187
|
+
const stats = fs.statSync(thePath);
|
|
188
|
+
if (!onlyDirectories && stats.isFile()) {
|
|
189
|
+
return (0, import_path.normalizePath)(thePath);
|
|
190
|
+
}
|
|
191
|
+
if (!onlyFiles && stats.isDirectory()) {
|
|
192
|
+
return (0, import_path.normalizePath)(thePath);
|
|
193
|
+
}
|
|
194
|
+
} catch {
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
dir = path.dirname(dir);
|
|
198
|
+
}
|
|
199
|
+
return void 0;
|
|
200
|
+
}
|
|
201
|
+
// @__NO_SIDE_EFFECTS__
|
|
202
|
+
async function isDir(filepath) {
|
|
203
|
+
return !!(await /* @__PURE__ */ safeStats(filepath))?.isDirectory();
|
|
204
|
+
}
|
|
205
|
+
// @__NO_SIDE_EFFECTS__
|
|
206
|
+
function isDirSync(filepath) {
|
|
207
|
+
return !!(/* @__PURE__ */ safeStatsSync(filepath))?.isDirectory();
|
|
208
|
+
}
|
|
209
|
+
// @__NO_SIDE_EFFECTS__
|
|
210
|
+
function isDirEmptySync(dirname, options) {
|
|
211
|
+
const { ignore = import_globs.defaultIgnore } = {
|
|
212
|
+
__proto__: null,
|
|
213
|
+
...options
|
|
214
|
+
};
|
|
215
|
+
const fs = /* @__PURE__ */ getFs();
|
|
216
|
+
try {
|
|
217
|
+
const files = fs.readdirSync(dirname);
|
|
218
|
+
const { length } = files;
|
|
219
|
+
if (length === 0) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
const matcher = (0, import_globs.getGlobMatcher)(
|
|
223
|
+
ignore,
|
|
224
|
+
{
|
|
225
|
+
cwd: (0, import_path.pathLikeToString)(dirname)
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
let ignoredCount = 0;
|
|
229
|
+
for (let i = 0; i < length; i += 1) {
|
|
230
|
+
const file = files[i];
|
|
231
|
+
if (file && matcher(file)) {
|
|
232
|
+
ignoredCount += 1;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return ignoredCount === length;
|
|
236
|
+
} catch {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// @__NO_SIDE_EFFECTS__
|
|
241
|
+
function isSymLinkSync(filepath) {
|
|
242
|
+
const fs = /* @__PURE__ */ getFs();
|
|
243
|
+
try {
|
|
244
|
+
return fs.lstatSync(filepath).isSymbolicLink();
|
|
245
|
+
} catch {
|
|
246
|
+
}
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
// @__NO_SIDE_EFFECTS__
|
|
250
|
+
function validateFiles(filepaths) {
|
|
251
|
+
const fs = /* @__PURE__ */ getFs();
|
|
252
|
+
const validPaths = [];
|
|
253
|
+
const invalidPaths = [];
|
|
254
|
+
const { R_OK } = fs.constants;
|
|
255
|
+
for (const filepath of filepaths) {
|
|
256
|
+
try {
|
|
257
|
+
fs.accessSync(filepath, R_OK);
|
|
258
|
+
validPaths.push(filepath);
|
|
259
|
+
} catch {
|
|
260
|
+
invalidPaths.push(filepath);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return { __proto__: null, validPaths, invalidPaths };
|
|
264
|
+
}
|
|
265
|
+
// @__NO_SIDE_EFFECTS__
|
|
266
|
+
async function readDirNames(dirname, options) {
|
|
267
|
+
const fs = /* @__PURE__ */ getFs();
|
|
268
|
+
try {
|
|
269
|
+
return /* @__PURE__ */ innerReadDirNames(
|
|
270
|
+
await fs.promises.readdir(dirname, {
|
|
271
|
+
__proto__: null,
|
|
272
|
+
encoding: "utf8",
|
|
273
|
+
withFileTypes: true
|
|
274
|
+
}),
|
|
275
|
+
String(dirname),
|
|
276
|
+
options
|
|
277
|
+
);
|
|
278
|
+
} catch {
|
|
279
|
+
}
|
|
280
|
+
return [];
|
|
281
|
+
}
|
|
282
|
+
// @__NO_SIDE_EFFECTS__
|
|
283
|
+
function readDirNamesSync(dirname, options) {
|
|
284
|
+
const fs = /* @__PURE__ */ getFs();
|
|
285
|
+
try {
|
|
286
|
+
return /* @__PURE__ */ innerReadDirNames(
|
|
287
|
+
fs.readdirSync(dirname, {
|
|
288
|
+
__proto__: null,
|
|
289
|
+
encoding: "utf8",
|
|
290
|
+
withFileTypes: true
|
|
291
|
+
}),
|
|
292
|
+
String(dirname),
|
|
293
|
+
options
|
|
294
|
+
);
|
|
295
|
+
} catch {
|
|
296
|
+
}
|
|
297
|
+
return [];
|
|
298
|
+
}
|
|
299
|
+
// @__NO_SIDE_EFFECTS__
|
|
300
|
+
async function readFileBinary(filepath, options) {
|
|
301
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
302
|
+
const fs = /* @__PURE__ */ getFs();
|
|
303
|
+
return await fs.promises.readFile(filepath, {
|
|
304
|
+
signal: abortSignal,
|
|
305
|
+
...opts,
|
|
306
|
+
encoding: null
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
// @__NO_SIDE_EFFECTS__
|
|
310
|
+
async function readFileUtf8(filepath, options) {
|
|
311
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
312
|
+
const fs = /* @__PURE__ */ getFs();
|
|
313
|
+
return await fs.promises.readFile(filepath, {
|
|
314
|
+
signal: abortSignal,
|
|
315
|
+
...opts,
|
|
316
|
+
encoding: "utf8"
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
// @__NO_SIDE_EFFECTS__
|
|
320
|
+
function readFileBinarySync(filepath, options) {
|
|
321
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
322
|
+
const fs = /* @__PURE__ */ getFs();
|
|
323
|
+
return fs.readFileSync(filepath, {
|
|
324
|
+
...opts,
|
|
325
|
+
encoding: null
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
// @__NO_SIDE_EFFECTS__
|
|
329
|
+
function readFileUtf8Sync(filepath, options) {
|
|
330
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
331
|
+
const fs = /* @__PURE__ */ getFs();
|
|
332
|
+
return fs.readFileSync(filepath, {
|
|
333
|
+
...opts,
|
|
334
|
+
encoding: "utf8"
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
// @__NO_SIDE_EFFECTS__
|
|
338
|
+
async function readJson(filepath, options) {
|
|
339
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
340
|
+
const { reviver, throws, ...fsOptions } = {
|
|
341
|
+
__proto__: null,
|
|
342
|
+
...opts
|
|
343
|
+
};
|
|
344
|
+
const shouldThrow = throws === void 0 || !!throws;
|
|
345
|
+
const fs = /* @__PURE__ */ getFs();
|
|
346
|
+
let content = "";
|
|
347
|
+
try {
|
|
348
|
+
content = await fs.promises.readFile(filepath, {
|
|
349
|
+
__proto__: null,
|
|
350
|
+
encoding: "utf8",
|
|
351
|
+
...fsOptions
|
|
352
|
+
});
|
|
353
|
+
} catch (e) {
|
|
354
|
+
if (shouldThrow) {
|
|
355
|
+
const code = e.code;
|
|
356
|
+
if (code === "ENOENT") {
|
|
357
|
+
throw new Error(
|
|
358
|
+
`JSON file not found: ${filepath}
|
|
359
|
+
Ensure the file exists or create it with the expected structure.`,
|
|
360
|
+
{ cause: e }
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
if (code === "EACCES" || code === "EPERM") {
|
|
364
|
+
throw new Error(
|
|
365
|
+
`Permission denied reading JSON file: ${filepath}
|
|
366
|
+
Check file permissions or run with appropriate access.`,
|
|
367
|
+
{ cause: e }
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
throw e;
|
|
371
|
+
}
|
|
372
|
+
return void 0;
|
|
373
|
+
}
|
|
374
|
+
return (0, import_json.jsonParse)(content, {
|
|
375
|
+
filepath: String(filepath),
|
|
376
|
+
reviver,
|
|
377
|
+
throws: shouldThrow
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
// @__NO_SIDE_EFFECTS__
|
|
381
|
+
function readJsonSync(filepath, options) {
|
|
382
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
383
|
+
const { reviver, throws, ...fsOptions } = {
|
|
384
|
+
__proto__: null,
|
|
385
|
+
...opts
|
|
386
|
+
};
|
|
387
|
+
const shouldThrow = throws === void 0 || !!throws;
|
|
388
|
+
const fs = /* @__PURE__ */ getFs();
|
|
389
|
+
let content = "";
|
|
390
|
+
try {
|
|
391
|
+
content = fs.readFileSync(filepath, {
|
|
392
|
+
__proto__: null,
|
|
393
|
+
encoding: "utf8",
|
|
394
|
+
...fsOptions
|
|
395
|
+
});
|
|
396
|
+
} catch (e) {
|
|
397
|
+
if (shouldThrow) {
|
|
398
|
+
const code = e.code;
|
|
399
|
+
if (code === "ENOENT") {
|
|
400
|
+
throw new Error(
|
|
401
|
+
`JSON file not found: ${filepath}
|
|
402
|
+
Ensure the file exists or create it with the expected structure.`,
|
|
403
|
+
{ cause: e }
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
if (code === "EACCES" || code === "EPERM") {
|
|
407
|
+
throw new Error(
|
|
408
|
+
`Permission denied reading JSON file: ${filepath}
|
|
409
|
+
Check file permissions or run with appropriate access.`,
|
|
410
|
+
{ cause: e }
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
throw e;
|
|
414
|
+
}
|
|
415
|
+
return void 0;
|
|
416
|
+
}
|
|
417
|
+
return (0, import_json.jsonParse)(content, {
|
|
418
|
+
filepath: String(filepath),
|
|
419
|
+
reviver,
|
|
420
|
+
throws: shouldThrow
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
let _cachedAllowedDirs;
|
|
424
|
+
function getAllowedDirectories() {
|
|
425
|
+
if (_cachedAllowedDirs === void 0) {
|
|
426
|
+
const path = /* @__PURE__ */ getPath();
|
|
427
|
+
const {
|
|
428
|
+
getOsTmpDir,
|
|
429
|
+
getSocketCacacheDir,
|
|
430
|
+
getSocketUserDir
|
|
431
|
+
} = require("#lib/paths");
|
|
432
|
+
_cachedAllowedDirs = [
|
|
433
|
+
path.resolve(getOsTmpDir()),
|
|
434
|
+
path.resolve(getSocketCacacheDir()),
|
|
435
|
+
path.resolve(getSocketUserDir())
|
|
436
|
+
];
|
|
437
|
+
}
|
|
438
|
+
return _cachedAllowedDirs;
|
|
439
|
+
}
|
|
440
|
+
function invalidatePathCache() {
|
|
441
|
+
_cachedAllowedDirs = void 0;
|
|
442
|
+
}
|
|
443
|
+
(0, import_rewire.registerCacheInvalidation)(invalidatePathCache);
|
|
444
|
+
// @__NO_SIDE_EFFECTS__
|
|
445
|
+
async function safeDelete(filepath, options) {
|
|
446
|
+
const del = require("./external/del");
|
|
447
|
+
const { deleteAsync } = del;
|
|
448
|
+
const opts = { __proto__: null, ...options };
|
|
449
|
+
const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_path.pathLikeToString) : [(0, import_path.pathLikeToString)(filepath)];
|
|
450
|
+
let shouldForce = opts.force !== false;
|
|
451
|
+
if (!shouldForce && patterns.length > 0) {
|
|
452
|
+
const path = /* @__PURE__ */ getPath();
|
|
453
|
+
const allowedDirs = getAllowedDirectories();
|
|
454
|
+
const allInAllowedDirs = patterns.every((pattern) => {
|
|
455
|
+
const resolvedPath = path.resolve(pattern);
|
|
456
|
+
for (const allowedDir of allowedDirs) {
|
|
457
|
+
const isInAllowedDir = resolvedPath.startsWith(allowedDir + path.sep) || resolvedPath === allowedDir;
|
|
458
|
+
const relativePath = path.relative(allowedDir, resolvedPath);
|
|
459
|
+
const isGoingBackward = relativePath.startsWith("..");
|
|
460
|
+
if (isInAllowedDir && !isGoingBackward) {
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return false;
|
|
465
|
+
});
|
|
466
|
+
if (allInAllowedDirs) {
|
|
467
|
+
shouldForce = true;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
await deleteAsync(patterns, {
|
|
471
|
+
concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
|
|
472
|
+
dryRun: false,
|
|
473
|
+
force: shouldForce,
|
|
474
|
+
onlyFiles: false
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
// @__NO_SIDE_EFFECTS__
|
|
478
|
+
function safeDeleteSync(filepath, options) {
|
|
479
|
+
const del = require("./external/del");
|
|
480
|
+
const { deleteSync } = del;
|
|
481
|
+
const opts = { __proto__: null, ...options };
|
|
482
|
+
const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_path.pathLikeToString) : [(0, import_path.pathLikeToString)(filepath)];
|
|
483
|
+
let shouldForce = opts.force !== false;
|
|
484
|
+
if (!shouldForce && patterns.length > 0) {
|
|
485
|
+
const path = /* @__PURE__ */ getPath();
|
|
486
|
+
const allowedDirs = getAllowedDirectories();
|
|
487
|
+
const allInAllowedDirs = patterns.every((pattern) => {
|
|
488
|
+
const resolvedPath = path.resolve(pattern);
|
|
489
|
+
for (const allowedDir of allowedDirs) {
|
|
490
|
+
const isInAllowedDir = resolvedPath.startsWith(allowedDir + path.sep) || resolvedPath === allowedDir;
|
|
491
|
+
const relativePath = path.relative(allowedDir, resolvedPath);
|
|
492
|
+
const isGoingBackward = relativePath.startsWith("..");
|
|
493
|
+
if (isInAllowedDir && !isGoingBackward) {
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return false;
|
|
498
|
+
});
|
|
499
|
+
if (allInAllowedDirs) {
|
|
500
|
+
shouldForce = true;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
deleteSync(patterns, {
|
|
504
|
+
concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
|
|
505
|
+
dryRun: false,
|
|
506
|
+
force: shouldForce,
|
|
507
|
+
onlyFiles: false
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
// @__NO_SIDE_EFFECTS__
|
|
511
|
+
async function safeMkdir(path, options) {
|
|
512
|
+
const fs = /* @__PURE__ */ getFs();
|
|
513
|
+
try {
|
|
514
|
+
await fs.promises.mkdir(path, options);
|
|
515
|
+
} catch (e) {
|
|
516
|
+
if (typeof e === "object" && e !== null && "code" in e && e.code !== "EEXIST") {
|
|
517
|
+
throw e;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
// @__NO_SIDE_EFFECTS__
|
|
522
|
+
function safeMkdirSync(path, options) {
|
|
523
|
+
const fs = /* @__PURE__ */ getFs();
|
|
524
|
+
try {
|
|
525
|
+
fs.mkdirSync(path, options);
|
|
526
|
+
} catch (e) {
|
|
527
|
+
if (typeof e === "object" && e !== null && "code" in e && e.code !== "EEXIST") {
|
|
528
|
+
throw e;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
// @__NO_SIDE_EFFECTS__
|
|
533
|
+
async function safeReadFile(filepath, options) {
|
|
534
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
535
|
+
const fs = /* @__PURE__ */ getFs();
|
|
536
|
+
try {
|
|
537
|
+
return await fs.promises.readFile(filepath, {
|
|
538
|
+
signal: abortSignal,
|
|
539
|
+
...opts
|
|
540
|
+
});
|
|
541
|
+
} catch {
|
|
542
|
+
}
|
|
543
|
+
return void 0;
|
|
544
|
+
}
|
|
545
|
+
// @__NO_SIDE_EFFECTS__
|
|
546
|
+
function safeReadFileSync(filepath, options) {
|
|
547
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
548
|
+
const fs = /* @__PURE__ */ getFs();
|
|
549
|
+
try {
|
|
550
|
+
return fs.readFileSync(filepath, {
|
|
551
|
+
__proto__: null,
|
|
552
|
+
...opts
|
|
553
|
+
});
|
|
554
|
+
} catch {
|
|
555
|
+
}
|
|
556
|
+
return void 0;
|
|
557
|
+
}
|
|
558
|
+
// @__NO_SIDE_EFFECTS__
|
|
559
|
+
async function safeStats(filepath) {
|
|
560
|
+
const fs = /* @__PURE__ */ getFs();
|
|
561
|
+
try {
|
|
562
|
+
return await fs.promises.stat(filepath);
|
|
563
|
+
} catch {
|
|
564
|
+
}
|
|
565
|
+
return void 0;
|
|
566
|
+
}
|
|
567
|
+
// @__NO_SIDE_EFFECTS__
|
|
568
|
+
function safeStatsSync(filepath, options) {
|
|
569
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
570
|
+
const fs = /* @__PURE__ */ getFs();
|
|
571
|
+
try {
|
|
572
|
+
return fs.statSync(filepath, {
|
|
573
|
+
__proto__: null,
|
|
574
|
+
throwIfNoEntry: false,
|
|
575
|
+
...opts
|
|
576
|
+
});
|
|
577
|
+
} catch {
|
|
578
|
+
}
|
|
579
|
+
return void 0;
|
|
580
|
+
}
|
|
581
|
+
// @__NO_SIDE_EFFECTS__
|
|
582
|
+
function uniqueSync(filepath) {
|
|
583
|
+
const fs = /* @__PURE__ */ getFs();
|
|
584
|
+
const path = /* @__PURE__ */ getPath();
|
|
585
|
+
const filepathStr = String(filepath);
|
|
586
|
+
if (!fs.existsSync(filepathStr)) {
|
|
587
|
+
return (0, import_path.normalizePath)(filepathStr);
|
|
588
|
+
}
|
|
589
|
+
const dirname = path.dirname(filepathStr);
|
|
590
|
+
const ext = path.extname(filepathStr);
|
|
591
|
+
const basename = path.basename(filepathStr, ext);
|
|
592
|
+
let counter = 1;
|
|
593
|
+
let uniquePath;
|
|
594
|
+
do {
|
|
595
|
+
uniquePath = path.join(dirname, `${basename}-${counter}${ext}`);
|
|
596
|
+
counter++;
|
|
597
|
+
} while (fs.existsSync(uniquePath));
|
|
598
|
+
return (0, import_path.normalizePath)(uniquePath);
|
|
599
|
+
}
|
|
600
|
+
// @__NO_SIDE_EFFECTS__
|
|
601
|
+
async function writeJson(filepath, jsonContent, options) {
|
|
602
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
603
|
+
const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {
|
|
604
|
+
__proto__: null,
|
|
605
|
+
...opts
|
|
606
|
+
};
|
|
607
|
+
const fs = /* @__PURE__ */ getFs();
|
|
608
|
+
const jsonString = /* @__PURE__ */ stringify(
|
|
609
|
+
jsonContent,
|
|
610
|
+
EOL || "\n",
|
|
611
|
+
finalEOL !== void 0 ? finalEOL : true,
|
|
612
|
+
replacer,
|
|
613
|
+
spaces
|
|
614
|
+
);
|
|
615
|
+
await fs.promises.writeFile(filepath, jsonString, {
|
|
616
|
+
encoding: "utf8",
|
|
617
|
+
...fsOptions,
|
|
618
|
+
__proto__: null
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
// @__NO_SIDE_EFFECTS__
|
|
622
|
+
function writeJsonSync(filepath, jsonContent, options) {
|
|
623
|
+
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
624
|
+
const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {
|
|
625
|
+
__proto__: null,
|
|
626
|
+
...opts
|
|
627
|
+
};
|
|
628
|
+
const fs = /* @__PURE__ */ getFs();
|
|
629
|
+
const jsonString = /* @__PURE__ */ stringify(
|
|
630
|
+
jsonContent,
|
|
631
|
+
EOL || "\n",
|
|
632
|
+
finalEOL !== void 0 ? finalEOL : true,
|
|
633
|
+
replacer,
|
|
634
|
+
spaces
|
|
635
|
+
);
|
|
636
|
+
fs.writeFileSync(filepath, jsonString, {
|
|
637
|
+
encoding: "utf8",
|
|
638
|
+
...fsOptions,
|
|
639
|
+
__proto__: null
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
643
|
+
0 && (module.exports = {
|
|
644
|
+
findUp,
|
|
645
|
+
findUpSync,
|
|
646
|
+
invalidatePathCache,
|
|
647
|
+
isDir,
|
|
648
|
+
isDirEmptySync,
|
|
649
|
+
isDirSync,
|
|
650
|
+
isSymLinkSync,
|
|
651
|
+
readDirNames,
|
|
652
|
+
readDirNamesSync,
|
|
653
|
+
readFileBinary,
|
|
654
|
+
readFileBinarySync,
|
|
655
|
+
readFileUtf8,
|
|
656
|
+
readFileUtf8Sync,
|
|
657
|
+
readJson,
|
|
658
|
+
readJsonSync,
|
|
659
|
+
safeDelete,
|
|
660
|
+
safeDeleteSync,
|
|
661
|
+
safeMkdir,
|
|
662
|
+
safeMkdirSync,
|
|
663
|
+
safeReadFile,
|
|
664
|
+
safeReadFileSync,
|
|
665
|
+
safeStats,
|
|
666
|
+
safeStatsSync,
|
|
667
|
+
uniqueSync,
|
|
668
|
+
validateFiles,
|
|
669
|
+
writeJson,
|
|
670
|
+
writeJsonSync
|
|
671
|
+
});
|
|
9
672
|
//# sourceMappingURL=fs.js.map
|