@socketsecurity/lib 6.0.8 → 6.0.10
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 +28 -0
- package/README.md +8 -9
- package/dist/abort/signal.d.ts +1 -1
- package/dist/abort/signal.js +1 -1
- package/dist/ai/agent-context.d.mts +1 -1
- package/dist/ai/agent-context.js +3 -2
- package/dist/ai/backends.d.mts +3 -3
- package/dist/ai/backends.js +2 -2
- package/dist/ai/billing-context.d.mts +74 -0
- package/dist/ai/billing-context.js +129 -0
- package/dist/ai/credentials.d.mts +39 -5
- package/dist/ai/credentials.js +61 -6
- package/dist/ai/discover.d.mts +4 -0
- package/dist/ai/discover.js +4 -0
- package/dist/ai/exec.d.mts +1 -1
- package/dist/ai/exec.js +1 -1
- package/dist/ai/http.d.mts +8 -8
- package/dist/ai/http.js +6 -6
- package/dist/ai/profiles.d.mts +9 -10
- package/dist/ai/profiles.js +0 -5
- package/dist/ai/role.d.mts +58 -0
- package/dist/ai/role.js +96 -0
- package/dist/ai/route-heuristic.d.mts +177 -0
- package/dist/ai/route-heuristic.js +194 -0
- package/dist/ai/route.d.mts +31 -17
- package/dist/ai/route.js +35 -19
- package/dist/ai/spawn.d.mts +34 -1
- package/dist/ai/spawn.js +115 -3
- package/dist/ai/subagent-status.d.mts +2 -0
- package/dist/ai/subagent-status.js +2 -0
- package/dist/ai/tier.d.mts +1 -1
- package/dist/ai/types.d.mts +19 -2
- package/dist/ai/worktree.d.mts +1 -1
- package/dist/ai/worktree.js +3 -2
- package/dist/argv/parse.d.ts +2 -0
- package/dist/argv/parse.js +2 -0
- package/dist/bin/_internal.d.ts +1 -1
- package/dist/bin/_internal.js +1 -1
- package/dist/bin/prim.cjs +19253 -13937
- package/dist/bin/resolve.js +1 -1
- package/dist/bin/shadow.js +2 -1
- package/dist/bin/which.d.ts +28 -3
- package/dist/bin/which.js +45 -3
- package/dist/cacache/_internal.d.ts +10 -2
- package/dist/cacache/_internal.js +6 -10
- package/dist/cache/ttl/_internal.d.ts +33 -0
- package/dist/cache/ttl/_internal.js +68 -0
- package/dist/cache/ttl/browser.d.ts +56 -0
- package/dist/cache/ttl/browser.js +257 -0
- package/dist/cache/ttl/store.js +11 -34
- package/dist/cache/ttl/types.d.ts +46 -3
- package/dist/checks/primordials-defaults.d.ts +5 -5
- package/dist/checks/primordials-defaults.js +5 -5
- package/dist/checks/primordials.d.ts +1 -1
- package/dist/checks/primordials.js +25 -17
- package/dist/cli/check-primordials.d.ts +6 -1
- package/dist/cli/check-primordials.js +14 -5
- package/dist/cli/check.js +1 -1
- package/dist/cli/socket-lib.d.ts +1 -1
- package/dist/cli/socket-lib.js +3 -3
- package/dist/colors/socket-palette.d.ts +1 -1
- package/dist/compression/brotli.d.ts +6 -2
- package/dist/compression/brotli.js +5 -1
- package/dist/compression/gzip.d.ts +6 -2
- package/dist/compression/gzip.js +7 -2
- package/dist/config/layers.d.ts +53 -0
- package/dist/config/layers.js +83 -0
- package/dist/constants/agents.d.ts +3 -0
- package/dist/constants/agents.js +3 -0
- package/dist/constants/node.d.ts +14 -0
- package/dist/constants/node.js +14 -0
- package/dist/constants/package-default-node-range.js +1 -5
- package/dist/constants/packages.d.ts +5 -0
- package/dist/constants/packages.js +5 -0
- package/dist/constants/platform.d.ts +1 -1
- package/dist/constants/platform.js +1 -1
- package/dist/constants/socket.js +1 -1
- package/dist/constants/typescript.d.ts +5 -0
- package/dist/constants/typescript.js +5 -0
- package/dist/debug/_internal.d.ts +22 -7
- package/dist/debug/_internal.js +33 -15
- package/dist/debug/caller-info.js +1 -1
- package/dist/debug/namespace.js +11 -8
- package/dist/debug/output.d.ts +12 -1
- package/dist/debug/output.js +33 -16
- package/dist/dlx/binary-cache.js +1 -1
- package/dist/dlx/binary-resolution.js +8 -5
- package/dist/dlx/firewall.js +1 -1
- package/dist/dlx/lockfile.js +1 -1
- package/dist/eco/npm/npm/parse-lockfile.js +3 -2
- package/dist/eco/npm/vlt/exec.d.ts +1 -1
- package/dist/eco/npm/vlt/exec.js +1 -1
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +1 -1
- package/dist/env/agents.d.ts +6 -0
- package/dist/env/agents.js +29 -0
- package/dist/env/flags.d.ts +12 -0
- package/dist/env/flags.js +23 -0
- package/dist/env/github-status.js +2 -2
- package/dist/env/providers.d.ts +6 -0
- package/dist/env/providers.js +23 -0
- package/dist/env/proxy.js +1 -1
- package/dist/env/rewire.d.ts +37 -3
- package/dist/env/rewire.js +60 -29
- package/dist/env/runtimes.d.ts +9 -0
- package/dist/env/runtimes.js +53 -0
- package/dist/env/socket-cli.d.ts +5 -2
- package/dist/env/socket-cli.js +6 -3
- package/dist/env/xdg.d.ts +17 -0
- package/dist/env/xdg.js +21 -1
- package/dist/errors/predicates.d.ts +3 -2
- package/dist/errors/predicates.js +5 -3
- package/dist/events/exit/_internal.d.ts +1 -23
- package/dist/external/@npmcli/package-json.js +3570 -4905
- package/dist/external/@npmcli/promise-spawn.js +2 -2
- package/dist/external/@sinclair/typebox/value.js +5 -4
- package/dist/external/@socketregistry/yocto-spinner.js +3 -3
- package/dist/external/@yarnpkg/extensions.js +1 -1
- package/dist/external/adm-zip.d.ts +82 -0
- package/dist/external/adm-zip.js +2 -2
- package/dist/external/cacache.d.ts +87 -0
- package/dist/external/debug.d.ts +22 -0
- package/dist/external/debug.js +11 -4
- package/dist/external/del.d.ts +1 -0
- package/dist/external/external-pack.d.ts +12 -0
- package/dist/external/external-pack.js +42 -35
- package/dist/external/fast-glob.d.ts +8 -0
- package/dist/external/fast-sort.d.ts +1 -0
- package/dist/external/get-east-asian-width.d.ts +5 -0
- package/dist/external/get-east-asian-width.js +8 -1
- package/dist/external/has-flag.d.ts +1 -0
- package/dist/external/inquirer-pack.d.ts +18 -0
- package/dist/external/libnpmexec.d.ts +35 -0
- package/dist/external/libnpmpack.d.ts +1 -0
- package/dist/external/make-fetch-happen.d.ts +13 -0
- package/dist/external/normalize-package-data.d.ts +4 -0
- package/dist/external/npm-core.d.ts +14 -0
- package/dist/external/npm-pack.d.ts +24 -0
- package/dist/external/npm-pack.js +28934 -31885
- package/dist/external/npm-package-arg.d.ts +4 -0
- package/dist/external/p-map.js +8 -1
- package/dist/external/pacote.d.ts +15 -0
- package/dist/external/pico-pack.d.ts +16 -0
- package/dist/external/pico-pack.js +38 -23
- package/dist/external/picomatch.d.ts +96 -0
- package/dist/external/pony-cause.d.ts +14 -0
- package/dist/external/semver.d.ts +60 -0
- package/dist/external/semver.js +1459 -4
- package/dist/external/shell-quote.d.ts +51 -0
- package/dist/external/shell-quote.js +55 -15
- package/dist/external/signal-exit.d.ts +1 -0
- package/dist/external/spdx-correct.d.ts +4 -0
- package/dist/external/spdx-expression-parse.d.ts +4 -0
- package/dist/external/spdx-pack.d.ts +10 -0
- package/dist/external/std-env.d.ts +284 -0
- package/dist/external/std-env.js +323 -0
- package/dist/external/streaming-iterables.d.ts +11 -0
- package/dist/external/supports-color.d.ts +1 -0
- package/dist/external/tar-fs.d.ts +31 -0
- package/dist/external/tar-fs.js +63 -16
- package/dist/external/validate-npm-package-name.d.ts +4 -0
- package/dist/external/which.d.ts +25 -0
- package/dist/external/which.js +2 -2
- package/dist/external/yargs-parser.d.ts +2 -0
- package/dist/external/yargs-parser.js +11 -3
- package/dist/external/yoctocolors-cjs.d.ts +51 -0
- package/dist/external-tools/bazel/asset-names.d.ts +1 -1
- package/dist/external-tools/bazel/from-download.d.ts +1 -1
- package/dist/external-tools/bazel/resolve.d.ts +3 -0
- package/dist/external-tools/bazel/resolve.js +3 -0
- package/dist/external-tools/cdxgen/asset-names.d.ts +5 -5
- package/dist/external-tools/cdxgen/asset-names.js +3 -3
- package/dist/external-tools/cdxgen/from-download.d.ts +2 -2
- package/dist/external-tools/cdxgen/from-download.js +1 -1
- package/dist/external-tools/cdxgen/resolve.d.ts +4 -1
- package/dist/external-tools/cdxgen/resolve.js +4 -1
- package/dist/external-tools/cdxgen/types.d.ts +1 -1
- package/dist/external-tools/from-download.d.ts +2 -2
- package/dist/external-tools/from-download.js +1 -1
- package/dist/external-tools/janus/asset-names.d.ts +4 -1
- package/dist/external-tools/janus/asset-names.js +3 -0
- package/dist/external-tools/janus/from-download.d.ts +3 -3
- package/dist/external-tools/janus/from-download.js +2 -2
- package/dist/external-tools/janus/resolve.d.ts +3 -0
- package/dist/external-tools/janus/resolve.js +3 -0
- package/dist/external-tools/jre/asset-names.d.ts +3 -1
- package/dist/external-tools/jre/asset-names.js +2 -0
- package/dist/external-tools/jre/detect-platform-arch.js +1 -1
- package/dist/external-tools/jre/from-download.d.ts +1 -1
- package/dist/external-tools/manifest.d.ts +5 -3
- package/dist/external-tools/manifest.js +5 -3
- package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
- package/dist/external-tools/opengrep/resolve.d.ts +3 -0
- package/dist/external-tools/opengrep/resolve.js +3 -0
- package/dist/external-tools/python/asset-names.d.ts +3 -1
- package/dist/external-tools/python/asset-names.js +8 -4
- package/dist/external-tools/python/pin.js +3 -1
- package/dist/external-tools/python/resolve.d.ts +3 -0
- package/dist/external-tools/python/resolve.js +3 -0
- package/dist/external-tools/python/uv-install.d.ts +89 -0
- package/dist/external-tools/python/uv-install.js +165 -0
- package/dist/external-tools/sbt/resolve.d.ts +3 -0
- package/dist/external-tools/sbt/resolve.js +3 -0
- package/dist/external-tools/skillspector/from-uv.d.ts +30 -0
- package/dist/external-tools/skillspector/from-uv.js +56 -0
- package/dist/external-tools/skillspector/resolve.d.ts +18 -3
- package/dist/external-tools/skillspector/resolve.js +21 -8
- package/dist/external-tools/skillspector/types.d.ts +3 -1
- package/dist/external-tools/synp/resolve.d.ts +3 -0
- package/dist/external-tools/synp/resolve.js +3 -0
- package/dist/external-tools/trivy/asset-names.d.ts +1 -1
- package/dist/external-tools/trivy/resolve.d.ts +3 -0
- package/dist/external-tools/trivy/resolve.js +3 -0
- package/dist/external-tools/trufflehog/asset-names.d.ts +4 -1
- package/dist/external-tools/trufflehog/asset-names.js +3 -0
- package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
- package/dist/external-tools/trufflehog/resolve.d.ts +3 -0
- package/dist/external-tools/trufflehog/resolve.js +3 -0
- package/dist/external-tools/uv/asset-names.d.ts +36 -0
- package/dist/external-tools/uv/asset-names.js +73 -0
- package/dist/external-tools/uv/from-download.d.ts +17 -0
- package/dist/external-tools/uv/from-download.js +50 -0
- package/dist/external-tools/uv/from-path.d.ts +5 -0
- package/dist/external-tools/uv/from-path.js +22 -0
- package/dist/external-tools/uv/from-vfs.d.ts +7 -0
- package/dist/external-tools/uv/from-vfs.js +26 -0
- package/dist/external-tools/uv/resolve.d.ts +28 -0
- package/dist/external-tools/uv/resolve.js +64 -0
- package/dist/external-tools/uv/types.d.ts +24 -0
- package/dist/external-tools/uv/types.js +2 -0
- package/dist/fleet/repo-config.d.ts +55 -0
- package/dist/fleet/repo-config.js +81 -0
- package/dist/fs/_internal.d.ts +1 -1
- package/dist/fs/_internal.js +1 -1
- package/dist/fs/access.d.ts +2 -0
- package/dist/fs/access.js +2 -0
- package/dist/fs/copy.d.ts +88 -0
- package/dist/fs/copy.js +89 -0
- package/dist/fs/find.js +1 -2
- package/dist/fs/inspect.d.ts +2 -2
- package/dist/fs/read-file.js +3 -4
- package/dist/fs/safe.js +2 -2
- package/dist/git/_internal.js +7 -3
- package/dist/github/commit.d.ts +92 -0
- package/dist/github/commit.js +113 -0
- package/dist/github/ghsa.js +1 -1
- package/dist/github/refs-graphql.js +1 -1
- package/dist/github/refs.js +10 -15
- package/dist/github/request.js +1 -1
- package/dist/github/token.d.ts +5 -2
- package/dist/github/token.js +6 -4
- package/dist/github/workflow-runs.d.ts +107 -0
- package/dist/github/workflow-runs.js +98 -0
- package/dist/globs/_internal.js +1 -1
- package/dist/http-request/_internal.d.ts +1 -1
- package/dist/http-request/browser.d.ts +6 -0
- package/dist/http-request/browser.js +4 -3
- package/dist/http-request/checksum-file.js +1 -1
- package/dist/http-request/download.js +2 -0
- package/dist/http-request/headers.d.ts +1 -1
- package/dist/http-request/headers.js +2 -2
- package/dist/http-request/request-attempt.js +6 -3
- package/dist/http-request/request-types.d.ts +10 -1
- package/dist/http-request/request.js +2 -2
- package/dist/http-request/user-agent.d.ts +23 -2
- package/dist/http-request/user-agent.js +48 -6
- package/dist/integrity.d.ts +127 -78
- package/dist/integrity.js +170 -84
- package/dist/json/format.js +4 -1
- package/dist/logger/_internal.d.ts +13 -15
- package/dist/logger/_internal.js +21 -21
- package/dist/logger/colors.d.ts +10 -5
- package/dist/logger/colors.js +7 -14
- package/dist/logger/console-methods.js +2 -2
- package/dist/logger/console.d.ts +1 -0
- package/dist/logger/console.js +9 -9
- package/dist/logger/node.js +2 -1
- package/dist/logger/symbols-builder.js +7 -8
- package/dist/logger/symbols.js +8 -8
- package/dist/native-messaging/install.js +1 -1
- package/dist/native-messaging/rate-limit.d.ts +4 -1
- package/dist/native-messaging/rate-limit.js +4 -1
- package/dist/node/events.d.ts +3 -0
- package/dist/node/events.js +3 -0
- package/dist/node/fs.d.ts +1 -1
- package/dist/node/module.d.ts +73 -2
- package/dist/node/module.js +97 -12
- package/dist/node/timers-promises.d.ts +3 -0
- package/dist/node/timers-promises.js +3 -0
- package/dist/node/url.d.ts +3 -0
- package/dist/node/url.js +3 -0
- package/dist/npm/meta-cache.d.ts +183 -0
- package/dist/npm/meta-cache.js +318 -0
- package/dist/npm/meta-slice.d.ts +27 -0
- package/dist/npm/meta-slice.js +68 -0
- package/dist/npm/meta-types.d.ts +282 -0
- package/dist/npm/meta-types.js +2 -0
- package/dist/npm/meta.d.ts +125 -0
- package/dist/npm/meta.js +347 -0
- package/dist/npm/registry.d.ts +212 -0
- package/dist/npm/registry.js +284 -0
- package/dist/objects/getters.d.ts +1 -1
- package/dist/objects/getters.js +1 -1
- package/dist/objects/predicates.js +1 -1
- package/dist/packages/exports.js +2 -2
- package/dist/packages/isolation.js +1 -1
- package/dist/packages/manifest.d.ts +29 -0
- package/dist/packages/manifest.js +44 -9
- package/dist/packages/metadata-extensions.js +2 -4
- package/dist/packages/normalize.js +1 -1
- package/dist/packages/provenance.d.ts +8 -0
- package/dist/packages/provenance.js +10 -2
- package/dist/packages/specs.js +1 -1
- package/dist/packages/tarball.js +1 -2
- package/dist/packages/validation.d.ts +0 -10
- package/dist/packages/validation.js +0 -14
- package/dist/paths/_internal.d.ts +1 -7
- package/dist/paths/_internal.js +9 -15
- package/dist/paths/conversion.js +1 -1
- package/dist/paths/exts.d.ts +30 -0
- package/dist/paths/exts.js +30 -0
- package/dist/paths/filenames.d.ts +6 -0
- package/dist/paths/filenames.js +6 -0
- package/dist/paths/globs.d.ts +6 -0
- package/dist/paths/globs.js +6 -0
- package/dist/paths/normalize.js +1 -1
- package/dist/paths/predicates.js +2 -1
- package/dist/paths/resolve.js +19 -14
- package/dist/paths/socket.d.ts +81 -30
- package/dist/paths/socket.js +102 -28
- package/dist/perf/metrics.js +1 -1
- package/dist/perf/report.js +5 -3
- package/dist/pkg-ext/data.js +0 -2
- package/dist/primordials/globals.d.ts +1 -1
- package/dist/primordials/globals.js +1 -1
- package/dist/primordials/headers.d.ts +13 -1
- package/dist/primordials/headers.js +13 -1
- package/dist/primordials/process.d.ts +1 -1
- package/dist/primordials/process.js +1 -1
- package/dist/primordials/url.d.ts +18 -0
- package/dist/primordials/url.js +18 -0
- package/dist/process/spawn/child.js +3 -5
- package/dist/promises/_internal.d.ts +1 -1
- package/dist/promises/_internal.js +1 -2
- package/dist/promises/options.js +3 -3
- package/dist/regexps/spec.js +1 -1
- package/dist/releases/socket-btm-binary-naming.js +12 -1
- package/dist/schema/validate.js +1 -1
- package/dist/secrets/_internal.d.ts +1 -1
- package/dist/secrets/_internal.js +1 -1
- package/dist/secrets/broker.d.ts +35 -0
- package/dist/secrets/broker.js +72 -0
- package/dist/secrets/find.d.ts +8 -6
- package/dist/secrets/find.js +17 -3
- package/dist/secrets/keychain.d.ts +10 -1
- package/dist/secrets/keychain.js +10 -1
- package/dist/secrets/rc.js +1 -1
- package/dist/secrets/socket-api-token.d.ts +1 -1
- package/dist/secrets/socket-api-token.js +1 -1
- package/dist/secrets/types.d.ts +1 -1
- package/dist/smol/detect.js +1 -1
- package/dist/smol/http.d.ts +2 -0
- package/dist/smol/http.js +3 -1
- package/dist/smol/https.d.ts +2 -0
- package/dist/smol/https.js +3 -1
- package/dist/smol/manifest.js +1 -1
- package/dist/smol/path.js +1 -1
- package/dist/smol/primordial.js +1 -1
- package/dist/smol/purl.js +1 -1
- package/dist/smol/versions.js +1 -1
- package/dist/smol/vfs.js +1 -1
- package/dist/sorts/_internal.d.ts +2 -4
- package/dist/sorts/_internal.js +1 -7
- package/dist/sorts/semver.js +2 -2
- package/dist/spinner/create-spinner-class.js +1 -1
- package/dist/spinner/format.js +2 -4
- package/dist/stdio/footer.js +8 -7
- package/dist/stdio/progress.js +1 -1
- package/dist/stdio/prompts.d.ts +8 -23
- package/dist/stdio/prompts.js +28 -52
- package/dist/strings/format.js +1 -1
- package/dist/strings/predicates.d.ts +2 -2
- package/dist/strings/search.js +2 -2
- package/dist/strings/types.d.ts +4 -0
- package/dist/strings/width.d.ts +1 -0
- package/dist/strings/width.js +17 -8
- package/dist/themes/context.d.ts +18 -3
- package/dist/themes/context.js +28 -14
- package/dist/versions/_internal.d.ts +43 -13
- package/dist/versions/_internal.js +27 -15
- package/dist/versions/compare.d.ts +16 -10
- package/dist/versions/compare.js +36 -16
- package/dist/versions/parse.js +1 -1
- package/dist/versions/range.js +3 -2
- package/dist/words/pluralize.js +4 -1
- package/llms.txt +63 -0
- package/package.json +271 -40
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
5
|
+
const require_paths_socket = require('../../paths/socket.js');
|
|
6
|
+
const require_external_tools_from_download = require('../from-download.js');
|
|
7
|
+
const require_external_tools_uv_asset_names = require('./asset-names.js');
|
|
8
|
+
let node_process = require("node:process");
|
|
9
|
+
node_process = require_runtime.__toESM(node_process);
|
|
10
|
+
let node_path = require("node:path");
|
|
11
|
+
node_path = require_runtime.__toESM(node_path);
|
|
12
|
+
|
|
13
|
+
//#region src/external-tools/uv/from-download.ts
|
|
14
|
+
/**
|
|
15
|
+
* @file `uvFromDownload()` — fetches upstream uv and returns a `ResolvedUv`
|
|
16
|
+
* pointing at the extracted binary. uv tarballs wrap the binary in a
|
|
17
|
+
* `<asset-stem>/` directory; the extractor strips that level so the binary
|
|
18
|
+
* sits at the cache-dir root.
|
|
19
|
+
*/
|
|
20
|
+
async function uvFromDownload(options) {
|
|
21
|
+
const { cacheDir, downloader, integrity, platformArch, version } = {
|
|
22
|
+
__proto__: null,
|
|
23
|
+
...options
|
|
24
|
+
};
|
|
25
|
+
const url = require_external_tools_uv_asset_names.getUvDownloadUrl({
|
|
26
|
+
version,
|
|
27
|
+
platformArch
|
|
28
|
+
});
|
|
29
|
+
const entry = require_external_tools_uv_asset_names.getUvAssetEntry(platformArch);
|
|
30
|
+
if (!url || !entry) return;
|
|
31
|
+
const archiveExt = entry.asset.endsWith(".zip") ? ".zip" : ".tar.gz";
|
|
32
|
+
const extractedDir = cacheDir ?? node_path.default.join(require_paths_socket.getSocketDlxDir(), "uv", version, platformArch);
|
|
33
|
+
const archive = await require_external_tools_from_download.downloadAndExtractTool({
|
|
34
|
+
url,
|
|
35
|
+
name: `uv-${version}-${platformArch}${archiveExt}`,
|
|
36
|
+
integrity,
|
|
37
|
+
extractedDir,
|
|
38
|
+
extractOptions: { strip: 1 },
|
|
39
|
+
downloader
|
|
40
|
+
});
|
|
41
|
+
const binary = node_process.default.platform === "win32" ? "uv.exe" : "uv";
|
|
42
|
+
return {
|
|
43
|
+
path: node_path.default.join(extractedDir, binary),
|
|
44
|
+
source: "download",
|
|
45
|
+
integrity: archive.integrity
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.uvFromDownload = uvFromDownload;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_bin_which = require('../../bin/which.js');
|
|
5
|
+
|
|
6
|
+
//#region src/external-tools/uv/from-path.ts
|
|
7
|
+
/**
|
|
8
|
+
* @file `uvFromPath()` — looks for `uv` on the system PATH.
|
|
9
|
+
*/
|
|
10
|
+
async function uvFromPath() {
|
|
11
|
+
const onPath = await require_bin_which.which("uv", { nothrow: true });
|
|
12
|
+
/* c8 ignore start - reached only when uv is NOT on PATH. */
|
|
13
|
+
if (typeof onPath !== "string") return;
|
|
14
|
+
/* c8 ignore stop */
|
|
15
|
+
return {
|
|
16
|
+
path: onPath,
|
|
17
|
+
source: "path"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.uvFromPath = uvFromPath;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `uvFromVfs()` — extracts the uv binary from the smol binary's VFS.
|
|
3
|
+
* Returns `undefined` when the binary doesn't have uv bundled.
|
|
4
|
+
*/
|
|
5
|
+
import type { ResolvedUv } from './types';
|
|
6
|
+
export declare const UV_VFS_KEY = "uv";
|
|
7
|
+
export declare function uvFromVfs(): Promise<ResolvedUv | undefined>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_smol_vfs = require('../../smol/vfs.js');
|
|
5
|
+
|
|
6
|
+
//#region src/external-tools/uv/from-vfs.ts
|
|
7
|
+
/**
|
|
8
|
+
* @file `uvFromVfs()` — extracts the uv binary from the smol binary's VFS.
|
|
9
|
+
* Returns `undefined` when the binary doesn't have uv bundled.
|
|
10
|
+
*/
|
|
11
|
+
const UV_VFS_KEY = "uv";
|
|
12
|
+
async function uvFromVfs() {
|
|
13
|
+
const vfs = require_smol_vfs.getSmolVfs();
|
|
14
|
+
if (!vfs) return;
|
|
15
|
+
/* c8 ignore start - smol Node binary only. */
|
|
16
|
+
if (!vfs.has("uv")) return;
|
|
17
|
+
return {
|
|
18
|
+
path: await vfs.extract("uv"),
|
|
19
|
+
source: "vfs"
|
|
20
|
+
};
|
|
21
|
+
/* c8 ignore stop */
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.UV_VFS_KEY = UV_VFS_KEY;
|
|
26
|
+
exports.uvFromVfs = uvFromVfs;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `resolveUv()` — uv resolution entry point. Tries each source in order:
|
|
3
|
+
*
|
|
4
|
+
* 1. VFS — smol binary's embedded uv (if packed)
|
|
5
|
+
* 2. PATH — `uv` on the system PATH
|
|
6
|
+
* 3. download — upstream GitHub release archive (only when `downloadIfMissing`
|
|
7
|
+
* is passed) Returns `undefined` if all of the enabled sources miss.
|
|
8
|
+
* Memoized per option-shape.
|
|
9
|
+
*/
|
|
10
|
+
import type { BinaryDownloader } from '../from-download';
|
|
11
|
+
import type { HashSpec } from '../../integrity';
|
|
12
|
+
import type { ResolvedUv } from './types';
|
|
13
|
+
export interface ResolveUvOptions {
|
|
14
|
+
downloadIfMissing?: {
|
|
15
|
+
version: string;
|
|
16
|
+
platformArch: string;
|
|
17
|
+
integrity?: HashSpec | undefined;
|
|
18
|
+
cacheDir?: string | undefined;
|
|
19
|
+
downloader?: BinaryDownloader | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
}
|
|
22
|
+
export declare function cacheKey(options: ResolveUvOptions | undefined): string;
|
|
23
|
+
export declare function doResolveUv(options?: ResolveUvOptions | undefined): Promise<ResolvedUv | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
26
|
+
*/
|
|
27
|
+
export declare function resetUvResolution(): void;
|
|
28
|
+
export declare function resolveUv(options?: ResolveUvOptions | undefined): Promise<ResolvedUv | undefined>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_primordials_map_set = require('../../primordials/map-set.js');
|
|
5
|
+
const require_external_tools_uv_from_download = require('./from-download.js');
|
|
6
|
+
const require_external_tools_uv_from_path = require('./from-path.js');
|
|
7
|
+
const require_external_tools_uv_from_vfs = require('./from-vfs.js');
|
|
8
|
+
|
|
9
|
+
//#region src/external-tools/uv/resolve.ts
|
|
10
|
+
/**
|
|
11
|
+
* @file `resolveUv()` — uv resolution entry point. Tries each source in order:
|
|
12
|
+
*
|
|
13
|
+
* 1. VFS — smol binary's embedded uv (if packed)
|
|
14
|
+
* 2. PATH — `uv` on the system PATH
|
|
15
|
+
* 3. download — upstream GitHub release archive (only when `downloadIfMissing`
|
|
16
|
+
* is passed) Returns `undefined` if all of the enabled sources miss.
|
|
17
|
+
* Memoized per option-shape.
|
|
18
|
+
*/
|
|
19
|
+
const resolutionCache = new require_primordials_map_set.MapCtor();
|
|
20
|
+
function cacheKey(options) {
|
|
21
|
+
const opts = {
|
|
22
|
+
__proto__: null,
|
|
23
|
+
...options
|
|
24
|
+
};
|
|
25
|
+
if (!opts?.downloadIfMissing) return "local-only";
|
|
26
|
+
const { cacheDir, integrity, platformArch, version } = opts.downloadIfMissing;
|
|
27
|
+
return `dl:${version}:${platformArch}:${typeof integrity === "string" ? integrity : integrity ? `${integrity.type}:${integrity.value}` : ""}:${cacheDir ?? ""}`;
|
|
28
|
+
}
|
|
29
|
+
async function doResolveUv(options) {
|
|
30
|
+
const opts = {
|
|
31
|
+
__proto__: null,
|
|
32
|
+
...options
|
|
33
|
+
};
|
|
34
|
+
const fromVfs = await require_external_tools_uv_from_vfs.uvFromVfs();
|
|
35
|
+
/* c8 ignore start - smol Node binary only. */
|
|
36
|
+
if (fromVfs) return fromVfs;
|
|
37
|
+
/* c8 ignore stop */
|
|
38
|
+
const fromPath = await require_external_tools_uv_from_path.uvFromPath();
|
|
39
|
+
if (fromPath) return fromPath;
|
|
40
|
+
if (opts?.downloadIfMissing) return require_external_tools_uv_from_download.uvFromDownload(opts.downloadIfMissing);
|
|
41
|
+
}
|
|
42
|
+
/* c8 ignore start - test-only escape hatch. */
|
|
43
|
+
/**
|
|
44
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
45
|
+
*/
|
|
46
|
+
function resetUvResolution() {
|
|
47
|
+
resolutionCache.clear();
|
|
48
|
+
}
|
|
49
|
+
/* c8 ignore stop */
|
|
50
|
+
function resolveUv(options) {
|
|
51
|
+
const key = cacheKey(options);
|
|
52
|
+
let cached = resolutionCache.get(key);
|
|
53
|
+
if (!cached) {
|
|
54
|
+
cached = doResolveUv(options);
|
|
55
|
+
resolutionCache.set(key, cached);
|
|
56
|
+
}
|
|
57
|
+
return cached;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.cacheKey = cacheKey;
|
|
62
|
+
exports.doResolveUv = doResolveUv;
|
|
63
|
+
exports.resetUvResolution = resetUvResolution;
|
|
64
|
+
exports.resolveUv = resolveUv;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Shared types for uv resolution. uv is Astral's Python package manager
|
|
3
|
+
* used by socket-basics for Python project bootstrap. Ships per-platform
|
|
4
|
+
* archives that wrap the `uv` binary one level deep.
|
|
5
|
+
*/
|
|
6
|
+
import type { ResolvedToolIntegrity } from '../from-download';
|
|
7
|
+
export type UvSource = 'download' | 'path' | 'vfs';
|
|
8
|
+
/**
|
|
9
|
+
* A resolved uv installation.
|
|
10
|
+
*/
|
|
11
|
+
export interface ResolvedUv {
|
|
12
|
+
/**
|
|
13
|
+
* Absolute path to the `uv` executable.
|
|
14
|
+
*/
|
|
15
|
+
readonly path: string;
|
|
16
|
+
/**
|
|
17
|
+
* Which resolver tier found this.
|
|
18
|
+
*/
|
|
19
|
+
readonly source: UvSource;
|
|
20
|
+
/**
|
|
21
|
+
* See {@link ResolvedToolIntegrity}.
|
|
22
|
+
*/
|
|
23
|
+
readonly integrity?: ResolvedToolIntegrity | undefined;
|
|
24
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Fleet-convention config reader: a per-repo override (`.config/repo`)
|
|
3
|
+
* layered over the cascaded fleet default (`.config/fleet`). A thin wrapper
|
|
4
|
+
* over the generic `config/layers` reader that returns the named `{ fleet,
|
|
5
|
+
* repo }` shape Socket callers use, plus the `{ fleet, repo }` array-merge
|
|
6
|
+
* convenience. The generic, convention-agnostic primitives
|
|
7
|
+
* (`readConfigLayers`, `mergeConfigArray`) live in `config/layers`. Lives in
|
|
8
|
+
* the published lib because it is the only import root the
|
|
9
|
+
* `.git-hooks/_shared` and `.claude/hooks/_shared` trees (which do not
|
|
10
|
+
* cross-import) plus `.config/*` can all reach.
|
|
11
|
+
*/
|
|
12
|
+
export declare const FLEET_LAYER_DIRS: readonly string[];
|
|
13
|
+
export interface RepoConfigTiers<T> {
|
|
14
|
+
fleet: T | undefined;
|
|
15
|
+
repo: T | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface ResolveRepoConfigOptions {
|
|
18
|
+
repoRoot?: string | undefined;
|
|
19
|
+
cwd?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Concatenate one array-valued key across the fleet + repo tiers. Fleet entries
|
|
23
|
+
* first, then repo entries. Convenience over `mergeConfigArray` for the `{
|
|
24
|
+
* fleet, repo }` shape.
|
|
25
|
+
*
|
|
26
|
+
* @param tiers - The `{ fleet, repo }` from `resolveRepoConfig`.
|
|
27
|
+
* @param key - The array-valued property to concatenate.
|
|
28
|
+
*
|
|
29
|
+
* @returns Fleet entries followed by repo entries; `[]` when neither is an
|
|
30
|
+
* array.
|
|
31
|
+
*
|
|
32
|
+
* @unused No internal or Socket consumers.
|
|
33
|
+
*/
|
|
34
|
+
export declare function mergeRepoConfigArray<T extends Record<string, unknown>, K extends keyof T>(tiers: RepoConfigTiers<T>, key: K): Array<T[K] extends Array<infer E> ? E : never>;
|
|
35
|
+
/**
|
|
36
|
+
* Fleet-convention reader: a repo override (`.config/repo`) layered over the
|
|
37
|
+
* cascaded fleet default (`.config/fleet`). A thin wrapper over
|
|
38
|
+
* `readConfigLayers` that returns the named `{ fleet, repo }` shape callers
|
|
39
|
+
* already use; either tier is `undefined` when absent or unparseable.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ;```typescript
|
|
43
|
+
* const { fleet, repo } = resolveRepoConfig<VitestTiers>('vitest')
|
|
44
|
+
* const nonIsolated = [
|
|
45
|
+
* ...(fleet?.nonIsolated ?? []),
|
|
46
|
+
* ...(repo?.nonIsolated ?? []),
|
|
47
|
+
* ]
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param name - Base name of the config file (no directory, no `.json`).
|
|
51
|
+
* @param options - `repoRoot` / `cwd` for path resolution.
|
|
52
|
+
*
|
|
53
|
+
* @returns `{ fleet, repo }` parsed tiers; either may be `undefined`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveRepoConfig<T = unknown>(name: string, options?: ResolveRepoConfigOptions | undefined): RepoConfigTiers<T>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_config_layers = require('../config/layers.js');
|
|
5
|
+
|
|
6
|
+
//#region src/fleet/repo-config.ts
|
|
7
|
+
/**
|
|
8
|
+
* @file Fleet-convention config reader: a per-repo override (`.config/repo`)
|
|
9
|
+
* layered over the cascaded fleet default (`.config/fleet`). A thin wrapper
|
|
10
|
+
* over the generic `config/layers` reader that returns the named `{ fleet,
|
|
11
|
+
* repo }` shape Socket callers use, plus the `{ fleet, repo }` array-merge
|
|
12
|
+
* convenience. The generic, convention-agnostic primitives
|
|
13
|
+
* (`readConfigLayers`, `mergeConfigArray`) live in `config/layers`. Lives in
|
|
14
|
+
* the published lib because it is the only import root the
|
|
15
|
+
* `.git-hooks/_shared` and `.claude/hooks/_shared` trees (which do not
|
|
16
|
+
* cross-import) plus `.config/*` can all reach.
|
|
17
|
+
*/
|
|
18
|
+
const FLEET_LAYER_DIRS = [".config/fleet", ".config/repo"];
|
|
19
|
+
/**
|
|
20
|
+
* Concatenate one array-valued key across the fleet + repo tiers. Fleet entries
|
|
21
|
+
* first, then repo entries. Convenience over `mergeConfigArray` for the `{
|
|
22
|
+
* fleet, repo }` shape.
|
|
23
|
+
*
|
|
24
|
+
* @param tiers - The `{ fleet, repo }` from `resolveRepoConfig`.
|
|
25
|
+
* @param key - The array-valued property to concatenate.
|
|
26
|
+
*
|
|
27
|
+
* @returns Fleet entries followed by repo entries; `[]` when neither is an
|
|
28
|
+
* array.
|
|
29
|
+
*
|
|
30
|
+
* @unused No internal or Socket consumers.
|
|
31
|
+
*/
|
|
32
|
+
function mergeRepoConfigArray(tiers, key) {
|
|
33
|
+
return require_config_layers.mergeConfigArray([tiers.fleet, tiers.repo], key);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Fleet-convention reader: a repo override (`.config/repo`) layered over the
|
|
37
|
+
* cascaded fleet default (`.config/fleet`). A thin wrapper over
|
|
38
|
+
* `readConfigLayers` that returns the named `{ fleet, repo }` shape callers
|
|
39
|
+
* already use; either tier is `undefined` when absent or unparseable.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ;```typescript
|
|
43
|
+
* const { fleet, repo } = resolveRepoConfig<VitestTiers>('vitest')
|
|
44
|
+
* const nonIsolated = [
|
|
45
|
+
* ...(fleet?.nonIsolated ?? []),
|
|
46
|
+
* ...(repo?.nonIsolated ?? []),
|
|
47
|
+
* ]
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param name - Base name of the config file (no directory, no `.json`).
|
|
51
|
+
* @param options - `repoRoot` / `cwd` for path resolution.
|
|
52
|
+
*
|
|
53
|
+
* @returns `{ fleet, repo }` parsed tiers; either may be `undefined`.
|
|
54
|
+
*/
|
|
55
|
+
function resolveRepoConfig(name, options) {
|
|
56
|
+
const opts = {
|
|
57
|
+
__proto__: null,
|
|
58
|
+
...options
|
|
59
|
+
};
|
|
60
|
+
const base = {
|
|
61
|
+
cwd: opts.cwd,
|
|
62
|
+
rootDir: opts.repoRoot
|
|
63
|
+
};
|
|
64
|
+
const [fleet] = require_config_layers.readConfigLayers(name, {
|
|
65
|
+
...base,
|
|
66
|
+
dirs: [FLEET_LAYER_DIRS[0]]
|
|
67
|
+
});
|
|
68
|
+
const [repo] = require_config_layers.readConfigLayers(name, {
|
|
69
|
+
...base,
|
|
70
|
+
dirs: [FLEET_LAYER_DIRS[1]]
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
fleet,
|
|
74
|
+
repo
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
exports.FLEET_LAYER_DIRS = FLEET_LAYER_DIRS;
|
|
80
|
+
exports.mergeRepoConfigArray = mergeRepoConfigArray;
|
|
81
|
+
exports.resolveRepoConfig = resolveRepoConfig;
|
package/dist/fs/_internal.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @file Private state shared between `fs/safe` and `fs/path-cache`. The `_`
|
|
3
3
|
* prefix keeps this module out of the generated package.json `exports` map
|
|
4
4
|
* (the `dist/**\/_*` ignore pattern in
|
|
5
|
-
* `scripts/
|
|
5
|
+
* `scripts/fleet/make-package-exports.mts` filters it out), so it is not
|
|
6
6
|
* part of the public surface — it exists only to give the two leaves above a
|
|
7
7
|
* common owner for the allowed-directory cache. The cache is invalidated by
|
|
8
8
|
* `invalidatePathCache()` in `fs/path-cache.ts` whenever paths are rewired in
|
package/dist/fs/_internal.js
CHANGED
|
@@ -9,7 +9,7 @@ const require_paths_socket = require('../paths/socket.js');
|
|
|
9
9
|
* @file Private state shared between `fs/safe` and `fs/path-cache`. The `_`
|
|
10
10
|
* prefix keeps this module out of the generated package.json `exports` map
|
|
11
11
|
* (the `dist/**\/_*` ignore pattern in
|
|
12
|
-
* `scripts/
|
|
12
|
+
* `scripts/fleet/make-package-exports.mts` filters it out), so it is not
|
|
13
13
|
* part of the public surface — it exists only to give the two leaves above a
|
|
14
14
|
* common owner for the allowed-directory cache. The cache is invalidated by
|
|
15
15
|
* `invalidatePathCache()` in `fs/path-cache.ts` whenever paths are rewired in
|
package/dist/fs/access.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ import type { PathLike } from 'node:fs';
|
|
|
20
20
|
export declare function canAccess(path: PathLike, mode?: number | undefined): boolean;
|
|
21
21
|
/**
|
|
22
22
|
* Can the process execute `path`? (`X_OK`)
|
|
23
|
+
*
|
|
24
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
23
25
|
*/
|
|
24
26
|
export declare function canExecute(path: PathLike): boolean;
|
|
25
27
|
/**
|
package/dist/fs/access.js
CHANGED
|
@@ -38,6 +38,8 @@ function canAccess(path, mode) {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Can the process execute `path`? (`X_OK`)
|
|
41
|
+
*
|
|
42
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
41
43
|
*/
|
|
42
44
|
function canExecute(path) {
|
|
43
45
|
return canAccess(path, require_node_fs.getNodeFs().constants.X_OK);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Recursive copy for a file or directory tree, with three destination
|
|
3
|
+
* modes (see {@link CopyMode}). Plain `fs.cp` (even with `force`) overwrites
|
|
4
|
+
* files present in the source but never deletes destination files absent from
|
|
5
|
+
* it, so copying onto an existing target leaves stale leftovers behind. The
|
|
6
|
+
* `'pave'` mode makes the destination an exact copy of the source by staging
|
|
7
|
+
* a fresh tree in a sibling temp directory and swapping it in with a single
|
|
8
|
+
* rename — atomic, with no stale survivors.
|
|
9
|
+
*/
|
|
10
|
+
import type { PathLike } from 'node:fs';
|
|
11
|
+
/**
|
|
12
|
+
* Named values for {@link CopyMode}. A frozen object rather than a TypeScript
|
|
13
|
+
* `enum` so the declaration is erasable (enums emit runtime helper code).
|
|
14
|
+
*/
|
|
15
|
+
export declare const CopyMode: Readonly<{
|
|
16
|
+
readonly Fill: 'fill';
|
|
17
|
+
readonly Overlay: 'overlay';
|
|
18
|
+
readonly Pave: 'pave';
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* How {@link copy} treats an existing destination.
|
|
22
|
+
*
|
|
23
|
+
* - `'overlay'` (default) — overwrite files present in the source but leave any
|
|
24
|
+
* pre-existing destination-only files in place (a recursive `fs.cp`).
|
|
25
|
+
* - `'pave'` — replace the destination so it becomes an exact copy of the source;
|
|
26
|
+
* destination entries absent from the source do not survive. The swap is
|
|
27
|
+
* atomic (a sibling temp directory is renamed into place), so a partial tree
|
|
28
|
+
* is never observable.
|
|
29
|
+
* - `'fill'` — copy only what the destination lacks: existing files stay
|
|
30
|
+
* untouched (no-clobber), missing ones are added. Never throws on an existing
|
|
31
|
+
* file.
|
|
32
|
+
*
|
|
33
|
+
* Maps to `cp` (overlay), `rsync --delete` / robocopy `/MIR` (pave), and
|
|
34
|
+
* `cp -n` (fill).
|
|
35
|
+
*/
|
|
36
|
+
export type CopyMode = (typeof CopyMode)[keyof typeof CopyMode];
|
|
37
|
+
/**
|
|
38
|
+
* Options for {@link copy}.
|
|
39
|
+
*/
|
|
40
|
+
export interface CopyOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Dereference symlinks — copy what each points to rather than the link
|
|
43
|
+
* itself.
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
dereference?: boolean | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Predicate deciding which entries to copy. Return `false` to skip an entry
|
|
50
|
+
* (and, for a directory, everything beneath it). Receives resolved source
|
|
51
|
+
* and destination paths, matching `node:fs` `cp`'s `filter`.
|
|
52
|
+
*/
|
|
53
|
+
filter?: ((source: string, destination: string) => boolean) | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* How to treat an existing destination. See {@link CopyMode}.
|
|
56
|
+
*
|
|
57
|
+
* @default 'overlay'
|
|
58
|
+
*/
|
|
59
|
+
mode?: CopyMode | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Abort signal to cancel the operation.
|
|
62
|
+
*/
|
|
63
|
+
signal?: AbortSignal | undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Recursively copy a file or directory tree from `from` to `to`.
|
|
67
|
+
*
|
|
68
|
+
* Works for both files and directories. The `mode` option chooses how an
|
|
69
|
+
* existing destination is treated — overlay (default), pave, or fill; see
|
|
70
|
+
* {@link CopyMode}.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ;```ts
|
|
74
|
+
* // Overlay (default) — overwrite collisions, keep files already in dest:
|
|
75
|
+
* await copy('./src', './dest')
|
|
76
|
+
*
|
|
77
|
+
* // Pave — dest ends up identical to src, no stale survivors:
|
|
78
|
+
* await copy('./vendor/upstream', './deps/upstream', { mode: CopyMode.Pave })
|
|
79
|
+
*
|
|
80
|
+
* // Fill — add only what's missing, never overwrite an existing file:
|
|
81
|
+
* await copy('./defaults', './config', { mode: CopyMode.Fill })
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param from - Source file or directory to copy.
|
|
85
|
+
* @param to - Destination path.
|
|
86
|
+
* @param options - Copy options (mode, filter, dereference, abort signal).
|
|
87
|
+
*/
|
|
88
|
+
export declare function copy(from: PathLike, to: PathLike, options?: CopyOptions | undefined): Promise<void>;
|
package/dist/fs/copy.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Socket Lib - Built with rolldown */
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_primordials_object = require('../primordials/object.js');
|
|
5
|
+
const require_paths__internal = require('../paths/_internal.js');
|
|
6
|
+
const require_node_fs = require('../node/fs.js');
|
|
7
|
+
const require_node_path = require('../node/path.js');
|
|
8
|
+
const require_fs_safe = require('./safe.js');
|
|
9
|
+
const require_fs_unique = require('./unique.js');
|
|
10
|
+
|
|
11
|
+
//#region src/fs/copy.ts
|
|
12
|
+
/**
|
|
13
|
+
* @file Recursive copy for a file or directory tree, with three destination
|
|
14
|
+
* modes (see {@link CopyMode}). Plain `fs.cp` (even with `force`) overwrites
|
|
15
|
+
* files present in the source but never deletes destination files absent from
|
|
16
|
+
* it, so copying onto an existing target leaves stale leftovers behind. The
|
|
17
|
+
* `'pave'` mode makes the destination an exact copy of the source by staging
|
|
18
|
+
* a fresh tree in a sibling temp directory and swapping it in with a single
|
|
19
|
+
* rename — atomic, with no stale survivors.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Named values for {@link CopyMode}. A frozen object rather than a TypeScript
|
|
23
|
+
* `enum` so the declaration is erasable (enums emit runtime helper code).
|
|
24
|
+
*/
|
|
25
|
+
const CopyMode = require_primordials_object.ObjectFreeze({
|
|
26
|
+
Fill: "fill",
|
|
27
|
+
Overlay: "overlay",
|
|
28
|
+
Pave: "pave"
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Recursively copy a file or directory tree from `from` to `to`.
|
|
32
|
+
*
|
|
33
|
+
* Works for both files and directories. The `mode` option chooses how an
|
|
34
|
+
* existing destination is treated — overlay (default), pave, or fill; see
|
|
35
|
+
* {@link CopyMode}.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ;```ts
|
|
39
|
+
* // Overlay (default) — overwrite collisions, keep files already in dest:
|
|
40
|
+
* await copy('./src', './dest')
|
|
41
|
+
*
|
|
42
|
+
* // Pave — dest ends up identical to src, no stale survivors:
|
|
43
|
+
* await copy('./vendor/upstream', './deps/upstream', { mode: CopyMode.Pave })
|
|
44
|
+
*
|
|
45
|
+
* // Fill — add only what's missing, never overwrite an existing file:
|
|
46
|
+
* await copy('./defaults', './config', { mode: CopyMode.Fill })
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param from - Source file or directory to copy.
|
|
50
|
+
* @param to - Destination path.
|
|
51
|
+
* @param options - Copy options (mode, filter, dereference, abort signal).
|
|
52
|
+
*/
|
|
53
|
+
async function copy(from, to, options) {
|
|
54
|
+
const fs = require_node_fs.getNodeFs();
|
|
55
|
+
const opts = {
|
|
56
|
+
__proto__: null,
|
|
57
|
+
...options
|
|
58
|
+
};
|
|
59
|
+
const { mode } = opts;
|
|
60
|
+
const fromStr = require_paths__internal.pathLikeToString(from);
|
|
61
|
+
const toStr = require_paths__internal.pathLikeToString(to);
|
|
62
|
+
const cpOptions = {
|
|
63
|
+
__proto__: null,
|
|
64
|
+
dereference: opts.dereference === true,
|
|
65
|
+
force: mode !== CopyMode.Fill,
|
|
66
|
+
recursive: true,
|
|
67
|
+
...opts.filter ? { filter: opts.filter } : {}
|
|
68
|
+
};
|
|
69
|
+
if (mode !== CopyMode.Pave) {
|
|
70
|
+
await fs.promises.cp(fromStr, toStr, cpOptions);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const path = require_node_path.getNodePath();
|
|
74
|
+
const tmp = require_fs_unique.uniqueSync(`${toStr}.tmp`);
|
|
75
|
+
try {
|
|
76
|
+
await fs.promises.cp(fromStr, tmp, cpOptions);
|
|
77
|
+
await require_fs_safe.safeMkdir(path.dirname(toStr));
|
|
78
|
+
await require_fs_safe.safeDelete(toStr, { signal: opts.signal });
|
|
79
|
+
await fs.promises.rename(tmp, toStr);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
/* c8 ignore start - best-effort cleanup of the staged copy on failure */
|
|
82
|
+
await require_fs_safe.safeDelete(tmp, { signal: opts.signal });
|
|
83
|
+
throw e;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
exports.CopyMode = CopyMode;
|
|
89
|
+
exports.copy = copy;
|
package/dist/fs/find.js
CHANGED
|
@@ -20,7 +20,6 @@ node_process = require_runtime.__toESM(node_process);
|
|
|
20
20
|
* visiting root itself, so a match at e.g. `/.foo` was never found. The
|
|
21
21
|
* current shape visits root, then breaks.
|
|
22
22
|
*/
|
|
23
|
-
const abortSignal = require_process_abort.getAbortSignal();
|
|
24
23
|
/**
|
|
25
24
|
* Find a file or directory by traversing up parent directories. Searches from
|
|
26
25
|
* the starting directory upward to the filesystem root. Useful for finding
|
|
@@ -44,7 +43,7 @@ const abortSignal = require_process_abort.getAbortSignal();
|
|
|
44
43
|
* @returns Normalized absolute path if found, undefined otherwise
|
|
45
44
|
*/
|
|
46
45
|
async function findUp(name, options) {
|
|
47
|
-
const { cwd = node_process.default.cwd(), signal =
|
|
46
|
+
const { cwd = node_process.default.cwd(), signal = require_process_abort.getAbortSignal() } = {
|
|
48
47
|
__proto__: null,
|
|
49
48
|
...options
|
|
50
49
|
};
|
package/dist/fs/inspect.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export declare function isSymlinkSync(filepath: PathLike): boolean;
|
|
|
94
94
|
*
|
|
95
95
|
* @returns Promise resolving to Stats object, or undefined on error
|
|
96
96
|
*/
|
|
97
|
-
export declare function safeStat(filepath: PathLike): Promise<import("fs").Stats | undefined>;
|
|
97
|
+
export declare function safeStat(filepath: PathLike): Promise<import("node:fs").Stats | undefined>;
|
|
98
98
|
/**
|
|
99
99
|
* Safely get file stats synchronously, returning undefined on error. Useful for
|
|
100
100
|
* checking file existence and properties without error handling. Returns
|
|
@@ -114,4 +114,4 @@ export declare function safeStat(filepath: PathLike): Promise<import("fs").Stats
|
|
|
114
114
|
*
|
|
115
115
|
* @returns Stats object, or undefined on error
|
|
116
116
|
*/
|
|
117
|
-
export declare function safeStatSync(filepath: PathLike): import("fs").BigIntStats | import("fs").Stats | undefined;
|
|
117
|
+
export declare function safeStatSync(filepath: PathLike): import("node:fs").BigIntStats | import("node:fs").Stats | undefined;
|
package/dist/fs/read-file.js
CHANGED
|
@@ -15,7 +15,6 @@ const require_fs_encoding = require('./encoding.js');
|
|
|
15
15
|
* the default and any string encoding return a string. The runtime fast-path
|
|
16
16
|
* normalizes encoding once and forwards untouched options to `node:fs`.
|
|
17
17
|
*/
|
|
18
|
-
const abortSignal = require_process_abort.getAbortSignal();
|
|
19
18
|
/**
|
|
20
19
|
* Read a file as binary data asynchronously. Returns a Buffer without encoding
|
|
21
20
|
* the contents. Useful for reading images, archives, or other binary formats.
|
|
@@ -37,7 +36,7 @@ const abortSignal = require_process_abort.getAbortSignal();
|
|
|
37
36
|
async function readFileBinary(filepath, options) {
|
|
38
37
|
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
39
38
|
return await require_node_fs.getNodeFs().promises.readFile(filepath, {
|
|
40
|
-
signal:
|
|
39
|
+
signal: require_process_abort.getAbortSignal(),
|
|
41
40
|
...opts,
|
|
42
41
|
encoding: void 0
|
|
43
42
|
});
|
|
@@ -88,7 +87,7 @@ function readFileBinarySync(filepath, options) {
|
|
|
88
87
|
async function readFileUtf8(filepath, options) {
|
|
89
88
|
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
90
89
|
return await require_node_fs.getNodeFs().promises.readFile(filepath, {
|
|
91
|
-
signal:
|
|
90
|
+
signal: require_process_abort.getAbortSignal(),
|
|
92
91
|
...opts,
|
|
93
92
|
encoding: "utf8"
|
|
94
93
|
});
|
|
@@ -138,7 +137,7 @@ async function safeReadFile(filepath, options) {
|
|
|
138
137
|
try {
|
|
139
138
|
return await fs.promises.readFile(filepath, {
|
|
140
139
|
__proto__: null,
|
|
141
|
-
signal:
|
|
140
|
+
signal: require_process_abort.getAbortSignal(),
|
|
142
141
|
...readOpts,
|
|
143
142
|
encoding
|
|
144
143
|
});
|