@socketsecurity/lib 3.5.0 → 4.0.1

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 (102) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +8 -8
  3. package/dist/agent.js +12 -25
  4. package/dist/bin.d.ts +97 -40
  5. package/dist/bin.js +133 -138
  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 +23 -11
  14. package/dist/constants/process.d.ts +1 -1
  15. package/dist/constants/process.js +2 -2
  16. package/dist/debug.js +3 -3
  17. package/dist/dlx-binary.js +10 -18
  18. package/dist/dlx-manifest.js +2 -2
  19. package/dist/dlx-package.js +22 -62
  20. package/dist/dlx.js +14 -14
  21. package/dist/effects/text-shimmer.js +1 -1
  22. package/dist/env/ci.js +2 -2
  23. package/dist/env/debug.js +1 -1
  24. package/dist/env/github.js +1 -1
  25. package/dist/env/home.js +1 -1
  26. package/dist/env/locale.js +1 -1
  27. package/dist/env/node-auth-token.js +1 -1
  28. package/dist/env/node-env.js +1 -1
  29. package/dist/env/npm.js +1 -1
  30. package/dist/env/package-manager.js +1 -1
  31. package/dist/env/path.js +1 -1
  32. package/dist/env/pre-commit.js +2 -2
  33. package/dist/env/rewire.d.ts +7 -7
  34. package/dist/env/rewire.js +1 -1
  35. package/dist/env/shell.js +1 -1
  36. package/dist/env/socket-cli-shadow.js +2 -2
  37. package/dist/env/socket-cli.js +2 -2
  38. package/dist/env/socket.js +2 -2
  39. package/dist/env/temp-dir.js +1 -1
  40. package/dist/env/term.js +1 -1
  41. package/dist/env/test.js +3 -3
  42. package/dist/env/windows.js +1 -1
  43. package/dist/env/xdg.js +1 -1
  44. package/dist/fs.js +20 -25
  45. package/dist/git.d.ts +6 -6
  46. package/dist/git.js +11 -14
  47. package/dist/github.js +2 -2
  48. package/dist/globs.js +16 -29
  49. package/dist/ipc.d.ts +4 -4
  50. package/dist/ipc.js +3 -3
  51. package/dist/logger.d.ts +0 -25
  52. package/dist/logger.js +0 -26
  53. package/dist/objects.js +1 -1
  54. package/dist/package-default-node-range.js +13 -3
  55. package/dist/package-extensions.d.ts +2 -1
  56. package/dist/package-extensions.js +12 -2
  57. package/dist/packages/editable.d.ts +0 -3
  58. package/dist/packages/editable.js +34 -24
  59. package/dist/packages/exports.js +1 -1
  60. package/dist/packages/isolation.js +33 -33
  61. package/dist/packages/licenses.js +20 -34
  62. package/dist/packages/manifest.js +21 -36
  63. package/dist/packages/normalize.js +20 -52
  64. package/dist/packages/operations.js +39 -103
  65. package/dist/packages/provenance.js +15 -5
  66. package/dist/packages/specs.js +13 -12
  67. package/dist/packages/validation.js +12 -10
  68. package/dist/packages.d.ts +2 -2
  69. package/dist/packages.js +3 -3
  70. package/dist/paths/dirnames.d.ts +13 -0
  71. package/dist/paths/dirnames.js +50 -0
  72. package/dist/paths/exts.d.ts +18 -0
  73. package/dist/paths/exts.js +68 -0
  74. package/dist/paths/filenames.d.ts +16 -0
  75. package/dist/paths/filenames.js +62 -0
  76. package/dist/paths/globs.d.ts +10 -0
  77. package/dist/{argv/quote.js → paths/globs.js} +21 -19
  78. package/dist/{path.d.ts → paths/normalize.d.ts} +41 -0
  79. package/dist/{path.js → paths/normalize.js} +18 -5
  80. package/dist/{packages/paths.js → paths/packages.js} +8 -8
  81. package/dist/paths/rewire.d.ts +1 -1
  82. package/dist/{paths.js → paths/socket.js} +31 -67
  83. package/dist/promises.js +2 -2
  84. package/dist/sea.js +2 -2
  85. package/dist/shadow.js +3 -3
  86. package/dist/sorts.js +12 -2
  87. package/dist/spawn.d.ts +15 -12
  88. package/dist/spawn.js +43 -31
  89. package/dist/spinner.d.ts +2 -6
  90. package/dist/spinner.js +9 -41
  91. package/dist/stdio/prompts.d.ts +8 -10
  92. package/dist/stdio/prompts.js +15 -13
  93. package/dist/streams.d.ts +0 -4
  94. package/dist/streams.js +3 -12
  95. package/dist/temporary-executor.js +4 -4
  96. package/dist/versions.js +31 -28
  97. package/package.json +28 -29
  98. package/dist/argv/quote.d.ts +0 -49
  99. package/dist/constants/paths.d.ts +0 -51
  100. package/dist/constants/paths.js +0 -152
  101. /package/dist/{packages/paths.d.ts → paths/packages.d.ts} +0 -0
  102. /package/dist/{paths.d.ts → paths/socket.d.ts} +0 -0
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
  *
package/dist/objects.js CHANGED
@@ -40,7 +40,7 @@ __export(objects_exports, {
40
40
  toSortedObjectFromEntries: () => toSortedObjectFromEntries
41
41
  });
42
42
  module.exports = __toCommonJS(objects_exports);
43
- var import_core = require("#constants/core");
43
+ var import_core = require("./constants/core");
44
44
  var import_arrays = require("./arrays");
45
45
  var import_sorts = require("./sorts");
46
46
  const ObjectDefineProperties = Object.defineProperties;
@@ -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,
@@ -27,7 +27,7 @@ __export(exports_exports, {
27
27
  resolvePackageJsonEntryExports: () => resolvePackageJsonEntryExports
28
28
  });
29
29
  module.exports = __toCommonJS(exports_exports);
30
- var import_core = require("#constants/core");
30
+ var import_core = require("../constants/core");
31
31
  var import_arrays = require("../arrays");
32
32
  var import_objects = require("../objects");
33
33
  // @__NO_SIDE_EFFECTS__
@@ -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 isolation_exports = {};
21
31
  __export(isolation_exports, {
@@ -23,18 +33,13 @@ __export(isolation_exports, {
23
33
  });
24
34
  module.exports = __toCommonJS(isolation_exports);
25
35
  var import_fs = require("fs");
26
- var import_platform = require("#constants/platform");
27
- var import_path = require("../path");
36
+ var import_platform = require("../constants/platform");
37
+ var import_node_path = __toESM(require("node:path"));
38
+ var import_npm_package_arg = __toESM(require("../external/npm-package-arg"));
39
+ var import_spawn = require("../spawn");
40
+ var import_normalize = require("../paths/normalize");
28
41
  var import_operations = require("./operations");
29
- var import_paths = require("#lib/paths");
30
- let _path;
31
- // @__NO_SIDE_EFFECTS__
32
- function getPath() {
33
- if (_path === void 0) {
34
- _path = require("node:path");
35
- }
36
- return _path;
37
- }
42
+ var import_socket = require("../paths/socket");
38
43
  const FS_CP_OPTIONS = {
39
44
  dereference: true,
40
45
  errorOnExist: false,
@@ -44,8 +49,7 @@ const FS_CP_OPTIONS = {
44
49
  ...import_platform.WIN32 ? { maxRetries: 3, retryDelay: 100 } : {}
45
50
  };
46
51
  async function resolveRealPath(pathStr) {
47
- const path = /* @__PURE__ */ getPath();
48
- return await import_fs.promises.realpath(pathStr).catch(() => path.resolve(pathStr));
52
+ return await import_fs.promises.realpath(pathStr).catch(() => import_node_path.default.resolve(pathStr));
49
53
  }
50
54
  async function mergePackageJson(pkgJsonPath, originalPkgJson) {
51
55
  const pkgJson = JSON.parse(await import_fs.promises.readFile(pkgJsonPath, "utf8"));
@@ -53,16 +57,15 @@ async function mergePackageJson(pkgJsonPath, originalPkgJson) {
53
57
  return mergedPkgJson;
54
58
  }
55
59
  async function isolatePackage(packageSpec, options) {
56
- const path = /* @__PURE__ */ getPath();
57
60
  const opts = { __proto__: null, ...options };
58
61
  const { imports, install, onPackageJson, sourcePath: optSourcePath } = opts;
59
62
  let sourcePath = optSourcePath;
60
63
  let packageName;
61
64
  let spec;
62
- if ((0, import_path.isPath)(packageSpec)) {
63
- const trimmedPath = (0, import_path.trimLeadingDotSlash)(packageSpec);
64
- const pathToResolve = (0, import_path.isAbsolute)(trimmedPath) ? trimmedPath : packageSpec;
65
- sourcePath = path.resolve(pathToResolve);
65
+ if ((0, import_normalize.isPath)(packageSpec)) {
66
+ const trimmedPath = (0, import_normalize.trimLeadingDotSlash)(packageSpec);
67
+ const pathToResolve = (0, import_normalize.isAbsolute)(trimmedPath) ? trimmedPath : packageSpec;
68
+ sourcePath = import_node_path.default.resolve(pathToResolve);
66
69
  if (!(0, import_fs.existsSync)(sourcePath)) {
67
70
  throw new Error(`Source path does not exist: ${sourcePath}`);
68
71
  }
@@ -72,8 +75,7 @@ async function isolatePackage(packageSpec, options) {
72
75
  }
73
76
  packageName = pkgJson.name;
74
77
  } else {
75
- const npa = require("../external/npm-package-arg");
76
- const parsed = npa(packageSpec);
78
+ const parsed = (0, import_npm_package_arg.default)(packageSpec);
77
79
  packageName = parsed.name;
78
80
  if (parsed.type === "directory" || parsed.type === "file") {
79
81
  sourcePath = parsed.fetchSpec;
@@ -96,15 +98,15 @@ async function isolatePackage(packageSpec, options) {
96
98
  }
97
99
  const sanitizedName = packageName.replace(/[@/]/g, "-");
98
100
  const tempDir = await import_fs.promises.mkdtemp(
99
- path.join((0, import_paths.getOsTmpDir)(), `socket-test-${sanitizedName}-`)
101
+ import_node_path.default.join((0, import_socket.getOsTmpDir)(), `socket-test-${sanitizedName}-`)
100
102
  );
101
- const packageTempDir = path.join(tempDir, sanitizedName);
103
+ const packageTempDir = import_node_path.default.join(tempDir, sanitizedName);
102
104
  await import_fs.promises.mkdir(packageTempDir, { recursive: true });
103
105
  let installedPath;
104
106
  let originalPackageJson;
105
107
  if (spec) {
106
108
  await import_fs.promises.writeFile(
107
- path.join(packageTempDir, "package.json"),
109
+ import_node_path.default.join(packageTempDir, "package.json"),
108
110
  JSON.stringify(
109
111
  {
110
112
  name: "test-temp",
@@ -118,15 +120,14 @@ async function isolatePackage(packageSpec, options) {
118
120
  if (install) {
119
121
  await install(packageTempDir);
120
122
  } else {
121
- const { spawn } = require("../spawn");
122
123
  const packageInstallSpec = spec.startsWith("https://") ? spec : `${packageName}@${spec}`;
123
- await spawn("pnpm", ["add", packageInstallSpec], {
124
+ await (0, import_spawn.spawn)("pnpm", ["add", packageInstallSpec], {
124
125
  cwd: packageTempDir,
125
126
  shell: import_platform.WIN32,
126
127
  stdio: "pipe"
127
128
  });
128
129
  }
129
- installedPath = path.join(packageTempDir, "node_modules", packageName);
130
+ installedPath = import_node_path.default.join(packageTempDir, "node_modules", packageName);
130
131
  originalPackageJson = await (0, import_operations.readPackageJson)(installedPath, {
131
132
  normalize: true
132
133
  });
@@ -141,17 +142,17 @@ async function isolatePackage(packageSpec, options) {
141
142
  if (!sourcePath) {
142
143
  throw new Error("sourcePath is required when no version spec provided");
143
144
  }
144
- const scopedPath = packageName.startsWith("@") ? path.join(
145
+ const scopedPath = packageName.startsWith("@") ? import_node_path.default.join(
145
146
  packageTempDir,
146
147
  "node_modules",
147
148
  packageName.split("/")[0] ?? ""
148
- ) : path.join(packageTempDir, "node_modules");
149
+ ) : import_node_path.default.join(packageTempDir, "node_modules");
149
150
  await import_fs.promises.mkdir(scopedPath, { recursive: true });
150
- installedPath = path.join(packageTempDir, "node_modules", packageName);
151
+ installedPath = import_node_path.default.join(packageTempDir, "node_modules", packageName);
151
152
  await import_fs.promises.cp(sourcePath, installedPath, FS_CP_OPTIONS);
152
153
  }
153
154
  if (onPackageJson || originalPackageJson) {
154
- const pkgJsonPath = path.join(installedPath, "package.json");
155
+ const pkgJsonPath = import_node_path.default.join(installedPath, "package.json");
155
156
  const mergedPkgJson = await mergePackageJson(
156
157
  pkgJsonPath,
157
158
  originalPackageJson
@@ -162,8 +163,7 @@ async function isolatePackage(packageSpec, options) {
162
163
  if (install) {
163
164
  await install(installedPath);
164
165
  } else {
165
- const { spawn } = require("../spawn");
166
- await spawn("pnpm", ["install"], {
166
+ await (0, import_spawn.spawn)("pnpm", ["install"], {
167
167
  cwd: installedPath,
168
168
  shell: import_platform.WIN32,
169
169
  stdio: "pipe"
@@ -172,7 +172,7 @@ async function isolatePackage(packageSpec, options) {
172
172
  const exports2 = imports ? { __proto__: null } : void 0;
173
173
  if (imports) {
174
174
  for (const { 0: key, 1: specifier } of Object.entries(imports)) {
175
- const fullPath = path.join(installedPath, specifier);
175
+ const fullPath = import_node_path.default.join(installedPath, specifier);
176
176
  exports2[key] = require(fullPath);
177
177
  }
178
178
  }
@@ -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 licenses_exports = {};
21
31
  __export(licenses_exports, {
@@ -29,38 +39,17 @@ __export(licenses_exports, {
29
39
  visitLicenses: () => visitLicenses
30
40
  });
31
41
  module.exports = __toCommonJS(licenses_exports);
32
- var import_core = require("#constants/core");
33
- var import_licenses = require("#constants/licenses");
42
+ var import_core = require("../constants/core");
43
+ var import_licenses = require("../constants/licenses");
44
+ var import_node_path = __toESM(require("node:path"));
45
+ var import_spdx_correct = __toESM(require("../external/spdx-correct"));
46
+ var import_spdx_expression_parse = __toESM(require("../external/spdx-expression-parse"));
34
47
  var import_objects = require("../objects");
35
- var import_path = require("../path");
48
+ var import_normalize = require("../paths/normalize");
36
49
  const copyLeftLicenses = (0, import_licenses.getCopyLeftLicenses)();
37
50
  const BINARY_OPERATION_NODE_TYPE = "BinaryOperation";
38
51
  const LICENSE_NODE_TYPE = "License";
39
52
  const fileReferenceRegExp = /^SEE LICEN[CS]E IN (.+)$/;
40
- let _path;
41
- // @__NO_SIDE_EFFECTS__
42
- function getPath() {
43
- if (_path === void 0) {
44
- _path = require("node:path");
45
- }
46
- return _path;
47
- }
48
- let _spdxCorrect;
49
- // @__NO_SIDE_EFFECTS__
50
- function getSpdxCorrect() {
51
- if (_spdxCorrect === void 0) {
52
- _spdxCorrect = require("../external/spdx-correct");
53
- }
54
- return _spdxCorrect;
55
- }
56
- let _spdxExpParse;
57
- // @__NO_SIDE_EFFECTS__
58
- function getSpdxExpParse() {
59
- if (_spdxExpParse === void 0) {
60
- _spdxExpParse = require("../external/spdx-expression-parse");
61
- }
62
- return _spdxExpParse;
63
- }
64
53
  // @__NO_SIDE_EFFECTS__
65
54
  function collectIncompatibleLicenses(licenseNodes) {
66
55
  const result = [];
@@ -130,14 +119,12 @@ function createLicenseNode(rawNode) {
130
119
  }
131
120
  // @__NO_SIDE_EFFECTS__
132
121
  function parseSpdxExp(spdxExp) {
133
- const spdxExpParse = /* @__PURE__ */ getSpdxExpParse();
134
122
  try {
135
- return spdxExpParse(spdxExp);
123
+ return (0, import_spdx_expression_parse.default)(spdxExp);
136
124
  } catch {
137
125
  }
138
- const spdxCorrect = /* @__PURE__ */ getSpdxCorrect();
139
- const corrected = spdxCorrect(spdxExp);
140
- return corrected ? spdxExpParse(corrected) : void 0;
126
+ const corrected = (0, import_spdx_correct.default)(spdxExp);
127
+ return corrected ? (0, import_spdx_expression_parse.default)(corrected) : void 0;
141
128
  }
142
129
  // @__NO_SIDE_EFFECTS__
143
130
  function resolvePackageLicenses(licenseFieldValue, where) {
@@ -146,11 +133,10 @@ function resolvePackageLicenses(licenseFieldValue, where) {
146
133
  }
147
134
  const match = fileReferenceRegExp.exec(licenseFieldValue);
148
135
  if (match) {
149
- const path = /* @__PURE__ */ getPath();
150
136
  return [
151
137
  {
152
138
  license: licenseFieldValue,
153
- inFile: (0, import_path.normalizePath)(path.relative(where, match[1] || ""))
139
+ inFile: (0, import_normalize.normalizePath)(import_node_path.default.relative(where, match[1] || ""))
154
140
  }
155
141
  ];
156
142
  }