@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
package/dist/lib/retry.js CHANGED
@@ -1,24 +1,21 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.EXPONENTIAL_BACKOFF_STARTING_IN_50_MS = exports.EXPONENTIAL_BACKOFF_STARTING_IN_200_MS = exports.EXPONENTIAL_BACKOFF_STARTING_IN_100_MS = void 0;
5
- exports.exponentialBackoff = exponentialBackoff;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EXPONENTIAL_BACKOFF_STARTING_IN_200_MS = exports.EXPONENTIAL_BACKOFF_STARTING_IN_100_MS = exports.EXPONENTIAL_BACKOFF_STARTING_IN_50_MS = void 0;
6
4
  exports.retry = retry;
7
- var _promises = require("node:timers/promises");
5
+ exports.exponentialBackoff = exponentialBackoff;
8
6
  // copied over from our internal lib
9
-
10
- const EXPONENTIAL_BACKOFF_STARTING_IN_50_MS = exports.EXPONENTIAL_BACKOFF_STARTING_IN_50_MS = exponentialBackoff(50);
11
- const EXPONENTIAL_BACKOFF_STARTING_IN_100_MS = exports.EXPONENTIAL_BACKOFF_STARTING_IN_100_MS = exponentialBackoff(100);
12
- const EXPONENTIAL_BACKOFF_STARTING_IN_200_MS = exports.EXPONENTIAL_BACKOFF_STARTING_IN_200_MS = exponentialBackoff(200);
7
+ const promises_1 = require("node:timers/promises");
8
+ exports.EXPONENTIAL_BACKOFF_STARTING_IN_50_MS = exponentialBackoff(50);
9
+ exports.EXPONENTIAL_BACKOFF_STARTING_IN_100_MS = exponentialBackoff(100);
10
+ exports.EXPONENTIAL_BACKOFF_STARTING_IN_200_MS = exponentialBackoff(200);
13
11
  const MAX_INTERVAL_BETWEEN_ATTEMPTS = 600000; // 10 minutes
14
-
15
- const NOOP = async () => {};
12
+ const NOOP = async () => { };
16
13
  const DEFAULT_OPTIONS = {
17
- maxRetries: 4,
18
- interval: EXPONENTIAL_BACKOFF_STARTING_IN_100_MS,
19
- retryOnlyIf: () => Promise.resolve(true),
20
- onRetry: NOOP,
21
- onFailedAttempt: NOOP
14
+ maxRetries: 4,
15
+ interval: exports.EXPONENTIAL_BACKOFF_STARTING_IN_100_MS,
16
+ retryOnlyIf: () => Promise.resolve(true),
17
+ onRetry: NOOP,
18
+ onFailedAttempt: NOOP,
22
19
  };
23
20
  /**
24
21
  * We don't need a strict Error instance, which can help in cases (probably
@@ -26,129 +23,96 @@ const DEFAULT_OPTIONS = {
26
23
  * really just need to check for an object with a message property.
27
24
  */
28
25
  function isErrorLike(value) {
29
- return value instanceof Error || null !== value && 'object' === typeof value && 'message' in value;
26
+ return (value instanceof Error || (null !== value && 'object' === typeof value && 'message' in value));
30
27
  }
31
-
32
- /**
33
- * Execute a <task> and retries <options.maxRetries> times while it fails.
34
- * @param {Object} [options] - The options.
35
- * @param {number} [options.maxRetries] - The max number of retry attempts to be executed.
36
- * @param {function|number} [options.interval] - The time to wait between retries in milliseconds.
37
- * It can be either a number or a function.
38
- * Function arguments: retryAttemptNumber.
39
- * Expected return: a number representing the time in milliseconds.
40
- * @param {function} [options.retryOnlyIf] - A function used to determine if a retry should be attempted.
41
- * Arguments: Object<{ error, attemptNumber }>.
42
- * Expected return: boolean|Promise<boolean>.
43
- * @param {function} [options.onRetry] - A callback function executed right before a retry attempt.
44
- * Arguments: Object<{ retryNumber: attemptNumber }>.
45
- * Expected return: void|Promise<void>.
46
- * @param {function} [options.onFailedAttempt] - A callback function executed right after a failed attempt.
47
- * Arguments: Object<{ error, attemptNumber, attemptDuration }>.
48
- * Expected return: void|Promise<void>.
49
- * @param {function} task - The task to be executed.
50
- * @return {any} - The value returned by the provided <task> function when it is successfully executed
51
- */
52
-
53
28
  async function retry(optionsOrTask, task) {
54
- let options = optionsOrTask;
55
- if (arguments.length < 3 && typeof optionsOrTask === 'function') {
56
- task = optionsOrTask;
57
- options = {};
58
- }
59
- const finalOptions = {
60
- ...DEFAULT_OPTIONS,
61
- ...options
62
- };
63
- const {
64
- maxRetries,
65
- interval,
66
- retryOnlyIf,
67
- onRetry,
68
- onFailedAttempt
69
- } = finalOptions;
70
- validateTask(task);
71
- validateOptions(finalOptions);
72
- const maxAttempts = maxRetries + 1;
73
- for (let attemptNumber = 1; attemptNumber <= maxAttempts; attemptNumber++) {
74
- /* eslint-disable no-await-in-loop */
75
- const attemptStart = Date.now();
76
- try {
77
- return await task();
78
- } catch (caughtError) {
79
- const attemptEnd = Date.now();
80
- const attemptDuration = attemptEnd - attemptStart;
81
- const attemptStartTime = new Date(attemptStart);
82
- const attemptEndTime = new Date(attemptEnd);
83
- const error = isErrorLike(caughtError) ? caughtError : new Error(String(caughtError));
84
- await onFailedAttempt({
85
- error,
86
- attemptNumber,
87
- attemptDuration,
88
- attemptStartTime,
89
- attemptEndTime
90
- });
91
- const shouldRetry = await retryOnlyIf({
92
- error,
93
- attemptNumber
94
- });
95
- if (attemptNumber === maxAttempts || shouldRetry !== true) {
96
- throw error;
97
- }
98
- await awaitInterval(interval, attemptNumber);
99
- await onRetry({
100
- retryNumber: attemptNumber
101
- });
29
+ let options = optionsOrTask;
30
+ if (arguments.length < 3 && typeof optionsOrTask === 'function') {
31
+ task = optionsOrTask;
32
+ options = {};
102
33
  }
103
- }
104
- throw new Error('Error, wrong retry options set');
34
+ const finalOptions = {
35
+ ...DEFAULT_OPTIONS,
36
+ ...options,
37
+ };
38
+ const { maxRetries, interval, retryOnlyIf, onRetry, onFailedAttempt } = finalOptions;
39
+ validateTask(task);
40
+ validateOptions(finalOptions);
41
+ const maxAttempts = maxRetries + 1;
42
+ for (let attemptNumber = 1; attemptNumber <= maxAttempts; attemptNumber++) {
43
+ /* eslint-disable no-await-in-loop */
44
+ const attemptStart = Date.now();
45
+ try {
46
+ return await task();
47
+ }
48
+ catch (caughtError) {
49
+ const attemptEnd = Date.now();
50
+ const attemptDuration = attemptEnd - attemptStart;
51
+ const attemptStartTime = new Date(attemptStart);
52
+ const attemptEndTime = new Date(attemptEnd);
53
+ const error = isErrorLike(caughtError) ? caughtError : new Error(String(caughtError));
54
+ await onFailedAttempt({
55
+ error,
56
+ attemptNumber,
57
+ attemptDuration,
58
+ attemptStartTime,
59
+ attemptEndTime,
60
+ });
61
+ const shouldRetry = await retryOnlyIf({ error, attemptNumber });
62
+ if (attemptNumber === maxAttempts || shouldRetry !== true) {
63
+ throw error;
64
+ }
65
+ await awaitInterval(interval, attemptNumber);
66
+ await onRetry({ retryNumber: attemptNumber });
67
+ }
68
+ }
69
+ throw new Error('Error, wrong retry options set');
105
70
  }
106
71
  function isValidInterval(interval) {
107
- if ('function' === typeof interval) {
108
- return true;
109
- }
110
- return typeof interval === 'number' && Number.isInteger(interval) && interval >= 0 && interval <= MAX_INTERVAL_BETWEEN_ATTEMPTS;
72
+ if ('function' === typeof interval) {
73
+ return true;
74
+ }
75
+ return (typeof interval === 'number' &&
76
+ Number.isInteger(interval) &&
77
+ interval >= 0 &&
78
+ interval <= MAX_INTERVAL_BETWEEN_ATTEMPTS);
111
79
  }
112
80
  function awaitInterval(interval, attemptNumber) {
113
- let newInterval;
114
- if (typeof interval === 'function') {
115
- newInterval = interval(attemptNumber);
116
- if (!isValidInterval(newInterval)) {
117
- throw new Error(`Invalid calculated interval for retry attempt ${attemptNumber}: "${newInterval}" (type: ${typeof newInterval})`);
81
+ let newInterval;
82
+ if (typeof interval === 'function') {
83
+ newInterval = interval(attemptNumber);
84
+ if (!isValidInterval(newInterval)) {
85
+ throw new Error(`Invalid calculated interval for retry attempt ${attemptNumber}: "${newInterval}" (type: ${typeof newInterval})`);
86
+ }
87
+ }
88
+ else {
89
+ newInterval = interval;
118
90
  }
119
- } else {
120
- newInterval = interval;
121
- }
122
- return (0, _promises.setTimeout)(newInterval);
91
+ return (0, promises_1.setTimeout)(newInterval);
123
92
  }
124
93
  function validateTask(task) {
125
- if (typeof task !== 'function') {
126
- throw new Error('Invalid task: it should be a function');
127
- }
94
+ if (typeof task !== 'function') {
95
+ throw new Error('Invalid task: it should be a function');
96
+ }
128
97
  }
129
- function validateOptions({
130
- maxRetries,
131
- interval,
132
- onFailedAttempt,
133
- retryOnlyIf
134
- }) {
135
- if (!Number.isInteger(maxRetries) || maxRetries < 0) {
136
- throw new Error('Invalid option "maxRetries": it should be an integer number >= 0');
137
- }
138
- if (!isValidInterval(interval)) {
139
- const definition = `an integer number between 0 and ${MAX_INTERVAL_BETWEEN_ATTEMPTS}`;
140
- throw new Error(`Invalid option "interval": it should be either ${definition}, or a synchronous function which returns ${definition}`);
141
- }
142
- if (!isValidInterval(interval)) {
143
- throw new Error('Invalid option "interval": it should be either an integer number >= 0, or a synchronous function which returns an integer number >= 0');
144
- }
145
- if (typeof onFailedAttempt !== 'function') {
146
- throw new Error('Invalid option "onFailedAttempt": it should be a function');
147
- }
148
- if (typeof retryOnlyIf !== 'function') {
149
- throw new Error('Invalid option "retryOnlyIf": it should be a function');
150
- }
98
+ function validateOptions({ maxRetries, interval, onFailedAttempt, retryOnlyIf, }) {
99
+ if (!Number.isInteger(maxRetries) || maxRetries < 0) {
100
+ throw new Error('Invalid option "maxRetries": it should be an integer number >= 0');
101
+ }
102
+ if (!isValidInterval(interval)) {
103
+ const definition = `an integer number between 0 and ${MAX_INTERVAL_BETWEEN_ATTEMPTS}`;
104
+ throw new Error(`Invalid option "interval": it should be either ${definition}, or a synchronous function which returns ${definition}`);
105
+ }
106
+ if (!isValidInterval(interval)) {
107
+ throw new Error('Invalid option "interval": it should be either an integer number >= 0, or a synchronous function which returns an integer number >= 0');
108
+ }
109
+ if (typeof onFailedAttempt !== 'function') {
110
+ throw new Error('Invalid option "onFailedAttempt": it should be a function');
111
+ }
112
+ if (typeof retryOnlyIf !== 'function') {
113
+ throw new Error('Invalid option "retryOnlyIf": it should be a function');
114
+ }
151
115
  }
152
116
  function exponentialBackoff(startMilliseconds) {
153
- return retryAttemptNumber => Math.pow(2, retryAttemptNumber - 1) * startMilliseconds;
154
- }
117
+ return retryAttemptNumber => Math.pow(2, retryAttemptNumber - 1) * startMilliseconds;
118
+ }
@@ -1,157 +1,173 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.getReadAndWriteStreams = getReadAndWriteStreams;
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
5
39
  exports.searchAndReplace = void 0;
6
- var _vipSearchReplace = require("@automattic/vip-search-replace");
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- var _debug = _interopRequireDefault(require("debug"));
9
- var _fs = _interopRequireDefault(require("fs"));
10
- var _promises = require("node:stream/promises");
11
- var _path = _interopRequireDefault(require("path"));
12
- var _database = require("./database");
13
- var _utils = require("./utils");
14
- var exit = _interopRequireWildcard(require("../lib/cli/exit"));
15
- var _prompt = require("../lib/cli/prompt");
16
- var _clientFileUploader = require("../lib/client-file-uploader");
17
- var _tracker = require("../lib/tracker");
18
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
19
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
- const debug = (0, _debug.default)('@automattic/vip:lib:search-and-replace');
21
- function getReadAndWriteStreams({
22
- fileName,
23
- inPlace,
24
- output
25
- }) {
26
- let writeStream;
27
- let usingStdOut = false;
28
- let outputFileName;
29
- if (inPlace) {
30
- const midputFileName = _path.default.join((0, _utils.makeTempDir)('vip-search-replace'), _path.default.basename(fileName));
31
- _fs.default.copyFileSync(fileName, midputFileName);
32
- debug(`Copied input file to ${midputFileName}`);
33
- debug(`Set output to the original file path ${fileName}`);
34
- outputFileName = fileName;
40
+ exports.getReadAndWriteStreams = getReadAndWriteStreams;
41
+ const vip_search_replace_1 = require("@automattic/vip-search-replace");
42
+ const chalk_1 = __importDefault(require("chalk"));
43
+ const debug_1 = __importDefault(require("debug"));
44
+ const fs_1 = __importDefault(require("fs"));
45
+ const promises_1 = require("node:stream/promises");
46
+ const path_1 = __importDefault(require("path"));
47
+ const database_1 = require("./database");
48
+ const utils_1 = require("./utils");
49
+ const exit = __importStar(require("../lib/cli/exit"));
50
+ const prompt_1 = require("../lib/cli/prompt");
51
+ const client_file_uploader_1 = require("../lib/client-file-uploader");
52
+ const tracker_1 = require("../lib/tracker");
53
+ const debug = (0, debug_1.default)('@automattic/vip:lib:search-and-replace');
54
+ function getReadAndWriteStreams({ fileName, inPlace, output, }) {
55
+ let writeStream;
56
+ let usingStdOut = false;
57
+ let outputFileName;
58
+ if (inPlace) {
59
+ const midputFileName = path_1.default.join((0, utils_1.makeTempDir)('vip-search-replace'), path_1.default.basename(fileName));
60
+ fs_1.default.copyFileSync(fileName, midputFileName);
61
+ debug(`Copied input file to ${midputFileName}`);
62
+ debug(`Set output to the original file path ${fileName}`);
63
+ outputFileName = fileName;
64
+ return {
65
+ outputFileName,
66
+ readStream: fs_1.default.createReadStream(midputFileName),
67
+ usingStdOut,
68
+ writeStream: fs_1.default.createWriteStream(fileName),
69
+ };
70
+ }
71
+ debug(`Reading input from file: ${fileName}`);
72
+ switch (typeof output) {
73
+ case 'string':
74
+ writeStream = fs_1.default.createWriteStream(output);
75
+ outputFileName = output;
76
+ debug(`Outputting to file: ${outputFileName}`);
77
+ break;
78
+ case 'object':
79
+ writeStream = output;
80
+ if (writeStream === process.stdout) {
81
+ usingStdOut = true;
82
+ debug('Outputting to the standard output stream');
83
+ }
84
+ else {
85
+ debug('Outputting to the provided output stream');
86
+ }
87
+ break;
88
+ default: {
89
+ const tmpOutFile = path_1.default.join((0, utils_1.makeTempDir)('vip-search-replace'), path_1.default.basename(fileName));
90
+ writeStream = fs_1.default.createWriteStream(tmpOutFile);
91
+ outputFileName = tmpOutFile;
92
+ debug(`Outputting to file: ${outputFileName}`);
93
+ break;
94
+ }
95
+ }
35
96
  return {
36
- outputFileName,
37
- readStream: _fs.default.createReadStream(midputFileName),
38
- usingStdOut,
39
- writeStream: _fs.default.createWriteStream(fileName)
97
+ outputFileName,
98
+ readStream: fs_1.default.createReadStream(fileName),
99
+ usingStdOut,
100
+ writeStream,
40
101
  };
41
- }
42
- debug(`Reading input from file: ${fileName}`);
43
- switch (typeof output) {
44
- case 'string':
45
- writeStream = _fs.default.createWriteStream(output);
46
- outputFileName = output;
47
- debug(`Outputting to file: ${outputFileName}`);
48
- break;
49
- case 'object':
50
- writeStream = output;
51
- if (writeStream === process.stdout) {
52
- usingStdOut = true;
53
- debug('Outputting to the standard output stream');
54
- } else {
55
- debug('Outputting to the provided output stream');
56
- }
57
- break;
58
- default:
59
- {
60
- const tmpOutFile = _path.default.join((0, _utils.makeTempDir)('vip-search-replace'), _path.default.basename(fileName));
61
- writeStream = _fs.default.createWriteStream(tmpOutFile);
62
- outputFileName = tmpOutFile;
63
- debug(`Outputting to file: ${outputFileName}`);
64
- break;
65
- }
66
- }
67
- return {
68
- outputFileName,
69
- readStream: _fs.default.createReadStream(fileName),
70
- usingStdOut,
71
- writeStream
72
- };
73
102
  }
74
- const searchAndReplace = async (fileName, pairs, {
75
- isImport = true,
76
- inPlace = false,
77
- output = process.stdout,
78
- batchMode = false
79
- }, binary = null) => {
80
- const dumpDetails = await (0, _database.getSqlDumpDetails)(fileName);
81
- const isMyDumper = dumpDetails.type === _database.SqlDumpType.MYDUMPER;
82
- await (0, _tracker.trackEvent)('searchreplace_started', {
83
- is_import: isImport,
84
- in_place: inPlace,
85
- sqldump_type: dumpDetails.type
86
- });
87
- const startTime = process.hrtime();
88
- const fileSize = (0, _clientFileUploader.getFileSize)(fileName);
89
-
90
- // if we don't have any pairs to replace with, return the input file
91
- if (!pairs.length) {
92
- throw new Error('No search and replace parameters provided.');
93
- }
94
-
95
- // If only one pair is provided, ensure we have an array
96
- if (!Array.isArray(pairs)) {
97
- pairs = [pairs];
98
- }
99
-
100
- // determine all the replacements required
101
- const replacements = pairs.flatMap(pair => pair.split(',').map(str => str.trim()));
102
- debug('Pairs: ', pairs, 'Replacements: ', replacements);
103
- if (inPlace && !batchMode) {
104
- const approved = await (0, _prompt.confirm)([], 'Are you sure you want to run search and replace on your input file? This operation is not reversible.');
105
-
106
- // Bail if user does not wish to proceed
107
- if (!approved) {
108
- await (0, _tracker.trackEvent)('search_replace_in_place_cancelled', {
103
+ const searchAndReplace = async (fileName, pairs, { isImport = true, inPlace = false, output = process.stdout, batchMode = false, }, binary = null) => {
104
+ const dumpDetails = await (0, database_1.getSqlDumpDetails)(fileName);
105
+ const isMyDumper = dumpDetails.type === database_1.SqlDumpType.MYDUMPER;
106
+ await (0, tracker_1.trackEvent)('searchreplace_started', {
109
107
  is_import: isImport,
110
108
  in_place: inPlace,
111
- sqldump_type: dumpDetails.type
112
- });
113
- process.exit();
109
+ sqldump_type: dumpDetails.type,
110
+ });
111
+ const startTime = process.hrtime();
112
+ const fileSize = (0, client_file_uploader_1.getFileSize)(fileName);
113
+ // if we don't have any pairs to replace with, return the input file
114
+ if (!pairs.length) {
115
+ throw new Error('No search and replace parameters provided.');
116
+ }
117
+ // If only one pair is provided, ensure we have an array
118
+ if (!Array.isArray(pairs)) {
119
+ pairs = [pairs];
114
120
  }
115
- }
116
- const {
117
- usingStdOut,
118
- outputFileName,
119
- readStream,
120
- writeStream
121
- } = getReadAndWriteStreams({
122
- fileName,
123
- inPlace,
124
- output
125
- });
126
- let replacedStream;
127
- try {
128
- replacedStream = await (0, _vipSearchReplace.replace)(readStream, replacements, binary);
129
- } catch (replaceError) {
130
- // replace() throws strings... OMG
131
- exit.withError(replaceError);
132
- }
133
- const transforms = [];
134
- if (isMyDumper) {
135
- transforms.push((0, _database.fixMyDumperTransform)());
136
- }
137
- try {
138
- await (0, _promises.pipeline)(replacedStream, ...transforms, writeStream);
139
- } catch (error) {
140
- console.log(_chalk.default.red("Oh no! We couldn't write to the output file. Please check your available disk space and file/folder permissions."));
141
- throw error;
142
- }
143
- const endTime = process.hrtime(startTime);
144
- const end = endTime[1] / 1000000; // time in ms
145
-
146
- await (0, _tracker.trackEvent)('searchreplace_completed', {
147
- time_to_run: end,
148
- file_size: fileSize,
149
- sqldump_type: dumpDetails.type
150
- });
151
- return {
152
- inputFileName: fileName,
153
- outputFileName,
154
- usingStdOut
155
- };
121
+ // determine all the replacements required
122
+ const replacements = pairs.flatMap(pair => pair.split(',').map(str => str.trim()));
123
+ debug('Pairs: ', pairs, 'Replacements: ', replacements);
124
+ if (inPlace && !batchMode) {
125
+ const approved = await (0, prompt_1.confirm)([], 'Are you sure you want to run search and replace on your input file? This operation is not reversible.');
126
+ // Bail if user does not wish to proceed
127
+ if (!approved) {
128
+ await (0, tracker_1.trackEvent)('search_replace_in_place_cancelled', {
129
+ is_import: isImport,
130
+ in_place: inPlace,
131
+ sqldump_type: dumpDetails.type,
132
+ });
133
+ process.exit();
134
+ }
135
+ }
136
+ const { usingStdOut, outputFileName, readStream, writeStream } = getReadAndWriteStreams({
137
+ fileName,
138
+ inPlace,
139
+ output,
140
+ });
141
+ let replacedStream;
142
+ try {
143
+ replacedStream = await (0, vip_search_replace_1.replace)(readStream, replacements, binary);
144
+ }
145
+ catch (replaceError) {
146
+ // replace() throws strings... OMG
147
+ exit.withError(replaceError);
148
+ }
149
+ const transforms = [];
150
+ if (isMyDumper) {
151
+ transforms.push((0, database_1.fixMyDumperTransform)());
152
+ }
153
+ try {
154
+ await (0, promises_1.pipeline)(replacedStream, ...transforms, writeStream);
155
+ }
156
+ catch (error) {
157
+ console.log(chalk_1.default.red("Oh no! We couldn't write to the output file. Please check your available disk space and file/folder permissions."));
158
+ throw error;
159
+ }
160
+ const endTime = process.hrtime(startTime);
161
+ const end = endTime[1] / 1000000; // time in ms
162
+ await (0, tracker_1.trackEvent)('searchreplace_completed', {
163
+ time_to_run: end,
164
+ file_size: fileSize,
165
+ sqldump_type: dumpDetails.type,
166
+ });
167
+ return {
168
+ inputFileName: fileName,
169
+ outputFileName,
170
+ usingStdOut,
171
+ };
156
172
  };
157
- exports.searchAndReplace = searchAndReplace;
173
+ exports.searchAndReplace = searchAndReplace;
@@ -1,21 +1,17 @@
1
1
  "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.SYNC_STATUS_NOT_SYNCING = exports.SQL_IMPORT_FILE_SIZE_LIMIT_LAUNCHED = exports.SQL_IMPORT_FILE_SIZE_LIMIT = void 0;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isImportingBlockedBySync = exports.SYNC_STATUS_NOT_SYNCING = exports.isSupportedApp = exports.SQL_IMPORT_FILE_SIZE_LIMIT_LAUNCHED = exports.SQL_IMPORT_FILE_SIZE_LIMIT = void 0;
5
4
  exports.currentUserCanImportForApp = currentUserCanImportForApp;
6
- exports.isSupportedApp = exports.isImportingBlockedBySync = void 0;
7
- var _fileSize = require("../../lib/constants/file-size");
8
- var _vipgo = require("../../lib/constants/vipgo");
9
- const SQL_IMPORT_FILE_SIZE_LIMIT = exports.SQL_IMPORT_FILE_SIZE_LIMIT = 200 * _fileSize.GB_IN_BYTES;
10
- const SQL_IMPORT_FILE_SIZE_LIMIT_LAUNCHED = exports.SQL_IMPORT_FILE_SIZE_LIMIT_LAUNCHED = 10 * _fileSize.GB_IN_BYTES;
5
+ const file_size_1 = require("../../lib/constants/file-size");
6
+ const vipgo_1 = require("../../lib/constants/vipgo");
7
+ exports.SQL_IMPORT_FILE_SIZE_LIMIT = 200 * file_size_1.GB_IN_BYTES;
8
+ exports.SQL_IMPORT_FILE_SIZE_LIMIT_LAUNCHED = 10 * file_size_1.GB_IN_BYTES;
11
9
  function currentUserCanImportForApp(app) {
12
- // TODO: implement
13
- return Boolean(app);
10
+ // TODO: implement
11
+ return Boolean(app);
14
12
  }
15
- const isSupportedApp = ({
16
- typeId
17
- }) => _vipgo.DATABASE_APPLICATION_TYPE_IDS.includes(typeId);
13
+ const isSupportedApp = ({ typeId }) => vipgo_1.DATABASE_APPLICATION_TYPE_IDS.includes(typeId);
18
14
  exports.isSupportedApp = isSupportedApp;
19
- const SYNC_STATUS_NOT_SYNCING = exports.SYNC_STATUS_NOT_SYNCING = 'not_syncing';
20
- const isImportingBlockedBySync = env => env.syncProgress?.status !== SYNC_STATUS_NOT_SYNCING;
21
- exports.isImportingBlockedBySync = isImportingBlockedBySync;
15
+ exports.SYNC_STATUS_NOT_SYNCING = 'not_syncing';
16
+ const isImportingBlockedBySync = (env) => env.syncProgress?.status !== exports.SYNC_STATUS_NOT_SYNCING;
17
+ exports.isImportingBlockedBySync = isImportingBlockedBySync;