@automattic/vip 4.1.6 → 4.1.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/assets/dev-env.lando.template.yml.ejs +1 -1
- package/dist/bin/vip-app-deploy-token-generate.js +110 -78
- package/dist/bin/vip-app-deploy-token.js +24 -16
- package/dist/bin/vip-app-deploy-validate.js +45 -41
- package/dist/bin/vip-app-deploy.js +222 -215
- package/dist/bin/vip-app-list.js +59 -43
- package/dist/bin/vip-app.js +97 -66
- package/dist/bin/vip-backup-db.js +36 -29
- package/dist/bin/vip-backup.js +16 -9
- package/dist/bin/vip-cache-purge-url.js +93 -55
- package/dist/bin/vip-cache.js +23 -14
- package/dist/bin/vip-config-envvar-delete.js +74 -73
- package/dist/bin/vip-config-envvar-get-all.js +68 -68
- package/dist/bin/vip-config-envvar-get.js +46 -46
- package/dist/bin/vip-config-envvar-list.js +54 -57
- package/dist/bin/vip-config-envvar-set.js +102 -96
- package/dist/bin/vip-config-envvar.js +38 -24
- package/dist/bin/vip-config-software-get.js +88 -75
- package/dist/bin/vip-config-software-update.js +116 -120
- package/dist/bin/vip-config-software.js +31 -21
- package/dist/bin/vip-config.js +25 -17
- package/dist/bin/vip-db-phpmyadmin.js +40 -39
- package/dist/bin/vip-db.js +13 -12
- package/dist/bin/vip-defensive-mode-configure.js +197 -197
- package/dist/bin/vip-defensive-mode-disable.js +43 -35
- package/dist/bin/vip-defensive-mode-enable.js +47 -38
- package/dist/bin/vip-defensive-mode.js +28 -17
- package/dist/bin/vip-dev-env-create.js +147 -104
- package/dist/bin/vip-dev-env-destroy.js +48 -39
- package/dist/bin/vip-dev-env-envvar-delete.js +60 -49
- package/dist/bin/vip-dev-env-envvar-get-all.js +52 -45
- package/dist/bin/vip-dev-env-envvar-get.js +48 -37
- package/dist/bin/vip-dev-env-envvar-list.js +48 -41
- package/dist/bin/vip-dev-env-envvar-set.js +83 -70
- package/dist/bin/vip-dev-env-envvar.js +38 -23
- package/dist/bin/vip-dev-env-exec.js +81 -74
- package/dist/bin/vip-dev-env-import-media.js +34 -26
- package/dist/bin/vip-dev-env-import-sql.js +65 -51
- package/dist/bin/vip-dev-env-import.js +23 -14
- package/dist/bin/vip-dev-env-info.js +59 -50
- package/dist/bin/vip-dev-env-list.js +34 -31
- package/dist/bin/vip-dev-env-logs.js +59 -49
- package/dist/bin/vip-dev-env-purge.js +71 -63
- package/dist/bin/vip-dev-env-shell.js +82 -71
- package/dist/bin/vip-dev-env-start.js +77 -65
- package/dist/bin/vip-dev-env-stop.js +80 -74
- package/dist/bin/vip-dev-env-sync-sql.js +80 -72
- package/dist/bin/vip-dev-env-sync.js +18 -11
- package/dist/bin/vip-dev-env-update.js +93 -84
- package/dist/bin/vip-dev-env.js +25 -8
- package/dist/bin/vip-edge-workers-build.js +82 -54
- package/dist/bin/vip-edge-workers-delete.js +84 -52
- package/dist/bin/vip-edge-workers-deploy.js +186 -126
- package/dist/bin/vip-edge-workers-disable.js +75 -44
- package/dist/bin/vip-edge-workers-enable.js +86 -54
- package/dist/bin/vip-edge-workers-get.js +108 -88
- package/dist/bin/vip-edge-workers-init.js +83 -53
- package/dist/bin/vip-edge-workers-list.js +89 -54
- package/dist/bin/vip-edge-workers-new.js +98 -69
- package/dist/bin/vip-edge-workers-validate.js +123 -82
- package/dist/bin/vip-edge-workers.js +19 -6
- package/dist/bin/vip-export-sql.js +75 -69
- package/dist/bin/vip-export.js +12 -7
- package/dist/bin/vip-import-media-abort.js +99 -73
- package/dist/bin/vip-import-media-status.js +83 -51
- package/dist/bin/vip-import-media.js +165 -166
- package/dist/bin/vip-import-sql-status.js +75 -45
- package/dist/bin/vip-import-sql.js +536 -596
- package/dist/bin/vip-import-validate-files.js +122 -141
- package/dist/bin/vip-import-validate-sql.js +52 -16
- package/dist/bin/vip-import.js +16 -7
- package/dist/bin/vip-logout.js +17 -13
- package/dist/bin/vip-logs.js +209 -183
- package/dist/bin/vip-search-replace.js +85 -53
- package/dist/bin/vip-slowlogs.js +168 -147
- package/dist/bin/vip-sync.js +163 -133
- package/dist/bin/vip-whoami.js +71 -35
- package/dist/bin/vip-wp.js +506 -549
- package/dist/bin/vip.js +161 -116
- package/dist/commands/backup-db.js +183 -149
- package/dist/commands/dev-env-import-sql.js +162 -117
- package/dist/commands/dev-env-sync-sql.js +372 -330
- package/dist/commands/export-sql.js +441 -425
- package/dist/commands/phpmyadmin.js +232 -212
- package/dist/commands/wp-ssh.js +218 -187
- package/dist/lib/analytics/clients/tracks.js +84 -91
- package/dist/lib/analytics/index.js +27 -27
- package/dist/lib/api/app.js +37 -36
- package/dist/lib/api/cache-purge.js +17 -20
- package/dist/lib/api/constants.js +5 -6
- package/dist/lib/api/edge-workers.js +84 -135
- package/dist/lib/api/error-debug.js +10 -13
- package/dist/lib/api/feature-flags.js +16 -17
- package/dist/lib/api/http.js +47 -48
- package/dist/lib/api/user.js +17 -18
- package/dist/lib/api.js +107 -116
- package/dist/lib/app-logs/app-logs.js +24 -25
- package/dist/lib/app-slowlogs/app-slowlogs.js +23 -24
- package/dist/lib/app-slowlogs/types.js +2 -1
- package/dist/lib/app.js +6 -8
- package/dist/lib/backup-storage-availability/backup-storage-availability.js +119 -119
- package/dist/lib/backup-storage-availability/docker-machine-not-found-error.js +5 -6
- package/dist/lib/cli/apiConfig.js +71 -41
- package/dist/lib/cli/command.js +1120 -873
- package/dist/lib/cli/config.js +29 -29
- package/dist/lib/cli/envAlias.js +35 -50
- package/dist/lib/cli/exit.js +19 -19
- package/dist/lib/cli/format.js +172 -172
- package/dist/lib/cli/progress.js +193 -236
- package/dist/lib/cli/prompt.js +14 -15
- package/dist/lib/cli/runtime-mode.js +5 -6
- package/dist/lib/client-file-uploader.js +489 -641
- package/dist/lib/config/software.js +206 -212
- package/dist/lib/constants/dev-environment.js +40 -37
- package/dist/lib/constants/file-size.js +6 -7
- package/dist/lib/constants/vipgo.js +24 -12
- package/dist/lib/custom-deploy/custom-deploy.js +138 -120
- package/dist/lib/database.js +88 -85
- package/dist/lib/defensive-mode/api.js +41 -46
- package/dist/lib/defensive-mode/cli-helpers.js +40 -40
- package/dist/lib/dev-environment/dev-environment-cli.js +776 -735
- package/dist/lib/dev-environment/dev-environment-configuration-file.js +224 -191
- package/dist/lib/dev-environment/dev-environment-core.js +697 -732
- package/dist/lib/dev-environment/dev-environment-database.js +57 -41
- package/dist/lib/dev-environment/dev-environment-lando.js +734 -666
- package/dist/lib/dev-environment/docker-utils.js +96 -90
- package/dist/lib/dev-environment/env-vars.js +61 -59
- package/dist/lib/dev-environment/lando-loader.js +6 -7
- package/dist/lib/dev-environment/types.js +2 -1
- package/dist/lib/edge-workers/confirmation.js +42 -36
- package/dist/lib/edge-workers/deployment.js +150 -159
- package/dist/lib/edge-workers/index.js +68 -85
- package/dist/lib/edge-workers/location.js +26 -26
- package/dist/lib/edge-workers/output.js +14 -15
- package/dist/lib/edge-workers/project.js +123 -132
- package/dist/lib/edge-workers/toolchains/assemblyscript/constants.js +6 -8
- package/dist/lib/edge-workers/toolchains/assemblyscript/index.js +100 -101
- package/dist/lib/edge-workers/toolchains/assemblyscript/templates.js +31 -33
- package/dist/lib/edge-workers/toolchains/index.js +15 -15
- package/dist/lib/edge-workers/types.js +10 -38
- package/dist/lib/edge-workers/validation.js +161 -150
- package/dist/lib/env.js +16 -17
- package/dist/lib/envvar/api-delete.js +16 -18
- package/dist/lib/envvar/api-get-all.js +15 -19
- package/dist/lib/envvar/api-get.js +8 -9
- package/dist/lib/envvar/api-list.js +16 -21
- package/dist/lib/envvar/api-set.js +20 -19
- package/dist/lib/envvar/api.js +34 -29
- package/dist/lib/envvar/input.js +29 -34
- package/dist/lib/envvar/logging.js +9 -11
- package/dist/lib/envvar/read-file.js +6 -7
- package/dist/lib/http/download-file.js +76 -44
- package/dist/lib/http/proxy-agent.js +37 -40
- package/dist/lib/http/proxy-dispatcher.js +69 -71
- package/dist/lib/keychain/insecure.js +40 -36
- package/dist/lib/keychain/keychain.js +2 -1
- package/dist/lib/keychain/secure.js +16 -15
- package/dist/lib/keychain.js +22 -22
- package/dist/lib/live-backup-copy.js +117 -115
- package/dist/lib/logout.js +17 -19
- package/dist/lib/media-import/config.js +15 -14
- package/dist/lib/media-import/media-file-import.js +9 -13
- package/dist/lib/media-import/progress.js +53 -65
- package/dist/lib/media-import/status.js +241 -256
- package/dist/lib/media-import/utils.js +15 -15
- package/dist/lib/node-version-check.js +16 -16
- package/dist/lib/promise.js +16 -17
- package/dist/lib/read-file.js +48 -16
- package/dist/lib/rechallenge/client.js +37 -43
- package/dist/lib/rechallenge/errors.js +38 -37
- package/dist/lib/rechallenge/flow.js +148 -123
- package/dist/lib/rechallenge/index.js +23 -24
- package/dist/lib/rechallenge/link.js +153 -151
- package/dist/lib/rechallenge/open-browser.js +14 -17
- package/dist/lib/rechallenge/token-cache.js +83 -86
- package/dist/lib/rechallenge/types.js +5 -14
- package/dist/lib/retry.js +93 -129
- package/dist/lib/search-and-replace.js +164 -148
- package/dist/lib/site-import/db-file-import.js +12 -16
- package/dist/lib/site-import/status.js +291 -291
- package/dist/lib/token.js +86 -87
- package/dist/lib/tracker.js +51 -62
- package/dist/lib/types/graphql/rate-limit-exceeded-error.js +2 -1
- package/dist/lib/types.js +2 -1
- package/dist/lib/user-error.js +6 -8
- package/dist/lib/utils.js +81 -87
- package/dist/lib/validations/custom-deploy.js +218 -186
- package/dist/lib/validations/is-multi-site-sql-dump.js +6 -6
- package/dist/lib/validations/is-multi-site.js +83 -50
- package/dist/lib/validations/is-multisite-domain-mapped.js +92 -62
- package/dist/lib/validations/line-by-line.js +78 -46
- package/dist/lib/validations/site-type.js +59 -63
- package/dist/lib/validations/sql-insert-parser.js +415 -0
- package/dist/lib/validations/sql.js +551 -431
- package/dist/lib/validations/utils.js +27 -29
- package/dist/lib/vip-import-validate-files.js +481 -490
- package/dist/lib/wp/helpers.js +41 -45
- package/dist/lib/wp/readline.js +21 -57
- package/dist/lib/xdg-data.js +11 -12
- package/helpers/mark-cli-executable.js +9 -0
- package/node_modules/@apollo/client/CHANGELOG.md +10 -0
- package/node_modules/@apollo/client/__cjs/cache/inmemory/helpers.cjs +5 -0
- package/node_modules/@apollo/client/__cjs/cache/inmemory/helpers.cjs.map +1 -1
- package/node_modules/@apollo/client/__cjs/cache/inmemory/inMemoryCache.cjs +2 -1
- package/node_modules/@apollo/client/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/node_modules/@apollo/client/__cjs/cache/inmemory/key-extractor.cjs +14 -2
- package/node_modules/@apollo/client/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
- package/node_modules/@apollo/client/__cjs/cache/inmemory/policies.cjs +16 -0
- package/node_modules/@apollo/client/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/node_modules/@apollo/client/__cjs/cache/inmemory/policies.d.cts +2 -0
- package/node_modules/@apollo/client/__cjs/cache/inmemory/writeToStore.cjs +3 -2
- package/node_modules/@apollo/client/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/node_modules/@apollo/client/__cjs/core/QueryInfo.cjs +9 -1
- package/node_modules/@apollo/client/__cjs/core/QueryInfo.cjs.map +1 -1
- package/node_modules/@apollo/client/__cjs/core/QueryInfo.d.cts +1 -1
- package/node_modules/@apollo/client/__cjs/core/QueryManager.cjs +10 -3
- package/node_modules/@apollo/client/__cjs/core/QueryManager.cjs.map +1 -1
- package/node_modules/@apollo/client/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/node_modules/@apollo/client/__cjs/react/hooks/useFragment.d.cts +42 -43
- package/node_modules/@apollo/client/__cjs/version.cjs +1 -1
- package/node_modules/@apollo/client/cache/inmemory/helpers.js +5 -0
- package/node_modules/@apollo/client/cache/inmemory/helpers.js.map +1 -1
- package/node_modules/@apollo/client/cache/inmemory/inMemoryCache.js +2 -1
- package/node_modules/@apollo/client/cache/inmemory/inMemoryCache.js.map +1 -1
- package/node_modules/@apollo/client/cache/inmemory/key-extractor.js +14 -2
- package/node_modules/@apollo/client/cache/inmemory/key-extractor.js.map +1 -1
- package/node_modules/@apollo/client/cache/inmemory/policies.d.ts +2 -0
- package/node_modules/@apollo/client/cache/inmemory/policies.js +17 -1
- package/node_modules/@apollo/client/cache/inmemory/policies.js.map +1 -1
- package/node_modules/@apollo/client/cache/inmemory/writeToStore.js +3 -2
- package/node_modules/@apollo/client/cache/inmemory/writeToStore.js.map +1 -1
- package/node_modules/@apollo/client/core/QueryInfo.d.ts +1 -1
- package/node_modules/@apollo/client/core/QueryInfo.js +10 -2
- package/node_modules/@apollo/client/core/QueryInfo.js.map +1 -1
- package/node_modules/@apollo/client/core/QueryManager.js +10 -3
- package/node_modules/@apollo/client/core/QueryManager.js.map +1 -1
- package/node_modules/@apollo/client/package.json +1 -1
- package/node_modules/@apollo/client/react/hooks/useFragment.d.ts +42 -43
- package/node_modules/@apollo/client/react/hooks/useFragment.js.map +1 -1
- package/node_modules/@apollo/client/react/hooks-compiled/useFragment.d.ts +42 -43
- package/node_modules/@apollo/client/react/hooks-compiled/useFragment.js.map +1 -1
- package/node_modules/@apollo/client/version.js +1 -1
- package/node_modules/@automattic/vip-search-replace/README.md +6 -1
- package/node_modules/@automattic/vip-search-replace/lib/index.js +46 -14
- package/node_modules/@automattic/vip-search-replace/package.json +1 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/zlib.d.ts +752 -0
- package/node_modules/check-disk-space/README.md +92 -32
- package/node_modules/check-disk-space/dist/check-disk-space.d.mts +58 -0
- package/node_modules/check-disk-space/dist/check-disk-space.mjs +170 -190
- package/node_modules/check-disk-space/package.json +43 -71
- package/node_modules/cpu-features/build/Makefile +2 -2
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/filesystem.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_aarch64_linux_or_android.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_aarch64_macos_or_iphone.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_aarch64_windows.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_arm_linux_or_android.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_mips_linux_or_android.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_ppc_linux.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_freebsd.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_linux_or_android.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_macos.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_windows.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/stack_line_reader.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/string_view.o.d +1 -1
- package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpufeatures/src/binding.o.d +157 -145
- package/node_modules/cpu-features/build/Release/cpufeatures.node +0 -0
- package/node_modules/cpu-features/build/Release/obj.target/cpufeatures/src/binding.o +0 -0
- package/node_modules/cpu-features/build/Release/obj.target/cpufeatures.node +0 -0
- package/node_modules/cpu-features/build/config.gypi +100 -31
- package/node_modules/cpu-features/build/cpufeatures.target.mk +14 -14
- package/node_modules/cpu-features/build/deps/cpu_features/cpu_features.target.mk +14 -14
- package/node_modules/ssh2/lib/protocol/crypto/build/Makefile +2 -2
- package/node_modules/ssh2/lib/protocol/crypto/build/Release/.deps/Release/obj.target/sshcrypto/src/binding.o.d.raw +136 -0
- package/node_modules/ssh2/lib/protocol/crypto/build/sshcrypto.target.mk +14 -14
- package/node_modules/undici/docs/docs/api/Interceptors.md +15 -2
- package/node_modules/undici/lib/dispatcher/client-h2.js +78 -3
- package/node_modules/undici/lib/dispatcher/pool-base.js +20 -3
- package/node_modules/undici/package.json +3 -3
- package/node_modules/undici/types/api.d.ts +1 -1
- package/node_modules/undici/types/utility.d.ts +4 -4
- package/package.json +44 -13
- package/dist/lib/analytics/clients/client.js +0 -1
- package/dist/lib/analytics/clients/pendo.js +0 -78
- package/helpers/check-version.js +0 -16
- package/node_modules/check-disk-space/dist/check-disk-space.cjs +0 -210
- package/node_modules/check-disk-space/dist/check-disk-space.d.ts +0 -53
- package/node_modules/fetch-retry/.eslintignore +0 -1
- package/node_modules/fetch-retry/.eslintrc.yml +0 -20
- package/node_modules/fetch-retry/.github/workflows/node.js.yml +0 -32
- package/node_modules/fetch-retry/.husky/pre-commit +0 -6
- package/node_modules/fetch-retry/.nycrc.json +0 -24
- package/node_modules/fetch-retry/.travis.yml +0 -3
- package/node_modules/fetch-retry/LICENSE +0 -21
- package/node_modules/fetch-retry/README.md +0 -128
- package/node_modules/fetch-retry/dist/fetch-retry.umd.js +0 -151
- package/node_modules/fetch-retry/index.d.ts +0 -29
- package/node_modules/fetch-retry/index.js +0 -143
- package/node_modules/fetch-retry/package.json +0 -41
- package/node_modules/fetch-retry/rollup.config.js +0 -12
- package/node_modules/fetch-retry/test/.eslintrc.yml +0 -7
- package/node_modules/fetch-retry/test/integration/index.js +0 -212
- package/node_modules/fetch-retry/test/integration/mock-api/index.js +0 -42
- package/node_modules/fetch-retry/test/unit/index.js +0 -1169
- package/node_modules/ssh2/lib/protocol/crypto/build/Release/.deps/Release/obj.target/sshcrypto/src/binding.o.d +0 -265
- package/node_modules/ssh2/lib/protocol/crypto/build/Release/.deps/Release/obj.target/sshcrypto.node.d +0 -1
- package/node_modules/ssh2/lib/protocol/crypto/build/Release/.deps/Release/sshcrypto.node.d +0 -1
- package/node_modules/ssh2/lib/protocol/crypto/build/Release/obj.target/sshcrypto/src/binding.o +0 -0
- package/node_modules/ssh2/lib/protocol/crypto/build/Release/obj.target/sshcrypto.node +0 -0
- package/node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node +0 -0
|
@@ -1,190 +1,181 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
6
|
exports.DeploymentApplyError = void 0;
|
|
5
|
-
exports.applyEdgeWorkerDeploymentPlan = applyEdgeWorkerDeploymentPlan;
|
|
6
|
-
exports.deploymentPlanRows = deploymentPlanRows;
|
|
7
7
|
exports.prepareEdgeWorkerDeploymentPlan = prepareEdgeWorkerDeploymentPlan;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
exports.deploymentPlanRows = deploymentPlanRows;
|
|
9
|
+
exports.applyEdgeWorkerDeploymentPlan = applyEdgeWorkerDeploymentPlan;
|
|
10
|
+
const edge_workers_1 = require("../api/edge-workers");
|
|
11
|
+
const user_error_1 = __importDefault(require("../user-error"));
|
|
12
|
+
const index_1 = require("./index");
|
|
13
|
+
const output_1 = require("./output");
|
|
13
14
|
class DeploymentApplyError extends Error {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.activeAfterUpload = state.activeAfterUpload;
|
|
31
|
-
}
|
|
15
|
+
appliedNames;
|
|
16
|
+
failedName;
|
|
17
|
+
unappliedNames;
|
|
18
|
+
stage;
|
|
19
|
+
uploadCompleted;
|
|
20
|
+
activeAfterUpload;
|
|
21
|
+
constructor(appliedNames, failedName, unappliedNames, cause, state) {
|
|
22
|
+
super(`Failed to apply edge worker "${failedName}".`, { cause });
|
|
23
|
+
this.name = 'DeploymentApplyError';
|
|
24
|
+
this.appliedNames = appliedNames;
|
|
25
|
+
this.failedName = failedName;
|
|
26
|
+
this.unappliedNames = unappliedNames;
|
|
27
|
+
this.stage = state.stage;
|
|
28
|
+
this.uploadCompleted = state.uploadCompleted;
|
|
29
|
+
this.activeAfterUpload = state.activeAfterUpload;
|
|
30
|
+
}
|
|
32
31
|
}
|
|
33
32
|
exports.DeploymentApplyError = DeploymentApplyError;
|
|
34
33
|
function prepareArtifact(options, worker) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (options.skipBuild) {
|
|
35
|
+
return (0, index_1.readPrebuiltWorker)(options.projectDir, worker);
|
|
36
|
+
}
|
|
37
|
+
return (0, index_1.buildWorker)(options.projectDir, worker);
|
|
39
38
|
}
|
|
40
39
|
async function prepareValidation(options, worker, artifact) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
throw new _userError.default(`worker "${worker.manifest.name}" failed validation: ${errors}`);
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
validation: 'passed',
|
|
54
|
-
phases: result.phases
|
|
55
|
-
};
|
|
40
|
+
if (options.skipValidate) {
|
|
41
|
+
return { validation: 'skipped', phases: [] };
|
|
42
|
+
}
|
|
43
|
+
const result = await (0, edge_workers_1.validateEdgeWorker)(options.envId, artifact.base64);
|
|
44
|
+
if (result.valid !== true) {
|
|
45
|
+
const errors = result.errors.join('; ') || 'unknown error';
|
|
46
|
+
throw new user_error_1.default(`worker "${worker.manifest.name}" failed validation: ${errors}`);
|
|
47
|
+
}
|
|
48
|
+
return { validation: 'passed', phases: result.phases };
|
|
56
49
|
}
|
|
57
50
|
function proposedLocationFor(worker, existing, hasLocation, currentLocation) {
|
|
58
|
-
|
|
51
|
+
if (!existing) {
|
|
52
|
+
return worker.manifest.location ?? null;
|
|
53
|
+
}
|
|
54
|
+
if (!hasLocation) {
|
|
55
|
+
return currentLocation;
|
|
56
|
+
}
|
|
59
57
|
return worker.manifest.location ?? null;
|
|
60
|
-
}
|
|
61
|
-
if (!hasLocation) {
|
|
62
|
-
return currentLocation;
|
|
63
|
-
}
|
|
64
|
-
return worker.manifest.location ?? null;
|
|
65
58
|
}
|
|
66
59
|
function prepareInput(worker, existing, artifact, source, hasLocation) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
60
|
+
const input = {
|
|
61
|
+
name: worker.manifest.name,
|
|
62
|
+
wasmBinary: artifact.base64,
|
|
63
|
+
};
|
|
64
|
+
if (worker.manifest.on_failure) {
|
|
65
|
+
input.onFailure = worker.manifest.on_failure;
|
|
66
|
+
}
|
|
67
|
+
if (source !== undefined) {
|
|
68
|
+
input.source = source;
|
|
69
|
+
}
|
|
70
|
+
if (existing && hasLocation) {
|
|
71
|
+
input.location = worker.manifest.location ?? null;
|
|
72
|
+
}
|
|
73
|
+
else if (!existing && worker.manifest.location) {
|
|
74
|
+
input.location = worker.manifest.location;
|
|
75
|
+
}
|
|
76
|
+
return input;
|
|
83
77
|
}
|
|
84
78
|
function sourceModeFor(skipSource, existing) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
if (!skipSource) {
|
|
80
|
+
return 'store';
|
|
81
|
+
}
|
|
82
|
+
return existing ? 'preserve' : 'omit';
|
|
89
83
|
}
|
|
90
84
|
async function preparePlanItem(options, worker, existing) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
enableAfterDeploy: options.enableAfterDeploy,
|
|
112
|
-
intendedActive
|
|
113
|
-
};
|
|
85
|
+
const artifact = prepareArtifact(options, worker);
|
|
86
|
+
const { validation, phases } = await prepareValidation(options, worker, artifact);
|
|
87
|
+
const source = options.skipSource ? undefined : (0, index_1.readWorkerSource)(worker);
|
|
88
|
+
const hasLocation = Object.hasOwn(worker.manifest, 'location');
|
|
89
|
+
const currentLocation = existing?.location ?? null;
|
|
90
|
+
const intendedActive = options.enableAfterDeploy || Boolean(existing?.active);
|
|
91
|
+
return {
|
|
92
|
+
action: existing ? 'update' : 'create',
|
|
93
|
+
worker,
|
|
94
|
+
existing,
|
|
95
|
+
artifact,
|
|
96
|
+
validation,
|
|
97
|
+
phases,
|
|
98
|
+
input: prepareInput(worker, existing, artifact, source, hasLocation),
|
|
99
|
+
currentLocation,
|
|
100
|
+
proposedLocation: proposedLocationFor(worker, existing, hasLocation, currentLocation),
|
|
101
|
+
sourceMode: sourceModeFor(options.skipSource, existing),
|
|
102
|
+
enableAfterDeploy: options.enableAfterDeploy,
|
|
103
|
+
intendedActive,
|
|
104
|
+
};
|
|
114
105
|
}
|
|
115
106
|
async function prepareEdgeWorkerDeploymentPlan(options) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
107
|
+
const remoteWorkers = await (0, edge_workers_1.listEdgeWorkers)(options.appId, options.envId);
|
|
108
|
+
const remoteWorkersByName = new Map(remoteWorkers.map(worker => [worker.name, worker]));
|
|
109
|
+
const items = [];
|
|
110
|
+
for (const worker of options.workers) {
|
|
111
|
+
const existing = remoteWorkersByName.get(worker.manifest.name) ?? null;
|
|
112
|
+
// eslint-disable-next-line no-await-in-loop
|
|
113
|
+
items.push(await preparePlanItem(options, worker, existing));
|
|
114
|
+
}
|
|
115
|
+
return items;
|
|
125
116
|
}
|
|
126
117
|
function formatLocation(location) {
|
|
127
|
-
|
|
118
|
+
return location
|
|
119
|
+
? `${(0, output_1.escapeTerminalText)(location.operator)} "${(0, output_1.escapeTerminalText)(location.value)}"`
|
|
120
|
+
: 'all requests';
|
|
128
121
|
}
|
|
129
122
|
function currentActiveLabel(item) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
if (!item.existing) {
|
|
124
|
+
return 'new';
|
|
125
|
+
}
|
|
126
|
+
return item.existing.active ? 'active' : 'inactive';
|
|
134
127
|
}
|
|
135
128
|
function deploymentPlanRows(items) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
129
|
+
return items.map(item => ({
|
|
130
|
+
worker: (0, output_1.escapeTerminalText)(item.worker.manifest.name),
|
|
131
|
+
action: item.action,
|
|
132
|
+
current_active: currentActiveLabel(item),
|
|
133
|
+
final_active: item.intendedActive ? 'active' : 'inactive',
|
|
134
|
+
current_scope: formatLocation(item.currentLocation),
|
|
135
|
+
proposed_scope: formatLocation(item.proposedLocation),
|
|
136
|
+
validation: item.validation,
|
|
137
|
+
phases: item.phases.map(output_1.escapeTerminalText).join(', ') || 'none',
|
|
138
|
+
bytes: String(item.artifact.sizeBytes),
|
|
139
|
+
source: item.sourceMode,
|
|
140
|
+
}));
|
|
148
141
|
}
|
|
149
142
|
async function applyPlanItem(envId, item) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
143
|
+
if (item.action === 'create') {
|
|
144
|
+
return (0, edge_workers_1.createEdgeWorker)(envId, item.input);
|
|
145
|
+
}
|
|
146
|
+
if (!item.existing) {
|
|
147
|
+
throw new Error(`Update plan for "${item.worker.manifest.name}" has no existing worker.`);
|
|
148
|
+
}
|
|
149
|
+
return (0, edge_workers_1.updateEdgeWorker)(envId, item.existing.id, item.input);
|
|
157
150
|
}
|
|
158
151
|
async function applyEdgeWorkerDeploymentPlan(envId, items, onApplied) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
152
|
+
const appliedNames = [];
|
|
153
|
+
for (const [index, item] of items.entries()) {
|
|
154
|
+
const name = item.worker.manifest.name;
|
|
155
|
+
let result;
|
|
156
|
+
try {
|
|
157
|
+
// eslint-disable-next-line no-await-in-loop
|
|
158
|
+
result = await applyPlanItem(envId, item);
|
|
159
|
+
}
|
|
160
|
+
catch (cause) {
|
|
161
|
+
throw new DeploymentApplyError([...appliedNames], name, items.slice(index + 1).map(remaining => remaining.worker.manifest.name), cause, { stage: 'upload', uploadCompleted: false, activeAfterUpload: null });
|
|
162
|
+
}
|
|
163
|
+
let finalResult = result;
|
|
164
|
+
if (item.enableAfterDeploy && !result.active) {
|
|
165
|
+
try {
|
|
166
|
+
// eslint-disable-next-line no-await-in-loop
|
|
167
|
+
finalResult = await (0, edge_workers_1.setEdgeWorkerActive)(envId, result.id, true);
|
|
168
|
+
}
|
|
169
|
+
catch (cause) {
|
|
170
|
+
throw new DeploymentApplyError([...appliedNames], name, items.slice(index + 1).map(remaining => remaining.worker.manifest.name), cause, {
|
|
171
|
+
stage: 'enable',
|
|
172
|
+
uploadCompleted: true,
|
|
173
|
+
activeAfterUpload: result.active,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
appliedNames.push(name);
|
|
176
178
|
// eslint-disable-next-line no-await-in-loop
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
stage: 'enable',
|
|
181
|
-
uploadCompleted: true,
|
|
182
|
-
activeAfterUpload: result.active
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
appliedNames.push(name);
|
|
187
|
-
// eslint-disable-next-line no-await-in-loop
|
|
188
|
-
await onApplied(item, finalResult);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
179
|
+
await onApplied(item, finalResult);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -1,100 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
var _exportNames = {
|
|
5
|
-
readPrebuiltWorker: true,
|
|
6
|
-
buildWorker: true,
|
|
7
|
-
readWorkerSource: true,
|
|
8
|
-
getToolchain: true
|
|
9
|
-
};
|
|
10
|
-
exports.buildWorker = buildWorker;
|
|
11
|
-
exports.readPrebuiltWorker = readPrebuiltWorker;
|
|
12
|
-
exports.readWorkerSource = readWorkerSource;
|
|
13
|
-
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
14
|
-
var _userError = _interopRequireDefault(require("../user-error"));
|
|
15
|
-
var _project = require("./project");
|
|
16
|
-
Object.keys(_project).forEach(function (key) {
|
|
17
|
-
if (key === "default" || key === "__esModule") return;
|
|
18
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
-
if (key in exports && exports[key] === _project[key]) return;
|
|
20
|
-
exports[key] = _project[key];
|
|
21
|
-
});
|
|
22
|
-
var _toolchains = require("./toolchains");
|
|
23
|
-
exports.getToolchain = _toolchains.getToolchain;
|
|
24
|
-
var _validation = require("./validation");
|
|
25
|
-
Object.keys(_validation).forEach(function (key) {
|
|
26
|
-
if (key === "default" || key === "__esModule") return;
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
28
|
-
if (key in exports && exports[key] === _validation[key]) return;
|
|
29
|
-
exports[key] = _validation[key];
|
|
30
|
-
});
|
|
31
|
-
var _types = require("./types");
|
|
32
|
-
Object.keys(_types).forEach(function (key) {
|
|
33
|
-
if (key === "default" || key === "__esModule") return;
|
|
34
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
35
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
36
|
-
exports[key] = _types[key];
|
|
37
|
-
});
|
|
38
|
-
var _location = require("./location");
|
|
39
|
-
Object.keys(_location).forEach(function (key) {
|
|
40
|
-
if (key === "default" || key === "__esModule") return;
|
|
41
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
42
|
-
if (key in exports && exports[key] === _location[key]) return;
|
|
43
|
-
exports[key] = _location[key];
|
|
44
|
-
});
|
|
45
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
46
2
|
/**
|
|
47
3
|
* Convenience entry point for the edge-workers lib: ties project resolution and
|
|
48
4
|
* the toolchain together to produce a deployable artifact.
|
|
49
5
|
*/
|
|
50
|
-
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.getToolchain = void 0;
|
|
25
|
+
exports.readPrebuiltWorker = readPrebuiltWorker;
|
|
26
|
+
exports.buildWorker = buildWorker;
|
|
27
|
+
exports.readWorkerSource = readWorkerSource;
|
|
28
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
29
|
+
const user_error_1 = __importDefault(require("../user-error"));
|
|
30
|
+
const project_1 = require("./project");
|
|
31
|
+
const toolchains_1 = require("./toolchains");
|
|
32
|
+
const validation_1 = require("./validation");
|
|
33
|
+
__exportStar(require("./types"), exports);
|
|
34
|
+
__exportStar(require("./project"), exports);
|
|
35
|
+
__exportStar(require("./location"), exports);
|
|
36
|
+
var toolchains_2 = require("./toolchains");
|
|
37
|
+
Object.defineProperty(exports, "getToolchain", { enumerable: true, get: function () { return toolchains_2.getToolchain; } });
|
|
38
|
+
__exportStar(require("./validation"), exports);
|
|
51
39
|
function encodeArtifact(wasmPath) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
wasmPath,
|
|
55
|
-
base64: buffer.toString('base64'),
|
|
56
|
-
sizeBytes: buffer.length
|
|
57
|
-
};
|
|
40
|
+
const buffer = node_fs_1.default.readFileSync(wasmPath);
|
|
41
|
+
return { wasmPath, base64: buffer.toString('base64'), sizeBytes: buffer.length };
|
|
58
42
|
}
|
|
59
|
-
|
|
60
43
|
/** Read a previously compiled artifact without recompiling (used by `deploy --skip-build`). */
|
|
61
44
|
function readPrebuiltWorker(projectDir, worker) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
45
|
+
const name = (0, validation_1.validateWorkerName)(worker.manifest.name);
|
|
46
|
+
const buildRoot = (0, validation_1.resolvePathWithin)(projectDir, project_1.BUILD_DIR, 'Worker build directory');
|
|
47
|
+
const candidate = (0, validation_1.resolvePathWithin)(buildRoot, `${name}.wasm`, 'Worker build artifact');
|
|
48
|
+
if (!node_fs_1.default.existsSync(candidate)) {
|
|
49
|
+
throw new user_error_1.default(`No compiled artifact found for "${worker.manifest.name}" at "${candidate}". ` +
|
|
50
|
+
'Run `vip edge-workers build` first, or deploy without `--skip-build`.');
|
|
51
|
+
}
|
|
52
|
+
if (node_fs_1.default.lstatSync(buildRoot).isSymbolicLink()) {
|
|
53
|
+
throw new user_error_1.default('Worker build directory must not be a symbolic link.');
|
|
54
|
+
}
|
|
55
|
+
if (node_fs_1.default.lstatSync(candidate).isSymbolicLink()) {
|
|
56
|
+
throw new user_error_1.default('Worker build artifact must not be a symbolic link.');
|
|
57
|
+
}
|
|
58
|
+
const canonicalBuildRoot = (0, validation_1.resolveExistingPathWithin)(projectDir, project_1.BUILD_DIR, 'Worker build directory');
|
|
59
|
+
const wasmPath = (0, validation_1.resolveExistingPathWithin)(canonicalBuildRoot, `${name}.wasm`, 'Worker build artifact');
|
|
60
|
+
return encodeArtifact(wasmPath);
|
|
77
61
|
}
|
|
78
|
-
|
|
79
62
|
/** Compile a worker and return both the artifact path and its base64 encoding. */
|
|
80
63
|
function buildWorker(projectDir, worker) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
64
|
+
const descriptor = (0, project_1.readProjectDescriptor)(projectDir);
|
|
65
|
+
const toolchain = (0, toolchains_1.getToolchain)(descriptor.type);
|
|
66
|
+
toolchain.ensureAvailable(projectDir);
|
|
67
|
+
const wasmPath = toolchain.compile(projectDir, worker);
|
|
68
|
+
return encodeArtifact(wasmPath);
|
|
86
69
|
}
|
|
87
|
-
|
|
88
70
|
/** Read the entry source of a worker, for storing alongside the binary. */
|
|
89
71
|
function readWorkerSource(worker) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
72
|
+
const candidate = (0, validation_1.resolvePathWithin)(worker.dir, worker.manifest.entry, 'Worker entry');
|
|
73
|
+
if (!node_fs_1.default.existsSync(candidate)) {
|
|
74
|
+
throw new user_error_1.default(`Could not read worker source at "${candidate}".`);
|
|
75
|
+
}
|
|
76
|
+
const entry = (0, validation_1.resolveExistingPathWithin)(worker.dir, worker.manifest.entry, 'Worker entry');
|
|
77
|
+
try {
|
|
78
|
+
return node_fs_1.default.readFileSync(entry, 'utf8');
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
throw new user_error_1.default(`Could not read worker source at "${entry}".`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.parseLocationOption = parseLocationOption;
|
|
5
|
-
var _userError = _interopRequireDefault(require("../user-error"));
|
|
6
|
-
var _output = require("./output");
|
|
7
|
-
var _types = require("./types");
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
2
|
/**
|
|
10
3
|
* Parsing for location rules passed on the command line as
|
|
11
4
|
* `<operator>:<value>` (e.g. `starts_with:/api/`). A location scopes which
|
|
12
5
|
* request paths a worker runs on; workers without one run on all requests.
|
|
13
6
|
*/
|
|
14
|
-
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.parseLocationOption = parseLocationOption;
|
|
12
|
+
const user_error_1 = __importDefault(require("../user-error"));
|
|
13
|
+
const output_1 = require("./output");
|
|
14
|
+
const types_1 = require("./types");
|
|
15
15
|
function parseLocationOption(raw) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
16
|
+
// `--location` passed without a value arrives as a boolean, not a string;
|
|
17
|
+
// guard so we surface a clear error instead of a TypeError from `.indexOf()`.
|
|
18
|
+
if (typeof raw !== 'string') {
|
|
19
|
+
throw new user_error_1.default('The --location flag requires a value in the form "<operator>:<value>" ' +
|
|
20
|
+
`(e.g. "starts_with:/api/"). Operators: ${types_1.EDGE_WORKER_LOCATION_OPERATORS.join(', ')}.`);
|
|
21
|
+
}
|
|
22
|
+
// Split on the first colon only: the value may itself contain colons.
|
|
23
|
+
const separator = raw.indexOf(':');
|
|
24
|
+
const operator = separator > 0 ? raw.slice(0, separator) : '';
|
|
25
|
+
const value = separator > 0 ? raw.slice(separator + 1) : '';
|
|
26
|
+
if (!types_1.EDGE_WORKER_LOCATION_OPERATORS.includes(operator) ||
|
|
27
|
+
!value ||
|
|
28
|
+
(0, output_1.hasTerminalControlCharacters)(value)) {
|
|
29
|
+
throw new user_error_1.default(`Invalid location "${raw}". Use "<operator>:<value>", where <operator> is one of: ` +
|
|
30
|
+
`${types_1.EDGE_WORKER_LOCATION_OPERATORS.join(', ')} (e.g. "starts_with:/api/").`);
|
|
31
|
+
}
|
|
32
|
+
return { operator: operator, value };
|
|
33
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.escapeTerminalSource = escapeTerminalSource;
|
|
5
|
-
exports.escapeTerminalText = escapeTerminalText;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.hasTerminalControlCharacters = hasTerminalControlCharacters;
|
|
4
|
+
exports.escapeTerminalText = escapeTerminalText;
|
|
5
|
+
exports.escapeTerminalSource = escapeTerminalSource;
|
|
7
6
|
// C0, DEL, and C1 controls can alter terminal state or forge surrounding output.
|
|
8
7
|
// eslint-disable-next-line no-control-regex
|
|
9
8
|
const TERMINAL_CONTROL_CHARACTER = /[\u0000-\u001f\u007f-\u009f]/;
|
|
@@ -13,22 +12,22 @@ const TERMINAL_CONTROL_CHARACTERS = /[\u0000-\u001f\u007f-\u009f]/g;
|
|
|
13
12
|
// eslint-disable-next-line no-control-regex
|
|
14
13
|
const SOURCE_CONTROL_CHARACTERS = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g;
|
|
15
14
|
function escapeControlCharacter(character) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
const codePoint = character.codePointAt(0);
|
|
16
|
+
if (codePoint === undefined) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
return String.raw `\u${codePoint.toString(16).padStart(4, '0')}`;
|
|
21
20
|
}
|
|
22
21
|
function hasTerminalControlCharacters(value) {
|
|
23
|
-
|
|
22
|
+
return TERMINAL_CONTROL_CHARACTER.test(value);
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
/** Render untrusted text without allowing it to emit terminal control characters. */
|
|
27
25
|
function escapeTerminalText(value) {
|
|
28
|
-
|
|
26
|
+
return String(value).replace(TERMINAL_CONTROL_CHARACTERS, escapeControlCharacter);
|
|
29
27
|
}
|
|
30
|
-
|
|
31
28
|
/** Preserve source layout; normalize CRLF while escaping standalone carriage returns. */
|
|
32
29
|
function escapeTerminalSource(value) {
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
return value
|
|
31
|
+
.replace(/\r\n/g, '\n')
|
|
32
|
+
.replace(SOURCE_CONTROL_CHARACTERS, escapeControlCharacter);
|
|
33
|
+
}
|