@socketsecurity/lib 5.18.1 → 5.19.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.
- package/CHANGELOG.md +49 -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/@npmcli/package-json.js +9 -3968
- package/dist/external/@socketregistry/packageurl-js.js +2 -2
- package/dist/external/debug.js +162 -328
- package/dist/external/external-pack.js +3 -2835
- package/dist/external/npm-pack.js +13939 -33342
- package/dist/external/zod.js +160 -7558
- 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/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/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 +34 -70
- package/dist/external/@inquirer/checkbox.js +0 -5
- package/dist/external/@inquirer/confirm.js +0 -5
- package/dist/external/@inquirer/input.js +0 -5
- package/dist/external/@inquirer/password.js +0 -5
- package/dist/external/@inquirer/search.js +0 -5
- package/dist/external/@inquirer/select.js +0 -5
- package/dist/functions.d.ts +0 -57
- package/dist/functions.js +0 -70
- package/dist/stdio/clear.d.ts +0 -140
- package/dist/stdio/clear.js +0 -95
- package/dist/stdio/mask.d.ts +0 -151
- package/dist/stdio/mask.js +0 -224
- package/dist/stdio/progress.d.ts +0 -148
- package/dist/stdio/progress.js +0 -212
- package/dist/stdio/prompts.d.ts +0 -195
- package/dist/stdio/prompts.js +0 -176
- package/dist/utils/get-ipc.d.ts +0 -15
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Safe Arborist wrapper for dlx installs and lockfile-only
|
|
3
|
+
* resolution.
|
|
4
|
+
*
|
|
5
|
+
* Every Arborist invocation in this module is configured with a fixed set
|
|
6
|
+
* of security-hardening options mirroring socket-cli v1.1.79 SafeArborist:
|
|
7
|
+
*
|
|
8
|
+
* - audit: false — no network call to the npm audit endpoint
|
|
9
|
+
* - fund: false — no collection/display of funding URLs
|
|
10
|
+
* - ignoreScripts: true — no preinstall/install/postinstall scripts
|
|
11
|
+
* - progress: false — no progress bar on stdout
|
|
12
|
+
* - saveBundle: false — never update bundledDependencies
|
|
13
|
+
* - silent: true — suppress Arborist's default log output
|
|
14
|
+
*
|
|
15
|
+
* `save` varies by operation: {@link safeIdealTree} uses `save: true` so
|
|
16
|
+
* Arborist writes `package-lock.json`; {@link safeReify} uses `save: false`
|
|
17
|
+
* so the caller's `package.json` is never rewritten.
|
|
18
|
+
*
|
|
19
|
+
* A `.npmrc` with the equivalent settings is also written into the
|
|
20
|
+
* install directory as a belt-and-suspenders defense for any downstream
|
|
21
|
+
* tool that reads it.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Shared options for the safe-arborist operations below.
|
|
25
|
+
*/
|
|
26
|
+
export interface SafeArboristOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Install directory. Arborist reads `package.json` (and, for reify,
|
|
29
|
+
* `package-lock.json`) from this directory and creates `node_modules`
|
|
30
|
+
* here when installing.
|
|
31
|
+
*
|
|
32
|
+
* Must already exist before calling. The caller is responsible for its
|
|
33
|
+
* lifecycle (including cleanup of tmp directories).
|
|
34
|
+
*/
|
|
35
|
+
path: string;
|
|
36
|
+
/**
|
|
37
|
+
* Refuse to resolve any version published after this date. Passed to
|
|
38
|
+
* Arborist (and pacote) as the `before` option. Matches npm's
|
|
39
|
+
* `min-release-age` semantics once a caller converts days → Date.
|
|
40
|
+
*/
|
|
41
|
+
before?: Date | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Suppress Arborist's default log output.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
quiet?: boolean | undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Result of {@link safeIdealTree}.
|
|
50
|
+
*/
|
|
51
|
+
export interface SafeIdealTreeResult {
|
|
52
|
+
/**
|
|
53
|
+
* SRI integrity of the top-level resolved package as advertised by the
|
|
54
|
+
* registry (sourced from Arborist's idealTree, not from a tarball).
|
|
55
|
+
*/
|
|
56
|
+
integrity: string;
|
|
57
|
+
/** Resolved package name. */
|
|
58
|
+
name: string;
|
|
59
|
+
/** Resolved package version. */
|
|
60
|
+
version: string;
|
|
61
|
+
/** `package-lock.json` JSON content written by Arborist. */
|
|
62
|
+
lockfile: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Options for {@link safeReify}.
|
|
66
|
+
*/
|
|
67
|
+
export interface SafeReifyOptions extends SafeArboristOptions {
|
|
68
|
+
/**
|
|
69
|
+
* When true, Arborist reifies against the existing `package-lock.json`
|
|
70
|
+
* in `path` without rewriting it. When false, Arborist may update the
|
|
71
|
+
* lockfile to match resolved dependencies.
|
|
72
|
+
*
|
|
73
|
+
* Pin-mode callers set this to true so committed lockfiles are the
|
|
74
|
+
* authoritative resolution.
|
|
75
|
+
*
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
packageLock?: boolean | undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Run Arborist in `packageLockOnly` mode against a directory that already
|
|
82
|
+
* contains a `package.json` with a single dependency. Resolves the graph
|
|
83
|
+
* against the registry and writes `package-lock.json` into `path`, but
|
|
84
|
+
* does NOT install into `node_modules`.
|
|
85
|
+
*
|
|
86
|
+
* Used by snapshot/bootstrap flows to obtain a lockfile + top-level
|
|
87
|
+
* integrity without paying for a full install.
|
|
88
|
+
*
|
|
89
|
+
* Uses `save: true` (rather than our usual `save: false`) so Arborist
|
|
90
|
+
* actually writes the lockfile — without that flag, `reify()` in
|
|
91
|
+
* `packageLockOnly` mode with no `add` list skips the write.
|
|
92
|
+
*/
|
|
93
|
+
export declare function safeIdealTree(options: SafeArboristOptions): Promise<SafeIdealTreeResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Install into `node_modules` using Arborist's reify operation. Honors
|
|
96
|
+
* the committed `package-lock.json` in `path` when `packageLock: true`.
|
|
97
|
+
*
|
|
98
|
+
* Does not fetch registry metadata for versions already pinned by the
|
|
99
|
+
* lockfile — arborist uses the lockfile's `integrity` strings to fetch
|
|
100
|
+
* tarballs by ssri. This is the strongest form of pinning pnpm/npm
|
|
101
|
+
* offer.
|
|
102
|
+
*/
|
|
103
|
+
export declare function safeReify(options: SafeReifyOptions): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Options for {@link writeSafeNpmrc}. Optional release-age hints are
|
|
106
|
+
* echoed into the generated `.npmrc` as defense-in-depth for any
|
|
107
|
+
* downstream tool that shells out to npm/pnpm in the directory.
|
|
108
|
+
*/
|
|
109
|
+
export interface WriteSafeNpmrcOptions {
|
|
110
|
+
/** npm `min-release-age` (days). Mutually exclusive with minReleaseMins. */
|
|
111
|
+
minReleaseDays?: number | undefined;
|
|
112
|
+
/** pnpm `minimumReleaseAge` (minutes). Mutually exclusive with minReleaseDays. */
|
|
113
|
+
minReleaseMins?: number | undefined;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Write a hardened `.npmrc` into `path`. Used by both preview and pin
|
|
117
|
+
* flows as a second layer of protection alongside the Arborist options.
|
|
118
|
+
*
|
|
119
|
+
* Content written (always):
|
|
120
|
+
* ignore-scripts=true
|
|
121
|
+
* audit=false
|
|
122
|
+
* fund=false
|
|
123
|
+
* save=false
|
|
124
|
+
* save-bundle=false
|
|
125
|
+
* progress=false
|
|
126
|
+
*
|
|
127
|
+
* When {@link WriteSafeNpmrcOptions.minReleaseDays} is set, also writes:
|
|
128
|
+
* min-release-age=<days>
|
|
129
|
+
*
|
|
130
|
+
* When {@link WriteSafeNpmrcOptions.minReleaseMins} is set, also writes
|
|
131
|
+
* the pnpm-style equivalent:
|
|
132
|
+
* minimum-release-age=<minutes>
|
|
133
|
+
*/
|
|
134
|
+
export declare function writeSafeNpmrc(installPath: string, options?: WriteSafeNpmrcOptions | undefined): Promise<void>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
var arborist_exports = {};
|
|
32
|
+
__export(arborist_exports, {
|
|
33
|
+
safeIdealTree: () => safeIdealTree,
|
|
34
|
+
safeReify: () => safeReify,
|
|
35
|
+
writeSafeNpmrc: () => writeSafeNpmrc
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(arborist_exports);
|
|
38
|
+
var import_arborist = __toESM(require("../external/@npmcli/arborist"));
|
|
39
|
+
var import_socket = require("../paths/socket");
|
|
40
|
+
let _fs;
|
|
41
|
+
// @__NO_SIDE_EFFECTS__
|
|
42
|
+
function getFs() {
|
|
43
|
+
if (_fs === void 0) {
|
|
44
|
+
_fs = require("node:fs");
|
|
45
|
+
}
|
|
46
|
+
return _fs;
|
|
47
|
+
}
|
|
48
|
+
let _path;
|
|
49
|
+
// @__NO_SIDE_EFFECTS__
|
|
50
|
+
function getPath() {
|
|
51
|
+
if (_path === void 0) {
|
|
52
|
+
_path = require("node:path");
|
|
53
|
+
}
|
|
54
|
+
return _path;
|
|
55
|
+
}
|
|
56
|
+
function getBaseArboristOptions(installPath, quiet) {
|
|
57
|
+
return {
|
|
58
|
+
__proto__: null,
|
|
59
|
+
path: installPath,
|
|
60
|
+
cache: (0, import_socket.getSocketCacacheDir)(),
|
|
61
|
+
audit: false,
|
|
62
|
+
fund: false,
|
|
63
|
+
ignoreScripts: true,
|
|
64
|
+
progress: false,
|
|
65
|
+
save: false,
|
|
66
|
+
saveBundle: false,
|
|
67
|
+
silent: quiet
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function readSingleDependency(packageJsonPath) {
|
|
71
|
+
const fs = /* @__PURE__ */ getFs();
|
|
72
|
+
const raw = fs.readFileSync(packageJsonPath, "utf8");
|
|
73
|
+
const pkg = JSON.parse(raw);
|
|
74
|
+
const deps = pkg.dependencies ?? {};
|
|
75
|
+
const names = Object.keys(deps);
|
|
76
|
+
if (names.length !== 1) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`safeIdealTree expects exactly one top-level dependency in ${packageJsonPath}, found ${names.length}`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return names[0];
|
|
82
|
+
}
|
|
83
|
+
function readTopLevelFromIdealTree(tree, targetName) {
|
|
84
|
+
const root = tree;
|
|
85
|
+
const inventory = root?.inventory;
|
|
86
|
+
if (!inventory || typeof inventory.values !== "function") {
|
|
87
|
+
throw new Error("Arborist idealTree missing inventory");
|
|
88
|
+
}
|
|
89
|
+
for (const node of inventory.values()) {
|
|
90
|
+
if (node.isProjectRoot) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (node.name === targetName && node.depth === 1) {
|
|
94
|
+
if (!node.version || !node.integrity) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`Arborist idealTree node for ${targetName} missing version/integrity`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
name: node.name,
|
|
101
|
+
version: node.version,
|
|
102
|
+
integrity: node.integrity
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
throw new Error(
|
|
107
|
+
`Arborist idealTree inventory has no top-level node for ${targetName}`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
async function safeIdealTree(options) {
|
|
111
|
+
const fs = /* @__PURE__ */ getFs();
|
|
112
|
+
const path = /* @__PURE__ */ getPath();
|
|
113
|
+
const { before, path: installPath, quiet = true } = options;
|
|
114
|
+
const targetName = readSingleDependency(
|
|
115
|
+
path.join(installPath, "package.json")
|
|
116
|
+
);
|
|
117
|
+
const arb = new import_arborist.default({
|
|
118
|
+
...getBaseArboristOptions(installPath, quiet),
|
|
119
|
+
...before !== void 0 ? { before } : {},
|
|
120
|
+
packageLockOnly: true,
|
|
121
|
+
save: true
|
|
122
|
+
});
|
|
123
|
+
const tree = await arb.buildIdealTree();
|
|
124
|
+
await arb.reify();
|
|
125
|
+
const top = readTopLevelFromIdealTree(tree, targetName);
|
|
126
|
+
const lockfile = await fs.promises.readFile(
|
|
127
|
+
path.join(installPath, "package-lock.json"),
|
|
128
|
+
"utf8"
|
|
129
|
+
);
|
|
130
|
+
return { ...top, lockfile };
|
|
131
|
+
}
|
|
132
|
+
async function safeReify(options) {
|
|
133
|
+
const { packageLock = true, path: installPath, quiet = true } = options;
|
|
134
|
+
const arb = new import_arborist.default({
|
|
135
|
+
...getBaseArboristOptions(installPath, quiet),
|
|
136
|
+
packageLock
|
|
137
|
+
});
|
|
138
|
+
await arb.reify();
|
|
139
|
+
}
|
|
140
|
+
async function writeSafeNpmrc(installPath, options) {
|
|
141
|
+
const fs = /* @__PURE__ */ getFs();
|
|
142
|
+
const path = /* @__PURE__ */ getPath();
|
|
143
|
+
const { minReleaseDays, minReleaseMins } = {
|
|
144
|
+
__proto__: null,
|
|
145
|
+
...options
|
|
146
|
+
};
|
|
147
|
+
if (minReleaseDays !== void 0 && minReleaseMins !== void 0) {
|
|
148
|
+
throw new Error(
|
|
149
|
+
"writeSafeNpmrc: minReleaseDays and minReleaseMins are mutually exclusive"
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
const lines = [
|
|
153
|
+
"ignore-scripts=true",
|
|
154
|
+
"audit=false",
|
|
155
|
+
"fund=false",
|
|
156
|
+
"save=false",
|
|
157
|
+
"save-bundle=false",
|
|
158
|
+
"progress=false"
|
|
159
|
+
];
|
|
160
|
+
if (minReleaseDays !== void 0) {
|
|
161
|
+
lines.push(`min-release-age=${minReleaseDays}`);
|
|
162
|
+
}
|
|
163
|
+
if (minReleaseMins !== void 0) {
|
|
164
|
+
lines.push(`minimum-release-age=${minReleaseMins}`);
|
|
165
|
+
}
|
|
166
|
+
await fs.promises.writeFile(
|
|
167
|
+
path.join(installPath, ".npmrc"),
|
|
168
|
+
lines.join("\n") + "\n",
|
|
169
|
+
"utf8"
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
173
|
+
0 && (module.exports = {
|
|
174
|
+
safeIdealTree,
|
|
175
|
+
safeReify,
|
|
176
|
+
writeSafeNpmrc
|
|
177
|
+
});
|
package/dist/dlx/binary.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
/** @fileoverview DLX binary execution utilities for Socket ecosystem. */
|
|
2
|
+
import { getSocketDlxDir } from '../paths/socket';
|
|
1
3
|
import { spawn } from '../spawn';
|
|
4
|
+
import type { HashSpec } from './integrity';
|
|
2
5
|
import type { SpawnExtra, SpawnOptions } from '../spawn';
|
|
3
6
|
export interface DlxBinaryOptions {
|
|
4
7
|
/**
|
|
@@ -9,14 +12,27 @@ export interface DlxBinaryOptions {
|
|
|
9
12
|
* Optional name for the cached binary (defaults to URL hash).
|
|
10
13
|
*/
|
|
11
14
|
name?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Expected hash for verification. Accepts either:
|
|
17
|
+
* - A bare sha512 SRI string (`sha512-<base64>`), sniffed as integrity.
|
|
18
|
+
* - A bare sha256 hex string (64 hex chars), sniffed as checksum.
|
|
19
|
+
* - An explicit `{ type: 'integrity' | 'checksum', value }` object.
|
|
20
|
+
*
|
|
21
|
+
* This is the preferred field. `integrity` and `sha256` remain as
|
|
22
|
+
* lower-level escapes; if both `hash` and one of those is set, `hash`
|
|
23
|
+
* wins for the matching flavor.
|
|
24
|
+
*/
|
|
25
|
+
hash?: HashSpec | undefined;
|
|
12
26
|
/**
|
|
13
27
|
* Expected SRI integrity hash (sha512-<base64>) for verification.
|
|
28
|
+
* Lower-level alternative to `hash`.
|
|
14
29
|
*/
|
|
15
30
|
integrity?: string | undefined;
|
|
16
31
|
/**
|
|
17
32
|
* Expected SHA-256 hex checksum for verification.
|
|
18
33
|
* Passed to httpDownload for inline verification during download.
|
|
19
34
|
* This is more secure than post-download verification as it fails early.
|
|
35
|
+
* Lower-level alternative to `hash`.
|
|
20
36
|
*/
|
|
21
37
|
sha256?: string | undefined;
|
|
22
38
|
/**
|
|
@@ -199,26 +215,26 @@ export declare function downloadBinaryFile(url: string, destPath: string, integr
|
|
|
199
215
|
*/
|
|
200
216
|
export declare function executeBinary(binaryPath: string, args: readonly string[] | string[], spawnOptions?: SpawnOptions | undefined, spawnExtra?: SpawnExtra | undefined): ReturnType<typeof spawn>;
|
|
201
217
|
/**
|
|
202
|
-
* Get
|
|
203
|
-
* Returns normalized path for cross-platform compatibility.
|
|
204
|
-
* Uses same directory as dlx-package for unified DLX storage.
|
|
218
|
+
* Get metadata file path for a cached binary.
|
|
205
219
|
*
|
|
206
220
|
* @example
|
|
207
221
|
* ```typescript
|
|
208
|
-
* const
|
|
222
|
+
* const metaPath = getBinaryCacheMetadataPath('/tmp/dlx-cache/a1b2c3d4')
|
|
223
|
+
* // '/tmp/dlx-cache/a1b2c3d4/.dlx-metadata.json'
|
|
209
224
|
* ```
|
|
210
225
|
*/
|
|
211
|
-
export declare function
|
|
226
|
+
export declare function getBinaryCacheMetadataPath(cacheEntryPath: string): string;
|
|
212
227
|
/**
|
|
213
|
-
* Get
|
|
228
|
+
* Get the DLX binary cache directory path.
|
|
229
|
+
* Alias of `getSocketDlxDir` — DLX binary cache uses the same directory
|
|
230
|
+
* as dlx-package for unified DLX storage.
|
|
214
231
|
*
|
|
215
232
|
* @example
|
|
216
233
|
* ```typescript
|
|
217
|
-
* const
|
|
218
|
-
* // '/tmp/dlx-cache/a1b2c3d4/.dlx-metadata.json'
|
|
234
|
+
* const cachePath = getDlxCachePath()
|
|
219
235
|
* ```
|
|
220
236
|
*/
|
|
221
|
-
export declare
|
|
237
|
+
export declare const getDlxCachePath: typeof getSocketDlxDir;
|
|
222
238
|
/**
|
|
223
239
|
* Check if a cached binary is still valid.
|
|
224
240
|
*
|
package/dist/dlx/binary.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;
|
|
@@ -44,19 +45,20 @@ module.exports = __toCommonJS(binary_exports);
|
|
|
44
45
|
var import_node_process = __toESM(require("node:process"));
|
|
45
46
|
var import_platform = require("../constants/platform");
|
|
46
47
|
var import_time = require("../constants/time");
|
|
47
|
-
var import_cache = require("./cache");
|
|
48
|
-
var import_http_request = require("../http-request");
|
|
49
48
|
var import_fs = require("../fs");
|
|
49
|
+
var import_http_request = require("../http-request");
|
|
50
50
|
var import_objects = require("../objects");
|
|
51
51
|
var import_normalize = require("../paths/normalize");
|
|
52
52
|
var import_socket = require("../paths/socket");
|
|
53
53
|
var import_process_lock = require("../process-lock");
|
|
54
54
|
var import_spawn = require("../spawn");
|
|
55
|
+
var import_cache = require("./cache");
|
|
56
|
+
var import_integrity = require("./integrity");
|
|
55
57
|
let _crypto;
|
|
56
58
|
// @__NO_SIDE_EFFECTS__
|
|
57
59
|
function getCrypto() {
|
|
58
60
|
if (_crypto === void 0) {
|
|
59
|
-
_crypto = require("crypto");
|
|
61
|
+
_crypto = require("node:crypto");
|
|
60
62
|
}
|
|
61
63
|
return _crypto;
|
|
62
64
|
}
|
|
@@ -64,7 +66,7 @@ let _fs;
|
|
|
64
66
|
// @__NO_SIDE_EFFECTS__
|
|
65
67
|
function getFs() {
|
|
66
68
|
if (_fs === void 0) {
|
|
67
|
-
_fs = require("fs");
|
|
69
|
+
_fs = require("node:fs");
|
|
68
70
|
}
|
|
69
71
|
return _fs;
|
|
70
72
|
}
|
|
@@ -72,7 +74,7 @@ let _path;
|
|
|
72
74
|
// @__NO_SIDE_EFFECTS__
|
|
73
75
|
function getPath() {
|
|
74
76
|
if (_path === void 0) {
|
|
75
|
-
_path = require("path");
|
|
77
|
+
_path = require("node:path");
|
|
76
78
|
}
|
|
77
79
|
return _path;
|
|
78
80
|
}
|
|
@@ -120,13 +122,24 @@ async function dlxBinary(args, options, spawnExtra) {
|
|
|
120
122
|
const {
|
|
121
123
|
cacheTtl = import_time.DLX_BINARY_CACHE_TTL,
|
|
122
124
|
force: userForce = false,
|
|
123
|
-
|
|
125
|
+
hash,
|
|
126
|
+
integrity: rawIntegrity,
|
|
124
127
|
name,
|
|
125
|
-
sha256,
|
|
128
|
+
sha256: rawSha256,
|
|
126
129
|
spawnOptions,
|
|
127
130
|
url,
|
|
128
131
|
yes
|
|
129
132
|
} = { __proto__: null, ...options };
|
|
133
|
+
let integrity = rawIntegrity;
|
|
134
|
+
let sha256 = rawSha256;
|
|
135
|
+
if (hash !== void 0) {
|
|
136
|
+
const normalized = (0, import_integrity.normalizeHash)(hash);
|
|
137
|
+
if (normalized.type === "integrity") {
|
|
138
|
+
integrity = normalized.value;
|
|
139
|
+
} else {
|
|
140
|
+
sha256 = normalized.value;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
130
143
|
const fs = /* @__PURE__ */ getFs();
|
|
131
144
|
const path = /* @__PURE__ */ getPath();
|
|
132
145
|
const force = yes === true ? true : userForce;
|
|
@@ -215,11 +228,22 @@ async function downloadBinary(options) {
|
|
|
215
228
|
const {
|
|
216
229
|
cacheTtl = import_time.DLX_BINARY_CACHE_TTL,
|
|
217
230
|
force = false,
|
|
218
|
-
|
|
231
|
+
hash,
|
|
232
|
+
integrity: rawIntegrity,
|
|
219
233
|
name,
|
|
220
|
-
sha256,
|
|
234
|
+
sha256: rawSha256,
|
|
221
235
|
url
|
|
222
236
|
} = { __proto__: null, ...options };
|
|
237
|
+
let integrity = rawIntegrity;
|
|
238
|
+
let sha256 = rawSha256;
|
|
239
|
+
if (hash !== void 0) {
|
|
240
|
+
const normalized = (0, import_integrity.normalizeHash)(hash);
|
|
241
|
+
if (normalized.type === "integrity") {
|
|
242
|
+
integrity = normalized.value;
|
|
243
|
+
} else {
|
|
244
|
+
sha256 = normalized.value;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
223
247
|
const fs = /* @__PURE__ */ getFs();
|
|
224
248
|
const path = /* @__PURE__ */ getPath();
|
|
225
249
|
const cacheDir = getDlxCachePath();
|
|
@@ -344,12 +368,10 @@ function executeBinary(binaryPath, args, spawnOptions, spawnExtra) {
|
|
|
344
368
|
} : spawnOptions;
|
|
345
369
|
return (0, import_spawn.spawn)(binaryPath, args, finalSpawnOptions, spawnExtra);
|
|
346
370
|
}
|
|
347
|
-
function getDlxCachePath() {
|
|
348
|
-
return (0, import_socket.getSocketDlxDir)();
|
|
349
|
-
}
|
|
350
371
|
function getBinaryCacheMetadataPath(cacheEntryPath) {
|
|
351
372
|
return (/* @__PURE__ */ getPath()).join(cacheEntryPath, ".dlx-metadata.json");
|
|
352
373
|
}
|
|
374
|
+
const getDlxCachePath = import_socket.getSocketDlxDir;
|
|
353
375
|
async function isBinaryCacheValid(cacheEntryPath, cacheTtl) {
|
|
354
376
|
const fs = /* @__PURE__ */ getFs();
|
|
355
377
|
try {
|
package/dist/dlx/cache.d.ts
CHANGED
package/dist/dlx/cache.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;
|
|
@@ -26,7 +27,7 @@ let _crypto;
|
|
|
26
27
|
// @__NO_SIDE_EFFECTS__
|
|
27
28
|
function getCrypto() {
|
|
28
29
|
if (_crypto === void 0) {
|
|
29
|
-
_crypto = require("crypto");
|
|
30
|
+
_crypto = require("node:crypto");
|
|
30
31
|
}
|
|
31
32
|
return _crypto;
|
|
32
33
|
}
|
package/dist/dlx/detect.d.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Executable type detection for DLX and local filesystem paths.
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities to detect whether a path is a Node.js package or native
|
|
5
|
+
* binary executable. Supports both DLX cache paths and local filesystem paths.
|
|
6
|
+
*
|
|
7
|
+
* Key Functions:
|
|
8
|
+
* - detectExecutableType: Generic entry point for any path
|
|
9
|
+
* - detectDlxExecutableType: DLX cache specific detection
|
|
10
|
+
* - detectLocalExecutableType: Local filesystem specific detection
|
|
11
|
+
*
|
|
12
|
+
* Detection Strategies:
|
|
13
|
+
* - DLX cache: Check for node_modules/ directory
|
|
14
|
+
* - Local paths: Check for package.json with bin field, then file extension
|
|
15
|
+
*/
|
|
1
16
|
export type ExecutableType = 'package' | 'binary' | 'unknown';
|
|
2
17
|
export interface ExecutableDetectionResult {
|
|
3
18
|
type: ExecutableType;
|
package/dist/dlx/detect.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;
|
|
@@ -31,20 +32,6 @@ var import_paths = require("./paths");
|
|
|
31
32
|
var import_socket = require("../paths/socket");
|
|
32
33
|
let _fs;
|
|
33
34
|
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
|
-
}
|
|
48
35
|
const NODE_JS_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs"]);
|
|
49
36
|
const packageJsonPathCache = /* @__PURE__ */ new Map();
|
|
50
37
|
const packageJsonContentCache = /* @__PURE__ */ new Map();
|
|
@@ -75,18 +62,39 @@ function findPackageJson(filePath) {
|
|
|
75
62
|
packageJsonPathCache.set(startDir, null);
|
|
76
63
|
return void 0;
|
|
77
64
|
}
|
|
65
|
+
// @__NO_SIDE_EFFECTS__
|
|
66
|
+
function getFs() {
|
|
67
|
+
if (_fs === void 0) {
|
|
68
|
+
_fs = require("node:fs");
|
|
69
|
+
}
|
|
70
|
+
return _fs;
|
|
71
|
+
}
|
|
72
|
+
// @__NO_SIDE_EFFECTS__
|
|
73
|
+
function getPath() {
|
|
74
|
+
if (_path === void 0) {
|
|
75
|
+
_path = require("node:path");
|
|
76
|
+
}
|
|
77
|
+
return _path;
|
|
78
|
+
}
|
|
78
79
|
function readPackageJson(packageJsonPath) {
|
|
79
80
|
const fs = /* @__PURE__ */ getFs();
|
|
81
|
+
let mtimeMs = 0;
|
|
82
|
+
try {
|
|
83
|
+
mtimeMs = fs.statSync(packageJsonPath).mtimeMs;
|
|
84
|
+
} catch {
|
|
85
|
+
packageJsonContentCache.delete(packageJsonPath);
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
80
88
|
const cached = packageJsonContentCache.get(packageJsonPath);
|
|
81
|
-
if (cached !== void 0) {
|
|
82
|
-
return cached;
|
|
89
|
+
if (cached !== void 0 && cached.mtimeMs === mtimeMs) {
|
|
90
|
+
return cached.content;
|
|
83
91
|
}
|
|
84
92
|
try {
|
|
85
93
|
const content = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
86
|
-
packageJsonContentCache.set(packageJsonPath, content);
|
|
94
|
+
packageJsonContentCache.set(packageJsonPath, { mtimeMs, content });
|
|
87
95
|
return content;
|
|
88
96
|
} catch {
|
|
89
|
-
packageJsonContentCache.set(packageJsonPath, null);
|
|
97
|
+
packageJsonContentCache.set(packageJsonPath, { mtimeMs, content: null });
|
|
90
98
|
return null;
|
|
91
99
|
}
|
|
92
100
|
}
|
|
@@ -96,7 +104,7 @@ function detectDlxExecutableType(filePath) {
|
|
|
96
104
|
const dlxDir = (0, import_socket.getSocketDlxDir)();
|
|
97
105
|
const absolutePath = path.resolve(filePath);
|
|
98
106
|
const relativePath = path.relative(dlxDir, absolutePath);
|
|
99
|
-
const cacheKey = relativePath.split(path.sep)[0];
|
|
107
|
+
const cacheKey = relativePath.split(path.sep)[0] ?? "";
|
|
100
108
|
const cacheDir = path.join(dlxDir, cacheKey);
|
|
101
109
|
if (fs.existsSync(path.join(cacheDir, "node_modules"))) {
|
|
102
110
|
return {
|
|
@@ -121,7 +129,7 @@ function detectLocalExecutableType(filePath) {
|
|
|
121
129
|
const packageJsonPath = findPackageJson(filePath);
|
|
122
130
|
if (packageJsonPath !== void 0) {
|
|
123
131
|
const packageJson = readPackageJson(packageJsonPath);
|
|
124
|
-
if (packageJson?.bin) {
|
|
132
|
+
if (packageJson?.["bin"]) {
|
|
125
133
|
return {
|
|
126
134
|
type: "package",
|
|
127
135
|
method: "package-json",
|
package/dist/dlx/dir.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @fileoverview Directory management utilities for DLX installations. */
|
|
1
2
|
/**
|
|
2
3
|
* Clear all DLX package installations.
|
|
3
4
|
*
|
|
@@ -27,17 +28,6 @@ export declare function clearDlxSync(): void;
|
|
|
27
28
|
* ```
|
|
28
29
|
*/
|
|
29
30
|
export declare function dlxDirExists(): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Check if the DLX directory exists asynchronously.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* if (await dlxDirExistsAsync()) {
|
|
36
|
-
* console.log('DLX directory is present')
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare function dlxDirExistsAsync(): Promise<boolean>;
|
|
41
31
|
/**
|
|
42
32
|
* Ensure the DLX directory exists, creating it if necessary.
|
|
43
33
|
*
|
package/dist/dlx/dir.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;
|
|
@@ -22,7 +23,6 @@ __export(dir_exports, {
|
|
|
22
23
|
clearDlx: () => clearDlx,
|
|
23
24
|
clearDlxSync: () => clearDlxSync,
|
|
24
25
|
dlxDirExists: () => dlxDirExists,
|
|
25
|
-
dlxDirExistsAsync: () => dlxDirExistsAsync,
|
|
26
26
|
ensureDlxDir: () => ensureDlxDir,
|
|
27
27
|
ensureDlxDirSync: () => ensureDlxDirSync
|
|
28
28
|
});
|
|
@@ -35,7 +35,7 @@ let _fs;
|
|
|
35
35
|
// @__NO_SIDE_EFFECTS__
|
|
36
36
|
function getFs() {
|
|
37
37
|
if (_fs === void 0) {
|
|
38
|
-
_fs = require("fs");
|
|
38
|
+
_fs = require("node:fs");
|
|
39
39
|
}
|
|
40
40
|
return _fs;
|
|
41
41
|
}
|
|
@@ -53,15 +53,6 @@ function dlxDirExists() {
|
|
|
53
53
|
const fs = /* @__PURE__ */ getFs();
|
|
54
54
|
return fs.existsSync((0, import_socket.getSocketDlxDir)());
|
|
55
55
|
}
|
|
56
|
-
async function dlxDirExistsAsync() {
|
|
57
|
-
const fs = /* @__PURE__ */ getFs();
|
|
58
|
-
try {
|
|
59
|
-
await fs.promises.access((0, import_socket.getSocketDlxDir)());
|
|
60
|
-
return true;
|
|
61
|
-
} catch {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
56
|
async function ensureDlxDir() {
|
|
66
57
|
await (0, import_fs.safeMkdir)((0, import_socket.getSocketDlxDir)());
|
|
67
58
|
}
|
|
@@ -73,7 +64,6 @@ function ensureDlxDirSync() {
|
|
|
73
64
|
clearDlx,
|
|
74
65
|
clearDlxSync,
|
|
75
66
|
dlxDirExists,
|
|
76
|
-
dlxDirExistsAsync,
|
|
77
67
|
ensureDlxDir,
|
|
78
68
|
ensureDlxDirSync
|
|
79
69
|
});
|