@socketsecurity/lib 3.4.0 → 4.0.0

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 (70) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +8 -8
  3. package/dist/agent.js +11 -24
  4. package/dist/bin.d.ts +97 -40
  5. package/dist/bin.js +129 -134
  6. package/dist/cacache.d.ts +5 -2
  7. package/dist/cacache.js +29 -18
  8. package/dist/cache-with-ttl.js +1 -1
  9. package/dist/constants/agents.d.ts +0 -4
  10. package/dist/constants/agents.js +13 -4
  11. package/dist/constants/node.d.ts +1 -0
  12. package/dist/constants/node.js +2 -5
  13. package/dist/constants/packages.js +22 -10
  14. package/dist/dlx-binary.js +9 -17
  15. package/dist/dlx-manifest.js +2 -2
  16. package/dist/dlx-package.js +22 -62
  17. package/dist/dlx.js +14 -14
  18. package/dist/fs.js +19 -24
  19. package/dist/git.d.ts +6 -6
  20. package/dist/git.js +11 -14
  21. package/dist/globs.js +16 -29
  22. package/dist/ipc.d.ts +4 -4
  23. package/dist/ipc.js +3 -3
  24. package/dist/logger.d.ts +0 -25
  25. package/dist/logger.js +0 -26
  26. package/dist/package-default-node-range.js +13 -3
  27. package/dist/package-extensions.d.ts +2 -1
  28. package/dist/package-extensions.js +12 -2
  29. package/dist/packages/editable.d.ts +0 -3
  30. package/dist/packages/editable.js +34 -24
  31. package/dist/packages/isolation.js +32 -32
  32. package/dist/packages/licenses.js +18 -32
  33. package/dist/packages/manifest.js +18 -33
  34. package/dist/packages/normalize.js +19 -43
  35. package/dist/packages/operations.js +33 -80
  36. package/dist/packages/provenance.js +14 -4
  37. package/dist/packages/specs.js +13 -12
  38. package/dist/packages/validation.js +12 -10
  39. package/dist/packages.d.ts +1 -1
  40. package/dist/packages.js +3 -3
  41. package/dist/paths/dirnames.d.ts +13 -0
  42. package/dist/paths/dirnames.js +50 -0
  43. package/dist/paths/exts.d.ts +18 -0
  44. package/dist/paths/exts.js +68 -0
  45. package/dist/paths/filenames.d.ts +16 -0
  46. package/dist/paths/filenames.js +62 -0
  47. package/dist/paths/globs.d.ts +10 -0
  48. package/dist/paths/globs.js +44 -0
  49. package/dist/{path.d.ts → paths/normalize.d.ts} +41 -0
  50. package/dist/{path.js → paths/normalize.js} +17 -4
  51. package/dist/{packages/paths.js → paths/packages.js} +8 -8
  52. package/dist/{paths.js → paths/socket.js} +29 -65
  53. package/dist/sea.js +2 -2
  54. package/dist/shadow.js +3 -3
  55. package/dist/sorts.js +12 -2
  56. package/dist/spawn.d.ts +15 -12
  57. package/dist/spawn.js +42 -30
  58. package/dist/spinner.d.ts +2 -6
  59. package/dist/spinner.js +6 -39
  60. package/dist/stdio/prompts.d.ts +8 -10
  61. package/dist/stdio/prompts.js +14 -12
  62. package/dist/streams.d.ts +0 -4
  63. package/dist/streams.js +3 -12
  64. package/dist/temporary-executor.js +3 -3
  65. package/dist/versions.js +31 -28
  66. package/package.json +28 -16
  67. package/dist/constants/paths.d.ts +0 -51
  68. package/dist/constants/paths.js +0 -152
  69. /package/dist/{packages/paths.d.ts → paths/packages.d.ts} +0 -0
  70. /package/dist/{paths.d.ts → paths/socket.d.ts} +0 -0
@@ -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 agents_exports = {};
21
31
  __export(agents_exports, {
@@ -44,6 +54,7 @@ __export(agents_exports, {
44
54
  YARN_LOCK: () => YARN_LOCK
45
55
  });
46
56
  module.exports = __toCommonJS(agents_exports);
57
+ var import_which = __toESM(require("../external/which"));
47
58
  const NPM = "npm";
48
59
  const PNPM = "pnpm";
49
60
  const YARN = "yarn";
@@ -52,8 +63,7 @@ const VLT = "vlt";
52
63
  const NPX = "npx";
53
64
  const NPM_BIN_PATH = /* @__PURE__ */ (() => {
54
65
  try {
55
- const which = require("../external/which");
56
- return which.sync("npm", { nothrow: true }) || "npm";
66
+ return import_which.default.sync("npm", { nothrow: true }) || "npm";
57
67
  } catch {
58
68
  return "npm";
59
69
  }
@@ -62,8 +72,7 @@ const NPM_REAL_EXEC_PATH = /* @__PURE__ */ (() => {
62
72
  try {
63
73
  const { existsSync } = require("node:fs");
64
74
  const path = require("node:path");
65
- const which = require("../external/which");
66
- const npmBin = which.sync("npm", { nothrow: true });
75
+ const npmBin = import_which.default.sync("npm", { nothrow: true });
67
76
  if (!npmBin) {
68
77
  return void 0;
69
78
  }
@@ -1,6 +1,7 @@
1
1
  // Version detection.
2
2
  export declare function getNodeVersion(): string;
3
3
  export declare function getNodeMajorVersion(): number;
4
+ // Maintained Node.js versions.
4
5
  export declare function getMaintainedNodeVersions(): readonly string[] & {
5
6
  current: string;
6
7
  last: string;
@@ -39,6 +39,7 @@ __export(node_exports, {
39
39
  supportsProcessSend: () => supportsProcessSend
40
40
  });
41
41
  module.exports = __toCommonJS(node_exports);
42
+ var import_maintained_node_versions = require("../maintained-node-versions");
42
43
  const NODE_VERSION = process.version;
43
44
  function getNodeVersion() {
44
45
  return NODE_VERSION;
@@ -46,12 +47,8 @@ function getNodeVersion() {
46
47
  function getNodeMajorVersion() {
47
48
  return Number.parseInt(NODE_VERSION.slice(1).split(".")[0] || "0", 10);
48
49
  }
49
- let _maintainedNodeVersions;
50
50
  function getMaintainedNodeVersions() {
51
- if (_maintainedNodeVersions === void 0) {
52
- _maintainedNodeVersions = require("#lib/maintained-node-versions").maintainedNodeVersions;
53
- }
54
- return _maintainedNodeVersions;
51
+ return import_maintained_node_versions.maintainedNodeVersions;
55
52
  }
56
53
  function supportsNodeCompileCacheApi() {
57
54
  const major = getNodeMajorVersion();
@@ -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 packages_exports = {};
21
31
  __export(packages_exports, {
@@ -33,6 +43,12 @@ __export(packages_exports, {
33
43
  });
34
44
  module.exports = __toCommonJS(packages_exports);
35
45
  var import_npm = require("#env/npm");
46
+ var import_lifecycle_script_names = require("../lifecycle-script-names");
47
+ var import_package_default_node_range = require("../package-default-node-range");
48
+ var import_package_default_socket_categories = require("../package-default-socket-categories");
49
+ var import_package_extensions = require("../package-extensions");
50
+ var import_pacote = __toESM(require("../external/pacote"));
51
+ var import_normalize = require("../paths/normalize");
36
52
  let _lifecycleScriptNames;
37
53
  let _packageDefaultNodeRange;
38
54
  let _packageDefaultSocketCategories;
@@ -46,22 +62,21 @@ const PACKAGE_DEFAULT_VERSION = "1.0.0";
46
62
  // @__NO_SIDE_EFFECTS__
47
63
  function getPackageDefaultNodeRange() {
48
64
  if (_packageDefaultNodeRange === void 0) {
49
- _packageDefaultNodeRange = require("#lib/package-default-node-range").packageDefaultNodeRange;
65
+ _packageDefaultNodeRange = import_package_default_node_range.packageDefaultNodeRange;
50
66
  }
51
67
  return _packageDefaultNodeRange;
52
68
  }
53
69
  // @__NO_SIDE_EFFECTS__
54
70
  function getPackageDefaultSocketCategories() {
55
71
  if (_packageDefaultSocketCategories === void 0) {
56
- _packageDefaultSocketCategories = require("#lib/package-default-socket-categories").packageDefaultSocketCategories;
72
+ _packageDefaultSocketCategories = import_package_default_socket_categories.packageDefaultSocketCategories;
57
73
  }
58
74
  return _packageDefaultSocketCategories;
59
75
  }
60
76
  // @__NO_SIDE_EFFECTS__
61
77
  function getPackageExtensions() {
62
78
  if (_packageExtensions === void 0) {
63
- const { packageExtensions } = require("#lib/package-extensions");
64
- _packageExtensions = Object.entries(packageExtensions);
79
+ _packageExtensions = Object.entries(import_package_extensions.packageExtensions);
65
80
  }
66
81
  return _packageExtensions;
67
82
  }
@@ -72,8 +87,7 @@ function getNpmLifecycleEvent() {
72
87
  // @__NO_SIDE_EFFECTS__
73
88
  function getLifecycleScriptNames() {
74
89
  if (_lifecycleScriptNames === void 0) {
75
- const { lifecycleScriptNames } = require("#lib/lifecycle-script-names");
76
- _lifecycleScriptNames = Array.from(lifecycleScriptNames);
90
+ _lifecycleScriptNames = Array.from(import_lifecycle_script_names.lifecycleScriptNames);
77
91
  }
78
92
  return _lifecycleScriptNames;
79
93
  }
@@ -88,10 +102,8 @@ function getPackumentCache() {
88
102
  function getPacoteCachePath() {
89
103
  if (_pacoteCachePath === void 0) {
90
104
  try {
91
- const pacote = require("../external/pacote");
92
- const { normalizePath } = require("#lib/path");
93
105
  const proto = Reflect.getPrototypeOf(
94
- pacote.RegistryFetcher.prototype
106
+ import_pacote.default.RegistryFetcher.prototype
95
107
  );
96
108
  const PacoteFetcherBase = proto?.constructor;
97
109
  const cachePath = PacoteFetcherBase ? new PacoteFetcherBase(
@@ -99,7 +111,7 @@ function getPacoteCachePath() {
99
111
  "x",
100
112
  {}
101
113
  ).cache : "";
102
- _pacoteCachePath = normalizePath(cachePath);
114
+ _pacoteCachePath = (0, import_normalize.normalizePath)(cachePath);
103
115
  } catch {
104
116
  _pacoteCachePath = "";
105
117
  }
@@ -41,13 +41,14 @@ var import_crypto = require("crypto");
41
41
  var import_os = __toESM(require("os"));
42
42
  var import_path = __toESM(require("path"));
43
43
  var import_platform = require("#constants/platform");
44
+ var import_time = require("#constants/time");
44
45
  var import_dlx = require("./dlx");
45
46
  var import_dlx_manifest = require("./dlx-manifest");
46
47
  var import_http_request = require("./http-request");
47
48
  var import_fs = require("./fs");
48
49
  var import_objects = require("./objects");
49
- var import_path2 = require("./path");
50
- var import_paths = require("./paths");
50
+ var import_normalize = require("./paths/normalize");
51
+ var import_socket = require("./paths/socket");
51
52
  var import_process_lock = require("./process-lock");
52
53
  var import_spawn = require("./spawn");
53
54
  let _fs;
@@ -165,10 +166,7 @@ async function writeMetadata(cacheEntryPath, cacheKey, url, binaryName, checksum
165
166
  } catch {
166
167
  }
167
168
  }
168
- async function cleanDlxCache(maxAge = (
169
- /*@__INLINE__*/
170
- require("#constants/time").DLX_BINARY_CACHE_TTL
171
- )) {
169
+ async function cleanDlxCache(maxAge = import_time.DLX_BINARY_CACHE_TTL) {
172
170
  const cacheDir = getDlxCachePath();
173
171
  const fs = /* @__PURE__ */ getFs();
174
172
  if (!fs.existsSync(cacheDir)) {
@@ -209,10 +207,7 @@ async function cleanDlxCache(maxAge = (
209
207
  }
210
208
  async function dlxBinary(args, options, spawnExtra) {
211
209
  const {
212
- cacheTtl = (
213
- /*@__INLINE__*/
214
- require("#constants/time").DLX_BINARY_CACHE_TTL
215
- ),
210
+ cacheTtl = import_time.DLX_BINARY_CACHE_TTL,
216
211
  checksum,
217
212
  force: userForce = false,
218
213
  name,
@@ -226,7 +221,7 @@ async function dlxBinary(args, options, spawnExtra) {
226
221
  const spec = `${url}:${binaryName}`;
227
222
  const cacheKey = (0, import_dlx.generateCacheKey)(spec);
228
223
  const cacheEntryDir = import_path.default.join(cacheDir, cacheKey);
229
- const binaryPath = (0, import_path2.normalizePath)(import_path.default.join(cacheEntryDir, binaryName));
224
+ const binaryPath = (0, import_normalize.normalizePath)(import_path.default.join(cacheEntryDir, binaryName));
230
225
  const fs = /* @__PURE__ */ getFs();
231
226
  let downloaded = false;
232
227
  let computedChecksum = checksum;
@@ -298,10 +293,7 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
298
293
  }
299
294
  async function downloadBinary(options) {
300
295
  const {
301
- cacheTtl = (
302
- /*@__INLINE__*/
303
- require("#constants/time").DLX_BINARY_CACHE_TTL
304
- ),
296
+ cacheTtl = import_time.DLX_BINARY_CACHE_TTL,
305
297
  checksum,
306
298
  force = false,
307
299
  name,
@@ -312,7 +304,7 @@ async function downloadBinary(options) {
312
304
  const spec = `${url}:${binaryName}`;
313
305
  const cacheKey = (0, import_dlx.generateCacheKey)(spec);
314
306
  const cacheEntryDir = import_path.default.join(cacheDir, cacheKey);
315
- const binaryPath = (0, import_path2.normalizePath)(import_path.default.join(cacheEntryDir, binaryName));
307
+ const binaryPath = (0, import_normalize.normalizePath)(import_path.default.join(cacheEntryDir, binaryName));
316
308
  const fs = /* @__PURE__ */ getFs();
317
309
  let downloaded = false;
318
310
  if (!force && fs.existsSync(cacheEntryDir) && await isCacheValid(cacheEntryDir, cacheTtl)) {
@@ -372,7 +364,7 @@ function executeBinary(binaryPath, args, spawnOptions, spawnExtra) {
372
364
  return (0, import_spawn.spawn)(binaryPath, args, finalSpawnOptions, spawnExtra);
373
365
  }
374
366
  function getDlxCachePath() {
375
- return (0, import_paths.getSocketDlxDir)();
367
+ return (0, import_socket.getSocketDlxDir)();
376
368
  }
377
369
  async function listDlxCache() {
378
370
  const cacheDir = getDlxCachePath();
@@ -39,7 +39,7 @@ var import_fs = require("fs");
39
39
  var import_path = __toESM(require("path"));
40
40
  var import_fs2 = require("./fs");
41
41
  var import_logger = require("./logger");
42
- var import_paths = require("./paths");
42
+ var import_socket = require("./paths/socket");
43
43
  var import_process_lock = require("./process-lock");
44
44
  const logger = (0, import_logger.getDefaultLogger)();
45
45
  const MANIFEST_FILE_NAME = ".dlx-manifest.json";
@@ -53,7 +53,7 @@ class DlxManifest {
53
53
  manifestPath;
54
54
  lockPath;
55
55
  constructor(options = {}) {
56
- this.manifestPath = options.manifestPath ?? import_path.default.join((0, import_paths.getSocketDlxDir)(), MANIFEST_FILE_NAME);
56
+ this.manifestPath = options.manifestPath ?? import_path.default.join((0, import_socket.getSocketDlxDir)(), MANIFEST_FILE_NAME);
57
57
  this.lockPath = `${this.manifestPath}.lock`;
58
58
  }
59
59
  /**
@@ -34,60 +34,24 @@ __export(dlx_package_exports, {
34
34
  executePackage: () => executePackage
35
35
  });
36
36
  module.exports = __toCommonJS(dlx_package_exports);
37
+ var import_node_fs = __toESM(require("node:fs"));
37
38
  var import_path = __toESM(require("path"));
38
39
  var import_platform = require("./constants/platform");
39
40
  var import_packages = require("./constants/packages");
40
41
  var import_dlx = require("./dlx");
42
+ var import_arborist = __toESM(require("./external/@npmcli/arborist"));
43
+ var import_libnpmexec = __toESM(require("./external/libnpmexec"));
44
+ var import_npm_package_arg = __toESM(require("./external/npm-package-arg"));
45
+ var import_pacote = __toESM(require("./external/pacote"));
41
46
  var import_fs = require("./fs");
42
- var import_path2 = require("./path");
43
- var import_paths = require("./paths");
47
+ var import_normalize = require("./paths/normalize");
48
+ var import_socket = require("./paths/socket");
44
49
  var import_process_lock = require("./process-lock");
45
50
  var import_spawn = require("./spawn");
46
- let _fs;
47
- // @__NO_SIDE_EFFECTS__
48
- function getFs() {
49
- if (_fs === void 0) {
50
- _fs = require("node:fs");
51
- }
52
- return _fs;
53
- }
54
- let _npmPackageArg;
55
- // @__NO_SIDE_EFFECTS__
56
- function getNpmPackageArg() {
57
- if (_npmPackageArg === void 0) {
58
- _npmPackageArg = require("./external/npm-package-arg.js");
59
- }
60
- return _npmPackageArg;
61
- }
62
- let _libnpmexec;
63
- // @__NO_SIDE_EFFECTS__
64
- function getLibnpmexec() {
65
- if (_libnpmexec === void 0) {
66
- _libnpmexec = require("./external/libnpmexec.js");
67
- }
68
- return _libnpmexec;
69
- }
70
- let _pacote;
71
- // @__NO_SIDE_EFFECTS__
72
- function getPacote() {
73
- if (_pacote === void 0) {
74
- _pacote = require("./external/pacote.js");
75
- }
76
- return _pacote;
77
- }
78
- let _arborist;
79
- // @__NO_SIDE_EFFECTS__
80
- function getArborist() {
81
- if (_arborist === void 0) {
82
- _arborist = require("./external/@npmcli/arborist.js");
83
- }
84
- return _arborist;
85
- }
86
51
  const rangeOperatorsRegExp = /[~^><=xX* ]|\|\|/;
87
52
  function parsePackageSpec(spec) {
88
53
  try {
89
- const npa = /* @__PURE__ */ getNpmPackageArg();
90
- const parsed = npa(spec);
54
+ const parsed = (0, import_npm_package_arg.default)(spec);
91
55
  const version = parsed.type === "tag" ? parsed.fetchSpec : parsed.type === "version" || parsed.type === "range" ? parsed.fetchSpec : void 0;
92
56
  return {
93
57
  name: parsed.name || spec,
@@ -106,8 +70,8 @@ function parsePackageSpec(spec) {
106
70
  }
107
71
  async function ensurePackageInstalled(packageName, packageSpec, force) {
108
72
  const cacheKey = (0, import_dlx.generateCacheKey)(packageSpec);
109
- const packageDir = (0, import_path2.normalizePath)(import_path.default.join((0, import_paths.getSocketDlxDir)(), cacheKey));
110
- const installedDir = (0, import_path2.normalizePath)(
73
+ const packageDir = (0, import_normalize.normalizePath)(import_path.default.join((0, import_socket.getSocketDlxDir)(), cacheKey));
74
+ const installedDir = (0, import_normalize.normalizePath)(
111
75
  import_path.default.join(packageDir, "node_modules", packageName)
112
76
  );
113
77
  try {
@@ -136,21 +100,19 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
136
100
  return await import_process_lock.processLock.withLock(
137
101
  lockPath,
138
102
  async () => {
139
- const fs = /* @__PURE__ */ getFs();
140
- if (!force && fs.existsSync(installedDir)) {
103
+ if (!force && import_node_fs.default.existsSync(installedDir)) {
141
104
  const pkgJsonPath = import_path.default.join(installedDir, "package.json");
142
- if (fs.existsSync(pkgJsonPath)) {
105
+ if (import_node_fs.default.existsSync(pkgJsonPath)) {
143
106
  return { installed: false, packageDir };
144
107
  }
145
108
  }
146
109
  const pacoteCachePath = (0, import_packages.getPacoteCachePath)();
147
110
  try {
148
- await (/* @__PURE__ */ getPacote()).extract(packageSpec, installedDir, {
111
+ await import_pacote.default.extract(packageSpec, installedDir, {
149
112
  // Use consistent pacote cache path (respects npm cache locations when available).
150
113
  cache: pacoteCachePath || import_path.default.join(packageDir, ".cache")
151
114
  });
152
- const Arborist = /* @__PURE__ */ getArborist();
153
- const arb = new Arborist({
115
+ const arb = new import_arborist.default({
154
116
  path: installedDir,
155
117
  cache: pacoteCachePath || import_path.default.join(packageDir, ".cache"),
156
118
  // Skip devDependencies (production-only like npx).
@@ -202,21 +164,20 @@ Check npm registry connectivity or package name.`,
202
164
  );
203
165
  }
204
166
  function resolveBinaryPath(basePath) {
205
- const fs = /* @__PURE__ */ getFs();
206
167
  if (!import_platform.WIN32) {
207
168
  return basePath;
208
169
  }
209
170
  const extensions = [".cmd", ".bat", ".ps1", ".exe", ""];
210
171
  for (const ext of extensions) {
211
172
  const testPath = basePath + ext;
212
- if (fs.existsSync(testPath)) {
173
+ if (import_node_fs.default.existsSync(testPath)) {
213
174
  return testPath;
214
175
  }
215
176
  }
216
177
  return basePath;
217
178
  }
218
179
  function findBinaryPath(packageDir, packageName, binaryName) {
219
- const installedDir = (0, import_path2.normalizePath)(
180
+ const installedDir = (0, import_normalize.normalizePath)(
220
181
  import_path.default.join(packageDir, "node_modules", packageName)
221
182
  );
222
183
  const pkgJsonPath = import_path.default.join(installedDir, "package.json");
@@ -234,7 +195,7 @@ function findBinaryPath(packageDir, packageName, binaryName) {
234
195
  binPath = binObj[binName];
235
196
  } else {
236
197
  try {
237
- const { getBinFromManifest } = /* @__PURE__ */ getLibnpmexec();
198
+ const { getBinFromManifest } = import_libnpmexec.default;
238
199
  binName = getBinFromManifest({
239
200
  name: packageName,
240
201
  bin: binObj,
@@ -265,7 +226,7 @@ function findBinaryPath(packageDir, packageName, binaryName) {
265
226
  if (!binPath) {
266
227
  throw new Error(`No binary found for package "${packageName}"`);
267
228
  }
268
- const rawPath = (0, import_path2.normalizePath)(import_path.default.join(installedDir, binPath));
229
+ const rawPath = (0, import_normalize.normalizePath)(import_path.default.join(installedDir, binPath));
269
230
  return resolveBinaryPath(rawPath);
270
231
  }
271
232
  async function dlxPackage(args, options, spawnExtra) {
@@ -285,8 +246,7 @@ function makePackageBinsExecutable(packageDir, packageName) {
285
246
  if (import_platform.WIN32) {
286
247
  return;
287
248
  }
288
- const fs = /* @__PURE__ */ getFs();
289
- const installedDir = (0, import_path2.normalizePath)(
249
+ const installedDir = (0, import_normalize.normalizePath)(
290
250
  import_path.default.join(packageDir, "node_modules", packageName)
291
251
  );
292
252
  const pkgJsonPath = import_path.default.join(installedDir, "package.json");
@@ -304,10 +264,10 @@ function makePackageBinsExecutable(packageDir, packageName) {
304
264
  binPaths.push(...Object.values(binObj));
305
265
  }
306
266
  for (const binPath of binPaths) {
307
- const fullPath = (0, import_path2.normalizePath)(import_path.default.join(installedDir, binPath));
308
- if (fs.existsSync(fullPath)) {
267
+ const fullPath = (0, import_normalize.normalizePath)(import_path.default.join(installedDir, binPath));
268
+ if (import_node_fs.default.existsSync(fullPath)) {
309
269
  try {
310
- fs.chmodSync(fullPath, 493);
270
+ import_node_fs.default.chmodSync(fullPath, 493);
311
271
  } catch {
312
272
  }
313
273
  }
package/dist/dlx.js CHANGED
@@ -41,8 +41,8 @@ __export(dlx_exports, {
41
41
  module.exports = __toCommonJS(dlx_exports);
42
42
  var import_crypto = require("crypto");
43
43
  var import_fs = require("./fs");
44
- var import_path = require("./path");
45
- var import_paths = require("./paths");
44
+ var import_normalize = require("./paths/normalize");
45
+ var import_socket = require("./paths/socket");
46
46
  var import_promises = require("./promises");
47
47
  let _fs;
48
48
  // @__NO_SIDE_EFFECTS__
@@ -75,50 +75,50 @@ function clearDlxSync() {
75
75
  }
76
76
  function dlxDirExists() {
77
77
  const fs = /* @__PURE__ */ getFs();
78
- return fs.existsSync((0, import_paths.getSocketDlxDir)());
78
+ return fs.existsSync((0, import_socket.getSocketDlxDir)());
79
79
  }
80
80
  async function dlxDirExistsAsync() {
81
81
  const fs = /* @__PURE__ */ getFs();
82
82
  try {
83
- await fs.promises.access((0, import_paths.getSocketDlxDir)());
83
+ await fs.promises.access((0, import_socket.getSocketDlxDir)());
84
84
  return true;
85
85
  } catch {
86
86
  return false;
87
87
  }
88
88
  }
89
89
  async function ensureDlxDir() {
90
- await (0, import_fs.safeMkdir)((0, import_paths.getSocketDlxDir)());
90
+ await (0, import_fs.safeMkdir)((0, import_socket.getSocketDlxDir)());
91
91
  }
92
92
  function ensureDlxDirSync() {
93
- (0, import_fs.safeMkdirSync)((0, import_paths.getSocketDlxDir)());
93
+ (0, import_fs.safeMkdirSync)((0, import_socket.getSocketDlxDir)());
94
94
  }
95
95
  function getDlxInstalledPackageDir(packageName) {
96
96
  const path = /* @__PURE__ */ getPath();
97
- return (0, import_path.normalizePath)(
97
+ return (0, import_normalize.normalizePath)(
98
98
  path.join(getDlxPackageNodeModulesDir(packageName), packageName)
99
99
  );
100
100
  }
101
101
  function getDlxPackageDir(packageName) {
102
102
  const path = /* @__PURE__ */ getPath();
103
- return (0, import_path.normalizePath)(path.join((0, import_paths.getSocketDlxDir)(), packageName));
103
+ return (0, import_normalize.normalizePath)(path.join((0, import_socket.getSocketDlxDir)(), packageName));
104
104
  }
105
105
  function getDlxPackageJsonPath(packageName) {
106
106
  const path = /* @__PURE__ */ getPath();
107
- return (0, import_path.normalizePath)(
107
+ return (0, import_normalize.normalizePath)(
108
108
  path.join(getDlxInstalledPackageDir(packageName), "package.json")
109
109
  );
110
110
  }
111
111
  function getDlxPackageNodeModulesDir(packageName) {
112
112
  const path = /* @__PURE__ */ getPath();
113
- return (0, import_path.normalizePath)(path.join(getDlxPackageDir(packageName), "node_modules"));
113
+ return (0, import_normalize.normalizePath)(path.join(getDlxPackageDir(packageName), "node_modules"));
114
114
  }
115
115
  function isInSocketDlx(filePath) {
116
116
  if (!filePath) {
117
117
  return false;
118
118
  }
119
119
  const path = /* @__PURE__ */ getPath();
120
- const dlxDir = (0, import_paths.getSocketDlxDir)();
121
- const absolutePath = (0, import_path.normalizePath)(path.resolve(filePath));
120
+ const dlxDir = (0, import_socket.getSocketDlxDir)();
121
+ const absolutePath = (0, import_normalize.normalizePath)(path.resolve(filePath));
122
122
  return absolutePath.startsWith(`${dlxDir}/`);
123
123
  }
124
124
  function isDlxPackageInstalled(packageName) {
@@ -136,7 +136,7 @@ async function isDlxPackageInstalledAsync(packageName) {
136
136
  }
137
137
  function listDlxPackages() {
138
138
  try {
139
- return (0, import_fs.readDirNamesSync)((0, import_paths.getSocketDlxDir)(), { sort: true });
139
+ return (0, import_fs.readDirNamesSync)((0, import_socket.getSocketDlxDir)(), { sort: true });
140
140
  } catch {
141
141
  return [];
142
142
  }
@@ -144,7 +144,7 @@ function listDlxPackages() {
144
144
  async function listDlxPackagesAsync() {
145
145
  const fs = /* @__PURE__ */ getFs();
146
146
  try {
147
- const entries = await fs.promises.readdir((0, import_paths.getSocketDlxDir)(), {
147
+ const entries = await fs.promises.readdir((0, import_socket.getSocketDlxDir)(), {
148
148
  withFileTypes: true
149
149
  });
150
150
  return entries.filter((e) => e.isDirectory()).map((e) => e.name).sort();
package/dist/fs.js CHANGED
@@ -50,11 +50,13 @@ __export(fs_exports, {
50
50
  module.exports = __toCommonJS(fs_exports);
51
51
  var import_process = require("#constants/process");
52
52
  var import_arrays = require("./arrays");
53
+ var import_del = require("./external/del");
53
54
  var import_globs = require("./globs");
54
55
  var import_json = require("./json");
55
56
  var import_objects = require("./objects");
56
- var import_path = require("./path");
57
+ var import_normalize = require("./paths/normalize");
57
58
  var import_rewire = require("./paths/rewire");
59
+ var import_socket = require("./paths/socket");
58
60
  var import_sorts = require("./sorts");
59
61
  const abortSignal = (0, import_process.getAbortSignal)();
60
62
  const defaultRemoveOptions = (0, import_objects.objectFreeze)({
@@ -131,10 +133,10 @@ async function findUp(name, options) {
131
133
  try {
132
134
  const stats = await fs.promises.stat(thePath);
133
135
  if (!onlyDirectories && stats.isFile()) {
134
- return (0, import_path.normalizePath)(thePath);
136
+ return (0, import_normalize.normalizePath)(thePath);
135
137
  }
136
138
  if (!onlyFiles && stats.isDirectory()) {
137
- return (0, import_path.normalizePath)(thePath);
139
+ return (0, import_normalize.normalizePath)(thePath);
138
140
  }
139
141
  } catch {
140
142
  }
@@ -172,10 +174,10 @@ function findUpSync(name, options) {
172
174
  try {
173
175
  const stats = fs.statSync(thePath);
174
176
  if (!onlyDirectories && stats.isFile()) {
175
- return (0, import_path.normalizePath)(thePath);
177
+ return (0, import_normalize.normalizePath)(thePath);
176
178
  }
177
179
  if (!onlyFiles && stats.isDirectory()) {
178
- return (0, import_path.normalizePath)(thePath);
180
+ return (0, import_normalize.normalizePath)(thePath);
179
181
  }
180
182
  } catch {
181
183
  }
@@ -187,10 +189,10 @@ function findUpSync(name, options) {
187
189
  try {
188
190
  const stats = fs.statSync(thePath);
189
191
  if (!onlyDirectories && stats.isFile()) {
190
- return (0, import_path.normalizePath)(thePath);
192
+ return (0, import_normalize.normalizePath)(thePath);
191
193
  }
192
194
  if (!onlyFiles && stats.isDirectory()) {
193
- return (0, import_path.normalizePath)(thePath);
195
+ return (0, import_normalize.normalizePath)(thePath);
194
196
  }
195
197
  } catch {
196
198
  }
@@ -223,7 +225,7 @@ function isDirEmptySync(dirname, options) {
223
225
  const matcher = (0, import_globs.getGlobMatcher)(
224
226
  ignore,
225
227
  {
226
- cwd: (0, import_path.pathLikeToString)(dirname)
228
+ cwd: (0, import_normalize.pathLikeToString)(dirname)
227
229
  }
228
230
  );
229
231
  let ignoredCount = 0;
@@ -425,15 +427,10 @@ let _cachedAllowedDirs;
425
427
  function getAllowedDirectories() {
426
428
  if (_cachedAllowedDirs === void 0) {
427
429
  const path = /* @__PURE__ */ getPath();
428
- const {
429
- getOsTmpDir,
430
- getSocketCacacheDir,
431
- getSocketUserDir
432
- } = require("#lib/paths");
433
430
  _cachedAllowedDirs = [
434
- path.resolve(getOsTmpDir()),
435
- path.resolve(getSocketCacacheDir()),
436
- path.resolve(getSocketUserDir())
431
+ path.resolve((0, import_socket.getOsTmpDir)()),
432
+ path.resolve((0, import_socket.getSocketCacacheDir)()),
433
+ path.resolve((0, import_socket.getSocketUserDir)())
437
434
  ];
438
435
  }
439
436
  return _cachedAllowedDirs;
@@ -443,9 +440,8 @@ function invalidatePathCache() {
443
440
  }
444
441
  (0, import_rewire.registerCacheInvalidation)(invalidatePathCache);
445
442
  async function safeDelete(filepath, options) {
446
- const { deleteAsync } = require("./external/del.js");
447
443
  const opts = { __proto__: null, ...options };
448
- const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_path.pathLikeToString) : [(0, import_path.pathLikeToString)(filepath)];
444
+ const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_normalize.pathLikeToString) : [(0, import_normalize.pathLikeToString)(filepath)];
449
445
  let shouldForce = opts.force !== false;
450
446
  if (!shouldForce && patterns.length > 0) {
451
447
  const path = /* @__PURE__ */ getPath();
@@ -466,7 +462,7 @@ async function safeDelete(filepath, options) {
466
462
  shouldForce = true;
467
463
  }
468
464
  }
469
- await deleteAsync(patterns, {
465
+ await (0, import_del.deleteAsync)(patterns, {
470
466
  concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
471
467
  dryRun: false,
472
468
  force: shouldForce,
@@ -474,9 +470,8 @@ async function safeDelete(filepath, options) {
474
470
  });
475
471
  }
476
472
  function safeDeleteSync(filepath, options) {
477
- const { deleteSync } = require("./external/del.js");
478
473
  const opts = { __proto__: null, ...options };
479
- const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_path.pathLikeToString) : [(0, import_path.pathLikeToString)(filepath)];
474
+ const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_normalize.pathLikeToString) : [(0, import_normalize.pathLikeToString)(filepath)];
480
475
  let shouldForce = opts.force !== false;
481
476
  if (!shouldForce && patterns.length > 0) {
482
477
  const path = /* @__PURE__ */ getPath();
@@ -497,7 +492,7 @@ function safeDeleteSync(filepath, options) {
497
492
  shouldForce = true;
498
493
  }
499
494
  }
500
- deleteSync(patterns, {
495
+ (0, import_del.deleteSync)(patterns, {
501
496
  concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
502
497
  dryRun: false,
503
498
  force: shouldForce,
@@ -581,7 +576,7 @@ function uniqueSync(filepath) {
581
576
  const path = /* @__PURE__ */ getPath();
582
577
  const filepathStr = String(filepath);
583
578
  if (!fs.existsSync(filepathStr)) {
584
- return (0, import_path.normalizePath)(filepathStr);
579
+ return (0, import_normalize.normalizePath)(filepathStr);
585
580
  }
586
581
  const dirname = path.dirname(filepathStr);
587
582
  const ext = path.extname(filepathStr);
@@ -592,7 +587,7 @@ function uniqueSync(filepath) {
592
587
  uniquePath = path.join(dirname, `${basename}-${counter}${ext}`);
593
588
  counter++;
594
589
  } while (fs.existsSync(uniquePath));
595
- return (0, import_path.normalizePath)(uniquePath);
590
+ return (0, import_normalize.normalizePath)(uniquePath);
596
591
  }
597
592
  async function writeJson(filepath, jsonContent, options) {
598
593
  const opts = typeof options === "string" ? { encoding: options } : options;