@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,53 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.startEnvironment = startEnvironment;
|
|
7
|
+
exports.stopEnvironment = stopEnvironment;
|
|
4
8
|
exports.createEnvironment = createEnvironment;
|
|
9
|
+
exports.updateEnvironment = updateEnvironment;
|
|
5
10
|
exports.destroyEnvironment = destroyEnvironment;
|
|
6
|
-
exports.doesEnvironmentExist = doesEnvironmentExist;
|
|
7
|
-
exports.exec = exec;
|
|
8
|
-
exports.fetchVersionList = fetchVersionList;
|
|
9
|
-
exports.generatePHPStormWorkspace = generatePHPStormWorkspace;
|
|
10
|
-
exports.generateVSCodeWorkspace = generateVSCodeWorkspace;
|
|
11
|
-
exports.getAllEnvironmentNames = getAllEnvironmentNames;
|
|
12
|
-
exports.getApplicationInformation = getApplicationInformation;
|
|
13
|
-
exports.getEnvironmentPath = getEnvironmentPath;
|
|
14
|
-
exports.getVSCodeWorkspacePath = getVSCodeWorkspacePath;
|
|
15
|
-
exports.getVersionList = getVersionList;
|
|
16
|
-
exports.importMediaPath = importMediaPath;
|
|
17
11
|
exports.printAllEnvironmentsInfo = printAllEnvironmentsInfo;
|
|
12
|
+
exports.showLogs = showLogs;
|
|
18
13
|
exports.printEnvironmentInfo = printEnvironmentInfo;
|
|
14
|
+
exports.exec = exec;
|
|
15
|
+
exports.doesEnvironmentExist = doesEnvironmentExist;
|
|
19
16
|
exports.readEnvironmentData = readEnvironmentData;
|
|
20
|
-
exports.resolveImportPath = resolveImportPath;
|
|
21
|
-
exports.showLogs = showLogs;
|
|
22
|
-
exports.startEnvironment = startEnvironment;
|
|
23
|
-
exports.stopEnvironment = stopEnvironment;
|
|
24
|
-
exports.updateEnvironment = updateEnvironment;
|
|
25
17
|
exports.writeEnvironmentData = writeEnvironmentData;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
18
|
+
exports.getAllEnvironmentNames = getAllEnvironmentNames;
|
|
19
|
+
exports.getEnvironmentPath = getEnvironmentPath;
|
|
20
|
+
exports.getApplicationInformation = getApplicationInformation;
|
|
21
|
+
exports.resolveImportPath = resolveImportPath;
|
|
22
|
+
exports.importMediaPath = importMediaPath;
|
|
23
|
+
exports.fetchVersionList = fetchVersionList;
|
|
24
|
+
exports.getVersionList = getVersionList;
|
|
25
|
+
exports.generateVSCodeWorkspace = generateVSCodeWorkspace;
|
|
26
|
+
exports.getVSCodeWorkspacePath = getVSCodeWorkspacePath;
|
|
27
|
+
exports.generatePHPStormWorkspace = generatePHPStormWorkspace;
|
|
28
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
29
|
+
const debug_1 = __importDefault(require("debug"));
|
|
30
|
+
const ejs_1 = __importDefault(require("ejs"));
|
|
31
|
+
const enquirer_1 = require("enquirer");
|
|
32
|
+
const graphql_1 = require("graphql");
|
|
33
|
+
const node_crypto_1 = require("node:crypto");
|
|
34
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
35
|
+
const promises_1 = require("node:fs/promises");
|
|
36
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
37
|
+
const semver_1 = __importDefault(require("semver"));
|
|
38
|
+
const undici_1 = require("undici");
|
|
39
|
+
const dev_environment_cli_1 = require("./dev-environment-cli");
|
|
40
|
+
const dev_environment_lando_1 = require("./dev-environment-lando");
|
|
41
|
+
const lando_loader_1 = require("./lando-loader");
|
|
42
|
+
const app_1 = __importDefault(require("../api/app"));
|
|
43
|
+
const software_1 = require("../config/software");
|
|
44
|
+
const dev_environment_1 = require("../constants/dev-environment");
|
|
45
|
+
const proxy_dispatcher_1 = require("../http/proxy-dispatcher");
|
|
46
|
+
const search_and_replace_1 = require("../search-and-replace");
|
|
47
|
+
const user_error_1 = __importDefault(require("../user-error"));
|
|
48
|
+
const xdg_data_1 = require("../xdg-data");
|
|
49
|
+
const debug = (0, debug_1.default)('@automattic/vip:bin:dev-environment');
|
|
50
|
+
const landoFileTemplatePath = node_path_1.default.join(__dirname, '..', '..', '..', 'assets', 'dev-env.lando.template.yml.ejs');
|
|
51
|
+
const nginxFileTemplatePath = node_path_1.default.join(__dirname, '..', '..', '..', 'assets', 'dev-env.nginx.template.conf.ejs');
|
|
51
52
|
const landoFileName = '.lando.yml';
|
|
52
53
|
const landoOverridesFileName = '.lando.local.yml';
|
|
53
54
|
const landoBackupFileName = '.lando.backup.yml';
|
|
@@ -61,290 +62,287 @@ const integrationsConfigPathString = 'integrations-config';
|
|
|
61
62
|
const STARTUP_READY_ATTEMPTS = 6;
|
|
62
63
|
const STARTUP_READY_DELAY_MS = 2000;
|
|
63
64
|
let dockerComposifyFromLando = null;
|
|
64
|
-
const dockerComposify = value => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
const dockerComposify = (value) => {
|
|
66
|
+
if (!dockerComposifyFromLando) {
|
|
67
|
+
const landoUtils = (0, lando_loader_1.loadLandoModule)('lando/lib/utils');
|
|
68
|
+
dockerComposifyFromLando = landoUtils.dockerComposify;
|
|
69
|
+
}
|
|
70
|
+
return dockerComposifyFromLando(value);
|
|
70
71
|
};
|
|
71
|
-
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
72
|
-
const renderTemplateFile = async (filePath, templateData) =>
|
|
72
|
+
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
73
|
+
const renderTemplateFile = async (filePath, templateData) => ejs_1.default.renderFile(filePath, templateData);
|
|
73
74
|
async function waitForEnvironmentToBeUp(lando, instancePath) {
|
|
74
|
-
|
|
75
|
+
return pollEnvironmentUpStatus(lando, instancePath, 1);
|
|
75
76
|
}
|
|
76
77
|
async function pollEnvironmentUpStatus(lando, instancePath, attempt) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
if (await (0, dev_environment_lando_1.isEnvUp)(lando, instancePath)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
if (attempt >= STARTUP_READY_ATTEMPTS) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
await sleep(STARTUP_READY_DELAY_MS);
|
|
85
|
+
return pollEnvironmentUpStatus(lando, instancePath, attempt + 1);
|
|
85
86
|
}
|
|
86
87
|
async function startEnvironment(lando, slug, options) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
extended: false
|
|
121
|
-
});
|
|
88
|
+
debug('Will start an environment', slug);
|
|
89
|
+
const instancePath = getEnvironmentPath(slug);
|
|
90
|
+
debug('Instance path for %s is %s', slug, instancePath);
|
|
91
|
+
const environmentExists = node_fs_1.default.existsSync(instancePath);
|
|
92
|
+
if (!environmentExists) {
|
|
93
|
+
throw new Error(dev_environment_1.DEV_ENVIRONMENT_NOT_FOUND);
|
|
94
|
+
}
|
|
95
|
+
const envFilePath = node_path_1.default.join(instancePath, '.env');
|
|
96
|
+
node_fs_1.default.appendFileSync(envFilePath, '');
|
|
97
|
+
let updated = false;
|
|
98
|
+
if (!options.skipWpVersionsCheck && process.stdin.isTTY) {
|
|
99
|
+
updated = await maybeUpdateWordPressImage(lando, slug);
|
|
100
|
+
}
|
|
101
|
+
updated = updated || (await maybeUpdateVersion(lando, slug));
|
|
102
|
+
const proxyContainer = await (0, dev_environment_lando_1.getProxyContainer)(lando);
|
|
103
|
+
if (!proxyContainer?.State.Running) {
|
|
104
|
+
await (0, dev_environment_lando_1.removeProxyCache)(lando);
|
|
105
|
+
}
|
|
106
|
+
if (options.skipRebuild && !updated) {
|
|
107
|
+
await (0, dev_environment_lando_1.landoStart)(lando, instancePath);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
await (0, dev_environment_lando_1.landoRebuild)(lando, instancePath);
|
|
111
|
+
}
|
|
112
|
+
let isEnvironmentUp = await waitForEnvironmentToBeUp(lando, instancePath);
|
|
113
|
+
if (!isEnvironmentUp) {
|
|
114
|
+
// A second startup pass helps recover after Docker network auto-cleanup edge cases.
|
|
115
|
+
await (0, dev_environment_lando_1.landoStart)(lando, instancePath);
|
|
116
|
+
isEnvironmentUp = await waitForEnvironmentToBeUp(lando, instancePath);
|
|
117
|
+
}
|
|
118
|
+
if (!isEnvironmentUp) {
|
|
119
|
+
throw new user_error_1.default(`Environment "${slug}" did not reach a running state. Please try "${chalk_1.default.bold(`vip dev-env start --slug ${slug}`)}" again.`);
|
|
120
|
+
}
|
|
121
|
+
await printEnvironmentInfo(lando, slug, { extended: false });
|
|
122
122
|
}
|
|
123
123
|
async function stopEnvironment(lando, slug) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
debug('Will stop an environment', slug);
|
|
125
|
+
const instancePath = getEnvironmentPath(slug);
|
|
126
|
+
debug('Instance path for', slug, 'is:', instancePath);
|
|
127
|
+
const environmentExists = node_fs_1.default.existsSync(instancePath);
|
|
128
|
+
if (!environmentExists) {
|
|
129
|
+
throw new Error(dev_environment_1.DEV_ENVIRONMENT_NOT_FOUND);
|
|
130
|
+
}
|
|
131
|
+
await (0, dev_environment_lando_1.landoStop)(lando, instancePath);
|
|
132
132
|
}
|
|
133
133
|
function createEnvironment(lando, instanceData, integrationsConfig, envVars) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
134
|
+
const slug = instanceData.siteSlug;
|
|
135
|
+
integrationsConfig ??= {};
|
|
136
|
+
debug('Will process an environment', slug, 'with instanceData for creation: ', instanceData);
|
|
137
|
+
const instancePath = getEnvironmentPath(slug);
|
|
138
|
+
debug('Instance path for', slug, 'is:', instancePath);
|
|
139
|
+
const alreadyExists = node_fs_1.default.existsSync(instancePath);
|
|
140
|
+
if (alreadyExists) {
|
|
141
|
+
return Promise.reject(new Error('Environment already exists.'));
|
|
142
|
+
}
|
|
143
|
+
const preProcessedInstanceData = preProcessInstanceData(instanceData);
|
|
144
|
+
debug('Will create an environment', slug, 'with instanceData: ', preProcessedInstanceData);
|
|
145
|
+
return prepareLandoEnv(lando, preProcessedInstanceData, instancePath, integrationsConfig, envVars);
|
|
146
146
|
}
|
|
147
147
|
async function updateEnvironment(lando, instanceData) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
const slug = instanceData.siteSlug;
|
|
149
|
+
debug('Will process an environment', slug, 'with instanceData for updating: ', instanceData);
|
|
150
|
+
const instancePath = getEnvironmentPath(slug);
|
|
151
|
+
debug('Instance path for', slug, 'is:', instancePath);
|
|
152
|
+
const alreadyExists = node_fs_1.default.existsSync(instancePath);
|
|
153
|
+
if (!alreadyExists) {
|
|
154
|
+
throw new Error("Environment doesn't exist.");
|
|
155
|
+
}
|
|
156
|
+
const preProcessedInstanceData = preProcessInstanceData(instanceData);
|
|
157
|
+
debug('Will create an environment', slug, 'with instanceData: ', preProcessedInstanceData);
|
|
158
|
+
await prepareLandoEnv(lando, preProcessedInstanceData, instancePath, undefined, undefined);
|
|
159
159
|
}
|
|
160
160
|
function preProcessInstanceData(instanceData) {
|
|
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
|
-
return newInstanceData;
|
|
161
|
+
const newInstanceData = {
|
|
162
|
+
...instanceData,
|
|
163
|
+
xdebugConfig: instanceData.xdebugConfig ?? '',
|
|
164
|
+
mariadb: instanceData.mariadb ?? '',
|
|
165
|
+
elasticsearch: instanceData.elasticsearch || false, // NOSONAR
|
|
166
|
+
php: instanceData.php ?? dev_environment_1.DEV_ENVIRONMENT_PHP_VERSIONS[dev_environment_1.DEV_ENVIRONMENT_DEFAULT_PHP_VERSION].image,
|
|
167
|
+
xdebug: Boolean(instanceData.xdebug),
|
|
168
|
+
phpmyadmin: Boolean(instanceData.phpmyadmin),
|
|
169
|
+
photon: Boolean(instanceData.photon),
|
|
170
|
+
cron: Boolean(instanceData.cron),
|
|
171
|
+
mailpit: Boolean(instanceData.mailpit),
|
|
172
|
+
pullAfter: instanceData.pullAfter ?? 0,
|
|
173
|
+
autologinKey: (0, node_crypto_1.randomUUID)(),
|
|
174
|
+
adminPassword: instanceData.adminPassword ?? 'password',
|
|
175
|
+
version: dev_environment_1.DEV_ENVIRONMENT_VERSION,
|
|
176
|
+
overrides: instanceData.overrides ?? '',
|
|
177
|
+
};
|
|
178
|
+
if (instanceData.mediaRedirectDomain && !/^https?:/.test(instanceData.mediaRedirectDomain)) {
|
|
179
|
+
// We need to make sure the redirect is an absolute path
|
|
180
|
+
newInstanceData.mediaRedirectDomain = `https://${instanceData.mediaRedirectDomain}`;
|
|
181
|
+
}
|
|
182
|
+
if (isNaN(instanceData.wordpress.tag)) {
|
|
183
|
+
newInstanceData.wordpress.tag = 'trunk';
|
|
184
|
+
}
|
|
185
|
+
return newInstanceData;
|
|
187
186
|
}
|
|
188
187
|
async function destroyEnvironment(lando, slug, removeFiles) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (removeFiles) {
|
|
208
|
-
await _nodeFs.default.promises.rm(instancePath, {
|
|
209
|
-
recursive: true
|
|
188
|
+
debug('Will destroy an environment', slug);
|
|
189
|
+
const instancePath = getEnvironmentPath(slug);
|
|
190
|
+
debug('Instance path for', slug, 'is:', instancePath);
|
|
191
|
+
const environmentExists = await doesEnvironmentExist(instancePath);
|
|
192
|
+
if (!environmentExists) {
|
|
193
|
+
throw new Error(dev_environment_1.DEV_ENVIRONMENT_NOT_FOUND);
|
|
194
|
+
}
|
|
195
|
+
const landoFilePath = node_path_1.default.join(instancePath, landoFileName);
|
|
196
|
+
if (node_fs_1.default.existsSync(landoFilePath)) {
|
|
197
|
+
debug('Lando file exists, will lando destroy.');
|
|
198
|
+
await (0, dev_environment_lando_1.landoDestroy)(lando, instancePath);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
debug("Lando file doesn't exist, skipping lando destroy.");
|
|
202
|
+
}
|
|
203
|
+
await node_fs_1.default.promises.rm(node_path_1.default.join((0, xdg_data_1.xdgData)(), 'vip', 'lando', 'compose', dockerComposify(slug)), {
|
|
204
|
+
force: true,
|
|
205
|
+
recursive: true,
|
|
210
206
|
});
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
if (removeFiles) {
|
|
208
|
+
await node_fs_1.default.promises.rm(instancePath, { recursive: true });
|
|
209
|
+
console.log(`${chalk_1.default.green('✓')} Environment files deleted successfully.`);
|
|
210
|
+
}
|
|
213
211
|
}
|
|
214
212
|
async function printAllEnvironmentsInfo(lando, options) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
213
|
+
const allEnvNames = getAllEnvironmentNames();
|
|
214
|
+
debug('Will print info for all environments. Names found: ', allEnvNames);
|
|
215
|
+
console.log('Found ' +
|
|
216
|
+
chalk_1.default.bold(allEnvNames.length) +
|
|
217
|
+
' environments' +
|
|
218
|
+
(allEnvNames.length ? ':' : '.'));
|
|
219
|
+
for (const envName of allEnvNames) {
|
|
220
|
+
try {
|
|
221
|
+
console.log('\n');
|
|
222
|
+
// eslint-disable-next-line no-await-in-loop
|
|
223
|
+
await printEnvironmentInfo(lando, envName, options);
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
if (error instanceof user_error_1.default) {
|
|
227
|
+
console.warn('\nWARNING: "%s" is not a valid environment\n', envName);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
229
233
|
}
|
|
230
|
-
}
|
|
231
234
|
}
|
|
232
235
|
function parseComponentForInfo(component) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return component.tag ?? '[demo-image]';
|
|
236
|
+
if (component.mode === 'local') {
|
|
237
|
+
return component.dir ?? '';
|
|
238
|
+
}
|
|
239
|
+
// Environments created by the old code will have `component.tag` set to `demo` instead of `undefined`.
|
|
240
|
+
if (component.tag === 'demo' || component.tag === 'latest') {
|
|
241
|
+
component.tag = undefined;
|
|
242
|
+
}
|
|
243
|
+
return component.tag ?? '[demo-image]';
|
|
242
244
|
}
|
|
243
245
|
async function showLogs(lando, slug, options = {}) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
246
|
+
debug('Will display logs command on env', slug, 'with options', options);
|
|
247
|
+
const instancePath = getEnvironmentPath(slug);
|
|
248
|
+
debug('Instance path for %s is %s', slug, instancePath);
|
|
249
|
+
if (options.service) {
|
|
250
|
+
const application = await (0, dev_environment_lando_1.getLandoApplication)(lando, instancePath);
|
|
251
|
+
const services = application.info.map(service => service.service);
|
|
252
|
+
if (!services.includes(options.service)) {
|
|
253
|
+
throw new user_error_1.default(`Service '${options.service}' not found. Please choose from: ${services.join(', ')}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return (0, dev_environment_lando_1.landoLogs)(lando, instancePath, options);
|
|
255
257
|
}
|
|
256
258
|
async function printEnvironmentInfo(lando, slug, options) {
|
|
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
|
-
|
|
259
|
+
debug('Will get info for an environment', slug);
|
|
260
|
+
const instancePath = getEnvironmentPath(slug);
|
|
261
|
+
debug('Instance path for', slug, 'is:', instancePath);
|
|
262
|
+
const environmentExists = await doesEnvironmentExist(instancePath);
|
|
263
|
+
if (!environmentExists) {
|
|
264
|
+
throw new user_error_1.default(dev_environment_1.DEV_ENVIRONMENT_NOT_FOUND);
|
|
265
|
+
}
|
|
266
|
+
const environmentData = readEnvironmentData(slug);
|
|
267
|
+
const appInfo = await (0, dev_environment_lando_1.landoInfo)(lando, instancePath, {
|
|
268
|
+
suppressWarnings: Boolean(options.suppressWarnings),
|
|
269
|
+
autologinKey: environmentData.autologinKey,
|
|
270
|
+
});
|
|
271
|
+
if (options.extended) {
|
|
272
|
+
appInfo.title = environmentData.wpTitle;
|
|
273
|
+
appInfo.multisite = Boolean(environmentData.multisite);
|
|
274
|
+
appInfo.php = environmentData.php.split(':')[1];
|
|
275
|
+
let xdebug = environmentData.xdebug ? 'enabled' : 'disabled';
|
|
276
|
+
if (environmentData.xdebug && environmentData.xdebugConfig) {
|
|
277
|
+
xdebug += ' (with additional configuration)';
|
|
278
|
+
}
|
|
279
|
+
appInfo.xdebug = xdebug;
|
|
280
|
+
appInfo.cron = environmentData.cron ? 'enabled' : 'disabled';
|
|
281
|
+
appInfo.wordpress = parseComponentForInfo(environmentData.wordpress);
|
|
282
|
+
appInfo['Mu plugins'] = parseComponentForInfo(environmentData.muPlugins);
|
|
283
|
+
appInfo['App Code'] = parseComponentForInfo(environmentData.appCode);
|
|
284
|
+
if (environmentData.mediaRedirectDomain) {
|
|
285
|
+
appInfo['Media Redirect'] = environmentData.mediaRedirectDomain;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
(0, dev_environment_cli_1.printTable)(appInfo);
|
|
287
289
|
}
|
|
288
290
|
function exec(lando, slug, args, options = {}) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
291
|
+
debug('Will run a wp command on env', slug, 'with args', args, ' and options', options);
|
|
292
|
+
const instancePath = getEnvironmentPath(slug);
|
|
293
|
+
debug('Instance path for', slug, 'is:', instancePath);
|
|
294
|
+
const [command, ...commandArgs] = args;
|
|
295
|
+
return (0, dev_environment_lando_1.landoExec)(lando, instancePath, command, commandArgs, options);
|
|
294
296
|
}
|
|
295
297
|
async function doesEnvironmentExist(instancePath) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
298
|
+
debug('Will check for environment at %s', instancePath);
|
|
299
|
+
const file = node_path_1.default.join(instancePath, instanceDataFileName);
|
|
300
|
+
try {
|
|
301
|
+
const stats = await node_fs_1.default.promises.stat(file);
|
|
302
|
+
return stats.isFile();
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
304
307
|
}
|
|
305
308
|
function readEnvironmentData(slug) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
//
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
// clientCode was renamed to appCode
|
|
343
|
-
instanceData.appCode = instanceData.clientCode;
|
|
344
|
-
}
|
|
345
|
-
return instanceData;
|
|
309
|
+
debug('Will try to get instance data for environment', slug);
|
|
310
|
+
const instancePath = getEnvironmentPath(slug);
|
|
311
|
+
const instanceDataTargetPath = node_path_1.default.join(instancePath, instanceDataFileName);
|
|
312
|
+
let instanceDataString;
|
|
313
|
+
let instanceData;
|
|
314
|
+
try {
|
|
315
|
+
instanceDataString = node_fs_1.default.readFileSync(instanceDataTargetPath, 'utf8');
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
const err = error;
|
|
319
|
+
throw new user_error_1.default(`There was an error reading file "${instanceDataTargetPath}": ${err.message}.`, { cause: error });
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
instanceData = JSON.parse(instanceDataString);
|
|
323
|
+
}
|
|
324
|
+
catch (error) {
|
|
325
|
+
const err = error;
|
|
326
|
+
throw new user_error_1.default(`There was an error parsing file "${instanceDataTargetPath}": ${err.message}. You may need to recreate the environment.`, { cause: error });
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
***********************************
|
|
330
|
+
* BACKWARDS COMPATIBILITY SECTION
|
|
331
|
+
**********************************
|
|
332
|
+
*/
|
|
333
|
+
// REMOVEME after the wheel of time spins around few times
|
|
334
|
+
if (instanceData.enterpriseSearchEnabled || instanceData.elasticsearchEnabled) {
|
|
335
|
+
// enterpriseSearchEnabled and elasticsearchEnabled was renamed to elasticsearch
|
|
336
|
+
instanceData.elasticsearch = (instanceData.enterpriseSearchEnabled ||
|
|
337
|
+
instanceData.elasticsearchEnabled);
|
|
338
|
+
}
|
|
339
|
+
// REMOVEME after the wheel of time spins around few times
|
|
340
|
+
if (instanceData.clientCode) {
|
|
341
|
+
// clientCode was renamed to appCode
|
|
342
|
+
instanceData.appCode = instanceData.clientCode;
|
|
343
|
+
}
|
|
344
|
+
return instanceData;
|
|
346
345
|
}
|
|
347
|
-
|
|
348
346
|
/**
|
|
349
347
|
* Writes the instance data.
|
|
350
348
|
*
|
|
@@ -353,108 +351,108 @@ function readEnvironmentData(slug) {
|
|
|
353
351
|
* @return {Promise<void>} Promise
|
|
354
352
|
*/
|
|
355
353
|
function writeEnvironmentData(slug, data) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
354
|
+
debug('Will try to write instance data for environment', slug);
|
|
355
|
+
const instancePath = getEnvironmentPath(slug);
|
|
356
|
+
const instanceDataTargetPath = node_path_1.default.join(instancePath, instanceDataFileName);
|
|
357
|
+
return node_fs_1.default.promises.writeFile(instanceDataTargetPath, JSON.stringify(data, null, 2));
|
|
360
358
|
}
|
|
361
359
|
async function writeIntegrationsConfig(instancePath, integrationsConfig) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
360
|
+
const integrationsConfigPath = node_path_1.default.join(instancePath, integrationsConfigPathString);
|
|
361
|
+
const integrationsConfigTargetPath = node_path_1.default.join(integrationsConfigPath, integrationsConfigFileName);
|
|
362
|
+
await node_fs_1.default.promises.mkdir(integrationsConfigPath, { recursive: true });
|
|
363
|
+
if (integrationsConfig !== undefined) {
|
|
364
|
+
const integrationsConfigBackupTargetPath = node_path_1.default.join(integrationsConfigPath, integrationsConfigBackupFileName);
|
|
365
|
+
try {
|
|
366
|
+
await node_fs_1.default.promises.rename(integrationsConfigTargetPath, integrationsConfigBackupTargetPath);
|
|
367
|
+
console.log(`Backup of ${integrationsConfigFileName} was created in ${integrationsConfigBackupTargetPath}`);
|
|
368
|
+
}
|
|
369
|
+
catch (err) {
|
|
370
|
+
if ('ENOENT' !== err.code) {
|
|
371
|
+
throw err;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const configJson = JSON.stringify(integrationsConfig, null, 4);
|
|
375
|
+
await node_fs_1.default.promises.writeFile(integrationsConfigTargetPath, configJson);
|
|
376
|
+
debug(`Integrations configuration file created in ${integrationsConfigTargetPath}`);
|
|
377
|
+
}
|
|
381
378
|
}
|
|
382
379
|
async function prepareLandoEnv(lando, instanceData, instancePath, integrationsConfig, envVars) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
recursive: true
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
await
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
380
|
+
const templateData = {
|
|
381
|
+
...instanceData,
|
|
382
|
+
domain: lando.config.domain,
|
|
383
|
+
};
|
|
384
|
+
const landoFile = await renderTemplateFile(landoFileTemplatePath, templateData);
|
|
385
|
+
const nginxFile = await renderTemplateFile(nginxFileTemplatePath, templateData);
|
|
386
|
+
const instanceDataFile = JSON.stringify(instanceData);
|
|
387
|
+
const landoFileTargetPath = node_path_1.default.join(instancePath, landoFileName);
|
|
388
|
+
const landoOverridesFileTargetPath = node_path_1.default.join(instancePath, landoOverridesFileName);
|
|
389
|
+
const landoBackupFileTargetPath = node_path_1.default.join(instancePath, landoBackupFileName);
|
|
390
|
+
const nginxFolderPath = node_path_1.default.join(instancePath, nginxPathString);
|
|
391
|
+
const nginxFileTargetPath = node_path_1.default.join(nginxFolderPath, nginxFileName);
|
|
392
|
+
const instanceDataTargetPath = node_path_1.default.join(instancePath, instanceDataFileName);
|
|
393
|
+
const envFilePath = node_path_1.default.join(instancePath, '.env');
|
|
394
|
+
await node_fs_1.default.promises.mkdir(instancePath, { recursive: true });
|
|
395
|
+
await node_fs_1.default.promises.mkdir(nginxFolderPath, { recursive: true });
|
|
396
|
+
try {
|
|
397
|
+
await node_fs_1.default.promises.rename(landoFileTargetPath, landoBackupFileTargetPath);
|
|
398
|
+
console.log(`Backup of ${landoFileName} was created in ${landoBackupFileTargetPath}`);
|
|
399
|
+
}
|
|
400
|
+
catch (err) {
|
|
401
|
+
// If the file doesn't exist, that's fine. Otherwise, throw the error.
|
|
402
|
+
if ('ENOENT' !== err.code) {
|
|
403
|
+
throw err;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
await Promise.all([
|
|
407
|
+
node_fs_1.default.promises.writeFile(landoFileTargetPath, landoFile),
|
|
408
|
+
node_fs_1.default.promises.writeFile(nginxFileTargetPath, nginxFile),
|
|
409
|
+
node_fs_1.default.promises.writeFile(instanceDataTargetPath, instanceDataFile),
|
|
410
|
+
]);
|
|
411
|
+
if (envVars !== undefined) {
|
|
412
|
+
const env = [];
|
|
413
|
+
Object.entries(envVars ?? {}).forEach(([key]) => {
|
|
414
|
+
env.push(`VIP_ENV_VAR_${key}=`);
|
|
415
|
+
});
|
|
416
|
+
await node_fs_1.default.promises.writeFile(envFilePath, env.join('\n'));
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
await node_fs_1.default.promises.appendFile(envFilePath, '');
|
|
420
|
+
}
|
|
421
|
+
debug(`Lando file created in ${landoFileTargetPath}`);
|
|
422
|
+
debug(`Nginx file created in ${nginxFileTargetPath}`);
|
|
423
|
+
debug(`Instance data file created in ${instanceDataTargetPath}`);
|
|
424
|
+
await writeIntegrationsConfig(instancePath, integrationsConfig);
|
|
425
|
+
if (instanceData.overrides) {
|
|
426
|
+
await node_fs_1.default.promises.writeFile(landoOverridesFileTargetPath, instanceData.overrides);
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
await node_fs_1.default.promises.rm(landoOverridesFileTargetPath, { force: true });
|
|
430
|
+
}
|
|
433
431
|
}
|
|
434
432
|
function getAllEnvironmentNames() {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
433
|
+
const mainEnvironmentPath = (0, xdg_data_1.xdgData)();
|
|
434
|
+
const baseDir = node_path_1.default.join(mainEnvironmentPath, 'vip', 'dev-environment');
|
|
435
|
+
const doWeHaveAnyEnvironment = node_fs_1.default.existsSync(baseDir);
|
|
436
|
+
let envNames = [];
|
|
437
|
+
if (doWeHaveAnyEnvironment) {
|
|
438
|
+
const files = node_fs_1.default.readdirSync(baseDir);
|
|
439
|
+
envNames = files.filter(file => {
|
|
440
|
+
const fullPath = node_path_1.default.join(baseDir, file);
|
|
441
|
+
return node_fs_1.default.lstatSync(fullPath).isDirectory();
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
return envNames;
|
|
447
445
|
}
|
|
448
446
|
function getEnvironmentPath(name) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
447
|
+
if (!name) {
|
|
448
|
+
throw new Error('Name was not provided');
|
|
449
|
+
}
|
|
450
|
+
const mainEnvironmentPath = (0, xdg_data_1.xdgData)();
|
|
451
|
+
return node_path_1.default.join(mainEnvironmentPath, 'vip', 'dev-environment', String(name));
|
|
454
452
|
}
|
|
455
453
|
async function getApplicationInformation(appId, envType) {
|
|
456
|
-
|
|
457
|
-
|
|
454
|
+
// $FlowFixMe: gql template is not supported by flow
|
|
455
|
+
const fieldsQuery = `
|
|
458
456
|
id,
|
|
459
457
|
name,
|
|
460
458
|
repository {
|
|
@@ -487,114 +485,109 @@ async function getApplicationInformation(appId, envType) {
|
|
|
487
485
|
}
|
|
488
486
|
}
|
|
489
487
|
}`;
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
envData = environments.find(candidateEnv => candidateEnv.type === env);
|
|
515
|
-
}
|
|
516
|
-
if (envData) {
|
|
517
|
-
const envVars = {};
|
|
518
|
-
envData.environmentVariables?.nodes?.forEach(envvar => {
|
|
519
|
-
if (envvar?.name) {
|
|
520
|
-
envVars[envvar.name] = '';
|
|
488
|
+
const queryResult = await (0, app_1.default)(appId, fieldsQuery, (0, graphql_1.print)(software_1.appQueryFragments));
|
|
489
|
+
const appData = {};
|
|
490
|
+
if (queryResult.id) {
|
|
491
|
+
appData.id = queryResult.id;
|
|
492
|
+
appData.name = queryResult.name;
|
|
493
|
+
appData.repository = queryResult.repository?.htmlUrl;
|
|
494
|
+
// FIXME: This is casted as AppEnvironment[] but pedantically, Parker's schema made it so that the array may contain nullable. Code-wise though, that doesn't actually happen.
|
|
495
|
+
const environments = (queryResult.environments ?? []);
|
|
496
|
+
let envData;
|
|
497
|
+
if (envType) {
|
|
498
|
+
envData = environments.find(candidateEnv => candidateEnv.type === envType);
|
|
499
|
+
}
|
|
500
|
+
else if (1 === environments.length) {
|
|
501
|
+
envData = environments[0];
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
const choices = environments.map(candidateEnv => candidateEnv.type);
|
|
505
|
+
const { env } = await (0, enquirer_1.prompt)({
|
|
506
|
+
type: 'select',
|
|
507
|
+
name: 'env',
|
|
508
|
+
message: 'Which environment?',
|
|
509
|
+
choices,
|
|
510
|
+
});
|
|
511
|
+
envData = environments.find(candidateEnv => candidateEnv.type === env);
|
|
521
512
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
513
|
+
if (envData) {
|
|
514
|
+
const envVars = {};
|
|
515
|
+
envData.environmentVariables?.nodes?.forEach(envvar => {
|
|
516
|
+
if (envvar?.name) {
|
|
517
|
+
envVars[envvar.name] = '';
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
appData.environment = {
|
|
521
|
+
name: envData.name,
|
|
522
|
+
branch: envData.branch,
|
|
523
|
+
type: envData.type,
|
|
524
|
+
isMultisite: envData.isMultisite,
|
|
525
|
+
primaryDomain: envData.primaryDomain?.name ?? '',
|
|
526
|
+
php: envData.softwareSettings?.php?.current.version ?? '',
|
|
527
|
+
wordpress: envData.softwareSettings?.wordpress?.current.version ?? '',
|
|
528
|
+
integrations: envData.getIntegrationsDevEnvConfig?.data ??
|
|
529
|
+
{},
|
|
530
|
+
envVars,
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return appData;
|
|
537
535
|
}
|
|
538
536
|
async function resolveImportPath(slug, fileName, searchReplace, inPlace) {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// Run Search and Replace if the --search-replace flag was provided
|
|
550
|
-
if (searchReplace?.length) {
|
|
551
|
-
const {
|
|
552
|
-
outputFileName
|
|
553
|
-
} = await (0, _searchAndReplace.searchAndReplace)(resolvedPath, searchReplace, {
|
|
554
|
-
isImport: true,
|
|
555
|
-
output: true,
|
|
556
|
-
inPlace
|
|
557
|
-
});
|
|
558
|
-
if (typeof outputFileName !== 'string') {
|
|
559
|
-
throw new Error('Unable to determine location of the intermediate search & replace file.');
|
|
537
|
+
debug(`Will try to resolve path - ${fileName}`);
|
|
538
|
+
let resolvedPath = (0, dev_environment_cli_1.resolvePath)(fileName);
|
|
539
|
+
debug(`Filename ${fileName} resolved to ${resolvedPath}`);
|
|
540
|
+
if (!node_fs_1.default.existsSync(resolvedPath)) {
|
|
541
|
+
throw new user_error_1.default(`The provided file ${resolvedPath} does not exist or it is not valid (see "--help" for examples)`);
|
|
542
|
+
}
|
|
543
|
+
if (node_fs_1.default.lstatSync(resolvedPath).isDirectory()) {
|
|
544
|
+
throw new user_error_1.default(`The provided file ${resolvedPath} is a directory. Please point to a sql file.`);
|
|
560
545
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
546
|
+
// Run Search and Replace if the --search-replace flag was provided
|
|
547
|
+
if (searchReplace?.length) {
|
|
548
|
+
const { outputFileName } = await (0, search_and_replace_1.searchAndReplace)(resolvedPath, searchReplace, {
|
|
549
|
+
isImport: true,
|
|
550
|
+
output: true,
|
|
551
|
+
inPlace,
|
|
552
|
+
});
|
|
553
|
+
if (typeof outputFileName !== 'string') {
|
|
554
|
+
throw new Error('Unable to determine location of the intermediate search & replace file.');
|
|
555
|
+
}
|
|
556
|
+
resolvedPath = outputFileName;
|
|
557
|
+
}
|
|
558
|
+
return resolvedPath;
|
|
564
559
|
}
|
|
565
560
|
async function importMediaPath(slug, filePath) {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}
|
|
561
|
+
const resolvedPath = (0, dev_environment_cli_1.resolvePath)(filePath);
|
|
562
|
+
if (!node_fs_1.default.existsSync(resolvedPath) || !node_fs_1.default.lstatSync(resolvedPath).isDirectory()) {
|
|
563
|
+
throw new Error('The provided path does not exist or it is not valid (see "--help" for examples)');
|
|
564
|
+
}
|
|
565
|
+
const environmentPath = getEnvironmentPath(slug);
|
|
566
|
+
if (!(await doesEnvironmentExist(environmentPath))) {
|
|
567
|
+
throw new Error(dev_environment_1.DEV_ENVIRONMENT_NOT_FOUND);
|
|
568
|
+
}
|
|
569
|
+
const files = await (0, promises_1.readdir)(resolvedPath);
|
|
570
|
+
if (files.includes(uploadPathString)) {
|
|
571
|
+
const confirm = await (0, enquirer_1.prompt)({
|
|
572
|
+
type: 'confirm',
|
|
573
|
+
name: 'continue',
|
|
574
|
+
message: 'The provided path contains an uploads folder inside. Do you want to continue?',
|
|
575
|
+
});
|
|
576
|
+
if (!confirm.continue) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const uploadsPath = node_path_1.default.join(environmentPath, uploadPathString);
|
|
581
|
+
console.log(`${chalk_1.default.yellow('-')} Started copying files`);
|
|
582
|
+
try {
|
|
583
|
+
await (0, promises_1.cp)(resolvedPath, uploadsPath, { recursive: true });
|
|
584
|
+
console.log(`${chalk_1.default.green('✓')} Files successfully copied to ${uploadsPath}.`);
|
|
585
|
+
}
|
|
586
|
+
catch (error) {
|
|
587
|
+
console.error(`${chalk_1.default.red('✗')} Error copying files to ${uploadsPath}.`);
|
|
588
|
+
throw error;
|
|
589
|
+
}
|
|
596
590
|
}
|
|
597
|
-
|
|
598
591
|
/**
|
|
599
592
|
* Uses the WordPress versions manifest on github.com
|
|
600
593
|
* Informs the user several things:
|
|
@@ -606,122 +599,106 @@ async function importMediaPath(slug, filePath) {
|
|
|
606
599
|
* @return {boolean} boolean
|
|
607
600
|
*/
|
|
608
601
|
async function maybeUpdateWordPressImage(lando, slug) {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
tag
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
602
|
+
const versions = await getVersionList();
|
|
603
|
+
if (!versions.length) {
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
606
|
+
let message;
|
|
607
|
+
let envData;
|
|
608
|
+
let currentWordPressTag;
|
|
609
|
+
// Get the current environment configuration
|
|
610
|
+
try {
|
|
611
|
+
envData = readEnvironmentData(slug);
|
|
612
|
+
currentWordPressTag = envData.wordpress.tag;
|
|
613
|
+
if (currentWordPressTag === 'trunk') {
|
|
614
|
+
return false;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
catch (err) {
|
|
618
|
+
const error = err;
|
|
619
|
+
// This can throw an exception if the env is build with older vip version
|
|
620
|
+
if ('ENOENT' === error.code) {
|
|
621
|
+
message = 'Environment was created before update was supported.\n\n';
|
|
622
|
+
message += 'To update environment please destroy it and create a new one.';
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
message = `An error prevented reading the configuration of: ${slug}\n\n ${error.message}`;
|
|
626
|
+
}
|
|
627
|
+
await (0, dev_environment_cli_1.handleCLIException)(new Error(message));
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
// sort
|
|
631
|
+
versions.sort((before, after) => (before.tag < after.tag ? 1 : -1));
|
|
632
|
+
// Newest WordPress Image but that is not trunk
|
|
633
|
+
const newestWordPressImage = versions.find(({ tag }) => tag !== 'trunk');
|
|
634
|
+
console.log('The most recent WordPress version available is: ' + chalk_1.default.green(newestWordPressImage?.tag));
|
|
635
|
+
// If the currently used version is the most up to date: exit.
|
|
636
|
+
if (currentWordPressTag === newestWordPressImage?.tag) {
|
|
637
|
+
console.log('Environment WordPress version is: ' + chalk_1.default.green(currentWordPressTag) + ' ... 😎 nice! ');
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
// Determine if there is an image available for the current WordPress version
|
|
641
|
+
const match = versions.find(({ tag }) => tag === currentWordPressTag);
|
|
642
|
+
// If there is no available image for the currently installed version, give user a path to change
|
|
643
|
+
if (typeof match === 'undefined') {
|
|
644
|
+
console.log(`Installed WordPress: ${currentWordPressTag} has no available container image in repository. `);
|
|
645
|
+
console.log('You must select a new WordPress image to continue... ');
|
|
646
|
+
}
|
|
647
|
+
else {
|
|
648
|
+
console.log('Environment WordPress version is: ' + chalk_1.default.yellow(`${match.tag} (${match.ref})`));
|
|
649
|
+
if (envData.wordpress.doNotUpgrade) {
|
|
650
|
+
return false;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
// Prompt the user to select a new WordPress Version
|
|
654
|
+
const confirm = await (0, enquirer_1.prompt)({
|
|
655
|
+
type: 'select',
|
|
656
|
+
name: 'upgrade',
|
|
657
|
+
message: 'Would you like to upgrade WordPress? ',
|
|
658
|
+
choices: ['yes', 'no', "no (don't ask anymore)"],
|
|
659
|
+
});
|
|
660
|
+
// If the user takes the new WP version path
|
|
661
|
+
if (confirm.upgrade === 'yes') {
|
|
662
|
+
console.log('Upgrading from: ' + chalk_1.default.yellow(currentWordPressTag) + ' to:');
|
|
663
|
+
// Select a new image
|
|
664
|
+
const choice = await (0, dev_environment_cli_1.promptForWordPress)(newestWordPressImage?.tag ?? null);
|
|
665
|
+
const version = versions.find(({ tag }) => tag.trim() === choice.tag.trim());
|
|
666
|
+
// Write new data and stage for rebuild
|
|
667
|
+
// FIXME: version?.tag is possibly null. Should we throw if we can't find a version somehow?
|
|
668
|
+
envData.wordpress.tag = version?.tag ?? '';
|
|
669
|
+
envData.wordpress.ref = version?.ref;
|
|
670
|
+
await updateEnvironment(lando, envData);
|
|
671
|
+
return true;
|
|
672
|
+
}
|
|
673
|
+
if (confirm.upgrade === "no (don't ask anymore)") {
|
|
674
|
+
const updateCommand = `vip dev-env update --slug=${slug}`;
|
|
675
|
+
envData.wordpress.doNotUpgrade = true;
|
|
676
|
+
console.log("We won't ask about upgrading this environment anymore.");
|
|
677
|
+
console.log(`To manually upgrade please run: ${chalk_1.default.yellow(updateCommand)}`);
|
|
678
|
+
await updateEnvironment(lando, envData);
|
|
679
|
+
}
|
|
648
680
|
return false;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
// Determine if there is an image available for the current WordPress version
|
|
652
|
-
const match = versions.find(({
|
|
653
|
-
tag
|
|
654
|
-
}) => tag === currentWordPressTag);
|
|
655
|
-
|
|
656
|
-
// If there is no available image for the currently installed version, give user a path to change
|
|
657
|
-
if (typeof match === 'undefined') {
|
|
658
|
-
console.log(`Installed WordPress: ${currentWordPressTag} has no available container image in repository. `);
|
|
659
|
-
console.log('You must select a new WordPress image to continue... ');
|
|
660
|
-
} else {
|
|
661
|
-
console.log('Environment WordPress version is: ' + _chalk.default.yellow(`${match.tag} (${match.ref})`));
|
|
662
|
-
if (envData.wordpress.doNotUpgrade) {
|
|
663
|
-
return false;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
// Prompt the user to select a new WordPress Version
|
|
668
|
-
const confirm = await (0, _enquirer.prompt)({
|
|
669
|
-
type: 'select',
|
|
670
|
-
name: 'upgrade',
|
|
671
|
-
message: 'Would you like to upgrade WordPress? ',
|
|
672
|
-
choices: ['yes', 'no', "no (don't ask anymore)"]
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
// If the user takes the new WP version path
|
|
676
|
-
if (confirm.upgrade === 'yes') {
|
|
677
|
-
console.log('Upgrading from: ' + _chalk.default.yellow(currentWordPressTag) + ' to:');
|
|
678
|
-
|
|
679
|
-
// Select a new image
|
|
680
|
-
const choice = await (0, _devEnvironmentCli.promptForWordPress)(newestWordPressImage?.tag ?? null);
|
|
681
|
-
const version = versions.find(({
|
|
682
|
-
tag
|
|
683
|
-
}) => tag.trim() === choice.tag.trim());
|
|
684
|
-
|
|
685
|
-
// Write new data and stage for rebuild
|
|
686
|
-
// FIXME: version?.tag is possibly null. Should we throw if we can't find a version somehow?
|
|
687
|
-
envData.wordpress.tag = version?.tag ?? '';
|
|
688
|
-
envData.wordpress.ref = version?.ref;
|
|
689
|
-
await updateEnvironment(lando, envData);
|
|
690
|
-
return true;
|
|
691
|
-
}
|
|
692
|
-
if (confirm.upgrade === "no (don't ask anymore)") {
|
|
693
|
-
const updateCommand = `vip dev-env update --slug=${slug}`;
|
|
694
|
-
envData.wordpress.doNotUpgrade = true;
|
|
695
|
-
console.log("We won't ask about upgrading this environment anymore.");
|
|
696
|
-
console.log(`To manually upgrade please run: ${_chalk.default.yellow(updateCommand)}`);
|
|
697
|
-
await updateEnvironment(lando, envData);
|
|
698
|
-
}
|
|
699
|
-
return false;
|
|
700
681
|
}
|
|
701
682
|
async function maybeUpdateVersion(lando, slug) {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
683
|
+
const envData = readEnvironmentData(slug);
|
|
684
|
+
const currentVersion = envData.version;
|
|
685
|
+
console.log('Current local environment version is: ' + chalk_1.default.yellow(currentVersion));
|
|
686
|
+
if (!currentVersion || semver_1.default.lt(currentVersion, dev_environment_1.DEV_ENVIRONMENT_VERSION)) {
|
|
687
|
+
envData.pullAfter = undefined;
|
|
688
|
+
await updateEnvironment(lando, envData);
|
|
689
|
+
console.log('Local environment version updated to: ' + chalk_1.default.green(dev_environment_1.DEV_ENVIRONMENT_VERSION));
|
|
690
|
+
return true;
|
|
691
|
+
}
|
|
692
|
+
return false;
|
|
712
693
|
}
|
|
713
|
-
|
|
714
694
|
/**
|
|
715
695
|
* Makes a web call to raw.githubusercontent.com
|
|
716
696
|
*/
|
|
717
697
|
function fetchVersionList() {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
dispatcher: proxyDispatcher ?? undefined
|
|
722
|
-
}).then(res => res.json());
|
|
698
|
+
const url = `https://${dev_environment_1.DEV_ENVIRONMENT_RAW_GITHUB_HOST}${dev_environment_1.DEV_ENVIRONMENT_WORDPRESS_VERSIONS_URI}`;
|
|
699
|
+
const proxyDispatcher = (0, proxy_dispatcher_1.createProxyDispatcher)(url);
|
|
700
|
+
return (0, undici_1.fetch)(url, { dispatcher: proxyDispatcher ?? undefined }).then(res => res.json());
|
|
723
701
|
}
|
|
724
|
-
|
|
725
702
|
/**
|
|
726
703
|
* Encapsulates the logic for determining if a file is expired by an arbitrary TTL
|
|
727
704
|
*
|
|
@@ -730,62 +707,59 @@ function fetchVersionList() {
|
|
|
730
707
|
* @return {Promise<boolean>} version list expired true/false
|
|
731
708
|
*/
|
|
732
709
|
async function isVersionListExpired(cacheFile, ttl) {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
}
|
|
710
|
+
try {
|
|
711
|
+
const { mtime: expire } = await node_fs_1.default.promises.stat(cacheFile);
|
|
712
|
+
expire.setSeconds(expire.getSeconds() + ttl);
|
|
713
|
+
return Number(new Date()) > Number(expire);
|
|
714
|
+
}
|
|
715
|
+
catch (error) {
|
|
716
|
+
debug(`Error checking version list expiration for cache file ${cacheFile}:`, error);
|
|
717
|
+
return true;
|
|
718
|
+
}
|
|
743
719
|
}
|
|
744
|
-
|
|
745
720
|
/**
|
|
746
721
|
* Uses a cache file to keep the version list in tow until it is ultimately outdated
|
|
747
722
|
*/
|
|
748
723
|
async function getVersionList() {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
724
|
+
let res;
|
|
725
|
+
const mainEnvironmentPath = (0, xdg_data_1.xdgData)();
|
|
726
|
+
const cacheFilePath = node_path_1.default.join(mainEnvironmentPath, 'vip');
|
|
727
|
+
const cacheFile = node_path_1.default.join(cacheFilePath, dev_environment_1.DEV_ENVIRONMENT_WORDPRESS_CACHE_KEY);
|
|
728
|
+
// Handle from cache
|
|
729
|
+
try {
|
|
730
|
+
// If the path for the cache file doesn't exist, create it
|
|
731
|
+
if (!node_fs_1.default.existsSync(cacheFilePath)) {
|
|
732
|
+
await node_fs_1.default.promises.mkdir(cacheFilePath, { recursive: true });
|
|
733
|
+
}
|
|
734
|
+
// If the cache does not exist or has expired, refresh it
|
|
735
|
+
if (await isVersionListExpired(cacheFile, dev_environment_1.DEV_ENVIRONMENT_WORDPRESS_VERSION_TTL)) {
|
|
736
|
+
res = await fetchVersionList();
|
|
737
|
+
await node_fs_1.default.promises.writeFile(cacheFile, JSON.stringify(res));
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
catch (err) {
|
|
741
|
+
// Soft error handling here, since it's still possible to use a previously cached file.
|
|
742
|
+
console.log(chalk_1.default.yellow('fetchWordPressVersionList failed to retrieve an updated version list'));
|
|
743
|
+
debug(err);
|
|
744
|
+
}
|
|
745
|
+
// Try to parse the cached file if it exists.
|
|
746
|
+
try {
|
|
747
|
+
const data = await node_fs_1.default.promises.readFile(cacheFile, 'utf8');
|
|
748
|
+
return JSON.parse(data);
|
|
749
|
+
}
|
|
750
|
+
catch (err) {
|
|
751
|
+
debug(err);
|
|
752
|
+
return [
|
|
753
|
+
{
|
|
754
|
+
ref: 'HEAD',
|
|
755
|
+
tag: 'trunk',
|
|
756
|
+
cacheable: false,
|
|
757
|
+
locked: false,
|
|
758
|
+
prerelease: true,
|
|
759
|
+
},
|
|
760
|
+
];
|
|
761
|
+
}
|
|
787
762
|
}
|
|
788
|
-
|
|
789
763
|
/**
|
|
790
764
|
* Functions generates workspace config including the launch config
|
|
791
765
|
*
|
|
@@ -793,73 +767,64 @@ async function getVersionList() {
|
|
|
793
767
|
* @return {string} Workspace path
|
|
794
768
|
*/
|
|
795
769
|
function generateVSCodeWorkspace(slug) {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
folders,
|
|
832
|
-
launch: {
|
|
833
|
-
version: '0.2.0',
|
|
834
|
-
configurations: [debugConfig]
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
_nodeFs.default.writeFileSync(workspacePath, JSON.stringify(workspace, null, 2));
|
|
838
|
-
return workspacePath;
|
|
770
|
+
debug('Generating VS Code Workspace');
|
|
771
|
+
const location = getEnvironmentPath(slug);
|
|
772
|
+
const workspacePath = getVSCodeWorkspacePath(slug);
|
|
773
|
+
const instanceData = readEnvironmentData(slug);
|
|
774
|
+
const pathMappings = generatePathMappings(location, instanceData);
|
|
775
|
+
const folders = [{ path: location }];
|
|
776
|
+
if (instanceData.muPlugins.dir) {
|
|
777
|
+
folders.push({ path: instanceData.muPlugins.dir });
|
|
778
|
+
}
|
|
779
|
+
if (instanceData.appCode.dir) {
|
|
780
|
+
folders.push({ path: instanceData.appCode.dir });
|
|
781
|
+
}
|
|
782
|
+
// Create debug configuration
|
|
783
|
+
const debugConfig = {
|
|
784
|
+
name: `Debug ${slug}`,
|
|
785
|
+
type: 'php',
|
|
786
|
+
request: 'launch',
|
|
787
|
+
port: 9003,
|
|
788
|
+
pathMappings,
|
|
789
|
+
};
|
|
790
|
+
// Check if running under WSL and add hostname if needed
|
|
791
|
+
// This is to allow xdebug to work when running under WSL
|
|
792
|
+
if (process.env?.WSL_DISTRO_NAME) {
|
|
793
|
+
debug('WSL detected, adding hostname to debug configuration');
|
|
794
|
+
debugConfig.hostname = '0.0.0.0';
|
|
795
|
+
}
|
|
796
|
+
const workspace = {
|
|
797
|
+
folders,
|
|
798
|
+
launch: {
|
|
799
|
+
version: '0.2.0',
|
|
800
|
+
configurations: [debugConfig],
|
|
801
|
+
},
|
|
802
|
+
};
|
|
803
|
+
node_fs_1.default.writeFileSync(workspacePath, JSON.stringify(workspace, null, 2));
|
|
804
|
+
return workspacePath;
|
|
839
805
|
}
|
|
840
806
|
const generatePathMappings = (location, instanceData) => {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
807
|
+
const pathMappings = {};
|
|
808
|
+
if (instanceData.muPlugins.dir) {
|
|
809
|
+
pathMappings['/wp/wp-content/mu-plugins'] = instanceData.muPlugins.dir;
|
|
810
|
+
}
|
|
811
|
+
if (instanceData.appCode.dir) {
|
|
812
|
+
pathMappings['/wp/wp-content/client-mu-plugins'] = node_path_1.default.resolve(instanceData.appCode.dir, 'client-mu-plugins');
|
|
813
|
+
pathMappings['/wp/wp-content/images'] = node_path_1.default.resolve(instanceData.appCode.dir, 'images');
|
|
814
|
+
pathMappings['/wp/wp-content/languages'] = node_path_1.default.resolve(instanceData.appCode.dir, 'languages');
|
|
815
|
+
pathMappings['/wp/wp-content/plugins'] = node_path_1.default.resolve(instanceData.appCode.dir, 'plugins');
|
|
816
|
+
pathMappings['/wp/wp-content/private'] = node_path_1.default.resolve(instanceData.appCode.dir, 'private');
|
|
817
|
+
pathMappings['/wp/wp-content/themes'] = node_path_1.default.resolve(instanceData.appCode.dir, 'themes');
|
|
818
|
+
pathMappings['/wp/vip-config'] = node_path_1.default.resolve(instanceData.appCode.dir, 'vip-config');
|
|
819
|
+
}
|
|
820
|
+
pathMappings['/wp'] = node_path_1.default.resolve(location, 'wordpress');
|
|
821
|
+
return pathMappings;
|
|
856
822
|
};
|
|
857
823
|
function getVSCodeWorkspacePath(slug) {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
824
|
+
const location = getEnvironmentPath(slug);
|
|
825
|
+
const workspacePath = node_path_1.default.join(location, `${slug}.code-workspace`);
|
|
826
|
+
return workspacePath;
|
|
861
827
|
}
|
|
862
|
-
|
|
863
828
|
/**
|
|
864
829
|
* Generates PHPStorm project configuration including debug settings
|
|
865
830
|
*
|
|
@@ -867,18 +832,14 @@ function getVSCodeWorkspacePath(slug) {
|
|
|
867
832
|
* @return {string} Project directory path
|
|
868
833
|
*/
|
|
869
834
|
function generatePHPStormWorkspace(slug) {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
});
|
|
879
|
-
|
|
880
|
-
// Generate workspace.xml
|
|
881
|
-
const workspaceXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
835
|
+
debug('Generating PHPStorm Workspace');
|
|
836
|
+
const location = getEnvironmentPath(slug);
|
|
837
|
+
const instanceData = readEnvironmentData(slug);
|
|
838
|
+
const pathMappings = generatePathMappings(location, instanceData);
|
|
839
|
+
// Create .idea directory
|
|
840
|
+
node_fs_1.default.mkdirSync(node_path_1.default.join(location, '.idea', 'runConfigurations'), { recursive: true });
|
|
841
|
+
// Generate workspace.xml
|
|
842
|
+
const workspaceXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
882
843
|
<project version="4">
|
|
883
844
|
<component name="PhpWorkspaceProjectConfiguration">
|
|
884
845
|
<include_path>
|
|
@@ -893,15 +854,19 @@ ${instanceData?.appCode?.dir ? `<path value="${instanceData.appCode.dir}" />` :
|
|
|
893
854
|
<server host="localhost" port="9003" />
|
|
894
855
|
</debug_server_list>
|
|
895
856
|
<path_mappings>
|
|
896
|
-
${Object.entries(pathMappings)
|
|
857
|
+
${Object.entries(pathMappings)
|
|
858
|
+
.map(([serverPath, localPath]) => ` <mapping local-root="${serverPath}" remote-root="$PROJECT_DIR$/${node_path_1.default.relative(location, localPath)}" />`)
|
|
859
|
+
.join('\n')}
|
|
897
860
|
</path_mappings>
|
|
898
861
|
</component>
|
|
899
862
|
<component name="PhpServers">
|
|
900
863
|
<servers>
|
|
901
|
-
<server host="localhost" id="${(0,
|
|
864
|
+
<server host="localhost" id="${(0, node_crypto_1.randomUUID)()}" name="localhost" use_path_mappings="true">
|
|
902
865
|
<path_mappings>
|
|
903
866
|
<mapping local-root="$PROJECT_DIR$/wordpress" remote-root="/wp" />
|
|
904
|
-
${Object.entries(pathMappings)
|
|
867
|
+
${Object.entries(pathMappings)
|
|
868
|
+
.map(([serverPath, localPath]) => `<mapping local-root="${localPath}" remote-root="${serverPath}" />`)
|
|
869
|
+
.join('\n')}
|
|
905
870
|
</path_mappings>
|
|
906
871
|
</server>
|
|
907
872
|
</servers>
|
|
@@ -910,15 +875,15 @@ ${Object.entries(pathMappings).map(([serverPath, localPath]) => ` <mapping
|
|
|
910
875
|
<wordpressPath>$PROJECT_DIR$/wordpress</wordpressPath>
|
|
911
876
|
</component>
|
|
912
877
|
</project>`;
|
|
913
|
-
|
|
914
|
-
|
|
878
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(location, '.idea', 'workspace.xml'), workspaceXml);
|
|
879
|
+
const xdebugXml = `<component name="ProjectRunConfigurationManager">
|
|
915
880
|
<configuration default="false" name="VIP Debug" type="PhpRemoteDebugRunConfigurationType" factoryName="PHP Remote Debug" nameIsGenerated="true" filter_connections="NOT_FILTER" server_name="localhost" session_id="XDEBUG">
|
|
916
881
|
<method v="2" />
|
|
917
882
|
</configuration>
|
|
918
883
|
</component>
|
|
919
884
|
`;
|
|
920
|
-
|
|
921
|
-
|
|
885
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(location, '.idea', 'runConfigurations', 'vip-xdebug.xml'), xdebugXml);
|
|
886
|
+
const projectXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
922
887
|
<project version="4">
|
|
923
888
|
<component name="ProjectModuleManager">
|
|
924
889
|
<modules>
|
|
@@ -927,18 +892,18 @@ ${Object.entries(pathMappings).map(([serverPath, localPath]) => ` <mapping
|
|
|
927
892
|
</component>
|
|
928
893
|
</project>
|
|
929
894
|
`;
|
|
930
|
-
|
|
931
|
-
|
|
895
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(location, '.idea', 'modules.xml'), projectXml);
|
|
896
|
+
const modulesXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
932
897
|
<module type="WEB_MODULE" version="4">
|
|
933
898
|
<component name="NewModuleRootManager">
|
|
934
|
-
<content url="file://$MODULE_DIR$/${
|
|
935
|
-
<content url="file://$MODULE_DIR$/${
|
|
899
|
+
<content url="file://$MODULE_DIR$/${node_path_1.default.relative(location, instanceData?.appCode?.dir ?? '')}" />
|
|
900
|
+
<content url="file://$MODULE_DIR$/${node_path_1.default.relative(location, instanceData?.muPlugins?.dir ?? '')}" />
|
|
936
901
|
<content url="file://$MODULE_DIR$" />
|
|
937
902
|
<orderEntry type="sourceFolder" forTests="false" />
|
|
938
903
|
<orderEntry type="inheritedJdk" />
|
|
939
904
|
</component>
|
|
940
905
|
</module>
|
|
941
906
|
`;
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
}
|
|
907
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(location, '.idea', slug + '.iml'), modulesXml);
|
|
908
|
+
return location;
|
|
909
|
+
}
|