@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,30 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.validate = exports.staticSqlValidations = exports.getTableNames = exports.validateImportFileExtension = void 0;
|
|
5
40
|
exports.validateFilename = validateFilename;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
41
|
+
const single_line_log_1 = require("@wwa/single-line-log");
|
|
42
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
43
|
+
const node_events_1 = require("node:events");
|
|
44
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
45
|
+
const exit = __importStar(require("../../lib/cli/exit"));
|
|
46
|
+
const client_file_uploader_1 = require("../../lib/client-file-uploader");
|
|
47
|
+
const tracker_1 = require("../../lib/tracker");
|
|
48
|
+
const line_by_line_1 = require("../../lib/validations/line-by-line");
|
|
49
|
+
const sql_insert_parser_1 = require("../../lib/validations/sql-insert-parser");
|
|
17
50
|
let problemsFound = 0;
|
|
18
51
|
let lineNum = 1;
|
|
19
52
|
const tableNames = [];
|
|
53
|
+
let currentInsertStatementTableName;
|
|
54
|
+
let currentInsertStatementColumns;
|
|
55
|
+
let currentInsertStatementColumnList;
|
|
56
|
+
let currentInsertStatementHasValues = false;
|
|
57
|
+
let currentInsertStatementValuesFinished = false;
|
|
58
|
+
let currentInsertStatementRowBuffer;
|
|
59
|
+
let currentSqlCommentStripState = { inBlockComment: false };
|
|
20
60
|
function formatError(message) {
|
|
21
|
-
|
|
61
|
+
return `${chalk_1.default.red('SQL Error:')} ${message}`;
|
|
22
62
|
}
|
|
23
63
|
function formatWarning(message) {
|
|
24
|
-
|
|
64
|
+
return `${chalk_1.default.yellow('Warning:')} ${message}`;
|
|
25
65
|
}
|
|
26
66
|
function formatRecommendation(message) {
|
|
27
|
-
|
|
67
|
+
return `${chalk_1.default.yellow('Recommendation:')} ${message}`;
|
|
28
68
|
}
|
|
29
69
|
/**
|
|
30
70
|
* Check if a file has a valid extension
|
|
@@ -32,451 +72,531 @@ function formatRecommendation(message) {
|
|
|
32
72
|
* @param {string} filename The file extension
|
|
33
73
|
* @returns {boolean} True if the extension is valid
|
|
34
74
|
*/
|
|
35
|
-
const validateImportFileExtension = filename => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
75
|
+
const validateImportFileExtension = (filename) => {
|
|
76
|
+
const ext = node_path_1.default.extname(filename).toLowerCase();
|
|
77
|
+
if (!['.sql', '.gz'].includes(ext)) {
|
|
78
|
+
exit.withError('Invalid file extension. Please provide a .sql or .gz file.');
|
|
79
|
+
}
|
|
40
80
|
};
|
|
41
81
|
exports.validateImportFileExtension = validateImportFileExtension;
|
|
42
82
|
function validateFilename(filename) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
83
|
+
const re = /^[a-z0-9\-_.]+$/i;
|
|
84
|
+
// Exits if filename contains anything outside a-z A-Z - _ .
|
|
85
|
+
if (!re.test(filename)) {
|
|
86
|
+
exit.withError('Error: The characters used in the name of a file for import are limited to [0-9,a-z,A-Z,-,_,.]');
|
|
87
|
+
}
|
|
49
88
|
}
|
|
50
|
-
const generalCheckFormatter = check => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
89
|
+
const generalCheckFormatter = (check) => {
|
|
90
|
+
const errors = [];
|
|
91
|
+
const infos = [];
|
|
92
|
+
const validProblems = check.results.filter(result => !result.falsePositive);
|
|
93
|
+
if (validProblems.length > 0) {
|
|
94
|
+
if (validProblems.some(result => !result.warning)) {
|
|
95
|
+
problemsFound += 1;
|
|
96
|
+
}
|
|
97
|
+
for (const problem of validProblems) {
|
|
98
|
+
const text = `${problem.text ?? check.message} on line ${problem.lineNumber ?? ''}.`;
|
|
99
|
+
if (problem.warning) {
|
|
100
|
+
errors.push({
|
|
101
|
+
warning: formatWarning(text),
|
|
102
|
+
recommendation: formatRecommendation(problem.recomendation ?? check.recommendation),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
errors.push({
|
|
107
|
+
error: formatError(text),
|
|
108
|
+
recommendation: formatRecommendation(problem.recomendation ?? check.recommendation),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
infos.push(`✅ ${check.message} was found 0 times.`);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
errors,
|
|
118
|
+
infos,
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
const lineNumberCheckFormatter = (check) => {
|
|
122
|
+
const errors = [];
|
|
123
|
+
const infos = [];
|
|
124
|
+
if (check.results.length > 0) {
|
|
125
|
+
problemsFound += 1;
|
|
126
|
+
const lineNumbers = check.results.map(result => result.lineNumber);
|
|
61
127
|
errors.push({
|
|
62
|
-
|
|
63
|
-
|
|
128
|
+
error: formatError(`${check.message} on line(s) ${lineNumbers.join(', ')}.`),
|
|
129
|
+
recommendation: formatRecommendation(check.recommendation),
|
|
64
130
|
});
|
|
65
|
-
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
infos.push(`✅ ${check.message} was found 0 times.`);
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
errors,
|
|
137
|
+
infos,
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
const requiredCheckFormatter = (check, type, isImport) => {
|
|
141
|
+
const errors = [];
|
|
142
|
+
const infos = [];
|
|
143
|
+
if (check.results.length > 0) {
|
|
144
|
+
infos.push(`✅ ${check.message} was found ${check.results.length} times.`);
|
|
145
|
+
if (type === 'createTable') {
|
|
146
|
+
if (!isImport) {
|
|
147
|
+
checkTablePrefixes(check.results, errors, infos);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
problemsFound += 1;
|
|
66
153
|
errors.push({
|
|
67
|
-
|
|
68
|
-
|
|
154
|
+
error: formatError(`${check.message} was not found.`),
|
|
155
|
+
recommendation: formatRecommendation(check.recommendation),
|
|
69
156
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
errors,
|
|
77
|
-
infos
|
|
78
|
-
};
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
errors,
|
|
160
|
+
infos,
|
|
161
|
+
};
|
|
79
162
|
};
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
errors.push({
|
|
87
|
-
error: formatError(`${check.message} on line(s) ${lineNumbers.join(', ')}.`),
|
|
88
|
-
recommendation: formatRecommendation(check.recommendation)
|
|
163
|
+
const infoCheckFormatter = (check) => {
|
|
164
|
+
const infos = [];
|
|
165
|
+
check.results.forEach(item => {
|
|
166
|
+
if (item.text) {
|
|
167
|
+
infos.push(item.text);
|
|
168
|
+
}
|
|
89
169
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
errors,
|
|
95
|
-
infos
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
const requiredCheckFormatter = (check, type, isImport) => {
|
|
99
|
-
const errors = [];
|
|
100
|
-
const infos = [];
|
|
101
|
-
if (check.results.length > 0) {
|
|
102
|
-
infos.push(`✅ ${check.message} was found ${check.results.length} times.`);
|
|
103
|
-
if (type === 'createTable') {
|
|
104
|
-
if (!isImport) {
|
|
105
|
-
checkTablePrefixes(check.results, errors, infos);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
problemsFound += 1;
|
|
110
|
-
errors.push({
|
|
111
|
-
error: formatError(`${check.message} was not found.`),
|
|
112
|
-
recommendation: formatRecommendation(check.recommendation)
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
errors,
|
|
117
|
-
infos
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
const infoCheckFormatter = check => {
|
|
121
|
-
const infos = [];
|
|
122
|
-
check.results.forEach(item => {
|
|
123
|
-
if (item.text) {
|
|
124
|
-
infos.push(item.text);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return {
|
|
128
|
-
errors: [],
|
|
129
|
-
infos
|
|
130
|
-
};
|
|
170
|
+
return {
|
|
171
|
+
errors: [],
|
|
172
|
+
infos,
|
|
173
|
+
};
|
|
131
174
|
};
|
|
132
175
|
function checkTablePrefixes(results, errors, infos) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
infos.push(` - wp_ prefix tables found: ${wpTables.length} `);
|
|
148
|
-
}
|
|
149
|
-
if (notWPTables.length > 0) {
|
|
150
|
-
problemsFound += 1;
|
|
151
|
-
errors.push({
|
|
152
|
-
error: formatError(`tables without wp_ prefix found: ${notWPTables.join(',')}`),
|
|
153
|
-
recommendation: formatRecommendation('Please make sure all table names are prefixed with `wp_`')
|
|
176
|
+
const wpTables = [];
|
|
177
|
+
const notWPTables = [];
|
|
178
|
+
const wpMultisiteTables = [];
|
|
179
|
+
results.forEach(result => {
|
|
180
|
+
const tableName = result.text ?? '';
|
|
181
|
+
if (/^wp_(\d+_)/.exec(tableName)) {
|
|
182
|
+
wpMultisiteTables.push(tableName);
|
|
183
|
+
}
|
|
184
|
+
else if (tableName.startsWith('wp_')) {
|
|
185
|
+
wpTables.push(tableName);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
notWPTables.push(tableName);
|
|
189
|
+
}
|
|
154
190
|
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
191
|
+
if (wpTables.length > 0) {
|
|
192
|
+
infos.push(` - wp_ prefix tables found: ${wpTables.length} `);
|
|
193
|
+
}
|
|
194
|
+
if (notWPTables.length > 0) {
|
|
195
|
+
problemsFound += 1;
|
|
196
|
+
errors.push({
|
|
197
|
+
error: formatError(`tables without wp_ prefix found: ${notWPTables.join(',')}`),
|
|
198
|
+
recommendation: formatRecommendation('Please make sure all table names are prefixed with `wp_`'),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (wpMultisiteTables.length > 0) {
|
|
202
|
+
infos.push(` - wp_n_ prefix tables found: ${wpMultisiteTables.length} `);
|
|
203
|
+
}
|
|
159
204
|
}
|
|
160
205
|
const checks = {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
return {
|
|
294
|
-
warning: true,
|
|
295
|
-
lineNumber,
|
|
296
|
-
recomendation: `Use '--search-replace="${foundDomain},${expectedDomain}"' switch to replace the domain`
|
|
297
|
-
};
|
|
206
|
+
binaryLogging: {
|
|
207
|
+
matcher: /SET @@SESSION.sql_log_bin/i,
|
|
208
|
+
matchHandler: lineNumber => ({ lineNumber }),
|
|
209
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
210
|
+
results: [],
|
|
211
|
+
message: 'SET @@SESSION.sql_log_bin statement',
|
|
212
|
+
excerpt: "'SET @@SESSION.sql_log_bin' statement should not be present (case-insensitive)",
|
|
213
|
+
recommendation: 'Remove these lines',
|
|
214
|
+
},
|
|
215
|
+
trigger: {
|
|
216
|
+
// Match `CREATE (DEFINER=`root`@`host`) TRIGGER`
|
|
217
|
+
// eslint-disable-next-line security/detect-unsafe-regex
|
|
218
|
+
matcher: /^CREATE (\(?DEFINER=`?(\w*)(`@`)?(\w*\.*%?)*`?\)?)?(| )TRIGGER/i,
|
|
219
|
+
matchHandler: lineNumber => ({ lineNumber }),
|
|
220
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
221
|
+
results: [],
|
|
222
|
+
message: 'TRIGGER statement',
|
|
223
|
+
excerpt: "'TRIGGER' statement should not be present (case-sensitive)",
|
|
224
|
+
recommendation: 'Remove these lines',
|
|
225
|
+
},
|
|
226
|
+
dropDB: {
|
|
227
|
+
matcher: /^DROP DATABASE/i,
|
|
228
|
+
matchHandler: lineNumber => ({ lineNumber }),
|
|
229
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
230
|
+
results: [],
|
|
231
|
+
message: 'DROP DATABASE statement',
|
|
232
|
+
excerpt: "'DROP DATABASE' should not be present (case-insensitive)",
|
|
233
|
+
recommendation: 'Remove these lines',
|
|
234
|
+
},
|
|
235
|
+
useStatement: {
|
|
236
|
+
matcher: /^USE /i,
|
|
237
|
+
matchHandler: lineNumber => ({ lineNumber }),
|
|
238
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
239
|
+
results: [],
|
|
240
|
+
message: 'USE <DATABASE_NAME> statement',
|
|
241
|
+
excerpt: "'USE <DATABASE_NAME>' should not be present (case-insensitive)",
|
|
242
|
+
recommendation: 'Remove these lines',
|
|
243
|
+
},
|
|
244
|
+
alterUser: {
|
|
245
|
+
matcher: /^(ALTER USER|SET PASSWORD)/i,
|
|
246
|
+
matchHandler: lineNumber => ({ lineNumber }),
|
|
247
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
248
|
+
results: [],
|
|
249
|
+
message: 'ALTER USER statement',
|
|
250
|
+
excerpt: "'ALTER USER' should not be present (case-insensitive)",
|
|
251
|
+
recommendation: 'Remove these lines',
|
|
252
|
+
},
|
|
253
|
+
dropTable: {
|
|
254
|
+
matcher: /^DROP TABLE IF EXISTS `?([a-z0-9_]*)/i,
|
|
255
|
+
matchHandler: (lineNumber, results) => ({ text: results[1] }),
|
|
256
|
+
outputFormatter: requiredCheckFormatter,
|
|
257
|
+
results: [],
|
|
258
|
+
message: 'DROP TABLE',
|
|
259
|
+
excerpt: "'DROP TABLE IF EXISTS' should be present (case-insensitive)",
|
|
260
|
+
recommendation: 'Check import settings to include DROP TABLE statements',
|
|
261
|
+
},
|
|
262
|
+
createTable: {
|
|
263
|
+
matcher: /^CREATE TABLE (?:IF NOT EXISTS )?`?([a-z0-9_]*)/i,
|
|
264
|
+
matchHandler: (lineNumber, results) => ({ text: results[1] }),
|
|
265
|
+
outputFormatter: requiredCheckFormatter,
|
|
266
|
+
results: [],
|
|
267
|
+
message: 'CREATE TABLE',
|
|
268
|
+
excerpt: "'CREATE TABLE' should be present (case-insensitive)",
|
|
269
|
+
recommendation: 'Check import settings to include CREATE TABLE statements',
|
|
270
|
+
},
|
|
271
|
+
alterTable: {
|
|
272
|
+
matcher: /^ALTER TABLE `?([a-z0-9_]*)/i,
|
|
273
|
+
matchHandler: lineNumber => ({ lineNumber }),
|
|
274
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
275
|
+
results: [],
|
|
276
|
+
message: 'ALTER TABLE statement',
|
|
277
|
+
excerpt: "'ALTER TABLE' should not be present (case-insensitive)",
|
|
278
|
+
recommendation: 'Remove these lines and define table structure in the CREATE TABLE statement instead',
|
|
279
|
+
},
|
|
280
|
+
uniqueChecks: {
|
|
281
|
+
matcher: /^SET UNIQUE_CHECKS\s*=\s*0/i,
|
|
282
|
+
matchHandler: lineNumber => ({ lineNumber }),
|
|
283
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
284
|
+
results: [],
|
|
285
|
+
message: 'SET UNIQUE_CHECKS = 0',
|
|
286
|
+
excerpt: "'SET UNIQUE_CHECKS = 0' should not be present",
|
|
287
|
+
recommendation: "Disabling 'UNIQUE_CHECKS' is not allowed. These lines should be removed",
|
|
288
|
+
},
|
|
289
|
+
siteHomeUrl: {
|
|
290
|
+
matchHandler: (lineNumber, results) => ({ text: results[1] + ' ' + results[2] }),
|
|
291
|
+
outputFormatter: infoCheckFormatter,
|
|
292
|
+
results: [],
|
|
293
|
+
message: 'Siteurl/home matches',
|
|
294
|
+
excerpt: 'Siteurl/home options',
|
|
295
|
+
recommendation: '',
|
|
296
|
+
},
|
|
297
|
+
siteHomeUrlLando: {
|
|
298
|
+
matchHandler: (lineNumber, results, expectedDomain) => {
|
|
299
|
+
let foundDomain = results[2];
|
|
300
|
+
foundDomain = foundDomain.replace(/^https?:\/\//, '');
|
|
301
|
+
if (!foundDomain.trim()) {
|
|
302
|
+
return { falsePositive: true };
|
|
303
|
+
}
|
|
304
|
+
if (foundDomain.includes(expectedDomain)) {
|
|
305
|
+
return { falsePositive: true };
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
warning: true,
|
|
309
|
+
lineNumber,
|
|
310
|
+
recomendation: `Use '--search-replace="${foundDomain},${expectedDomain}"' switch to replace the domain`,
|
|
311
|
+
};
|
|
312
|
+
},
|
|
313
|
+
outputFormatter: generalCheckFormatter,
|
|
314
|
+
results: [],
|
|
315
|
+
message: 'Siteurl/home options not pointing to lando domain',
|
|
316
|
+
excerpt: 'Siteurl/home options not pointing to lando domain',
|
|
317
|
+
recommendation: "Use search-replace to change environment's domain",
|
|
318
|
+
},
|
|
319
|
+
engineInnoDB: {
|
|
320
|
+
matcher: /\sENGINE\s?=(?!(\s?InnoDB))/i,
|
|
321
|
+
matchHandler: lineNumber => ({ lineNumber }),
|
|
322
|
+
outputFormatter: lineNumberCheckFormatter,
|
|
323
|
+
results: [],
|
|
324
|
+
message: 'ENGINE != InnoDB',
|
|
325
|
+
excerpt: "'ENGINE=InnoDB' should be present (case-insensitive) for all tables",
|
|
326
|
+
recommendation: "Ensure your application works with InnoDB and update your SQL dump to include only 'ENGINE=InnoDB' engine definitions in 'CREATE TABLE' statements. " +
|
|
327
|
+
"We suggest you search for all 'ENGINE=X' entries and replace them with 'ENGINE=InnoDB'!",
|
|
328
|
+
},
|
|
329
|
+
autoIncrement: {
|
|
330
|
+
matcher: /\s(NOT NULL AUTO_INCREMENT,)/i,
|
|
331
|
+
matchHandler: (_lineNumber, results) => ({ text: results[1] }),
|
|
332
|
+
outputFormatter: requiredCheckFormatter,
|
|
333
|
+
results: [],
|
|
334
|
+
message: 'AUTO_INCREMENT attribute',
|
|
335
|
+
excerpt: "'AUTO_INCREMENT attribute' should be present (case-insensitive) for all CREATE TABLE statements",
|
|
336
|
+
recommendation: 'Check import settings to include AUTO_INCREMENT attribute in all the CREATE TABLE statements',
|
|
298
337
|
},
|
|
299
|
-
outputFormatter: generalCheckFormatter,
|
|
300
|
-
results: [],
|
|
301
|
-
message: 'Siteurl/home options not pointing to lando domain',
|
|
302
|
-
excerpt: 'Siteurl/home options not pointing to lando domain',
|
|
303
|
-
recommendation: "Use search-replace to change environment's domain"
|
|
304
|
-
},
|
|
305
|
-
engineInnoDB: {
|
|
306
|
-
matcher: /\sENGINE\s?=(?!(\s?InnoDB))/i,
|
|
307
|
-
matchHandler: lineNumber => ({
|
|
308
|
-
lineNumber
|
|
309
|
-
}),
|
|
310
|
-
outputFormatter: lineNumberCheckFormatter,
|
|
311
|
-
results: [],
|
|
312
|
-
message: 'ENGINE != InnoDB',
|
|
313
|
-
excerpt: "'ENGINE=InnoDB' should be present (case-insensitive) for all tables",
|
|
314
|
-
recommendation: "Ensure your application works with InnoDB and update your SQL dump to include only 'ENGINE=InnoDB' engine definitions in 'CREATE TABLE' statements. " + "We suggest you search for all 'ENGINE=X' entries and replace them with 'ENGINE=InnoDB'!"
|
|
315
|
-
},
|
|
316
|
-
autoIncrement: {
|
|
317
|
-
matcher: /\s(NOT NULL AUTO_INCREMENT,)/i,
|
|
318
|
-
matchHandler: (_lineNumber, results) => ({
|
|
319
|
-
text: results[1]
|
|
320
|
-
}),
|
|
321
|
-
outputFormatter: requiredCheckFormatter,
|
|
322
|
-
results: [],
|
|
323
|
-
message: 'AUTO_INCREMENT attribute',
|
|
324
|
-
excerpt: "'AUTO_INCREMENT attribute' should be present (case-insensitive) for all CREATE TABLE statements",
|
|
325
|
-
recommendation: 'Check import settings to include AUTO_INCREMENT attribute in all the CREATE TABLE statements'
|
|
326
|
-
}
|
|
327
338
|
};
|
|
328
339
|
const DEV_ENV_SPECIFIC_CHECKS = ['useStatement', 'siteHomeUrlLando'];
|
|
329
340
|
function findDuplicates(arr, where) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
});
|
|
337
|
-
return [...new Set(filtered)];
|
|
338
|
-
}
|
|
339
|
-
const postValidation = async options => {
|
|
340
|
-
await (0, _tracker.trackEvent)('import_validate_sql_command_execute', {
|
|
341
|
-
is_import: options.isImport
|
|
342
|
-
});
|
|
343
|
-
if (!options.isImport) {
|
|
344
|
-
(0, _singleLineLog.stdout)(`Finished processing ${lineNum} lines.`);
|
|
345
|
-
console.log('\n');
|
|
346
|
-
}
|
|
347
|
-
const errorSummary = {};
|
|
348
|
-
const checkEntries = Object.entries(checks).filter(([type]) => !options.skipChecks.includes(type));
|
|
349
|
-
const formattedWarnings = [];
|
|
350
|
-
let formattedErrors = [];
|
|
351
|
-
let formattedInfos = [];
|
|
352
|
-
for (const [type, check] of checkEntries) {
|
|
353
|
-
const formattedOutput = check.outputFormatter(check, type, options.isImport);
|
|
354
|
-
for (const error of formattedOutput.errors) {
|
|
355
|
-
if ('warning' in error) {
|
|
356
|
-
formattedWarnings.push(error);
|
|
357
|
-
} else {
|
|
358
|
-
formattedErrors.push(error);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
formattedInfos = formattedInfos.concat(formattedOutput.infos);
|
|
362
|
-
errorSummary[type] = check.results.length;
|
|
363
|
-
}
|
|
364
|
-
errorSummary.problems_found = problemsFound;
|
|
365
|
-
const tableNamesSet = new Set(tableNames);
|
|
366
|
-
if (tableNames.length > tableNamesSet.size) {
|
|
367
|
-
// there was a duplciate table
|
|
368
|
-
problemsFound++;
|
|
369
|
-
const duplicates = findDuplicates(tableNames, tableNamesSet);
|
|
370
|
-
const errorObject = {
|
|
371
|
-
error: formatError('Duplicate table names were found: ' + duplicates.join(',')),
|
|
372
|
-
recommendation: formatRecommendation('Ensure that there are no duplicate tables in your SQL dump')
|
|
373
|
-
};
|
|
374
|
-
formattedErrors = formattedErrors.concat(errorObject);
|
|
375
|
-
}
|
|
376
|
-
if (formattedWarnings.length) {
|
|
377
|
-
const warningOutput = [];
|
|
378
|
-
formattedWarnings.forEach(warning => {
|
|
379
|
-
warningOutput.push(warning.warning);
|
|
380
|
-
if (warning.recommendation) {
|
|
381
|
-
warningOutput.push(warning.recommendation);
|
|
382
|
-
}
|
|
383
|
-
warningOutput.push('');
|
|
384
|
-
});
|
|
385
|
-
console.log(warningOutput.join('\n'));
|
|
386
|
-
console.log('');
|
|
387
|
-
}
|
|
388
|
-
if (problemsFound > 0) {
|
|
389
|
-
await (0, _tracker.trackEvent)('import_validate_sql_command_failure', {
|
|
390
|
-
is_import: options.isImport,
|
|
391
|
-
error: errorSummary
|
|
341
|
+
const filtered = arr.filter(item => {
|
|
342
|
+
if (where.has(item)) {
|
|
343
|
+
where.delete(item);
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
return true;
|
|
392
347
|
});
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
348
|
+
return [...new Set(filtered)];
|
|
349
|
+
}
|
|
350
|
+
const postValidation = async (options) => {
|
|
351
|
+
await (0, tracker_1.trackEvent)('import_validate_sql_command_execute', { is_import: options.isImport });
|
|
352
|
+
if (!options.isImport) {
|
|
353
|
+
(0, single_line_log_1.stdout)(`Finished processing ${lineNum} lines.`);
|
|
354
|
+
console.log('\n');
|
|
355
|
+
}
|
|
356
|
+
const errorSummary = {};
|
|
357
|
+
const checkEntries = Object.entries(checks).filter(([type]) => !options.skipChecks.includes(type));
|
|
358
|
+
const formattedWarnings = [];
|
|
359
|
+
let formattedErrors = [];
|
|
360
|
+
let formattedInfos = [];
|
|
361
|
+
for (const [type, check] of checkEntries) {
|
|
362
|
+
const formattedOutput = check.outputFormatter(check, type, options.isImport);
|
|
363
|
+
for (const error of formattedOutput.errors) {
|
|
364
|
+
if ('warning' in error) {
|
|
365
|
+
formattedWarnings.push(error);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
formattedErrors.push(error);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
formattedInfos = formattedInfos.concat(formattedOutput.infos);
|
|
372
|
+
errorSummary[type] = check.results.length;
|
|
373
|
+
}
|
|
374
|
+
errorSummary.problems_found = problemsFound;
|
|
375
|
+
const tableNamesSet = new Set(tableNames);
|
|
376
|
+
if (tableNames.length > tableNamesSet.size) {
|
|
377
|
+
// there was a duplciate table
|
|
378
|
+
problemsFound++;
|
|
379
|
+
const duplicates = findDuplicates(tableNames, tableNamesSet);
|
|
380
|
+
const errorObject = {
|
|
381
|
+
error: formatError('Duplicate table names were found: ' + duplicates.join(',')),
|
|
382
|
+
recommendation: formatRecommendation('Ensure that there are no duplicate tables in your SQL dump'),
|
|
383
|
+
};
|
|
384
|
+
formattedErrors = formattedErrors.concat(errorObject);
|
|
385
|
+
}
|
|
386
|
+
if (formattedWarnings.length) {
|
|
387
|
+
const warningOutput = [];
|
|
388
|
+
formattedWarnings.forEach(warning => {
|
|
389
|
+
warningOutput.push(warning.warning);
|
|
390
|
+
if (warning.recommendation) {
|
|
391
|
+
warningOutput.push(warning.recommendation);
|
|
392
|
+
}
|
|
393
|
+
warningOutput.push('');
|
|
394
|
+
});
|
|
395
|
+
console.log(warningOutput.join('\n'));
|
|
396
|
+
console.log('');
|
|
397
|
+
}
|
|
398
|
+
if (problemsFound > 0) {
|
|
399
|
+
await (0, tracker_1.trackEvent)('import_validate_sql_command_failure', {
|
|
400
|
+
is_import: options.isImport,
|
|
401
|
+
error: errorSummary,
|
|
402
|
+
});
|
|
403
|
+
const errorOutput = [];
|
|
404
|
+
formattedErrors.forEach(error => {
|
|
405
|
+
errorOutput.push(error.error);
|
|
406
|
+
if (error.recommendation) {
|
|
407
|
+
errorOutput.push(error.recommendation);
|
|
408
|
+
}
|
|
409
|
+
errorOutput.push('');
|
|
410
|
+
});
|
|
411
|
+
errorOutput.push(chalk_1.default.bold.red(`SQL validation failed due to ${problemsFound} error(s)`));
|
|
412
|
+
if (options.isImport) {
|
|
413
|
+
throw new Error(errorOutput.join('\n'));
|
|
414
|
+
}
|
|
415
|
+
exit.withError(errorOutput.join('\n'));
|
|
416
|
+
}
|
|
417
|
+
if (!options.isImport) {
|
|
418
|
+
console.log(formattedInfos.join('\n'));
|
|
419
|
+
console.log('');
|
|
420
|
+
}
|
|
421
|
+
await (0, tracker_1.trackEvent)('import_validate_sql_command_success', { is_import: options.isImport });
|
|
414
422
|
};
|
|
415
423
|
const getTableNames = () => {
|
|
416
|
-
|
|
424
|
+
return tableNames;
|
|
417
425
|
};
|
|
418
426
|
exports.getTableNames = getTableNames;
|
|
419
|
-
const checkForTableName = line => {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
427
|
+
const checkForTableName = (line) => {
|
|
428
|
+
const matches = /(?<=^CREATE\sTABLE\s)`?(?:(wp_[\d+_]?\w+))`?/.exec(line);
|
|
429
|
+
if (matches) {
|
|
430
|
+
const tableName = matches[1];
|
|
431
|
+
// we should only have one match if we have any since we're looking at the start of the string
|
|
432
|
+
tableNames.push(tableName);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
const collectInsertColumnList = (line, startIndex) => {
|
|
436
|
+
if (undefined !== currentInsertStatementColumnList) {
|
|
437
|
+
const closingParenthesisIndex = line.indexOf(')');
|
|
438
|
+
if (-1 === closingParenthesisIndex) {
|
|
439
|
+
currentInsertStatementColumnList += `\n${line}`;
|
|
440
|
+
return undefined;
|
|
441
|
+
}
|
|
442
|
+
const columnList = `${currentInsertStatementColumnList}\n${line.slice(0, closingParenthesisIndex)}`;
|
|
443
|
+
currentInsertStatementColumnList = undefined;
|
|
444
|
+
return (0, sql_insert_parser_1.parseInsertColumnListSegment)(columnList);
|
|
445
|
+
}
|
|
446
|
+
const valuesIndex = (0, sql_insert_parser_1.findValuesKeywordIndex)(line);
|
|
447
|
+
const openingParenthesisIndex = line.indexOf('(', startIndex);
|
|
448
|
+
if (-1 === openingParenthesisIndex ||
|
|
449
|
+
(-1 !== valuesIndex && openingParenthesisIndex > valuesIndex)) {
|
|
450
|
+
return undefined;
|
|
451
|
+
}
|
|
452
|
+
const closingParenthesisIndex = line.indexOf(')', openingParenthesisIndex + 1);
|
|
453
|
+
if (-1 !== closingParenthesisIndex) {
|
|
454
|
+
return (0, sql_insert_parser_1.parseInsertColumnListSegment)(line.slice(openingParenthesisIndex + 1, closingParenthesisIndex));
|
|
455
|
+
}
|
|
456
|
+
currentInsertStatementColumnList = line.slice(openingParenthesisIndex + 1);
|
|
457
|
+
return undefined;
|
|
458
|
+
};
|
|
459
|
+
const isSqlCommentOnlyLine = (line) => {
|
|
460
|
+
return '' === line.trim();
|
|
461
|
+
};
|
|
462
|
+
const collectOptionUrlMatchesFromRows = (rows) => {
|
|
463
|
+
return rows
|
|
464
|
+
.map(row => (0, sql_insert_parser_1.getOptionUrlMatchResults)(row, currentInsertStatementColumns))
|
|
465
|
+
.filter((results) => Boolean(results));
|
|
466
|
+
};
|
|
467
|
+
const collectOptionsInsertRows = (line, startIndex) => {
|
|
468
|
+
const lineSegment = line.slice(startIndex);
|
|
469
|
+
const parseInput = currentInsertStatementRowBuffer
|
|
470
|
+
? `${currentInsertStatementRowBuffer}\n${lineSegment}`
|
|
471
|
+
: lineSegment;
|
|
472
|
+
const { rows, remainder, finished } = (0, sql_insert_parser_1.parseSqlTupleRows)(parseInput, 0);
|
|
473
|
+
currentInsertStatementRowBuffer = remainder;
|
|
474
|
+
currentInsertStatementValuesFinished = Boolean(finished);
|
|
475
|
+
return collectOptionUrlMatchesFromRows(rows);
|
|
476
|
+
};
|
|
477
|
+
const collectOptionsInsertMatches = (uncommentedLine) => {
|
|
478
|
+
if (!(0, sql_insert_parser_1.isWordPressOptionsTable)(currentInsertStatementTableName)) {
|
|
479
|
+
return [];
|
|
480
|
+
}
|
|
481
|
+
if (currentInsertStatementValuesFinished) {
|
|
482
|
+
return [];
|
|
483
|
+
}
|
|
484
|
+
if (isSqlCommentOnlyLine(uncommentedLine)) {
|
|
485
|
+
return [];
|
|
486
|
+
}
|
|
487
|
+
if (!currentInsertStatementHasValues) {
|
|
488
|
+
currentInsertStatementColumns =
|
|
489
|
+
currentInsertStatementColumns ?? collectInsertColumnList(uncommentedLine, 0);
|
|
490
|
+
const valuesKeyword = (0, sql_insert_parser_1.findValuesKeyword)(uncommentedLine);
|
|
491
|
+
if (!valuesKeyword) {
|
|
492
|
+
return [];
|
|
493
|
+
}
|
|
494
|
+
currentInsertStatementHasValues = true;
|
|
495
|
+
return collectOptionsInsertRows(uncommentedLine, valuesKeyword.endIndex);
|
|
496
|
+
}
|
|
497
|
+
return collectOptionsInsertRows(uncommentedLine, 0);
|
|
426
498
|
};
|
|
427
499
|
const DEFAULT_VALIDATION_OPTIONS = {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
500
|
+
isImport: true,
|
|
501
|
+
skipChecks: DEV_ENV_SPECIFIC_CHECKS,
|
|
502
|
+
extraCheckParams: {},
|
|
503
|
+
};
|
|
504
|
+
const resetFinishedInsertStatement = (uncommentedLine) => {
|
|
505
|
+
if (currentInsertStatementTableName &&
|
|
506
|
+
!currentInsertStatementRowBuffer &&
|
|
507
|
+
!currentSqlCommentStripState.quote &&
|
|
508
|
+
uncommentedLine.length > 0 &&
|
|
509
|
+
uncommentedLine.trimEnd().endsWith(';')) {
|
|
510
|
+
currentInsertStatementTableName = undefined;
|
|
511
|
+
currentInsertStatementColumns = undefined;
|
|
512
|
+
currentInsertStatementColumnList = undefined;
|
|
513
|
+
currentInsertStatementHasValues = false;
|
|
514
|
+
currentInsertStatementValuesFinished = false;
|
|
515
|
+
currentInsertStatementRowBuffer = undefined;
|
|
516
|
+
}
|
|
431
517
|
};
|
|
432
518
|
const perLineValidations = (line, options = DEFAULT_VALIDATION_OPTIONS) => {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
519
|
+
if (options.isImport && lineNum % 500 === 0) {
|
|
520
|
+
(0, single_line_log_1.stdout)(`Reading line ${lineNum} `);
|
|
521
|
+
}
|
|
522
|
+
checkForTableName(line);
|
|
523
|
+
const wasInQuotedValue = Boolean(currentSqlCommentStripState.quote);
|
|
524
|
+
const rawInsertInfo = wasInQuotedValue ? undefined : (0, sql_insert_parser_1.getInsertStatementInfo)(line);
|
|
525
|
+
const shouldStripComments = currentSqlCommentStripState.inBlockComment ||
|
|
526
|
+
Boolean(currentSqlCommentStripState.quote) ||
|
|
527
|
+
line.includes('/*') ||
|
|
528
|
+
Boolean(currentInsertStatementTableName) ||
|
|
529
|
+
Boolean(rawInsertInfo);
|
|
530
|
+
const uncommentedLine = shouldStripComments
|
|
531
|
+
? (0, sql_insert_parser_1.stripSqlCommentsOutsideQuotedStrings)(line, currentSqlCommentStripState)
|
|
532
|
+
: line;
|
|
533
|
+
let insertStatementInfo = rawInsertInfo;
|
|
534
|
+
if (!wasInQuotedValue && shouldStripComments) {
|
|
535
|
+
insertStatementInfo = (0, sql_insert_parser_1.getInsertStatementInfo)(uncommentedLine);
|
|
536
|
+
}
|
|
537
|
+
if (insertStatementInfo) {
|
|
538
|
+
currentInsertStatementTableName = insertStatementInfo.tableName;
|
|
539
|
+
currentInsertStatementColumns = (0, sql_insert_parser_1.parseInsertColumnList)(uncommentedLine, insertStatementInfo.tableEndIndex);
|
|
540
|
+
currentInsertStatementColumnList = undefined;
|
|
541
|
+
currentInsertStatementHasValues = false;
|
|
542
|
+
currentInsertStatementValuesFinished = false;
|
|
543
|
+
currentInsertStatementRowBuffer = undefined;
|
|
544
|
+
}
|
|
545
|
+
const optionsInsertMatches = currentInsertStatementTableName
|
|
546
|
+
? collectOptionsInsertMatches(uncommentedLine)
|
|
547
|
+
: [];
|
|
548
|
+
const checkKeys = Object.keys(checks).filter(checkItem => !options.skipChecks.includes(checkItem));
|
|
549
|
+
for (const checkKey of checkKeys) {
|
|
550
|
+
const check = checks[checkKey];
|
|
551
|
+
const extraCheckParams = options.extraCheckParams[checkKey];
|
|
552
|
+
if ((0, sql_insert_parser_1.checkRequiresOptionsInsertContext)(checkKey)) {
|
|
553
|
+
for (const results of optionsInsertMatches) {
|
|
554
|
+
check.results.push(check.matchHandler(lineNum, results, extraCheckParams));
|
|
555
|
+
}
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
const results = check.matcher === undefined ? null : line.match(check.matcher); // NOSONAR
|
|
559
|
+
if (results) {
|
|
560
|
+
check.results.push(check.matchHandler(lineNum, results, extraCheckParams));
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
resetFinishedInsertStatement(uncommentedLine);
|
|
564
|
+
lineNum += 1;
|
|
447
565
|
};
|
|
448
|
-
const postLineExecutionProcessing = async ({
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
skipChecks: skipChecks ?? DEV_ENV_SPECIFIC_CHECKS,
|
|
455
|
-
extraCheckParams: {}
|
|
456
|
-
});
|
|
566
|
+
const postLineExecutionProcessing = async ({ isImport, skipChecks, }) => {
|
|
567
|
+
await postValidation({
|
|
568
|
+
isImport: isImport ?? false,
|
|
569
|
+
skipChecks: skipChecks ?? DEV_ENV_SPECIFIC_CHECKS,
|
|
570
|
+
extraCheckParams: {},
|
|
571
|
+
});
|
|
457
572
|
};
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
573
|
+
exports.staticSqlValidations = {
|
|
574
|
+
execute: perLineValidations,
|
|
575
|
+
postLineExecutionProcessing,
|
|
461
576
|
};
|
|
462
|
-
|
|
463
577
|
// For standalone SQL validations
|
|
464
578
|
const validate = async (filename, options = DEFAULT_VALIDATION_OPTIONS) => {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
579
|
+
currentInsertStatementTableName = undefined;
|
|
580
|
+
currentInsertStatementColumns = undefined;
|
|
581
|
+
currentInsertStatementColumnList = undefined;
|
|
582
|
+
currentInsertStatementHasValues = false;
|
|
583
|
+
currentInsertStatementValuesFinished = false;
|
|
584
|
+
currentInsertStatementRowBuffer = undefined;
|
|
585
|
+
currentSqlCommentStripState = { inBlockComment: false };
|
|
586
|
+
const fileMeta = await (0, client_file_uploader_1.getFileMeta)(filename);
|
|
587
|
+
if (fileMeta.isCompressed) {
|
|
588
|
+
exit.withError('Compressed files cannot be validated. Please extract the archive and re-run the command, providing the path to the extracted SQL file.');
|
|
589
|
+
}
|
|
590
|
+
const readInterface = await (0, line_by_line_1.getReadInterface)(filename);
|
|
591
|
+
options.isImport = false;
|
|
592
|
+
readInterface.on('line', line => {
|
|
593
|
+
perLineValidations(line, options);
|
|
594
|
+
});
|
|
595
|
+
// Block until the processing completes
|
|
596
|
+
await (0, node_events_1.once)(readInterface, 'close');
|
|
597
|
+
await postLineExecutionProcessing({
|
|
598
|
+
isImport: options.isImport,
|
|
599
|
+
skipChecks: options.skipChecks,
|
|
600
|
+
});
|
|
481
601
|
};
|
|
482
|
-
exports.validate = validate;
|
|
602
|
+
exports.validate = validate;
|