@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
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOptionUrlMatchResults = exports.unquoteSqlValue = exports.parseSqlTupleRows = exports.stripSqlCommentsOutsideQuotedStrings = exports.isEscapedByBackslash = exports.parseInsertColumnListSegment = exports.parseInsertColumnList = exports.findValuesKeywordIndex = exports.findValuesKeyword = exports.normalizeSqlIdentifier = exports.checkRequiresOptionsInsertContext = exports.isWordPressOptionsTable = exports.getInsertStatementInfo = exports.readSqlIdentifier = exports.skipSqlWhitespace = exports.DEFAULT_OPTIONS_INSERT_COLUMNS = exports.INSERT_STATEMENT_MODIFIERS = void 0;
|
|
4
|
+
exports.INSERT_STATEMENT_MODIFIERS = new Set([
|
|
5
|
+
'IGNORE',
|
|
6
|
+
'LOW_PRIORITY',
|
|
7
|
+
'DELAYED',
|
|
8
|
+
'HIGH_PRIORITY',
|
|
9
|
+
]);
|
|
10
|
+
const SQL_IDENTIFIER_REGEX = /^[a-z0-9_$]+/i;
|
|
11
|
+
const SQL_IDENTIFIER_CHAR_REGEX = /^[a-z0-9_$]$/i;
|
|
12
|
+
const VALUES_KEYWORD_REGEX = /^VALUES?/i;
|
|
13
|
+
exports.DEFAULT_OPTIONS_INSERT_COLUMNS = [
|
|
14
|
+
'option_id',
|
|
15
|
+
'option_name',
|
|
16
|
+
'option_value',
|
|
17
|
+
'autoload',
|
|
18
|
+
];
|
|
19
|
+
const skipSqlWhitespace = (line, startIndex) => {
|
|
20
|
+
let index = startIndex;
|
|
21
|
+
while (index < line.length && /\s/.test(line[index])) {
|
|
22
|
+
index += 1;
|
|
23
|
+
}
|
|
24
|
+
return index;
|
|
25
|
+
};
|
|
26
|
+
exports.skipSqlWhitespace = skipSqlWhitespace;
|
|
27
|
+
const readSqlIdentifier = (line, startIndex) => {
|
|
28
|
+
const index = (0, exports.skipSqlWhitespace)(line, startIndex);
|
|
29
|
+
if (index >= line.length) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
if ('`' === line[index]) {
|
|
33
|
+
let endIndex = index + 1;
|
|
34
|
+
while (endIndex < line.length) {
|
|
35
|
+
endIndex = line.indexOf('`', endIndex);
|
|
36
|
+
if (-1 === endIndex) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
if ('`' !== line[endIndex + 1]) {
|
|
40
|
+
return {
|
|
41
|
+
name: line.slice(index + 1, endIndex).replaceAll('``', '`'),
|
|
42
|
+
endIndex: endIndex + 1,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
endIndex += 2;
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
const matches = SQL_IDENTIFIER_REGEX.exec(line.slice(index));
|
|
50
|
+
if (!matches) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return { name: matches[0], endIndex: index + matches[0].length };
|
|
54
|
+
};
|
|
55
|
+
exports.readSqlIdentifier = readSqlIdentifier;
|
|
56
|
+
const getInsertStatementInfo = (line) => {
|
|
57
|
+
const statementMatches = /^\s*(?:INSERT|REPLACE)\b/i.exec(line);
|
|
58
|
+
if (!statementMatches) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
let index = statementMatches[0].length;
|
|
62
|
+
let tableName;
|
|
63
|
+
while (true) {
|
|
64
|
+
const identifier = (0, exports.readSqlIdentifier)(line, index);
|
|
65
|
+
if (!identifier) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const keyword = identifier.name.toUpperCase();
|
|
69
|
+
index = identifier.endIndex;
|
|
70
|
+
if (exports.INSERT_STATEMENT_MODIFIERS.has(keyword) || 'INTO' === keyword) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
tableName = identifier;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
const dotIndex = (0, exports.skipSqlWhitespace)(line, tableName.endIndex);
|
|
77
|
+
if ('.' !== line[dotIndex]) {
|
|
78
|
+
return { tableName: tableName.name, tableEndIndex: tableName.endIndex };
|
|
79
|
+
}
|
|
80
|
+
const qualifiedTableName = (0, exports.readSqlIdentifier)(line, dotIndex + 1);
|
|
81
|
+
return {
|
|
82
|
+
tableName: qualifiedTableName?.name ?? tableName.name,
|
|
83
|
+
tableEndIndex: qualifiedTableName?.endIndex ?? tableName.endIndex,
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
exports.getInsertStatementInfo = getInsertStatementInfo;
|
|
87
|
+
const isWordPressOptionsTable = (tableName) => tableName
|
|
88
|
+
? /^wp_\d+_options$/i.test(tableName) || 'wp_options' === tableName.toLowerCase()
|
|
89
|
+
: false;
|
|
90
|
+
exports.isWordPressOptionsTable = isWordPressOptionsTable;
|
|
91
|
+
const checkRequiresOptionsInsertContext = (checkKey) => {
|
|
92
|
+
return 'siteHomeUrl' === checkKey || 'siteHomeUrlLando' === checkKey;
|
|
93
|
+
};
|
|
94
|
+
exports.checkRequiresOptionsInsertContext = checkRequiresOptionsInsertContext;
|
|
95
|
+
const normalizeSqlIdentifier = (identifier) => {
|
|
96
|
+
return identifier.replace(/^`|`$/g, '').toLowerCase();
|
|
97
|
+
};
|
|
98
|
+
exports.normalizeSqlIdentifier = normalizeSqlIdentifier;
|
|
99
|
+
const isSqlIdentifierChar = (char) => {
|
|
100
|
+
return undefined !== char && SQL_IDENTIFIER_CHAR_REGEX.test(char);
|
|
101
|
+
};
|
|
102
|
+
const skipSqlDelimitedSegment = (line, startIndex) => {
|
|
103
|
+
const delimiter = line[startIndex];
|
|
104
|
+
if ('`' !== delimiter && "'" !== delimiter && '"' !== delimiter) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
for (let index = startIndex + 1; index < line.length; index += 1) {
|
|
108
|
+
const char = line[index];
|
|
109
|
+
const nextChar = line[index + 1];
|
|
110
|
+
if (char !== delimiter) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if ('`' !== delimiter && (0, exports.isEscapedByBackslash)(line, index)) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (nextChar === delimiter) {
|
|
117
|
+
index += 1;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
return index;
|
|
121
|
+
}
|
|
122
|
+
return line.length - 1;
|
|
123
|
+
};
|
|
124
|
+
const getValuesKeywordMatchAt = (line, index) => {
|
|
125
|
+
const valuesMatches = VALUES_KEYWORD_REGEX.exec(line.slice(index));
|
|
126
|
+
if (!valuesMatches) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
const endIndex = index + valuesMatches[0].length;
|
|
130
|
+
if (isSqlIdentifierChar(line[index - 1]) || isSqlIdentifierChar(line[endIndex])) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
index,
|
|
135
|
+
endIndex,
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
const findValuesKeyword = (line) => {
|
|
139
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
140
|
+
const segmentEndIndex = skipSqlDelimitedSegment(line, index);
|
|
141
|
+
if (undefined !== segmentEndIndex) {
|
|
142
|
+
index = segmentEndIndex; // NOSONAR
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const valuesKeyword = getValuesKeywordMatchAt(line, index);
|
|
146
|
+
if (valuesKeyword) {
|
|
147
|
+
return valuesKeyword;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
151
|
+
};
|
|
152
|
+
exports.findValuesKeyword = findValuesKeyword;
|
|
153
|
+
const findValuesKeywordIndex = (line) => {
|
|
154
|
+
return (0, exports.findValuesKeyword)(line)?.index ?? -1;
|
|
155
|
+
};
|
|
156
|
+
exports.findValuesKeywordIndex = findValuesKeywordIndex;
|
|
157
|
+
const parseInsertColumnList = (line, startIndex) => {
|
|
158
|
+
const valuesIndex = (0, exports.findValuesKeywordIndex)(line);
|
|
159
|
+
const openingParenthesisIndex = line.indexOf('(', startIndex);
|
|
160
|
+
if (-1 === openingParenthesisIndex ||
|
|
161
|
+
(-1 !== valuesIndex && openingParenthesisIndex > valuesIndex)) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
const closingParenthesisIndex = line.indexOf(')', openingParenthesisIndex + 1);
|
|
165
|
+
if (-1 === closingParenthesisIndex) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
const columns = line
|
|
169
|
+
.slice(openingParenthesisIndex + 1, closingParenthesisIndex)
|
|
170
|
+
.split(',')
|
|
171
|
+
.map(column => (0, exports.normalizeSqlIdentifier)(column.trim()))
|
|
172
|
+
.filter(Boolean);
|
|
173
|
+
return columns.length > 0 ? columns : undefined;
|
|
174
|
+
};
|
|
175
|
+
exports.parseInsertColumnList = parseInsertColumnList;
|
|
176
|
+
const parseInsertColumnListSegment = (columnList) => {
|
|
177
|
+
const columns = columnList
|
|
178
|
+
.split(',')
|
|
179
|
+
.map(column => (0, exports.normalizeSqlIdentifier)(column.trim()))
|
|
180
|
+
.filter(Boolean);
|
|
181
|
+
return columns.length > 0 ? columns : undefined;
|
|
182
|
+
};
|
|
183
|
+
exports.parseInsertColumnListSegment = parseInsertColumnListSegment;
|
|
184
|
+
const isEscapedByBackslash = (line, index) => {
|
|
185
|
+
let backslashCount = 0;
|
|
186
|
+
let currentIndex = index - 1;
|
|
187
|
+
while (currentIndex >= 0 && '\\' === line[currentIndex]) {
|
|
188
|
+
backslashCount += 1;
|
|
189
|
+
currentIndex -= 1;
|
|
190
|
+
}
|
|
191
|
+
return 1 === backslashCount % 2;
|
|
192
|
+
};
|
|
193
|
+
exports.isEscapedByBackslash = isEscapedByBackslash;
|
|
194
|
+
const isSqlQuoteStart = (char) => "'" === char || '"' === char || '`' === char;
|
|
195
|
+
const isSqlBlockCommentStart = (line, index) => '/' === line[index] && '*' === line[index + 1];
|
|
196
|
+
const isSqlBlockCommentEnd = (line, index) => '*' === line[index] && '/' === line[index + 1];
|
|
197
|
+
const isSqlDashCommentStart = (line, index) => {
|
|
198
|
+
if ('-' !== line[index] || '-' !== line[index + 1]) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
const afterCommentMarker = line[index + 2];
|
|
202
|
+
return undefined === afterCommentMarker || /\s/.test(afterCommentMarker);
|
|
203
|
+
};
|
|
204
|
+
const isSqlLineCommentStart = (line, index) => '#' === line[index] || isSqlDashCommentStart(line, index);
|
|
205
|
+
const setSqlCommentStripState = (state, inBlockComment) => {
|
|
206
|
+
if (state) {
|
|
207
|
+
state.inBlockComment = inBlockComment;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const readSqlQuotedSegment = (line, startIndex) => {
|
|
211
|
+
if (!isSqlQuoteStart(line[startIndex])) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
const endIndex = skipSqlDelimitedSegment(line, startIndex);
|
|
215
|
+
if (undefined === endIndex) {
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
text: line.slice(startIndex, endIndex + 1),
|
|
220
|
+
nextIndex: endIndex + 1,
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
const skipSqlBlockComment = (line, startIndex, uncommentedLine, state) => {
|
|
224
|
+
for (let index = startIndex; index < line.length; index += 1) {
|
|
225
|
+
if (!isSqlBlockCommentEnd(line, index)) {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
setSqlCommentStripState(state, false);
|
|
229
|
+
const nextIndex = index + 2;
|
|
230
|
+
return {
|
|
231
|
+
inBlockComment: false,
|
|
232
|
+
nextIndex: '' === uncommentedLine ? (0, exports.skipSqlWhitespace)(line, nextIndex) : nextIndex,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
setSqlCommentStripState(state, true);
|
|
236
|
+
return {
|
|
237
|
+
inBlockComment: true,
|
|
238
|
+
nextIndex: line.length,
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
const blockCommentNeedsSeparator = (output, line, nextIndex) => Boolean(output) &&
|
|
242
|
+
!/\s$/.test(output) &&
|
|
243
|
+
nextIndex < line.length &&
|
|
244
|
+
!/\s/.test(line[nextIndex]);
|
|
245
|
+
const isUnescapedDelimiter = (quote, line, index) => '`' === quote || !(0, exports.isEscapedByBackslash)(line, index);
|
|
246
|
+
const stripSqlCommentsOutsideQuotedStrings = (line, state) => {
|
|
247
|
+
let uncommentedLine = '';
|
|
248
|
+
let inBlockComment = state?.inBlockComment ?? false;
|
|
249
|
+
let index = 0;
|
|
250
|
+
while (index < line.length) {
|
|
251
|
+
if (inBlockComment) {
|
|
252
|
+
const blockComment = skipSqlBlockComment(line, index, uncommentedLine, state);
|
|
253
|
+
inBlockComment = blockComment.inBlockComment;
|
|
254
|
+
index = blockComment.nextIndex;
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (state?.quote) {
|
|
258
|
+
const quote = state.quote;
|
|
259
|
+
const start = index;
|
|
260
|
+
while (index < line.length) {
|
|
261
|
+
const nextQuote = line.indexOf(quote, index);
|
|
262
|
+
if (-1 === nextQuote) {
|
|
263
|
+
index = line.length;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
index = nextQuote;
|
|
267
|
+
if (isUnescapedDelimiter(quote, line, index)) {
|
|
268
|
+
if (line[index + 1] === quote) {
|
|
269
|
+
index += 2;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
state.quote = undefined;
|
|
273
|
+
index += 1;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
index += 1;
|
|
277
|
+
}
|
|
278
|
+
uncommentedLine += line.slice(start, index);
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
if (state && isSqlQuoteStart(line[index])) {
|
|
282
|
+
state.quote = line[index];
|
|
283
|
+
uncommentedLine += line[index];
|
|
284
|
+
index += 1;
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const quotedSegment = readSqlQuotedSegment(line, index);
|
|
288
|
+
if (quotedSegment) {
|
|
289
|
+
uncommentedLine += quotedSegment.text;
|
|
290
|
+
index = quotedSegment.nextIndex;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (isSqlLineCommentStart(line, index)) {
|
|
294
|
+
return uncommentedLine.trimEnd();
|
|
295
|
+
}
|
|
296
|
+
if (isSqlBlockCommentStart(line, index)) {
|
|
297
|
+
const blockComment = skipSqlBlockComment(line, index + 2, uncommentedLine, state);
|
|
298
|
+
if (blockCommentNeedsSeparator(uncommentedLine, line, blockComment.nextIndex)) {
|
|
299
|
+
uncommentedLine += ' ';
|
|
300
|
+
}
|
|
301
|
+
inBlockComment = blockComment.inBlockComment;
|
|
302
|
+
index = blockComment.nextIndex;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
const nextSpecial = /['"`#/-]/g;
|
|
306
|
+
nextSpecial.lastIndex = index + 1;
|
|
307
|
+
const match = nextSpecial.exec(line);
|
|
308
|
+
const end = match?.index ?? line.length;
|
|
309
|
+
uncommentedLine += line.slice(index, end);
|
|
310
|
+
index = end;
|
|
311
|
+
}
|
|
312
|
+
if (inBlockComment) {
|
|
313
|
+
return uncommentedLine.trimEnd();
|
|
314
|
+
}
|
|
315
|
+
return uncommentedLine;
|
|
316
|
+
};
|
|
317
|
+
exports.stripSqlCommentsOutsideQuotedStrings = stripSqlCommentsOutsideQuotedStrings;
|
|
318
|
+
const isNonTupleContent = (char, depth, quote) => 0 === depth && !quote && !/[\s,(]/.test(char);
|
|
319
|
+
const parseSqlTupleRows = (line, startIndex) => {
|
|
320
|
+
const rows = [];
|
|
321
|
+
let currentRow;
|
|
322
|
+
let currentValue = '';
|
|
323
|
+
let parenthesisDepth = 0;
|
|
324
|
+
let quote;
|
|
325
|
+
let rowStartIndex;
|
|
326
|
+
for (let index = startIndex; index < line.length; index += 1) {
|
|
327
|
+
const char = line[index];
|
|
328
|
+
if (isNonTupleContent(char, parenthesisDepth, quote)) {
|
|
329
|
+
return { rows, finished: true };
|
|
330
|
+
}
|
|
331
|
+
if (quote) {
|
|
332
|
+
currentValue += char;
|
|
333
|
+
if (char === quote && !(0, exports.isEscapedByBackslash)(line, index)) {
|
|
334
|
+
if (line[index + 1] === quote) {
|
|
335
|
+
currentValue += line[index + 1];
|
|
336
|
+
index += 1;
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
quote = undefined;
|
|
340
|
+
}
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if ("'" === char || '"' === char) {
|
|
344
|
+
quote = char;
|
|
345
|
+
currentValue += char;
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if ('(' === char) {
|
|
349
|
+
if (0 === parenthesisDepth) {
|
|
350
|
+
currentRow = [];
|
|
351
|
+
currentValue = '';
|
|
352
|
+
rowStartIndex = index;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
currentValue += char;
|
|
356
|
+
}
|
|
357
|
+
parenthesisDepth += 1;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (')' === char && currentRow) {
|
|
361
|
+
parenthesisDepth -= 1;
|
|
362
|
+
if (0 === parenthesisDepth) {
|
|
363
|
+
currentRow.push(currentValue.trim());
|
|
364
|
+
rows.push(currentRow);
|
|
365
|
+
currentRow = undefined;
|
|
366
|
+
currentValue = '';
|
|
367
|
+
rowStartIndex = undefined;
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (',' === char && 1 === parenthesisDepth && currentRow) {
|
|
372
|
+
currentRow.push(currentValue.trim());
|
|
373
|
+
currentValue = '';
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if (currentRow) {
|
|
377
|
+
currentValue += char;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
rows,
|
|
382
|
+
remainder: undefined === rowStartIndex ? undefined : line.slice(rowStartIndex),
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
exports.parseSqlTupleRows = parseSqlTupleRows;
|
|
386
|
+
const unquoteSqlValue = (value) => {
|
|
387
|
+
const trimmedValue = value?.trim() ?? '';
|
|
388
|
+
const quote = trimmedValue[0];
|
|
389
|
+
if (!quote || ("'" !== quote && '"' !== quote) || trimmedValue.at(-1) !== quote) {
|
|
390
|
+
return trimmedValue;
|
|
391
|
+
}
|
|
392
|
+
return trimmedValue
|
|
393
|
+
.slice(1, -1)
|
|
394
|
+
.replaceAll(quote + quote, quote)
|
|
395
|
+
.replaceAll('\\' + quote, quote);
|
|
396
|
+
};
|
|
397
|
+
exports.unquoteSqlValue = unquoteSqlValue;
|
|
398
|
+
const getOptionUrlMatchResults = (row, columns) => {
|
|
399
|
+
const optionColumns = columns ?? exports.DEFAULT_OPTIONS_INSERT_COLUMNS;
|
|
400
|
+
const optionNameIndex = optionColumns.indexOf('option_name');
|
|
401
|
+
const optionValueIndex = optionColumns.indexOf('option_value');
|
|
402
|
+
if (-1 === optionNameIndex || -1 === optionValueIndex) {
|
|
403
|
+
return undefined;
|
|
404
|
+
}
|
|
405
|
+
const optionName = (0, exports.unquoteSqlValue)(row[optionNameIndex]).toLowerCase();
|
|
406
|
+
const optionValue = (0, exports.unquoteSqlValue)(row[optionValueIndex]);
|
|
407
|
+
if ('siteurl' !== optionName && 'home' !== optionName) {
|
|
408
|
+
return undefined;
|
|
409
|
+
}
|
|
410
|
+
if (!/^https?:\/\//i.test(optionValue)) {
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
413
|
+
return ['', optionName, optionValue];
|
|
414
|
+
};
|
|
415
|
+
exports.getOptionUrlMatchResults = getOptionUrlMatchResults;
|