@socketsecurity/lib 5.11.1 → 5.11.3

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/abort.js +1 -3
  3. package/dist/agent.js +12 -1
  4. package/dist/ansi.js +1 -1
  5. package/dist/archives.js +7 -6
  6. package/dist/argv/flags.d.ts +0 -7
  7. package/dist/argv/flags.js +12 -1
  8. package/dist/argv/parse.js +5 -9
  9. package/dist/bin.js +2 -1
  10. package/dist/cache-with-ttl.js +10 -3
  11. package/dist/constants/node.js +14 -3
  12. package/dist/cover/code.js +13 -2
  13. package/dist/cover/type.js +12 -1
  14. package/dist/dlx/binary.js +16 -5
  15. package/dist/dlx/manifest.js +22 -33
  16. package/dist/env/package-manager.js +12 -1
  17. package/dist/env/rewire.js +14 -3
  18. package/dist/external/@npmcli/package-json.js +5 -3
  19. package/dist/external/adm-zip.js +1 -0
  20. package/dist/external/debug.js +18 -10
  21. package/dist/external/external-pack.js +8 -2
  22. package/dist/external/libnpmexec.js +2 -2
  23. package/dist/external/npm-pack.js +380 -367
  24. package/dist/external/p-map.js +240 -0
  25. package/dist/external/pico-pack.js +245 -12
  26. package/dist/external/zod.js +1 -0
  27. package/dist/fs.d.ts +0 -4
  28. package/dist/fs.js +13 -2
  29. package/dist/git.js +12 -1
  30. package/dist/github.js +15 -6
  31. package/dist/http-request.d.ts +29 -0
  32. package/dist/http-request.js +23 -2
  33. package/dist/ipc.js +17 -5
  34. package/dist/json/edit.js +14 -3
  35. package/dist/logger.js +5 -4
  36. package/dist/memoization.js +46 -13
  37. package/dist/packages/isolation.js +9 -1
  38. package/dist/performance.js +13 -2
  39. package/dist/process-lock.js +16 -3
  40. package/dist/promise-queue.d.ts +2 -0
  41. package/dist/promise-queue.js +20 -9
  42. package/dist/promises.js +1 -3
  43. package/dist/releases/github.js +9 -4
  44. package/dist/sea.js +12 -1
  45. package/dist/shadow.js +14 -3
  46. package/dist/spawn.js +5 -4
  47. package/dist/spinner.d.ts +0 -4
  48. package/dist/spinner.js +2 -1
  49. package/dist/stdio/clear.d.ts +0 -21
  50. package/dist/stdio/clear.js +20 -9
  51. package/dist/stdio/mask.js +27 -16
  52. package/dist/stdio/progress.js +3 -2
  53. package/dist/stdio/stderr.d.ts +0 -13
  54. package/dist/stdio/stderr.js +12 -1
  55. package/dist/stdio/stdout.js +17 -6
  56. package/dist/suppress-warnings.d.ts +0 -9
  57. package/dist/suppress-warnings.js +17 -6
  58. package/dist/temporary-executor.js +14 -3
  59. package/dist/validation/json-parser.js +10 -12
  60. package/package.json +8 -6
package/CHANGELOG.md CHANGED
@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.11.3](https://github.com/SocketDev/socket-lib/releases/tag/v5.11.3) - 2026-03-26
9
+
10
+ ### Fixed
11
+
12
+ - **build**: Deduplicate shared deps across external bundles (#110)
13
+ - **quality**: Comprehensive quality scan fixes across codebase (#111)
14
+ - **releases**: Add in-memory TTL cache for GitHub API responses
15
+ - **releases**: Guard against missing assets in GitHub release response (#112)
16
+ - **process-lock**: Fix Windows path separator handling for lock directory creation (#112)
17
+
18
+ ## [5.11.2](https://github.com/SocketDev/socket-lib/releases/tag/v5.11.2) - 2026-03-24
19
+
20
+ ### Added
21
+
22
+ - **http-request**: Custom CA certificate support for TLS connections
23
+ - `httpRequest`, `httpJson`, `httpText` accept `ca` option for custom certificate authorities
24
+ - `httpDownload` accepts `ca` option, threaded through redirects and retries
25
+ - `fetchChecksums` accepts `ca` option, passed through to underlying request
26
+ - Enables SSL_CERT_FILE support when NODE_EXTRA_CA_CERTS is unavailable at process startup
27
+
8
28
  ## [5.11.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.11.1) - 2026-03-24
9
29
 
10
30
  ### Added
package/dist/abort.js CHANGED
@@ -51,9 +51,7 @@ function createTimeoutSignal(ms) {
51
51
  if (ms <= 0) {
52
52
  throw new TypeError("timeout must be a positive number");
53
53
  }
54
- const controller = new AbortController();
55
- setTimeout(() => controller.abort(), ms);
56
- return controller.signal;
54
+ return AbortSignal.timeout(Math.ceil(ms));
57
55
  }
58
56
  // Annotate the CommonJS export names for ESM import in node:
59
57
  0 && (module.exports = {
package/dist/agent.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var agent_exports = {};
21
31
  __export(agent_exports, {
@@ -34,6 +44,7 @@ __export(agent_exports, {
34
44
  isPnpmLoglevelFlag: () => isPnpmLoglevelFlag
35
45
  });
36
46
  module.exports = __toCommonJS(agent_exports);
47
+ var import_node_process = __toESM(require("node:process"));
37
48
  var import_agents = require("./constants/agents");
38
49
  var import_node = require("./constants/node");
39
50
  var import_platform = require("./constants/platform");
@@ -230,7 +241,7 @@ function execScript(scriptName, args, options) {
230
241
  return (0, import_spawn.spawn)(scriptName, resolvedArgs, spawnOptions);
231
242
  }
232
243
  const useNodeRun = !prepost && (0, import_node.supportsNodeRun)();
233
- const cwd = (0, import_objects.getOwn)(spawnOptions, "cwd") ?? process.cwd();
244
+ const cwd = (0, import_objects.getOwn)(spawnOptions, "cwd") ?? import_node_process.default.cwd();
234
245
  const pnpmLockPath = (0, import_fs.findUpSync)(import_agents.PNPM_LOCK_YAML, { cwd });
235
246
  if (pnpmLockPath) {
236
247
  return execPnpm(["run", scriptName, ...resolvedArgs], spawnOptions);
package/dist/ansi.js CHANGED
@@ -39,7 +39,7 @@ const ANSI_REGEX = /\x1b\[[0-9;]*m/g;
39
39
  // @__NO_SIDE_EFFECTS__
40
40
  function ansiRegex(options) {
41
41
  const { onlyFirst } = options ?? {};
42
- const ST = "(?:\\u0007\\u001B\\u005C|\\u009C)";
42
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
43
43
  const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
44
44
  const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
45
45
  const pattern = `${osc}|${csi}`;
package/dist/archives.js CHANGED
@@ -39,6 +39,7 @@ module.exports = __toCommonJS(archives_exports);
39
39
  var import_node_fs = require("node:fs");
40
40
  var import_promises = require("node:stream/promises");
41
41
  var import_node_zlib = require("node:zlib");
42
+ var import_node_process = __toESM(require("node:process"));
42
43
  var import_adm_zip = __toESM(require("./external/adm-zip.js"));
43
44
  var import_tar_fs = __toESM(require("./external/tar-fs.js"));
44
45
  var import_fs = require("./fs.js");
@@ -96,7 +97,7 @@ async function extractTar(archivePath, outputDir, options = {}) {
96
97
  }
97
98
  if (header.type === "symlink" || header.type === "link") {
98
99
  destroyScheduled = true;
99
- process.nextTick(() => {
100
+ import_node_process.default.nextTick(() => {
100
101
  extractStream.destroy(
101
102
  new Error(
102
103
  `Symlink detected in archive: ${header.name}. Symlinks are not supported for security reasons.`
@@ -107,7 +108,7 @@ async function extractTar(archivePath, outputDir, options = {}) {
107
108
  }
108
109
  if (header.size && header.size > maxFileSize) {
109
110
  destroyScheduled = true;
110
- process.nextTick(() => {
111
+ import_node_process.default.nextTick(() => {
111
112
  extractStream.destroy(
112
113
  new Error(
113
114
  `File size exceeds limit: ${header.name} (${header.size} bytes > ${maxFileSize} bytes)`
@@ -120,7 +121,7 @@ async function extractTar(archivePath, outputDir, options = {}) {
120
121
  totalExtractedSize += header.size;
121
122
  if (totalExtractedSize > maxTotalSize) {
122
123
  destroyScheduled = true;
123
- process.nextTick(() => {
124
+ import_node_process.default.nextTick(() => {
124
125
  extractStream.destroy(
125
126
  new Error(
126
127
  `Total extracted size exceeds limit: ${totalExtractedSize} bytes > ${maxTotalSize} bytes`
@@ -161,7 +162,7 @@ async function extractTarGz(archivePath, outputDir, options = {}) {
161
162
  }
162
163
  if (header.type === "symlink" || header.type === "link") {
163
164
  destroyScheduled = true;
164
- process.nextTick(() => {
165
+ import_node_process.default.nextTick(() => {
165
166
  extractStream.destroy(
166
167
  new Error(
167
168
  `Symlink detected in archive: ${header.name}. Symlinks are not supported for security reasons.`
@@ -172,7 +173,7 @@ async function extractTarGz(archivePath, outputDir, options = {}) {
172
173
  }
173
174
  if (header.size && header.size > maxFileSize) {
174
175
  destroyScheduled = true;
175
- process.nextTick(() => {
176
+ import_node_process.default.nextTick(() => {
176
177
  extractStream.destroy(
177
178
  new Error(
178
179
  `File size exceeds limit: ${header.name} (${header.size} bytes > ${maxFileSize} bytes)`
@@ -185,7 +186,7 @@ async function extractTarGz(archivePath, outputDir, options = {}) {
185
186
  totalExtractedSize += header.size;
186
187
  if (totalExtractedSize > maxTotalSize) {
187
188
  destroyScheduled = true;
188
- process.nextTick(() => {
189
+ import_node_process.default.nextTick(() => {
189
190
  extractStream.destroy(
190
191
  new Error(
191
192
  `Total extracted size exceeds limit: ${totalExtractedSize} bytes > ${maxTotalSize} bytes`
@@ -1,10 +1,3 @@
1
- /**
2
- * Common flag utilities for Socket CLI applications.
3
- * Provides consistent flag checking across all Socket projects.
4
- */
5
- /**
6
- * Flag values object from parsed arguments.
7
- */
8
1
  export interface FlagValues {
9
2
  [key: string]: unknown;
10
3
  quiet?: boolean;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var flags_exports = {};
21
31
  __export(flags_exports, {
@@ -37,7 +47,8 @@ __export(flags_exports, {
37
47
  isWatch: () => isWatch
38
48
  });
39
49
  module.exports = __toCommonJS(flags_exports);
40
- const processArg = [...process.argv];
50
+ var import_node_process = __toESM(require("node:process"));
51
+ const processArg = [...import_node_process.default.argv];
41
52
  function getLogLevel(input) {
42
53
  if (isQuiet(input)) {
43
54
  return "silent";
@@ -36,12 +36,13 @@ __export(parse_exports, {
36
36
  parseArgsWithDefaults: () => parseArgsWithDefaults
37
37
  });
38
38
  module.exports = __toCommonJS(parse_exports);
39
+ var import_node_process = __toESM(require("node:process"));
39
40
  var import_yargs_parser = __toESM(require("../external/yargs-parser"));
40
41
  function parseArgs(config = {}) {
41
42
  const {
42
43
  allowNegative = false,
43
44
  allowPositionals = true,
44
- args = process.argv.slice(2),
45
+ args = import_node_process.default.argv.slice(2),
45
46
  configuration,
46
47
  options = {},
47
48
  strict = true
@@ -142,7 +143,7 @@ const commonParseArgsConfig = {
142
143
  strict: false
143
144
  };
144
145
  function getPositionalArgs(startIndex = 2) {
145
- const args = process.argv.slice(startIndex);
146
+ const args = import_node_process.default.argv.slice(startIndex);
146
147
  const positionals = [];
147
148
  let i = 0;
148
149
  while (i < args.length) {
@@ -155,13 +156,8 @@ function getPositionalArgs(startIndex = 2) {
155
156
  }
156
157
  return positionals;
157
158
  }
158
- function hasFlag(flag, argv = process.argv) {
159
- const flagVariants = [
160
- `--${flag}`,
161
- // Short flag.
162
- `-${flag.charAt(0)}`
163
- ];
164
- return flagVariants.some((variant) => argv.includes(variant));
159
+ function hasFlag(flag, argv = import_node_process.default.argv) {
160
+ return argv.includes(`--${flag}`);
165
161
  }
166
162
  // Annotate the CommonJS export names for ESM import in node:
167
163
  0 && (module.exports = {
package/dist/bin.js CHANGED
@@ -42,6 +42,7 @@ __export(bin_exports, {
42
42
  whichSync: () => whichSync
43
43
  });
44
44
  module.exports = __toCommonJS(bin_exports);
45
+ var import_node_process = __toESM(require("node:process"));
45
46
  var import_home = require("./env/home");
46
47
  var import_windows = require("./env/windows");
47
48
  var import_xdg = require("./env/xdg");
@@ -135,7 +136,7 @@ function findRealBin(binName, commonPaths = []) {
135
136
  function findRealNpm() {
136
137
  const fs = /* @__PURE__ */ getFs();
137
138
  const path = /* @__PURE__ */ getPath();
138
- const nodeDir = path.dirname(process.execPath);
139
+ const nodeDir = path.dirname(import_node_process.default.execPath);
139
140
  const npmInNodeDir = path.join(nodeDir, "npm");
140
141
  if (fs.existsSync(npmInNodeDir)) {
141
142
  return npmInNodeDir;
@@ -90,9 +90,16 @@ function createTtlCache(options) {
90
90
  }
91
91
  const cacheEntry = await cacache.safeGet(fullKey);
92
92
  if (cacheEntry) {
93
- const entry = JSON.parse(
94
- cacheEntry.data.toString("utf8")
95
- );
93
+ let entry;
94
+ try {
95
+ entry = JSON.parse(cacheEntry.data.toString("utf8"));
96
+ } catch {
97
+ try {
98
+ await cacache.remove(fullKey);
99
+ } catch {
100
+ }
101
+ return void 0;
102
+ }
96
103
  if (!isExpired(entry)) {
97
104
  if (opts.memoize) {
98
105
  memoCache.set(fullKey, entry);
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var node_exports = {};
21
31
  __export(node_exports, {
@@ -41,8 +51,9 @@ __export(node_exports, {
41
51
  supportsProcessSend: () => supportsProcessSend
42
52
  });
43
53
  module.exports = __toCommonJS(node_exports);
54
+ var import_node_process = __toESM(require("node:process"));
44
55
  var import_maintained_node_versions = require("./maintained-node-versions");
45
- const NODE_VERSION = process.version;
56
+ const NODE_VERSION = import_node_process.default.version;
46
57
  function getNodeVersion() {
47
58
  return NODE_VERSION;
48
59
  }
@@ -105,7 +116,7 @@ function getNodeDisableSigusr1Flags() {
105
116
  return _nodeDisableSigusr1Flags;
106
117
  }
107
118
  function supportsProcessSend() {
108
- return typeof process.send === "function";
119
+ return typeof import_node_process.default.send === "function";
109
120
  }
110
121
  let _nodeHardenFlags;
111
122
  let _nodePermissionFlags;
@@ -152,7 +163,7 @@ function getNodeNoWarningsFlags() {
152
163
  return _nodeNoWarningsFlags;
153
164
  }
154
165
  function getExecPath() {
155
- return process.execPath;
166
+ return import_node_process.default.execPath;
156
167
  }
157
168
  const NODE_SEA_FUSE = "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2";
158
169
  const ESNEXT = "esnext";
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,12 +18,21 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var code_exports = {};
21
31
  __export(code_exports, {
22
32
  getCodeCoverage: () => getCodeCoverage
23
33
  });
24
34
  module.exports = __toCommonJS(code_exports);
35
+ var import_node_process = __toESM(require("node:process"));
25
36
  var import_fs = require("../fs");
26
37
  var import_objects = require("../objects");
27
38
  var import_spawn = require("../spawn");
@@ -45,7 +56,7 @@ async function getCodeCoverage(options) {
45
56
  const path = /* @__PURE__ */ getPath();
46
57
  const opts = {
47
58
  __proto__: null,
48
- coveragePath: path.join(process.cwd(), "coverage/coverage-final.json"),
59
+ coveragePath: path.join(import_node_process.default.cwd(), "coverage/coverage-final.json"),
49
60
  generateIfMissing: false,
50
61
  ...options
51
62
  };
@@ -58,7 +69,7 @@ async function getCodeCoverage(options) {
58
69
  if (!coverageExists) {
59
70
  if (generateIfMissing) {
60
71
  await (0, import_spawn.spawn)("vitest", ["run", "--coverage"], {
61
- cwd: process.cwd(),
72
+ cwd: import_node_process.default.cwd(),
62
73
  stdio: "inherit"
63
74
  });
64
75
  } else {
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,17 +18,26 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var type_exports = {};
21
31
  __export(type_exports, {
22
32
  getTypeCoverage: () => getTypeCoverage
23
33
  });
24
34
  module.exports = __toCommonJS(type_exports);
35
+ var import_node_process = __toESM(require("node:process"));
25
36
  var import_spawn = require("../spawn");
26
37
  async function getTypeCoverage(options) {
27
38
  const opts = {
28
39
  __proto__: null,
29
- cwd: process.cwd(),
40
+ cwd: import_node_process.default.cwd(),
30
41
  generateIfMissing: false,
31
42
  ...options
32
43
  };
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var binary_exports = {};
21
31
  __export(binary_exports, {
@@ -31,6 +41,7 @@ __export(binary_exports, {
31
41
  writeBinaryCacheMetadata: () => writeBinaryCacheMetadata
32
42
  });
33
43
  module.exports = __toCommonJS(binary_exports);
44
+ var import_node_process = __toESM(require("node:process"));
34
45
  var import_platform = require("../constants/platform");
35
46
  var import_time = require("../constants/time");
36
47
  var import_cache = require("./cache");
@@ -120,7 +131,7 @@ async function dlxBinary(args, options, spawnExtra) {
120
131
  const path = /* @__PURE__ */ getPath();
121
132
  const force = yes === true ? true : userForce;
122
133
  const cacheDir = getDlxCachePath();
123
- const binaryName = name || `binary-${process.platform}-${(0, import_platform.getArch)()}`;
134
+ const binaryName = name || `binary-${import_node_process.default.platform}-${(0, import_platform.getArch)()}`;
124
135
  const spec = `${url}:${binaryName}`;
125
136
  const cacheKey = (0, import_cache.generateCacheKey)(spec);
126
137
  const cacheEntryDir = path.join(cacheDir, cacheKey);
@@ -189,7 +200,7 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
189
200
  ...spawnOptions,
190
201
  env: {
191
202
  ...spawnOptions?.env,
192
- PATH: `${cacheEntryDir}${(/* @__PURE__ */ getPath()).delimiter}${process.env["PATH"] || ""}`
203
+ PATH: `${cacheEntryDir}${(/* @__PURE__ */ getPath()).delimiter}${import_node_process.default.env["PATH"] || ""}`
193
204
  },
194
205
  shell: true
195
206
  } : spawnOptions;
@@ -212,7 +223,7 @@ async function downloadBinary(options) {
212
223
  const fs = /* @__PURE__ */ getFs();
213
224
  const path = /* @__PURE__ */ getPath();
214
225
  const cacheDir = getDlxCachePath();
215
- const binaryName = name || `binary-${process.platform}-${(0, import_platform.getArch)()}`;
226
+ const binaryName = name || `binary-${import_node_process.default.platform}-${(0, import_platform.getArch)()}`;
216
227
  const spec = `${url}:${binaryName}`;
217
228
  const cacheKey = (0, import_cache.generateCacheKey)(spec);
218
229
  const cacheEntryDir = path.join(cacheDir, cacheKey);
@@ -321,7 +332,7 @@ function executeBinary(binaryPath, args, spawnOptions, spawnExtra) {
321
332
  ...spawnOptions,
322
333
  env: {
323
334
  ...spawnOptions?.env,
324
- PATH: `${cacheEntryDir}${path.delimiter}${process.env["PATH"] || ""}`
335
+ PATH: `${cacheEntryDir}${path.delimiter}${import_node_process.default.env["PATH"] || ""}`
325
336
  },
326
337
  shell: true
327
338
  } : spawnOptions;
@@ -414,7 +425,7 @@ async function writeBinaryCacheMetadata(cacheEntryPath, cacheKey, url, integrity
414
425
  }
415
426
  };
416
427
  const fs = /* @__PURE__ */ getFs();
417
- const tmpPath = `${metaPath}.tmp.${process.pid}`;
428
+ const tmpPath = `${metaPath}.tmp.${import_node_process.default.pid}`;
418
429
  await fs.promises.writeFile(tmpPath, JSON.stringify(metadata, null, 2));
419
430
  await fs.promises.rename(tmpPath, metaPath);
420
431
  }
@@ -45,6 +45,8 @@ function getPath() {
45
45
  }
46
46
  return _path;
47
47
  }
48
+ const fs = /* @__PURE__ */ getFs();
49
+ const path = /* @__PURE__ */ getPath();
48
50
  const logger = (0, import_logger.getDefaultLogger)();
49
51
  const MANIFEST_FILE_NAME = ".dlx-manifest.json";
50
52
  function isBinaryEntry(entry) {
@@ -57,7 +59,7 @@ class DlxManifest {
57
59
  manifestPath;
58
60
  lockPath;
59
61
  constructor(options = {}) {
60
- this.manifestPath = options.manifestPath ?? (/* @__PURE__ */ getPath()).join((0, import_socket.getSocketDlxDir)(), MANIFEST_FILE_NAME);
62
+ this.manifestPath = options.manifestPath ?? path.join((0, import_socket.getSocketDlxDir)(), MANIFEST_FILE_NAME);
61
63
  this.lockPath = `${this.manifestPath}.lock`;
62
64
  }
63
65
  /**
@@ -66,7 +68,7 @@ class DlxManifest {
66
68
  */
67
69
  readManifest() {
68
70
  try {
69
- if (!(/* @__PURE__ */ getFs()).existsSync(this.manifestPath)) {
71
+ if (!fs.existsSync(this.manifestPath)) {
70
72
  return /* @__PURE__ */ Object.create(null);
71
73
  }
72
74
  const rawContent = (0, import_fs.readFileUtf8Sync)(this.manifestPath);
@@ -87,7 +89,7 @@ class DlxManifest {
87
89
  * @private
88
90
  */
89
91
  async writeManifest(data) {
90
- const manifestDir = (/* @__PURE__ */ getPath()).dirname(this.manifestPath);
92
+ const manifestDir = path.dirname(this.manifestPath);
91
93
  try {
92
94
  (0, import_fs.safeMkdirSync)(manifestDir, { recursive: true });
93
95
  } catch (error) {
@@ -98,18 +100,12 @@ class DlxManifest {
98
100
  const content = JSON.stringify(data, null, 2);
99
101
  const tempPath = `${this.manifestPath}.tmp`;
100
102
  try {
101
- (/* @__PURE__ */ getFs()).writeFileSync(tempPath, content, "utf8");
102
- (/* @__PURE__ */ getFs()).writeFileSync(this.manifestPath, content, "utf8");
103
- try {
104
- if ((/* @__PURE__ */ getFs()).existsSync(tempPath)) {
105
- (/* @__PURE__ */ getFs()).unlinkSync(tempPath);
106
- }
107
- } catch {
108
- }
103
+ fs.writeFileSync(tempPath, content, "utf8");
104
+ fs.renameSync(tempPath, this.manifestPath);
109
105
  } catch (error) {
110
106
  try {
111
- if ((/* @__PURE__ */ getFs()).existsSync(tempPath)) {
112
- (/* @__PURE__ */ getFs()).unlinkSync(tempPath);
107
+ if (fs.existsSync(tempPath)) {
108
+ fs.unlinkSync(tempPath);
113
109
  }
114
110
  } catch {
115
111
  }
@@ -122,17 +118,16 @@ class DlxManifest {
122
118
  async clear(name) {
123
119
  await import_process_lock.processLock.withLock(this.lockPath, async () => {
124
120
  try {
125
- if (!(/* @__PURE__ */ getFs()).existsSync(this.manifestPath)) {
121
+ if (!fs.existsSync(this.manifestPath)) {
126
122
  return;
127
123
  }
128
- const content = (/* @__PURE__ */ getFs()).readFileSync(this.manifestPath, "utf8");
124
+ const content = fs.readFileSync(this.manifestPath, "utf8");
129
125
  if (!content.trim()) {
130
126
  return;
131
127
  }
132
128
  const data = JSON.parse(content);
133
129
  delete data[name];
134
- const updatedContent = JSON.stringify(data, null, 2);
135
- (/* @__PURE__ */ getFs()).writeFileSync(this.manifestPath, updatedContent, "utf8");
130
+ await this.writeManifest(data);
136
131
  } catch (error) {
137
132
  logger.warn(
138
133
  `Failed to clear cache for ${name}: ${error instanceof Error ? error.message : String(error)}`
@@ -146,8 +141,8 @@ class DlxManifest {
146
141
  async clearAll() {
147
142
  await import_process_lock.processLock.withLock(this.lockPath, async () => {
148
143
  try {
149
- if ((/* @__PURE__ */ getFs()).existsSync(this.manifestPath)) {
150
- (/* @__PURE__ */ getFs()).unlinkSync(this.manifestPath);
144
+ if (fs.existsSync(this.manifestPath)) {
145
+ fs.unlinkSync(this.manifestPath);
151
146
  }
152
147
  } catch (error) {
153
148
  logger.warn(
@@ -173,7 +168,7 @@ class DlxManifest {
173
168
  */
174
169
  getAllPackages() {
175
170
  try {
176
- if (!(/* @__PURE__ */ getFs()).existsSync(this.manifestPath)) {
171
+ if (!fs.existsSync(this.manifestPath)) {
177
172
  return [];
178
173
  }
179
174
  const rawContent = (0, import_fs.readFileUtf8Sync)(this.manifestPath);
@@ -219,8 +214,8 @@ class DlxManifest {
219
214
  await import_process_lock.processLock.withLock(this.lockPath, async () => {
220
215
  let data = /* @__PURE__ */ Object.create(null);
221
216
  try {
222
- if ((/* @__PURE__ */ getFs()).existsSync(this.manifestPath)) {
223
- const content2 = (/* @__PURE__ */ getFs()).readFileSync(this.manifestPath, "utf8");
217
+ if (fs.existsSync(this.manifestPath)) {
218
+ const content2 = fs.readFileSync(this.manifestPath, "utf8");
224
219
  if (content2.trim()) {
225
220
  data = JSON.parse(content2);
226
221
  }
@@ -231,7 +226,7 @@ class DlxManifest {
231
226
  );
232
227
  }
233
228
  data[name] = record;
234
- const manifestDir = (/* @__PURE__ */ getPath()).dirname(this.manifestPath);
229
+ const manifestDir = path.dirname(this.manifestPath);
235
230
  try {
236
231
  (0, import_fs.safeMkdirSync)(manifestDir, { recursive: true });
237
232
  } catch (error) {
@@ -242,18 +237,12 @@ class DlxManifest {
242
237
  const content = JSON.stringify(data, null, 2);
243
238
  const tempPath = `${this.manifestPath}.tmp`;
244
239
  try {
245
- (/* @__PURE__ */ getFs()).writeFileSync(tempPath, content, "utf8");
246
- (/* @__PURE__ */ getFs()).writeFileSync(this.manifestPath, content, "utf8");
247
- try {
248
- if ((/* @__PURE__ */ getFs()).existsSync(tempPath)) {
249
- (/* @__PURE__ */ getFs()).unlinkSync(tempPath);
250
- }
251
- } catch {
252
- }
240
+ fs.writeFileSync(tempPath, content, "utf8");
241
+ fs.renameSync(tempPath, this.manifestPath);
253
242
  } catch (error) {
254
243
  try {
255
- if ((/* @__PURE__ */ getFs()).existsSync(tempPath)) {
256
- (/* @__PURE__ */ getFs()).unlinkSync(tempPath);
244
+ if (fs.existsSync(tempPath)) {
245
+ fs.unlinkSync(tempPath);
257
246
  }
258
247
  } catch {
259
248
  }