@socketsecurity/lib 6.0.6 → 6.0.8
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 +46 -1
- package/README.md +1 -1
- package/dist/ai/agent-context.d.mts +103 -0
- package/dist/ai/agent-context.js +157 -0
- package/dist/ai/backends.d.mts +83 -0
- package/dist/ai/backends.js +173 -0
- package/dist/ai/credentials.d.mts +49 -0
- package/dist/ai/credentials.js +82 -0
- package/dist/ai/discover.d.mts +6 -2
- package/dist/ai/discover.js +4 -3
- package/dist/ai/exec.d.mts +52 -0
- package/dist/ai/exec.js +92 -0
- package/dist/ai/http.d.mts +132 -0
- package/dist/ai/http.js +130 -0
- package/dist/ai/profiles.d.mts +41 -6
- package/dist/ai/profiles.js +52 -10
- package/dist/ai/route.d.mts +69 -0
- package/dist/ai/route.js +156 -0
- package/dist/ai/spawn.d.mts +10 -2
- package/dist/ai/spawn.js +56 -31
- package/dist/ai/subagent-status.d.mts +48 -0
- package/dist/ai/subagent-status.js +57 -0
- package/dist/ai/tier.d.mts +60 -0
- package/dist/ai/tier.js +53 -0
- package/dist/ai/types.d.mts +31 -6
- package/dist/ai/worktree.d.mts +6 -6
- package/dist/ai/worktree.js +5 -1
- package/dist/ansi/strip.d.ts +1 -1
- package/dist/ansi/strip.js +0 -2
- package/dist/archives/_internal.js +7 -9
- package/dist/archives/extract.js +1 -1
- package/dist/archives/tar.js +7 -7
- package/dist/archives/zip.js +5 -7
- package/dist/argv/flag-predicates.d.ts +12 -12
- package/dist/argv/flag-predicates.js +17 -17
- package/dist/argv/flag-types.d.ts +18 -18
- package/dist/argv/flag-types.js +4 -4
- package/dist/argv/parse.d.ts +20 -3
- package/dist/argv/parse.js +1 -1
- package/dist/arrays/_internal.js +11 -12
- package/dist/arrays/chunk.js +0 -1
- package/dist/arrays/join.d.ts +37 -3
- package/dist/arrays/join.js +47 -7
- package/dist/arrays/unique.js +0 -1
- package/dist/bin/_internal.d.ts +1 -1
- package/dist/bin/_internal.js +1 -1
- package/dist/bin/exec.js +2 -3
- package/dist/bin/find.js +17 -17
- package/dist/bin/prim.cjs +36175 -35861
- package/dist/bin/resolve.js +13 -14
- package/dist/bin/which.js +8 -8
- package/dist/cache/ttl/store.js +6 -6
- package/dist/checks/primordials-defaults.d.ts +3 -3
- package/dist/checks/primordials-defaults.js +3 -3
- package/dist/checks/primordials.js +4 -3
- package/dist/{bin → cli}/check-primordials.d.ts +18 -13
- package/dist/{bin → cli}/check-primordials.js +58 -55
- package/dist/{bin → cli}/check.js +3 -3
- package/dist/{bin → cli}/socket-lib.d.ts +1 -1
- package/dist/{bin → cli}/socket-lib.js +4 -4
- package/dist/colors/socket-palette.js +7 -9
- package/dist/compression/_internal.d.ts +12 -12
- package/dist/compression/_internal.js +18 -18
- package/dist/compression/brotli.d.ts +26 -27
- package/dist/compression/brotli.js +39 -35
- package/dist/compression/gzip.d.ts +23 -23
- package/dist/compression/gzip.js +46 -42
- package/dist/constants/agents.d.ts +3 -1
- package/dist/constants/agents.js +15 -11
- package/dist/constants/licenses.js +3 -3
- package/dist/constants/node.d.ts +23 -0
- package/dist/constants/node.js +47 -15
- package/dist/constants/packages.d.ts +3 -0
- package/dist/constants/packages.js +24 -29
- package/dist/constants/platform.d.ts +30 -3
- package/dist/constants/platform.js +72 -12
- package/dist/constants/runtime.d.ts +22 -0
- package/dist/constants/runtime.js +32 -0
- package/dist/constants/socket.d.ts +2 -6
- package/dist/constants/socket.js +12 -14
- package/dist/cover/code.js +10 -10
- package/dist/cover/formatters.js +5 -5
- package/dist/crypto/hash.d.ts +30 -2
- package/dist/crypto/hash.js +47 -13
- package/dist/debug/_internal.js +4 -6
- package/dist/debug/caller-info.js +3 -4
- package/dist/debug/namespace.d.ts +7 -0
- package/dist/debug/namespace.js +21 -12
- package/dist/debug/output.js +21 -24
- package/dist/debug/types.d.ts +4 -4
- package/dist/dlx/arborist.js +18 -8
- package/dist/dlx/binary-cache.js +15 -15
- package/dist/dlx/binary-download.d.ts +1 -1
- package/dist/dlx/binary-download.js +11 -11
- package/dist/dlx/binary-resolution.js +17 -15
- package/dist/dlx/binary-types.d.ts +5 -5
- package/dist/dlx/binary.js +5 -5
- package/dist/dlx/cache.js +1 -1
- package/dist/dlx/detect.d.ts +42 -25
- package/dist/dlx/detect.js +86 -77
- package/dist/dlx/dir.js +2 -2
- package/dist/dlx/firewall.d.ts +9 -1
- package/dist/dlx/firewall.js +1 -1
- package/dist/dlx/lockfile.d.ts +19 -18
- package/dist/dlx/lockfile.js +19 -16
- package/dist/dlx/manifest.d.ts +6 -6
- package/dist/dlx/manifest.js +5 -5
- package/dist/dlx/package.d.ts +10 -10
- package/dist/dlx/package.js +20 -16
- package/dist/dlx/packages.js +4 -4
- package/dist/dlx/paths.js +7 -7
- package/dist/dlx/spec.js +1 -1
- package/dist/dlx/types.d.ts +28 -27
- package/dist/eco/cargo/parse-lockfile.d.ts +2 -3
- package/dist/eco/cargo/parse-lockfile.js +5 -5
- package/dist/eco/manifest/analyze-lockfile.js +2 -2
- package/dist/eco/manifest/detect-format.js +5 -5
- package/dist/eco/manifest/find-packages.js +2 -2
- package/dist/eco/manifest/get-package-versions.js +2 -2
- package/dist/eco/manifest/get-package.js +2 -2
- package/dist/eco/manifest/parse-lockfile.js +2 -2
- package/dist/eco/manifest/parse-manifest.js +2 -2
- package/dist/eco/manifest/parse.js +2 -2
- package/dist/eco/npm/npm/exec.js +2 -2
- package/dist/eco/npm/npm/flags.js +7 -12
- package/dist/eco/npm/npm/parse-lockfile.d.ts +17 -18
- package/dist/eco/npm/npm/parse-lockfile.js +4 -4
- package/dist/eco/npm/parse-package-json.d.ts +11 -0
- package/dist/eco/npm/parse-package-json.js +3 -3
- package/dist/eco/npm/pnpm/exec.d.ts +1 -1
- package/dist/eco/npm/pnpm/exec.js +5 -5
- package/dist/eco/npm/pnpm/flags.js +0 -3
- package/dist/eco/npm/pnpm/parse-lockfile.d.ts +6 -4
- package/dist/eco/npm/pnpm/parse-lockfile.js +7 -7
- package/dist/eco/npm/script.js +9 -6
- package/dist/eco/npm/yarnpkg/yarn/exec.js +4 -4
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.d.ts +3 -4
- package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +9 -9
- package/dist/effects/pulse-frames.d.ts +3 -1
- package/dist/effects/shimmer-keyframes.d.ts +1 -1
- package/dist/effects/shimmer-terminal.d.ts +1 -1
- package/dist/env/boolean.js +0 -1
- package/dist/env/ci.js +0 -1
- package/dist/env/debug.js +0 -1
- package/dist/env/github-status.d.ts +51 -0
- package/dist/env/github-status.js +90 -0
- package/dist/env/github.js +0 -8
- package/dist/env/home.js +0 -1
- package/dist/env/locale.js +0 -3
- package/dist/env/node-auth-token.js +0 -1
- package/dist/env/node-env.js +0 -1
- package/dist/env/node-version-managers.d.ts +53 -0
- package/dist/env/node-version-managers.js +90 -0
- package/dist/env/npm.js +0 -5
- package/dist/env/number.js +0 -1
- package/dist/env/package-manager.js +3 -6
- package/dist/env/path.js +0 -1
- package/dist/env/pre-commit.js +1 -2
- package/dist/env/proxy.js +1 -1
- package/dist/env/rewire.d.ts +8 -6
- package/dist/env/rewire.js +16 -17
- package/dist/env/shell.js +0 -1
- package/dist/env/socket-cli.js +5 -18
- package/dist/env/socket-mcp.d.ts +114 -0
- package/dist/env/socket-mcp.js +146 -0
- package/dist/env/socket.d.ts +8 -109
- package/dist/env/socket.js +22 -167
- package/dist/env/string.js +0 -1
- package/dist/env/temp-dir.js +0 -3
- package/dist/env/term.js +0 -1
- package/dist/env/test.js +3 -6
- package/dist/env/windows.js +0 -4
- package/dist/env/xdg.js +0 -3
- package/dist/errors/predicates.js +1 -1
- package/dist/events/exit/_internal.d.ts +11 -9
- package/dist/events/exit/_internal.js +31 -35
- package/dist/events/exit/handler.js +3 -4
- package/dist/events/exit/intercept.js +4 -6
- package/dist/events/exit/lifecycle.js +16 -18
- package/dist/events/exit/signals.js +1 -2
- package/dist/events/exit/types.d.ts +6 -5
- package/dist/external/@npmcli/package-json.js +2 -2
- package/dist/external/@npmcli/promise-spawn.js +3 -1
- package/dist/external/npm-pack.js +2 -2
- package/dist/external/pico-pack.js +4 -2
- package/dist/external/which.js +3 -1
- package/dist/external-tools/bazel/asset-names.d.ts +1 -1
- package/dist/external-tools/bazel/asset-names.js +5 -2
- package/dist/external-tools/bazel/from-download.d.ts +1 -1
- package/dist/external-tools/bazel/from-download.js +5 -2
- package/dist/external-tools/bazel/read-bazel-version-file.js +1 -1
- package/dist/external-tools/bazel/resolve-bazel-version.js +4 -0
- package/dist/external-tools/bazel/resolve.d.ts +3 -3
- package/dist/external-tools/bazel/resolve.js +16 -8
- package/dist/external-tools/bazel/types.d.ts +1 -1
- package/dist/external-tools/cdxgen/asset-names.d.ts +1 -1
- package/dist/external-tools/cdxgen/asset-names.js +5 -2
- package/dist/external-tools/cdxgen/from-download.d.ts +1 -1
- package/dist/external-tools/cdxgen/from-download.js +7 -4
- package/dist/external-tools/cdxgen/from-vfs.js +1 -1
- package/dist/external-tools/cdxgen/resolve.d.ts +3 -3
- package/dist/external-tools/cdxgen/resolve.js +16 -8
- package/dist/external-tools/cdxgen/types.d.ts +1 -1
- package/dist/external-tools/from-download.d.ts +3 -3
- package/dist/external-tools/from-download.js +12 -6
- package/dist/external-tools/from-pip-venv.d.ts +1 -1
- package/dist/external-tools/from-pip-venv.js +12 -5
- package/dist/external-tools/janus/asset-names.d.ts +1 -1
- package/dist/external-tools/janus/asset-names.js +5 -2
- package/dist/external-tools/janus/from-download.d.ts +1 -1
- package/dist/external-tools/janus/from-download.js +5 -2
- package/dist/external-tools/janus/from-vfs.js +1 -1
- package/dist/external-tools/janus/resolve.d.ts +3 -3
- package/dist/external-tools/janus/resolve.js +16 -8
- package/dist/external-tools/janus/types.d.ts +1 -1
- package/dist/external-tools/jre/asset-names.d.ts +1 -1
- package/dist/external-tools/jre/asset-names.js +5 -2
- package/dist/external-tools/jre/detect-platform-arch.d.ts +10 -6
- package/dist/external-tools/jre/detect-platform-arch.js +29 -14
- package/dist/external-tools/jre/from-download.d.ts +1 -1
- package/dist/external-tools/jre/from-download.js +7 -4
- package/dist/external-tools/jre/from-java-home.js +2 -2
- package/dist/external-tools/jre/from-vfs.js +3 -3
- package/dist/external-tools/jre/resolve.d.ts +3 -3
- package/dist/external-tools/jre/resolve.js +16 -8
- package/dist/external-tools/jre/types.d.ts +1 -1
- package/dist/external-tools/manifest.d.ts +25 -7
- package/dist/external-tools/manifest.js +13 -13
- package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
- package/dist/external-tools/opengrep/asset-names.js +5 -2
- package/dist/external-tools/opengrep/from-download.d.ts +1 -1
- package/dist/external-tools/opengrep/from-download.js +5 -2
- package/dist/external-tools/opengrep/from-vfs.js +1 -1
- package/dist/external-tools/opengrep/resolve.d.ts +3 -3
- package/dist/external-tools/opengrep/resolve.js +16 -8
- package/dist/external-tools/opengrep/types.d.ts +1 -1
- package/dist/external-tools/python/asset-names.d.ts +76 -0
- package/dist/external-tools/python/asset-names.js +111 -0
- package/dist/external-tools/python/dlx.d.ts +80 -0
- package/dist/external-tools/python/dlx.js +98 -0
- package/dist/external-tools/python/from-download.d.ts +53 -0
- package/dist/external-tools/python/from-download.js +75 -0
- package/dist/external-tools/python/from-path.d.ts +7 -0
- package/dist/external-tools/python/from-path.js +23 -0
- package/dist/external-tools/python/pin.d.ts +121 -0
- package/dist/external-tools/python/pin.js +176 -0
- package/dist/external-tools/python/pip-install.d.ts +75 -0
- package/dist/external-tools/python/pip-install.js +142 -0
- package/dist/external-tools/python/resolve.d.ts +42 -0
- package/dist/external-tools/python/resolve.js +66 -0
- package/dist/external-tools/python/types.d.ts +49 -0
- package/dist/external-tools/sbt/asset-names.d.ts +1 -1
- package/dist/external-tools/sbt/asset-names.js +5 -2
- package/dist/external-tools/sbt/from-download.d.ts +1 -1
- package/dist/external-tools/sbt/from-download.js +5 -2
- package/dist/external-tools/sbt/from-vfs.js +1 -1
- package/dist/external-tools/sbt/resolve.d.ts +3 -3
- package/dist/external-tools/sbt/resolve.js +16 -8
- package/dist/external-tools/sbt/types.d.ts +1 -1
- package/dist/external-tools/skillspector/from-dlx.d.ts +1 -1
- package/dist/external-tools/skillspector/from-dlx.js +10 -3
- package/dist/external-tools/skillspector/from-path.js +3 -5
- package/dist/external-tools/skillspector/from-vfs.js +1 -1
- package/dist/external-tools/skillspector/resolve.d.ts +2 -2
- package/dist/external-tools/skillspector/resolve.js +14 -6
- package/dist/external-tools/synp/asset-names.d.ts +1 -1
- package/dist/external-tools/synp/asset-names.js +6 -2
- package/dist/external-tools/synp/from-download.d.ts +1 -1
- package/dist/external-tools/synp/from-download.js +7 -4
- package/dist/external-tools/synp/from-vfs.js +1 -1
- package/dist/external-tools/synp/resolve.d.ts +3 -3
- package/dist/external-tools/synp/resolve.js +16 -8
- package/dist/external-tools/trivy/asset-names.d.ts +1 -1
- package/dist/external-tools/trivy/asset-names.js +5 -2
- package/dist/external-tools/trivy/from-download.d.ts +1 -1
- package/dist/external-tools/trivy/from-download.js +7 -4
- package/dist/external-tools/trivy/from-vfs.js +1 -1
- package/dist/external-tools/trivy/resolve.d.ts +3 -3
- package/dist/external-tools/trivy/resolve.js +16 -8
- package/dist/external-tools/trivy/types.d.ts +1 -1
- package/dist/external-tools/trufflehog/asset-names.d.ts +1 -1
- package/dist/external-tools/trufflehog/asset-names.js +5 -2
- package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
- package/dist/external-tools/trufflehog/from-download.js +7 -4
- package/dist/external-tools/trufflehog/from-vfs.js +1 -1
- package/dist/external-tools/trufflehog/resolve.d.ts +3 -3
- package/dist/external-tools/trufflehog/resolve.js +16 -8
- package/dist/external-tools/trufflehog/types.d.ts +1 -1
- package/dist/fs/_internal.d.ts +1 -1
- package/dist/fs/_internal.js +7 -7
- package/dist/fs/access.js +5 -9
- package/dist/fs/allowed-dirs-cache.d.ts +47 -0
- package/dist/fs/allowed-dirs-cache.js +69 -0
- package/dist/fs/encoding.js +5 -7
- package/dist/fs/{find-up.js → find.js} +12 -14
- package/dist/fs/inspect.js +7 -13
- package/dist/fs/read-dir.js +7 -10
- package/dist/fs/read-file.js +8 -14
- package/dist/fs/read-json-cache.d.ts +13 -4
- package/dist/fs/read-json-cache.js +9 -6
- package/dist/fs/read-json.js +4 -6
- package/dist/fs/resolve-module.js +7 -3
- package/dist/fs/safe.d.ts +1 -1
- package/dist/fs/safe.js +13 -14
- package/dist/fs/unique.js +4 -5
- package/dist/fs/validate.js +1 -2
- package/dist/fs/write-json.js +4 -5
- package/dist/git/_internal.js +11 -11
- package/dist/git/changed.js +4 -4
- package/dist/git/repo.js +5 -7
- package/dist/git/staged.js +12 -4
- package/dist/git/tracked.d.ts +84 -0
- package/dist/git/tracked.js +163 -0
- package/dist/git/unstaged.js +12 -4
- package/dist/github/ghsa.js +2 -2
- package/dist/github/refs-cache.d.ts +1 -1
- package/dist/github/refs-cache.js +5 -5
- package/dist/github/refs-graphql.js +4 -0
- package/dist/github/refs-rest.js +9 -5
- package/dist/github/refs.js +15 -10
- package/dist/github/{fetch.js → request.js} +13 -2
- package/dist/github/token.js +1 -1
- package/dist/github/types.d.ts +1 -1
- package/dist/globs/_internal.js +8 -10
- package/dist/globs/match.js +13 -7
- package/dist/globs/matcher.d.ts +3 -3
- package/dist/globs/matcher.js +16 -14
- package/dist/globs/stream.js +1 -2
- package/dist/globs/types.d.ts +24 -24
- package/dist/http-request/_internal.d.ts +1 -1
- package/dist/http-request/browser.js +10 -4
- package/dist/http-request/checksum-file.d.ts +55 -0
- package/dist/http-request/checksum-file.js +95 -0
- package/dist/http-request/download-types.d.ts +15 -23
- package/dist/http-request/download.js +3 -3
- package/dist/http-request/{browser-fetch.d.ts → fetch/browser.d.ts} +2 -2
- package/dist/http-request/{browser-fetch.js → fetch/browser.js} +4 -4
- package/dist/http-request/headers.js +1 -2
- package/dist/http-request/request-attempt.js +38 -34
- package/dist/http-request/request-types.d.ts +2 -2
- package/dist/http-request/request.js +1 -1
- package/dist/http-request/user-agent.js +4 -5
- package/dist/integrity.d.ts +92 -18
- package/dist/integrity.js +125 -30
- package/dist/ipc/directory.js +2 -2
- package/dist/ipc/paths.js +1 -1
- package/dist/ipc/write.js +1 -1
- package/dist/ipc-cli/get.js +12 -12
- package/dist/json/edit.js +51 -44
- package/dist/json/format.js +1 -1
- package/dist/json/parse.d.ts +1 -1
- package/dist/json/parse.js +3 -7
- package/dist/logger/_internal.d.ts +4 -4
- package/dist/logger/_internal.js +3 -3
- package/dist/logger/colors.js +4 -3
- package/dist/logger/console-methods.d.ts +132 -0
- package/dist/logger/console-methods.js +169 -0
- package/dist/logger/console.d.ts +12 -0
- package/dist/logger/console.js +42 -11
- package/dist/logger/indentation-methods.d.ts +81 -0
- package/dist/logger/indentation-methods.js +121 -0
- package/dist/logger/node.d.ts +16 -338
- package/dist/logger/node.js +75 -608
- package/dist/logger/options.d.ts +39 -0
- package/dist/logger/options.js +47 -0
- package/dist/logger/semantic-methods.d.ts +63 -0
- package/dist/logger/semantic-methods.js +108 -0
- package/dist/logger/stream-methods.d.ts +63 -0
- package/dist/logger/stream-methods.js +101 -0
- package/dist/logger/stream.d.ts +37 -0
- package/dist/logger/stream.js +42 -0
- package/dist/logger/symbols-builder.js +9 -9
- package/dist/logger/symbols.d.ts +2 -25
- package/dist/logger/symbols.js +53 -74
- package/dist/logger/types.d.ts +1 -1
- package/dist/memo/types.d.ts +6 -6
- package/dist/native-messaging/host.d.ts +20 -0
- package/dist/native-messaging/host.js +120 -0
- package/dist/native-messaging/index.d.ts +5 -0
- package/dist/native-messaging/index.js +22 -0
- package/dist/native-messaging/install.d.ts +60 -0
- package/dist/native-messaging/install.js +144 -0
- package/dist/native-messaging/rate-limit.d.ts +69 -0
- package/dist/native-messaging/rate-limit.js +119 -0
- package/dist/native-messaging/run.d.ts +10 -0
- package/dist/native-messaging/run.js +17 -0
- package/dist/node/async-hooks.js +4 -3
- package/dist/node/child-process.js +4 -3
- package/dist/node/crypto.js +4 -3
- package/dist/node/events.js +4 -3
- package/dist/node/fs-promises.js +4 -3
- package/dist/node/fs.d.ts +22 -6
- package/dist/node/fs.js +17 -3
- package/dist/node/http.js +4 -3
- package/dist/node/https.js +4 -3
- package/dist/node/module.js +10 -6
- package/dist/node/os.d.ts +10 -2
- package/dist/node/os.js +12 -4
- package/dist/node/path.d.ts +11 -2
- package/dist/node/path.js +18 -4
- package/dist/node/timers-promises.js +4 -3
- package/dist/node/url.js +4 -3
- package/dist/node/util.js +4 -3
- package/dist/objects/getters.js +6 -8
- package/dist/objects/inspect.js +1 -4
- package/dist/objects/mutate.js +4 -5
- package/dist/objects/predicates.js +1 -5
- package/dist/objects/sort.js +3 -7
- package/dist/packages/edit-class.d.ts +2 -3
- package/dist/packages/edit-class.js +53 -48
- package/dist/packages/edit.js +12 -14
- package/dist/packages/exports.js +15 -21
- package/dist/packages/fetch.d.ts +16 -0
- package/dist/packages/fetch.js +81 -0
- package/dist/packages/find.d.ts +55 -0
- package/dist/packages/find.js +65 -0
- package/dist/packages/isolation.js +14 -14
- package/dist/packages/licenses.js +18 -18
- package/dist/packages/manifest.js +16 -19
- package/dist/packages/metadata-extensions.d.ts +14 -0
- package/dist/packages/metadata-extensions.js +43 -0
- package/dist/packages/normalize.js +6 -10
- package/dist/packages/provenance.js +17 -19
- package/dist/packages/read.d.ts +29 -0
- package/dist/packages/read.js +66 -0
- package/dist/packages/specs.d.ts +48 -1
- package/dist/packages/specs.js +75 -12
- package/dist/packages/tarball.d.ts +24 -0
- package/dist/packages/tarball.js +81 -0
- package/dist/packages/types.d.ts +22 -22
- package/dist/packages/validation.js +0 -3
- package/dist/paths/_internal.d.ts +2 -1
- package/dist/paths/_internal.js +7 -19
- package/dist/paths/conversion.js +5 -9
- package/dist/paths/dirnames.d.ts +1 -0
- package/dist/paths/dirnames.js +2 -0
- package/dist/paths/filenames.d.ts +0 -1
- package/dist/paths/filenames.js +0 -2
- package/dist/paths/normalize.js +4 -5
- package/dist/paths/packages.js +4 -7
- package/dist/paths/predicates.js +9 -16
- package/dist/paths/resolve.js +17 -25
- package/dist/paths/rewire.d.ts +5 -0
- package/dist/paths/rewire.js +3 -3
- package/dist/paths/socket.d.ts +74 -111
- package/dist/paths/socket.js +106 -139
- package/dist/paths/walk.d.ts +1 -1
- package/dist/paths/walk.js +4 -4
- package/dist/perf/report.js +2 -2
- package/dist/perf/types.d.ts +1 -1
- package/dist/pkg-ext/data.js +1 -1
- package/dist/primordials/array.js +9 -9
- package/dist/primordials/date.js +2 -2
- package/dist/primordials/error.js +3 -3
- package/dist/primordials/headers.d.ts +10 -0
- package/dist/primordials/headers.js +23 -0
- package/dist/primordials/intl.d.ts +13 -0
- package/dist/primordials/intl.js +26 -0
- package/dist/primordials/math.js +33 -33
- package/dist/primordials/number.js +9 -9
- package/dist/primordials/object.js +5 -5
- package/dist/primordials/process.d.ts +88 -0
- package/dist/primordials/process.js +132 -0
- package/dist/primordials/string.d.ts +2 -2
- package/dist/primordials/string.js +6 -6
- package/dist/primordials/symbol.js +3 -3
- package/dist/primordials/uncurry.d.ts +1 -2
- package/dist/primordials/uncurry.js +9 -9
- package/dist/process/abort.js +3 -3
- package/dist/process/lock-manager.js +8 -8
- package/dist/process/spawn/_internal.js +6 -8
- package/dist/process/spawn/child.js +20 -14
- package/dist/process/spawn/errors.js +3 -5
- package/dist/process/spawn/kill-tree.d.ts +53 -0
- package/dist/process/spawn/kill-tree.js +85 -0
- package/dist/process/spawn/stdio.js +0 -1
- package/dist/process/spawn/types.d.ts +5 -5
- package/dist/process/transient.js +2 -2
- package/dist/promises/_internal.d.ts +2 -1
- package/dist/promises/_internal.js +2 -6
- package/dist/promises/iterate.js +11 -15
- package/dist/promises/options.js +3 -6
- package/dist/promises/retry.js +4 -5
- package/dist/promises/timers.d.ts +30 -0
- package/dist/promises/timers.js +48 -0
- package/dist/regexps/spec.js +1 -1
- package/dist/releases/github-archives.d.ts +6 -6
- package/dist/releases/github-archives.js +3 -3
- package/dist/releases/github-asset-url.d.ts +1 -1
- package/dist/releases/github-asset-url.js +5 -5
- package/dist/releases/github-downloads.d.ts +1 -1
- package/dist/releases/github-downloads.js +3 -3
- package/dist/releases/github-listing.d.ts +12 -4
- package/dist/releases/github-listing.js +20 -7
- package/dist/releases/github-retry-config.js +1 -1
- package/dist/releases/github-types.d.ts +6 -6
- package/dist/releases/socket-btm-binary-naming.d.ts +107 -0
- package/dist/releases/socket-btm-binary-naming.js +155 -0
- package/dist/releases/socket-btm.d.ts +8 -115
- package/dist/releases/socket-btm.js +16 -159
- package/dist/schema/types.d.ts +4 -5
- package/dist/schema/validate.js +1 -1
- package/dist/sea/detect.js +6 -6
- package/dist/secrets/_internal.d.ts +2 -2
- package/dist/secrets/_internal.js +2 -2
- package/dist/secrets/compare.d.ts +45 -0
- package/dist/secrets/compare.js +61 -0
- package/dist/secrets/find.d.ts +2 -2
- package/dist/secrets/find.js +10 -4
- package/dist/secrets/keychain.d.ts +1 -1
- package/dist/secrets/keychain.js +6 -4
- package/dist/secrets/linux.js +40 -52
- package/dist/secrets/macos.d.ts +2 -3
- package/dist/secrets/macos.js +24 -33
- package/dist/secrets/rc.d.ts +4 -4
- package/dist/secrets/rc.js +27 -17
- package/dist/secrets/socket-api-token.d.ts +4 -4
- package/dist/secrets/socket-api-token.js +26 -9
- package/dist/secrets/windows.js +32 -37
- package/dist/shadow/skip.js +2 -2
- package/dist/shell/parse.d.ts +32 -0
- package/dist/shell/parse.js +60 -0
- package/dist/smol/detect.js +9 -10
- package/dist/smol/http.js +6 -7
- package/dist/smol/https.js +6 -7
- package/dist/smol/manifest.d.ts +1 -1
- package/dist/smol/manifest.js +6 -7
- package/dist/smol/path.d.ts +1 -1
- package/dist/smol/path.js +7 -8
- package/dist/smol/primordial.d.ts +4 -0
- package/dist/smol/primordial.js +6 -7
- package/dist/smol/purl.d.ts +1 -1
- package/dist/smol/purl.js +7 -8
- package/dist/smol/versions.js +6 -7
- package/dist/smol/vfs.js +6 -7
- package/dist/sorts/_internal.js +6 -8
- package/dist/sorts/natural.js +10 -12
- package/dist/sorts/semver.js +1 -2
- package/dist/sorts/strings.js +0 -1
- package/dist/sorts/types.d.ts +1 -1
- package/dist/spinner/create-spinner-class.d.ts +38 -0
- package/dist/spinner/create-spinner-class.js +302 -0
- package/dist/spinner/default.js +8 -9
- package/dist/spinner/spinner-internals.d.ts +36 -0
- package/dist/spinner/spinner-internals.js +105 -0
- package/dist/spinner/spinner-shimmer-methods.d.ts +54 -0
- package/dist/spinner/spinner-shimmer-methods.js +143 -0
- package/dist/spinner/spinner-status-methods.d.ts +40 -0
- package/dist/spinner/spinner-status-methods.js +133 -0
- package/dist/spinner/spinner.d.ts +8 -5
- package/dist/spinner/spinner.js +19 -706
- package/dist/spinner/types.d.ts +3 -1
- package/dist/spinner/with.d.ts +10 -0
- package/dist/spinner/with.js +16 -2
- package/dist/stdio/divider.js +1 -1
- package/dist/stdio/footer.js +3 -3
- package/dist/stdio/header.js +4 -4
- package/dist/stdio/progress.js +10 -6
- package/dist/stdio/prompts.d.ts +7 -5
- package/dist/stdio/prompts.js +7 -8
- package/dist/stdio/stdout.js +3 -3
- package/dist/streams/parallel.js +3 -5
- package/dist/streams/transform.js +2 -3
- package/dist/strings/format.js +2 -6
- package/dist/strings/predicates.js +0 -2
- package/dist/strings/search.js +1 -2
- package/dist/strings/transform.js +0 -3
- package/dist/strings/width.js +9 -10
- package/dist/tables/bordered.js +4 -3
- package/dist/tables/padding.js +1 -1
- package/dist/tables/simple.js +8 -5
- package/dist/temporal/instant.js +1 -1
- package/dist/temporal/slots.js +6 -6
- package/dist/temporal/system.js +9 -9
- package/dist/themes/context.d.ts +3 -2
- package/dist/themes/context.js +4 -5
- package/dist/themes/themes.js +15 -15
- package/dist/themes/types.d.ts +3 -3
- package/dist/url/assert-safe.d.ts +29 -0
- package/dist/url/assert-safe.js +54 -0
- package/dist/url/parse.js +0 -2
- package/dist/url/predicates.d.ts +31 -1
- package/dist/url/predicates.js +43 -3
- package/dist/url/search-params.js +3 -9
- package/dist/url/types.d.ts +9 -5
- package/dist/versions/_internal.js +3 -3
- package/dist/words/article.js +0 -1
- package/dist/words/capitalize.js +0 -1
- package/dist/words/pluralize.js +15 -5
- package/package.json +419 -216
- package/dist/external-tools/uv/asset-names.d.ts +0 -36
- package/dist/external-tools/uv/asset-names.js +0 -70
- package/dist/external-tools/uv/from-download.d.ts +0 -17
- package/dist/external-tools/uv/from-download.js +0 -47
- package/dist/external-tools/uv/from-path.d.ts +0 -5
- package/dist/external-tools/uv/from-path.js +0 -22
- package/dist/external-tools/uv/from-vfs.d.ts +0 -7
- package/dist/external-tools/uv/from-vfs.js +0 -26
- package/dist/external-tools/uv/resolve.d.ts +0 -25
- package/dist/external-tools/uv/resolve.js +0 -53
- package/dist/external-tools/uv/types.d.ts +0 -24
- package/dist/fs/path-cache.d.ts +0 -21
- package/dist/fs/path-cache.js +0 -34
- package/dist/http-request/checksums.d.ts +0 -69
- package/dist/http-request/checksums.js +0 -108
- package/dist/http-request/http-request.d.ts +0 -12
- package/dist/http-request/http-request.js +0 -11
- package/dist/packages/operations.d.ts +0 -113
- package/dist/packages/operations.js +0 -304
- package/dist/ssri/convert.d.ts +0 -48
- package/dist/ssri/convert.js +0 -69
- package/dist/ssri/parse.d.ts +0 -27
- package/dist/ssri/parse.js +0 -41
- package/dist/ssri/validate.d.ts +0 -41
- package/dist/ssri/validate.js +0 -56
- /package/dist/{bin → cli}/check.d.ts +0 -0
- /package/dist/external-tools/{uv → python}/types.js +0 -0
- /package/dist/fs/{find-up.d.ts → find.d.ts} +0 -0
- /package/dist/github/{fetch.d.ts → request.d.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_primordials_object = require('../primordials/object.js');
|
|
5
4
|
const require_arrays_predicates = require('../arrays/predicates.js');
|
|
5
|
+
const require_primordials_object = require('../primordials/object.js');
|
|
6
6
|
|
|
7
7
|
//#region src/objects/predicates.ts
|
|
8
8
|
/**
|
|
@@ -31,7 +31,6 @@ const require_arrays_predicates = require('../arrays/predicates.js');
|
|
|
31
31
|
*
|
|
32
32
|
* @returns `true` if obj has enumerable own properties, `false` otherwise
|
|
33
33
|
*/
|
|
34
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
35
34
|
function hasKeys(obj) {
|
|
36
35
|
if (obj === null || obj === void 0) return false;
|
|
37
36
|
for (const key in obj) if (require_primordials_object.ObjectHasOwn(obj, key)) return true;
|
|
@@ -58,7 +57,6 @@ function hasKeys(obj) {
|
|
|
58
57
|
*
|
|
59
58
|
* @returns `true` if obj has the property as an own property, `false` otherwise
|
|
60
59
|
*/
|
|
61
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
62
60
|
function hasOwn(obj, propKey) {
|
|
63
61
|
if (obj === null || obj === void 0) return false;
|
|
64
62
|
return require_primordials_object.ObjectHasOwn(obj, propKey);
|
|
@@ -83,7 +81,6 @@ function hasOwn(obj, propKey) {
|
|
|
83
81
|
*
|
|
84
82
|
* @returns `true` if value is an object (including arrays), `false` otherwise
|
|
85
83
|
*/
|
|
86
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
87
84
|
function isObject(value) {
|
|
88
85
|
return value !== null && typeof value === "object";
|
|
89
86
|
}
|
|
@@ -107,7 +104,6 @@ function isObject(value) {
|
|
|
107
104
|
*
|
|
108
105
|
* @returns `true` if value is a plain object, `false` otherwise
|
|
109
106
|
*/
|
|
110
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
111
107
|
function isPlainObject(value) {
|
|
112
108
|
if (value === null || typeof value !== "object" || require_arrays_predicates.isArray(value)) return false;
|
|
113
109
|
const proto = require_primordials_object.ObjectGetPrototypeOf(value);
|
package/dist/objects/sort.js
CHANGED
|
@@ -35,11 +35,10 @@ const require_sorts_natural = require('../sorts/natural.js');
|
|
|
35
35
|
*
|
|
36
36
|
* @returns Negative if a < b, positive if a > b, zero if equal
|
|
37
37
|
*/
|
|
38
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
39
38
|
function entryKeyComparator(a, b) {
|
|
40
39
|
const keyA = a[0];
|
|
41
40
|
const keyB = b[0];
|
|
42
|
-
return
|
|
41
|
+
return require_sorts_natural.localeCompare(typeof keyA === "string" ? keyA : String(keyA), typeof keyB === "string" ? keyB : String(keyB));
|
|
43
42
|
}
|
|
44
43
|
/**
|
|
45
44
|
* Get all own property entries (key-value pairs) from an object.
|
|
@@ -58,7 +57,6 @@ function entryKeyComparator(a, b) {
|
|
|
58
57
|
*
|
|
59
58
|
* @returns Array of [key, value] tuples, or empty array for null/undefined
|
|
60
59
|
*/
|
|
61
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
62
60
|
function objectEntries(obj) {
|
|
63
61
|
if (obj === null || obj === void 0) return [];
|
|
64
62
|
const keys = require_primordials_reflect.ReflectOwnKeys(obj);
|
|
@@ -87,9 +85,8 @@ function objectEntries(obj) {
|
|
|
87
85
|
*
|
|
88
86
|
* @returns A new object with sorted keys
|
|
89
87
|
*/
|
|
90
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
91
88
|
function toSortedObject(obj) {
|
|
92
|
-
return
|
|
89
|
+
return toSortedObjectFromEntries(objectEntries(obj));
|
|
93
90
|
}
|
|
94
91
|
/**
|
|
95
92
|
* Create an object from entries with sorted keys.
|
|
@@ -112,14 +109,13 @@ function toSortedObject(obj) {
|
|
|
112
109
|
*
|
|
113
110
|
* @returns A new object with sorted keys
|
|
114
111
|
*/
|
|
115
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
116
112
|
function toSortedObjectFromEntries(entries) {
|
|
117
113
|
const otherEntries = [];
|
|
118
114
|
const symbolEntries = [];
|
|
119
115
|
for (const entry of entries) if (typeof entry[0] === "symbol") symbolEntries.push(entry);
|
|
120
116
|
else otherEntries.push(entry);
|
|
121
117
|
if (!otherEntries.length && !symbolEntries.length) return {};
|
|
122
|
-
return require_primordials_object.ObjectFromEntries([...symbolEntries.
|
|
118
|
+
return require_primordials_object.ObjectFromEntries([...symbolEntries.toSorted(entryKeyComparator), ...otherEntries.toSorted(entryKeyComparator)]);
|
|
123
119
|
}
|
|
124
120
|
|
|
125
121
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file The `EditablePackageJson` class factory. Split out of
|
|
3
3
|
* `packages/edit.ts` for size hygiene. Wraps `@npmcli/package-json` with
|
|
4
|
-
* Socket-specific knobs: path tracking, a `
|
|
4
|
+
* Socket-specific knobs: path tracking, a `canSave` guard for content-only
|
|
5
5
|
* instances, async + sync save paths that honor `EditablePackageJsonOptions`
|
|
6
6
|
* formatting.
|
|
7
7
|
*
|
|
@@ -14,7 +14,7 @@ import type { EditablePackageJsonInstance } from './edit';
|
|
|
14
14
|
* class. Not exported because consumers go through
|
|
15
15
|
* `getEditablePackageJsonClass()`.
|
|
16
16
|
*/
|
|
17
|
-
interface EditablePackageJsonConstructor {
|
|
17
|
+
export interface EditablePackageJsonConstructor {
|
|
18
18
|
new (): EditablePackageJsonInstance;
|
|
19
19
|
fixSteps: unknown[];
|
|
20
20
|
normalizeSteps: unknown[];
|
|
@@ -36,4 +36,3 @@ interface EditablePackageJsonConstructor {
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
export declare function getEditablePackageJsonClass(): EditablePackageJsonConstructor;
|
|
39
|
-
export {};
|
|
@@ -18,13 +18,13 @@ let src_external__npmcli_package_json_lib_sort = require("../external/@npmcli/pa
|
|
|
18
18
|
/**
|
|
19
19
|
* @file The `EditablePackageJson` class factory. Split out of
|
|
20
20
|
* `packages/edit.ts` for size hygiene. Wraps `@npmcli/package-json` with
|
|
21
|
-
* Socket-specific knobs: path tracking, a `
|
|
21
|
+
* Socket-specific knobs: path tracking, a `canSave` guard for content-only
|
|
22
22
|
* instances, async + sync save paths that honor `EditablePackageJsonOptions`
|
|
23
23
|
* formatting.
|
|
24
24
|
*
|
|
25
25
|
* - `getEditablePackageJsonClass` — lazy class accessor (Webpack-safe)
|
|
26
26
|
*/
|
|
27
|
-
let
|
|
27
|
+
let cachedEditablePackageJsonClass;
|
|
28
28
|
/**
|
|
29
29
|
* Get the EditablePackageJson class for package.json manipulation.
|
|
30
30
|
*
|
|
@@ -35,37 +35,36 @@ let _EditablePackageJsonClass;
|
|
|
35
35
|
* console.log(pkg.content.name)
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
39
38
|
function getEditablePackageJsonClass() {
|
|
40
|
-
if (
|
|
39
|
+
if (cachedEditablePackageJsonClass === void 0) cachedEditablePackageJsonClass = class EditablePackageJson extends src_external__npmcli_package_json.default {
|
|
41
40
|
static fixSteps = src_external__npmcli_package_json.default.fixSteps;
|
|
42
41
|
static normalizeSteps = src_external__npmcli_package_json.default.normalizeSteps;
|
|
43
42
|
static prepareSteps = src_external__npmcli_package_json.default.prepareSteps;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
canSave = true;
|
|
44
|
+
pkgPath = void 0;
|
|
45
|
+
readFileContent = "";
|
|
46
|
+
readFileJson = void 0;
|
|
48
47
|
get content() {
|
|
49
48
|
return super.content;
|
|
50
49
|
}
|
|
51
50
|
get filename() {
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
54
|
-
if (require_primordials_string.StringPrototypeEndsWith(
|
|
55
|
-
return
|
|
51
|
+
const pkgPath = this.pkgPath;
|
|
52
|
+
if (!pkgPath) return "";
|
|
53
|
+
if (require_primordials_string.StringPrototypeEndsWith(pkgPath, "package.json")) return pkgPath;
|
|
54
|
+
return require_node_path.getNodePath().join(pkgPath, "package.json");
|
|
56
55
|
}
|
|
57
56
|
static async create(path, opts = {}) {
|
|
58
|
-
const p = new
|
|
57
|
+
const p = new cachedEditablePackageJsonClass();
|
|
59
58
|
await p.create(path);
|
|
60
59
|
return opts.data ? p.update(opts.data) : p;
|
|
61
60
|
}
|
|
62
|
-
static async fix(path,
|
|
63
|
-
const p = new
|
|
61
|
+
static async fix(path, options) {
|
|
62
|
+
const p = new cachedEditablePackageJsonClass();
|
|
64
63
|
await p.load(path, true);
|
|
65
|
-
return await p.fix(
|
|
64
|
+
return await p.fix(options);
|
|
66
65
|
}
|
|
67
66
|
static async load(path, opts = {}) {
|
|
68
|
-
const p = new
|
|
67
|
+
const p = new cachedEditablePackageJsonClass();
|
|
69
68
|
if (!opts.create) return await p.load(path);
|
|
70
69
|
try {
|
|
71
70
|
return await p.load(path);
|
|
@@ -74,19 +73,19 @@ function getEditablePackageJsonClass() {
|
|
|
74
73
|
return p.create(path);
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
|
-
static async normalize(path,
|
|
78
|
-
const p = new
|
|
76
|
+
static async normalize(path, options) {
|
|
77
|
+
const p = new cachedEditablePackageJsonClass();
|
|
79
78
|
await p.load(path);
|
|
80
|
-
return await p.normalize(
|
|
79
|
+
return await p.normalize(options);
|
|
81
80
|
}
|
|
82
|
-
static async prepare(path,
|
|
83
|
-
const p = new
|
|
81
|
+
static async prepare(path, options) {
|
|
82
|
+
const p = new cachedEditablePackageJsonClass();
|
|
84
83
|
await p.load(path, true);
|
|
85
|
-
return await p.prepare(
|
|
84
|
+
return await p.prepare(options);
|
|
86
85
|
}
|
|
87
86
|
create(path) {
|
|
88
87
|
super.create(path);
|
|
89
|
-
this.
|
|
88
|
+
this.pkgPath = path;
|
|
90
89
|
return this;
|
|
91
90
|
}
|
|
92
91
|
async fix(opts = {}) {
|
|
@@ -95,7 +94,7 @@ function getEditablePackageJsonClass() {
|
|
|
95
94
|
}
|
|
96
95
|
fromContent(data) {
|
|
97
96
|
super.fromContent(data);
|
|
98
|
-
this.
|
|
97
|
+
this.canSave = false;
|
|
99
98
|
return this;
|
|
100
99
|
}
|
|
101
100
|
fromJSON(data) {
|
|
@@ -103,17 +102,17 @@ function getEditablePackageJsonClass() {
|
|
|
103
102
|
return this;
|
|
104
103
|
}
|
|
105
104
|
async load(path, create) {
|
|
106
|
-
this.
|
|
107
|
-
const { promises: fsPromises } =
|
|
105
|
+
this.pkgPath = path;
|
|
106
|
+
const { promises: fsPromises } = require_node_fs.getNodeFs();
|
|
108
107
|
let parseErr;
|
|
109
108
|
try {
|
|
110
|
-
this.
|
|
109
|
+
this.readFileContent = await (0, src_external__npmcli_package_json_lib_read_package.read)(this.filename);
|
|
111
110
|
} catch (e) {
|
|
112
111
|
if (!create) throw e;
|
|
113
112
|
parseErr = e;
|
|
114
113
|
}
|
|
115
114
|
if (parseErr) {
|
|
116
|
-
const indexFile =
|
|
115
|
+
const indexFile = require_node_path.getNodePath().resolve(this.path || "", "index.js");
|
|
117
116
|
let indexFileContent;
|
|
118
117
|
try {
|
|
119
118
|
indexFileContent = await fsPromises.readFile(indexFile, "utf8");
|
|
@@ -125,11 +124,11 @@ function getEditablePackageJsonClass() {
|
|
|
125
124
|
} catch {
|
|
126
125
|
throw parseErr;
|
|
127
126
|
}
|
|
128
|
-
this.
|
|
127
|
+
this.canSave = false;
|
|
129
128
|
return this;
|
|
130
129
|
}
|
|
131
|
-
this.fromJSON(this.
|
|
132
|
-
this.
|
|
130
|
+
this.fromJSON(this.readFileContent);
|
|
131
|
+
this.readFileJson = (0, src_external__npmcli_package_json_lib_read_package.parse)(this.readFileContent);
|
|
133
132
|
return this;
|
|
134
133
|
}
|
|
135
134
|
async normalize(opts = {}) {
|
|
@@ -137,42 +136,47 @@ function getEditablePackageJsonClass() {
|
|
|
137
136
|
return this;
|
|
138
137
|
}
|
|
139
138
|
get path() {
|
|
140
|
-
return this.
|
|
139
|
+
return this.pkgPath;
|
|
141
140
|
}
|
|
142
141
|
async prepare(opts = {}) {
|
|
143
142
|
await super.prepare(opts);
|
|
144
143
|
return this;
|
|
145
144
|
}
|
|
146
145
|
async save(options) {
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
options = {
|
|
147
|
+
__proto__: null,
|
|
148
|
+
...options
|
|
149
|
+
};
|
|
150
|
+
if (!this.canSave || this.content === void 0) throw new require_primordials_error.ErrorCtor("No package.json to save to");
|
|
151
|
+
if (!require_json_format.shouldSave(this.content, this.readFileJson, this.readFileContent, {
|
|
149
152
|
...options,
|
|
150
153
|
sortFn: options?.sort ? src_external__npmcli_package_json_lib_sort.packageSort : void 0
|
|
151
154
|
})) return false;
|
|
152
155
|
const content = require_json_format.stripFormattingSymbols(this.content);
|
|
153
156
|
const fileContent = require_json_format.stringifyWithFormatting(options?.sort ? (0, src_external__npmcli_package_json_lib_sort.packageSort)(content) : content, require_json_format.getFormattingFromContent(this.content));
|
|
154
|
-
const { promises: fsPromises } =
|
|
157
|
+
const { promises: fsPromises } = require_node_fs.getNodeFs();
|
|
155
158
|
await fsPromises.writeFile(this.filename, fileContent);
|
|
156
|
-
this.
|
|
157
|
-
this.
|
|
159
|
+
this.readFileContent = fileContent;
|
|
160
|
+
this.readFileJson = (0, src_external__npmcli_package_json_lib_read_package.parse)(fileContent);
|
|
158
161
|
return true;
|
|
159
162
|
}
|
|
160
163
|
saveSync(options) {
|
|
161
|
-
if (!this.
|
|
164
|
+
if (!this.canSave || this.content === void 0) throw new require_primordials_error.ErrorCtor("No package.json to save to");
|
|
162
165
|
const { ignoreWhitespace = false, sort = false } = {
|
|
163
166
|
__proto__: null,
|
|
164
167
|
...options
|
|
165
168
|
};
|
|
166
169
|
const { [Symbol.for("indent")]: indent, [Symbol.for("newline")]: newline, ...rest } = this.content;
|
|
167
170
|
const content = sort ? (0, src_external__npmcli_package_json_lib_sort.packageSort)(rest) : rest;
|
|
168
|
-
|
|
171
|
+
const util = require_node_util.getNodeUtil();
|
|
172
|
+
if (ignoreWhitespace && util.isDeepStrictEqual(content, this.readFileJson)) return false;
|
|
169
173
|
const format = indent === void 0 || indent === null ? " " : indent;
|
|
170
174
|
const eol = newline === void 0 || newline === null ? "\n" : newline;
|
|
171
175
|
const fileContent = `${require_primordials_json.JSONStringify(content, void 0, format)}\n`.replace(/\n/g, eol);
|
|
172
|
-
if (!ignoreWhitespace && fileContent.trim() === this.
|
|
173
|
-
|
|
174
|
-
this.
|
|
175
|
-
this.
|
|
176
|
+
if (!ignoreWhitespace && fileContent.trim() === this.readFileContent.trim()) return false;
|
|
177
|
+
require_node_fs.getNodeFs().writeFileSync(this.filename, fileContent);
|
|
178
|
+
this.readFileContent = fileContent;
|
|
179
|
+
this.readFileJson = (0, src_external__npmcli_package_json_lib_read_package.parse)(fileContent);
|
|
176
180
|
return true;
|
|
177
181
|
}
|
|
178
182
|
update(content) {
|
|
@@ -184,18 +188,19 @@ function getEditablePackageJsonClass() {
|
|
|
184
188
|
__proto__: null,
|
|
185
189
|
...options
|
|
186
190
|
};
|
|
187
|
-
if (!this.
|
|
191
|
+
if (!this.canSave || this.content === void 0) return false;
|
|
188
192
|
const { [Symbol.for("indent")]: indent, [Symbol.for("newline")]: newline, ...rest } = this.content;
|
|
189
193
|
const content = sort ? (0, src_external__npmcli_package_json_lib_sort.packageSort)(rest) : rest;
|
|
190
|
-
|
|
194
|
+
const util = require_node_util.getNodeUtil();
|
|
195
|
+
if (ignoreWhitespace && util.isDeepStrictEqual(content, this.readFileJson)) return false;
|
|
191
196
|
const format = indent === void 0 || indent === null ? " " : indent;
|
|
192
197
|
const eol = newline === void 0 || newline === null ? "\n" : newline;
|
|
193
198
|
const fileContent = `${require_primordials_json.JSONStringify(content, void 0, format)}\n`.replace(/\n/g, eol);
|
|
194
|
-
if (!ignoreWhitespace && fileContent.trim() === this.
|
|
199
|
+
if (!ignoreWhitespace && fileContent.trim() === this.readFileContent.trim()) return false;
|
|
195
200
|
return true;
|
|
196
201
|
}
|
|
197
202
|
};
|
|
198
|
-
return
|
|
203
|
+
return cachedEditablePackageJsonClass;
|
|
199
204
|
}
|
|
200
205
|
|
|
201
206
|
//#endregion
|
package/dist/packages/edit.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_paths_predicates = require('../paths/predicates.js');
|
|
5
5
|
const require_primordials_json = require('../primordials/json.js');
|
|
6
|
-
const require_packages_normalize = require('./normalize.js');
|
|
7
|
-
const require_paths_packages = require('../paths/packages.js');
|
|
8
6
|
const require_packages_edit_class = require('./edit-class.js');
|
|
7
|
+
const require_paths_packages = require('../paths/packages.js');
|
|
8
|
+
const require_packages_normalize = require('./normalize.js');
|
|
9
9
|
|
|
10
10
|
//#region src/packages/edit.ts
|
|
11
11
|
/**
|
|
@@ -35,18 +35,17 @@ const require_packages_edit_class = require('./edit-class.js');
|
|
|
35
35
|
* )
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
39
38
|
async function toEditablePackageJson(pkgJson, options) {
|
|
40
39
|
const { path: filepath, ...restOptions } = {
|
|
41
40
|
__proto__: null,
|
|
42
41
|
...options
|
|
43
42
|
};
|
|
44
43
|
const { normalize, ...normalizeOptions } = restOptions;
|
|
45
|
-
const EditablePackageJson =
|
|
46
|
-
if (typeof filepath !== "string") return new EditablePackageJson().fromContent(normalize ?
|
|
47
|
-
const pkgJsonPath =
|
|
48
|
-
return (await EditablePackageJson.load(pkgJsonPath, { create: true })).fromJSON(`${require_primordials_json.JSONStringify(normalize ?
|
|
49
|
-
|
|
44
|
+
const EditablePackageJson = require_packages_edit_class.getEditablePackageJsonClass();
|
|
45
|
+
if (typeof filepath !== "string") return new EditablePackageJson().fromContent(normalize ? require_packages_normalize.normalizePackageJson(pkgJson, normalizeOptions) : pkgJson);
|
|
46
|
+
const pkgJsonPath = require_paths_packages.resolvePackageJsonDirname(filepath);
|
|
47
|
+
return (await EditablePackageJson.load(pkgJsonPath, { create: true })).fromJSON(`${require_primordials_json.JSONStringify(normalize ? require_packages_normalize.normalizePackageJson(pkgJson, {
|
|
48
|
+
...require_paths_predicates.isNodeModules(pkgJsonPath) ? {} : { preserve: ["repository"] },
|
|
50
49
|
...normalizeOptions
|
|
51
50
|
}) : pkgJson, void 0, 2)}\n`);
|
|
52
51
|
}
|
|
@@ -62,18 +61,17 @@ async function toEditablePackageJson(pkgJson, options) {
|
|
|
62
61
|
* )
|
|
63
62
|
* ```
|
|
64
63
|
*/
|
|
65
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
66
64
|
function toEditablePackageJsonSync(pkgJson, options) {
|
|
67
65
|
const { path: filepath, ...restOptions } = {
|
|
68
66
|
__proto__: null,
|
|
69
67
|
...options
|
|
70
68
|
};
|
|
71
69
|
const { normalize, ...normalizeOptions } = restOptions;
|
|
72
|
-
const EditablePackageJson =
|
|
73
|
-
if (typeof filepath !== "string") return new EditablePackageJson().fromContent(normalize ?
|
|
74
|
-
const pkgJsonPath =
|
|
75
|
-
return new EditablePackageJson().create(pkgJsonPath).fromJSON(`${require_primordials_json.JSONStringify(normalize ?
|
|
76
|
-
|
|
70
|
+
const EditablePackageJson = require_packages_edit_class.getEditablePackageJsonClass();
|
|
71
|
+
if (typeof filepath !== "string") return new EditablePackageJson().fromContent(normalize ? require_packages_normalize.normalizePackageJson(pkgJson, normalizeOptions) : pkgJson);
|
|
72
|
+
const pkgJsonPath = require_paths_packages.resolvePackageJsonDirname(filepath);
|
|
73
|
+
return new EditablePackageJson().create(pkgJsonPath).fromJSON(`${require_primordials_json.JSONStringify(normalize ? require_packages_normalize.normalizePackageJson(pkgJson, {
|
|
74
|
+
...require_paths_predicates.isNodeModules(pkgJsonPath) ? {} : { preserve: ["repository"] },
|
|
77
75
|
...normalizeOptions
|
|
78
76
|
}) : pkgJson, void 0, 2)}\n`);
|
|
79
77
|
}
|
package/dist/packages/exports.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_primordials_error = require('../primordials/error.js');
|
|
5
|
+
const require_arrays_predicates = require('../arrays/predicates.js');
|
|
6
|
+
const require_primordials_object = require('../primordials/object.js');
|
|
7
|
+
const require_objects_predicates = require('../objects/predicates.js');
|
|
8
|
+
const require_primordials_map_set = require('../primordials/map-set.js');
|
|
5
9
|
const require_primordials_string = require('../primordials/string.js');
|
|
6
10
|
const require_primordials_array = require('../primordials/array.js');
|
|
7
|
-
const require_primordials_map_set = require('../primordials/map-set.js');
|
|
8
|
-
const require_primordials_object = require('../primordials/object.js');
|
|
9
11
|
const require_constants_sentinels = require('../constants/sentinels.js');
|
|
10
|
-
const require_arrays_predicates = require('../arrays/predicates.js');
|
|
11
|
-
const require_objects_predicates = require('../objects/predicates.js');
|
|
12
12
|
|
|
13
13
|
//#region src/packages/exports.ts
|
|
14
14
|
/**
|
|
@@ -26,7 +26,6 @@ const require_objects_predicates = require('../objects/predicates.js');
|
|
|
26
26
|
* // types === './dist/index.d.ts'
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
30
29
|
function findTypesForSubpath(entryExports, subpath) {
|
|
31
30
|
const queue = [entryExports];
|
|
32
31
|
let pos = 0;
|
|
@@ -36,14 +35,14 @@ function findTypesForSubpath(entryExports, subpath) {
|
|
|
36
35
|
if (require_arrays_predicates.isArray(value)) for (let i = 0, { length } = value; i < length; i += 1) {
|
|
37
36
|
const item = value[i];
|
|
38
37
|
if (item === subpath) return value.types;
|
|
39
|
-
if (
|
|
38
|
+
if (require_objects_predicates.isObject(item)) queue.push(item);
|
|
40
39
|
}
|
|
41
|
-
else if (
|
|
40
|
+
else if (require_objects_predicates.isObject(value)) {
|
|
42
41
|
const keys = require_primordials_object.ObjectGetOwnPropertyNames(value);
|
|
43
42
|
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
44
43
|
const item = value[keys[i]];
|
|
45
44
|
if (item === subpath) return value.types;
|
|
46
|
-
if (
|
|
45
|
+
if (require_objects_predicates.isObject(item)) queue.push(item);
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
}
|
|
@@ -57,20 +56,19 @@ function findTypesForSubpath(entryExports, subpath) {
|
|
|
57
56
|
* getExportFilePaths(exports) // ['./dist/index.js', './dist/utils.js']
|
|
58
57
|
* ```
|
|
59
58
|
*/
|
|
60
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
61
59
|
function getExportFilePaths(entryExports) {
|
|
62
|
-
if (
|
|
60
|
+
if (!require_objects_predicates.isObject(entryExports)) return [];
|
|
63
61
|
const paths = [];
|
|
64
62
|
for (const key of require_primordials_object.ObjectGetOwnPropertyNames(entryExports)) {
|
|
65
63
|
if (!require_primordials_string.StringPrototypeStartsWith(key, ".")) continue;
|
|
66
64
|
const value = entryExports[key];
|
|
67
65
|
if (typeof value === "string") require_primordials_array.ArrayPrototypePush(paths, value);
|
|
68
|
-
else if (
|
|
66
|
+
else if (require_objects_predicates.isObject(value)) for (const subKey of require_primordials_object.ObjectGetOwnPropertyNames(value)) {
|
|
69
67
|
const subValue = value[subKey];
|
|
70
68
|
if (typeof subValue === "string") require_primordials_array.ArrayPrototypePush(paths, subValue);
|
|
71
69
|
else if (require_arrays_predicates.isArray(subValue)) {
|
|
72
70
|
for (const item of subValue) if (typeof item === "string") require_primordials_array.ArrayPrototypePush(paths, item);
|
|
73
|
-
else if (
|
|
71
|
+
else if (require_objects_predicates.isObject(item)) for (const nestedKey of require_primordials_object.ObjectGetOwnPropertyNames(item)) {
|
|
74
72
|
const nestedValue = item[nestedKey];
|
|
75
73
|
if (typeof nestedValue === "string") require_primordials_array.ArrayPrototypePush(paths, nestedValue);
|
|
76
74
|
}
|
|
@@ -88,9 +86,8 @@ function getExportFilePaths(entryExports) {
|
|
|
88
86
|
* getSubpaths(exports) // ['.', './utils']
|
|
89
87
|
* ```
|
|
90
88
|
*/
|
|
91
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
92
89
|
function getSubpaths(entryExports) {
|
|
93
|
-
if (
|
|
90
|
+
if (!require_objects_predicates.isObject(entryExports)) return [];
|
|
94
91
|
return require_primordials_object.ObjectGetOwnPropertyNames(entryExports).filter((key) => require_primordials_string.StringPrototypeStartsWith(key, "."));
|
|
95
92
|
}
|
|
96
93
|
/**
|
|
@@ -102,9 +99,8 @@ function getSubpaths(entryExports) {
|
|
|
102
99
|
* isConditionalExports({ '.': './index.js' }) // false
|
|
103
100
|
* ```
|
|
104
101
|
*/
|
|
105
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
106
102
|
function isConditionalExports(entryExports) {
|
|
107
|
-
if (
|
|
103
|
+
if (!require_objects_predicates.isPlainObject(entryExports)) return false;
|
|
108
104
|
const keys = require_primordials_object.ObjectGetOwnPropertyNames(entryExports);
|
|
109
105
|
const { length } = keys;
|
|
110
106
|
if (!length) return false;
|
|
@@ -123,9 +119,8 @@ function isConditionalExports(entryExports) {
|
|
|
123
119
|
* isSubpathExports({ import: './index.mjs' }) // false
|
|
124
120
|
* ```
|
|
125
121
|
*/
|
|
126
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
127
122
|
function isSubpathExports(entryExports) {
|
|
128
|
-
if (
|
|
123
|
+
if (require_objects_predicates.isPlainObject(entryExports)) {
|
|
129
124
|
const keys = require_primordials_object.ObjectGetOwnPropertyNames(entryExports);
|
|
130
125
|
for (let i = 0, { length } = keys; i < length; i += 1) if (keys[i]?.charCodeAt(0) === 46) return true;
|
|
131
126
|
}
|
|
@@ -143,11 +138,10 @@ function isSubpathExports(entryExports) {
|
|
|
143
138
|
* // { '.': './index.js' }
|
|
144
139
|
* ```
|
|
145
140
|
*/
|
|
146
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
147
141
|
function resolvePackageJsonEntryExports(entryExports) {
|
|
148
142
|
if (typeof entryExports === "string" || require_arrays_predicates.isArray(entryExports)) return { ".": entryExports };
|
|
149
|
-
if (
|
|
150
|
-
return
|
|
143
|
+
if (isConditionalExports(entryExports)) return entryExports;
|
|
144
|
+
return require_objects_predicates.isObject(entryExports) ? entryExports : void 0;
|
|
151
145
|
}
|
|
152
146
|
|
|
153
147
|
//#endregion
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Network-facing package helpers: the lazily-initialized
|
|
3
|
+
* make-fetch-happen fetcher (shared cache) and GitHub tarball-URL resolution
|
|
4
|
+
* for a package spec.
|
|
5
|
+
*/
|
|
6
|
+
import makeFetchHappen from '../external/make-fetch-happen';
|
|
7
|
+
export declare function getFetcher(): ReturnType<typeof makeFetchHappen.defaults>;
|
|
8
|
+
/**
|
|
9
|
+
* Resolve GitHub tarball URL for a package specifier.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ;```typescript
|
|
13
|
+
* const url = await resolveGitHubTgzUrl('my-pkg@1.0.0', '/tmp/my-project')
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveGitHubTgzUrl(pkgNameOrId: string, where?: unknown): Promise<string>;
|
|
@@ -0,0 +1,81 @@
|
|
|
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_objects_predicates = require('../objects/predicates.js');
|
|
6
|
+
const require_packages_specs = require('./specs.js');
|
|
7
|
+
const require_constants_packages = require('../constants/packages.js');
|
|
8
|
+
const require_packages_read = require('./read.js');
|
|
9
|
+
let src_external_npm_package_arg = require("../external/npm-package-arg");
|
|
10
|
+
src_external_npm_package_arg = require_runtime.__toESM(src_external_npm_package_arg);
|
|
11
|
+
let src_external_make_fetch_happen = require("../external/make-fetch-happen");
|
|
12
|
+
src_external_make_fetch_happen = require_runtime.__toESM(src_external_make_fetch_happen);
|
|
13
|
+
|
|
14
|
+
//#region src/packages/fetch.ts
|
|
15
|
+
/**
|
|
16
|
+
* @file Network-facing package helpers: the lazily-initialized
|
|
17
|
+
* make-fetch-happen fetcher (shared cache) and GitHub tarball-URL resolution
|
|
18
|
+
* for a package spec.
|
|
19
|
+
*/
|
|
20
|
+
const pacoteCachePath = require_constants_packages.getPacoteCachePath();
|
|
21
|
+
let cachedFetcher;
|
|
22
|
+
function getFetcher() {
|
|
23
|
+
if (cachedFetcher === void 0) cachedFetcher = src_external_make_fetch_happen.default.defaults({
|
|
24
|
+
cachePath: pacoteCachePath,
|
|
25
|
+
cache: "force-cache"
|
|
26
|
+
});
|
|
27
|
+
return cachedFetcher;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolve GitHub tarball URL for a package specifier.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ;```typescript
|
|
34
|
+
* const url = await resolveGitHubTgzUrl('my-pkg@1.0.0', '/tmp/my-project')
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
async function resolveGitHubTgzUrl(pkgNameOrId, where) {
|
|
38
|
+
const whereIsPkgJson = require_objects_predicates.isPlainObject(where);
|
|
39
|
+
const pkgJson = whereIsPkgJson ? where : await require_packages_read.readPackageJson(where, { normalize: true });
|
|
40
|
+
if (!pkgJson) return "";
|
|
41
|
+
const { version } = pkgJson;
|
|
42
|
+
const parsedSpec = (0, src_external_npm_package_arg.default)(pkgNameOrId, whereIsPkgJson ? void 0 : where);
|
|
43
|
+
if (require_packages_specs.isGitHubTgzSpec(parsedSpec)) return parsedSpec.saveSpec || "";
|
|
44
|
+
const isGitHubUrl = require_packages_specs.isGitHubUrlSpec(parsedSpec);
|
|
45
|
+
const repository = pkgJson.repository;
|
|
46
|
+
const { project, user } = (isGitHubUrl ? parsedSpec.hosted : require_packages_specs.getRepoUrlDetails(repository?.url)) || {
|
|
47
|
+
project: "",
|
|
48
|
+
user: ""
|
|
49
|
+
};
|
|
50
|
+
/* c8 ignore start - External GitHub API calls */
|
|
51
|
+
if (user && project) {
|
|
52
|
+
const fetcher = getFetcher();
|
|
53
|
+
let apiUrl = "";
|
|
54
|
+
if (isGitHubUrl) apiUrl = require_packages_specs.gitHubTagRefUrl(user, project, parsedSpec.gitCommittish || "");
|
|
55
|
+
else {
|
|
56
|
+
const versionStr = version;
|
|
57
|
+
apiUrl = require_packages_specs.gitHubTagRefUrl(user, project, `v${versionStr}`);
|
|
58
|
+
if (!(await fetcher(apiUrl, { method: "head" })).ok) {
|
|
59
|
+
apiUrl = require_packages_specs.gitHubTagRefUrl(user, project, versionStr);
|
|
60
|
+
if (!(await fetcher(apiUrl, { method: "head" })).ok) apiUrl = "";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (apiUrl) {
|
|
64
|
+
const resp = await fetcher(apiUrl);
|
|
65
|
+
let json;
|
|
66
|
+
try {
|
|
67
|
+
json = await resp.json();
|
|
68
|
+
} catch {
|
|
69
|
+
json = void 0;
|
|
70
|
+
}
|
|
71
|
+
const sha = json?.object?.sha;
|
|
72
|
+
if (sha) return require_packages_specs.gitHubTgzUrl(user, project, sha);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/* c8 ignore stop */
|
|
76
|
+
return "";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
exports.getFetcher = getFetcher;
|
|
81
|
+
exports.resolveGitHubTgzUrl = resolveGitHubTgzUrl;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Find the nearest package.json (or other marker) walking up from an
|
|
3
|
+
* `import.meta` — the package-domain wrapper over the generic `findUpSync`
|
|
4
|
+
* lookup in `fs/find`. Lives here (not in `paths/`) because it touches the
|
|
5
|
+
* filesystem; `paths/packages.ts` stays pure path-string shaping.
|
|
6
|
+
*/
|
|
7
|
+
export interface FindUpPackageJsonOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Names to look for. Defaults to `['package.json']`. Pass alternate markers
|
|
10
|
+
* for non-package roots (e.g. `['pnpm-workspace.yaml']` for the workspace
|
|
11
|
+
* root in a pnpm monorepo).
|
|
12
|
+
*/
|
|
13
|
+
names?: readonly string[] | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Optional ancestor boundary. Useful when a script is run from a deeply
|
|
16
|
+
* nested fixture and you don't want to escape the test's tmpdir. Defaults to
|
|
17
|
+
* the filesystem root.
|
|
18
|
+
*/
|
|
19
|
+
stopAt?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Find the nearest `package.json` walking up from `import.meta`. Returns the
|
|
23
|
+
* absolute path to the file (normalized to forward slashes), matching the
|
|
24
|
+
* `findUp` / `findUpSync` return shape. Throws when no marker is found — every
|
|
25
|
+
* script using this helper lives inside a package and should resolve.
|
|
26
|
+
*
|
|
27
|
+
* Use this instead of `path.join(__dirname, '..', '..'[, '..'])`. The ascent
|
|
28
|
+
* count is computed at runtime from the actual filesystem layout, not
|
|
29
|
+
* hard-coded into the source, so the helper stays correct across refactors that
|
|
30
|
+
* move scripts between directories.
|
|
31
|
+
*
|
|
32
|
+
* Pair with `readPackageJson` to find AND parse the nearest package.json:
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ;```ts
|
|
36
|
+
* const pkgJsonPath = findUpPackageJson(import.meta)
|
|
37
|
+
* // → '/abs/path/to/package.json'
|
|
38
|
+
* const pkg = await readPackageJson(pkgJsonPath)
|
|
39
|
+
* console.log(pkg?.name)
|
|
40
|
+
*
|
|
41
|
+
* // Workspace root in a pnpm monorepo:
|
|
42
|
+
* const wsRoot = findUpPackageJson(import.meta, {
|
|
43
|
+
* names: ['pnpm-workspace.yaml'],
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param meta - `import.meta` from the calling script.
|
|
48
|
+
* @param options - Override marker name(s) or set a stopAt boundary.
|
|
49
|
+
*
|
|
50
|
+
* @returns Absolute, normalized path to the marker file.
|
|
51
|
+
*
|
|
52
|
+
* @throws When no marker is found between the script and the filesystem root
|
|
53
|
+
* (or `stopAt`).
|
|
54
|
+
*/
|
|
55
|
+
export declare function findUpPackageJson(meta: ImportMeta, options?: FindUpPackageJsonOptions | undefined): string;
|