@socketsecurity/lib 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cover/code.js +12 -4
  3. package/dist/dlx/cache.js +10 -2
  4. package/dist/dlx/manifest.js +45 -41
  5. package/dist/env/rewire.js +10 -2
  6. package/dist/external/@inquirer/checkbox.js +4 -2528
  7. package/dist/external/@inquirer/confirm.js +4 -2371
  8. package/dist/external/@inquirer/input.js +4 -2395
  9. package/dist/external/@inquirer/password.js +4 -2503
  10. package/dist/external/@inquirer/search.js +4 -2500
  11. package/dist/external/@inquirer/select.js +4 -2617
  12. package/dist/external/del.js +4 -7139
  13. package/dist/external/fast-glob.js +4 -5776
  14. package/dist/external/inquirer-pack.js +4610 -0
  15. package/dist/external/npm-core.js +3 -1
  16. package/dist/external/pico-pack.js +7162 -0
  17. package/dist/external/picomatch.js +4 -1523
  18. package/dist/external/spdx-correct.js +4 -1384
  19. package/dist/external/spdx-expression-parse.js +4 -1047
  20. package/dist/external/spdx-pack.js +1640 -0
  21. package/dist/external/validate-npm-package-name.js +4 -104
  22. package/dist/http-request.js +10 -2
  23. package/dist/ipc.js +53 -29
  24. package/dist/packages/isolation.js +45 -23
  25. package/dist/packages/licenses.js +10 -2
  26. package/dist/paths/socket.d.ts +2 -2
  27. package/dist/paths/socket.js +27 -21
  28. package/dist/process-lock.js +23 -14
  29. package/dist/releases/github.d.ts +67 -41
  30. package/dist/releases/github.js +142 -100
  31. package/dist/releases/socket-btm.d.ts +40 -33
  32. package/dist/releases/socket-btm.js +45 -5
  33. package/dist/spawn.js +10 -3
  34. package/dist/stdio/mask.d.ts +6 -21
  35. package/dist/stdio/mask.js +18 -14
  36. package/dist/themes/context.js +10 -2
  37. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.4.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.4.0) - 2026-01-07
9
+
10
+ ### Added
11
+
12
+ - **releases/github**: Extended release functions to accept glob patterns for asset discovery
13
+ - `getReleaseAssetUrl()` now accepts glob patterns: `'yoga-sync-*.mjs'`, `'models-*.tar.gz'`
14
+ - `downloadReleaseAsset()` now accepts glob patterns for automatic asset discovery
15
+ - `getLatestRelease()` now accepts asset patterns to find releases with matching assets
16
+ - Supports wildcards, brace expansion, RegExp patterns, and prefix/suffix objects
17
+ - Uses picomatch for robust glob pattern matching
18
+
19
+ - **releases/socket-btm**: Extended `downloadSocketBtmRelease()` to accept glob patterns
20
+ - `asset` parameter now accepts wildcards: `'yoga-sync-*.mjs'`, `'models-*.tar.gz'`
21
+ - Automatically discovers and downloads latest matching asset
22
+ - Eliminates need for hardcoded asset names in build scripts
23
+
8
24
  ## [5.3.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.3.0) - 2026-01-07
9
25
 
10
26
  ### Added
@@ -22,12 +22,19 @@ __export(code_exports, {
22
22
  getCodeCoverage: () => getCodeCoverage
23
23
  });
24
24
  module.exports = __toCommonJS(code_exports);
25
- var import_fs = require("fs");
26
- var import_fs2 = require("../fs");
25
+ var import_fs = require("../fs");
27
26
  var import_objects = require("../objects");
28
27
  var import_spawn = require("../spawn");
28
+ let _fs;
29
29
  let _path;
30
30
  // @__NO_SIDE_EFFECTS__
31
+ function getFs() {
32
+ if (_fs === void 0) {
33
+ _fs = require("fs");
34
+ }
35
+ return _fs;
36
+ }
37
+ // @__NO_SIDE_EFFECTS__
31
38
  function getPath() {
32
39
  if (_path === void 0) {
33
40
  _path = require("path");
@@ -46,7 +53,8 @@ async function getCodeCoverage(options) {
46
53
  if (!coveragePath) {
47
54
  throw new Error("Coverage path is required");
48
55
  }
49
- const coverageExists = await import_fs.promises.access(coveragePath).then(() => true).catch(() => false);
56
+ const fs = /* @__PURE__ */ getFs();
57
+ const coverageExists = await fs.promises.access(coveragePath).then(() => true).catch(() => false);
50
58
  if (!coverageExists) {
51
59
  if (generateIfMissing) {
52
60
  await (0, import_spawn.spawn)("vitest", ["run", "--coverage"], {
@@ -59,7 +67,7 @@ async function getCodeCoverage(options) {
59
67
  );
60
68
  }
61
69
  }
62
- const coverageData = await (0, import_fs2.readJson)(coveragePath);
70
+ const coverageData = await (0, import_fs.readJson)(coveragePath);
63
71
  if (!(0, import_objects.isObjectObject)(coverageData)) {
64
72
  throw new Error(`Invalid coverage data format in "${coveragePath}"`);
65
73
  }
package/dist/dlx/cache.js CHANGED
@@ -22,9 +22,17 @@ __export(cache_exports, {
22
22
  generateCacheKey: () => generateCacheKey
23
23
  });
24
24
  module.exports = __toCommonJS(cache_exports);
25
- var import_node_crypto = require("node:crypto");
25
+ let _crypto;
26
+ // @__NO_SIDE_EFFECTS__
27
+ function getCrypto() {
28
+ if (_crypto === void 0) {
29
+ _crypto = require("crypto");
30
+ }
31
+ return _crypto;
32
+ }
26
33
  function generateCacheKey(spec) {
27
- return (0, import_node_crypto.createHash)("sha512").update(spec).digest("hex").substring(0, 16);
34
+ const crypto = /* @__PURE__ */ getCrypto();
35
+ return crypto.createHash("sha512").update(spec).digest("hex").substring(0, 16);
28
36
  }
29
37
  // Annotate the CommonJS export names for ESM import in node:
30
38
  0 && (module.exports = {
@@ -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 manifest_exports = {};
31
21
  __export(manifest_exports, {
@@ -35,12 +25,26 @@ __export(manifest_exports, {
35
25
  isPackageEntry: () => isPackageEntry
36
26
  });
37
27
  module.exports = __toCommonJS(manifest_exports);
38
- var import_fs = require("fs");
39
- var import_path = __toESM(require("path"));
40
- var import_fs2 = require("../fs");
28
+ var import_fs = require("../fs");
41
29
  var import_logger = require("../logger");
42
30
  var import_socket = require("../paths/socket");
43
31
  var import_process_lock = require("../process-lock");
32
+ let _fs;
33
+ let _path;
34
+ // @__NO_SIDE_EFFECTS__
35
+ function getFs() {
36
+ if (_fs === void 0) {
37
+ _fs = require("fs");
38
+ }
39
+ return _fs;
40
+ }
41
+ // @__NO_SIDE_EFFECTS__
42
+ function getPath() {
43
+ if (_path === void 0) {
44
+ _path = require("path");
45
+ }
46
+ return _path;
47
+ }
44
48
  const logger = (0, import_logger.getDefaultLogger)();
45
49
  const MANIFEST_FILE_NAME = ".dlx-manifest.json";
46
50
  function isPackageEntry(entry) {
@@ -53,7 +57,7 @@ class DlxManifest {
53
57
  manifestPath;
54
58
  lockPath;
55
59
  constructor(options = {}) {
56
- this.manifestPath = options.manifestPath ?? import_path.default.join((0, import_socket.getSocketDlxDir)(), MANIFEST_FILE_NAME);
60
+ this.manifestPath = options.manifestPath ?? (/* @__PURE__ */ getPath()).join((0, import_socket.getSocketDlxDir)(), MANIFEST_FILE_NAME);
57
61
  this.lockPath = `${this.manifestPath}.lock`;
58
62
  }
59
63
  /**
@@ -61,10 +65,10 @@ class DlxManifest {
61
65
  */
62
66
  readManifest() {
63
67
  try {
64
- if (!(0, import_fs.existsSync)(this.manifestPath)) {
68
+ if (!(/* @__PURE__ */ getFs()).existsSync(this.manifestPath)) {
65
69
  return /* @__PURE__ */ Object.create(null);
66
70
  }
67
- const rawContent = (0, import_fs2.readFileUtf8Sync)(this.manifestPath);
71
+ const rawContent = (0, import_fs.readFileUtf8Sync)(this.manifestPath);
68
72
  const content = (typeof rawContent === "string" ? rawContent : rawContent.toString("utf8")).trim();
69
73
  if (!content) {
70
74
  return /* @__PURE__ */ Object.create(null);
@@ -134,9 +138,9 @@ class DlxManifest {
134
138
  * Write the manifest file atomically.
135
139
  */
136
140
  async writeManifest(data) {
137
- const manifestDir = import_path.default.dirname(this.manifestPath);
141
+ const manifestDir = (/* @__PURE__ */ getPath()).dirname(this.manifestPath);
138
142
  try {
139
- (0, import_fs2.safeMkdirSync)(manifestDir, { recursive: true });
143
+ (0, import_fs.safeMkdirSync)(manifestDir, { recursive: true });
140
144
  } catch (error) {
141
145
  logger.warn(
142
146
  `Failed to create manifest directory: ${error instanceof Error ? error.message : String(error)}`
@@ -145,18 +149,18 @@ class DlxManifest {
145
149
  const content = JSON.stringify(data, null, 2);
146
150
  const tempPath = `${this.manifestPath}.tmp`;
147
151
  try {
148
- (0, import_fs.writeFileSync)(tempPath, content, "utf8");
149
- (0, import_fs.writeFileSync)(this.manifestPath, content, "utf8");
152
+ (/* @__PURE__ */ getFs()).writeFileSync(tempPath, content, "utf8");
153
+ (/* @__PURE__ */ getFs()).writeFileSync(this.manifestPath, content, "utf8");
150
154
  try {
151
- if ((0, import_fs.existsSync)(tempPath)) {
152
- (0, import_fs.unlinkSync)(tempPath);
155
+ if ((/* @__PURE__ */ getFs()).existsSync(tempPath)) {
156
+ (/* @__PURE__ */ getFs()).unlinkSync(tempPath);
153
157
  }
154
158
  } catch {
155
159
  }
156
160
  } catch (error) {
157
161
  try {
158
- if ((0, import_fs.existsSync)(tempPath)) {
159
- (0, import_fs.unlinkSync)(tempPath);
162
+ if ((/* @__PURE__ */ getFs()).existsSync(tempPath)) {
163
+ (/* @__PURE__ */ getFs()).unlinkSync(tempPath);
160
164
  }
161
165
  } catch {
162
166
  }
@@ -171,8 +175,8 @@ class DlxManifest {
171
175
  await import_process_lock.processLock.withLock(this.lockPath, async () => {
172
176
  let data = /* @__PURE__ */ Object.create(null);
173
177
  try {
174
- if ((0, import_fs.existsSync)(this.manifestPath)) {
175
- const content2 = (0, import_fs.readFileSync)(this.manifestPath, "utf8");
178
+ if ((/* @__PURE__ */ getFs()).existsSync(this.manifestPath)) {
179
+ const content2 = (/* @__PURE__ */ getFs()).readFileSync(this.manifestPath, "utf8");
176
180
  if (content2.trim()) {
177
181
  data = JSON.parse(content2);
178
182
  }
@@ -183,9 +187,9 @@ class DlxManifest {
183
187
  );
184
188
  }
185
189
  data[name] = record;
186
- const manifestDir = import_path.default.dirname(this.manifestPath);
190
+ const manifestDir = (/* @__PURE__ */ getPath()).dirname(this.manifestPath);
187
191
  try {
188
- (0, import_fs2.safeMkdirSync)(manifestDir, { recursive: true });
192
+ (0, import_fs.safeMkdirSync)(manifestDir, { recursive: true });
189
193
  } catch (error) {
190
194
  logger.warn(
191
195
  `Failed to create manifest directory: ${error instanceof Error ? error.message : String(error)}`
@@ -194,18 +198,18 @@ class DlxManifest {
194
198
  const content = JSON.stringify(data, null, 2);
195
199
  const tempPath = `${this.manifestPath}.tmp`;
196
200
  try {
197
- (0, import_fs.writeFileSync)(tempPath, content, "utf8");
198
- (0, import_fs.writeFileSync)(this.manifestPath, content, "utf8");
201
+ (/* @__PURE__ */ getFs()).writeFileSync(tempPath, content, "utf8");
202
+ (/* @__PURE__ */ getFs()).writeFileSync(this.manifestPath, content, "utf8");
199
203
  try {
200
- if ((0, import_fs.existsSync)(tempPath)) {
201
- (0, import_fs.unlinkSync)(tempPath);
204
+ if ((/* @__PURE__ */ getFs()).existsSync(tempPath)) {
205
+ (/* @__PURE__ */ getFs()).unlinkSync(tempPath);
202
206
  }
203
207
  } catch {
204
208
  }
205
209
  } catch (error) {
206
210
  try {
207
- if ((0, import_fs.existsSync)(tempPath)) {
208
- (0, import_fs.unlinkSync)(tempPath);
211
+ if ((/* @__PURE__ */ getFs()).existsSync(tempPath)) {
212
+ (/* @__PURE__ */ getFs()).unlinkSync(tempPath);
209
213
  }
210
214
  } catch {
211
215
  }
@@ -219,17 +223,17 @@ class DlxManifest {
219
223
  async clear(name) {
220
224
  await import_process_lock.processLock.withLock(this.lockPath, async () => {
221
225
  try {
222
- if (!(0, import_fs.existsSync)(this.manifestPath)) {
226
+ if (!(/* @__PURE__ */ getFs()).existsSync(this.manifestPath)) {
223
227
  return;
224
228
  }
225
- const content = (0, import_fs.readFileSync)(this.manifestPath, "utf8");
229
+ const content = (/* @__PURE__ */ getFs()).readFileSync(this.manifestPath, "utf8");
226
230
  if (!content.trim()) {
227
231
  return;
228
232
  }
229
233
  const data = JSON.parse(content);
230
234
  delete data[name];
231
235
  const updatedContent = JSON.stringify(data, null, 2);
232
- (0, import_fs.writeFileSync)(this.manifestPath, updatedContent, "utf8");
236
+ (/* @__PURE__ */ getFs()).writeFileSync(this.manifestPath, updatedContent, "utf8");
233
237
  } catch (error) {
234
238
  logger.warn(
235
239
  `Failed to clear cache for ${name}: ${error instanceof Error ? error.message : String(error)}`
@@ -243,8 +247,8 @@ class DlxManifest {
243
247
  async clearAll() {
244
248
  await import_process_lock.processLock.withLock(this.lockPath, async () => {
245
249
  try {
246
- if ((0, import_fs.existsSync)(this.manifestPath)) {
247
- (0, import_fs.unlinkSync)(this.manifestPath);
250
+ if ((/* @__PURE__ */ getFs()).existsSync(this.manifestPath)) {
251
+ (/* @__PURE__ */ getFs()).unlinkSync(this.manifestPath);
248
252
  }
249
253
  } catch (error) {
250
254
  logger.warn(
@@ -268,10 +272,10 @@ class DlxManifest {
268
272
  */
269
273
  getAllPackages() {
270
274
  try {
271
- if (!(0, import_fs.existsSync)(this.manifestPath)) {
275
+ if (!(/* @__PURE__ */ getFs()).existsSync(this.manifestPath)) {
272
276
  return [];
273
277
  }
274
- const rawContent = (0, import_fs2.readFileUtf8Sync)(this.manifestPath);
278
+ const rawContent = (0, import_fs.readFileUtf8Sync)(this.manifestPath);
275
279
  const content = (typeof rawContent === "string" ? rawContent : rawContent.toString("utf8")).trim();
276
280
  if (!content) {
277
281
  return [];
@@ -28,9 +28,17 @@ __export(rewire_exports, {
28
28
  withEnvSync: () => withEnvSync
29
29
  });
30
30
  module.exports = __toCommonJS(rewire_exports);
31
- var import_async_hooks = require("async_hooks");
32
31
  var import_helpers = require("./helpers");
33
- const isolatedOverridesStorage = new import_async_hooks.AsyncLocalStorage();
32
+ let _async_hooks;
33
+ // @__NO_SIDE_EFFECTS__
34
+ function getAsyncHooks() {
35
+ if (_async_hooks === void 0) {
36
+ _async_hooks = require("async_hooks");
37
+ }
38
+ return _async_hooks;
39
+ }
40
+ const { AsyncLocalStorage } = /* @__PURE__ */ getAsyncHooks();
41
+ const isolatedOverridesStorage = new AsyncLocalStorage();
34
42
  const sharedOverridesSymbol = Symbol.for(
35
43
  "@socketsecurity/lib/env/rewire/test-overrides"
36
44
  );