@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
package/dist/git.d.ts CHANGED
@@ -24,6 +24,12 @@ export interface GitDiffOptions {
24
24
  * @default false
25
25
  */
26
26
  absolute?: boolean | undefined;
27
+ /**
28
+ * Return results as a `Set` instead of an array.
29
+ *
30
+ * @default false
31
+ */
32
+ asSet?: boolean | undefined;
27
33
  /**
28
34
  * Cache git diff results to avoid repeated git subprocess calls.
29
35
  *
@@ -52,12 +58,6 @@ export interface GitDiffOptions {
52
58
  * @default false
53
59
  */
54
60
  porcelain?: boolean | undefined;
55
- /**
56
- * Return results as a `Set` instead of an array.
57
- *
58
- * @default false
59
- */
60
- asSet?: boolean | undefined;
61
61
  /**
62
62
  * Additional options passed to glob matcher.
63
63
  *
package/dist/git.js CHANGED
@@ -45,10 +45,9 @@ __export(git_exports, {
45
45
  });
46
46
  module.exports = __toCommonJS(git_exports);
47
47
  var import_path = __toESM(require("path"));
48
- var import_platform = require("#constants/platform");
49
48
  var import_debug = require("./debug");
50
49
  var import_globs = require("./globs");
51
- var import_path2 = require("./path");
50
+ var import_normalize = require("./paths/normalize");
52
51
  var import_spawn = require("./spawn");
53
52
  var import_strings = require("./strings");
54
53
  const gitDiffCache = /* @__PURE__ */ new Map();
@@ -81,8 +80,7 @@ function getGitDiffSpawnArgs(cwd) {
81
80
  getGitPath(),
82
81
  ["status", "--porcelain"],
83
82
  {
84
- cwd: resolvedCwd,
85
- shell: import_platform.WIN32
83
+ cwd: resolvedCwd
86
84
  }
87
85
  ],
88
86
  unstaged: [
@@ -96,8 +94,7 @@ function getGitDiffSpawnArgs(cwd) {
96
94
  getGitPath(),
97
95
  ["diff", "--cached", "--name-only"],
98
96
  {
99
- cwd: resolvedCwd,
100
- shell: import_platform.WIN32
97
+ cwd: resolvedCwd
101
98
  }
102
99
  ]
103
100
  };
@@ -197,11 +194,11 @@ function parseGitDiffStdout(stdout, options, spawnCwd) {
197
194
  return line.length > 3 ? line.substring(3) : line;
198
195
  });
199
196
  }
200
- const files = absolute ? rawFiles.map((relPath2) => (0, import_path2.normalizePath)(import_path.default.join(rootPath, relPath2))) : rawFiles.map((relPath2) => (0, import_path2.normalizePath)(relPath2));
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));
201
198
  if (cwd === rootPath) {
202
199
  return files;
203
200
  }
204
- const relPath = (0, import_path2.normalizePath)(import_path.default.relative(rootPath, cwd));
201
+ const relPath = (0, import_normalize.normalizePath)(import_path.default.relative(rootPath, cwd));
205
202
  const matcher = (0, import_globs.getGlobMatcher)([`${relPath}/**`], {
206
203
  ...matcherOptions,
207
204
  absolute,
@@ -255,7 +252,7 @@ async function isChanged(pathname, options) {
255
252
  });
256
253
  const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
257
254
  const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
258
- const relativePath = (0, import_path2.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
255
+ const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
259
256
  return files.includes(relativePath);
260
257
  }
261
258
  function isChangedSync(pathname, options) {
@@ -266,7 +263,7 @@ function isChangedSync(pathname, options) {
266
263
  });
267
264
  const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
268
265
  const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
269
- const relativePath = (0, import_path2.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
266
+ const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
270
267
  return files.includes(relativePath);
271
268
  }
272
269
  async function isUnstaged(pathname, options) {
@@ -277,7 +274,7 @@ async function isUnstaged(pathname, options) {
277
274
  });
278
275
  const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
279
276
  const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
280
- const relativePath = (0, import_path2.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
277
+ const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
281
278
  return files.includes(relativePath);
282
279
  }
283
280
  function isUnstagedSync(pathname, options) {
@@ -288,7 +285,7 @@ function isUnstagedSync(pathname, options) {
288
285
  });
289
286
  const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
290
287
  const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
291
- const relativePath = (0, import_path2.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
288
+ const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
292
289
  return files.includes(relativePath);
293
290
  }
294
291
  async function isStaged(pathname, options) {
@@ -299,7 +296,7 @@ async function isStaged(pathname, options) {
299
296
  });
300
297
  const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
301
298
  const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
302
- const relativePath = (0, import_path2.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
299
+ const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
303
300
  return files.includes(relativePath);
304
301
  }
305
302
  function isStagedSync(pathname, options) {
@@ -310,7 +307,7 @@ function isStagedSync(pathname, options) {
310
307
  });
311
308
  const resolvedPathname = (/* @__PURE__ */ getFs()).realpathSync(pathname);
312
309
  const baseCwd = options?.cwd ? (/* @__PURE__ */ getFs()).realpathSync(options["cwd"]) : getCwd();
313
- const relativePath = (0, import_path2.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
310
+ const relativePath = (0, import_normalize.normalizePath)(import_path.default.relative(baseCwd, resolvedPathname));
314
311
  return files.includes(relativePath);
315
312
  }
316
313
  // Annotate the CommonJS export names for ESM import in node:
package/dist/globs.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 globs_exports = {};
21
31
  __export(globs_exports, {
@@ -24,7 +34,10 @@ __export(globs_exports, {
24
34
  globStreamLicenses: () => globStreamLicenses
25
35
  });
26
36
  module.exports = __toCommonJS(globs_exports);
37
+ var fastGlob = __toESM(require("./external/fast-glob.js"));
38
+ var import_picomatch = __toESM(require("./external/picomatch.js"));
27
39
  var import_objects = require("./objects");
40
+ var import_globs = require("./paths/globs");
28
41
  const defaultIgnore = (0, import_objects.objectFreeze)([
29
42
  // Most of these ignored files can be included specifically if included in the
30
43
  // files globs. Exceptions to this are:
@@ -65,22 +78,6 @@ const defaultIgnore = (0, import_objects.objectFreeze)([
65
78
  // Inline additional ignores.
66
79
  "**/bower_components"
67
80
  ]);
68
- let _picomatch;
69
- // @__NO_SIDE_EFFECTS__
70
- function getPicomatch() {
71
- if (_picomatch === void 0) {
72
- _picomatch = require("./external/picomatch.js");
73
- }
74
- return _picomatch;
75
- }
76
- let _fastGlob;
77
- // @__NO_SIDE_EFFECTS__
78
- function getFastGlob() {
79
- if (_fastGlob === void 0) {
80
- _fastGlob = require("./external/fast-glob.js");
81
- }
82
- return _fastGlob;
83
- }
84
81
  // @__NO_SIDE_EFFECTS__
85
82
  function globStreamLicenses(dirname, options) {
86
83
  const {
@@ -94,19 +91,10 @@ function globStreamLicenses(dirname, options) {
94
91
  "**/*.{cjs,cts,js,json,mjs,mts,ts}"
95
92
  ];
96
93
  if (ignoreOriginals) {
97
- const { LICENSE_ORIGINAL_GLOB_RECURSIVE } = (
98
- /*@__INLINE__*/
99
- require("#constants/paths")
100
- );
101
- ignore.push(LICENSE_ORIGINAL_GLOB_RECURSIVE);
94
+ ignore.push(import_globs.LICENSE_ORIGINAL_GLOB_RECURSIVE);
102
95
  }
103
- const fastGlob = /* @__PURE__ */ getFastGlob();
104
- const paths = (
105
- /*@__INLINE__*/
106
- require("#constants/paths")
107
- );
108
96
  return fastGlob.globStream(
109
- [recursive ? paths.LICENSE_GLOB_RECURSIVE : paths.LICENSE_GLOB],
97
+ [recursive ? import_globs.LICENSE_GLOB_RECURSIVE : import_globs.LICENSE_GLOB],
110
98
  {
111
99
  __proto__: null,
112
100
  absolute: true,
@@ -128,14 +116,13 @@ function getGlobMatcher(glob, options) {
128
116
  }
129
117
  const positivePatterns = patterns.filter((p) => !p.startsWith("!"));
130
118
  const negativePatterns = patterns.filter((p) => p.startsWith("!")).map((p) => p.slice(1));
131
- const picomatch = /* @__PURE__ */ getPicomatch();
132
119
  const matchOptions = {
133
120
  dot: true,
134
121
  nocase: true,
135
122
  ...options,
136
123
  ...negativePatterns.length > 0 ? { ignore: negativePatterns } : {}
137
124
  };
138
- matcher = picomatch(
125
+ matcher = (0, import_picomatch.default)(
139
126
  positivePatterns.length > 0 ? positivePatterns : patterns,
140
127
  matchOptions
141
128
  );
package/dist/ipc.d.ts CHANGED
@@ -56,21 +56,21 @@ export interface IpcHandshake extends IpcMessage<{
56
56
  * Represents the structure of stub files used for filesystem-based IPC.
57
57
  */
58
58
  export interface IpcStub {
59
+ /** The actual data payload. */
60
+ data: unknown;
59
61
  /** Process ID that created the stub. */
60
62
  pid: number;
61
63
  /** Creation timestamp for age validation. */
62
64
  timestamp: number;
63
- /** The actual data payload. */
64
- data: unknown;
65
65
  }
66
66
  /**
67
67
  * Options for IPC communication
68
68
  */
69
69
  export interface IpcOptions {
70
- /** Timeout in milliseconds for async operations. */
71
- timeout?: number;
72
70
  /** Text encoding for message serialization. */
73
71
  encoding?: BufferEncoding;
72
+ /** Timeout in milliseconds for async operations. */
73
+ timeout?: number;
74
74
  }
75
75
  /**
76
76
  * Create a unique IPC channel identifier for message correlation.
package/dist/ipc.js CHANGED
@@ -47,7 +47,7 @@ var import_crypto = __toESM(require("crypto"));
47
47
  var import_fs = require("fs");
48
48
  var import_path = __toESM(require("path"));
49
49
  var import_fs2 = require("./fs");
50
- var import_paths = require("./paths");
50
+ var import_socket = require("./paths/socket");
51
51
  var import_zod = require("./zod");
52
52
  const IpcMessageSchema = import_zod.z.object({
53
53
  /** Unique identifier for message tracking and response correlation. */
@@ -84,7 +84,7 @@ function createIpcChannelId(prefix = "socket") {
84
84
  return `${prefix}-${process.pid}-${import_crypto.default.randomBytes(8).toString("hex")}`;
85
85
  }
86
86
  function getIpcStubPath(appName) {
87
- const tempDir = (0, import_paths.getOsTmpDir)();
87
+ const tempDir = (0, import_socket.getOsTmpDir)();
88
88
  const stubDir = import_path.default.join(tempDir, ".socket-ipc", appName);
89
89
  return import_path.default.join(stubDir, `stub-${process.pid}.json`);
90
90
  }
@@ -124,7 +124,7 @@ async function readIpcStub(stubPath) {
124
124
  }
125
125
  }
126
126
  async function cleanupIpcStubs(appName) {
127
- const tempDir = (0, import_paths.getOsTmpDir)();
127
+ const tempDir = (0, import_socket.getOsTmpDir)();
128
128
  const stubDir = import_path.default.join(tempDir, ".socket-ipc", appName);
129
129
  try {
130
130
  const files = await import_fs.promises.readdir(stubDir);
package/dist/logger.d.ts CHANGED
@@ -14,7 +14,6 @@
14
14
  * console.log(`${LOG_SYMBOLS.info} Information message`)
15
15
  * console.log(`${LOG_SYMBOLS.step} Processing step`)
16
16
  * console.log(`${LOG_SYMBOLS.progress} Working on task`)
17
- * console.log(`${LOG_SYMBOLS.reason} Working through logic`)
18
17
  * ```
19
18
  */
20
19
  type LogSymbols = {
@@ -24,8 +23,6 @@ type LogSymbols = {
24
23
  info: string;
25
24
  /** Cyan colored progress indicator symbol (∴ or :. in ASCII) */
26
25
  progress: string;
27
- /** Dimmed yellow reasoning/working symbol (∴ or :. in ASCII) */
28
- reason: string;
29
26
  /** Cyan colored skip symbol (↻ or @ in ASCII) */
30
27
  skip: string;
31
28
  /** Cyan colored step symbol (→ or > in ASCII) */
@@ -85,7 +82,6 @@ export type { LogSymbols, LoggerMethods, Task };
85
82
  * console.log(`${LOG_SYMBOLS.fail} Build failed`) // Theme error color ✖
86
83
  * console.log(`${LOG_SYMBOLS.info} Starting process`) // Theme info color ℹ
87
84
  * console.log(`${LOG_SYMBOLS.progress} Working on task`) // Theme step color ∴
88
- * console.log(`${LOG_SYMBOLS.reason} Analyzing dependencies`) // Dimmed yellow ∴
89
85
  * console.log(`${LOG_SYMBOLS.step} Processing files`) // Theme step color →
90
86
  * console.log(`${LOG_SYMBOLS.success} Build completed`) // Theme success color ✔
91
87
  * console.log(`${LOG_SYMBOLS.warn} Deprecated API used`) // Theme warning color ⚠
@@ -701,27 +697,6 @@ export declare class Logger {
701
697
  * ```
702
698
  */
703
699
  progress(text: string): this;
704
- /**
705
- * Logs a reasoning/working message with a dimmed yellow therefore symbol.
706
- *
707
- * Automatically prefixes the message with `LOG_SYMBOLS.reason` (dimmed yellow ∴).
708
- * Useful for showing intermediate reasoning, logic steps, or "working" output
709
- * that leads to a conclusion. Always outputs to stderr. If the message starts
710
- * with an existing symbol, it will be stripped and replaced.
711
- *
712
- * @param args - Message and additional arguments to log
713
- * @returns The logger instance for chaining
714
- *
715
- * @example
716
- * ```typescript
717
- * logger.step('Analyzing package security')
718
- * logger.reason('Found 3 direct dependencies')
719
- * logger.reason('Checking 47 transitive dependencies')
720
- * logger.reason('Risk score: 8.5/10')
721
- * logger.fail('Package blocked due to high risk')
722
- * ```
723
- */
724
- reason(...args: unknown[]): this;
725
700
  /**
726
701
  * Resets all indentation to zero.
727
702
  *
package/dist/logger.js CHANGED
@@ -330,9 +330,6 @@ class Logger {
330
330
  fail: /* @__PURE__ */ applyColor(supported ? "\u2716" : "\xD7", theme.colors.error, colors),
331
331
  info: /* @__PURE__ */ applyColor(supported ? "\u2139" : "i", theme.colors.info, colors),
332
332
  progress: /* @__PURE__ */ applyColor(supported ? "\u2234" : ":.", theme.colors.step, colors),
333
- reason: colors.dim(
334
- /* @__PURE__ */ applyColor(supported ? "\u2234" : ":.", theme.colors.warning, colors)
335
- ),
336
333
  skip: /* @__PURE__ */ applyColor(supported ? "\u21BB" : "@", theme.colors.step, colors),
337
334
  step: /* @__PURE__ */ applyColor(supported ? "\u2192" : ">", theme.colors.step, colors),
338
335
  success: /* @__PURE__ */ applyColor(supported ? "\u2714" : "\u221A", theme.colors.success, colors),
@@ -1069,29 +1066,6 @@ class Logger {
1069
1066
  this[lastWasBlankSymbol](false);
1070
1067
  return this;
1071
1068
  }
1072
- /**
1073
- * Logs a reasoning/working message with a dimmed yellow therefore symbol.
1074
- *
1075
- * Automatically prefixes the message with `LOG_SYMBOLS.reason` (dimmed yellow ∴).
1076
- * Useful for showing intermediate reasoning, logic steps, or "working" output
1077
- * that leads to a conclusion. Always outputs to stderr. If the message starts
1078
- * with an existing symbol, it will be stripped and replaced.
1079
- *
1080
- * @param args - Message and additional arguments to log
1081
- * @returns The logger instance for chaining
1082
- *
1083
- * @example
1084
- * ```typescript
1085
- * logger.step('Analyzing package security')
1086
- * logger.reason('Found 3 direct dependencies')
1087
- * logger.reason('Checking 47 transitive dependencies')
1088
- * logger.reason('Risk score: 8.5/10')
1089
- * logger.fail('Package blocked due to high risk')
1090
- * ```
1091
- */
1092
- reason(...args) {
1093
- return this.#symbolApply("reason", args);
1094
- }
1095
1069
  /**
1096
1070
  * Resets all indentation to zero.
1097
1071
  *
@@ -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,15 +18,23 @@ 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 package_default_node_range_exports = {};
21
31
  __export(package_default_node_range_exports, {
22
32
  packageDefaultNodeRange: () => packageDefaultNodeRange
23
33
  });
24
34
  module.exports = __toCommonJS(package_default_node_range_exports);
25
- const { maintainedNodeVersions } = require("#lib/maintained-node-versions");
26
- const semver = require("./external/semver.js");
27
- const packageDefaultNodeRange = `>=${semver.parse(maintainedNodeVersions.last).major}`;
35
+ var import_maintained_node_versions = require("./maintained-node-versions");
36
+ var semver = __toESM(require("./external/semver.js"));
37
+ const packageDefaultNodeRange = `>=${semver.parse(import_maintained_node_versions.maintainedNodeVersions.last).major}`;
28
38
  // Annotate the CommonJS export names for ESM import in node:
29
39
  0 && (module.exports = {
30
40
  packageDefaultNodeRange
@@ -1,2 +1,3 @@
1
- declare const packageExtensions: readonly any[];
1
+ type PackageExtension = readonly [string, Record<string, unknown>];
2
+ declare const packageExtensions: readonly PackageExtension[];
2
3
  export { packageExtensions };
@@ -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,25 @@ 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 package_extensions_exports = {};
21
31
  __export(package_extensions_exports, {
22
32
  packageExtensions: () => packageExtensions
23
33
  });
24
34
  module.exports = __toCommonJS(package_extensions_exports);
35
+ var yarnPkgExtensions = __toESM(require("./external/@yarnpkg/extensions.js"));
25
36
  const { freeze: ObjectFreeze } = Object;
26
- const yarnPkgExtensions = require("./external/@yarnpkg/extensions.js");
27
37
  const packageExtensions = ObjectFreeze(
28
38
  [
29
- yarnPkgExtensions.packageExtensions,
39
+ ...yarnPkgExtensions.packageExtensions,
30
40
  [
31
41
  "@yarnpkg/extensions@>=1.1.0",
32
42
  {
@@ -1,6 +1,3 @@
1
- /**
2
- * @fileoverview Editable package.json manipulation utilities.
3
- */
4
1
  import type { EditablePackageJsonOptions, NormalizeOptions, PackageJson, SaveOptions } from '../packages';
5
2
  // Define the interface for the dynamic class
6
3
  interface EditablePackageJsonConstructor {
@@ -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 editable_exports = {};
21
31
  __export(editable_exports, {
@@ -25,9 +35,12 @@ __export(editable_exports, {
25
35
  toEditablePackageJsonSync: () => toEditablePackageJsonSync
26
36
  });
27
37
  module.exports = __toCommonJS(editable_exports);
28
- var import_path = require("../path");
29
- var import_normalize = require("./normalize");
30
- var import_paths = require("./paths");
38
+ var import_package_json = __toESM(require("../external/@npmcli/package-json"));
39
+ var import_read_package = require("../external/@npmcli/package-json/lib/read-package");
40
+ var import_sort = require("../external/@npmcli/package-json/lib/sort");
41
+ var import_normalize = require("../paths/normalize");
42
+ var import_normalize2 = require("./normalize");
43
+ var import_packages = require("../paths/packages");
31
44
  const identSymbol = Symbol.for("indent");
32
45
  const newlineSymbol = Symbol.for("newline");
33
46
  let _EditablePackageJsonClass;
@@ -58,13 +71,10 @@ function getUtil() {
58
71
  // @__NO_SIDE_EFFECTS__
59
72
  function getEditablePackageJsonClass() {
60
73
  if (_EditablePackageJsonClass === void 0) {
61
- const EditablePackageJsonBase = require("../external/@npmcli/package-json");
62
- const { parse, read } = require("../external/@npmcli/package-json/lib/read-package");
63
- const { packageSort } = require("../external/@npmcli/package-json/lib/sort");
64
- _EditablePackageJsonClass = class EditablePackageJson extends EditablePackageJsonBase {
65
- static fixSteps = EditablePackageJsonBase.fixSteps;
66
- static normalizeSteps = EditablePackageJsonBase.normalizeSteps;
67
- static prepareSteps = EditablePackageJsonBase.prepareSteps;
74
+ _EditablePackageJsonClass = class EditablePackageJson extends import_package_json.default {
75
+ static fixSteps = import_package_json.default.fixSteps;
76
+ static normalizeSteps = import_package_json.default.normalizeSteps;
77
+ static prepareSteps = import_package_json.default.prepareSteps;
68
78
  _canSave = true;
69
79
  _path = void 0;
70
80
  _readFileContent = "";
@@ -140,7 +150,7 @@ function getEditablePackageJsonClass() {
140
150
  const { promises: fsPromises } = /* @__PURE__ */ getFs();
141
151
  let parseErr;
142
152
  try {
143
- this._readFileContent = await read(this.filename);
153
+ this._readFileContent = await (0, import_read_package.read)(this.filename);
144
154
  } catch (err) {
145
155
  if (!create) {
146
156
  throw err;
@@ -165,7 +175,7 @@ function getEditablePackageJsonClass() {
165
175
  return this;
166
176
  }
167
177
  this.fromJSON(this._readFileContent);
168
- this._readFileJson = parse(this._readFileContent);
178
+ this._readFileJson = (0, import_read_package.parse)(this._readFileContent);
169
179
  return this;
170
180
  }
171
181
  async normalize(opts = {}) {
@@ -192,7 +202,7 @@ function getEditablePackageJsonClass() {
192
202
  [newlineSymbol]: newline,
193
203
  ...rest
194
204
  } = this.content;
195
- const content = sort ? packageSort(rest) : rest;
205
+ const content = sort ? (0, import_sort.packageSort)(rest) : rest;
196
206
  const {
197
207
  [identSymbol]: _indent,
198
208
  [newlineSymbol]: _newline,
@@ -215,7 +225,7 @@ function getEditablePackageJsonClass() {
215
225
  const { promises: fsPromises } = /* @__PURE__ */ getFs();
216
226
  await fsPromises.writeFile(this.filename, fileContent);
217
227
  this._readFileContent = fileContent;
218
- this._readFileJson = parse(fileContent);
228
+ this._readFileJson = (0, import_read_package.parse)(fileContent);
219
229
  return true;
220
230
  }
221
231
  saveSync(options) {
@@ -231,7 +241,7 @@ function getEditablePackageJsonClass() {
231
241
  [Symbol.for("newline")]: newline,
232
242
  ...rest
233
243
  } = this.content;
234
- const content = sort ? packageSort(rest) : rest;
244
+ const content = sort ? (0, import_sort.packageSort)(rest) : rest;
235
245
  if (ignoreWhitespace && (/* @__PURE__ */ getUtil()).isDeepStrictEqual(content, this._readFileJson)) {
236
246
  return false;
237
247
  }
@@ -249,7 +259,7 @@ function getEditablePackageJsonClass() {
249
259
  const fs = /* @__PURE__ */ getFs();
250
260
  fs.writeFileSync(this.filename, fileContent);
251
261
  this._readFileContent = fileContent;
252
- this._readFileJson = parse(fileContent);
262
+ this._readFileJson = (0, import_read_package.parse)(fileContent);
253
263
  return true;
254
264
  }
255
265
  update(content) {
@@ -269,7 +279,7 @@ function getEditablePackageJsonClass() {
269
279
  [Symbol.for("newline")]: newline,
270
280
  ...rest
271
281
  } = this.content;
272
- const content = sort ? packageSort(rest) : rest;
282
+ const content = sort ? (0, import_sort.packageSort)(rest) : rest;
273
283
  if (ignoreWhitespace && (/* @__PURE__ */ getUtil()).isDeepStrictEqual(content, this._readFileJson)) {
274
284
  return false;
275
285
  }
@@ -298,7 +308,7 @@ function pkgJsonToEditable(pkgJson, options) {
298
308
  };
299
309
  const EditablePackageJson = /* @__PURE__ */ getEditablePackageJsonClass();
300
310
  return new EditablePackageJson().fromContent(
301
- normalize ? (0, import_normalize.normalizePackageJson)(pkgJson, normalizeOptions) : pkgJson
311
+ normalize ? (0, import_normalize2.normalizePackageJson)(pkgJson, normalizeOptions) : pkgJson
302
312
  );
303
313
  }
304
314
  // @__NO_SIDE_EFFECTS__
@@ -312,11 +322,11 @@ async function toEditablePackageJson(pkgJson, options) {
312
322
  return /* @__PURE__ */ pkgJsonToEditable(pkgJson, pkgJsonToEditableOptions);
313
323
  }
314
324
  const EditablePackageJson = /* @__PURE__ */ getEditablePackageJsonClass();
315
- const pkgJsonPath = (0, import_paths.resolvePackageJsonDirname)(filepath);
325
+ const pkgJsonPath = (0, import_packages.resolvePackageJsonDirname)(filepath);
316
326
  return (await EditablePackageJson.load(pkgJsonPath, { create: true })).fromJSON(
317
327
  `${JSON.stringify(
318
- normalize ? (0, import_normalize.normalizePackageJson)(pkgJson, {
319
- ...(0, import_path.isNodeModules)(pkgJsonPath) ? {} : { preserve: ["repository"] },
328
+ normalize ? (0, import_normalize2.normalizePackageJson)(pkgJson, {
329
+ ...(0, import_normalize.isNodeModules)(pkgJsonPath) ? {} : { preserve: ["repository"] },
320
330
  ...normalizeOptions
321
331
  }) : pkgJson,
322
332
  null,
@@ -336,11 +346,11 @@ function toEditablePackageJsonSync(pkgJson, options) {
336
346
  return /* @__PURE__ */ pkgJsonToEditable(pkgJson, pkgJsonToEditableOptions);
337
347
  }
338
348
  const EditablePackageJson = /* @__PURE__ */ getEditablePackageJsonClass();
339
- const pkgJsonPath = (0, import_paths.resolvePackageJsonDirname)(filepath);
349
+ const pkgJsonPath = (0, import_packages.resolvePackageJsonDirname)(filepath);
340
350
  return new EditablePackageJson().create(pkgJsonPath).fromJSON(
341
351
  `${JSON.stringify(
342
- normalize ? (0, import_normalize.normalizePackageJson)(pkgJson, {
343
- ...(0, import_path.isNodeModules)(pkgJsonPath) ? {} : { preserve: ["repository"] },
352
+ normalize ? (0, import_normalize2.normalizePackageJson)(pkgJson, {
353
+ ...(0, import_normalize.isNodeModules)(pkgJsonPath) ? {} : { preserve: ["repository"] },
344
354
  ...normalizeOptions
345
355
  }) : pkgJson,
346
356
  null,