@socketsecurity/lib 5.2.1 → 5.4.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 (60) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/bin.d.ts +0 -9
  3. package/dist/bin.js +70 -48
  4. package/dist/constants/agents.js +2 -2
  5. package/dist/constants/platform.d.ts +21 -0
  6. package/dist/constants/platform.js +30 -6
  7. package/dist/cover/code.js +13 -5
  8. package/dist/debug.js +1 -1
  9. package/dist/dlx/binary.d.ts +1 -1
  10. package/dist/dlx/binary.js +49 -39
  11. package/dist/dlx/cache.js +10 -2
  12. package/dist/dlx/dir.js +1 -1
  13. package/dist/dlx/manifest.d.ts +2 -1
  14. package/dist/dlx/manifest.js +45 -41
  15. package/dist/dlx/package.js +39 -19
  16. package/dist/dlx/packages.js +1 -1
  17. package/dist/dlx/paths.js +1 -1
  18. package/dist/env/rewire.js +10 -2
  19. package/dist/external/@inquirer/checkbox.js +4 -2528
  20. package/dist/external/@inquirer/confirm.js +4 -2371
  21. package/dist/external/@inquirer/input.js +4 -2395
  22. package/dist/external/@inquirer/password.js +4 -2503
  23. package/dist/external/@inquirer/search.js +4 -2500
  24. package/dist/external/@inquirer/select.js +4 -2617
  25. package/dist/external/del.js +4 -7139
  26. package/dist/external/fast-glob.js +4 -5776
  27. package/dist/external/inquirer-pack.js +4610 -0
  28. package/dist/external/npm-core.js +3 -1
  29. package/dist/external/pico-pack.js +7162 -0
  30. package/dist/external/picomatch.js +4 -1523
  31. package/dist/external/spdx-correct.js +4 -1384
  32. package/dist/external/spdx-expression-parse.js +4 -1047
  33. package/dist/external/spdx-pack.js +1640 -0
  34. package/dist/external/validate-npm-package-name.js +4 -104
  35. package/dist/fs.js +3 -3
  36. package/dist/git.js +41 -38
  37. package/dist/http-request.js +12 -4
  38. package/dist/ipc.js +53 -29
  39. package/dist/json/edit.js +1 -1
  40. package/dist/json/format.js +1 -1
  41. package/dist/logger.js +1 -1
  42. package/dist/packages/edit.js +3 -3
  43. package/dist/packages/isolation.js +45 -23
  44. package/dist/packages/licenses.js +10 -2
  45. package/dist/paths/normalize.js +3 -3
  46. package/dist/paths/packages.js +1 -1
  47. package/dist/paths/socket.d.ts +2 -2
  48. package/dist/paths/socket.js +27 -21
  49. package/dist/process-lock.js +23 -14
  50. package/dist/promises.js +1 -1
  51. package/dist/releases/github.d.ts +82 -137
  52. package/dist/releases/github.js +91 -48
  53. package/dist/releases/socket-btm.d.ts +78 -192
  54. package/dist/releases/socket-btm.js +112 -50
  55. package/dist/signal-exit.js +1 -1
  56. package/dist/spawn.js +11 -4
  57. package/dist/stdio/mask.d.ts +6 -21
  58. package/dist/stdio/mask.js +18 -14
  59. package/dist/themes/context.js +10 -2
  60. package/package.json +3 -2
@@ -32,14 +32,28 @@ __export(isolation_exports, {
32
32
  isolatePackage: () => isolatePackage
33
33
  });
34
34
  module.exports = __toCommonJS(isolation_exports);
35
- var import_fs = require("fs");
36
35
  var import_platform = require("../constants/platform");
37
- var import_node_path = __toESM(require("node:path"));
38
36
  var import_npm_package_arg = __toESM(require("../external/npm-package-arg"));
39
37
  var import_spawn = require("../spawn");
40
38
  var import_normalize = require("../paths/normalize");
41
39
  var import_operations = require("./operations");
42
40
  var import_socket = require("../paths/socket");
41
+ let _fs;
42
+ // @__NO_SIDE_EFFECTS__
43
+ function getFs() {
44
+ if (_fs === void 0) {
45
+ _fs = require("fs");
46
+ }
47
+ return _fs;
48
+ }
49
+ let _path;
50
+ // @__NO_SIDE_EFFECTS__
51
+ function getPath() {
52
+ if (_path === void 0) {
53
+ _path = require("path");
54
+ }
55
+ return _path;
56
+ }
43
57
  const FS_CP_OPTIONS = {
44
58
  dereference: true,
45
59
  errorOnExist: false,
@@ -49,14 +63,19 @@ const FS_CP_OPTIONS = {
49
63
  ...import_platform.WIN32 ? { maxRetries: 3, retryDelay: 100 } : {}
50
64
  };
51
65
  async function resolveRealPath(pathStr) {
52
- return await import_fs.promises.realpath(pathStr).catch(() => import_node_path.default.resolve(pathStr));
66
+ const fs = /* @__PURE__ */ getFs();
67
+ const path = /* @__PURE__ */ getPath();
68
+ return await fs.promises.realpath(pathStr).catch(() => path.resolve(pathStr));
53
69
  }
54
70
  async function mergePackageJson(pkgJsonPath, originalPkgJson) {
55
- const pkgJson = JSON.parse(await import_fs.promises.readFile(pkgJsonPath, "utf8"));
71
+ const fs = /* @__PURE__ */ getFs();
72
+ const pkgJson = JSON.parse(await fs.promises.readFile(pkgJsonPath, "utf8"));
56
73
  const mergedPkgJson = originalPkgJson ? { ...originalPkgJson, ...pkgJson } : pkgJson;
57
74
  return mergedPkgJson;
58
75
  }
59
76
  async function isolatePackage(packageSpec, options) {
77
+ const fs = /* @__PURE__ */ getFs();
78
+ const path = /* @__PURE__ */ getPath();
60
79
  const opts = { __proto__: null, ...options };
61
80
  const { imports, install, onPackageJson, sourcePath: optSourcePath } = opts;
62
81
  let sourcePath = optSourcePath;
@@ -65,8 +84,8 @@ async function isolatePackage(packageSpec, options) {
65
84
  if ((0, import_normalize.isPath)(packageSpec)) {
66
85
  const trimmedPath = (0, import_normalize.trimLeadingDotSlash)(packageSpec);
67
86
  const pathToResolve = (0, import_normalize.isAbsolute)(trimmedPath) ? trimmedPath : packageSpec;
68
- sourcePath = import_node_path.default.resolve(pathToResolve);
69
- if (!(0, import_fs.existsSync)(sourcePath)) {
87
+ sourcePath = path.resolve(pathToResolve);
88
+ if (!fs.existsSync(sourcePath)) {
70
89
  throw new Error(`Source path does not exist: ${sourcePath}`);
71
90
  }
72
91
  const pkgJson = await (0, import_operations.readPackageJson)(sourcePath, { normalize: true });
@@ -79,7 +98,7 @@ async function isolatePackage(packageSpec, options) {
79
98
  packageName = parsed.name;
80
99
  if (parsed.type === "directory" || parsed.type === "file") {
81
100
  sourcePath = parsed.fetchSpec;
82
- if (!sourcePath || !(0, import_fs.existsSync)(sourcePath)) {
101
+ if (!sourcePath || !fs.existsSync(sourcePath)) {
83
102
  throw new Error(`Source path does not exist: ${sourcePath}`);
84
103
  }
85
104
  if (!packageName) {
@@ -97,16 +116,16 @@ async function isolatePackage(packageSpec, options) {
97
116
  throw new Error(`Could not determine package name from: ${packageSpec}`);
98
117
  }
99
118
  const sanitizedName = packageName.replace(/[@/]/g, "-");
100
- const tempDir = await import_fs.promises.mkdtemp(
101
- import_node_path.default.join((0, import_socket.getOsTmpDir)(), `socket-test-${sanitizedName}-`)
119
+ const tempDir = await fs.promises.mkdtemp(
120
+ path.join((0, import_socket.getOsTmpDir)(), `socket-test-${sanitizedName}-`)
102
121
  );
103
- const packageTempDir = import_node_path.default.join(tempDir, sanitizedName);
104
- await import_fs.promises.mkdir(packageTempDir, { recursive: true });
122
+ const packageTempDir = path.join(tempDir, sanitizedName);
123
+ await fs.promises.mkdir(packageTempDir, { recursive: true });
105
124
  let installedPath;
106
125
  let originalPackageJson;
107
126
  if (spec) {
108
- await import_fs.promises.writeFile(
109
- import_node_path.default.join(packageTempDir, "package.json"),
127
+ await fs.promises.writeFile(
128
+ path.join(packageTempDir, "package.json"),
110
129
  JSON.stringify(
111
130
  {
112
131
  name: "test-temp",
@@ -127,7 +146,7 @@ async function isolatePackage(packageSpec, options) {
127
146
  stdio: "pipe"
128
147
  });
129
148
  }
130
- installedPath = import_node_path.default.join(packageTempDir, "node_modules", packageName);
149
+ installedPath = path.join(packageTempDir, "node_modules", packageName);
131
150
  originalPackageJson = await (0, import_operations.readPackageJson)(installedPath, {
132
151
  normalize: true
133
152
  });
@@ -135,30 +154,33 @@ async function isolatePackage(packageSpec, options) {
135
154
  const realInstalledPath = await resolveRealPath(installedPath);
136
155
  const realSourcePath = await resolveRealPath(sourcePath);
137
156
  if (realSourcePath !== realInstalledPath) {
138
- await import_fs.promises.cp(sourcePath, installedPath, FS_CP_OPTIONS);
157
+ await fs.promises.cp(sourcePath, installedPath, FS_CP_OPTIONS);
139
158
  }
140
159
  }
141
160
  } else {
142
161
  if (!sourcePath) {
143
162
  throw new Error("sourcePath is required when no version spec provided");
144
163
  }
145
- const scopedPath = packageName.startsWith("@") ? import_node_path.default.join(
164
+ const scopedPath = packageName.startsWith("@") ? path.join(
146
165
  packageTempDir,
147
166
  "node_modules",
148
167
  packageName.split("/")[0] ?? ""
149
- ) : import_node_path.default.join(packageTempDir, "node_modules");
150
- await import_fs.promises.mkdir(scopedPath, { recursive: true });
151
- installedPath = import_node_path.default.join(packageTempDir, "node_modules", packageName);
152
- await import_fs.promises.cp(sourcePath, installedPath, FS_CP_OPTIONS);
168
+ ) : path.join(packageTempDir, "node_modules");
169
+ await fs.promises.mkdir(scopedPath, { recursive: true });
170
+ installedPath = path.join(packageTempDir, "node_modules", packageName);
171
+ await fs.promises.cp(sourcePath, installedPath, FS_CP_OPTIONS);
153
172
  }
154
173
  if (onPackageJson || originalPackageJson) {
155
- const pkgJsonPath = import_node_path.default.join(installedPath, "package.json");
174
+ const pkgJsonPath = path.join(installedPath, "package.json");
156
175
  const mergedPkgJson = await mergePackageJson(
157
176
  pkgJsonPath,
158
177
  originalPackageJson
159
178
  );
160
179
  const finalPkgJson = onPackageJson ? await onPackageJson(mergedPkgJson) : mergedPkgJson;
161
- await import_fs.promises.writeFile(pkgJsonPath, JSON.stringify(finalPkgJson, null, 2));
180
+ await fs.promises.writeFile(
181
+ pkgJsonPath,
182
+ JSON.stringify(finalPkgJson, null, 2)
183
+ );
162
184
  }
163
185
  if (install) {
164
186
  await install(installedPath);
@@ -172,7 +194,7 @@ async function isolatePackage(packageSpec, options) {
172
194
  const exports2 = imports ? { __proto__: null } : void 0;
173
195
  if (imports) {
174
196
  for (const { 0: key, 1: specifier } of Object.entries(imports)) {
175
- const fullPath = import_node_path.default.join(installedPath, specifier);
197
+ const fullPath = path.join(installedPath, specifier);
176
198
  exports2[key] = require(fullPath);
177
199
  }
178
200
  }
@@ -41,12 +41,19 @@ __export(licenses_exports, {
41
41
  module.exports = __toCommonJS(licenses_exports);
42
42
  var import_core = require("../constants/core");
43
43
  var import_licenses = require("../constants/licenses");
44
- var import_node_path = __toESM(require("node:path"));
45
44
  var import_spdx_correct = __toESM(require("../external/spdx-correct"));
46
45
  var import_spdx_expression_parse = __toESM(require("../external/spdx-expression-parse"));
47
46
  var import_objects = require("../objects");
48
47
  var import_normalize = require("../paths/normalize");
49
48
  const copyLeftLicenses = (0, import_licenses.getCopyLeftLicenses)();
49
+ let _path;
50
+ // @__NO_SIDE_EFFECTS__
51
+ function getPath() {
52
+ if (_path === void 0) {
53
+ _path = require("path");
54
+ }
55
+ return _path;
56
+ }
50
57
  const BINARY_OPERATION_NODE_TYPE = "BinaryOperation";
51
58
  const LICENSE_NODE_TYPE = "License";
52
59
  const fileReferenceRegExp = /^SEE LICEN[CS]E IN (.+)$/;
@@ -133,10 +140,11 @@ function resolvePackageLicenses(licenseFieldValue, where) {
133
140
  }
134
141
  const match = fileReferenceRegExp.exec(licenseFieldValue);
135
142
  if (match) {
143
+ const path = /* @__PURE__ */ getPath();
136
144
  return [
137
145
  {
138
146
  license: licenseFieldValue,
139
- inFile: (0, import_normalize.normalizePath)(import_node_path.default.relative(where, match[1] || ""))
147
+ inFile: (0, import_normalize.normalizePath)(path.relative(where, match[1] || ""))
140
148
  }
141
149
  ];
142
150
  }
@@ -54,7 +54,7 @@ let _buffer;
54
54
  // @__NO_SIDE_EFFECTS__
55
55
  function getBuffer() {
56
56
  if (_buffer === void 0) {
57
- _buffer = require("node:buffer");
57
+ _buffer = require("buffer");
58
58
  }
59
59
  return _buffer;
60
60
  }
@@ -62,7 +62,7 @@ let _url;
62
62
  // @__NO_SIDE_EFFECTS__
63
63
  function getUrl() {
64
64
  if (_url === void 0) {
65
- _url = require("node:url");
65
+ _url = require("url");
66
66
  }
67
67
  return _url;
68
68
  }
@@ -351,7 +351,7 @@ function resolve(...segments) {
351
351
  resolvedAbsolute = /* @__PURE__ */ isAbsolute(segment);
352
352
  }
353
353
  if (!resolvedAbsolute) {
354
- const cwd = /* @__PURE__ */ require("node:process").cwd();
354
+ const cwd = /* @__PURE__ */ require("process").cwd();
355
355
  resolvedPath = cwd + (resolvedPath.length === 0 ? "" : `/${resolvedPath}`);
356
356
  }
357
357
  return /* @__PURE__ */ normalizePath(resolvedPath);
@@ -28,7 +28,7 @@ let _path;
28
28
  // @__NO_SIDE_EFFECTS__
29
29
  function getPath() {
30
30
  if (_path === void 0) {
31
- _path = require("node:path");
31
+ _path = require("path");
32
32
  }
33
33
  return _path;
34
34
  }
@@ -81,7 +81,7 @@ export declare function getSocketRegistryGithubCacheDir(): string;
81
81
  * Priority order:
82
82
  * 1. HOME environment variable (Unix)
83
83
  * 2. USERPROFILE environment variable (Windows)
84
- * 3. os.homedir()
85
- * 4. Fallback: os.tmpdir() (rarely used, for restricted environments)
84
+ * 3. getOs().homedir()
85
+ * 4. Fallback: getOs().tmpdir() (rarely used, for restricted environments)
86
86
  */
87
87
  export declare function getUserHomeDir(): string;
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
- var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
7
  var __export = (target, all) => {
10
8
  for (var name in all)
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
18
16
  }
19
17
  return to;
20
18
  };
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
- ));
29
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
20
  var socket_exports = {};
31
21
  __export(socket_exports, {
@@ -44,8 +34,6 @@ __export(socket_exports, {
44
34
  getUserHomeDir: () => getUserHomeDir
45
35
  });
46
36
  module.exports = __toCommonJS(socket_exports);
47
- var os = __toESM(require("os"));
48
- var path = __toESM(require("path"));
49
37
  var import_github = require("../constants/github");
50
38
  var import_socket = require("../constants/socket");
51
39
  var import_home = require("../env/home");
@@ -54,11 +42,27 @@ var import_windows = require("../env/windows");
54
42
  var import_dirnames = require("./dirnames");
55
43
  var import_normalize = require("./normalize");
56
44
  var import_rewire = require("./rewire");
45
+ let _os;
46
+ // @__NO_SIDE_EFFECTS__
47
+ function getOs() {
48
+ if (_os === void 0) {
49
+ _os = require("os");
50
+ }
51
+ return _os;
52
+ }
53
+ let _path;
54
+ // @__NO_SIDE_EFFECTS__
55
+ function getPath() {
56
+ if (_path === void 0) {
57
+ _path = require("path");
58
+ }
59
+ return _path;
60
+ }
57
61
  function getOsHomeDir() {
58
- return (0, import_rewire.getPathValue)("homedir", () => os.homedir());
62
+ return (0, import_rewire.getPathValue)("homedir", () => (/* @__PURE__ */ getOs()).homedir());
59
63
  }
60
64
  function getOsTmpDir() {
61
- return (0, import_rewire.getPathValue)("tmpdir", () => os.tmpdir());
65
+ return (0, import_rewire.getPathValue)("tmpdir", () => (/* @__PURE__ */ getOs()).tmpdir());
62
66
  }
63
67
  function getSocketHomePath() {
64
68
  return getSocketUserDir();
@@ -69,12 +73,12 @@ function getSocketUserDir() {
69
73
  if (socketHome) {
70
74
  return (0, import_normalize.normalizePath)(socketHome);
71
75
  }
72
- return (0, import_normalize.normalizePath)(path.join(getUserHomeDir(), import_dirnames.DOT_SOCKET_DIR));
76
+ return (0, import_normalize.normalizePath)((/* @__PURE__ */ getPath()).join(getUserHomeDir(), import_dirnames.DOT_SOCKET_DIR));
73
77
  });
74
78
  }
75
79
  function getSocketAppDir(appName) {
76
80
  return (0, import_normalize.normalizePath)(
77
- path.join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}${appName}`)
81
+ (/* @__PURE__ */ getPath()).join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}${appName}`)
78
82
  );
79
83
  }
80
84
  function getSocketCacacheDir() {
@@ -83,7 +87,7 @@ function getSocketCacacheDir() {
83
87
  return (0, import_normalize.normalizePath)((0, import_socket2.getSocketCacacheDir)());
84
88
  }
85
89
  return (0, import_normalize.normalizePath)(
86
- path.join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}cacache`)
90
+ (/* @__PURE__ */ getPath()).join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}cacache`)
87
91
  );
88
92
  });
89
93
  }
@@ -93,7 +97,7 @@ function getSocketDlxDir() {
93
97
  return (0, import_normalize.normalizePath)((0, import_socket2.getSocketDlxDirEnv)());
94
98
  }
95
99
  return (0, import_normalize.normalizePath)(
96
- path.join(
100
+ (/* @__PURE__ */ getPath()).join(
97
101
  getSocketUserDir(),
98
102
  `${import_socket.SOCKET_APP_PREFIX}${import_socket.SOCKET_DLX_APP_NAME}`
99
103
  )
@@ -101,10 +105,12 @@ function getSocketDlxDir() {
101
105
  });
102
106
  }
103
107
  function getSocketAppCacheDir(appName) {
104
- return (0, import_normalize.normalizePath)(path.join(getSocketAppDir(appName), import_dirnames.CACHE_DIR));
108
+ return (0, import_normalize.normalizePath)((/* @__PURE__ */ getPath()).join(getSocketAppDir(appName), import_dirnames.CACHE_DIR));
105
109
  }
106
110
  function getSocketAppCacheTtlDir(appName) {
107
- return (0, import_normalize.normalizePath)(path.join(getSocketAppCacheDir(appName), import_dirnames.CACHE_TTL_DIR));
111
+ return (0, import_normalize.normalizePath)(
112
+ (/* @__PURE__ */ getPath()).join(getSocketAppCacheDir(appName), import_dirnames.CACHE_TTL_DIR)
113
+ );
108
114
  }
109
115
  function getSocketCliDir() {
110
116
  return getSocketAppDir(import_socket.SOCKET_CLI_APP_NAME);
@@ -114,7 +120,7 @@ function getSocketRegistryDir() {
114
120
  }
115
121
  function getSocketRegistryGithubCacheDir() {
116
122
  return (0, import_normalize.normalizePath)(
117
- path.join(
123
+ (/* @__PURE__ */ getPath()).join(
118
124
  getSocketAppCacheTtlDir(import_socket.SOCKET_REGISTRY_APP_NAME),
119
125
  import_github.CACHE_GITHUB_DIR
120
126
  )
@@ -22,11 +22,20 @@ __export(process_lock_exports, {
22
22
  processLock: () => processLock
23
23
  });
24
24
  module.exports = __toCommonJS(process_lock_exports);
25
- var import_fs = require("fs");
26
- var import_fs2 = require("./fs");
25
+ var import_fs = require("./fs");
27
26
  var import_logger = require("./logger");
28
27
  var import_promises = require("./promises");
29
28
  var import_signal_exit = require("./signal-exit");
29
+ let _fs;
30
+ // @__NO_SIDE_EFFECTS__
31
+ function getFs() {
32
+ if (_fs === void 0) {
33
+ _fs = require("fs");
34
+ }
35
+ return _fs;
36
+ }
37
+ const fs = /* @__PURE__ */ getFs();
38
+ const { existsSync, mkdirSync, statSync, utimesSync } = fs;
30
39
  const logger = (0, import_logger.getDefaultLogger)();
31
40
  class ProcessLockManager {
32
41
  activeLocks = /* @__PURE__ */ new Set();
@@ -47,8 +56,8 @@ class ProcessLockManager {
47
56
  this.touchTimers.clear();
48
57
  for (const lockPath of this.activeLocks) {
49
58
  try {
50
- if ((0, import_fs.existsSync)(lockPath)) {
51
- (0, import_fs2.safeDeleteSync)(lockPath, { recursive: true });
59
+ if (existsSync(lockPath)) {
60
+ (0, import_fs.safeDeleteSync)(lockPath, { recursive: true });
52
61
  }
53
62
  } catch {
54
63
  }
@@ -64,9 +73,9 @@ class ProcessLockManager {
64
73
  */
65
74
  touchLock(lockPath) {
66
75
  try {
67
- if ((0, import_fs.existsSync)(lockPath)) {
76
+ if (existsSync(lockPath)) {
68
77
  const now = /* @__PURE__ */ new Date();
69
- (0, import_fs.utimesSync)(lockPath, now, now);
78
+ utimesSync(lockPath, now, now);
70
79
  }
71
80
  } catch (error) {
72
81
  logger.warn(
@@ -114,10 +123,10 @@ class ProcessLockManager {
114
123
  */
115
124
  isStale(lockPath, staleMs) {
116
125
  try {
117
- if (!(0, import_fs.existsSync)(lockPath)) {
126
+ if (!existsSync(lockPath)) {
118
127
  return false;
119
128
  }
120
- const stats = (0, import_fs.statSync)(lockPath);
129
+ const stats = statSync(lockPath);
121
130
  const ageSeconds = Math.floor((Date.now() - stats.mtime.getTime()) / 1e3);
122
131
  const staleSeconds = Math.floor(staleMs / 1e3);
123
132
  return ageSeconds > staleSeconds;
@@ -160,17 +169,17 @@ class ProcessLockManager {
160
169
  return await (0, import_promises.pRetry)(
161
170
  async () => {
162
171
  try {
163
- if ((0, import_fs.existsSync)(lockPath) && this.isStale(lockPath, staleMs)) {
172
+ if (existsSync(lockPath) && this.isStale(lockPath, staleMs)) {
164
173
  logger.log(`Removing stale lock: ${lockPath}`);
165
174
  try {
166
- (0, import_fs2.safeDeleteSync)(lockPath, { recursive: true });
175
+ (0, import_fs.safeDeleteSync)(lockPath, { recursive: true });
167
176
  } catch {
168
177
  }
169
178
  }
170
- if ((0, import_fs.existsSync)(lockPath)) {
179
+ if (existsSync(lockPath)) {
171
180
  throw new Error(`Lock already exists: ${lockPath}`);
172
181
  }
173
- (0, import_fs.mkdirSync)(lockPath, { recursive: true });
182
+ mkdirSync(lockPath, { recursive: true });
174
183
  this.activeLocks.add(lockPath);
175
184
  this.startTouchTimer(lockPath, touchIntervalMs);
176
185
  return () => this.release(lockPath);
@@ -246,8 +255,8 @@ To resolve:
246
255
  release(lockPath) {
247
256
  this.stopTouchTimer(lockPath);
248
257
  try {
249
- if ((0, import_fs.existsSync)(lockPath)) {
250
- (0, import_fs2.safeDeleteSync)(lockPath, { recursive: true });
258
+ if (existsSync(lockPath)) {
259
+ (0, import_fs.safeDeleteSync)(lockPath, { recursive: true });
251
260
  }
252
261
  this.activeLocks.delete(lockPath);
253
262
  } catch (error) {
package/dist/promises.js CHANGED
@@ -37,7 +37,7 @@ let _timers;
37
37
  // @__NO_SIDE_EFFECTS__
38
38
  function getTimers() {
39
39
  if (_timers === void 0) {
40
- _timers = require("node:timers/promises");
40
+ _timers = require("timers/promises");
41
41
  }
42
42
  return _timers;
43
43
  }