@socketsecurity/lib 5.18.2 → 5.19.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.
- package/CHANGELOG.md +57 -0
- package/README.md +6 -5
- package/dist/abort.d.ts +3 -0
- package/dist/abort.js +1 -0
- package/dist/agent.d.ts +66 -49
- package/dist/agent.js +51 -50
- package/dist/ansi.d.ts +2 -5
- package/dist/ansi.js +3 -2
- package/dist/archives.d.ts +25 -21
- package/dist/archives.js +35 -34
- package/dist/argv/flags.d.ts +100 -91
- package/dist/argv/flags.js +88 -87
- package/dist/argv/parse.d.ts +30 -40
- package/dist/argv/parse.js +33 -32
- package/dist/arrays.d.ts +4 -8
- package/dist/arrays.js +1 -0
- package/dist/bin.d.ts +7 -5
- package/dist/bin.js +52 -29
- package/dist/cacache.d.ts +13 -12
- package/dist/cacache.js +9 -8
- package/dist/cache-with-ttl.d.ts +53 -35
- package/dist/cache-with-ttl.js +1 -0
- package/dist/colors.d.ts +5 -5
- package/dist/colors.js +1 -0
- package/dist/constants/agents.d.ts +5 -9
- package/dist/constants/agents.js +3 -2
- package/dist/constants/core.d.ts +5 -10
- package/dist/constants/core.js +2 -1
- package/dist/constants/encoding.d.ts +3 -3
- package/dist/constants/encoding.js +1 -0
- package/dist/constants/github.d.ts +3 -3
- package/dist/constants/github.js +1 -0
- package/dist/constants/licenses.d.ts +9 -2
- package/dist/constants/licenses.js +1 -0
- package/dist/constants/lifecycle-script-names.js +1 -0
- package/dist/constants/maintained-node-versions.d.ts +3 -0
- package/dist/constants/maintained-node-versions.js +1 -0
- package/dist/constants/node.d.ts +125 -16
- package/dist/constants/node.js +74 -73
- package/dist/constants/package-default-node-range.d.ts +3 -1
- package/dist/constants/package-default-node-range.js +2 -1
- package/dist/constants/package-default-socket-categories.d.ts +0 -1
- package/dist/constants/package-default-socket-categories.js +1 -0
- package/dist/constants/packages.d.ts +12 -17
- package/dist/constants/packages.js +31 -16
- package/dist/constants/platform.d.ts +1 -2
- package/dist/constants/platform.js +2 -1
- package/dist/constants/process.d.ts +18 -0
- package/dist/constants/process.js +1 -0
- package/dist/constants/socket.d.ts +4 -10
- package/dist/constants/socket.js +2 -1
- package/dist/constants/testing.d.ts +3 -3
- package/dist/constants/testing.js +1 -0
- package/dist/constants/time.d.ts +3 -4
- package/dist/constants/time.js +1 -0
- package/dist/constants/typescript.d.ts +10 -3
- package/dist/constants/typescript.js +5 -4
- package/dist/cover/code.d.ts +3 -0
- package/dist/cover/code.js +12 -12
- package/dist/cover/formatters.d.ts +12 -9
- package/dist/cover/formatters.js +19 -18
- package/dist/cover/type.d.ts +3 -0
- package/dist/cover/type.js +1 -0
- package/dist/cover/types.js +1 -0
- package/dist/debug.d.ts +32 -47
- package/dist/debug.js +97 -96
- package/dist/dlx/arborist.d.ts +134 -0
- package/dist/dlx/arborist.js +177 -0
- package/dist/dlx/binary.d.ts +25 -9
- package/dist/dlx/binary.js +34 -12
- package/dist/dlx/cache.d.ts +1 -0
- package/dist/dlx/cache.js +2 -1
- package/dist/dlx/detect.d.ts +15 -0
- package/dist/dlx/detect.js +28 -20
- package/dist/dlx/dir.d.ts +1 -11
- package/dist/dlx/dir.js +2 -12
- package/dist/dlx/integrity.d.ts +86 -0
- package/dist/dlx/integrity.js +112 -0
- package/dist/dlx/lockfile.d.ts +115 -0
- package/dist/dlx/lockfile.js +139 -0
- package/dist/dlx/manifest.d.ts +26 -1
- package/dist/dlx/manifest.js +9 -6
- package/dist/dlx/package.d.ts +58 -3
- package/dist/dlx/package.js +101 -74
- package/dist/dlx/packages.d.ts +1 -11
- package/dist/dlx/packages.js +3 -14
- package/dist/dlx/paths.d.ts +1 -0
- package/dist/dlx/paths.js +2 -1
- package/dist/effects/pulse-frames.js +1 -0
- package/dist/effects/text-shimmer.d.ts +13 -2
- package/dist/effects/text-shimmer.js +50 -46
- package/dist/effects/types.js +1 -0
- package/dist/effects/ultra.js +1 -0
- package/dist/env/ci.d.ts +6 -1
- package/dist/env/ci.js +1 -0
- package/dist/env/debug.d.ts +5 -1
- package/dist/env/debug.js +1 -0
- package/dist/env/github.d.ts +19 -23
- package/dist/env/github.js +5 -4
- package/dist/env/helpers.d.ts +21 -9
- package/dist/env/helpers.js +5 -11
- package/dist/env/home.d.ts +17 -4
- package/dist/env/home.js +2 -1
- package/dist/env/locale.d.ts +4 -3
- package/dist/env/locale.js +1 -0
- package/dist/env/node-auth-token.d.ts +5 -1
- package/dist/env/node-auth-token.js +1 -0
- package/dist/env/node-env.d.ts +5 -1
- package/dist/env/node-env.js +1 -0
- package/dist/env/npm.d.ts +4 -5
- package/dist/env/npm.js +1 -0
- package/dist/env/package-manager.d.ts +4 -3
- package/dist/env/package-manager.js +2 -1
- package/dist/env/path.d.ts +5 -1
- package/dist/env/path.js +1 -0
- package/dist/env/pre-commit.d.ts +5 -1
- package/dist/env/pre-commit.js +1 -0
- package/dist/env/rewire.d.ts +10 -0
- package/dist/env/rewire.js +7 -5
- package/dist/env/shell.d.ts +5 -1
- package/dist/env/shell.js +1 -0
- package/dist/env/socket-cli-shadow.d.ts +4 -5
- package/dist/env/socket-cli-shadow.js +1 -0
- package/dist/env/socket-cli.d.ts +4 -14
- package/dist/env/socket-cli.js +1 -0
- package/dist/env/socket.d.ts +6 -18
- package/dist/env/socket.js +4 -3
- package/dist/env/temp-dir.d.ts +4 -3
- package/dist/env/temp-dir.js +1 -0
- package/dist/env/term.d.ts +5 -1
- package/dist/env/term.js +1 -0
- package/dist/env/test.d.ts +4 -3
- package/dist/env/test.js +1 -0
- package/dist/env/windows.d.ts +4 -4
- package/dist/env/windows.js +1 -0
- package/dist/env/xdg.d.ts +4 -3
- package/dist/env/xdg.js +1 -0
- package/dist/env.d.ts +83 -23
- package/dist/env.js +112 -80
- package/dist/errors.js +1 -0
- package/dist/external/@socketregistry/packageurl-js.js +2 -2
- package/dist/external/external-pack.js +1562 -1673
- package/dist/external/npm-pack.js +5 -1
- package/dist/fs.d.ts +92 -113
- package/dist/fs.js +35 -35
- package/dist/git.d.ts +170 -164
- package/dist/git.js +113 -87
- package/dist/github.d.ts +249 -227
- package/dist/github.js +82 -81
- package/dist/globs.d.ts +31 -17
- package/dist/globs.js +51 -58
- package/dist/http-request.d.ts +99 -99
- package/dist/http-request.js +182 -156
- package/dist/ipc-cli.d.ts +28 -0
- package/dist/{utils/get-ipc.js → ipc-cli.js} +4 -3
- package/dist/ipc.d.ts +9 -299
- package/dist/ipc.js +18 -204
- package/dist/json/edit.d.ts +3 -1
- package/dist/json/edit.js +30 -30
- package/dist/json/format.d.ts +36 -36
- package/dist/json/format.js +22 -21
- package/dist/json/parse.d.ts +4 -2
- package/dist/json/parse.js +1 -0
- package/dist/json/types.js +1 -0
- package/dist/{links/index.d.ts → links.d.ts} +6 -2
- package/dist/{links/index.js → links.js} +5 -4
- package/dist/logger.d.ts +4 -6
- package/dist/logger.js +61 -53
- package/dist/memoization.d.ts +52 -49
- package/dist/memoization.js +55 -33
- package/dist/objects.d.ts +25 -44
- package/dist/objects.js +2 -1
- package/dist/package-extensions.d.ts +6 -0
- package/dist/package-extensions.js +2 -1
- package/dist/packages/edit.d.ts +3 -5
- package/dist/packages/edit.js +4 -3
- package/dist/packages/exports.d.ts +11 -14
- package/dist/packages/exports.js +11 -10
- package/dist/packages/isolation.d.ts +4 -0
- package/dist/packages/isolation.js +20 -19
- package/dist/packages/licenses.d.ts +3 -10
- package/dist/packages/licenses.js +2 -1
- package/dist/packages/manifest.d.ts +3 -3
- package/dist/packages/manifest.js +1 -0
- package/dist/packages/normalize.d.ts +3 -4
- package/dist/packages/normalize.js +1 -0
- package/dist/packages/operations.d.ts +3 -10
- package/dist/packages/operations.js +1 -0
- package/dist/packages/provenance.d.ts +10 -8
- package/dist/packages/provenance.js +55 -54
- package/dist/packages/specs.d.ts +3 -5
- package/dist/packages/specs.js +1 -0
- package/dist/packages/validation.d.ts +3 -3
- package/dist/packages/validation.js +1 -0
- package/dist/packages.d.ts +2 -17
- package/dist/packages.js +2 -1
- package/dist/paths/dirnames.d.ts +0 -2
- package/dist/paths/dirnames.js +1 -0
- package/dist/paths/exts.d.ts +0 -1
- package/dist/paths/exts.js +1 -0
- package/dist/paths/filenames.d.ts +0 -1
- package/dist/paths/filenames.js +1 -0
- package/dist/paths/globs.d.ts +0 -1
- package/dist/paths/globs.js +1 -0
- package/dist/paths/normalize.d.ts +115 -123
- package/dist/paths/normalize.js +128 -127
- package/dist/paths/packages.d.ts +3 -2
- package/dist/paths/packages.js +2 -1
- package/dist/paths/rewire.d.ts +9 -0
- package/dist/paths/rewire.js +5 -3
- package/dist/paths/socket.d.ts +37 -23
- package/dist/paths/socket.js +26 -25
- package/dist/performance.d.ts +87 -84
- package/dist/performance.js +97 -96
- package/dist/process-lock.d.ts +41 -1
- package/dist/process-lock.js +24 -17
- package/dist/promise-queue.d.ts +6 -0
- package/dist/promise-queue.js +1 -0
- package/dist/promises.d.ts +40 -55
- package/dist/promises.js +12 -11
- package/dist/regexps.d.ts +0 -5
- package/dist/regexps.js +1 -0
- package/dist/releases/github.d.ts +59 -63
- package/dist/releases/github.js +95 -100
- package/dist/releases/socket-btm.d.ts +9 -2
- package/dist/releases/socket-btm.js +32 -25
- package/dist/sea.d.ts +5 -0
- package/dist/sea.js +1 -0
- package/dist/shadow.d.ts +4 -0
- package/dist/shadow.js +1 -0
- package/dist/signal-exit.d.ts +7 -7
- package/dist/signal-exit.js +46 -45
- package/dist/sorts.d.ts +5 -7
- package/dist/sorts.js +11 -10
- package/dist/spawn.d.ts +96 -77
- package/dist/spawn.js +39 -38
- package/dist/spinner.d.ts +21 -22
- package/dist/spinner.js +15 -11
- package/dist/ssri.d.ts +31 -36
- package/dist/ssri.js +15 -14
- package/dist/stdio/_stream.d.ts +31 -0
- package/dist/stdio/_stream.js +57 -0
- package/dist/stdio/clear.d.ts +38 -15
- package/dist/stdio/clear.js +5 -4
- package/dist/stdio/divider.d.ts +40 -36
- package/dist/stdio/divider.js +10 -9
- package/dist/stdio/footer.d.ts +20 -0
- package/dist/stdio/footer.js +12 -2
- package/dist/stdio/header.d.ts +4 -16
- package/dist/stdio/header.js +1 -9
- package/dist/stdio/progress.d.ts +4 -0
- package/dist/stdio/progress.js +13 -8
- package/dist/stdio/prompts.d.ts +24 -23
- package/dist/stdio/prompts.js +10 -9
- package/dist/stdio/stderr.d.ts +51 -39
- package/dist/stdio/stderr.js +19 -22
- package/dist/stdio/stdout.d.ts +54 -52
- package/dist/stdio/stdout.js +35 -33
- package/dist/streams.d.ts +4 -3
- package/dist/streams.js +1 -0
- package/dist/strings.d.ts +31 -85
- package/dist/strings.js +5 -49
- package/dist/suppress-warnings.d.ts +32 -15
- package/dist/suppress-warnings.js +14 -13
- package/dist/tables.d.ts +30 -26
- package/dist/tables.js +24 -23
- package/dist/temporary-executor.d.ts +4 -0
- package/dist/temporary-executor.js +1 -0
- package/dist/themes/context.d.ts +30 -26
- package/dist/themes/context.js +19 -18
- package/dist/themes/index.d.ts +0 -4
- package/dist/themes/index.js +1 -0
- package/dist/themes/themes.d.ts +1 -1
- package/dist/themes/themes.js +1 -0
- package/dist/themes/types.js +1 -0
- package/dist/themes/utils.d.ts +46 -43
- package/dist/themes/utils.js +45 -44
- package/dist/types.d.ts +48 -52
- package/dist/types.js +35 -35
- package/dist/url.d.ts +48 -53
- package/dist/url.js +38 -37
- package/dist/validation/json-parser.d.ts +19 -190
- package/dist/validation/json-parser.js +5 -69
- package/dist/validation/types.d.ts +9 -33
- package/dist/validation/types.js +1 -0
- package/dist/versions.d.ts +1 -0
- package/dist/versions.js +2 -1
- package/dist/words.d.ts +3 -6
- package/dist/words.js +1 -0
- package/dist/zod.js +1 -0
- package/package.json +40 -54
- package/dist/functions.d.ts +0 -57
- package/dist/functions.js +0 -70
- package/dist/stdio/mask.d.ts +0 -151
- package/dist/stdio/mask.js +0 -224
- package/dist/utils/get-ipc.d.ts +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,63 @@ 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.19.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.19.1) - 2026-04-19
|
|
9
|
+
|
|
10
|
+
### Fixed — stdio (restore accidentally-dropped modules)
|
|
11
|
+
|
|
12
|
+
5.19.0 shipped a breaking change that was not called out in its changelog or version bump: a refactor commit removed `stdio/prompts`, `stdio/progress`, `stdio/clear`, and the vendored `external/@inquirer/*` shims. socket-cli and other consumers import `stdio/prompts` directly and broke on upgrade.
|
|
13
|
+
|
|
14
|
+
Restored:
|
|
15
|
+
|
|
16
|
+
- `@socketsecurity/lib/stdio/prompts` — inquirer wrappers (`password`, `confirm`, `input`, `select`, `checkbox`, `search`)
|
|
17
|
+
- `@socketsecurity/lib/stdio/progress` — progress-bar utility (`ProgressBar` class)
|
|
18
|
+
- `@socketsecurity/lib/stdio/clear` — terminal line/screen/cursor helpers
|
|
19
|
+
- `src/external/@inquirer/{checkbox,confirm,input,password,search,select}.js` vendor shims
|
|
20
|
+
- Corresponding test suites
|
|
21
|
+
|
|
22
|
+
## [5.19.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.19.0) - 2026-04-19
|
|
23
|
+
|
|
24
|
+
### Added — dlx/integrity (new module)
|
|
25
|
+
|
|
26
|
+
- `HashSpec`, `NormalizedHash`, `ComputedHashes` types. `HashSpec` accepts a bare string (sha512 SRI or sha256 hex, sniffed) or an explicit `{ type, value }` object
|
|
27
|
+
- `normalizeHash()`, `computeHashes()`, `verifyHash()` — `verifyHash` uses `crypto.timingSafeEqual` for constant-time comparison
|
|
28
|
+
- `DlxHashMismatchError` — carries `expected` + `actual` for diagnostics
|
|
29
|
+
|
|
30
|
+
### Added — dlx/arborist (new module)
|
|
31
|
+
|
|
32
|
+
- `safeIdealTree()`, `safeReify()` — hardened `@npmcli/arborist` wrappers mirroring socket-cli v1.1.79 `SafeArborist` overrides (`audit: false`, `fund: false`, `ignoreScripts: true`, `progress: false`, `saveBundle: false`, `silent: true`)
|
|
33
|
+
- `writeSafeNpmrc()` — defense-in-depth `.npmrc` writer matching the Arborist overrides
|
|
34
|
+
- Optional `before?: Date` on `safeIdealTree` for release-age enforcement during resolution
|
|
35
|
+
|
|
36
|
+
### Added — dlx/lockfile (new module)
|
|
37
|
+
|
|
38
|
+
- `generatePackagePin({ package, minReleaseDays?, minReleaseMins? })` — returns `PinDetails { name, version, hash: ComputedHashes, packageJson, lockfile }`. Runs Arborist in `packageLockOnly: true` mode against a tmp directory and auto-cleans
|
|
39
|
+
- **Default `minReleaseDays: 7`** — resolution refuses to select versions published in the last week. Pass `0` to disable. `minReleaseMins` is a pnpm-style alias (mutually exclusive with `minReleaseDays`)
|
|
40
|
+
- `LockfileSpec` type — export for use as the new `lockfile` option on `downloadPackage`
|
|
41
|
+
|
|
42
|
+
### Added — dlx existing modules
|
|
43
|
+
|
|
44
|
+
- `DlxPackageOptions.hash?: HashSpec` and `DlxPackageOptions.lockfile?: LockfileSpec` — passing a lockfile materializes it into the install dir (path → `fs.copyFileSync`, content → `fs.writeFileSync`) and drops a hardened `.npmrc` alongside before Arborist runs
|
|
45
|
+
- `DlxBinaryOptions.hash?: HashSpec` — ergonomic alternative to the lower-level `integrity` and `sha256` fields (both still accepted)
|
|
46
|
+
|
|
47
|
+
### Fixed — external
|
|
48
|
+
|
|
49
|
+
- `pacote` shim now exposes `tarball`, `manifest`, `packument` alongside `extract`. **Fixes a latent runtime crash** in `src/packages/manifest.ts` callers (`fetchPackageManifest` / `fetchPackagePackument` called `.manifest(...)` / `.packument(...)` on a shim that previously only had `extract`, raising `TypeError: not a function`)
|
|
50
|
+
|
|
51
|
+
### Changed — build (bundle size)
|
|
52
|
+
|
|
53
|
+
- `dist/external/npm-pack.js`: 2,526,598 → 1,755,460 bytes (−771 KB, −30.5%). New `STUB_MAP` entries for code paths our callers never reach:
|
|
54
|
+
- `@sigstore/{bundle,core,protobuf-specs,sign,tuf,verify}`, `sigstore`, `tuf-js`, `@tufjs/{canonical-json,models}` — Sigstore attestation, only reached via `arb.audit()`
|
|
55
|
+
- `@npmcli/metavuln-calculator` — audit-only
|
|
56
|
+
- `@npmcli/query`, `postcss-selector-parser` — `arb.query()` unused
|
|
57
|
+
- `@npmcli/run-script`, `@npmcli/node-gyp` — guarded out by `ignoreScripts: true`
|
|
58
|
+
- `@npmcli/git`, `pacote/lib/{git,file,dir,remote}.js` — registry specs only
|
|
59
|
+
- arborist `audit-report.js`, `yarn-lock.js`, `isolated-reifier.js`, `query-selector-all.js`, `printable.js` — each gated or unused
|
|
60
|
+
- `cacache/lib/verify.js` — `cacache.verify` (npm cache verify) unused
|
|
61
|
+
- `proggy` — progress tracker, gated by `progress: false`
|
|
62
|
+
- `debug/src/browser.js` — Node-only bundle
|
|
63
|
+
- `dist/external/zod.js`: 597,238 → 291,430 bytes (−306 KB, −51.2%). Stubbed `zod/v4/{core,classic,mini}`'s eager `locales/index.cjs` barrel (40+ translation modules). Opt-in via `z.config(z.locales.xx())` is never called by us
|
|
64
|
+
|
|
8
65
|
## [5.18.2](https://github.com/SocketDev/socket-lib/releases/tag/v5.18.2) - 2026-04-14
|
|
9
66
|
|
|
10
67
|
### Removed
|
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@ logger.success(`Package: ${pkg.name}@${pkg.version}`)
|
|
|
45
45
|
|
|
46
46
|
## Documentation
|
|
47
47
|
|
|
48
|
+
- [API Index](./docs/api-index.md) - Every subpath export with a one-line description (start here)
|
|
48
49
|
- [Getting Started](./docs/getting-started.md) - Prerequisites, installation, and first examples
|
|
49
50
|
- [Visual Effects](./docs/visual-effects.md) - Spinners, loggers, themes, and progress indicators
|
|
50
51
|
- [File System](./docs/file-system.md) - File operations, globs, paths, and safe deletion
|
|
@@ -96,8 +97,8 @@ Spawn child processes safely with cross-platform support.
|
|
|
96
97
|
- `spawnSync()` - Synchronous version for blocking operations
|
|
97
98
|
- Array-based arguments prevent command injection
|
|
98
99
|
- Automatic Windows `.cmd`/`.bat` handling
|
|
99
|
-
- `
|
|
100
|
-
- `
|
|
100
|
+
- `processLock.withLock()` / `processLock.acquire()` / `processLock.release()` - Ensure only one instance runs at a time
|
|
101
|
+
- `writeIpcStub()` / `getIpcStubPath()` - Filesystem-based inter-process data handoff
|
|
101
102
|
|
|
102
103
|
### Environment Detection
|
|
103
104
|
|
|
@@ -106,14 +107,14 @@ Type-safe environment variable access and platform detection.
|
|
|
106
107
|
- `getCI()` - Detect CI environment
|
|
107
108
|
- `getNodeEnv()` - Get NODE_ENV value
|
|
108
109
|
- `isTest()` - Check if running tests
|
|
109
|
-
- `getHome()` - Home directory (
|
|
110
|
+
- `getHome()` - Home directory (cross-platform, with Windows `USERPROFILE` fallback)
|
|
110
111
|
- Test rewiring with `setEnv()`, `resetEnv()`
|
|
111
112
|
|
|
112
113
|
### Package Management
|
|
113
114
|
|
|
114
115
|
Detect and work with npm, pnpm, and yarn.
|
|
115
116
|
|
|
116
|
-
- `detectPackageManager()` - Identify package manager from
|
|
117
|
+
- `detectPackageManager()` - Identify running package manager from `npm_config_user_agent` / binary path
|
|
117
118
|
- Package manifest operations
|
|
118
119
|
- Lock file management
|
|
119
120
|
|
|
@@ -141,7 +142,7 @@ Helpers for arrays, objects, strings, promises, sorting, and more.
|
|
|
141
142
|
- **Cross-platform** - Works on Windows, macOS, and Linux
|
|
142
143
|
- **TypeScript-first** - Full type safety with .d.ts files
|
|
143
144
|
- **Zero dependencies** (for core HTTP - uses Node.js native modules)
|
|
144
|
-
- **Well-tested** -
|
|
145
|
+
- **Well-tested** - 6000+ tests across 139+ test files
|
|
145
146
|
- **Security-focused** - Safe defaults, command injection protection
|
|
146
147
|
- **CommonJS output** - Compatible with Node.js tooling
|
|
147
148
|
|
package/dist/abort.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export declare function createCompositeAbortSignal(...signals: Array<AbortSignal
|
|
|
15
15
|
/**
|
|
16
16
|
* Create an AbortSignal that triggers after a timeout.
|
|
17
17
|
*
|
|
18
|
+
* @throws {TypeError} If `ms` is not a number, is NaN, is not finite, or is not
|
|
19
|
+
* positive.
|
|
20
|
+
*
|
|
18
21
|
* @example
|
|
19
22
|
* ```typescript
|
|
20
23
|
* const signal = createTimeoutSignal(5000) // aborts after 5 seconds
|
package/dist/abort.js
CHANGED
package/dist/agent.d.ts
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Package manager agent for executing npm, pnpm, and yarn commands.
|
|
3
|
+
* Provides cross-platform utilities with optimized flags and security defaults.
|
|
4
|
+
*
|
|
5
|
+
* SECURITY: Array-Based Arguments Prevent Command Injection
|
|
6
|
+
*
|
|
7
|
+
* All functions in this module (execNpm, execPnpm, execYarn) use array-based
|
|
8
|
+
* arguments when calling spawn(). This is the PRIMARY DEFENSE against command
|
|
9
|
+
* injection attacks.
|
|
10
|
+
*
|
|
11
|
+
* When arguments are passed as an array:
|
|
12
|
+
* spawn(cmd, ['install', packageName, '--flag'], options)
|
|
13
|
+
*
|
|
14
|
+
* Node.js handles escaping automatically. Each argument is passed directly to
|
|
15
|
+
* the OS without shell interpretation. Shell metacharacters like ; | & $ ( )
|
|
16
|
+
* are treated as LITERAL STRINGS, not as commands.
|
|
17
|
+
*
|
|
18
|
+
* Example: If packageName = "lodash; rm -rf /", the package manager will try to
|
|
19
|
+
* install a package literally named "lodash; rm -rf /" (which doesn't exist),
|
|
20
|
+
* rather than executing the malicious command.
|
|
21
|
+
*
|
|
22
|
+
* This approach is secure even when shell: true is used on Windows for .cmd
|
|
23
|
+
* file resolution, because Node.js properly escapes each array element.
|
|
24
|
+
*/
|
|
1
25
|
import type { SpawnOptions } from './spawn';
|
|
26
|
+
export interface PnpmOptions extends SpawnOptions {
|
|
27
|
+
allowLockfileUpdate?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface ExecScriptOptions extends SpawnOptions {
|
|
30
|
+
prepost?: boolean | undefined;
|
|
31
|
+
}
|
|
2
32
|
/**
|
|
3
33
|
* Execute npm commands with optimized flags and settings.
|
|
4
34
|
*
|
|
@@ -12,9 +42,6 @@ import type { SpawnOptions } from './spawn';
|
|
|
12
42
|
* ```
|
|
13
43
|
*/
|
|
14
44
|
export declare function execNpm(args: string[], options?: SpawnOptions | undefined): import("./spawn").PromiseSpawnResult;
|
|
15
|
-
export interface PnpmOptions extends SpawnOptions {
|
|
16
|
-
allowLockfileUpdate?: boolean;
|
|
17
|
-
}
|
|
18
45
|
/**
|
|
19
46
|
* Execute pnpm commands with optimized flags and settings.
|
|
20
47
|
*
|
|
@@ -31,9 +58,28 @@ export declare function execPnpm(args: string[], options?: PnpmOptions | undefin
|
|
|
31
58
|
cmd: string;
|
|
32
59
|
args: string[] | readonly string[];
|
|
33
60
|
code: number;
|
|
34
|
-
signal: NodeJS.Signals;
|
|
35
|
-
stdout: string | Buffer
|
|
36
|
-
stderr: string | Buffer
|
|
61
|
+
signal: NodeJS.Signals | null;
|
|
62
|
+
stdout: string | Buffer;
|
|
63
|
+
stderr: string | Buffer;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Execute a package.json script using the detected package manager.
|
|
67
|
+
* Picks pnpm, npm, or yarn by walking up to the nearest lockfile; falls back
|
|
68
|
+
* to running `node --run` or `npm run` directly when no lockfile is found.
|
|
69
|
+
* Honors `shell: true` by passing through to `spawn()` unchanged.
|
|
70
|
+
*
|
|
71
|
+
* @param scriptName - The package.json script to run
|
|
72
|
+
* @param args - Either the script arguments or an options object
|
|
73
|
+
* @param options - Spawn options plus `prepost` to force npm-style pre/post scripts
|
|
74
|
+
* @returns The spawned `ChildProcess`-like promise from the underlying runner.
|
|
75
|
+
*/
|
|
76
|
+
export declare function execScript(scriptName: string, args?: string[] | readonly string[] | ExecScriptOptions | undefined, options?: ExecScriptOptions | undefined): Promise<{
|
|
77
|
+
cmd: string;
|
|
78
|
+
args: string[] | readonly string[];
|
|
79
|
+
code: number;
|
|
80
|
+
signal: NodeJS.Signals | null;
|
|
81
|
+
stdout: string | Buffer;
|
|
82
|
+
stderr: string | Buffer;
|
|
37
83
|
}>;
|
|
38
84
|
/**
|
|
39
85
|
* Execute yarn commands with optimized flags and settings.
|
|
@@ -51,9 +97,9 @@ export declare function execYarn(args: string[], options?: import('./spawn').Spa
|
|
|
51
97
|
cmd: string;
|
|
52
98
|
args: string[] | readonly string[];
|
|
53
99
|
code: number;
|
|
54
|
-
signal: NodeJS.Signals;
|
|
55
|
-
stdout: string | Buffer
|
|
56
|
-
stderr: string | Buffer
|
|
100
|
+
signal: NodeJS.Signals | null;
|
|
101
|
+
stdout: string | Buffer;
|
|
102
|
+
stderr: string | Buffer;
|
|
57
103
|
}>;
|
|
58
104
|
/**
|
|
59
105
|
* Check if a command argument is an npm audit flag.
|
|
@@ -65,7 +111,6 @@ export declare function execYarn(args: string[], options?: import('./spawn').Spa
|
|
|
65
111
|
* isNpmAuditFlag('--save') // false
|
|
66
112
|
* ```
|
|
67
113
|
*/
|
|
68
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
69
114
|
export declare function isNpmAuditFlag(cmdArg: string): boolean;
|
|
70
115
|
/**
|
|
71
116
|
* Check if a command argument is an npm fund flag.
|
|
@@ -77,7 +122,6 @@ export declare function isNpmAuditFlag(cmdArg: string): boolean;
|
|
|
77
122
|
* isNpmFundFlag('--save') // false
|
|
78
123
|
* ```
|
|
79
124
|
*/
|
|
80
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
81
125
|
export declare function isNpmFundFlag(cmdArg: string): boolean;
|
|
82
126
|
/**
|
|
83
127
|
* Check if a command argument is an npm loglevel flag.
|
|
@@ -90,7 +134,6 @@ export declare function isNpmFundFlag(cmdArg: string): boolean;
|
|
|
90
134
|
* isNpmLoglevelFlag('--save') // false
|
|
91
135
|
* ```
|
|
92
136
|
*/
|
|
93
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
94
137
|
export declare function isNpmLoglevelFlag(cmdArg: string): boolean;
|
|
95
138
|
/**
|
|
96
139
|
* Check if a command argument is an npm node-options flag.
|
|
@@ -102,7 +145,6 @@ export declare function isNpmLoglevelFlag(cmdArg: string): boolean;
|
|
|
102
145
|
* isNpmNodeOptionsFlag('--save') // false
|
|
103
146
|
* ```
|
|
104
147
|
*/
|
|
105
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
106
148
|
export declare function isNpmNodeOptionsFlag(cmdArg: string): boolean;
|
|
107
149
|
/**
|
|
108
150
|
* Check if a command argument is an npm progress flag.
|
|
@@ -114,32 +156,29 @@ export declare function isNpmNodeOptionsFlag(cmdArg: string): boolean;
|
|
|
114
156
|
* isNpmProgressFlag('--save') // false
|
|
115
157
|
* ```
|
|
116
158
|
*/
|
|
117
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
118
159
|
export declare function isNpmProgressFlag(cmdArg: string): boolean;
|
|
119
160
|
/**
|
|
120
|
-
* Check if a command argument is a pnpm
|
|
161
|
+
* Check if a command argument is a pnpm frozen-lockfile flag.
|
|
121
162
|
*
|
|
122
163
|
* @example
|
|
123
164
|
* ```typescript
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
165
|
+
* isPnpmFrozenLockfileFlag('--frozen-lockfile') // true
|
|
166
|
+
* isPnpmFrozenLockfileFlag('--no-frozen-lockfile') // true
|
|
167
|
+
* isPnpmFrozenLockfileFlag('--save') // false
|
|
127
168
|
* ```
|
|
128
169
|
*/
|
|
129
|
-
|
|
130
|
-
export declare function isPnpmIgnoreScriptsFlag(cmdArg: string): boolean;
|
|
170
|
+
export declare function isPnpmFrozenLockfileFlag(cmdArg: string): boolean;
|
|
131
171
|
/**
|
|
132
|
-
* Check if a command argument is a pnpm
|
|
172
|
+
* Check if a command argument is a pnpm ignore-scripts flag.
|
|
133
173
|
*
|
|
134
174
|
* @example
|
|
135
175
|
* ```typescript
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
176
|
+
* isPnpmIgnoreScriptsFlag('--ignore-scripts') // true
|
|
177
|
+
* isPnpmIgnoreScriptsFlag('--no-ignore-scripts') // true
|
|
178
|
+
* isPnpmIgnoreScriptsFlag('--save') // false
|
|
139
179
|
* ```
|
|
140
180
|
*/
|
|
141
|
-
|
|
142
|
-
export declare function isPnpmFrozenLockfileFlag(cmdArg: string): boolean;
|
|
181
|
+
export declare function isPnpmIgnoreScriptsFlag(cmdArg: string): boolean;
|
|
143
182
|
/**
|
|
144
183
|
* Check if a command argument is a pnpm install command.
|
|
145
184
|
*
|
|
@@ -150,30 +189,8 @@ export declare function isPnpmFrozenLockfileFlag(cmdArg: string): boolean;
|
|
|
150
189
|
* isPnpmInstallCommand('run') // false
|
|
151
190
|
* ```
|
|
152
191
|
*/
|
|
153
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
154
192
|
export declare function isPnpmInstallCommand(cmdArg: string): boolean;
|
|
155
193
|
/**
|
|
156
|
-
* Alias for isNpmLoglevelFlag
|
|
194
|
+
* Alias for isNpmLoglevelFlag — pnpm uses the same `--loglevel` surface.
|
|
157
195
|
*/
|
|
158
196
|
export declare const isPnpmLoglevelFlag: typeof isNpmLoglevelFlag;
|
|
159
|
-
/**
|
|
160
|
-
* Execute a package.json script using the appropriate package manager.
|
|
161
|
-
* Automatically detects pnpm, yarn, or npm based on lockfiles.
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```typescript
|
|
165
|
-
* await execScript('build')
|
|
166
|
-
* await execScript('test', ['--coverage'], { cwd: '/tmp/project' })
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
export interface ExecScriptOptions extends SpawnOptions {
|
|
170
|
-
prepost?: boolean | undefined;
|
|
171
|
-
}
|
|
172
|
-
export declare function execScript(scriptName: string, args?: string[] | readonly string[] | ExecScriptOptions | undefined, options?: ExecScriptOptions | undefined): Promise<{
|
|
173
|
-
cmd: string;
|
|
174
|
-
args: string[] | readonly string[];
|
|
175
|
-
code: number;
|
|
176
|
-
signal: NodeJS.Signals;
|
|
177
|
-
stdout: string | Buffer<ArrayBufferLike>;
|
|
178
|
-
stderr: string | Buffer<ArrayBufferLike>;
|
|
179
|
-
}>;
|
package/dist/agent.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -45,12 +46,12 @@ __export(agent_exports, {
|
|
|
45
46
|
});
|
|
46
47
|
module.exports = __toCommonJS(agent_exports);
|
|
47
48
|
var import_node_process = __toESM(require("node:process"));
|
|
49
|
+
var import_bin = require("./bin");
|
|
48
50
|
var import_agents = require("./constants/agents");
|
|
49
51
|
var import_node = require("./constants/node");
|
|
50
52
|
var import_platform = require("./constants/platform");
|
|
51
|
-
var import_ci = require("./env/ci");
|
|
52
|
-
var import_bin = require("./bin");
|
|
53
53
|
var import_debug = require("./debug");
|
|
54
|
+
var import_ci = require("./env/ci");
|
|
54
55
|
var import_fs = require("./fs");
|
|
55
56
|
var import_objects = require("./objects");
|
|
56
57
|
var import_spawn = require("./spawn");
|
|
@@ -158,6 +159,50 @@ function execPnpm(args, options) {
|
|
|
158
159
|
extBinOpts
|
|
159
160
|
);
|
|
160
161
|
}
|
|
162
|
+
function execScript(scriptName, args, options) {
|
|
163
|
+
let resolvedOptions;
|
|
164
|
+
let resolvedArgs;
|
|
165
|
+
if (!Array.isArray(args) && args !== null && typeof args === "object") {
|
|
166
|
+
resolvedOptions = args;
|
|
167
|
+
resolvedArgs = [];
|
|
168
|
+
} else {
|
|
169
|
+
resolvedOptions = options;
|
|
170
|
+
resolvedArgs = args || [];
|
|
171
|
+
}
|
|
172
|
+
const { prepost, ...spawnOptions } = {
|
|
173
|
+
__proto__: null,
|
|
174
|
+
...resolvedOptions
|
|
175
|
+
};
|
|
176
|
+
if (spawnOptions.shell === true) {
|
|
177
|
+
return (0, import_spawn.spawn)(scriptName, resolvedArgs, spawnOptions);
|
|
178
|
+
}
|
|
179
|
+
const useNodeRun = !prepost && (0, import_node.supportsNodeRun)();
|
|
180
|
+
const cwd = (0, import_objects.getOwn)(spawnOptions, "cwd") ?? import_node_process.default.cwd();
|
|
181
|
+
const pnpmLockPath = (0, import_fs.findUpSync)(import_agents.PNPM_LOCK_YAML, { cwd });
|
|
182
|
+
if (pnpmLockPath) {
|
|
183
|
+
return execPnpm(["run", scriptName, ...resolvedArgs], spawnOptions);
|
|
184
|
+
}
|
|
185
|
+
const packageLockPath = (0, import_fs.findUpSync)(import_agents.PACKAGE_LOCK_JSON, { cwd });
|
|
186
|
+
if (packageLockPath) {
|
|
187
|
+
return execNpm(["run", scriptName, ...resolvedArgs], spawnOptions);
|
|
188
|
+
}
|
|
189
|
+
const yarnLockPath = (0, import_fs.findUpSync)(import_agents.YARN_LOCK, { cwd });
|
|
190
|
+
if (yarnLockPath) {
|
|
191
|
+
return execYarn(["run", scriptName, ...resolvedArgs], spawnOptions);
|
|
192
|
+
}
|
|
193
|
+
return (0, import_spawn.spawn)(
|
|
194
|
+
(0, import_node.getExecPath)(),
|
|
195
|
+
[
|
|
196
|
+
...(0, import_node.getNodeNoWarningsFlags)(),
|
|
197
|
+
...useNodeRun ? ["--run"] : [import_agents.NPM_REAL_EXEC_PATH, "run"],
|
|
198
|
+
scriptName,
|
|
199
|
+
...resolvedArgs
|
|
200
|
+
],
|
|
201
|
+
{
|
|
202
|
+
...spawnOptions
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
}
|
|
161
206
|
function execYarn(args, options) {
|
|
162
207
|
const useDebug = (0, import_debug.isDebug)();
|
|
163
208
|
const terminatorPos = args.indexOf("--");
|
|
@@ -211,62 +256,18 @@ function isNpmProgressFlag(cmdArg) {
|
|
|
211
256
|
return /^--(no-)?progress(=.*)?$/.test(cmdArg);
|
|
212
257
|
}
|
|
213
258
|
// @__NO_SIDE_EFFECTS__
|
|
214
|
-
function isPnpmIgnoreScriptsFlag(cmdArg) {
|
|
215
|
-
return pnpmIgnoreScriptsFlags.has(cmdArg);
|
|
216
|
-
}
|
|
217
|
-
// @__NO_SIDE_EFFECTS__
|
|
218
259
|
function isPnpmFrozenLockfileFlag(cmdArg) {
|
|
219
260
|
return pnpmFrozenLockfileFlags.has(cmdArg);
|
|
220
261
|
}
|
|
221
262
|
// @__NO_SIDE_EFFECTS__
|
|
263
|
+
function isPnpmIgnoreScriptsFlag(cmdArg) {
|
|
264
|
+
return pnpmIgnoreScriptsFlags.has(cmdArg);
|
|
265
|
+
}
|
|
266
|
+
// @__NO_SIDE_EFFECTS__
|
|
222
267
|
function isPnpmInstallCommand(cmdArg) {
|
|
223
268
|
return pnpmInstallCommands.has(cmdArg);
|
|
224
269
|
}
|
|
225
270
|
const isPnpmLoglevelFlag = isNpmLoglevelFlag;
|
|
226
|
-
function execScript(scriptName, args, options) {
|
|
227
|
-
let resolvedOptions;
|
|
228
|
-
let resolvedArgs;
|
|
229
|
-
if (!Array.isArray(args) && args !== null && typeof args === "object") {
|
|
230
|
-
resolvedOptions = args;
|
|
231
|
-
resolvedArgs = [];
|
|
232
|
-
} else {
|
|
233
|
-
resolvedOptions = options;
|
|
234
|
-
resolvedArgs = args || [];
|
|
235
|
-
}
|
|
236
|
-
const { prepost, ...spawnOptions } = {
|
|
237
|
-
__proto__: null,
|
|
238
|
-
...resolvedOptions
|
|
239
|
-
};
|
|
240
|
-
if (spawnOptions.shell === true) {
|
|
241
|
-
return (0, import_spawn.spawn)(scriptName, resolvedArgs, spawnOptions);
|
|
242
|
-
}
|
|
243
|
-
const useNodeRun = !prepost && (0, import_node.supportsNodeRun)();
|
|
244
|
-
const cwd = (0, import_objects.getOwn)(spawnOptions, "cwd") ?? import_node_process.default.cwd();
|
|
245
|
-
const pnpmLockPath = (0, import_fs.findUpSync)(import_agents.PNPM_LOCK_YAML, { cwd });
|
|
246
|
-
if (pnpmLockPath) {
|
|
247
|
-
return execPnpm(["run", scriptName, ...resolvedArgs], spawnOptions);
|
|
248
|
-
}
|
|
249
|
-
const packageLockPath = (0, import_fs.findUpSync)(import_agents.PACKAGE_LOCK_JSON, { cwd });
|
|
250
|
-
if (packageLockPath) {
|
|
251
|
-
return execNpm(["run", scriptName, ...resolvedArgs], spawnOptions);
|
|
252
|
-
}
|
|
253
|
-
const yarnLockPath = (0, import_fs.findUpSync)(import_agents.YARN_LOCK, { cwd });
|
|
254
|
-
if (yarnLockPath) {
|
|
255
|
-
return execYarn(["run", scriptName, ...resolvedArgs], spawnOptions);
|
|
256
|
-
}
|
|
257
|
-
return (0, import_spawn.spawn)(
|
|
258
|
-
(0, import_node.getExecPath)(),
|
|
259
|
-
[
|
|
260
|
-
...(0, import_node.getNodeNoWarningsFlags)(),
|
|
261
|
-
...useNodeRun ? ["--run"] : [import_agents.NPM_REAL_EXEC_PATH, "run"],
|
|
262
|
-
scriptName,
|
|
263
|
-
...resolvedArgs
|
|
264
|
-
],
|
|
265
|
-
{
|
|
266
|
-
...spawnOptions
|
|
267
|
-
}
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
271
|
// Annotate the CommonJS export names for ESM import in node:
|
|
271
272
|
0 && (module.exports = {
|
|
272
273
|
execNpm,
|
package/dist/ansi.d.ts
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
* @fileoverview ANSI escape code utilities.
|
|
3
3
|
* Provides constants and helpers for terminal formatting.
|
|
4
4
|
*/
|
|
5
|
-
// ANSI escape codes - commonly used sequences.
|
|
6
|
-
export declare const ANSI_RESET = "\u001B[0m";
|
|
7
5
|
export declare const ANSI_BOLD = "\u001B[1m";
|
|
8
6
|
export declare const ANSI_DIM = "\u001B[2m";
|
|
9
7
|
export declare const ANSI_ITALIC = "\u001B[3m";
|
|
10
|
-
export declare const
|
|
8
|
+
export declare const ANSI_RESET = "\u001B[0m";
|
|
11
9
|
export declare const ANSI_STRIKETHROUGH = "\u001B[9m";
|
|
10
|
+
export declare const ANSI_UNDERLINE = "\u001B[4m";
|
|
12
11
|
/**
|
|
13
12
|
* Create a regular expression for matching ANSI escape codes.
|
|
14
13
|
*
|
|
@@ -24,7 +23,6 @@ export declare const ANSI_STRIKETHROUGH = "\u001B[9m";
|
|
|
24
23
|
* ansiRegex({ onlyFirst: true }) // matches only the first code
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
28
26
|
export declare function ansiRegex(options?: {
|
|
29
27
|
onlyFirst?: boolean;
|
|
30
28
|
}): RegExp;
|
|
@@ -38,5 +36,4 @@ export declare function ansiRegex(options?: {
|
|
|
38
36
|
* stripAnsi('\u001b[1mBold\u001b[0m') // 'Bold'
|
|
39
37
|
* ```
|
|
40
38
|
*/
|
|
41
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
42
39
|
export declare function stripAnsi(text: string): string;
|
package/dist/ansi.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -29,12 +30,12 @@ __export(ansi_exports, {
|
|
|
29
30
|
stripAnsi: () => stripAnsi
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(ansi_exports);
|
|
32
|
-
const ANSI_RESET = "\x1B[0m";
|
|
33
33
|
const ANSI_BOLD = "\x1B[1m";
|
|
34
34
|
const ANSI_DIM = "\x1B[2m";
|
|
35
35
|
const ANSI_ITALIC = "\x1B[3m";
|
|
36
|
-
const
|
|
36
|
+
const ANSI_RESET = "\x1B[0m";
|
|
37
37
|
const ANSI_STRIKETHROUGH = "\x1B[9m";
|
|
38
|
+
const ANSI_UNDERLINE = "\x1B[4m";
|
|
38
39
|
const ANSI_REGEX = /\x1b\[[0-9;]*m/g;
|
|
39
40
|
// @__NO_SIDE_EFFECTS__
|
|
40
41
|
function ansiRegex(options) {
|
package/dist/archives.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Generic archive extraction utilities.
|
|
3
|
+
* Supports zip, tar, tar.gz, and tgz formats.
|
|
4
|
+
*/
|
|
1
5
|
/**
|
|
2
6
|
* Archive format type.
|
|
3
7
|
*/
|
|
@@ -7,15 +11,15 @@ export type ArchiveFormat = 'tar' | 'tar.gz' | 'tgz' | 'zip';
|
|
|
7
11
|
*/
|
|
8
12
|
export interface ExtractOptions {
|
|
9
13
|
/** Suppress log messages */
|
|
10
|
-
quiet?: boolean;
|
|
14
|
+
quiet?: boolean | undefined;
|
|
11
15
|
/** Strip leading path components (like tar --strip-components) */
|
|
12
|
-
strip?: number;
|
|
16
|
+
strip?: number | undefined;
|
|
13
17
|
/** Maximum number of entries to extract (default: 100,000) */
|
|
14
|
-
maxEntries?: number;
|
|
18
|
+
maxEntries?: number | undefined;
|
|
15
19
|
/** Maximum size of a single extracted file in bytes (default: 100MB) */
|
|
16
|
-
maxFileSize?: number;
|
|
20
|
+
maxFileSize?: number | undefined;
|
|
17
21
|
/** Maximum total extracted size in bytes (default: 1GB) */
|
|
18
|
-
maxTotalSize?: number;
|
|
22
|
+
maxTotalSize?: number | undefined;
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
21
25
|
* Detect archive format from file path.
|
|
@@ -31,6 +35,22 @@ export interface ExtractOptions {
|
|
|
31
35
|
* ```
|
|
32
36
|
*/
|
|
33
37
|
export declare function detectArchiveFormat(filePath: string): ArchiveFormat | null;
|
|
38
|
+
/**
|
|
39
|
+
* Extract an archive to a directory.
|
|
40
|
+
* Automatically detects format from file extension.
|
|
41
|
+
*
|
|
42
|
+
* @param archivePath - Path to archive file
|
|
43
|
+
* @param outputDir - Directory to extract to
|
|
44
|
+
* @param options - Extraction options
|
|
45
|
+
* @throws Error if archive format is not supported
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* await extractArchive('/tmp/package.tar.gz', '/tmp/output')
|
|
50
|
+
* await extractArchive('/tmp/release.zip', '/tmp/output', { strip: 1 })
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function extractArchive(archivePath: string, outputDir: string, options?: ExtractOptions): Promise<void>;
|
|
34
54
|
/**
|
|
35
55
|
* Extract a tar archive to a directory.
|
|
36
56
|
*
|
|
@@ -73,19 +93,3 @@ export declare function extractTarGz(archivePath: string, outputDir: string, opt
|
|
|
73
93
|
* ```
|
|
74
94
|
*/
|
|
75
95
|
export declare function extractZip(archivePath: string, outputDir: string, options?: ExtractOptions): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Extract an archive to a directory.
|
|
78
|
-
* Automatically detects format from file extension.
|
|
79
|
-
*
|
|
80
|
-
* @param archivePath - Path to archive file
|
|
81
|
-
* @param outputDir - Directory to extract to
|
|
82
|
-
* @param options - Extraction options
|
|
83
|
-
* @throws Error if archive format is not supported
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* await extractArchive('/tmp/package.tar.gz', '/tmp/output')
|
|
88
|
-
* await extractArchive('/tmp/release.zip', '/tmp/output', { strip: 1 })
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
export declare function extractArchive(archivePath: string, outputDir: string, options?: ExtractOptions): Promise<void>;
|