@socketsecurity/cli-with-sentry 1.16.1 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE +87 -0
- package/README.md +13 -13
- package/bin/cli.js +9 -9
- package/dist/.config/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/cli.js +2114 -4292
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +71 -87
- package/dist/constants.js.map +1 -1
- package/dist/env-helpers.js +63 -0
- package/dist/env-helpers.js.map +1 -0
- package/dist/instrument-with-sentry.js +7 -7
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/manifest-scripts/dotnet-tool/Microsoft.Build.Locator.dll +0 -0
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.deps.json +2 -2
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.dll +0 -0
- package/dist/manifest-scripts/maven-extension/coana-maven-extension.jar +0 -0
- package/dist/runtime-constants.js +345 -0
- package/dist/runtime-constants.js.map +1 -0
- package/dist/shadow-npm-bin2.js +9 -13
- package/dist/shadow-npm-bin2.js.map +1 -1
- package/dist/shadow-npm-inject.js +10 -15
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/shadow-npx-bin.js.map +1 -1
- package/dist/shadow-pnpm-bin2.js +21 -25
- package/dist/shadow-pnpm-bin2.js.map +1 -1
- package/dist/shadow-yarn-bin.js +4 -6
- package/dist/shadow-yarn-bin.js.map +1 -1
- package/dist/socket-completion.bash +0 -0
- package/dist/spawn-sync.js +47 -0
- package/dist/spawn-sync.js.map +1 -0
- package/dist/spinner.js +182 -0
- package/dist/spinner.js.map +1 -0
- package/dist/types/commands/fix/generated-socket-facts.d.mts +5 -2
- package/dist/types/commands/fix/handle-fix.d.mts +1 -1
- package/dist/types/commands/fix/types.d.mts +1 -1
- package/dist/types/commands/manifest/bazel/process.d.mts +2 -2
- package/dist/types/commands/manifest/convert-dotnet-to-facts.d.mts +3 -6
- package/dist/types/commands/manifest/discover-manifest-roots.d.mts +10 -11
- package/dist/types/commands/manifest/generate-recursive-manifests.d.mts +16 -30
- package/dist/types/commands/manifest/generate_auto_manifest.d.mts +6 -11
- package/dist/types/commands/manifest/load-build.d.mts +3 -11
- package/dist/types/commands/manifest/run-manifest-facts.d.mts +88 -29
- package/dist/types/commands/manifest/scripts/build-tool.d.mts +2 -0
- package/dist/types/commands/optimize/add-overrides.d.mts +2 -2
- package/dist/types/commands/optimize/get-dependency-entries.d.mts +1 -1
- package/dist/types/commands/optimize/get-overrides-by-agent.d.mts +16 -7
- package/dist/types/commands/optimize/update-lockfile.d.mts +2 -2
- package/dist/types/commands/optimize/update-manifest-by-agent.d.mts +4 -2
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts +2 -2
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +1 -1
- package/dist/types/commands/scan/generate-report.d.mts +1 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts +5 -1
- package/dist/types/commands/scan/output-create-new-scan.d.mts +1 -1
- package/dist/types/commands/scan/output-diff-scan.d.mts +4 -2
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts +4 -5
- package/dist/types/commands/scan/run-dynamic-sbom-inference.d.mts +7 -15
- package/dist/types/constants/runtime.d.mts +417 -0
- package/dist/types/constants.d.mts +9 -10
- package/dist/types/paths/coana.d.mts +5 -0
- package/dist/types/paths/uv.d.mts +2 -0
- package/dist/types/sea/adapters/cdxgen-worker.d.mts +1 -0
- package/dist/types/sea/adapters/synp-worker.d.mts +1 -0
- package/dist/types/sea/build/cdxgen-fixture.d.mts +4 -0
- package/dist/types/sea/build/smoke-test.d.mts +2 -0
- package/dist/types/sea/build-sea.d.mts +4 -2
- package/dist/types/sea/download-bytes.d.mts +0 -1
- package/dist/types/sea/paths/archive.d.mts +3 -0
- package/dist/types/sea/paths/coana-cache.d.mts +1 -0
- package/dist/types/sea/paths/native-tools.d.mts +13 -0
- package/dist/types/sea/pnpm-lock.d.mts +22 -0
- package/dist/types/sea/rollup-workers.d.mts +1 -0
- package/dist/types/sea/runtime.d.mts +4 -3
- package/dist/types/sea/vfs-digest.d.mts +2 -0
- package/dist/types/shadow/common.d.mts +1 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts +1 -1
- package/dist/types/shadow/npm/bin.d.mts +1 -1
- package/dist/types/shadow/npm/install.d.mts +3 -3
- package/dist/types/shadow/npm-base.d.mts +1 -1
- package/dist/types/shadow/npx/bin.d.mts +1 -1
- package/dist/types/shadow/pnpm/bin.d.mts +1 -1
- package/dist/types/shadow/yarn/bin.d.mts +1 -1
- package/dist/types/test/mocks/socket-auth.d.mts +40 -39
- package/dist/types/utils/agent.d.mts +6 -1
- package/dist/types/utils/alert/artifact.d.mts +1 -1
- package/dist/types/utils/alerts-map.d.mts +1 -1
- package/dist/types/utils/api.d.mts +1 -1
- package/dist/types/utils/arrays.d.mts +6 -0
- package/dist/types/utils/bin.d.mts +26 -0
- package/dist/types/utils/{coana-release.d.mts → coana/release.d.mts} +5 -3
- package/dist/types/utils/debug.d.mts +23 -49
- package/dist/types/utils/dlx.d.mts +1 -1
- package/dist/types/utils/ecosystem.d.mts +1 -9
- package/dist/types/utils/env.d.mts +24 -0
- package/dist/types/utils/errors.d.mts +2 -2
- package/dist/types/utils/escape-regexp.d.mts +6 -0
- package/dist/types/utils/fs.d.mts +33 -0
- package/dist/types/utils/github.d.mts +1 -1
- package/dist/types/utils/globs.d.mts +1 -0
- package/dist/types/utils/logger.d.mts +51 -0
- package/dist/types/utils/objects.d.mts +11 -0
- package/dist/types/utils/package-environment.d.mts +3 -3
- package/dist/types/utils/packages.d.mts +65 -0
- package/dist/types/utils/path.d.mts +3 -0
- package/dist/types/utils/promises.d.mts +23 -0
- package/dist/types/utils/prompts.d.mts +25 -0
- package/dist/types/utils/purl.d.mts +4 -1
- package/dist/types/utils/socket-package-alert.d.mts +1 -1
- package/dist/types/utils/socket-url.d.mts +1 -1
- package/dist/types/utils/sorts.d.mts +1 -0
- package/dist/types/utils/spawn-sync.d.mts +3 -0
- package/dist/types/utils/spawn.d.mts +67 -0
- package/dist/types/utils/spec.d.mts +1 -1
- package/dist/types/utils/spinner.d.mts +46 -0
- package/dist/types/utils/streams.d.mts +3 -0
- package/dist/types/utils/strings.d.mts +6 -0
- package/dist/types/utils/url.d.mts +2 -0
- package/dist/types/utils/words.d.mts +1 -0
- package/dist/utils.js +4475 -803
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +39737 -41318
- package/external/blessed-contrib/lib/widget/charts/line.js +172 -149
- package/package.json +41 -37
- package/shadow-bin/npm +0 -0
- package/shadow-bin/npx +0 -0
- package/shadow-bin/pnpm +0 -0
- package/shadow-bin/yarn +0 -0
- package/dist/types/commands/manifest/convert-gradle-to-facts.d.mts +0 -19
- package/dist/types/commands/manifest/convert-maven-to-facts.d.mts +0 -19
- package/dist/types/commands/manifest/convert-sbt-to-facts.d.mts +0 -22
- package/dist/types/commands/manifest/enumerate-workspaces.d.mts +0 -22
- package/dist/types/commands/manifest/expand-env-var-refs.d.mts +0 -9
- package/dist/types/sea/archive-paths.d.mts +0 -6
- package/external/@socketsecurity/registry/LICENSE +0 -21
- package/external/@socketsecurity/registry/README.md +0 -9
- package/external/@socketsecurity/registry/extensions.json +0 -28
- package/external/@socketsecurity/registry/external/@inquirer/confirm.js +0 -3165
- package/external/@socketsecurity/registry/external/@inquirer/input.js +0 -3202
- package/external/@socketsecurity/registry/external/@inquirer/password.js +0 -3307
- package/external/@socketsecurity/registry/external/@inquirer/search.js +0 -3519
- package/external/@socketsecurity/registry/external/@inquirer/select.js +0 -3655
- package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +0 -21406
- package/external/@socketsecurity/registry/external/@npmcli/package-json/lib/read-package.js +0 -183
- package/external/@socketsecurity/registry/external/@npmcli/package-json/lib/sort.js +0 -274
- package/external/@socketsecurity/registry/external/@npmcli/promise-spawn.js +0 -704
- package/external/@socketsecurity/registry/external/@socketregistry/is-unicode-supported.js +0 -54
- package/external/@socketsecurity/registry/external/@socketregistry/packageurl-js.js +0 -4516
- package/external/@socketsecurity/registry/external/@socketregistry/yocto-spinner.js +0 -453
- package/external/@socketsecurity/registry/external/@yarnpkg/extensions.js +0 -1406
- package/external/@socketsecurity/registry/external/browserslist.js +0 -20496
- package/external/@socketsecurity/registry/external/cacache.js +0 -16208
- package/external/@socketsecurity/registry/external/debug.js +0 -1163
- package/external/@socketsecurity/registry/external/fast-glob.js +0 -7994
- package/external/@socketsecurity/registry/external/fast-sort.js +0 -181
- package/external/@socketsecurity/registry/external/libnpmpack.js +0 -106271
- package/external/@socketsecurity/registry/external/make-fetch-happen.js +0 -38997
- package/external/@socketsecurity/registry/external/normalize-package-data.js +0 -5343
- package/external/@socketsecurity/registry/external/npm-package-arg.js +0 -5773
- package/external/@socketsecurity/registry/external/pacote.js +0 -74109
- package/external/@socketsecurity/registry/external/picomatch.js +0 -2307
- package/external/@socketsecurity/registry/external/semver.js +0 -2618
- package/external/@socketsecurity/registry/external/signal-exit.js +0 -336
- package/external/@socketsecurity/registry/external/spdx-correct.js +0 -1457
- package/external/@socketsecurity/registry/external/spdx-expression-parse.js +0 -1043
- package/external/@socketsecurity/registry/external/streaming-iterables.js +0 -326
- package/external/@socketsecurity/registry/external/validate-npm-package-name.js +0 -108
- package/external/@socketsecurity/registry/external/which.js +0 -405
- package/external/@socketsecurity/registry/external/yoctocolors-cjs.js +0 -101
- package/external/@socketsecurity/registry/index.js +0 -31
- package/external/@socketsecurity/registry/lib/agent.js +0 -390
- package/external/@socketsecurity/registry/lib/arrays.js +0 -89
- package/external/@socketsecurity/registry/lib/bin.js +0 -650
- package/external/@socketsecurity/registry/lib/constants/abort-controller.js +0 -15
- package/external/@socketsecurity/registry/lib/constants/abort-signal.js +0 -27
- package/external/@socketsecurity/registry/lib/constants/at-latest.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/biome-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/bun-lock.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/bun-lockb.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/bun.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ci.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/column-limit.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/copy-left-licenses.js +0 -27
- package/external/@socketsecurity/registry/lib/constants/darwin.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/dot-git-dir.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/dot-package-lock-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/dot-socket-dir.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/empty-file.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/empty-value.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/env.js +0 -59
- package/external/@socketsecurity/registry/lib/constants/eslint-config-js.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/esnext.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/exec-path.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cjs.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cmd.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cts.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-dts.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-js.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-lock.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-lockb.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-md.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-mjs.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-mts.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-ps1.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-yaml.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-yml.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/extensions-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/extensions.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/get-ipc.js +0 -10
- package/external/@socketsecurity/registry/lib/constants/gitignore.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/index.js +0 -139
- package/external/@socketsecurity/registry/lib/constants/ipc-handler.js +0 -19
- package/external/@socketsecurity/registry/lib/constants/ipc-object.js +0 -6
- package/external/@socketsecurity/registry/lib/constants/ipc-promise.js +0 -47
- package/external/@socketsecurity/registry/lib/constants/ipc-target.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/k-internals-symbol.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/latest.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-glob.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-original-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-original-glob.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-original.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/lifecycle-script-names.js +0 -18
- package/external/@socketsecurity/registry/lib/constants/loop-sentinel.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/maintained-node-versions.js +0 -47
- package/external/@socketsecurity/registry/lib/constants/manifest-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/mit.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-auth-token.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-debug-flags.js +0 -9
- package/external/@socketsecurity/registry/lib/constants/node-env.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-harden-flags.js +0 -29
- package/external/@socketsecurity/registry/lib/constants/node-modules-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-modules.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-no-warnings-flags.js +0 -16
- package/external/@socketsecurity/registry/lib/constants/node-version.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/npm-exec-path.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/npm-real-exec-path.js +0 -6
- package/external/@socketsecurity/registry/lib/constants/npm-shrinkwrap-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/npm.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/npx.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/overrides.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-default-node-range.js +0 -6
- package/external/@socketsecurity/registry/lib/constants/package-default-socket-categories.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-default-version.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-extensions.js +0 -47
- package/external/@socketsecurity/registry/lib/constants/package-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-lock-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/packument-cache.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/pacote-cache-path.js +0 -9
- package/external/@socketsecurity/registry/lib/constants/pnpm-exec-path.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/pnpm-lock-yaml.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/pnpm.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/pre-commit.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/readme-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/readme-glob.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/readme-md.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/registry-scope-delimiter.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/registry.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/resolutions.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-github-org.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-ipc-handshake.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-override-scope.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-public-api-token.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-npm-org.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-package-name.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-repo-name.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-scope.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-security-scope.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/spinner.js +0 -4
- package/external/@socketsecurity/registry/lib/constants/supports-node-compile-cache-api.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-compile-cache-env-var.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-disable-warning-flag.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-permission-flag.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-require-module.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/supports-node-run.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-process-send.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/ts-libs-available.js +0 -22
- package/external/@socketsecurity/registry/lib/constants/ts-types-available.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/tsconfig-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/undefined-token.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unknown-error.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unknown-value.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unlicenced.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unlicensed.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/utf8.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/vitest.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/vlt-lock-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/vlt.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/win32.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn-berry.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn-classic.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn-exec-path.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/yarn-lock.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn.js +0 -3
- package/external/@socketsecurity/registry/lib/debug.js +0 -264
- package/external/@socketsecurity/registry/lib/env.js +0 -62
- package/external/@socketsecurity/registry/lib/fs.js +0 -556
- package/external/@socketsecurity/registry/lib/functions.js +0 -20
- package/external/@socketsecurity/registry/lib/globs.js +0 -145
- package/external/@socketsecurity/registry/lib/json.js +0 -69
- package/external/@socketsecurity/registry/lib/logger.js +0 -534
- package/external/@socketsecurity/registry/lib/objects.js +0 -422
- package/external/@socketsecurity/registry/lib/packages.js +0 -1379
- package/external/@socketsecurity/registry/lib/path.js +0 -231
- package/external/@socketsecurity/registry/lib/promises.js +0 -286
- package/external/@socketsecurity/registry/lib/prompts.js +0 -63
- package/external/@socketsecurity/registry/lib/regexps.js +0 -23
- package/external/@socketsecurity/registry/lib/sorts.js +0 -70
- package/external/@socketsecurity/registry/lib/spawn.js +0 -252
- package/external/@socketsecurity/registry/lib/spinner.js +0 -205
- package/external/@socketsecurity/registry/lib/streams.js +0 -84
- package/external/@socketsecurity/registry/lib/strings.js +0 -235
- package/external/@socketsecurity/registry/lib/url.js +0 -68
- package/external/@socketsecurity/registry/lib/words.js +0 -45
- package/external/@socketsecurity/registry/manifest.json +0 -1875
|
@@ -1,556 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { isArray: ArrayIsArray } = Array
|
|
4
|
-
const { freeze: ObjectFreeze } = Object
|
|
5
|
-
|
|
6
|
-
const { defaultIgnore, getGlobMatcher } = /*@__PURE__*/ require('./globs')
|
|
7
|
-
const { jsonParse } = /*@__PURE__*/ require('./json')
|
|
8
|
-
const { naturalCompare } = /*@__PURE__*/ require('./sorts')
|
|
9
|
-
const { pathLikeToString } = /*@__PURE__*/ require('./path')
|
|
10
|
-
|
|
11
|
-
const defaultRemoveOptions = ObjectFreeze({
|
|
12
|
-
__proto__: null,
|
|
13
|
-
force: true,
|
|
14
|
-
maxRetries: 3,
|
|
15
|
-
recursive: true,
|
|
16
|
-
retryDelay: 200
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
let _fs
|
|
20
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
21
|
-
function getFs() {
|
|
22
|
-
if (_fs === undefined) {
|
|
23
|
-
// Use non-'node:' prefixed require to avoid Webpack errors.
|
|
24
|
-
// eslint-disable-next-line n/prefer-node-protocol
|
|
25
|
-
_fs = /*@__PURE__*/ require('fs')
|
|
26
|
-
}
|
|
27
|
-
return _fs
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let _path
|
|
31
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
32
|
-
function getPath() {
|
|
33
|
-
if (_path === undefined) {
|
|
34
|
-
// Use non-'node:' prefixed require to avoid Webpack errors.
|
|
35
|
-
// eslint-disable-next-line n/prefer-node-protocol
|
|
36
|
-
_path = /*@__PURE__*/ require('path')
|
|
37
|
-
}
|
|
38
|
-
return _path
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Find a file or directory by traversing up parent directories.
|
|
43
|
-
* @param {string | string[]} name - Name(s) to search for.
|
|
44
|
-
* @param {FindUpOptions} [options] - Search options.
|
|
45
|
-
* @returns {Promise<string | undefined>} Path to found file/directory.
|
|
46
|
-
* @typedef {{cwd?: string; onlyDirectories?: boolean; onlyFiles?: boolean; signal?: AbortSignal}} FindUpOptions
|
|
47
|
-
*/
|
|
48
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
49
|
-
async function findUp(name, options) {
|
|
50
|
-
const {
|
|
51
|
-
cwd = process.cwd(),
|
|
52
|
-
signal = /*@__PURE__*/ require('./constants/abort-signal')
|
|
53
|
-
} = { __proto__: null, ...options }
|
|
54
|
-
let { onlyDirectories = false, onlyFiles = true } = {
|
|
55
|
-
__proto__: null,
|
|
56
|
-
...options
|
|
57
|
-
}
|
|
58
|
-
if (onlyDirectories) {
|
|
59
|
-
onlyFiles = false
|
|
60
|
-
}
|
|
61
|
-
if (onlyFiles) {
|
|
62
|
-
onlyDirectories = false
|
|
63
|
-
}
|
|
64
|
-
const fs = getFs()
|
|
65
|
-
const path = getPath()
|
|
66
|
-
let dir = path.resolve(cwd)
|
|
67
|
-
const { root } = path.parse(dir)
|
|
68
|
-
const names = ArrayIsArray(name) ? name : [name]
|
|
69
|
-
while (dir && dir !== root) {
|
|
70
|
-
for (const n of names) {
|
|
71
|
-
if (signal?.aborted) {
|
|
72
|
-
return undefined
|
|
73
|
-
}
|
|
74
|
-
const thePath = path.join(dir, n)
|
|
75
|
-
try {
|
|
76
|
-
// eslint-disable-next-line no-await-in-loop
|
|
77
|
-
const stats = await fs.promises.stat(thePath)
|
|
78
|
-
if (!onlyDirectories && stats.isFile()) {
|
|
79
|
-
return thePath
|
|
80
|
-
}
|
|
81
|
-
if (!onlyFiles && stats.isDirectory()) {
|
|
82
|
-
return thePath
|
|
83
|
-
}
|
|
84
|
-
} catch {}
|
|
85
|
-
}
|
|
86
|
-
dir = path.dirname(dir)
|
|
87
|
-
}
|
|
88
|
-
return undefined
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Synchronously find a file or directory by traversing up parent directories.
|
|
93
|
-
* @param {string | string[]} name - Name(s) to search for.
|
|
94
|
-
* @param {Omit<FindUpOptions, 'signal'>} [options] - Search options.
|
|
95
|
-
* @returns {string | undefined} Path to found file/directory.
|
|
96
|
-
*/
|
|
97
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
98
|
-
function findUpSync(name, options) {
|
|
99
|
-
const { cwd = process.cwd() } = { __proto__: null, ...options }
|
|
100
|
-
let { onlyDirectories = false, onlyFiles = true } = {
|
|
101
|
-
__proto__: null,
|
|
102
|
-
...options
|
|
103
|
-
}
|
|
104
|
-
if (onlyDirectories) {
|
|
105
|
-
onlyFiles = false
|
|
106
|
-
}
|
|
107
|
-
if (onlyFiles) {
|
|
108
|
-
onlyDirectories = false
|
|
109
|
-
}
|
|
110
|
-
const fs = getFs()
|
|
111
|
-
const path = getPath()
|
|
112
|
-
let dir = path.resolve(cwd)
|
|
113
|
-
const { root } = path.parse(dir)
|
|
114
|
-
const names = ArrayIsArray(name) ? name : [name]
|
|
115
|
-
while (dir && dir !== root) {
|
|
116
|
-
for (const n of names) {
|
|
117
|
-
const thePath = path.join(dir, n)
|
|
118
|
-
try {
|
|
119
|
-
const stats = fs.statSync(thePath)
|
|
120
|
-
if (!onlyDirectories && stats.isFile()) {
|
|
121
|
-
return thePath
|
|
122
|
-
}
|
|
123
|
-
if (!onlyFiles && stats.isDirectory()) {
|
|
124
|
-
return thePath
|
|
125
|
-
}
|
|
126
|
-
} catch {}
|
|
127
|
-
}
|
|
128
|
-
dir = path.dirname(dir)
|
|
129
|
-
}
|
|
130
|
-
return undefined
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Process directory entries and filter for directories.
|
|
135
|
-
* @param {import('fs').Dirent[]} dirents - Directory entries to process.
|
|
136
|
-
* @param {ReadDirOptions} [options] - Options for filtering and sorting.
|
|
137
|
-
* @returns {string[]} Array of directory names.
|
|
138
|
-
* @private
|
|
139
|
-
*/
|
|
140
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
141
|
-
function innerReadDirNames(dirents, options) {
|
|
142
|
-
const {
|
|
143
|
-
ignore,
|
|
144
|
-
includeEmpty = false,
|
|
145
|
-
sort = true
|
|
146
|
-
} = { __proto__: null, ...options }
|
|
147
|
-
const path = getPath()
|
|
148
|
-
const names = dirents
|
|
149
|
-
.filter(
|
|
150
|
-
d =>
|
|
151
|
-
d.isDirectory() &&
|
|
152
|
-
(includeEmpty ||
|
|
153
|
-
!isDirEmptySync(path.join(d.parentPath, d.name), { ignore }))
|
|
154
|
-
)
|
|
155
|
-
.map(d => d.name)
|
|
156
|
-
return sort ? names.sort(naturalCompare) : names
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Check if a path is a directory synchronously.
|
|
161
|
-
* @param {import('fs').PathLike} filepath - Path to check.
|
|
162
|
-
* @returns {boolean} True if the path is a directory.
|
|
163
|
-
*/
|
|
164
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
165
|
-
function isDirSync(filepath) {
|
|
166
|
-
const fs = getFs()
|
|
167
|
-
return fs.existsSync(filepath) && !!safeStatsSync(filepath)?.isDirectory()
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Check if a directory is empty synchronously.
|
|
172
|
-
* @param {import('fs').PathLike} dirname - Directory path to check.
|
|
173
|
-
* @param {IsDirEmptyOptions} [options] - Options with ignore patterns.
|
|
174
|
-
* @returns {boolean} True if the directory is empty or only contains ignored files.
|
|
175
|
-
* @typedef {{ignore?: string[] | readonly string[]}} IsDirEmptyOptions
|
|
176
|
-
*/
|
|
177
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
178
|
-
function isDirEmptySync(dirname, options) {
|
|
179
|
-
const { ignore = defaultIgnore } = { __proto__: null, ...options }
|
|
180
|
-
const fs = getFs()
|
|
181
|
-
try {
|
|
182
|
-
const files = fs.readdirSync(dirname)
|
|
183
|
-
const { length } = files
|
|
184
|
-
if (length === 0) {
|
|
185
|
-
return true
|
|
186
|
-
}
|
|
187
|
-
const matcher = getGlobMatcher(ignore, { cwd: pathLikeToString(dirname) })
|
|
188
|
-
let ignoredCount = 0
|
|
189
|
-
for (let i = 0; i < length; i += 1) {
|
|
190
|
-
if (matcher(files[i])) {
|
|
191
|
-
ignoredCount += 1
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return ignoredCount === length
|
|
195
|
-
} catch (e) {
|
|
196
|
-
return e?.code === 'ENOENT'
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Check if a path is a symbolic link synchronously.
|
|
202
|
-
* @param {import('fs').PathLike} filepath - Path to check.
|
|
203
|
-
* @returns {boolean} True if the path is a symbolic link.
|
|
204
|
-
*/
|
|
205
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
206
|
-
function isSymLinkSync(filepath) {
|
|
207
|
-
const fs = getFs()
|
|
208
|
-
try {
|
|
209
|
-
return fs.lstatSync(filepath).isSymbolicLink()
|
|
210
|
-
} catch {}
|
|
211
|
-
return false
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Read directory names asynchronously with filtering and sorting.
|
|
216
|
-
* @param {import('fs').PathLike} dirname - Directory to read.
|
|
217
|
-
* @param {ReadDirOptions} [options] - Options for filtering and sorting.
|
|
218
|
-
* @returns {Promise<string[]>} Array of directory names.
|
|
219
|
-
* @typedef {{ignore?: string[] | readonly string[]; includeEmpty?: boolean; sort?: boolean}} ReadDirOptions
|
|
220
|
-
*/
|
|
221
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
222
|
-
async function readDirNames(dirname, options) {
|
|
223
|
-
const fs = getFs()
|
|
224
|
-
try {
|
|
225
|
-
return innerReadDirNames(
|
|
226
|
-
await fs.promises.readdir(dirname, {
|
|
227
|
-
__proto__: null,
|
|
228
|
-
withFileTypes: true
|
|
229
|
-
}),
|
|
230
|
-
options
|
|
231
|
-
)
|
|
232
|
-
} catch {}
|
|
233
|
-
return []
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Read directory names synchronously with filtering and sorting.
|
|
238
|
-
* @param {import('fs').PathLike} dirname - Directory to read.
|
|
239
|
-
* @param {ReadDirOptions} [options] - Options for filtering and sorting.
|
|
240
|
-
* @returns {string[]} Array of directory names.
|
|
241
|
-
*/
|
|
242
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
243
|
-
function readDirNamesSync(dirname, options) {
|
|
244
|
-
const fs = getFs()
|
|
245
|
-
try {
|
|
246
|
-
return innerReadDirNames(
|
|
247
|
-
fs.readdirSync(dirname, { __proto__: null, withFileTypes: true }),
|
|
248
|
-
options
|
|
249
|
-
)
|
|
250
|
-
} catch {}
|
|
251
|
-
return []
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Read a file as binary data asynchronously.
|
|
256
|
-
* @param {import('fs').PathLike | import('fs/promises').FileHandle} filepath - Path to the file.
|
|
257
|
-
* @param {import('fs').ReadFileOptions} [options] - Read options.
|
|
258
|
-
* @returns {Promise<Buffer>} The file contents as a Buffer.
|
|
259
|
-
*/
|
|
260
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
261
|
-
async function readFileBinary(filepath, options) {
|
|
262
|
-
const fs = getFs()
|
|
263
|
-
return await fs.promises.readFile(filepath, {
|
|
264
|
-
signal: /*@__PURE__*/ require('./constants/abort-signal'),
|
|
265
|
-
...options,
|
|
266
|
-
encoding: 'binary'
|
|
267
|
-
})
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Read a file as UTF-8 text asynchronously.
|
|
272
|
-
* @param {import('fs').PathLike | import('fs/promises').FileHandle} filepath - Path to the file.
|
|
273
|
-
* @param {import('fs').ReadFileOptions} [options] - Read options.
|
|
274
|
-
* @returns {Promise<string>} The file contents as a string.
|
|
275
|
-
*/
|
|
276
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
277
|
-
async function readFileUtf8(filepath, options) {
|
|
278
|
-
const fs = getFs()
|
|
279
|
-
return await fs.promises.readFile(filepath, {
|
|
280
|
-
signal: /*@__PURE__*/ require('./constants/abort-signal'),
|
|
281
|
-
...options,
|
|
282
|
-
encoding: 'utf8'
|
|
283
|
-
})
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Read and parse a JSON file asynchronously.
|
|
288
|
-
* @param {import('fs').PathLike} filepath - Path to the JSON file.
|
|
289
|
-
* @param {ReadJsonOptions} [options] - Read and parse options.
|
|
290
|
-
* @returns {Promise<any>} The parsed JSON content.
|
|
291
|
-
* @typedef {{encoding?: string; throws?: boolean; reviver?: Function} & import('fs').ReadFileOptions} ReadJsonOptions
|
|
292
|
-
*/
|
|
293
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
294
|
-
async function readJson(filepath, options) {
|
|
295
|
-
if (typeof options === 'string') {
|
|
296
|
-
options = { encoding: options }
|
|
297
|
-
}
|
|
298
|
-
const { reviver, throws, ...fsOptions } = { __proto__: null, ...options }
|
|
299
|
-
const shouldThrow = throws === undefined || !!throws
|
|
300
|
-
const fs = getFs()
|
|
301
|
-
let content = ''
|
|
302
|
-
try {
|
|
303
|
-
content = await fs.promises.readFile(filepath, {
|
|
304
|
-
__proto__: null,
|
|
305
|
-
encoding: 'utf8',
|
|
306
|
-
...fsOptions
|
|
307
|
-
})
|
|
308
|
-
} catch (e) {
|
|
309
|
-
if (shouldThrow) {
|
|
310
|
-
throw e
|
|
311
|
-
}
|
|
312
|
-
return null
|
|
313
|
-
}
|
|
314
|
-
return jsonParse(content, {
|
|
315
|
-
filepath,
|
|
316
|
-
reviver,
|
|
317
|
-
throws: shouldThrow
|
|
318
|
-
})
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Read and parse a JSON file synchronously.
|
|
323
|
-
* @param {import('fs').PathLike} filepath - Path to the JSON file.
|
|
324
|
-
* @param {ReadJsonOptions} [options] - Read and parse options.
|
|
325
|
-
* @returns {any} The parsed JSON content.
|
|
326
|
-
*/
|
|
327
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
328
|
-
function readJsonSync(filepath, options) {
|
|
329
|
-
if (typeof options === 'string') {
|
|
330
|
-
options = { encoding: options }
|
|
331
|
-
}
|
|
332
|
-
const { reviver, throws, ...fsOptions } = { __proto__: null, ...options }
|
|
333
|
-
const shouldThrow = throws === undefined || !!throws
|
|
334
|
-
const fs = getFs()
|
|
335
|
-
let content = ''
|
|
336
|
-
try {
|
|
337
|
-
content = fs.readFileSync(filepath, {
|
|
338
|
-
__proto__: null,
|
|
339
|
-
encoding: 'utf8',
|
|
340
|
-
...fsOptions
|
|
341
|
-
})
|
|
342
|
-
} catch (e) {
|
|
343
|
-
if (shouldThrow) {
|
|
344
|
-
throw e
|
|
345
|
-
}
|
|
346
|
-
return null
|
|
347
|
-
}
|
|
348
|
-
return jsonParse(content, {
|
|
349
|
-
filepath,
|
|
350
|
-
reviver,
|
|
351
|
-
throws: shouldThrow
|
|
352
|
-
})
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Remove a file or directory asynchronously.
|
|
357
|
-
* @param {import('fs').PathLike} filepath - Path to remove.
|
|
358
|
-
* @param {import('fs').RmOptions} [options] - Remove options.
|
|
359
|
-
* @returns {Promise<void>}
|
|
360
|
-
*/
|
|
361
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
362
|
-
async function remove(filepath, options) {
|
|
363
|
-
// Attempt to workaround occasional ENOTEMPTY errors in Windows.
|
|
364
|
-
// https://github.com/jprichardson/node-fs-extra/issues/532#issuecomment-1178360589
|
|
365
|
-
const fs = getFs()
|
|
366
|
-
await fs.promises.rm(filepath, {
|
|
367
|
-
__proto__: null,
|
|
368
|
-
...defaultRemoveOptions,
|
|
369
|
-
...options
|
|
370
|
-
})
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Remove a file or directory synchronously.
|
|
375
|
-
* @param {import('fs').PathLike} filepath - Path to remove.
|
|
376
|
-
* @param {import('fs').RmOptions} [options] - Remove options.
|
|
377
|
-
* @returns {void}
|
|
378
|
-
*/
|
|
379
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
380
|
-
function removeSync(filepath, options) {
|
|
381
|
-
const fs = getFs()
|
|
382
|
-
fs.rmSync(filepath, {
|
|
383
|
-
__proto__: null,
|
|
384
|
-
...defaultRemoveOptions,
|
|
385
|
-
...options
|
|
386
|
-
})
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Safely read a file asynchronously, returning undefined on error.
|
|
391
|
-
* @param {import('fs').PathLike | import('fs/promises').FileHandle} filepath - Path to the file.
|
|
392
|
-
* @param {import('fs').ReadFileOptions | string} [options] - Read options or encoding.
|
|
393
|
-
* @returns {Promise<string | undefined>} The file contents or undefined if read fails.
|
|
394
|
-
*/
|
|
395
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
396
|
-
async function safeReadFile(filepath, options) {
|
|
397
|
-
const fs = getFs()
|
|
398
|
-
try {
|
|
399
|
-
return await fs.promises.readFile(filepath, {
|
|
400
|
-
encoding: 'utf8',
|
|
401
|
-
signal: /*@__PURE__*/ require('./constants/abort-signal'),
|
|
402
|
-
...(typeof options === 'string' ? { encoding: options } : options)
|
|
403
|
-
})
|
|
404
|
-
} catch {}
|
|
405
|
-
return undefined
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Safely get file stats synchronously, returning undefined on error.
|
|
410
|
-
* @param {import('fs').PathLike} filepath - Path to stat.
|
|
411
|
-
* @param {import('fs').StatSyncOptions} [options] - Stat options.
|
|
412
|
-
* @returns {import('fs').Stats | undefined} File stats or undefined if stat fails.
|
|
413
|
-
*/
|
|
414
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
415
|
-
function safeStatsSync(filepath, options) {
|
|
416
|
-
const fs = getFs()
|
|
417
|
-
try {
|
|
418
|
-
return fs.statSync(filepath, {
|
|
419
|
-
__proto__: null,
|
|
420
|
-
throwIfNoEntry: false,
|
|
421
|
-
...options
|
|
422
|
-
})
|
|
423
|
-
} catch {}
|
|
424
|
-
return undefined
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Safely read a file synchronously, returning undefined on error.
|
|
429
|
-
* @param {import('fs').PathOrFileDescriptor} filepath - Path to the file.
|
|
430
|
-
* @param {import('fs').ReadFileOptions | string} [options] - Read options or encoding.
|
|
431
|
-
* @returns {string | Buffer | undefined} The file contents or undefined if read fails.
|
|
432
|
-
*/
|
|
433
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
434
|
-
function safeReadFileSync(filepath, options) {
|
|
435
|
-
const fs = getFs()
|
|
436
|
-
try {
|
|
437
|
-
return fs.readFileSync(filepath, {
|
|
438
|
-
__proto__: null,
|
|
439
|
-
encoding: 'utf8',
|
|
440
|
-
...(typeof options === 'string' ? { encoding: options } : options)
|
|
441
|
-
})
|
|
442
|
-
} catch {}
|
|
443
|
-
return undefined
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Stringify JSON with custom formatting options.
|
|
448
|
-
* @param {any} json - The JSON object to stringify.
|
|
449
|
-
* @param {string} [EOL='\n'] - End of line character.
|
|
450
|
-
* @param {boolean} [finalEOL=true] - Whether to add final EOL.
|
|
451
|
-
* @param {Function | null} [replacer=null] - JSON replacer function.
|
|
452
|
-
* @param {number | string} [spaces=2] - Indentation spaces.
|
|
453
|
-
* @returns {string} The formatted JSON string.
|
|
454
|
-
*/
|
|
455
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
456
|
-
function stringify(
|
|
457
|
-
json,
|
|
458
|
-
EOL = '\n',
|
|
459
|
-
finalEOL = true,
|
|
460
|
-
replacer = null,
|
|
461
|
-
spaces = 2
|
|
462
|
-
) {
|
|
463
|
-
const EOF = finalEOL ? EOL : ''
|
|
464
|
-
const str = JSON.stringify(json, replacer, spaces)
|
|
465
|
-
return `${str.replace(/\n/g, EOL)}${EOF}`
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Generate a unique filepath by prepending underscores if the path exists.
|
|
470
|
-
* @param {import('fs').PathLike} filepath - The desired filepath.
|
|
471
|
-
* @returns {string} A unique filepath that doesn't exist.
|
|
472
|
-
*/
|
|
473
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
474
|
-
function uniqueSync(filepath) {
|
|
475
|
-
const fs = getFs()
|
|
476
|
-
const path = getPath()
|
|
477
|
-
const dirname = path.dirname(filepath)
|
|
478
|
-
let basename = path.basename(filepath)
|
|
479
|
-
while (fs.existsSync(`${dirname}/${basename}`)) {
|
|
480
|
-
basename = `_${basename}`
|
|
481
|
-
}
|
|
482
|
-
return path.join(dirname, basename)
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Write JSON content to a file asynchronously with formatting.
|
|
487
|
-
* @param {import('fs').PathLike} filepath - Path to write to.
|
|
488
|
-
* @param {any} jsonContent - The JSON content to write.
|
|
489
|
-
* @param {WriteJsonOptions} [options] - Write and format options.
|
|
490
|
-
* @returns {Promise<void>}
|
|
491
|
-
* @typedef {{EOL?: string; finalEOL?: boolean; replacer?: Function; spaces?: number | string} & import('fs').WriteFileOptions} WriteJsonOptions
|
|
492
|
-
*/
|
|
493
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
494
|
-
async function writeJson(filepath, jsonContent, options) {
|
|
495
|
-
if (typeof options === 'string') {
|
|
496
|
-
options = { encoding: options }
|
|
497
|
-
}
|
|
498
|
-
const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {
|
|
499
|
-
__proto__: null,
|
|
500
|
-
...options
|
|
501
|
-
}
|
|
502
|
-
const fs = getFs()
|
|
503
|
-
const jsonString = stringify(jsonContent, EOL, finalEOL, replacer, spaces)
|
|
504
|
-
await fs.promises.writeFile(filepath, jsonString, {
|
|
505
|
-
__proto__: null,
|
|
506
|
-
encoding: 'utf8',
|
|
507
|
-
...fsOptions
|
|
508
|
-
})
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Write JSON content to a file synchronously with formatting.
|
|
513
|
-
* @param {import('fs').PathLike} filepath - Path to write to.
|
|
514
|
-
* @param {any} jsonContent - The JSON content to write.
|
|
515
|
-
* @param {WriteJsonOptions} [options] - Write and format options.
|
|
516
|
-
* @returns {void}
|
|
517
|
-
*/
|
|
518
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
519
|
-
function writeJsonSync(filepath, jsonContent, options) {
|
|
520
|
-
if (typeof options === 'string') {
|
|
521
|
-
options = { encoding: options }
|
|
522
|
-
}
|
|
523
|
-
const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {
|
|
524
|
-
__proto__: null,
|
|
525
|
-
...options
|
|
526
|
-
}
|
|
527
|
-
const fs = getFs()
|
|
528
|
-
const jsonString = stringify(jsonContent, EOL, finalEOL, replacer, spaces)
|
|
529
|
-
fs.writeFileSync(filepath, jsonString, {
|
|
530
|
-
__proto__: null,
|
|
531
|
-
encoding: 'utf8',
|
|
532
|
-
...fsOptions
|
|
533
|
-
})
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
module.exports = {
|
|
537
|
-
findUp,
|
|
538
|
-
findUpSync,
|
|
539
|
-
isDirSync,
|
|
540
|
-
isDirEmptySync,
|
|
541
|
-
isSymLinkSync,
|
|
542
|
-
readDirNames,
|
|
543
|
-
readDirNamesSync,
|
|
544
|
-
readFileBinary,
|
|
545
|
-
readFileUtf8,
|
|
546
|
-
readJson,
|
|
547
|
-
readJsonSync,
|
|
548
|
-
remove,
|
|
549
|
-
removeSync,
|
|
550
|
-
safeReadFile,
|
|
551
|
-
safeReadFileSync,
|
|
552
|
-
safeStatsSync,
|
|
553
|
-
uniqueSync,
|
|
554
|
-
writeJson,
|
|
555
|
-
writeJsonSync
|
|
556
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Wrap an async function to silently catch and ignore errors.
|
|
5
|
-
* @param {Function} fn - The async function to wrap.
|
|
6
|
-
* @returns {Function} The wrapped async function that returns undefined on error.
|
|
7
|
-
*/
|
|
8
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
9
|
-
function silentWrapAsync(fn) {
|
|
10
|
-
return async (...args) => {
|
|
11
|
-
try {
|
|
12
|
-
return await fn(...args)
|
|
13
|
-
} catch {}
|
|
14
|
-
return undefined
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
silentWrapAsync
|
|
20
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { freeze: ObjectFreeze } = Object
|
|
4
|
-
|
|
5
|
-
const defaultIgnore = ObjectFreeze([
|
|
6
|
-
// Most of these ignored files can be included specifically if included in the
|
|
7
|
-
// files globs. Exceptions to this are:
|
|
8
|
-
// https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files
|
|
9
|
-
// These can NOT be included.
|
|
10
|
-
// https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L280
|
|
11
|
-
'**/.git',
|
|
12
|
-
'**/.npmrc',
|
|
13
|
-
// '**/bun.lockb?',
|
|
14
|
-
'**/node_modules',
|
|
15
|
-
// '**/package-lock.json',
|
|
16
|
-
// '**/pnpm-lock.ya?ml',
|
|
17
|
-
// '**/yarn.lock',
|
|
18
|
-
// Include npm-packlist defaults:
|
|
19
|
-
// https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L15-L38
|
|
20
|
-
'**/.DS_Store',
|
|
21
|
-
'**/.gitignore',
|
|
22
|
-
'**/.hg',
|
|
23
|
-
'**/.lock-wscript',
|
|
24
|
-
'**/.npmignore',
|
|
25
|
-
'**/.svn',
|
|
26
|
-
'**/.wafpickle-*',
|
|
27
|
-
'**/.*.swp',
|
|
28
|
-
'**/._*/**',
|
|
29
|
-
'**/archived-packages/**',
|
|
30
|
-
'**/build/config.gypi',
|
|
31
|
-
'**/CVS',
|
|
32
|
-
'**/npm-debug.log',
|
|
33
|
-
'**/*.orig',
|
|
34
|
-
// Inline generic socket-registry .gitignore entries.
|
|
35
|
-
'**/.env',
|
|
36
|
-
'**/.eslintcache',
|
|
37
|
-
'**/.nvm',
|
|
38
|
-
'**/.tap',
|
|
39
|
-
'**/.vscode',
|
|
40
|
-
'**/*.tsbuildinfo',
|
|
41
|
-
'**/Thumbs.db',
|
|
42
|
-
// Inline additional ignores.
|
|
43
|
-
'**/bower_components'
|
|
44
|
-
])
|
|
45
|
-
|
|
46
|
-
let _picomatch
|
|
47
|
-
/**
|
|
48
|
-
* Lazily load the picomatch module.
|
|
49
|
-
* @returns {import('picomatch')} The picomatch module.
|
|
50
|
-
* @private
|
|
51
|
-
*/
|
|
52
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
53
|
-
function getPicomatch() {
|
|
54
|
-
if (_picomatch === undefined) {
|
|
55
|
-
// The 'picomatch' package is browser safe.
|
|
56
|
-
_picomatch = /*@__PURE__*/ require('../external/picomatch')
|
|
57
|
-
}
|
|
58
|
-
return _picomatch
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let _fastGlob
|
|
62
|
-
/**
|
|
63
|
-
* Lazily load the fast-glob module.
|
|
64
|
-
* @returns {import('fast-glob')} The fast-glob module.
|
|
65
|
-
* @private
|
|
66
|
-
*/
|
|
67
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
68
|
-
function getFastGlob() {
|
|
69
|
-
if (_fastGlob === undefined) {
|
|
70
|
-
_fastGlob = /*@__PURE__*/ require('../external/fast-glob')
|
|
71
|
-
}
|
|
72
|
-
return _fastGlob
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Create a stream of license file paths matching glob patterns.
|
|
77
|
-
* @param {string} dirname - The directory to search in.
|
|
78
|
-
* @param {{ignore?: string[]; ignoreOriginals?: boolean; recursive?: boolean}} [options] - Glob options.
|
|
79
|
-
* @returns {import('stream').Stream} Stream of matching file paths.
|
|
80
|
-
*/
|
|
81
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
82
|
-
function globStreamLicenses(dirname, options) {
|
|
83
|
-
const {
|
|
84
|
-
ignore: ignoreOpt,
|
|
85
|
-
ignoreOriginals,
|
|
86
|
-
recursive,
|
|
87
|
-
...globOptions
|
|
88
|
-
} = { __proto__: null, ...options }
|
|
89
|
-
const ignore = [
|
|
90
|
-
...(Array.isArray(ignoreOpt) ? ignoreOpt : defaultIgnore),
|
|
91
|
-
'**/*.{cjs,cts,js,json,mjs,mts,ts}'
|
|
92
|
-
]
|
|
93
|
-
if (ignoreOriginals) {
|
|
94
|
-
ignore.push(
|
|
95
|
-
/*@__PURE__*/ require('./constants/license-original-glob-recursive')
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
const fastGlob = getFastGlob()
|
|
99
|
-
return fastGlob.globStream(
|
|
100
|
-
[
|
|
101
|
-
recursive
|
|
102
|
-
? /*@__PURE__*/ require('./constants/license-glob-recursive')
|
|
103
|
-
: /*@__PURE__*/ require('./constants/license-glob')
|
|
104
|
-
],
|
|
105
|
-
{
|
|
106
|
-
__proto__: null,
|
|
107
|
-
absolute: true,
|
|
108
|
-
caseSensitiveMatch: false,
|
|
109
|
-
cwd: dirname,
|
|
110
|
-
...globOptions,
|
|
111
|
-
...(ignore ? { ignore } : {})
|
|
112
|
-
}
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const matcherCache = new Map()
|
|
117
|
-
/**
|
|
118
|
-
* Get a cached glob matcher function.
|
|
119
|
-
* @param {string | string[]} glob - Glob pattern(s) to match.
|
|
120
|
-
* @param {Object} [options] - Picomatch options.
|
|
121
|
-
* @returns {Function} The glob matcher function.
|
|
122
|
-
*/
|
|
123
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
124
|
-
function getGlobMatcher(glob, options) {
|
|
125
|
-
const patterns = Array.isArray(glob) ? glob : [glob]
|
|
126
|
-
const key = JSON.stringify({ patterns, options })
|
|
127
|
-
let matcher = matcherCache.get(key)
|
|
128
|
-
if (matcher) {
|
|
129
|
-
return matcher
|
|
130
|
-
}
|
|
131
|
-
const picomatch = getPicomatch()
|
|
132
|
-
matcher = picomatch(patterns, {
|
|
133
|
-
dot: true,
|
|
134
|
-
nocase: true,
|
|
135
|
-
...options
|
|
136
|
-
})
|
|
137
|
-
matcherCache.set(key, matcher)
|
|
138
|
-
return matcher
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
module.exports = {
|
|
142
|
-
defaultIgnore,
|
|
143
|
-
getGlobMatcher,
|
|
144
|
-
globStreamLicenses
|
|
145
|
-
}
|