@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
package/dist/bin/vip-wp.js
CHANGED
|
@@ -1,29 +1,63 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const core_1 = require("@apollo/client/core");
|
|
41
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const debug_1 = __importDefault(require("debug"));
|
|
43
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
44
|
+
const readline_1 = __importDefault(require("readline"));
|
|
45
|
+
const socket_io_client_1 = __importDefault(require("socket.io-client"));
|
|
46
|
+
const socket_io_stream_1 = __importDefault(require("socket.io-stream"));
|
|
47
|
+
const stream_1 = require("stream");
|
|
48
|
+
const wp_ssh_1 = require("../commands/wp-ssh");
|
|
49
|
+
const api_1 = __importStar(require("../lib/api"));
|
|
50
|
+
const app_1 = require("../lib/app");
|
|
51
|
+
const command_1 = __importStar(require("../lib/cli/command"));
|
|
52
|
+
const exit = __importStar(require("../lib/cli/exit"));
|
|
53
|
+
const format_1 = require("../lib/cli/format");
|
|
54
|
+
const prompt_1 = require("../lib/cli/prompt");
|
|
55
|
+
const proxy_agent_1 = require("../lib/http/proxy-agent");
|
|
56
|
+
const token_1 = __importDefault(require("../lib/token"));
|
|
57
|
+
const tracker_1 = require("../lib/tracker");
|
|
58
|
+
const helpers_1 = require("../lib/wp/helpers");
|
|
59
|
+
const readline_2 = require("../lib/wp/readline");
|
|
60
|
+
const debug = (0, debug_1.default)('@automattic/vip:wp');
|
|
27
61
|
const appQuery = `id, name, typeId,
|
|
28
62
|
organization {
|
|
29
63
|
id
|
|
@@ -46,109 +80,95 @@ let currentJob = null;
|
|
|
46
80
|
let currentOffset = 0;
|
|
47
81
|
let commandRunning = false;
|
|
48
82
|
const isStdinTty = process.stdin.isTTY;
|
|
49
|
-
const normalizeNewlineStream = new
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
83
|
+
const normalizeNewlineStream = new stream_1.Transform({
|
|
84
|
+
transform(chunk, encoding, callback) {
|
|
85
|
+
callback(null, chunk.toString().replace(/\r/g, '\n'));
|
|
86
|
+
},
|
|
53
87
|
});
|
|
54
|
-
const pipeStreamsToProcess = ({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
outStream.pipe(process.stdout);
|
|
64
|
-
};
|
|
65
|
-
const unpipeStreamsFromProcess = ({
|
|
66
|
-
stdin,
|
|
67
|
-
stdout: outStream
|
|
68
|
-
}) => {
|
|
69
|
-
if (isStdinTty) {
|
|
70
|
-
process.stdin.unpipe(normalizeNewlineStream);
|
|
71
|
-
normalizeNewlineStream.unpipe(stdin);
|
|
72
|
-
} else {
|
|
73
|
-
process.stdin.unpipe(stdin);
|
|
74
|
-
}
|
|
75
|
-
outStream.unpipe(process.stdout);
|
|
88
|
+
const pipeStreamsToProcess = ({ stdin, stdout: outStream }) => {
|
|
89
|
+
if (isStdinTty) {
|
|
90
|
+
process.stdin.pipe(normalizeNewlineStream).pipe(stdin);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
process.stdin.pipe(stdin);
|
|
94
|
+
}
|
|
95
|
+
outStream.pipe(process.stdout);
|
|
76
96
|
};
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
currentJob.finished = true;
|
|
88
|
-
clearTimeout(currentJob.exitTimer);
|
|
89
|
-
clearTimeout(currentJob.retryTimer);
|
|
90
|
-
subShellRl.clearLine();
|
|
91
|
-
commandRunning = false;
|
|
92
|
-
const tracking = (0, _tracker.trackEvent)('wpcli_command_end', commonTrackingParams).catch(() => {});
|
|
93
|
-
currentJob.socket.close();
|
|
94
|
-
unpipeStreamsFromProcess({
|
|
95
|
-
stdin: currentJob.stdinStream,
|
|
96
|
-
stdout: currentJob.stdoutStream
|
|
97
|
-
});
|
|
98
|
-
currentOffset = 0;
|
|
99
|
-
if (!isSubShell) {
|
|
100
|
-
subShellRl.close();
|
|
101
|
-
void tracking.catch(() => {}).finally(() => process.exit(exitCode));
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (exitCode) {
|
|
105
|
-
console.log(_chalk.default.red(`Error: WP-CLI command failed with exit code ${exitCode}`));
|
|
106
|
-
}
|
|
107
|
-
(0, _readline2.safeResume)(subShellRl);
|
|
108
|
-
(0, _readline2.safePrompt)(subShellRl);
|
|
97
|
+
const unpipeStreamsFromProcess = ({ stdin, stdout: outStream }) => {
|
|
98
|
+
if (isStdinTty) {
|
|
99
|
+
process.stdin.unpipe(normalizeNewlineStream);
|
|
100
|
+
normalizeNewlineStream.unpipe(stdin);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
process.stdin.unpipe(stdin);
|
|
104
|
+
}
|
|
105
|
+
outStream.unpipe(process.stdout);
|
|
109
106
|
};
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
isSubShell,
|
|
114
|
-
stdoutStream
|
|
115
|
-
}) => {
|
|
116
|
-
const job = currentJob;
|
|
117
|
-
const isCurrentStream = () => job === currentJob && !job.finished && stdoutStream === job.stdoutStream;
|
|
118
|
-
const criticalErrors = ['ECONNRESET', 'ETIMEDOUT', 'EHOSTUNREACH', 'ENOSPC', 'EACCES', 'EMFILE', 'ENOMEM'];
|
|
119
|
-
stdoutStream.on('error', err => {
|
|
120
|
-
if (!isCurrentStream()) {
|
|
121
|
-
return;
|
|
107
|
+
const finishCommand = ({ subShellRl, commonTrackingParams, isSubShell, exitCode = 0, job = currentJob, }) => {
|
|
108
|
+
if (job !== currentJob || job.finished) {
|
|
109
|
+
return;
|
|
122
110
|
}
|
|
111
|
+
currentJob.finished = true;
|
|
112
|
+
clearTimeout(currentJob.exitTimer);
|
|
113
|
+
clearTimeout(currentJob.retryTimer);
|
|
114
|
+
subShellRl.clearLine();
|
|
123
115
|
commandRunning = false;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
116
|
+
const tracking = (0, tracker_1.trackEvent)('wpcli_command_end', commonTrackingParams).catch(() => { });
|
|
117
|
+
currentJob.socket.close();
|
|
118
|
+
unpipeStreamsFromProcess({ stdin: currentJob.stdinStream, stdout: currentJob.stdoutStream });
|
|
119
|
+
currentOffset = 0;
|
|
120
|
+
if (!isSubShell) {
|
|
121
|
+
subShellRl.close();
|
|
122
|
+
void tracking.catch(() => { }).finally(() => process.exit(exitCode));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (exitCode) {
|
|
126
|
+
console.log(chalk_1.default.red(`Error: WP-CLI command failed with exit code ${exitCode}`));
|
|
129
127
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
(0, readline_2.safeResume)(subShellRl);
|
|
129
|
+
(0, readline_2.safePrompt)(subShellRl);
|
|
130
|
+
};
|
|
131
|
+
const bindStreamEvents = ({ subShellRl, commonTrackingParams, isSubShell, stdoutStream }) => {
|
|
132
|
+
const job = currentJob;
|
|
133
|
+
const isCurrentStream = () => job === currentJob && !job.finished && stdoutStream === job.stdoutStream;
|
|
134
|
+
const criticalErrors = [
|
|
135
|
+
'ECONNRESET',
|
|
136
|
+
'ETIMEDOUT',
|
|
137
|
+
'EHOSTUNREACH',
|
|
138
|
+
'ENOSPC',
|
|
139
|
+
'EACCES',
|
|
140
|
+
'EMFILE',
|
|
141
|
+
'ENOMEM',
|
|
142
|
+
];
|
|
143
|
+
stdoutStream.on('error', err => {
|
|
144
|
+
if (!isCurrentStream()) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
commandRunning = false;
|
|
148
|
+
if (criticalErrors.includes(err.code)) {
|
|
149
|
+
console.error(`Error: ${err.message}`);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// TODO handle this better
|
|
153
|
+
debug('Error: ' + err.message);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
stdoutStream.on('end', () => {
|
|
157
|
+
// Allow the server's exit event to deliver its status after stdout EOF.
|
|
136
158
|
if (isCurrentStream()) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
159
|
+
clearTimeout(job.exitTimer);
|
|
160
|
+
job.exitTimer = setTimeout(() => {
|
|
161
|
+
if (isCurrentStream()) {
|
|
162
|
+
finishCommand({ subShellRl, commonTrackingParams, isSubShell, job });
|
|
163
|
+
}
|
|
164
|
+
}, 2000);
|
|
143
165
|
}
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
});
|
|
166
|
+
});
|
|
147
167
|
};
|
|
148
168
|
const getTokenForCommand = async (appId, envId, command) => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
169
|
+
const api = (0, api_1.default)();
|
|
170
|
+
return api.mutate({
|
|
171
|
+
mutation: (0, graphql_tag_1.default) `
|
|
152
172
|
mutation TriggerWPCLICommandMutation($input: AppEnvironmentTriggerWPCLICommandInput) {
|
|
153
173
|
triggerWPCLICommandOnAppEnvironment(input: $input) {
|
|
154
174
|
inputToken
|
|
@@ -158,16 +178,15 @@ const getTokenForCommand = async (appId, envId, command) => {
|
|
|
158
178
|
}
|
|
159
179
|
}
|
|
160
180
|
`,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
181
|
+
variables: {
|
|
182
|
+
input: {
|
|
183
|
+
id: appId,
|
|
184
|
+
environmentId: envId,
|
|
185
|
+
command,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
});
|
|
169
189
|
};
|
|
170
|
-
|
|
171
190
|
/**
|
|
172
191
|
* Returns the error so it can be caught by the `socket.on('error')`.
|
|
173
192
|
*
|
|
@@ -175,447 +194,385 @@ const getTokenForCommand = async (appId, envId, command) => {
|
|
|
175
194
|
* @returns {Error}
|
|
176
195
|
*/
|
|
177
196
|
const onSocketError = err => err;
|
|
178
|
-
const launchCommandAndGetStreams = ({
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
197
|
+
const launchCommandAndGetStreams = ({ socket, guid, inputToken, offset = 0 }) => {
|
|
198
|
+
const stdoutStream = socket_io_stream_1.default.createStream();
|
|
199
|
+
const stdinStream = socket_io_stream_1.default.createStream();
|
|
200
|
+
stdoutStream.on('data', data => {
|
|
201
|
+
if (currentJob?.stdoutStream === stdoutStream && !currentJob.finished) {
|
|
202
|
+
currentOffset += data.length;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
// TODO handle all arguments
|
|
206
|
+
// TODO handle disconnect - does IOStream correctly buffer stdin?
|
|
207
|
+
// TODO stderr - currently server doesn't support it, so errors don't terminate process
|
|
208
|
+
const data = {
|
|
209
|
+
guid,
|
|
210
|
+
inputToken,
|
|
211
|
+
columns: process.stdout.columns || NON_TTY_COLUMNS,
|
|
212
|
+
rows: process.stdout.rows || NON_TTY_ROWS,
|
|
213
|
+
offset,
|
|
214
|
+
};
|
|
215
|
+
(0, socket_io_stream_1.default)(socket).emit('cmd', data, stdinStream, stdoutStream);
|
|
216
|
+
const onUnauthorized = err => {
|
|
217
|
+
if (currentJob?.socket !== socket || currentJob.finished) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
console.log('There was an error with the authentication:', err.message);
|
|
221
|
+
};
|
|
222
|
+
const onCancel = message => {
|
|
223
|
+
if (currentJob?.socket !== socket || currentJob.finished) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
socket.close();
|
|
227
|
+
exit.withError(`Cancel received from server: ${message}`);
|
|
228
|
+
};
|
|
229
|
+
(0, socket_io_stream_1.default)(socket).off('error', onSocketError).on('error', onSocketError);
|
|
230
|
+
const onError = err => {
|
|
231
|
+
if (currentJob?.socket !== socket || currentJob.finished) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (err === 'Rate limit exceeded') {
|
|
235
|
+
console.log(chalk_1.default.red('\nError:'), 'Rate limit exceeded: Please wait a moment and try again.');
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
console.log(err);
|
|
239
|
+
};
|
|
240
|
+
if (currentJob?.socket === socket) {
|
|
241
|
+
for (const [event, handler] of Object.entries(currentJob.socketHandlers)) {
|
|
242
|
+
socket.off(event, handler);
|
|
243
|
+
}
|
|
225
244
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
for (const [event, handler] of Object.entries(currentJob.socketHandlers)) {
|
|
230
|
-
socket.off(event, handler);
|
|
245
|
+
const socketHandlers = { unauthorized: onUnauthorized, cancel: onCancel, error: onError };
|
|
246
|
+
for (const [event, handler] of Object.entries(socketHandlers)) {
|
|
247
|
+
socket.on(event, handler);
|
|
231
248
|
}
|
|
232
|
-
|
|
233
|
-
const socketHandlers = {
|
|
234
|
-
unauthorized: onUnauthorized,
|
|
235
|
-
cancel: onCancel,
|
|
236
|
-
error: onError
|
|
237
|
-
};
|
|
238
|
-
for (const [event, handler] of Object.entries(socketHandlers)) {
|
|
239
|
-
socket.on(event, handler);
|
|
240
|
-
}
|
|
241
|
-
return {
|
|
242
|
-
stdinStream,
|
|
243
|
-
stdoutStream,
|
|
244
|
-
socket,
|
|
245
|
-
socketHandlers
|
|
246
|
-
};
|
|
249
|
+
return { stdinStream, stdoutStream, socket, socketHandlers };
|
|
247
250
|
};
|
|
248
|
-
const bindReconnectEvents = ({
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
// Rebind new streams
|
|
285
|
-
pipeStreamsToProcess({
|
|
286
|
-
stdin: currentJob.stdinStream,
|
|
287
|
-
stdout: currentJob.stdoutStream
|
|
288
|
-
});
|
|
289
|
-
bindStreamEvents({
|
|
290
|
-
subShellRl,
|
|
291
|
-
isSubShell,
|
|
292
|
-
commonTrackingParams,
|
|
293
|
-
stdoutStream: currentJob.stdoutStream
|
|
251
|
+
const bindReconnectEvents = ({ cliCommand, inputToken, subShellRl, commonTrackingParams, isSubShell, }) => {
|
|
252
|
+
const job = currentJob;
|
|
253
|
+
const isCurrentJob = () => job === currentJob && !job.finished;
|
|
254
|
+
currentJob.socket.io.removeAllListeners('reconnect');
|
|
255
|
+
currentJob.socket.io.removeAllListeners('reconnect_attempt');
|
|
256
|
+
currentJob.socket.removeAllListeners('retry');
|
|
257
|
+
currentJob.socket.removeAllListeners('connect_error');
|
|
258
|
+
currentJob.socket.removeAllListeners('exit');
|
|
259
|
+
currentJob.socket.io.on('reconnect', () => {
|
|
260
|
+
if (!isCurrentJob()) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
debug('socket.io: reconnect');
|
|
264
|
+
clearTimeout(job.exitTimer);
|
|
265
|
+
clearTimeout(job.retryTimer);
|
|
266
|
+
// Close old streams
|
|
267
|
+
unpipeStreamsFromProcess({ stdin: currentJob.stdinStream, stdout: currentJob.stdoutStream });
|
|
268
|
+
(0, tracker_1.trackEvent)('wpcli_command_reconnect', commonTrackingParams).catch(() => { });
|
|
269
|
+
job.finished = true;
|
|
270
|
+
currentJob = launchCommandAndGetStreams({
|
|
271
|
+
socket: currentJob.socket,
|
|
272
|
+
guid: cliCommand.guid,
|
|
273
|
+
inputToken,
|
|
274
|
+
offset: currentOffset,
|
|
275
|
+
});
|
|
276
|
+
// Rebind new streams
|
|
277
|
+
pipeStreamsToProcess({ stdin: currentJob.stdinStream, stdout: currentJob.stdoutStream });
|
|
278
|
+
bindStreamEvents({
|
|
279
|
+
subShellRl,
|
|
280
|
+
isSubShell,
|
|
281
|
+
commonTrackingParams,
|
|
282
|
+
stdoutStream: currentJob.stdoutStream,
|
|
283
|
+
});
|
|
284
|
+
bindReconnectEvents({ cliCommand, inputToken, subShellRl, commonTrackingParams, isSubShell });
|
|
285
|
+
// Resume readline interface
|
|
286
|
+
(0, readline_2.safeResume)(subShellRl);
|
|
294
287
|
});
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
288
|
+
currentJob.socket.on('retry', () => {
|
|
289
|
+
if (!isCurrentJob()) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
debug('socket: retry');
|
|
293
|
+
clearTimeout(job.retryTimer);
|
|
294
|
+
job.retryTimer = setTimeout(() => {
|
|
295
|
+
if (isCurrentJob()) {
|
|
296
|
+
job.socket.io.engine.close();
|
|
297
|
+
}
|
|
298
|
+
}, 5000);
|
|
301
299
|
});
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
debug('socket: retry');
|
|
311
|
-
clearTimeout(job.retryTimer);
|
|
312
|
-
job.retryTimer = setTimeout(() => {
|
|
313
|
-
if (isCurrentJob()) {
|
|
314
|
-
job.socket.io.engine.close();
|
|
315
|
-
}
|
|
316
|
-
}, 5000);
|
|
317
|
-
});
|
|
318
|
-
currentJob.socket.on('connect_error', () => {
|
|
319
|
-
if (!isCurrentJob()) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
debug('socket: connect_error; forcing the preference for websocket');
|
|
323
|
-
|
|
324
|
-
// Force the preference for WebSocket in case we see an error during connection
|
|
325
|
-
// https://socket.io/docs/v3/client-initialization/#low-level-engine-options
|
|
326
|
-
currentJob.socket.io.opts.transports = ['websocket', 'polling'];
|
|
327
|
-
});
|
|
328
|
-
currentJob.socket.on('exit', ({
|
|
329
|
-
exitCode,
|
|
330
|
-
message
|
|
331
|
-
}) => {
|
|
332
|
-
if (!isCurrentJob()) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
debug('socket: exit. Code: %d. Message: %s', exitCode, message);
|
|
336
|
-
if (message) {
|
|
337
|
-
console.log(message);
|
|
338
|
-
}
|
|
339
|
-
currentJob.stdinStream.destroy();
|
|
340
|
-
currentJob.stdoutStream.destroy();
|
|
341
|
-
finishCommand({
|
|
342
|
-
subShellRl,
|
|
343
|
-
commonTrackingParams,
|
|
344
|
-
isSubShell,
|
|
345
|
-
exitCode
|
|
300
|
+
currentJob.socket.on('connect_error', () => {
|
|
301
|
+
if (!isCurrentJob()) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
debug('socket: connect_error; forcing the preference for websocket');
|
|
305
|
+
// Force the preference for WebSocket in case we see an error during connection
|
|
306
|
+
// https://socket.io/docs/v3/client-initialization/#low-level-engine-options
|
|
307
|
+
currentJob.socket.io.opts.transports = ['websocket', 'polling'];
|
|
346
308
|
});
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
// create a new input stream so that we can still catch things like SIGINT while reconnecting
|
|
360
|
-
if (currentJob.stdinStream) {
|
|
361
|
-
unpipeStreamsFromProcess({
|
|
362
|
-
stdin: currentJob.stdinStream,
|
|
363
|
-
stdout: currentJob.stdoutStream
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
currentJob.stdinStream = _socket2.default.createStream();
|
|
367
|
-
currentJob.stdoutStream = _socket2.default.createStream();
|
|
368
|
-
pipeStreamsToProcess({
|
|
369
|
-
stdin: currentJob.stdinStream,
|
|
370
|
-
stdout: currentJob.stdoutStream
|
|
309
|
+
currentJob.socket.on('exit', ({ exitCode, message }) => {
|
|
310
|
+
if (!isCurrentJob()) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
debug('socket: exit. Code: %d. Message: %s', exitCode, message);
|
|
314
|
+
if (message) {
|
|
315
|
+
console.log(message);
|
|
316
|
+
}
|
|
317
|
+
currentJob.stdinStream.destroy();
|
|
318
|
+
currentJob.stdoutStream.destroy();
|
|
319
|
+
finishCommand({ subShellRl, commonTrackingParams, isSubShell, exitCode });
|
|
371
320
|
});
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
321
|
+
currentJob.socket.io.on('reconnect_attempt', attempt => {
|
|
322
|
+
if (!isCurrentJob()) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
debug('There was an error connecting to the server. Retrying...');
|
|
326
|
+
if (attempt > 1) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
clearTimeout(job.exitTimer);
|
|
330
|
+
clearTimeout(job.retryTimer);
|
|
331
|
+
// create a new input stream so that we can still catch things like SIGINT while reconnecting
|
|
332
|
+
if (currentJob.stdinStream) {
|
|
333
|
+
unpipeStreamsFromProcess({
|
|
334
|
+
stdin: currentJob.stdinStream,
|
|
335
|
+
stdout: currentJob.stdoutStream,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
currentJob.stdinStream = socket_io_stream_1.default.createStream();
|
|
339
|
+
currentJob.stdoutStream = socket_io_stream_1.default.createStream();
|
|
340
|
+
pipeStreamsToProcess({ stdin: currentJob.stdinStream, stdout: currentJob.stdoutStream });
|
|
341
|
+
bindStreamEvents({
|
|
342
|
+
subShellRl,
|
|
343
|
+
isSubShell,
|
|
344
|
+
commonTrackingParams,
|
|
345
|
+
stdoutStream: currentJob.stdoutStream,
|
|
346
|
+
});
|
|
377
347
|
});
|
|
378
|
-
});
|
|
379
348
|
};
|
|
380
|
-
|
|
381
349
|
// Command examples
|
|
382
|
-
const examples = [
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
id: envId,
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
if ((0, _app.isAppNodejs)(appTypeId)) {
|
|
422
|
-
exit.withError('WP-CLI commands are not supported on Node.js environments.');
|
|
423
|
-
}
|
|
424
|
-
const commonTrackingParams = {
|
|
425
|
-
command: commandForAnalytics,
|
|
426
|
-
app_id: appId,
|
|
427
|
-
env_id: envId,
|
|
428
|
-
org_id: orgId,
|
|
429
|
-
method: isSubShell ? 'subshell' : 'shell'
|
|
430
|
-
};
|
|
431
|
-
(0, _tracker.trackEvent)('wpcli_command_execute', commonTrackingParams).catch(() => {});
|
|
432
|
-
if (isSubShell) {
|
|
433
|
-
// Reset the cursor (can get messed up with enquirer)
|
|
434
|
-
process.stdout.write('\u001b[?25h');
|
|
435
|
-
console.log(`Welcome to the WP-CLI shell for the ${(0, _format.formatEnvironment)(envName)} environment of ${_chalk.default.green(appName)} (${opts.env.primaryDomain.name})!`);
|
|
436
|
-
} else if (envName === 'production') {
|
|
437
|
-
const yes = opts.yes || (await (0, _prompt.confirm)([{
|
|
438
|
-
key: 'command',
|
|
439
|
-
value: `wp ${cmd}`
|
|
440
|
-
}], `Are you sure you want to run this command on ${(0, _format.formatEnvironment)(envName)} for site ${appName}?`));
|
|
441
|
-
if (!yes) {
|
|
442
|
-
(0, _tracker.trackEvent)('wpcli_confirm_cancel', commonTrackingParams).catch(() => {});
|
|
443
|
-
console.log('Command cancelled');
|
|
444
|
-
process.exit();
|
|
350
|
+
const examples = [
|
|
351
|
+
{
|
|
352
|
+
usage: `vip @example-app.develop -- wp site list`,
|
|
353
|
+
description: 'Use a WP-CLI command to retrieve the list of network sites on the develop environment of the "example-app" WordPress multisite application.',
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
usage: `vip @example-app.production --yes -- wp user list`,
|
|
357
|
+
description: 'Use a WP-CLI command to retrieve the list of Super Admins on the production environment and automatically answer "yes" to the confirmation prompt.',
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
usage: `vip @example-app.develop -- wp post list --posts_per_page=100 --url=dev.example.com`,
|
|
361
|
+
description: 'Use a WP-CLI command to retrieve the list of posts for the network site dev.example.com.',
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
usage: `vip @example-app.develop -- wp\n` +
|
|
365
|
+
` - example-app.develop:~$ wp option get home\n` +
|
|
366
|
+
` - https://dev.example.com`,
|
|
367
|
+
description: 'Use the VIP-CLI to launch an interactive WP-CLI shell console and run WP-CLI commands on the develop environment.',
|
|
368
|
+
},
|
|
369
|
+
];
|
|
370
|
+
(0, command_1.default)({
|
|
371
|
+
wildcardCommand: true,
|
|
372
|
+
appContext: true,
|
|
373
|
+
envContext: true,
|
|
374
|
+
appQuery,
|
|
375
|
+
})
|
|
376
|
+
.option('yes', 'Answer yes to the confirmation prompt (only on production environments).')
|
|
377
|
+
.examples(examples)
|
|
378
|
+
.argv(process.argv, async (args, opts) => {
|
|
379
|
+
const isSubShell = 0 === args.length;
|
|
380
|
+
// Have to re-quote anything that needs it before we pass it on
|
|
381
|
+
const quotedArgs = (0, format_1.requoteArgs)(args);
|
|
382
|
+
const cmd = quotedArgs.join(' ');
|
|
383
|
+
// Store only the first 2 parts of command to avoid recording secrets. Can be tweaked
|
|
384
|
+
const commandForAnalytics = quotedArgs.slice(0, 2).join(' ');
|
|
385
|
+
const { id: appId, name: appName, typeId: appTypeId, organization: { id: orgId }, } = opts.app;
|
|
386
|
+
const { id: envId, type: envName } = opts.env;
|
|
387
|
+
if ((0, app_1.isAppNodejs)(appTypeId)) {
|
|
388
|
+
exit.withError('WP-CLI commands are not supported on Node.js environments.');
|
|
445
389
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
const mutableStdout = new _stream.Writable({
|
|
460
|
-
write(chunk, encoding, callback) {
|
|
461
|
-
if (!this.muted) {
|
|
462
|
-
process.stdout.write(chunk, encoding);
|
|
463
|
-
}
|
|
464
|
-
callback();
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
mutableStdout.muted = false;
|
|
468
|
-
const subShellSettings = {
|
|
469
|
-
input: process.stdin,
|
|
470
|
-
output: mutableStdout,
|
|
471
|
-
terminal: true,
|
|
472
|
-
prompt: '',
|
|
473
|
-
historySize: 0,
|
|
474
|
-
crlfDelay: Infinity
|
|
475
|
-
};
|
|
476
|
-
if (isSubShell) {
|
|
477
|
-
subShellSettings.prompt = _chalk.default.bold.yellowBright(`${promptIdentifier}:`) + _chalk.default.blue('~') + '$ ';
|
|
478
|
-
subShellSettings.historySize = 200;
|
|
479
|
-
}
|
|
480
|
-
const commandState = (0, _helpers.initState)();
|
|
481
|
-
let seenWP = false;
|
|
482
|
-
const subShellRl = _readline.default.createInterface(subShellSettings);
|
|
483
|
-
(0, _readline2.trackReadline)(subShellRl);
|
|
484
|
-
subShellRl.on('line', async line => {
|
|
485
|
-
if (commandRunning) {
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// Handle plain return / newline
|
|
490
|
-
if (!line && !seenWP) {
|
|
491
|
-
(0, _readline2.safePrompt)(subShellRl);
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
// Check for exit, like SSH (handles both `exit` and `exit;`)
|
|
496
|
-
if (!seenWP && line.startsWith('exit')) {
|
|
497
|
-
subShellRl.close();
|
|
498
|
-
process.exit();
|
|
499
|
-
}
|
|
500
|
-
const userCmdCancelled = line === cancelCommandChar;
|
|
501
|
-
if (userCmdCancelled) {
|
|
502
|
-
seenWP = false;
|
|
503
|
-
(0, _helpers.resetState)(commandState);
|
|
504
|
-
(0, _readline2.safePrompt)(subShellRl);
|
|
505
|
-
return;
|
|
390
|
+
const commonTrackingParams = {
|
|
391
|
+
command: commandForAnalytics,
|
|
392
|
+
app_id: appId,
|
|
393
|
+
env_id: envId,
|
|
394
|
+
org_id: orgId,
|
|
395
|
+
method: isSubShell ? 'subshell' : 'shell',
|
|
396
|
+
};
|
|
397
|
+
(0, tracker_1.trackEvent)('wpcli_command_execute', commonTrackingParams).catch(() => { });
|
|
398
|
+
if (isSubShell) {
|
|
399
|
+
// Reset the cursor (can get messed up with enquirer)
|
|
400
|
+
process.stdout.write('\u001b[?25h');
|
|
401
|
+
console.log(`Welcome to the WP-CLI shell for the ${(0, format_1.formatEnvironment)(envName)} environment of ${chalk_1.default.green(appName)} (${opts.env.primaryDomain.name})!`);
|
|
506
402
|
}
|
|
507
|
-
if (
|
|
508
|
-
|
|
509
|
-
|
|
403
|
+
else if (envName === 'production') {
|
|
404
|
+
const yes = opts.yes ||
|
|
405
|
+
(await (0, prompt_1.confirm)([
|
|
406
|
+
{
|
|
407
|
+
key: 'command',
|
|
408
|
+
value: `wp ${cmd}`,
|
|
409
|
+
},
|
|
410
|
+
], `Are you sure you want to run this command on ${(0, format_1.formatEnvironment)(envName)} for site ${appName}?`));
|
|
411
|
+
if (!yes) {
|
|
412
|
+
(0, tracker_1.trackEvent)('wpcli_confirm_cancel', commonTrackingParams).catch(() => { });
|
|
413
|
+
console.log('Command cancelled');
|
|
414
|
+
process.exit();
|
|
415
|
+
}
|
|
510
416
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
417
|
+
// We'll handle our own errors, thank you
|
|
418
|
+
(0, api_1.disableGlobalGraphQLErrorHandling)();
|
|
419
|
+
const promptIdentifier = `${appName}.${(0, command_1.getEnvIdentifier)(opts.env)}`;
|
|
420
|
+
let countSIGINT = 0;
|
|
421
|
+
if (opts.env.wpcliStrategy === 'ssh') {
|
|
422
|
+
const wpCommandRunner = new wp_ssh_1.WPCliCommandOverSSH(opts.app, opts.env);
|
|
423
|
+
await wpCommandRunner.run(cmd, { command: commandForAnalytics });
|
|
514
424
|
return;
|
|
515
|
-
}
|
|
516
|
-
} else {
|
|
517
|
-
(0, _helpers.resetState)(commandState);
|
|
518
|
-
console.log(_chalk.default.red('Error:'), 'invalid command, please pass a valid WP-CLI command.');
|
|
519
|
-
(0, _readline2.safePrompt)(subShellRl);
|
|
520
|
-
return;
|
|
521
425
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
544
|
-
(0, _readline2.safePrompt)(subShellRl);
|
|
545
|
-
return;
|
|
426
|
+
const mutableStdout = new stream_1.Writable({
|
|
427
|
+
write(chunk, encoding, callback) {
|
|
428
|
+
if (!this.muted) {
|
|
429
|
+
process.stdout.write(chunk, encoding);
|
|
430
|
+
}
|
|
431
|
+
callback();
|
|
432
|
+
},
|
|
433
|
+
});
|
|
434
|
+
mutableStdout.muted = false;
|
|
435
|
+
const subShellSettings = {
|
|
436
|
+
input: process.stdin,
|
|
437
|
+
output: mutableStdout,
|
|
438
|
+
terminal: true,
|
|
439
|
+
prompt: '',
|
|
440
|
+
historySize: 0,
|
|
441
|
+
crlfDelay: Infinity,
|
|
442
|
+
};
|
|
443
|
+
if (isSubShell) {
|
|
444
|
+
subShellSettings.prompt =
|
|
445
|
+
chalk_1.default.bold.yellowBright(`${promptIdentifier}:`) + chalk_1.default.blue('~') + '$ ';
|
|
446
|
+
subShellSettings.historySize = 200;
|
|
546
447
|
}
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
448
|
+
const commandState = (0, helpers_1.initState)();
|
|
449
|
+
let seenWP = false;
|
|
450
|
+
const subShellRl = readline_1.default.createInterface(subShellSettings);
|
|
451
|
+
(0, readline_2.trackReadline)(subShellRl);
|
|
452
|
+
subShellRl.on('line', async (line) => {
|
|
453
|
+
if (commandRunning) {
|
|
454
|
+
return;
|
|
552
455
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
Authorization: `Bearer ${token.raw}`
|
|
558
|
-
};
|
|
559
|
-
const socket = (0, _socket.default)(`${_api.API_HOST}/wp-cli`, {
|
|
560
|
-
transportOptions: {
|
|
561
|
-
polling: {
|
|
562
|
-
extraHeaders
|
|
563
|
-
},
|
|
564
|
-
websocket: {
|
|
565
|
-
extraHeaders
|
|
456
|
+
// Handle plain return / newline
|
|
457
|
+
if (!line && !seenWP) {
|
|
458
|
+
(0, readline_2.safePrompt)(subShellRl);
|
|
459
|
+
return;
|
|
566
460
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
461
|
+
// Check for exit, like SSH (handles both `exit` and `exit;`)
|
|
462
|
+
if (!seenWP && line.startsWith('exit')) {
|
|
463
|
+
subShellRl.close();
|
|
464
|
+
process.exit();
|
|
465
|
+
}
|
|
466
|
+
const userCmdCancelled = line === cancelCommandChar;
|
|
467
|
+
if (userCmdCancelled) {
|
|
468
|
+
seenWP = false;
|
|
469
|
+
(0, helpers_1.resetState)(commandState);
|
|
470
|
+
(0, readline_2.safePrompt)(subShellRl);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
if (!seenWP && line.trimStart().startsWith('wp ')) {
|
|
474
|
+
seenWP = true;
|
|
475
|
+
(0, helpers_1.resetState)(commandState);
|
|
476
|
+
}
|
|
477
|
+
if (seenWP) {
|
|
478
|
+
(0, helpers_1.stateMachine)(commandState, line);
|
|
479
|
+
if (!commandState.done) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
(0, helpers_1.resetState)(commandState);
|
|
485
|
+
console.log(chalk_1.default.red('Error:'), 'invalid command, please pass a valid WP-CLI command.');
|
|
486
|
+
(0, readline_2.safePrompt)(subShellRl);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
(0, readline_2.safePause)(subShellRl);
|
|
490
|
+
countSIGINT = 0;
|
|
491
|
+
let result;
|
|
492
|
+
const wpCliCmd = commandState.command.trimStart().replace(/^wp\s+/, '');
|
|
493
|
+
seenWP = false;
|
|
494
|
+
(0, helpers_1.resetState)(commandState);
|
|
495
|
+
try {
|
|
496
|
+
result = await getTokenForCommand(appId, envId, wpCliCmd);
|
|
497
|
+
}
|
|
498
|
+
catch (error) {
|
|
499
|
+
// If this was a GraphQL error, print that to the message to the line
|
|
500
|
+
if (core_1.CombinedGraphQLErrors.is(error)) {
|
|
501
|
+
for (const err of error.errors) {
|
|
502
|
+
console.log(chalk_1.default.red('Error:'), err.message);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
// Else, other type of error, just dump it
|
|
507
|
+
console.log(error);
|
|
508
|
+
}
|
|
509
|
+
if (!isSubShell) {
|
|
510
|
+
subShellRl.close();
|
|
511
|
+
process.exit(1);
|
|
512
|
+
}
|
|
513
|
+
(0, readline_2.safePrompt)(subShellRl);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
const { data: { triggerWPCLICommandOnAppEnvironment: { command: cliCommand, inputToken }, }, } = result;
|
|
517
|
+
const token = await token_1.default.get();
|
|
518
|
+
const extraHeaders = {
|
|
519
|
+
Authorization: `Bearer ${token.raw}`,
|
|
520
|
+
};
|
|
521
|
+
const socket = (0, socket_io_client_1.default)(`${api_1.API_HOST}/wp-cli`, {
|
|
522
|
+
transportOptions: {
|
|
523
|
+
polling: {
|
|
524
|
+
extraHeaders,
|
|
525
|
+
},
|
|
526
|
+
websocket: {
|
|
527
|
+
extraHeaders,
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
agent: (0, proxy_agent_1.createProxyAgent)(api_1.API_HOST),
|
|
531
|
+
});
|
|
532
|
+
currentJob = launchCommandAndGetStreams({
|
|
533
|
+
socket,
|
|
534
|
+
guid: cliCommand.guid,
|
|
535
|
+
inputToken,
|
|
536
|
+
});
|
|
537
|
+
pipeStreamsToProcess({ stdin: currentJob.stdinStream, stdout: currentJob.stdoutStream });
|
|
538
|
+
commandRunning = true;
|
|
539
|
+
bindStreamEvents({
|
|
540
|
+
subShellRl,
|
|
541
|
+
commonTrackingParams,
|
|
542
|
+
isSubShell,
|
|
543
|
+
stdoutStream: currentJob.stdoutStream,
|
|
544
|
+
});
|
|
545
|
+
bindReconnectEvents({
|
|
546
|
+
cliCommand,
|
|
547
|
+
inputToken,
|
|
548
|
+
subShellRl,
|
|
549
|
+
commonTrackingParams,
|
|
550
|
+
isSubShell,
|
|
551
|
+
});
|
|
585
552
|
});
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
553
|
+
subShellRl.on('SIGINT', async () => {
|
|
554
|
+
// if we have a 2nd SIGINT, exit immediately
|
|
555
|
+
if (countSIGINT >= 1) {
|
|
556
|
+
process.exit();
|
|
557
|
+
}
|
|
558
|
+
countSIGINT += 1;
|
|
559
|
+
// write out CTRL-C/SIGINT
|
|
560
|
+
process.stdin.write(cancelCommandChar);
|
|
561
|
+
if (currentJob?.stdoutStream) {
|
|
562
|
+
currentJob.stdoutStream.end();
|
|
563
|
+
}
|
|
564
|
+
await (0, tracker_1.trackEvent)('wpcli_cancel_command', commonTrackingParams);
|
|
565
|
+
console.log('Command cancelled by user');
|
|
566
|
+
// if no command running (.e.g. interactive shell) exit only after doing cleanup
|
|
567
|
+
if (commandRunning === false) {
|
|
568
|
+
process.exit();
|
|
569
|
+
}
|
|
592
570
|
});
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
}
|
|
599
|
-
countSIGINT += 1;
|
|
600
|
-
|
|
601
|
-
// write out CTRL-C/SIGINT
|
|
602
|
-
process.stdin.write(cancelCommandChar);
|
|
603
|
-
if (currentJob?.stdoutStream) {
|
|
604
|
-
currentJob.stdoutStream.end();
|
|
605
|
-
}
|
|
606
|
-
await (0, _tracker.trackEvent)('wpcli_cancel_command', commonTrackingParams);
|
|
607
|
-
console.log('Command cancelled by user');
|
|
608
|
-
|
|
609
|
-
// if no command running (.e.g. interactive shell) exit only after doing cleanup
|
|
610
|
-
if (commandRunning === false) {
|
|
611
|
-
process.exit();
|
|
571
|
+
if (!isSubShell) {
|
|
572
|
+
mutableStdout.muted = true;
|
|
573
|
+
(0, readline_2.safeWrite)(subShellRl, `wp ${cmd}\n`);
|
|
574
|
+
mutableStdout.muted = false;
|
|
575
|
+
return;
|
|
612
576
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
mutableStdout.muted = true;
|
|
616
|
-
(0, _readline2.safeWrite)(subShellRl, `wp ${cmd}\n`);
|
|
617
|
-
mutableStdout.muted = false;
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
(0, _readline2.safePrompt)(subShellRl);
|
|
621
|
-
});
|
|
577
|
+
(0, readline_2.safePrompt)(subShellRl);
|
|
578
|
+
});
|