@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.
Files changed (311) hide show
  1. package/assets/dev-env.lando.template.yml.ejs +1 -1
  2. package/dist/bin/vip-app-deploy-token-generate.js +110 -78
  3. package/dist/bin/vip-app-deploy-token.js +24 -16
  4. package/dist/bin/vip-app-deploy-validate.js +45 -41
  5. package/dist/bin/vip-app-deploy.js +222 -215
  6. package/dist/bin/vip-app-list.js +59 -43
  7. package/dist/bin/vip-app.js +97 -66
  8. package/dist/bin/vip-backup-db.js +36 -29
  9. package/dist/bin/vip-backup.js +16 -9
  10. package/dist/bin/vip-cache-purge-url.js +93 -55
  11. package/dist/bin/vip-cache.js +23 -14
  12. package/dist/bin/vip-config-envvar-delete.js +74 -73
  13. package/dist/bin/vip-config-envvar-get-all.js +68 -68
  14. package/dist/bin/vip-config-envvar-get.js +46 -46
  15. package/dist/bin/vip-config-envvar-list.js +54 -57
  16. package/dist/bin/vip-config-envvar-set.js +102 -96
  17. package/dist/bin/vip-config-envvar.js +38 -24
  18. package/dist/bin/vip-config-software-get.js +88 -75
  19. package/dist/bin/vip-config-software-update.js +116 -120
  20. package/dist/bin/vip-config-software.js +31 -21
  21. package/dist/bin/vip-config.js +25 -17
  22. package/dist/bin/vip-db-phpmyadmin.js +40 -39
  23. package/dist/bin/vip-db.js +13 -12
  24. package/dist/bin/vip-defensive-mode-configure.js +197 -197
  25. package/dist/bin/vip-defensive-mode-disable.js +43 -35
  26. package/dist/bin/vip-defensive-mode-enable.js +47 -38
  27. package/dist/bin/vip-defensive-mode.js +28 -17
  28. package/dist/bin/vip-dev-env-create.js +147 -104
  29. package/dist/bin/vip-dev-env-destroy.js +48 -39
  30. package/dist/bin/vip-dev-env-envvar-delete.js +60 -49
  31. package/dist/bin/vip-dev-env-envvar-get-all.js +52 -45
  32. package/dist/bin/vip-dev-env-envvar-get.js +48 -37
  33. package/dist/bin/vip-dev-env-envvar-list.js +48 -41
  34. package/dist/bin/vip-dev-env-envvar-set.js +83 -70
  35. package/dist/bin/vip-dev-env-envvar.js +38 -23
  36. package/dist/bin/vip-dev-env-exec.js +81 -74
  37. package/dist/bin/vip-dev-env-import-media.js +34 -26
  38. package/dist/bin/vip-dev-env-import-sql.js +65 -51
  39. package/dist/bin/vip-dev-env-import.js +23 -14
  40. package/dist/bin/vip-dev-env-info.js +59 -50
  41. package/dist/bin/vip-dev-env-list.js +34 -31
  42. package/dist/bin/vip-dev-env-logs.js +59 -49
  43. package/dist/bin/vip-dev-env-purge.js +71 -63
  44. package/dist/bin/vip-dev-env-shell.js +82 -71
  45. package/dist/bin/vip-dev-env-start.js +77 -65
  46. package/dist/bin/vip-dev-env-stop.js +80 -74
  47. package/dist/bin/vip-dev-env-sync-sql.js +80 -72
  48. package/dist/bin/vip-dev-env-sync.js +18 -11
  49. package/dist/bin/vip-dev-env-update.js +93 -84
  50. package/dist/bin/vip-dev-env.js +25 -8
  51. package/dist/bin/vip-edge-workers-build.js +82 -54
  52. package/dist/bin/vip-edge-workers-delete.js +84 -52
  53. package/dist/bin/vip-edge-workers-deploy.js +186 -126
  54. package/dist/bin/vip-edge-workers-disable.js +75 -44
  55. package/dist/bin/vip-edge-workers-enable.js +86 -54
  56. package/dist/bin/vip-edge-workers-get.js +108 -88
  57. package/dist/bin/vip-edge-workers-init.js +83 -53
  58. package/dist/bin/vip-edge-workers-list.js +89 -54
  59. package/dist/bin/vip-edge-workers-new.js +98 -69
  60. package/dist/bin/vip-edge-workers-validate.js +123 -82
  61. package/dist/bin/vip-edge-workers.js +19 -6
  62. package/dist/bin/vip-export-sql.js +75 -69
  63. package/dist/bin/vip-export.js +12 -7
  64. package/dist/bin/vip-import-media-abort.js +99 -73
  65. package/dist/bin/vip-import-media-status.js +83 -51
  66. package/dist/bin/vip-import-media.js +165 -166
  67. package/dist/bin/vip-import-sql-status.js +75 -45
  68. package/dist/bin/vip-import-sql.js +536 -596
  69. package/dist/bin/vip-import-validate-files.js +122 -141
  70. package/dist/bin/vip-import-validate-sql.js +52 -16
  71. package/dist/bin/vip-import.js +16 -7
  72. package/dist/bin/vip-logout.js +17 -13
  73. package/dist/bin/vip-logs.js +209 -183
  74. package/dist/bin/vip-search-replace.js +85 -53
  75. package/dist/bin/vip-slowlogs.js +168 -147
  76. package/dist/bin/vip-sync.js +163 -133
  77. package/dist/bin/vip-whoami.js +71 -35
  78. package/dist/bin/vip-wp.js +506 -549
  79. package/dist/bin/vip.js +161 -116
  80. package/dist/commands/backup-db.js +183 -149
  81. package/dist/commands/dev-env-import-sql.js +162 -117
  82. package/dist/commands/dev-env-sync-sql.js +372 -330
  83. package/dist/commands/export-sql.js +441 -425
  84. package/dist/commands/phpmyadmin.js +232 -212
  85. package/dist/commands/wp-ssh.js +218 -187
  86. package/dist/lib/analytics/clients/tracks.js +84 -91
  87. package/dist/lib/analytics/index.js +27 -27
  88. package/dist/lib/api/app.js +37 -36
  89. package/dist/lib/api/cache-purge.js +17 -20
  90. package/dist/lib/api/constants.js +5 -6
  91. package/dist/lib/api/edge-workers.js +84 -135
  92. package/dist/lib/api/error-debug.js +10 -13
  93. package/dist/lib/api/feature-flags.js +16 -17
  94. package/dist/lib/api/http.js +47 -48
  95. package/dist/lib/api/user.js +17 -18
  96. package/dist/lib/api.js +107 -116
  97. package/dist/lib/app-logs/app-logs.js +24 -25
  98. package/dist/lib/app-slowlogs/app-slowlogs.js +23 -24
  99. package/dist/lib/app-slowlogs/types.js +2 -1
  100. package/dist/lib/app.js +6 -8
  101. package/dist/lib/backup-storage-availability/backup-storage-availability.js +119 -119
  102. package/dist/lib/backup-storage-availability/docker-machine-not-found-error.js +5 -6
  103. package/dist/lib/cli/apiConfig.js +71 -41
  104. package/dist/lib/cli/command.js +1120 -873
  105. package/dist/lib/cli/config.js +29 -29
  106. package/dist/lib/cli/envAlias.js +35 -50
  107. package/dist/lib/cli/exit.js +19 -19
  108. package/dist/lib/cli/format.js +172 -172
  109. package/dist/lib/cli/progress.js +193 -236
  110. package/dist/lib/cli/prompt.js +14 -15
  111. package/dist/lib/cli/runtime-mode.js +5 -6
  112. package/dist/lib/client-file-uploader.js +489 -641
  113. package/dist/lib/config/software.js +206 -212
  114. package/dist/lib/constants/dev-environment.js +40 -37
  115. package/dist/lib/constants/file-size.js +6 -7
  116. package/dist/lib/constants/vipgo.js +24 -12
  117. package/dist/lib/custom-deploy/custom-deploy.js +138 -120
  118. package/dist/lib/database.js +88 -85
  119. package/dist/lib/defensive-mode/api.js +41 -46
  120. package/dist/lib/defensive-mode/cli-helpers.js +40 -40
  121. package/dist/lib/dev-environment/dev-environment-cli.js +776 -735
  122. package/dist/lib/dev-environment/dev-environment-configuration-file.js +224 -191
  123. package/dist/lib/dev-environment/dev-environment-core.js +697 -732
  124. package/dist/lib/dev-environment/dev-environment-database.js +57 -41
  125. package/dist/lib/dev-environment/dev-environment-lando.js +734 -666
  126. package/dist/lib/dev-environment/docker-utils.js +96 -90
  127. package/dist/lib/dev-environment/env-vars.js +61 -59
  128. package/dist/lib/dev-environment/lando-loader.js +6 -7
  129. package/dist/lib/dev-environment/types.js +2 -1
  130. package/dist/lib/edge-workers/confirmation.js +42 -36
  131. package/dist/lib/edge-workers/deployment.js +150 -159
  132. package/dist/lib/edge-workers/index.js +68 -85
  133. package/dist/lib/edge-workers/location.js +26 -26
  134. package/dist/lib/edge-workers/output.js +14 -15
  135. package/dist/lib/edge-workers/project.js +123 -132
  136. package/dist/lib/edge-workers/toolchains/assemblyscript/constants.js +6 -8
  137. package/dist/lib/edge-workers/toolchains/assemblyscript/index.js +100 -101
  138. package/dist/lib/edge-workers/toolchains/assemblyscript/templates.js +31 -33
  139. package/dist/lib/edge-workers/toolchains/index.js +15 -15
  140. package/dist/lib/edge-workers/types.js +10 -38
  141. package/dist/lib/edge-workers/validation.js +161 -150
  142. package/dist/lib/env.js +16 -17
  143. package/dist/lib/envvar/api-delete.js +16 -18
  144. package/dist/lib/envvar/api-get-all.js +15 -19
  145. package/dist/lib/envvar/api-get.js +8 -9
  146. package/dist/lib/envvar/api-list.js +16 -21
  147. package/dist/lib/envvar/api-set.js +20 -19
  148. package/dist/lib/envvar/api.js +34 -29
  149. package/dist/lib/envvar/input.js +29 -34
  150. package/dist/lib/envvar/logging.js +9 -11
  151. package/dist/lib/envvar/read-file.js +6 -7
  152. package/dist/lib/http/download-file.js +76 -44
  153. package/dist/lib/http/proxy-agent.js +37 -40
  154. package/dist/lib/http/proxy-dispatcher.js +69 -71
  155. package/dist/lib/keychain/insecure.js +40 -36
  156. package/dist/lib/keychain/keychain.js +2 -1
  157. package/dist/lib/keychain/secure.js +16 -15
  158. package/dist/lib/keychain.js +22 -22
  159. package/dist/lib/live-backup-copy.js +117 -115
  160. package/dist/lib/logout.js +17 -19
  161. package/dist/lib/media-import/config.js +15 -14
  162. package/dist/lib/media-import/media-file-import.js +9 -13
  163. package/dist/lib/media-import/progress.js +53 -65
  164. package/dist/lib/media-import/status.js +241 -256
  165. package/dist/lib/media-import/utils.js +15 -15
  166. package/dist/lib/node-version-check.js +16 -16
  167. package/dist/lib/promise.js +16 -17
  168. package/dist/lib/read-file.js +48 -16
  169. package/dist/lib/rechallenge/client.js +37 -43
  170. package/dist/lib/rechallenge/errors.js +38 -37
  171. package/dist/lib/rechallenge/flow.js +148 -123
  172. package/dist/lib/rechallenge/index.js +23 -24
  173. package/dist/lib/rechallenge/link.js +153 -151
  174. package/dist/lib/rechallenge/open-browser.js +14 -17
  175. package/dist/lib/rechallenge/token-cache.js +83 -86
  176. package/dist/lib/rechallenge/types.js +5 -14
  177. package/dist/lib/retry.js +93 -129
  178. package/dist/lib/search-and-replace.js +164 -148
  179. package/dist/lib/site-import/db-file-import.js +12 -16
  180. package/dist/lib/site-import/status.js +291 -291
  181. package/dist/lib/token.js +86 -87
  182. package/dist/lib/tracker.js +51 -62
  183. package/dist/lib/types/graphql/rate-limit-exceeded-error.js +2 -1
  184. package/dist/lib/types.js +2 -1
  185. package/dist/lib/user-error.js +6 -8
  186. package/dist/lib/utils.js +81 -87
  187. package/dist/lib/validations/custom-deploy.js +218 -186
  188. package/dist/lib/validations/is-multi-site-sql-dump.js +6 -6
  189. package/dist/lib/validations/is-multi-site.js +83 -50
  190. package/dist/lib/validations/is-multisite-domain-mapped.js +92 -62
  191. package/dist/lib/validations/line-by-line.js +78 -46
  192. package/dist/lib/validations/site-type.js +59 -63
  193. package/dist/lib/validations/sql-insert-parser.js +415 -0
  194. package/dist/lib/validations/sql.js +551 -431
  195. package/dist/lib/validations/utils.js +27 -29
  196. package/dist/lib/vip-import-validate-files.js +481 -490
  197. package/dist/lib/wp/helpers.js +41 -45
  198. package/dist/lib/wp/readline.js +21 -57
  199. package/dist/lib/xdg-data.js +11 -12
  200. package/helpers/mark-cli-executable.js +9 -0
  201. package/node_modules/@apollo/client/CHANGELOG.md +10 -0
  202. package/node_modules/@apollo/client/__cjs/cache/inmemory/helpers.cjs +5 -0
  203. package/node_modules/@apollo/client/__cjs/cache/inmemory/helpers.cjs.map +1 -1
  204. package/node_modules/@apollo/client/__cjs/cache/inmemory/inMemoryCache.cjs +2 -1
  205. package/node_modules/@apollo/client/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  206. package/node_modules/@apollo/client/__cjs/cache/inmemory/key-extractor.cjs +14 -2
  207. package/node_modules/@apollo/client/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
  208. package/node_modules/@apollo/client/__cjs/cache/inmemory/policies.cjs +16 -0
  209. package/node_modules/@apollo/client/__cjs/cache/inmemory/policies.cjs.map +1 -1
  210. package/node_modules/@apollo/client/__cjs/cache/inmemory/policies.d.cts +2 -0
  211. package/node_modules/@apollo/client/__cjs/cache/inmemory/writeToStore.cjs +3 -2
  212. package/node_modules/@apollo/client/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  213. package/node_modules/@apollo/client/__cjs/core/QueryInfo.cjs +9 -1
  214. package/node_modules/@apollo/client/__cjs/core/QueryInfo.cjs.map +1 -1
  215. package/node_modules/@apollo/client/__cjs/core/QueryInfo.d.cts +1 -1
  216. package/node_modules/@apollo/client/__cjs/core/QueryManager.cjs +10 -3
  217. package/node_modules/@apollo/client/__cjs/core/QueryManager.cjs.map +1 -1
  218. package/node_modules/@apollo/client/__cjs/react/hooks/useFragment.cjs.map +1 -1
  219. package/node_modules/@apollo/client/__cjs/react/hooks/useFragment.d.cts +42 -43
  220. package/node_modules/@apollo/client/__cjs/version.cjs +1 -1
  221. package/node_modules/@apollo/client/cache/inmemory/helpers.js +5 -0
  222. package/node_modules/@apollo/client/cache/inmemory/helpers.js.map +1 -1
  223. package/node_modules/@apollo/client/cache/inmemory/inMemoryCache.js +2 -1
  224. package/node_modules/@apollo/client/cache/inmemory/inMemoryCache.js.map +1 -1
  225. package/node_modules/@apollo/client/cache/inmemory/key-extractor.js +14 -2
  226. package/node_modules/@apollo/client/cache/inmemory/key-extractor.js.map +1 -1
  227. package/node_modules/@apollo/client/cache/inmemory/policies.d.ts +2 -0
  228. package/node_modules/@apollo/client/cache/inmemory/policies.js +17 -1
  229. package/node_modules/@apollo/client/cache/inmemory/policies.js.map +1 -1
  230. package/node_modules/@apollo/client/cache/inmemory/writeToStore.js +3 -2
  231. package/node_modules/@apollo/client/cache/inmemory/writeToStore.js.map +1 -1
  232. package/node_modules/@apollo/client/core/QueryInfo.d.ts +1 -1
  233. package/node_modules/@apollo/client/core/QueryInfo.js +10 -2
  234. package/node_modules/@apollo/client/core/QueryInfo.js.map +1 -1
  235. package/node_modules/@apollo/client/core/QueryManager.js +10 -3
  236. package/node_modules/@apollo/client/core/QueryManager.js.map +1 -1
  237. package/node_modules/@apollo/client/package.json +1 -1
  238. package/node_modules/@apollo/client/react/hooks/useFragment.d.ts +42 -43
  239. package/node_modules/@apollo/client/react/hooks/useFragment.js.map +1 -1
  240. package/node_modules/@apollo/client/react/hooks-compiled/useFragment.d.ts +42 -43
  241. package/node_modules/@apollo/client/react/hooks-compiled/useFragment.js.map +1 -1
  242. package/node_modules/@apollo/client/version.js +1 -1
  243. package/node_modules/@automattic/vip-search-replace/README.md +6 -1
  244. package/node_modules/@automattic/vip-search-replace/lib/index.js +46 -14
  245. package/node_modules/@automattic/vip-search-replace/package.json +1 -1
  246. package/node_modules/@types/node/README.md +1 -1
  247. package/node_modules/@types/node/package.json +2 -2
  248. package/node_modules/@types/node/zlib.d.ts +752 -0
  249. package/node_modules/check-disk-space/README.md +92 -32
  250. package/node_modules/check-disk-space/dist/check-disk-space.d.mts +58 -0
  251. package/node_modules/check-disk-space/dist/check-disk-space.mjs +170 -190
  252. package/node_modules/check-disk-space/package.json +43 -71
  253. package/node_modules/cpu-features/build/Makefile +2 -2
  254. package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/filesystem.o.d +1 -1
  255. 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
  256. 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
  257. package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_aarch64_windows.o.d +1 -1
  258. 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
  259. 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
  260. package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_ppc_linux.o.d +1 -1
  261. package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_freebsd.o.d +1 -1
  262. 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
  263. package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_macos.o.d +1 -1
  264. package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_windows.o.d +1 -1
  265. package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/stack_line_reader.o.d +1 -1
  266. package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpu_features/deps/cpu_features/src/string_view.o.d +1 -1
  267. package/node_modules/cpu-features/build/Release/.deps/Release/obj.target/cpufeatures/src/binding.o.d +157 -145
  268. package/node_modules/cpu-features/build/Release/cpufeatures.node +0 -0
  269. package/node_modules/cpu-features/build/Release/obj.target/cpufeatures/src/binding.o +0 -0
  270. package/node_modules/cpu-features/build/Release/obj.target/cpufeatures.node +0 -0
  271. package/node_modules/cpu-features/build/config.gypi +100 -31
  272. package/node_modules/cpu-features/build/cpufeatures.target.mk +14 -14
  273. package/node_modules/cpu-features/build/deps/cpu_features/cpu_features.target.mk +14 -14
  274. package/node_modules/ssh2/lib/protocol/crypto/build/Makefile +2 -2
  275. package/node_modules/ssh2/lib/protocol/crypto/build/Release/.deps/Release/obj.target/sshcrypto/src/binding.o.d.raw +136 -0
  276. package/node_modules/ssh2/lib/protocol/crypto/build/sshcrypto.target.mk +14 -14
  277. package/node_modules/undici/docs/docs/api/Interceptors.md +15 -2
  278. package/node_modules/undici/lib/dispatcher/client-h2.js +78 -3
  279. package/node_modules/undici/lib/dispatcher/pool-base.js +20 -3
  280. package/node_modules/undici/package.json +3 -3
  281. package/node_modules/undici/types/api.d.ts +1 -1
  282. package/node_modules/undici/types/utility.d.ts +4 -4
  283. package/package.json +44 -13
  284. package/dist/lib/analytics/clients/client.js +0 -1
  285. package/dist/lib/analytics/clients/pendo.js +0 -78
  286. package/helpers/check-version.js +0 -16
  287. package/node_modules/check-disk-space/dist/check-disk-space.cjs +0 -210
  288. package/node_modules/check-disk-space/dist/check-disk-space.d.ts +0 -53
  289. package/node_modules/fetch-retry/.eslintignore +0 -1
  290. package/node_modules/fetch-retry/.eslintrc.yml +0 -20
  291. package/node_modules/fetch-retry/.github/workflows/node.js.yml +0 -32
  292. package/node_modules/fetch-retry/.husky/pre-commit +0 -6
  293. package/node_modules/fetch-retry/.nycrc.json +0 -24
  294. package/node_modules/fetch-retry/.travis.yml +0 -3
  295. package/node_modules/fetch-retry/LICENSE +0 -21
  296. package/node_modules/fetch-retry/README.md +0 -128
  297. package/node_modules/fetch-retry/dist/fetch-retry.umd.js +0 -151
  298. package/node_modules/fetch-retry/index.d.ts +0 -29
  299. package/node_modules/fetch-retry/index.js +0 -143
  300. package/node_modules/fetch-retry/package.json +0 -41
  301. package/node_modules/fetch-retry/rollup.config.js +0 -12
  302. package/node_modules/fetch-retry/test/.eslintrc.yml +0 -7
  303. package/node_modules/fetch-retry/test/integration/index.js +0 -212
  304. package/node_modules/fetch-retry/test/integration/mock-api/index.js +0 -42
  305. package/node_modules/fetch-retry/test/unit/index.js +0 -1169
  306. package/node_modules/ssh2/lib/protocol/crypto/build/Release/.deps/Release/obj.target/sshcrypto/src/binding.o.d +0 -265
  307. package/node_modules/ssh2/lib/protocol/crypto/build/Release/.deps/Release/obj.target/sshcrypto.node.d +0 -1
  308. package/node_modules/ssh2/lib/protocol/crypto/build/Release/.deps/Release/sshcrypto.node.d +0 -1
  309. package/node_modules/ssh2/lib/protocol/crypto/build/Release/obj.target/sshcrypto/src/binding.o +0 -0
  310. package/node_modules/ssh2/lib/protocol/crypto/build/Release/obj.target/sshcrypto.node +0 -0
  311. package/node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node +0 -0
@@ -1,53 +1,54 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
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
- var _chalk = _interopRequireDefault(require("chalk"));
27
- var _debug = _interopRequireDefault(require("debug"));
28
- var _ejs = _interopRequireDefault(require("ejs"));
29
- var _enquirer = require("enquirer");
30
- var _graphql = require("graphql");
31
- var _nodeCrypto = require("node:crypto");
32
- var _nodeFs = _interopRequireDefault(require("node:fs"));
33
- var _promises = require("node:fs/promises");
34
- var _nodePath = _interopRequireDefault(require("node:path"));
35
- var _semver = _interopRequireDefault(require("semver"));
36
- var _undici = require("undici");
37
- var _devEnvironmentCli = require("./dev-environment-cli");
38
- var _devEnvironmentLando = require("./dev-environment-lando");
39
- var _landoLoader = require("./lando-loader");
40
- var _app = _interopRequireDefault(require("../api/app"));
41
- var _software = require("../config/software");
42
- var _devEnvironment = require("../constants/dev-environment");
43
- var _proxyDispatcher = require("../http/proxy-dispatcher");
44
- var _searchAndReplace = require("../search-and-replace");
45
- var _userError = _interopRequireDefault(require("../user-error"));
46
- var _xdgData = require("../xdg-data");
47
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
48
- const debug = (0, _debug.default)('@automattic/vip:bin:dev-environment');
49
- const landoFileTemplatePath = _nodePath.default.join(__dirname, '..', '..', '..', 'assets', 'dev-env.lando.template.yml.ejs');
50
- const nginxFileTemplatePath = _nodePath.default.join(__dirname, '..', '..', '..', 'assets', 'dev-env.nginx.template.conf.ejs');
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
- if (!dockerComposifyFromLando) {
66
- const landoUtils = (0, _landoLoader.loadLandoModule)('lando/lib/utils');
67
- dockerComposifyFromLando = landoUtils.dockerComposify;
68
- }
69
- return dockerComposifyFromLando(value);
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) => _ejs.default.renderFile(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
- return pollEnvironmentUpStatus(lando, instancePath, 1);
75
+ return pollEnvironmentUpStatus(lando, instancePath, 1);
75
76
  }
76
77
  async function pollEnvironmentUpStatus(lando, instancePath, attempt) {
77
- if (await (0, _devEnvironmentLando.isEnvUp)(lando, instancePath)) {
78
- return true;
79
- }
80
- if (attempt >= STARTUP_READY_ATTEMPTS) {
81
- return false;
82
- }
83
- await sleep(STARTUP_READY_DELAY_MS);
84
- return pollEnvironmentUpStatus(lando, instancePath, attempt + 1);
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
- debug('Will start an environment', slug);
88
- const instancePath = getEnvironmentPath(slug);
89
- debug('Instance path for %s is %s', slug, instancePath);
90
- const environmentExists = _nodeFs.default.existsSync(instancePath);
91
- if (!environmentExists) {
92
- throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
93
- }
94
- const envFilePath = _nodePath.default.join(instancePath, '.env');
95
- _nodeFs.default.appendFileSync(envFilePath, '');
96
- let updated = false;
97
- if (!options.skipWpVersionsCheck && process.stdin.isTTY) {
98
- updated = await maybeUpdateWordPressImage(lando, slug);
99
- }
100
- updated = updated || (await maybeUpdateVersion(lando, slug));
101
- const proxyContainer = await (0, _devEnvironmentLando.getProxyContainer)(lando);
102
- if (!proxyContainer?.State.Running) {
103
- await (0, _devEnvironmentLando.removeProxyCache)(lando);
104
- }
105
- if (options.skipRebuild && !updated) {
106
- await (0, _devEnvironmentLando.landoStart)(lando, instancePath);
107
- } else {
108
- await (0, _devEnvironmentLando.landoRebuild)(lando, instancePath);
109
- }
110
- let isEnvironmentUp = await waitForEnvironmentToBeUp(lando, instancePath);
111
- if (!isEnvironmentUp) {
112
- // A second startup pass helps recover after Docker network auto-cleanup edge cases.
113
- await (0, _devEnvironmentLando.landoStart)(lando, instancePath);
114
- isEnvironmentUp = await waitForEnvironmentToBeUp(lando, instancePath);
115
- }
116
- if (!isEnvironmentUp) {
117
- throw new _userError.default(`Environment "${slug}" did not reach a running state. Please try "${_chalk.default.bold(`vip dev-env start --slug ${slug}`)}" again.`);
118
- }
119
- await printEnvironmentInfo(lando, slug, {
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
- debug('Will stop an environment', slug);
125
- const instancePath = getEnvironmentPath(slug);
126
- debug('Instance path for', slug, 'is:', instancePath);
127
- const environmentExists = _nodeFs.default.existsSync(instancePath);
128
- if (!environmentExists) {
129
- throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
130
- }
131
- await (0, _devEnvironmentLando.landoStop)(lando, instancePath);
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
- 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 = _nodeFs.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);
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
- 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 = _nodeFs.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);
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
- const newInstanceData = {
162
- ...instanceData,
163
- xdebugConfig: instanceData.xdebugConfig ?? '',
164
- mariadb: instanceData.mariadb ?? '',
165
- elasticsearch: instanceData.elasticsearch || false,
166
- // NOSONAR
167
- php: instanceData.php ?? _devEnvironment.DEV_ENVIRONMENT_PHP_VERSIONS[_devEnvironment.DEV_ENVIRONMENT_DEFAULT_PHP_VERSION].image,
168
- xdebug: Boolean(instanceData.xdebug),
169
- phpmyadmin: Boolean(instanceData.phpmyadmin),
170
- photon: Boolean(instanceData.photon),
171
- cron: Boolean(instanceData.cron),
172
- mailpit: Boolean(instanceData.mailpit),
173
- pullAfter: instanceData.pullAfter ?? 0,
174
- autologinKey: (0, _nodeCrypto.randomUUID)(),
175
- adminPassword: instanceData.adminPassword ?? 'password',
176
- version: _devEnvironment.DEV_ENVIRONMENT_VERSION,
177
- overrides: instanceData.overrides ?? ''
178
- };
179
- if (instanceData.mediaRedirectDomain && !/^https?:/.test(instanceData.mediaRedirectDomain)) {
180
- // We need to make sure the redirect is an absolute path
181
- newInstanceData.mediaRedirectDomain = `https://${instanceData.mediaRedirectDomain}`;
182
- }
183
- if (isNaN(instanceData.wordpress.tag)) {
184
- newInstanceData.wordpress.tag = 'trunk';
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
- debug('Will destroy an environment', slug);
190
- const instancePath = getEnvironmentPath(slug);
191
- debug('Instance path for', slug, 'is:', instancePath);
192
- const environmentExists = await doesEnvironmentExist(instancePath);
193
- if (!environmentExists) {
194
- throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
195
- }
196
- const landoFilePath = _nodePath.default.join(instancePath, landoFileName);
197
- if (_nodeFs.default.existsSync(landoFilePath)) {
198
- debug('Lando file exists, will lando destroy.');
199
- await (0, _devEnvironmentLando.landoDestroy)(lando, instancePath);
200
- } else {
201
- debug("Lando file doesn't exist, skipping lando destroy.");
202
- }
203
- await _nodeFs.default.promises.rm(_nodePath.default.join((0, _xdgData.xdgData)(), 'vip', 'lando', 'compose', dockerComposify(slug)), {
204
- force: true,
205
- recursive: true
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
- console.log(`${_chalk.default.green('✓')} Environment files deleted successfully.`);
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
- const allEnvNames = getAllEnvironmentNames();
216
- debug('Will print info for all environments. Names found: ', allEnvNames);
217
- console.log('Found ' + _chalk.default.bold(allEnvNames.length) + ' environments' + (allEnvNames.length ? ':' : '.'));
218
- for (const envName of allEnvNames) {
219
- try {
220
- console.log('\n');
221
- // eslint-disable-next-line no-await-in-loop
222
- await printEnvironmentInfo(lando, envName, options);
223
- } catch (error) {
224
- if (error instanceof _userError.default) {
225
- console.warn('\nWARNING: "%s" is not a valid environment\n', envName);
226
- } else {
227
- throw error;
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
- if (component.mode === 'local') {
234
- return component.dir ?? '';
235
- }
236
-
237
- // Environments created by the old code will have `component.tag` set to `demo` instead of `undefined`.
238
- if (component.tag === 'demo' || component.tag === 'latest') {
239
- component.tag = undefined;
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
- debug('Will display logs command on env', slug, 'with options', options);
245
- const instancePath = getEnvironmentPath(slug);
246
- debug('Instance path for %s is %s', slug, instancePath);
247
- if (options.service) {
248
- const application = await (0, _devEnvironmentLando.getLandoApplication)(lando, instancePath);
249
- const services = application.info.map(service => service.service);
250
- if (!services.includes(options.service)) {
251
- throw new _userError.default(`Service '${options.service}' not found. Please choose from: ${services.join(', ')}`);
252
- }
253
- }
254
- return (0, _devEnvironmentLando.landoLogs)(lando, instancePath, options);
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
- debug('Will get info for an environment', slug);
258
- const instancePath = getEnvironmentPath(slug);
259
- debug('Instance path for', slug, 'is:', instancePath);
260
- const environmentExists = await doesEnvironmentExist(instancePath);
261
- if (!environmentExists) {
262
- throw new _userError.default(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
263
- }
264
- const environmentData = readEnvironmentData(slug);
265
- const appInfo = await (0, _devEnvironmentLando.landoInfo)(lando, instancePath, {
266
- suppressWarnings: Boolean(options.suppressWarnings),
267
- autologinKey: environmentData.autologinKey
268
- });
269
- if (options.extended) {
270
- appInfo.title = environmentData.wpTitle;
271
- appInfo.multisite = Boolean(environmentData.multisite);
272
- appInfo.php = environmentData.php.split(':')[1];
273
- let xdebug = environmentData.xdebug ? 'enabled' : 'disabled';
274
- if (environmentData.xdebug && environmentData.xdebugConfig) {
275
- xdebug += ' (with additional configuration)';
276
- }
277
- appInfo.xdebug = xdebug;
278
- appInfo.cron = environmentData.cron ? 'enabled' : 'disabled';
279
- appInfo.wordpress = parseComponentForInfo(environmentData.wordpress);
280
- appInfo['Mu plugins'] = parseComponentForInfo(environmentData.muPlugins);
281
- appInfo['App Code'] = parseComponentForInfo(environmentData.appCode);
282
- if (environmentData.mediaRedirectDomain) {
283
- appInfo['Media Redirect'] = environmentData.mediaRedirectDomain;
284
- }
285
- }
286
- (0, _devEnvironmentCli.printTable)(appInfo);
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
- debug('Will run a wp command on env', slug, 'with args', args, ' and options', options);
290
- const instancePath = getEnvironmentPath(slug);
291
- debug('Instance path for', slug, 'is:', instancePath);
292
- const [command, ...commandArgs] = args;
293
- return (0, _devEnvironmentLando.landoExec)(lando, instancePath, command, commandArgs, options);
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
- debug('Will check for environment at %s', instancePath);
297
- const file = _nodePath.default.join(instancePath, instanceDataFileName);
298
- try {
299
- const stats = await _nodeFs.default.promises.stat(file);
300
- return stats.isFile();
301
- } catch {
302
- return false;
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
- debug('Will try to get instance data for environment', slug);
307
- const instancePath = getEnvironmentPath(slug);
308
- const instanceDataTargetPath = _nodePath.default.join(instancePath, instanceDataFileName);
309
- let instanceDataString;
310
- let instanceData;
311
- try {
312
- instanceDataString = _nodeFs.default.readFileSync(instanceDataTargetPath, 'utf8');
313
- } catch (error) {
314
- const err = error;
315
- throw new _userError.default(`There was an error reading file "${instanceDataTargetPath}": ${err.message}.`, {
316
- cause: error
317
- });
318
- }
319
- try {
320
- instanceData = JSON.parse(instanceDataString);
321
- } catch (error) {
322
- const err = error;
323
- throw new _userError.default(`There was an error parsing file "${instanceDataTargetPath}": ${err.message}. You may need to recreate the environment.`, {
324
- cause: error
325
- });
326
- }
327
-
328
- /**
329
- ***********************************
330
- * BACKWARDS COMPATIBILITY SECTION
331
- **********************************
332
- */
333
-
334
- // REMOVEME after the wheel of time spins around few times
335
- if (instanceData.enterpriseSearchEnabled || instanceData.elasticsearchEnabled) {
336
- // enterpriseSearchEnabled and elasticsearchEnabled was renamed to elasticsearch
337
- instanceData.elasticsearch = instanceData.enterpriseSearchEnabled || instanceData.elasticsearchEnabled;
338
- }
339
-
340
- // REMOVEME after the wheel of time spins around few times
341
- if (instanceData.clientCode) {
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
- debug('Will try to write instance data for environment', slug);
357
- const instancePath = getEnvironmentPath(slug);
358
- const instanceDataTargetPath = _nodePath.default.join(instancePath, instanceDataFileName);
359
- return _nodeFs.default.promises.writeFile(instanceDataTargetPath, JSON.stringify(data, null, 2));
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
- const integrationsConfigPath = _nodePath.default.join(instancePath, integrationsConfigPathString);
363
- const integrationsConfigTargetPath = _nodePath.default.join(integrationsConfigPath, integrationsConfigFileName);
364
- await _nodeFs.default.promises.mkdir(integrationsConfigPath, {
365
- recursive: true
366
- });
367
- if (integrationsConfig !== undefined) {
368
- const integrationsConfigBackupTargetPath = _nodePath.default.join(integrationsConfigPath, integrationsConfigBackupFileName);
369
- try {
370
- await _nodeFs.default.promises.rename(integrationsConfigTargetPath, integrationsConfigBackupTargetPath);
371
- console.log(`Backup of ${integrationsConfigFileName} was created in ${integrationsConfigBackupTargetPath}`);
372
- } catch (err) {
373
- if ('ENOENT' !== err.code) {
374
- throw err;
375
- }
376
- }
377
- const configJson = JSON.stringify(integrationsConfig, null, 4);
378
- await _nodeFs.default.promises.writeFile(integrationsConfigTargetPath, configJson);
379
- debug(`Integrations configuration file created in ${integrationsConfigTargetPath}`);
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
- const templateData = {
384
- ...instanceData,
385
- domain: lando.config.domain
386
- };
387
- const landoFile = await renderTemplateFile(landoFileTemplatePath, templateData);
388
- const nginxFile = await renderTemplateFile(nginxFileTemplatePath, templateData);
389
- const instanceDataFile = JSON.stringify(instanceData);
390
- const landoFileTargetPath = _nodePath.default.join(instancePath, landoFileName);
391
- const landoOverridesFileTargetPath = _nodePath.default.join(instancePath, landoOverridesFileName);
392
- const landoBackupFileTargetPath = _nodePath.default.join(instancePath, landoBackupFileName);
393
- const nginxFolderPath = _nodePath.default.join(instancePath, nginxPathString);
394
- const nginxFileTargetPath = _nodePath.default.join(nginxFolderPath, nginxFileName);
395
- const instanceDataTargetPath = _nodePath.default.join(instancePath, instanceDataFileName);
396
- const envFilePath = _nodePath.default.join(instancePath, '.env');
397
- await _nodeFs.default.promises.mkdir(instancePath, {
398
- recursive: true
399
- });
400
- await _nodeFs.default.promises.mkdir(nginxFolderPath, {
401
- recursive: true
402
- });
403
- try {
404
- await _nodeFs.default.promises.rename(landoFileTargetPath, landoBackupFileTargetPath);
405
- console.log(`Backup of ${landoFileName} was created in ${landoBackupFileTargetPath}`);
406
- } catch (err) {
407
- // If the file doesn't exist, that's fine. Otherwise, throw the error.
408
- if ('ENOENT' !== err.code) {
409
- throw err;
410
- }
411
- }
412
- await Promise.all([_nodeFs.default.promises.writeFile(landoFileTargetPath, landoFile), _nodeFs.default.promises.writeFile(nginxFileTargetPath, nginxFile), _nodeFs.default.promises.writeFile(instanceDataTargetPath, instanceDataFile)]);
413
- if (envVars !== undefined) {
414
- const env = [];
415
- Object.entries(envVars ?? {}).forEach(([key]) => {
416
- env.push(`VIP_ENV_VAR_${key}=`);
417
- });
418
- await _nodeFs.default.promises.writeFile(envFilePath, env.join('\n'));
419
- } else {
420
- await _nodeFs.default.promises.appendFile(envFilePath, '');
421
- }
422
- debug(`Lando file created in ${landoFileTargetPath}`);
423
- debug(`Nginx file created in ${nginxFileTargetPath}`);
424
- debug(`Instance data file created in ${instanceDataTargetPath}`);
425
- await writeIntegrationsConfig(instancePath, integrationsConfig);
426
- if (instanceData.overrides) {
427
- await _nodeFs.default.promises.writeFile(landoOverridesFileTargetPath, instanceData.overrides);
428
- } else {
429
- await _nodeFs.default.promises.rm(landoOverridesFileTargetPath, {
430
- force: true
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
- const mainEnvironmentPath = (0, _xdgData.xdgData)();
436
- const baseDir = _nodePath.default.join(mainEnvironmentPath, 'vip', 'dev-environment');
437
- const doWeHaveAnyEnvironment = _nodeFs.default.existsSync(baseDir);
438
- let envNames = [];
439
- if (doWeHaveAnyEnvironment) {
440
- const files = _nodeFs.default.readdirSync(baseDir);
441
- envNames = files.filter(file => {
442
- const fullPath = _nodePath.default.join(baseDir, file);
443
- return _nodeFs.default.lstatSync(fullPath).isDirectory();
444
- });
445
- }
446
- return envNames;
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
- if (!name) {
450
- throw new Error('Name was not provided');
451
- }
452
- const mainEnvironmentPath = (0, _xdgData.xdgData)();
453
- return _nodePath.default.join(mainEnvironmentPath, 'vip', 'dev-environment', String(name));
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
- // $FlowFixMe: gql template is not supported by flow
457
- const fieldsQuery = `
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
- const queryResult = await (0, _app.default)(appId, fieldsQuery, (0, _graphql.print)(_software.appQueryFragments));
491
- const appData = {};
492
- if (queryResult.id) {
493
- appData.id = queryResult.id;
494
- appData.name = queryResult.name;
495
- appData.repository = queryResult.repository?.htmlUrl;
496
-
497
- // 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.
498
- const environments = queryResult.environments ?? [];
499
- let envData;
500
- if (envType) {
501
- envData = environments.find(candidateEnv => candidateEnv.type === envType);
502
- } else if (1 === environments.length) {
503
- envData = environments[0];
504
- } else {
505
- const choices = environments.map(candidateEnv => candidateEnv.type);
506
- const {
507
- env
508
- } = await (0, _enquirer.prompt)({
509
- type: 'select',
510
- name: 'env',
511
- message: 'Which environment?',
512
- choices
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
- appData.environment = {
524
- name: envData.name,
525
- branch: envData.branch,
526
- type: envData.type,
527
- isMultisite: envData.isMultisite,
528
- primaryDomain: envData.primaryDomain?.name ?? '',
529
- php: envData.softwareSettings?.php?.current.version ?? '',
530
- wordpress: envData.softwareSettings?.wordpress?.current.version ?? '',
531
- integrations: envData.getIntegrationsDevEnvConfig?.data ?? {},
532
- envVars
533
- };
534
- }
535
- }
536
- return appData;
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
- debug(`Will try to resolve path - ${fileName}`);
540
- let resolvedPath = (0, _devEnvironmentCli.resolvePath)(fileName);
541
- debug(`Filename ${fileName} resolved to ${resolvedPath}`);
542
- if (!_nodeFs.default.existsSync(resolvedPath)) {
543
- throw new _userError.default(`The provided file ${resolvedPath} does not exist or it is not valid (see "--help" for examples)`);
544
- }
545
- if (_nodeFs.default.lstatSync(resolvedPath).isDirectory()) {
546
- throw new _userError.default(`The provided file ${resolvedPath} is a directory. Please point to a sql file.`);
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
- resolvedPath = outputFileName;
562
- }
563
- return resolvedPath;
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
- const resolvedPath = (0, _devEnvironmentCli.resolvePath)(filePath);
567
- if (!_nodeFs.default.existsSync(resolvedPath) || !_nodeFs.default.lstatSync(resolvedPath).isDirectory()) {
568
- throw new Error('The provided path does not exist or it is not valid (see "--help" for examples)');
569
- }
570
- const environmentPath = getEnvironmentPath(slug);
571
- if (!(await doesEnvironmentExist(environmentPath))) {
572
- throw new Error(_devEnvironment.DEV_ENVIRONMENT_NOT_FOUND);
573
- }
574
- const files = await (0, _promises.readdir)(resolvedPath);
575
- if (files.includes(uploadPathString)) {
576
- const confirm = await (0, _enquirer.prompt)({
577
- type: 'confirm',
578
- name: 'continue',
579
- message: 'The provided path contains an uploads folder inside. Do you want to continue?'
580
- });
581
- if (!confirm.continue) {
582
- return;
583
- }
584
- }
585
- const uploadsPath = _nodePath.default.join(environmentPath, uploadPathString);
586
- console.log(`${_chalk.default.yellow('-')} Started copying files`);
587
- try {
588
- await (0, _promises.cp)(resolvedPath, uploadsPath, {
589
- recursive: true
590
- });
591
- console.log(`${_chalk.default.green('✓')} Files successfully copied to ${uploadsPath}.`);
592
- } catch (error) {
593
- console.error(`${_chalk.default.red('✗')} Error copying files to ${uploadsPath}.`);
594
- throw error;
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
- const versions = await getVersionList();
610
- if (!versions.length) {
611
- return false;
612
- }
613
- let message;
614
- let envData;
615
- let currentWordPressTag;
616
-
617
- // Get the current environment configuration
618
- try {
619
- envData = readEnvironmentData(slug);
620
- currentWordPressTag = envData.wordpress.tag;
621
- if (currentWordPressTag === 'trunk') {
622
- return false;
623
- }
624
- } catch (err) {
625
- const error = err;
626
- // This can throw an exception if the env is build with older vip version
627
- if ('ENOENT' === error.code) {
628
- message = 'Environment was created before update was supported.\n\n';
629
- message += 'To update environment please destroy it and create a new one.';
630
- } else {
631
- message = `An error prevented reading the configuration of: ${slug}\n\n ${error.message}`;
632
- }
633
- await (0, _devEnvironmentCli.handleCLIException)(new Error(message));
634
- return false;
635
- }
636
-
637
- // sort
638
- versions.sort((before, after) => before.tag < after.tag ? 1 : -1);
639
- // Newest WordPress Image but that is not trunk
640
- const newestWordPressImage = versions.find(({
641
- tag
642
- }) => tag !== 'trunk');
643
- console.log('The most recent WordPress version available is: ' + _chalk.default.green(newestWordPressImage?.tag));
644
-
645
- // If the currently used version is the most up to date: exit.
646
- if (currentWordPressTag === newestWordPressImage?.tag) {
647
- console.log('Environment WordPress version is: ' + _chalk.default.green(currentWordPressTag) + ' ... 😎 nice! ');
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
- const envData = readEnvironmentData(slug);
703
- const currentVersion = envData.version;
704
- console.log('Current local environment version is: ' + _chalk.default.yellow(currentVersion));
705
- if (!currentVersion || _semver.default.lt(currentVersion, _devEnvironment.DEV_ENVIRONMENT_VERSION)) {
706
- envData.pullAfter = undefined;
707
- await updateEnvironment(lando, envData);
708
- console.log('Local environment version updated to: ' + _chalk.default.green(_devEnvironment.DEV_ENVIRONMENT_VERSION));
709
- return true;
710
- }
711
- return false;
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
- const url = `https://${_devEnvironment.DEV_ENVIRONMENT_RAW_GITHUB_HOST}${_devEnvironment.DEV_ENVIRONMENT_WORDPRESS_VERSIONS_URI}`;
719
- const proxyDispatcher = (0, _proxyDispatcher.createProxyDispatcher)(url);
720
- return (0, _undici.fetch)(url, {
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
- try {
734
- const {
735
- mtime: expire
736
- } = await _nodeFs.default.promises.stat(cacheFile);
737
- expire.setSeconds(expire.getSeconds() + ttl);
738
- return Number(new Date()) > Number(expire);
739
- } catch (error) {
740
- debug(`Error checking version list expiration for cache file ${cacheFile}:`, error);
741
- return true;
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
- let res;
750
- const mainEnvironmentPath = (0, _xdgData.xdgData)();
751
- const cacheFilePath = _nodePath.default.join(mainEnvironmentPath, 'vip');
752
- const cacheFile = _nodePath.default.join(cacheFilePath, _devEnvironment.DEV_ENVIRONMENT_WORDPRESS_CACHE_KEY);
753
- // Handle from cache
754
- try {
755
- // If the path for the cache file doesn't exist, create it
756
- if (!_nodeFs.default.existsSync(cacheFilePath)) {
757
- await _nodeFs.default.promises.mkdir(cacheFilePath, {
758
- recursive: true
759
- });
760
- }
761
-
762
- // If the cache does not exist or has expired, refresh it
763
- if (await isVersionListExpired(cacheFile, _devEnvironment.DEV_ENVIRONMENT_WORDPRESS_VERSION_TTL)) {
764
- res = await fetchVersionList();
765
- await _nodeFs.default.promises.writeFile(cacheFile, JSON.stringify(res));
766
- }
767
- } catch (err) {
768
- // Soft error handling here, since it's still possible to use a previously cached file.
769
- console.log(_chalk.default.yellow('fetchWordPressVersionList failed to retrieve an updated version list'));
770
- debug(err);
771
- }
772
-
773
- // Try to parse the cached file if it exists.
774
- try {
775
- const data = await _nodeFs.default.promises.readFile(cacheFile, 'utf8');
776
- return JSON.parse(data);
777
- } catch (err) {
778
- debug(err);
779
- return [{
780
- ref: 'HEAD',
781
- tag: 'trunk',
782
- cacheable: false,
783
- locked: false,
784
- prerelease: true
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
- debug('Generating VS Code Workspace');
797
- const location = getEnvironmentPath(slug);
798
- const workspacePath = getVSCodeWorkspacePath(slug);
799
- const instanceData = readEnvironmentData(slug);
800
- const pathMappings = generatePathMappings(location, instanceData);
801
- const folders = [{
802
- path: location
803
- }];
804
- if (instanceData.muPlugins.dir) {
805
- folders.push({
806
- path: instanceData.muPlugins.dir
807
- });
808
- }
809
- if (instanceData.appCode.dir) {
810
- folders.push({
811
- path: instanceData.appCode.dir
812
- });
813
- }
814
-
815
- // Create debug configuration
816
- const debugConfig = {
817
- name: `Debug ${slug}`,
818
- type: 'php',
819
- request: 'launch',
820
- port: 9003,
821
- pathMappings
822
- };
823
-
824
- // Check if running under WSL and add hostname if needed
825
- // This is to allow xdebug to work when running under WSL
826
- if (process.env?.WSL_DISTRO_NAME) {
827
- debug('WSL detected, adding hostname to debug configuration');
828
- debugConfig.hostname = '0.0.0.0';
829
- }
830
- const workspace = {
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
- const pathMappings = {};
842
- if (instanceData.muPlugins.dir) {
843
- pathMappings['/wp/wp-content/mu-plugins'] = instanceData.muPlugins.dir;
844
- }
845
- if (instanceData.appCode.dir) {
846
- pathMappings['/wp/wp-content/client-mu-plugins'] = _nodePath.default.resolve(instanceData.appCode.dir, 'client-mu-plugins');
847
- pathMappings['/wp/wp-content/images'] = _nodePath.default.resolve(instanceData.appCode.dir, 'images');
848
- pathMappings['/wp/wp-content/languages'] = _nodePath.default.resolve(instanceData.appCode.dir, 'languages');
849
- pathMappings['/wp/wp-content/plugins'] = _nodePath.default.resolve(instanceData.appCode.dir, 'plugins');
850
- pathMappings['/wp/wp-content/private'] = _nodePath.default.resolve(instanceData.appCode.dir, 'private');
851
- pathMappings['/wp/wp-content/themes'] = _nodePath.default.resolve(instanceData.appCode.dir, 'themes');
852
- pathMappings['/wp/vip-config'] = _nodePath.default.resolve(instanceData.appCode.dir, 'vip-config');
853
- }
854
- pathMappings['/wp'] = _nodePath.default.resolve(location, 'wordpress');
855
- return pathMappings;
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
- const location = getEnvironmentPath(slug);
859
- const workspacePath = _nodePath.default.join(location, `${slug}.code-workspace`);
860
- return workspacePath;
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
- debug('Generating PHPStorm Workspace');
871
- const location = getEnvironmentPath(slug);
872
- const instanceData = readEnvironmentData(slug);
873
- const pathMappings = generatePathMappings(location, instanceData);
874
-
875
- // Create .idea directory
876
- _nodeFs.default.mkdirSync(_nodePath.default.join(location, '.idea', 'runConfigurations'), {
877
- recursive: true
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).map(([serverPath, localPath]) => ` <mapping local-root="${serverPath}" remote-root="$PROJECT_DIR$/${_nodePath.default.relative(location, localPath)}" />`).join('\n')}
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, _nodeCrypto.randomUUID)()}" name="localhost" use_path_mappings="true">
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).map(([serverPath, localPath]) => `<mapping local-root="${localPath}" remote-root="${serverPath}" />`).join('\n')}
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
- _nodeFs.default.writeFileSync(_nodePath.default.join(location, '.idea', 'workspace.xml'), workspaceXml);
914
- const xdebugXml = `<component name="ProjectRunConfigurationManager">
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
- _nodeFs.default.writeFileSync(_nodePath.default.join(location, '.idea', 'runConfigurations', 'vip-xdebug.xml'), xdebugXml);
921
- const projectXml = `<?xml version="1.0" encoding="UTF-8"?>
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
- _nodeFs.default.writeFileSync(_nodePath.default.join(location, '.idea', 'modules.xml'), projectXml);
931
- const modulesXml = `<?xml version="1.0" encoding="UTF-8"?>
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$/${_nodePath.default.relative(location, instanceData?.appCode?.dir ?? '')}" />
935
- <content url="file://$MODULE_DIR$/${_nodePath.default.relative(location, instanceData?.muPlugins?.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
- _nodeFs.default.writeFileSync(_nodePath.default.join(location, '.idea', slug + '.iml'), modulesXml);
943
- return location;
944
- }
907
+ node_fs_1.default.writeFileSync(node_path_1.default.join(location, '.idea', slug + '.iml'), modulesXml);
908
+ return location;
909
+ }