@socketsecurity/lib 5.2.0 → 5.3.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.
@@ -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 binary_exports = {};
31
21
  __export(binary_exports, {
@@ -37,9 +27,6 @@ __export(binary_exports, {
37
27
  listDlxCache: () => listDlxCache
38
28
  });
39
29
  module.exports = __toCommonJS(binary_exports);
40
- var import_crypto = require("crypto");
41
- var import_os = __toESM(require("os"));
42
- var import_path = __toESM(require("path"));
43
30
  var import_platform = require("../constants/platform");
44
31
  var import_time = require("../constants/time");
45
32
  var import_cache = require("./cache");
@@ -51,16 +38,32 @@ var import_normalize = require("../paths/normalize");
51
38
  var import_socket = require("../paths/socket");
52
39
  var import_process_lock = require("../process-lock");
53
40
  var import_spawn = require("../spawn");
41
+ let _crypto;
42
+ // @__NO_SIDE_EFFECTS__
43
+ function getCrypto() {
44
+ if (_crypto === void 0) {
45
+ _crypto = require("crypto");
46
+ }
47
+ return _crypto;
48
+ }
54
49
  let _fs;
55
50
  // @__NO_SIDE_EFFECTS__
56
51
  function getFs() {
57
52
  if (_fs === void 0) {
58
- _fs = require("node:fs");
53
+ _fs = require("fs");
59
54
  }
60
55
  return _fs;
61
56
  }
57
+ let _path;
58
+ // @__NO_SIDE_EFFECTS__
59
+ function getPath() {
60
+ if (_path === void 0) {
61
+ _path = require("path");
62
+ }
63
+ return _path;
64
+ }
62
65
  function getMetadataPath(cacheEntryPath) {
63
- return import_path.default.join(cacheEntryPath, ".dlx-metadata.json");
66
+ return (/* @__PURE__ */ getPath()).join(cacheEntryPath, ".dlx-metadata.json");
64
67
  }
65
68
  async function isCacheValid(cacheEntryPath, cacheTtl) {
66
69
  const fs = /* @__PURE__ */ getFs();
@@ -85,17 +88,19 @@ async function isCacheValid(cacheEntryPath, cacheTtl) {
85
88
  }
86
89
  }
87
90
  async function downloadBinaryFile(url, destPath, checksum) {
88
- const cacheEntryDir = import_path.default.dirname(destPath);
89
- const lockPath = import_path.default.join(cacheEntryDir, "concurrency.lock");
91
+ const crypto = /* @__PURE__ */ getCrypto();
92
+ const fs = /* @__PURE__ */ getFs();
93
+ const path = /* @__PURE__ */ getPath();
94
+ const cacheEntryDir = path.dirname(destPath);
95
+ const lockPath = path.join(cacheEntryDir, "concurrency.lock");
90
96
  return await import_process_lock.processLock.withLock(
91
97
  lockPath,
92
98
  async () => {
93
- const fs = /* @__PURE__ */ getFs();
94
99
  if (fs.existsSync(destPath)) {
95
100
  const stats = await fs.promises.stat(destPath);
96
101
  if (stats.size > 0) {
97
102
  const fileBuffer2 = await fs.promises.readFile(destPath);
98
- const hasher2 = (0, import_crypto.createHash)("sha256");
103
+ const hasher2 = crypto.createHash("sha256");
99
104
  hasher2.update(fileBuffer2);
100
105
  return hasher2.digest("hex");
101
106
  }
@@ -111,7 +116,7 @@ Check your internet connection or verify the URL is accessible.`,
111
116
  );
112
117
  }
113
118
  const fileBuffer = await fs.promises.readFile(destPath);
114
- const hasher = (0, import_crypto.createHash)("sha256");
119
+ const hasher = crypto.createHash("sha256");
115
120
  hasher.update(fileBuffer);
116
121
  const actualChecksum = hasher.digest("hex");
117
122
  if (checksum && actualChecksum !== checksum) {
@@ -140,8 +145,8 @@ async function writeMetadata(cacheEntryPath, cacheKey, url, binaryName, checksum
140
145
  timestamp: Date.now(),
141
146
  checksum,
142
147
  checksum_algorithm: "sha256",
143
- platform: import_os.default.platform(),
144
- arch: import_os.default.arch(),
148
+ platform: (0, import_platform.getPlatform)(),
149
+ arch: (0, import_platform.getArch)(),
145
150
  size,
146
151
  source: {
147
152
  type: "download",
@@ -154,9 +159,9 @@ async function writeMetadata(cacheEntryPath, cacheKey, url, binaryName, checksum
154
159
  const spec = `${url}:${binaryName}`;
155
160
  await import_manifest.dlxManifest.setBinaryEntry(spec, cacheKey, {
156
161
  checksum,
157
- checksum_algorithm: "sha256",
158
- platform: import_os.default.platform(),
159
- arch: import_os.default.arch(),
162
+ checksum_algorithm: metadata.checksum_algorithm,
163
+ platform: metadata.platform,
164
+ arch: metadata.arch,
160
165
  size,
161
166
  source: {
162
167
  type: "download",
@@ -174,9 +179,10 @@ async function cleanDlxCache(maxAge = import_time.DLX_BINARY_CACHE_TTL) {
174
179
  }
175
180
  let cleaned = 0;
176
181
  const now = Date.now();
182
+ const path = /* @__PURE__ */ getPath();
177
183
  const entries = await fs.promises.readdir(cacheDir);
178
184
  for (const entry of entries) {
179
- const entryPath = import_path.default.join(cacheDir, entry);
185
+ const entryPath = path.join(cacheDir, entry);
180
186
  const metaPath = getMetadataPath(entryPath);
181
187
  try {
182
188
  if (!await (0, import_fs.isDir)(entryPath)) {
@@ -215,14 +221,15 @@ async function dlxBinary(args, options, spawnExtra) {
215
221
  url,
216
222
  yes
217
223
  } = { __proto__: null, ...options };
224
+ const fs = /* @__PURE__ */ getFs();
225
+ const path = /* @__PURE__ */ getPath();
218
226
  const force = yes === true ? true : userForce;
219
227
  const cacheDir = getDlxCachePath();
220
- const binaryName = name || `binary-${process.platform}-${import_os.default.arch()}`;
228
+ const binaryName = name || `binary-${process.platform}-${(0, import_platform.getArch)()}`;
221
229
  const spec = `${url}:${binaryName}`;
222
230
  const cacheKey = (0, import_cache.generateCacheKey)(spec);
223
- const cacheEntryDir = import_path.default.join(cacheDir, cacheKey);
224
- const binaryPath = (0, import_normalize.normalizePath)(import_path.default.join(cacheEntryDir, binaryName));
225
- const fs = /* @__PURE__ */ getFs();
231
+ const cacheEntryDir = path.join(cacheDir, cacheKey);
232
+ const binaryPath = (0, import_normalize.normalizePath)(path.join(cacheEntryDir, binaryName));
226
233
  let downloaded = false;
227
234
  let computedChecksum = checksum;
228
235
  if (!force && fs.existsSync(cacheEntryDir) && await isCacheValid(cacheEntryDir, cacheTtl)) {
@@ -280,7 +287,7 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
280
287
  ...spawnOptions,
281
288
  env: {
282
289
  ...spawnOptions?.env,
283
- PATH: `${cacheEntryDir}${import_path.default.delimiter}${process.env["PATH"] || ""}`
290
+ PATH: `${cacheEntryDir}${(/* @__PURE__ */ getPath()).delimiter}${process.env["PATH"] || ""}`
284
291
  },
285
292
  shell: true
286
293
  } : spawnOptions;
@@ -299,13 +306,14 @@ async function downloadBinary(options) {
299
306
  name,
300
307
  url
301
308
  } = { __proto__: null, ...options };
309
+ const fs = /* @__PURE__ */ getFs();
310
+ const path = /* @__PURE__ */ getPath();
302
311
  const cacheDir = getDlxCachePath();
303
- const binaryName = name || `binary-${process.platform}-${import_os.default.arch()}`;
312
+ const binaryName = name || `binary-${process.platform}-${(0, import_platform.getArch)()}`;
304
313
  const spec = `${url}:${binaryName}`;
305
314
  const cacheKey = (0, import_cache.generateCacheKey)(spec);
306
- const cacheEntryDir = import_path.default.join(cacheDir, cacheKey);
307
- const binaryPath = (0, import_normalize.normalizePath)(import_path.default.join(cacheEntryDir, binaryName));
308
- const fs = /* @__PURE__ */ getFs();
315
+ const cacheEntryDir = path.join(cacheDir, cacheKey);
316
+ const binaryPath = (0, import_normalize.normalizePath)(path.join(cacheEntryDir, binaryName));
309
317
  let downloaded = false;
310
318
  if (!force && fs.existsSync(cacheEntryDir) && await isCacheValid(cacheEntryDir, cacheTtl)) {
311
319
  downloaded = false;
@@ -352,12 +360,13 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
352
360
  }
353
361
  function executeBinary(binaryPath, args, spawnOptions, spawnExtra) {
354
362
  const needsShell = import_platform.WIN32 && /\.(?:bat|cmd|ps1)$/i.test(binaryPath);
355
- const cacheEntryDir = import_path.default.dirname(binaryPath);
363
+ const path = /* @__PURE__ */ getPath();
364
+ const cacheEntryDir = path.dirname(binaryPath);
356
365
  const finalSpawnOptions = needsShell ? {
357
366
  ...spawnOptions,
358
367
  env: {
359
368
  ...spawnOptions?.env,
360
- PATH: `${cacheEntryDir}${import_path.default.delimiter}${process.env["PATH"] || ""}`
369
+ PATH: `${cacheEntryDir}${path.delimiter}${process.env["PATH"] || ""}`
361
370
  },
362
371
  shell: true
363
372
  } : spawnOptions;
@@ -374,9 +383,10 @@ async function listDlxCache() {
374
383
  }
375
384
  const results = [];
376
385
  const now = Date.now();
386
+ const path = /* @__PURE__ */ getPath();
377
387
  const entries = await fs.promises.readdir(cacheDir);
378
388
  for (const entry of entries) {
379
- const entryPath = import_path.default.join(cacheDir, entry);
389
+ const entryPath = path.join(cacheDir, entry);
380
390
  try {
381
391
  if (!await (0, import_fs.isDir)(entryPath)) {
382
392
  continue;
@@ -392,7 +402,7 @@ async function listDlxCache() {
392
402
  const files = await fs.promises.readdir(entryPath);
393
403
  const binaryFile = files.find((f) => !f.startsWith("."));
394
404
  if (binaryFile) {
395
- const binaryPath = import_path.default.join(entryPath, binaryFile);
405
+ const binaryPath = path.join(entryPath, binaryFile);
396
406
  const binaryStats = await fs.promises.stat(binaryPath);
397
407
  results.push({
398
408
  age: now - (metaObj["timestamp"] || 0),
package/dist/dlx/dir.js CHANGED
@@ -35,7 +35,7 @@ let _fs;
35
35
  // @__NO_SIDE_EFFECTS__
36
36
  function getFs() {
37
37
  if (_fs === void 0) {
38
- _fs = require("node:fs");
38
+ _fs = require("fs");
39
39
  }
40
40
  return _fs;
41
41
  }
@@ -15,7 +15,7 @@ export interface PackageDetails {
15
15
  */
16
16
  export interface BinaryDetails {
17
17
  checksum: string;
18
- checksum_algorithm: 'sha256' | 'sha512';
18
+ checksum_algorithm: ChecksumAlgorithm;
19
19
  platform: string;
20
20
  arch: string;
21
21
  size: number;
@@ -24,6 +24,7 @@ export interface BinaryDetails {
24
24
  url: string;
25
25
  };
26
26
  }
27
+ export type ChecksumAlgorithm = 'sha256' | 'sha512';
27
28
  /**
28
29
  * Unified manifest entry for all cached items (packages and binaries).
29
30
  * Shared fields at root, type-specific fields in details.
@@ -34,8 +34,6 @@ __export(package_exports, {
34
34
  executePackage: () => executePackage
35
35
  });
36
36
  module.exports = __toCommonJS(package_exports);
37
- var import_node_fs = __toESM(require("node:fs"));
38
- var import_path = __toESM(require("path"));
39
37
  var import_platform = require("../constants/platform");
40
38
  var import_packages = require("../constants/packages");
41
39
  var import_cache = require("./cache");
@@ -48,6 +46,22 @@ var import_normalize = require("../paths/normalize");
48
46
  var import_socket = require("../paths/socket");
49
47
  var import_process_lock = require("../process-lock");
50
48
  var import_spawn = require("../spawn");
49
+ let _fs;
50
+ // @__NO_SIDE_EFFECTS__
51
+ function getFs() {
52
+ if (_fs === void 0) {
53
+ _fs = require("fs");
54
+ }
55
+ return _fs;
56
+ }
57
+ let _path;
58
+ // @__NO_SIDE_EFFECTS__
59
+ function getPath() {
60
+ if (_path === void 0) {
61
+ _path = require("path");
62
+ }
63
+ return _path;
64
+ }
51
65
  const rangeOperatorsRegExp = /[~^><=xX* ]|\|\|/;
52
66
  function parsePackageSpec(spec) {
53
67
  try {
@@ -69,10 +83,12 @@ function parsePackageSpec(spec) {
69
83
  }
70
84
  }
71
85
  async function ensurePackageInstalled(packageName, packageSpec, force) {
86
+ const fs = /* @__PURE__ */ getFs();
87
+ const path = /* @__PURE__ */ getPath();
72
88
  const cacheKey = (0, import_cache.generateCacheKey)(packageSpec);
73
- const packageDir = (0, import_normalize.normalizePath)(import_path.default.join((0, import_socket.getSocketDlxDir)(), cacheKey));
89
+ const packageDir = (0, import_normalize.normalizePath)(path.join((0, import_socket.getSocketDlxDir)(), cacheKey));
74
90
  const installedDir = (0, import_normalize.normalizePath)(
75
- import_path.default.join(packageDir, "node_modules", packageName)
91
+ path.join(packageDir, "node_modules", packageName)
76
92
  );
77
93
  try {
78
94
  await (0, import_fs.safeMkdir)(packageDir);
@@ -96,13 +112,13 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
96
112
  cause: e
97
113
  });
98
114
  }
99
- const lockPath = import_path.default.join(packageDir, "concurrency.lock");
115
+ const lockPath = path.join(packageDir, "concurrency.lock");
100
116
  return await import_process_lock.processLock.withLock(
101
117
  lockPath,
102
118
  async () => {
103
- if (!force && import_node_fs.default.existsSync(installedDir)) {
104
- const pkgJsonPath = import_path.default.join(installedDir, "package.json");
105
- if (import_node_fs.default.existsSync(pkgJsonPath)) {
119
+ if (!force && fs.existsSync(installedDir)) {
120
+ const pkgJsonPath = path.join(installedDir, "package.json");
121
+ if (fs.existsSync(pkgJsonPath)) {
106
122
  return { installed: false, packageDir };
107
123
  }
108
124
  }
@@ -110,11 +126,11 @@ Ensure the filesystem is writable or set SOCKET_DLX_DIR to a writable location.`
110
126
  try {
111
127
  await import_pacote.default.extract(packageSpec, installedDir, {
112
128
  // Use consistent pacote cache path (respects npm cache locations when available).
113
- cache: pacoteCachePath || import_path.default.join(packageDir, ".cache")
129
+ cache: pacoteCachePath || path.join(packageDir, ".cache")
114
130
  });
115
131
  const arb = new import_arborist.default({
116
132
  path: installedDir,
117
- cache: pacoteCachePath || import_path.default.join(packageDir, ".cache"),
133
+ cache: pacoteCachePath || path.join(packageDir, ".cache"),
118
134
  // Skip devDependencies (production-only like npx).
119
135
  omit: ["dev"],
120
136
  // Security: Skip install/preinstall/postinstall scripts to prevent arbitrary code execution.
@@ -167,20 +183,22 @@ function resolveBinaryPath(basePath) {
167
183
  if (!import_platform.WIN32) {
168
184
  return basePath;
169
185
  }
186
+ const fs = /* @__PURE__ */ getFs();
170
187
  const extensions = [".cmd", ".bat", ".ps1", ".exe", ""];
171
188
  for (const ext of extensions) {
172
189
  const testPath = basePath + ext;
173
- if (import_node_fs.default.existsSync(testPath)) {
190
+ if (fs.existsSync(testPath)) {
174
191
  return testPath;
175
192
  }
176
193
  }
177
194
  return basePath;
178
195
  }
179
196
  function findBinaryPath(packageDir, packageName, binaryName) {
197
+ const path = /* @__PURE__ */ getPath();
180
198
  const installedDir = (0, import_normalize.normalizePath)(
181
- import_path.default.join(packageDir, "node_modules", packageName)
199
+ path.join(packageDir, "node_modules", packageName)
182
200
  );
183
- const pkgJsonPath = import_path.default.join(installedDir, "package.json");
201
+ const pkgJsonPath = path.join(installedDir, "package.json");
184
202
  const pkgJson = (0, import_fs.readJsonSync)(pkgJsonPath);
185
203
  const bin = pkgJson["bin"];
186
204
  let binName;
@@ -226,7 +244,7 @@ function findBinaryPath(packageDir, packageName, binaryName) {
226
244
  if (!binPath) {
227
245
  throw new Error(`No binary found for package "${packageName}"`);
228
246
  }
229
- const rawPath = (0, import_normalize.normalizePath)(import_path.default.join(installedDir, binPath));
247
+ const rawPath = (0, import_normalize.normalizePath)(path.join(installedDir, binPath));
230
248
  return resolveBinaryPath(rawPath);
231
249
  }
232
250
  async function dlxPackage(args, options, spawnExtra) {
@@ -246,10 +264,12 @@ function makePackageBinsExecutable(packageDir, packageName) {
246
264
  if (import_platform.WIN32) {
247
265
  return;
248
266
  }
267
+ const fs = /* @__PURE__ */ getFs();
268
+ const path = /* @__PURE__ */ getPath();
249
269
  const installedDir = (0, import_normalize.normalizePath)(
250
- import_path.default.join(packageDir, "node_modules", packageName)
270
+ path.join(packageDir, "node_modules", packageName)
251
271
  );
252
- const pkgJsonPath = import_path.default.join(installedDir, "package.json");
272
+ const pkgJsonPath = path.join(installedDir, "package.json");
253
273
  try {
254
274
  const pkgJson = (0, import_fs.readJsonSync)(pkgJsonPath);
255
275
  const bin = pkgJson["bin"];
@@ -264,10 +284,10 @@ function makePackageBinsExecutable(packageDir, packageName) {
264
284
  binPaths.push(...Object.values(binObj));
265
285
  }
266
286
  for (const binPath of binPaths) {
267
- const fullPath = (0, import_normalize.normalizePath)(import_path.default.join(installedDir, binPath));
268
- if (import_node_fs.default.existsSync(fullPath)) {
287
+ const fullPath = (0, import_normalize.normalizePath)(path.join(installedDir, binPath));
288
+ if (fs.existsSync(fullPath)) {
269
289
  try {
270
- import_node_fs.default.chmodSync(fullPath, 493);
290
+ fs.chmodSync(fullPath, 493);
271
291
  } catch {
272
292
  }
273
293
  }
@@ -34,7 +34,7 @@ let _fs;
34
34
  // @__NO_SIDE_EFFECTS__
35
35
  function getFs() {
36
36
  if (_fs === void 0) {
37
- _fs = require("node:fs");
37
+ _fs = require("fs");
38
38
  }
39
39
  return _fs;
40
40
  }
package/dist/dlx/paths.js CHANGED
@@ -32,7 +32,7 @@ let _path;
32
32
  // @__NO_SIDE_EFFECTS__
33
33
  function getPath() {
34
34
  if (_path === void 0) {
35
- _path = require("node:path");
35
+ _path = require("path");
36
36
  }
37
37
  return _path;
38
38
  }
package/dist/fs.js CHANGED
@@ -84,7 +84,7 @@ let _buffer;
84
84
  // @__NO_SIDE_EFFECTS__
85
85
  function getBuffer() {
86
86
  if (_buffer === void 0) {
87
- _buffer = require("node:buffer");
87
+ _buffer = require("buffer");
88
88
  }
89
89
  return _buffer;
90
90
  }
@@ -92,7 +92,7 @@ let _fs;
92
92
  // @__NO_SIDE_EFFECTS__
93
93
  function getFs() {
94
94
  if (_fs === void 0) {
95
- _fs = require("node:fs");
95
+ _fs = require("fs");
96
96
  }
97
97
  return _fs;
98
98
  }
@@ -100,7 +100,7 @@ let _path;
100
100
  // @__NO_SIDE_EFFECTS__
101
101
  function getPath() {
102
102
  if (_path === void 0) {
103
- _path = require("node:path");
103
+ _path = require("path");
104
104
  }
105
105
  return _path;
106
106
  }
package/dist/git.js CHANGED
@@ -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 git_exports = {};
31
21
  __export(git_exports, {
@@ -44,18 +34,16 @@ __export(git_exports, {
44
34
  isUnstagedSync: () => isUnstagedSync
45
35
  });
46
36
  module.exports = __toCommonJS(git_exports);
47
- var import_path = __toESM(require("path"));
48
37
  var import_debug = require("./debug");
49
38
  var import_globs = require("./globs");
50
39
  var import_normalize = require("./paths/normalize");
51
40
  var import_spawn = require("./spawn");
52
41
  var import_strings = require("./strings");
53
- const gitDiffCache = /* @__PURE__ */ new Map();
54
42
  let _fs;
55
43
  // @__NO_SIDE_EFFECTS__
56
44
  function getFs() {
57
45
  if (_fs === void 0) {
58
- _fs = require("node:fs");
46
+ _fs = require("fs");
59
47
  }
60
48
  return _fs;
61
49
  }
@@ -63,10 +51,11 @@ let _path;
63
51
  // @__NO_SIDE_EFFECTS__
64
52
  function getPath() {
65
53
  if (_path === void 0) {
66
- _path = require("node:path");
54
+ _path = require("path");
67
55
  }
68
56
  return _path;
69
57
  }
58
+ const gitDiffCache = /* @__PURE__ */ new Map();
70
59
  function getGitPath() {
71
60
  return "git";
72
61
  }
@@ -161,17 +150,17 @@ function innerDiffSync(args, options) {
161
150
  }
162
151
  function findGitRoot(startPath) {
163
152
  const fs = /* @__PURE__ */ getFs();
164
- const path2 = /* @__PURE__ */ getPath();
153
+ const path = /* @__PURE__ */ getPath();
165
154
  let currentPath = startPath;
166
155
  while (true) {
167
156
  try {
168
- const gitPath = path2.join(currentPath, ".git");
157
+ const gitPath = path.join(currentPath, ".git");
169
158
  if (fs.existsSync(gitPath)) {
170
159
  return currentPath;
171
160
  }
172
161
  } catch {
173
162
  }
174
- const parentPath = path2.dirname(currentPath);
163
+ const parentPath = path.dirname(currentPath);
175
164
  if (parentPath === currentPath) {
176
165
  return startPath;
177
166
  }
@@ -186,7 +175,9 @@ function parseGitDiffStdout(stdout, options, spawnCwd) {
186
175
  porcelain = false,
187
176
  ...matcherOptions
188
177
  } = { __proto__: null, ...options };
189
- const cwd = cwdOption === defaultRoot ? defaultRoot : (/* @__PURE__ */ getFs()).realpathSync(cwdOption);
178
+ const fs = /* @__PURE__ */ getFs();
179
+ const path = /* @__PURE__ */ getPath();
180
+ const cwd = cwdOption === defaultRoot ? defaultRoot : fs.realpathSync(cwdOption);
190
181
  const rootPath = defaultRoot;
191
182
  let rawFiles = stdout ? (0, import_strings.stripAnsi)(stdout).split("\n").map((line) => line.trimEnd()).filter((line) => line) : [];
192
183
  if (porcelain) {
@@ -194,11 +185,11 @@ function parseGitDiffStdout(stdout, options, spawnCwd) {
194
185
  return line.length > 3 ? line.substring(3) : line;
195
186
  });
196
187
  }
197
- const files = absolute ? rawFiles.map((relPath2) => (0, import_normalize.normalizePath)(import_path.default.join(rootPath, relPath2))) : rawFiles.map((relPath2) => (0, import_normalize.normalizePath)(relPath2));
188
+ const files = absolute ? rawFiles.map((relPath2) => (0, import_normalize.normalizePath)(path.join(rootPath, relPath2))) : rawFiles.map((relPath2) => (0, import_normalize.normalizePath)(relPath2));
198
189
  if (cwd === rootPath) {
199
190
  return files;
200
191
  }
201
- const relPath = (0, import_normalize.normalizePath)(import_path.default.relative(rootPath, cwd));
192
+ const relPath = (0, import_normalize.normalizePath)(path.relative(rootPath, cwd));
202
193
  const matcher = (0, import_globs.getGlobMatcher)([`${relPath}/**`], {
203
194
  ...matcherOptions,
204
195
  absolute,
@@ -250,9 +241,11 @@ async function isChanged(pathname, options) {
250
241
  ...options,
251
242
  absolute: false
252
243
  });
253
- const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
254
- const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
255
- const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
244
+ const fs = /* @__PURE__ */ getFs();
245
+ const path = /* @__PURE__ */ getPath();
246
+ const resolvedPathname = fs.realpathSync(pathname);
247
+ const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
248
+ const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
256
249
  return files.includes(relativePath);
257
250
  }
258
251
  function isChangedSync(pathname, options) {
@@ -261,9 +254,11 @@ function isChangedSync(pathname, options) {
261
254
  ...options,
262
255
  absolute: false
263
256
  });
264
- const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
265
- const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
266
- const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
257
+ const fs = /* @__PURE__ */ getFs();
258
+ const path = /* @__PURE__ */ getPath();
259
+ const resolvedPathname = fs.realpathSync(pathname);
260
+ const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
261
+ const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
267
262
  return files.includes(relativePath);
268
263
  }
269
264
  async function isUnstaged(pathname, options) {
@@ -272,9 +267,11 @@ async function isUnstaged(pathname, options) {
272
267
  ...options,
273
268
  absolute: false
274
269
  });
275
- const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
276
- const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
277
- const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
270
+ const fs = /* @__PURE__ */ getFs();
271
+ const path = /* @__PURE__ */ getPath();
272
+ const resolvedPathname = fs.realpathSync(pathname);
273
+ const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
274
+ const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
278
275
  return files.includes(relativePath);
279
276
  }
280
277
  function isUnstagedSync(pathname, options) {
@@ -283,9 +280,11 @@ function isUnstagedSync(pathname, options) {
283
280
  ...options,
284
281
  absolute: false
285
282
  });
286
- const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
287
- const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
288
- const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
283
+ const fs = /* @__PURE__ */ getFs();
284
+ const path = /* @__PURE__ */ getPath();
285
+ const resolvedPathname = fs.realpathSync(pathname);
286
+ const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
287
+ const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
289
288
  return files.includes(relativePath);
290
289
  }
291
290
  async function isStaged(pathname, options) {
@@ -294,9 +293,11 @@ async function isStaged(pathname, options) {
294
293
  ...options,
295
294
  absolute: false
296
295
  });
297
- const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
298
- const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
299
- const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
296
+ const fs = /* @__PURE__ */ getFs();
297
+ const path = /* @__PURE__ */ getPath();
298
+ const resolvedPathname = fs.realpathSync(pathname);
299
+ const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
300
+ const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
300
301
  return files.includes(relativePath);
301
302
  }
302
303
  function isStagedSync(pathname, options) {
@@ -305,9 +306,11 @@ function isStagedSync(pathname, options) {
305
306
  ...options,
306
307
  absolute: false
307
308
  });
308
- const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
309
- const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
310
- const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
309
+ const fs = /* @__PURE__ */ getFs();
310
+ const path = /* @__PURE__ */ getPath();
311
+ const resolvedPathname = fs.realpathSync(pathname);
312
+ const baseCwd = options?.cwd ? fs.realpathSync(options["cwd"]) : getCwd();
313
+ const relativePath = (0, import_normalize.normalizePath)(path.relative(baseCwd, resolvedPathname));
311
314
  return files.includes(relativePath);
312
315
  }
313
316
  // Annotate the CommonJS export names for ESM import in node:
@@ -31,14 +31,14 @@ let _https;
31
31
  // @__NO_SIDE_EFFECTS__
32
32
  function getHttp() {
33
33
  if (_http === void 0) {
34
- _http = require("node:http");
34
+ _http = require("http");
35
35
  }
36
36
  return _http;
37
37
  }
38
38
  // @__NO_SIDE_EFFECTS__
39
39
  function getHttps() {
40
40
  if (_https === void 0) {
41
- _https = require("node:https");
41
+ _https = require("https");
42
42
  }
43
43
  return _https;
44
44
  }
package/dist/json/edit.js CHANGED
@@ -32,7 +32,7 @@ let _fs;
32
32
  // @__NO_SIDE_EFFECTS__
33
33
  function getFs() {
34
34
  if (_fs === void 0) {
35
- _fs = require("node:fs");
35
+ _fs = require("fs");
36
36
  }
37
37
  return _fs;
38
38
  }
@@ -98,7 +98,7 @@ function shouldSave(currentContent, originalContent, originalFileContent, option
98
98
  const sortedContent = sortFn ? sortFn(content) : sort ? sortKeys(content) : content;
99
99
  const origContent = originalContent ? stripFormattingSymbols(originalContent) : {};
100
100
  if (ignoreWhitespace) {
101
- const util = require("node:util");
101
+ const util = require("util");
102
102
  return !util.isDeepStrictEqual(sortedContent, origContent);
103
103
  }
104
104
  const formatting = getFormattingFromContent(currentContent);