@socketsecurity/cli-with-sentry 1.16.1 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -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,252 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { isArray: ArrayIsArray } = Array
|
|
4
|
-
const { hasOwn: ObjectHasOwn, keys: ObjectKeys } = Object
|
|
5
|
-
|
|
6
|
-
const { getOwn } = /*@__PURE__*/ require('./objects')
|
|
7
|
-
const { stripAnsi } = /*@__PURE__*/ require('./strings')
|
|
8
|
-
|
|
9
|
-
const windowsScriptExtRegExp = /\.(?:cmd|bat|ps1)$/i
|
|
10
|
-
|
|
11
|
-
let _child_process
|
|
12
|
-
/**
|
|
13
|
-
* Lazily load the child_process module.
|
|
14
|
-
* @returns {import('child_process')} The Node.js child_process module.
|
|
15
|
-
*/
|
|
16
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
17
|
-
function getChildProcess() {
|
|
18
|
-
if (_child_process === undefined) {
|
|
19
|
-
// Use non-'node:' prefixed require to avoid Webpack errors.
|
|
20
|
-
// eslint-disable-next-line n/prefer-node-protocol
|
|
21
|
-
_child_process = /*@__PURE__*/ require('child_process')
|
|
22
|
-
}
|
|
23
|
-
return _child_process
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let _npmCliPromiseSpawn
|
|
27
|
-
/**
|
|
28
|
-
* Lazily load the promise-spawn module for async process spawning.
|
|
29
|
-
* @returns {Function} The promise-spawn module.
|
|
30
|
-
*/
|
|
31
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
32
|
-
function getNpmcliPromiseSpawn() {
|
|
33
|
-
if (_npmCliPromiseSpawn === undefined) {
|
|
34
|
-
_npmCliPromiseSpawn = /*@__PURE__*/ require('../external/@npmcli/promise-spawn')
|
|
35
|
-
}
|
|
36
|
-
return _npmCliPromiseSpawn
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let _path
|
|
40
|
-
/**
|
|
41
|
-
* Lazily load the path module to avoid Webpack errors.
|
|
42
|
-
* @returns {import('path')} The Node.js path module.
|
|
43
|
-
*/
|
|
44
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
45
|
-
function getPath() {
|
|
46
|
-
if (_path === undefined) {
|
|
47
|
-
// Use non-'node:' prefixed require to avoid Webpack errors.
|
|
48
|
-
// eslint-disable-next-line n/prefer-node-protocol
|
|
49
|
-
_path = /*@__PURE__*/ require('path')
|
|
50
|
-
}
|
|
51
|
-
return _path
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Check if a value is a spawn error.
|
|
56
|
-
* @param {any} value - The value to check.
|
|
57
|
-
* @returns {value is SpawnError} True if the value is a spawn error.
|
|
58
|
-
* @typedef {Object} SpawnError
|
|
59
|
-
* @property {string[]} args - Command arguments.
|
|
60
|
-
* @property {string} cmd - Command that was run.
|
|
61
|
-
* @property {number} code - Exit code.
|
|
62
|
-
* @property {string} name - Error name.
|
|
63
|
-
* @property {string} message - Error message.
|
|
64
|
-
* @property {AbortSignal | null} signal - Abort signal.
|
|
65
|
-
* @property {string} stack - Stack trace.
|
|
66
|
-
* @property {string | Buffer} stderr - Standard error output.
|
|
67
|
-
* @property {string | Buffer} stdout - Standard output.
|
|
68
|
-
*/
|
|
69
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
70
|
-
function isSpawnError(value) {
|
|
71
|
-
return (
|
|
72
|
-
value !== null &&
|
|
73
|
-
typeof value === 'object' &&
|
|
74
|
-
ObjectHasOwn(value, 'code') &&
|
|
75
|
-
typeof value.code === 'number' &&
|
|
76
|
-
ObjectHasOwn(value, 'cmd') &&
|
|
77
|
-
typeof value.code === 'string' &&
|
|
78
|
-
ObjectHasOwn(value, 'args') &&
|
|
79
|
-
ArrayIsArray(value.args)
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Check if stdio configuration matches a specific type.
|
|
85
|
-
* @param {string | string[] | readonly string[]} stdio - The stdio configuration.
|
|
86
|
-
* @param {import('child_process').IOType | 'ipc' | Array<import('child_process').IOType | 'ipc'>} type - The type to check.
|
|
87
|
-
* @returns {boolean} True if the stdio matches the type.
|
|
88
|
-
*/
|
|
89
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
90
|
-
function isStdioType(stdio, type) {
|
|
91
|
-
return (
|
|
92
|
-
stdio === type ||
|
|
93
|
-
((stdio === null || stdio === undefined) && type === 'pipe') ||
|
|
94
|
-
(ArrayIsArray(stdio) &&
|
|
95
|
-
stdio.length > 2 &&
|
|
96
|
-
stdio[0] === type &&
|
|
97
|
-
stdio[1] === type &&
|
|
98
|
-
stdio[2] === type)
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Strip ANSI escape codes from spawn result stdout and stderr.
|
|
104
|
-
* @param {{ stdout?: string; stderr?: string }} result - The spawn result.
|
|
105
|
-
* @returns {{ stdout?: string; stderr?: string }} The result with ANSI codes stripped.
|
|
106
|
-
*/
|
|
107
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
108
|
-
function stripAnsiFromSpawnResult(result) {
|
|
109
|
-
const { stderr, stdout } = result
|
|
110
|
-
if (typeof stdout === 'string') {
|
|
111
|
-
result.stdout = stripAnsi(stdout)
|
|
112
|
-
}
|
|
113
|
-
if (typeof stderr === 'string') {
|
|
114
|
-
result.stderr = stripAnsi(stderr)
|
|
115
|
-
}
|
|
116
|
-
return result
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
120
|
-
/**
|
|
121
|
-
* Spawn a child process with enhanced error handling and output capture.
|
|
122
|
-
* @template {SpawnOptions} O
|
|
123
|
-
* @param {string} cmd - The command to execute.
|
|
124
|
-
* @param {string[] | readonly string[]} [args=[]] - Arguments to pass to the command.
|
|
125
|
-
* @param {O} [options] - Spawn options.
|
|
126
|
-
* @param {Record<any, any>} [extra] - Additional data to include in the result.
|
|
127
|
-
* @returns {SpawnResult<O extends {stdioString: false} ? Buffer : string, typeof extra>} Command result with process handle.
|
|
128
|
-
* @typedef {import('./objects').Remap<import('child_process').SpawnOptions & {spinner?: import('./spinner').Spinner; stdioString?: boolean; stripAnsi?: boolean}>} SpawnOptions
|
|
129
|
-
* @typedef {Promise<SpawnStdioResult> & {process: import('child_process').ChildProcess; stdin: import('stream').Writable | null}} SpawnResult
|
|
130
|
-
* @typedef {{cmd: string; args: string[] | readonly string[]; code: number; signal: AbortSignal | null; stdout: string | Buffer; stderr: string | Buffer}} SpawnStdioResult
|
|
131
|
-
*/
|
|
132
|
-
function spawn(cmd, args, options, extra) {
|
|
133
|
-
// On Windows with shell: true, use just the command name, not the full path.
|
|
134
|
-
// When shell: true is used, Windows cmd.exe has issues executing full paths to
|
|
135
|
-
// .cmd/.bat files (e.g., 'C:\...\pnpm.cmd'), often resulting in ENOENT errors.
|
|
136
|
-
// Using just the command name (e.g., 'pnpm') allows cmd.exe to find it via PATH.
|
|
137
|
-
// See: https://github.com/nodejs/node/issues/3675
|
|
138
|
-
// Check for .cmd, .bat, .ps1 extensions that indicate a Windows script.
|
|
139
|
-
const shell = getOwn(options, 'shell')
|
|
140
|
-
const WIN32 = /*@__PURE__*/ require('./constants/win32')
|
|
141
|
-
if (WIN32 && shell && windowsScriptExtRegExp.test(cmd)) {
|
|
142
|
-
const path = getPath()
|
|
143
|
-
// Extract just the command name without path and extension.
|
|
144
|
-
cmd = path.basename(cmd, path.extname(cmd))
|
|
145
|
-
}
|
|
146
|
-
const {
|
|
147
|
-
spinner = /*@__PURE__*/ require('./constants/spinner'),
|
|
148
|
-
stripAnsi: shouldStripAnsi = true,
|
|
149
|
-
...spawnOptions
|
|
150
|
-
} = { __proto__: null, ...options }
|
|
151
|
-
const { env, stdio, stdioString = true } = spawnOptions
|
|
152
|
-
// The stdio option can be a string or an array.
|
|
153
|
-
// https://nodejs.org/api/child_process.html#optionsstdio
|
|
154
|
-
const wasSpinning = !!spinner?.isSpinning
|
|
155
|
-
const shouldStopSpinner =
|
|
156
|
-
wasSpinning && !isStdioType(stdio, 'ignore') && !isStdioType(stdio, 'pipe')
|
|
157
|
-
const shouldRestartSpinner = shouldStopSpinner
|
|
158
|
-
if (shouldStopSpinner) {
|
|
159
|
-
spinner.stop()
|
|
160
|
-
}
|
|
161
|
-
const npmCliPromiseSpawn = getNpmcliPromiseSpawn()
|
|
162
|
-
let spawnPromise = npmCliPromiseSpawn(
|
|
163
|
-
cmd,
|
|
164
|
-
args,
|
|
165
|
-
{
|
|
166
|
-
signal: /*@__PURE__*/ require('./constants/abort-signal'),
|
|
167
|
-
...spawnOptions,
|
|
168
|
-
// Node includes inherited properties of options.env when it normalizes
|
|
169
|
-
// it due to backwards compatibility. However, this is a prototype sink and
|
|
170
|
-
// undesired behavior so to prevent it we spread options.env onto a fresh
|
|
171
|
-
// object with a null [[Prototype]].
|
|
172
|
-
// https://github.com/nodejs/node/blob/v24.0.1/lib/child_process.js#L674-L678
|
|
173
|
-
env: {
|
|
174
|
-
__proto__: null,
|
|
175
|
-
...process.env,
|
|
176
|
-
...env
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
extra
|
|
180
|
-
)
|
|
181
|
-
const oldSpawnPromise = spawnPromise
|
|
182
|
-
if (shouldStripAnsi && stdioString) {
|
|
183
|
-
spawnPromise = spawnPromise.then(stripAnsiFromSpawnResult).catch(error => {
|
|
184
|
-
throw stripAnsiFromSpawnResult(error)
|
|
185
|
-
})
|
|
186
|
-
}
|
|
187
|
-
if (shouldRestartSpinner) {
|
|
188
|
-
spawnPromise = spawnPromise.finally(() => {
|
|
189
|
-
spinner.start()
|
|
190
|
-
})
|
|
191
|
-
}
|
|
192
|
-
for (const key of ObjectKeys(oldSpawnPromise)) {
|
|
193
|
-
spawnPromise[key] = oldSpawnPromise[key]
|
|
194
|
-
}
|
|
195
|
-
return spawnPromise
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
199
|
-
/**
|
|
200
|
-
* Synchronously spawn a child process.
|
|
201
|
-
* @param {string} cmd - The command to execute.
|
|
202
|
-
* @param {string[] | readonly string[]} [args] - Arguments to pass to the command.
|
|
203
|
-
* @param {SpawnSyncOptions} [options] - Spawn options without spinner support.
|
|
204
|
-
* @returns {import('child_process').SpawnSyncReturns<string | Buffer>} Command result.
|
|
205
|
-
* @typedef {Omit<SpawnOptions, 'spinner'>} SpawnSyncOptions
|
|
206
|
-
*/
|
|
207
|
-
function spawnSync(cmd, args, options) {
|
|
208
|
-
// On Windows with shell: true, use just the command name, not the full path.
|
|
209
|
-
// When shell: true is used, Windows cmd.exe has issues executing full paths to
|
|
210
|
-
// .cmd/.bat files (e.g., 'C:\...\pnpm.cmd'), often resulting in ENOENT errors.
|
|
211
|
-
// Using just the command name (e.g., 'pnpm') allows cmd.exe to find it via PATH.
|
|
212
|
-
// See: https://github.com/nodejs/node/issues/3675
|
|
213
|
-
// Check for .cmd, .bat, .ps1 extensions that indicate a Windows script.
|
|
214
|
-
const shell = getOwn(options, 'shell')
|
|
215
|
-
const WIN32 = /*@__PURE__*/ require('./constants/win32')
|
|
216
|
-
if (WIN32 && shell && windowsScriptExtRegExp.test(cmd)) {
|
|
217
|
-
const path = getPath()
|
|
218
|
-
// Extract just the command name without path and extension.
|
|
219
|
-
cmd = path.basename(cmd, path.extname(cmd))
|
|
220
|
-
}
|
|
221
|
-
const { stripAnsi: shouldStripAnsi = true, ...rawSpawnOptions } = {
|
|
222
|
-
__proto__: null,
|
|
223
|
-
...options
|
|
224
|
-
}
|
|
225
|
-
const { stdioString: rawStdioString = true } = rawSpawnOptions
|
|
226
|
-
const rawEncoding = rawStdioString ? 'utf8' : 'buffer'
|
|
227
|
-
const spawnOptions = {
|
|
228
|
-
encoding: rawEncoding,
|
|
229
|
-
...rawSpawnOptions
|
|
230
|
-
}
|
|
231
|
-
const stdioString = spawnOptions.encoding !== 'buffer'
|
|
232
|
-
const result = getChildProcess().spawnSync(cmd, args, spawnOptions)
|
|
233
|
-
if (stdioString) {
|
|
234
|
-
const { stderr, stdout } = result
|
|
235
|
-
if (stdout) {
|
|
236
|
-
result.stdout = stdout.toString().trim()
|
|
237
|
-
}
|
|
238
|
-
if (stderr) {
|
|
239
|
-
result.stderr = stderr.toString().trim()
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return shouldStripAnsi && stdioString
|
|
243
|
-
? stripAnsiFromSpawnResult(result)
|
|
244
|
-
: result
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
module.exports = {
|
|
248
|
-
isSpawnError,
|
|
249
|
-
isStdioType,
|
|
250
|
-
spawn,
|
|
251
|
-
spawnSync
|
|
252
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { hasOwn } = /*@__PURE__*/ require('./objects')
|
|
4
|
-
|
|
5
|
-
const ciSpinner = {
|
|
6
|
-
frames: [''],
|
|
7
|
-
// The delay argument is converted to a signed 32-bit integer. This effectively
|
|
8
|
-
// limits delay to 2147483647 ms, roughly 24.8 days, since it's specified as a
|
|
9
|
-
// signed integer in the IDL.
|
|
10
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Window/setInterval?utm_source=chatgpt.com#return_value
|
|
11
|
-
interval: 2147483647
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function desc(value) {
|
|
15
|
-
return {
|
|
16
|
-
__proto__: null,
|
|
17
|
-
configurable: true,
|
|
18
|
-
value,
|
|
19
|
-
writable: true
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function normalizeText(value) {
|
|
24
|
-
return typeof value === 'string' ? value.trimStart() : ''
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let _cliSpinners
|
|
28
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
29
|
-
function getCliSpinners(styleName) {
|
|
30
|
-
if (_cliSpinners === undefined) {
|
|
31
|
-
const yoctoFactory = /*@__PURE__*/ require('../external/@socketregistry/yocto-spinner')
|
|
32
|
-
const { constructor: YoctoCtor } = yoctoFactory()
|
|
33
|
-
_cliSpinners = YoctoCtor.spinners
|
|
34
|
-
}
|
|
35
|
-
if (typeof styleName === 'string') {
|
|
36
|
-
return hasOwn(_cliSpinners, styleName) ? _cliSpinners[styleName] : undefined
|
|
37
|
-
}
|
|
38
|
-
return _cliSpinners
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let _Spinner
|
|
42
|
-
let _defaultSpinner
|
|
43
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
44
|
-
function Spinner(options) {
|
|
45
|
-
if (_Spinner === undefined) {
|
|
46
|
-
const ENV = /*@__PURE__*/ require('./constants/env')
|
|
47
|
-
const abortSignal = /*@__PURE__*/ require('./constants/abort-signal')
|
|
48
|
-
const { isBlankString } = /*@__PURE__*/ require('./strings')
|
|
49
|
-
const yoctoFactory = /*@__PURE__*/ require('../external/@socketregistry/yocto-spinner')
|
|
50
|
-
const { constructor: YoctoCtor } = yoctoFactory()
|
|
51
|
-
|
|
52
|
-
/*@__PURE__*/
|
|
53
|
-
_Spinner = class Spinner extends YoctoCtor {
|
|
54
|
-
constructor(options) {
|
|
55
|
-
super({
|
|
56
|
-
signal: abortSignal,
|
|
57
|
-
...options
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
#apply(methodName, args) {
|
|
62
|
-
let extras
|
|
63
|
-
let text = args.at(0)
|
|
64
|
-
if (typeof text === 'string') {
|
|
65
|
-
extras = args.slice(1)
|
|
66
|
-
} else {
|
|
67
|
-
extras = args
|
|
68
|
-
text = ''
|
|
69
|
-
}
|
|
70
|
-
const wasSpinning = this.isSpinning
|
|
71
|
-
const normalized = normalizeText(text)
|
|
72
|
-
super[methodName](normalized)
|
|
73
|
-
const {
|
|
74
|
-
incLogCallCountSymbol,
|
|
75
|
-
lastWasBlankSymbol,
|
|
76
|
-
logger
|
|
77
|
-
} = /*@__PURE__*/ require('./logger')
|
|
78
|
-
if (methodName === 'stop') {
|
|
79
|
-
if (wasSpinning && normalized) {
|
|
80
|
-
logger[lastWasBlankSymbol](isBlankString(normalized))
|
|
81
|
-
logger[incLogCallCountSymbol]()
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
logger[lastWasBlankSymbol](false)
|
|
85
|
-
logger[incLogCallCountSymbol]()
|
|
86
|
-
}
|
|
87
|
-
if (extras.length) {
|
|
88
|
-
logger.log(...extras)
|
|
89
|
-
logger[lastWasBlankSymbol](false)
|
|
90
|
-
}
|
|
91
|
-
return this
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
#applyAndKeepSpinning(methodName, args) {
|
|
95
|
-
const wasSpinning = this.isSpinning
|
|
96
|
-
this.#apply(methodName, args)
|
|
97
|
-
if (wasSpinning) {
|
|
98
|
-
this.start()
|
|
99
|
-
}
|
|
100
|
-
return this
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
debug(...args) {
|
|
104
|
-
const { isDebug } = /*@__PURE__*/ require('./debug')
|
|
105
|
-
if (isDebug()) {
|
|
106
|
-
return this.#applyAndKeepSpinning('info', args)
|
|
107
|
-
}
|
|
108
|
-
return this
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
debugAndStop(...args) {
|
|
112
|
-
const { isDebug } = /*@__PURE__*/ require('./debug')
|
|
113
|
-
if (isDebug()) {
|
|
114
|
-
return this.#apply('info', args)
|
|
115
|
-
}
|
|
116
|
-
return this
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
fail(...args) {
|
|
120
|
-
return this.#applyAndKeepSpinning('error', args)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
failAndStop(...args) {
|
|
124
|
-
return this.#apply('error', args)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
getText() {
|
|
128
|
-
return this.text
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
info(...args) {
|
|
132
|
-
return this.#applyAndKeepSpinning('info', args)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
infoAndStop(...args) {
|
|
136
|
-
return this.#apply('info', args)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
log(...args) {
|
|
140
|
-
return this.#applyAndKeepSpinning('stop', args)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
logAndStop(...args) {
|
|
144
|
-
return this.#apply('stop', args)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
setText(value) {
|
|
148
|
-
this.text = normalizeText(value)
|
|
149
|
-
return this
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
start(...args) {
|
|
153
|
-
if (args.length) {
|
|
154
|
-
const text = args.at(0)
|
|
155
|
-
const normalized = normalizeText(text)
|
|
156
|
-
// We clear this.text on start when `text` is falsy because yocto-spinner
|
|
157
|
-
// will not clear it otherwise.
|
|
158
|
-
if (!normalized) {
|
|
159
|
-
this.setText('')
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return this.#apply('start', args)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
stop(...args) {
|
|
166
|
-
// We clear this.text on stop because yocto-spinner will not clear it.
|
|
167
|
-
this.setText('')
|
|
168
|
-
return this.#apply('stop', args)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
success(...args) {
|
|
172
|
-
return this.#applyAndKeepSpinning('success', args)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
successAndStop(...args) {
|
|
176
|
-
return this.#apply('success', args)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
warn(...args) {
|
|
180
|
-
return this.#applyAndKeepSpinning('warning', args)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
warnAndStop(...args) {
|
|
184
|
-
return this.#apply('warning', args)
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
// Add aliases.
|
|
188
|
-
Object.defineProperties(_Spinner.prototype, {
|
|
189
|
-
error: desc(_Spinner.prototype.fail),
|
|
190
|
-
errorAndStop: desc(_Spinner.prototype.failAndStop),
|
|
191
|
-
warning: desc(_Spinner.prototype.warn),
|
|
192
|
-
warningAndStop: desc(_Spinner.prototype.warnAndStop)
|
|
193
|
-
})
|
|
194
|
-
_defaultSpinner = ENV.CI ? ciSpinner : undefined
|
|
195
|
-
}
|
|
196
|
-
return new _Spinner({
|
|
197
|
-
spinner: _defaultSpinner,
|
|
198
|
-
...options
|
|
199
|
-
})
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
module.exports = {
|
|
203
|
-
getCliSpinners,
|
|
204
|
-
Spinner
|
|
205
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
normalizeIterationOptions,
|
|
5
|
-
pRetry
|
|
6
|
-
} = /*@__PURE__*/ require('./promises')
|
|
7
|
-
|
|
8
|
-
let _streamingIterables
|
|
9
|
-
/**
|
|
10
|
-
* Get the streaming-iterables module.
|
|
11
|
-
* @returns {Object} The streaming-iterables module.
|
|
12
|
-
* @private
|
|
13
|
-
*/
|
|
14
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
15
|
-
function getStreamingIterables() {
|
|
16
|
-
if (_streamingIterables === undefined) {
|
|
17
|
-
_streamingIterables = /*@__PURE__*/ require('../external/streaming-iterables')
|
|
18
|
-
}
|
|
19
|
-
return _streamingIterables
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Execute a function for each item in an iterable in parallel.
|
|
24
|
-
* @param {AsyncIterable} iterable - The async iterable to process.
|
|
25
|
-
* @param {Function} func - Function to execute for each item.
|
|
26
|
-
* @param {Object} [options] - Iteration options including concurrency.
|
|
27
|
-
* @returns {Promise<void>} Resolves when all items are processed.
|
|
28
|
-
*/
|
|
29
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
30
|
-
async function parallelEach(iterable, func, options) {
|
|
31
|
-
for await (const _ of parallelMap(iterable, func, options)) {
|
|
32
|
-
/* empty block */
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Map over an iterable in parallel with concurrency control.
|
|
38
|
-
* @param {AsyncIterable} iterable - The async iterable to map.
|
|
39
|
-
* @param {Function} func - Mapping function.
|
|
40
|
-
* @param {Object} [options] - Iteration options including concurrency.
|
|
41
|
-
* @returns {AsyncIterable} Async iterable of mapped values.
|
|
42
|
-
*/
|
|
43
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
44
|
-
function parallelMap(iterable, func, options) {
|
|
45
|
-
const streamingIterables = getStreamingIterables()
|
|
46
|
-
const opts = normalizeIterationOptions(options)
|
|
47
|
-
return streamingIterables.parallelMap(
|
|
48
|
-
opts.concurrency,
|
|
49
|
-
item =>
|
|
50
|
-
pRetry(func, {
|
|
51
|
-
...opts.retries,
|
|
52
|
-
args: [item]
|
|
53
|
-
}),
|
|
54
|
-
iterable
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Transform an iterable with a function.
|
|
60
|
-
* @param {AsyncIterable} iterable - The async iterable to transform.
|
|
61
|
-
* @param {Function} func - Transform function.
|
|
62
|
-
* @param {Object} [options] - Iteration options including concurrency.
|
|
63
|
-
* @returns {AsyncIterable} Transformed async iterable.
|
|
64
|
-
*/
|
|
65
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
66
|
-
function transform(iterable, func, options) {
|
|
67
|
-
const streamingIterables = getStreamingIterables()
|
|
68
|
-
const opts = normalizeIterationOptions(options)
|
|
69
|
-
return streamingIterables.transform(
|
|
70
|
-
opts.concurrency,
|
|
71
|
-
item =>
|
|
72
|
-
pRetry(func, {
|
|
73
|
-
...opts.retries,
|
|
74
|
-
args: [item]
|
|
75
|
-
}),
|
|
76
|
-
iterable
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
module.exports = {
|
|
81
|
-
parallelEach,
|
|
82
|
-
parallelMap,
|
|
83
|
-
transform
|
|
84
|
-
}
|