@zuplo/cli 6.69.4 → 6.69.5

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 (333) hide show
  1. package/dist/__tests__/integration/jest-mocks-setup.js +29 -10
  2. package/dist/__tests__/integration/jest-mocks-setup.js.map +1 -1
  3. package/dist/cmds/custom-domain/index.d.ts.map +1 -1
  4. package/dist/cmds/custom-domain/index.js +6 -10
  5. package/dist/cmds/custom-domain/index.js.map +1 -1
  6. package/dist/cmds/mtls-certificates/index.d.ts.map +1 -1
  7. package/dist/cmds/mtls-certificates/index.js +8 -12
  8. package/dist/cmds/mtls-certificates/index.js.map +1 -1
  9. package/dist/cmds/open-api/index.d.ts.map +1 -1
  10. package/dist/cmds/open-api/index.js +2 -5
  11. package/dist/cmds/open-api/index.js.map +1 -1
  12. package/dist/cmds/project/index.d.ts.map +1 -1
  13. package/dist/cmds/project/index.js +2 -5
  14. package/dist/cmds/project/index.js.map +1 -1
  15. package/dist/cmds/proxies/index.d.ts +4 -4
  16. package/dist/cmds/proxies/index.d.ts.map +1 -1
  17. package/dist/cmds/proxies/index.js +6 -10
  18. package/dist/cmds/proxies/index.js.map +1 -1
  19. package/dist/cmds/source/index.d.ts.map +1 -1
  20. package/dist/cmds/source/index.js +2 -9
  21. package/dist/cmds/source/index.js.map +1 -1
  22. package/dist/cmds/source/migrate.d.ts +4 -4
  23. package/dist/cmds/source/migrate.d.ts.map +1 -1
  24. package/dist/cmds/source/migrate.js +3 -6
  25. package/dist/cmds/source/migrate.js.map +1 -1
  26. package/dist/cmds/tunnel/index.d.ts.map +1 -1
  27. package/dist/cmds/tunnel/index.js +8 -12
  28. package/dist/cmds/tunnel/index.js.map +1 -1
  29. package/dist/cmds/tunnel/services/index.d.ts.map +1 -1
  30. package/dist/cmds/tunnel/services/index.js +2 -5
  31. package/dist/cmds/tunnel/services/index.js.map +1 -1
  32. package/dist/cmds/variable/index.d.ts.map +1 -1
  33. package/dist/cmds/variable/index.js +2 -5
  34. package/dist/cmds/variable/index.js.map +1 -1
  35. package/dist/common/handler.d.ts +4 -1
  36. package/dist/common/handler.d.ts.map +1 -1
  37. package/dist/common/handler.js +11 -2
  38. package/dist/common/handler.js.map +1 -1
  39. package/dist/common/middleware/get-environment-param.d.ts.map +1 -1
  40. package/dist/common/middleware/get-environment-param.js +2 -18
  41. package/dist/common/middleware/get-environment-param.js.map +1 -1
  42. package/dist/common/utils/build-environment-prompt-choices.d.ts +13 -0
  43. package/dist/common/utils/build-environment-prompt-choices.d.ts.map +1 -0
  44. package/dist/common/utils/build-environment-prompt-choices.js +66 -0
  45. package/dist/common/utils/build-environment-prompt-choices.js.map +1 -0
  46. package/dist/common/utils/build-environment-prompt-choices.test.d.ts +2 -0
  47. package/dist/common/utils/build-environment-prompt-choices.test.d.ts.map +1 -0
  48. package/dist/common/utils/build-environment-prompt-choices.test.js +97 -0
  49. package/dist/common/utils/build-environment-prompt-choices.test.js.map +1 -0
  50. package/dist/common/utils/pretty-print-environment-prompt.d.ts +1 -4
  51. package/dist/common/utils/pretty-print-environment-prompt.d.ts.map +1 -1
  52. package/dist/common/utils/pretty-print-environment-prompt.js +3 -8
  53. package/dist/common/utils/pretty-print-environment-prompt.js.map +1 -1
  54. package/dist/common/utils/pretty-print-environment-prompt.test.js +15 -17
  55. package/dist/common/utils/pretty-print-environment-prompt.test.js.map +1 -1
  56. package/dist/common/utils/sort-environments-for-prompt.d.ts +5 -0
  57. package/dist/common/utils/sort-environments-for-prompt.d.ts.map +1 -0
  58. package/dist/common/utils/sort-environments-for-prompt.js +27 -0
  59. package/dist/common/utils/sort-environments-for-prompt.js.map +1 -0
  60. package/dist/common/utils/sort-environments-for-prompt.test.d.ts +2 -0
  61. package/dist/common/utils/sort-environments-for-prompt.test.d.ts.map +1 -0
  62. package/dist/common/utils/sort-environments-for-prompt.test.js +82 -0
  63. package/dist/common/utils/sort-environments-for-prompt.test.js.map +1 -0
  64. package/dist/tsconfig.tsbuildinfo +1 -1
  65. package/node_modules/@fastify/proxy-addr/node_modules/ipaddr.js/README.md +1 -5
  66. package/node_modules/@fastify/proxy-addr/node_modules/ipaddr.js/ipaddr.min.js +1 -1
  67. package/node_modules/@fastify/proxy-addr/node_modules/ipaddr.js/lib/ipaddr.js +21 -6
  68. package/node_modules/@fastify/proxy-addr/node_modules/ipaddr.js/package.json +1 -1
  69. package/node_modules/@zuplo/core/index.minified.js +141 -137
  70. package/node_modules/@zuplo/core/package.json +1 -1
  71. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/.github/workflows/ci.yml +1 -1
  72. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/.github/workflows/lock-threads.yml +19 -0
  73. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/LICENSE +1 -3
  74. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/benchmark/bench-cmp-lib.js +60 -44
  75. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/index.js +2 -2
  76. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/package.json +7 -7
  77. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/anyof.test.js +20 -0
  78. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/array.test.js +22 -0
  79. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/debug-mode.test.js +21 -0
  80. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/if-then-else.test.js +72 -0
  81. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/invalidSchema.test.js +20 -0
  82. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/issue-836.test.js +183 -0
  83. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/json-add-comma.test.js +57 -57
  84. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/oneof.test.js +20 -0
  85. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/ref.test.js +31 -0
  86. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/test/typebox.test.js +1 -1
  87. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/types/{index.test-d.ts → index.tst.ts} +17 -17
  88. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.d.ts.map +1 -0
  89. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.js.map +1 -0
  90. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.d.ts +5 -0
  91. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.js +7 -0
  92. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.d.ts +1380 -0
  93. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -0
  94. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.js +1686 -0
  95. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -0
  96. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.min.js +2 -0
  97. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +7 -0
  98. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts +12 -0
  99. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts.map +1 -0
  100. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/perf.js +11 -0
  101. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/browser/perf.js.map +1 -0
  102. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.cjs.map +1 -0
  103. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.d.cts.map +1 -0
  104. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts +2 -2
  105. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +4 -7
  106. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.d.ts +2 -3
  107. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
  108. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.js +10 -16
  109. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
  110. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  111. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/index.min.js.map +4 -4
  112. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.d.ts.map +1 -0
  113. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.js.map +1 -0
  114. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.d.ts +5 -0
  115. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.js +9 -0
  116. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.d.ts +1380 -0
  117. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -0
  118. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.js +1686 -0
  119. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -0
  120. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.min.js +2 -0
  121. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +7 -0
  122. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/perf.d.ts +12 -0
  123. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/perf.d.ts.map +1 -0
  124. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/perf.js +11 -0
  125. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/node/perf.js.map +1 -0
  126. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/perf.d.ts +12 -0
  127. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/perf.d.ts.map +1 -0
  128. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/perf.js +11 -0
  129. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/perf.js.map +1 -0
  130. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.ts.map +1 -0
  131. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.js.map +1 -0
  132. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.d.ts +1 -1
  133. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +1 -1
  134. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.d.ts +2 -3
  135. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
  136. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.js +9 -15
  137. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
  138. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.min.js +1 -1
  139. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/index.min.js.map +4 -4
  140. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/perf.d.ts +12 -0
  141. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/perf.d.ts.map +1 -0
  142. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/perf.js +8 -0
  143. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/perf.js.map +1 -0
  144. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.d.mts.map +1 -1
  145. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.mjs.map +1 -1
  146. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.d.ts +2 -3
  147. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
  148. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.js +9 -15
  149. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.js.map +1 -1
  150. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  151. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/index.min.js.map +4 -4
  152. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.ts.map +1 -0
  153. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.js.map +1 -0
  154. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel.d.ts +1 -1
  155. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +2 -3
  156. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.d.ts +2 -3
  157. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
  158. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.js +9 -15
  159. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
  160. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.min.js +1 -1
  161. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/index.min.js.map +4 -4
  162. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/perf.d.ts +12 -0
  163. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/perf.d.ts.map +1 -0
  164. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/perf.js +8 -0
  165. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/perf.js.map +1 -0
  166. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/perf.d.ts +12 -0
  167. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/perf.d.ts.map +1 -0
  168. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/perf.js +8 -0
  169. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/perf.js.map +1 -0
  170. package/node_modules/@zuplo/editor/node_modules/lru-cache/package.json +44 -16
  171. package/node_modules/@zuplo/graphql/package.json +1 -1
  172. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  173. package/node_modules/@zuplo/otel/package.json +1 -1
  174. package/node_modules/@zuplo/runtime/out/esm/index.js +54 -54
  175. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  176. package/node_modules/@zuplo/runtime/out/types/index.d.ts +4 -0
  177. package/node_modules/@zuplo/runtime/package.json +1 -1
  178. package/node_modules/axios/CHANGELOG.md +32 -6
  179. package/node_modules/axios/README.md +356 -20
  180. package/node_modules/axios/dist/axios.js +1389 -1071
  181. package/node_modules/axios/dist/axios.js.map +1 -1
  182. package/node_modules/axios/dist/axios.min.js +3 -3
  183. package/node_modules/axios/dist/axios.min.js.map +1 -1
  184. package/node_modules/axios/dist/browser/axios.cjs +1486 -1123
  185. package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  186. package/node_modules/axios/dist/esm/axios.js +1488 -1124
  187. package/node_modules/axios/dist/esm/axios.js.map +1 -1
  188. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  189. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  190. package/node_modules/axios/dist/node/axios.cjs +1230 -871
  191. package/node_modules/axios/dist/node/axios.cjs.map +1 -1
  192. package/node_modules/axios/index.d.cts +25 -13
  193. package/node_modules/axios/index.d.ts +21 -4
  194. package/node_modules/axios/index.js +2 -0
  195. package/node_modules/axios/lib/adapters/adapters.js +4 -2
  196. package/node_modules/axios/lib/adapters/fetch.js +126 -10
  197. package/node_modules/axios/lib/adapters/http.js +178 -59
  198. package/node_modules/axios/lib/adapters/xhr.js +6 -2
  199. package/node_modules/axios/lib/core/Axios.js +7 -3
  200. package/node_modules/axios/lib/core/AxiosError.js +86 -1
  201. package/node_modules/axios/lib/core/AxiosHeaders.js +3 -0
  202. package/node_modules/axios/lib/core/dispatchRequest.js +19 -7
  203. package/node_modules/axios/lib/core/mergeConfig.js +6 -3
  204. package/node_modules/axios/lib/core/settle.js +7 -11
  205. package/node_modules/axios/lib/defaults/index.js +1 -1
  206. package/node_modules/axios/lib/env/data.js +1 -1
  207. package/node_modules/axios/lib/helpers/buildURL.js +1 -1
  208. package/node_modules/axios/lib/helpers/cookies.js +14 -2
  209. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +28 -1
  210. package/node_modules/axios/lib/helpers/formDataToStream.js +1 -1
  211. package/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
  212. package/node_modules/axios/lib/helpers/resolveConfig.js +33 -17
  213. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +26 -1
  214. package/node_modules/axios/lib/helpers/validator.js +1 -1
  215. package/node_modules/axios/lib/utils.js +27 -15
  216. package/node_modules/axios/package.json +17 -24
  217. package/node_modules/fast-uri/.github/workflows/ci.yml +12 -7
  218. package/node_modules/fast-uri/.github/workflows/lock-threads.yml +19 -0
  219. package/node_modules/fast-uri/.github/workflows/package-manager-ci.yml +1 -1
  220. package/node_modules/fast-uri/LICENSE +1 -3
  221. package/node_modules/fast-uri/README.md +13 -4
  222. package/node_modules/fast-uri/index.js +90 -24
  223. package/node_modules/fast-uri/lib/utils.js +129 -22
  224. package/node_modules/fast-uri/package.json +3 -4
  225. package/node_modules/fast-uri/test/equal.test.js +9 -0
  226. package/node_modules/fast-uri/test/parse.test.js +5 -0
  227. package/node_modules/fast-uri/test/resolve.test.js +9 -0
  228. package/node_modules/fast-uri/test/security-normalization.test.js +39 -0
  229. package/node_modules/fast-uri/test/security.test.js +133 -0
  230. package/node_modules/is-core-module/CHANGELOG.md +244 -113
  231. package/node_modules/is-core-module/README.md +1 -1
  232. package/node_modules/is-core-module/core.json +12 -12
  233. package/node_modules/is-core-module/package.json +5 -5
  234. package/node_modules/is-core-module/test/index.js +101 -0
  235. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.d.ts.map +1 -0
  236. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.js.map +1 -0
  237. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.d.ts +5 -0
  238. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.js +7 -0
  239. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.d.ts +1380 -0
  240. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -0
  241. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.js +1686 -0
  242. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -0
  243. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.min.js +2 -0
  244. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +7 -0
  245. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts +12 -0
  246. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts.map +1 -0
  247. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/perf.js +11 -0
  248. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/browser/perf.js.map +1 -0
  249. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.cjs.map +1 -0
  250. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.d.cts.map +1 -0
  251. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts +2 -2
  252. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +4 -7
  253. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.d.ts +2 -3
  254. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
  255. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.js +10 -16
  256. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
  257. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  258. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/index.min.js.map +4 -4
  259. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.d.ts.map +1 -0
  260. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.js.map +1 -0
  261. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.d.ts +5 -0
  262. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.js +9 -0
  263. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.d.ts +1380 -0
  264. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -0
  265. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.js +1686 -0
  266. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -0
  267. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.min.js +2 -0
  268. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +7 -0
  269. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/perf.d.ts +12 -0
  270. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/perf.d.ts.map +1 -0
  271. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/perf.js +11 -0
  272. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/node/perf.js.map +1 -0
  273. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/perf.d.ts +12 -0
  274. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/perf.d.ts.map +1 -0
  275. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/perf.js +11 -0
  276. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/perf.js.map +1 -0
  277. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.ts.map +1 -0
  278. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.js.map +1 -0
  279. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.d.ts +1 -1
  280. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +1 -1
  281. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.d.ts +2 -3
  282. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
  283. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.js +9 -15
  284. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
  285. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.min.js +1 -1
  286. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/index.min.js.map +4 -4
  287. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/perf.d.ts +12 -0
  288. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/perf.d.ts.map +1 -0
  289. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/perf.js +8 -0
  290. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/perf.js.map +1 -0
  291. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.d.mts.map +1 -1
  292. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.mjs.map +1 -1
  293. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.d.ts +2 -3
  294. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
  295. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.js +9 -15
  296. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.js.map +1 -1
  297. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  298. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/index.min.js.map +4 -4
  299. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.ts.map +1 -0
  300. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.js.map +1 -0
  301. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel.d.ts +1 -1
  302. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +2 -3
  303. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.d.ts +2 -3
  304. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
  305. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.js +9 -15
  306. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
  307. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.min.js +1 -1
  308. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/index.min.js.map +4 -4
  309. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/perf.d.ts +12 -0
  310. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/perf.d.ts.map +1 -0
  311. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/perf.js +8 -0
  312. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/perf.js.map +1 -0
  313. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/perf.d.ts +12 -0
  314. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/perf.d.ts.map +1 -0
  315. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/perf.js +8 -0
  316. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/perf.js.map +1 -0
  317. package/node_modules/rimraf/node_modules/lru-cache/package.json +44 -16
  318. package/package.json +6 -6
  319. package/node_modules/@zuplo/editor/node_modules/fast-json-stringify/.github/stale.yml +0 -21
  320. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts.map +0 -1
  321. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js.map +0 -1
  322. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.mts.map +0 -1
  323. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.mjs.map +0 -1
  324. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.mts.map +0 -1
  325. package/node_modules/@zuplo/editor/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.mjs.map +0 -1
  326. package/node_modules/fast-uri/.github/.stale.yml +0 -21
  327. package/node_modules/fast-uri/.github/tests_checker.yml +0 -8
  328. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts.map +0 -1
  329. package/node_modules/rimraf/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js.map +0 -1
  330. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.mts.map +0 -1
  331. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.mjs.map +0 -1
  332. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.mts.map +0 -1
  333. package/node_modules/rimraf/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.mjs.map +0 -1
@@ -4,7 +4,7 @@ import { logger } from "../logger.js";
4
4
  import { printCriticalFailureToConsoleAndExit, textOrJson } from "../output.js";
5
5
  import settings from "../settings.js";
6
6
  import { isInteractiveTerminal } from "../terminal.js";
7
- import { prettyPrintEnvironmentPrompt } from "../utils/pretty-print-environment-prompt.js";
7
+ import { buildEnvironmentPromptChoices } from "../utils/build-environment-prompt-choices.js";
8
8
  export async function fetchEnvironment(argv) {
9
9
  if (argv.environment && typeof argv.environment === "string") {
10
10
  return;
@@ -69,26 +69,10 @@ export async function fetchEnvironment(argv) {
69
69
  if (environmentJsonFromDeveloperAPI.data.length === 0) {
70
70
  await printCriticalFailureToConsoleAndExit("Error: You don't have any environments for this project to link against. First, deploy this project using zuplo deploy and then link against that.");
71
71
  }
72
- const environments = environmentJsonFromDeveloperAPI.data
73
- .map((env) => {
74
- return {
75
- [prettyPrintEnvironmentPrompt(env, false)]: env.name,
76
- };
77
- })
78
- .reduce((acc, curr) => {
79
- return { ...acc, ...curr };
80
- });
81
72
  try {
82
73
  argv.environment = await select({
83
74
  message: "Select the environment",
84
- choices: Object.entries(environments)
85
- .map(([key, value]) => {
86
- return {
87
- name: key,
88
- value: value,
89
- };
90
- })
91
- .sort((a, b) => a.name.localeCompare(b.name)),
75
+ choices: buildEnvironmentPromptChoices(environmentJsonFromDeveloperAPI.data),
92
76
  });
93
77
  }
94
78
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"get-environment-param.js","sourceRoot":"","sources":["../../../src/common/middleware/get-environment-param.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,oCAAoC,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM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,CAAC,CAAC,CAAC;gBAC9C,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC;oBACjC,IAAI;oBACJ,YAAY;oBACZ,YAAY,CAAC,OAAO;iBACrB,CAAC,CAAC;gBACH,IAAI,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACxB,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBACtC,MAAM,iBAAiB,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;oBAChE,IAAI,CAAC,iBAAiB,EAAE,CAAC;wBACvB,MAAM,IAAI,KAAK,CACb,qDAAqD,CACtD,CAAC;oBACJ,CAAC;oBACD,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,CAAC;gBACpC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { select } from \"@inquirer/prompts\";\nimport { simpleGit } from \"simple-git\";\nimport { Environment } from \"../api/lib.js\";\nimport { logger } from \"../logger.js\";\nimport { printCriticalFailureToConsoleAndExit, textOrJson } from \"../output.js\";\nimport settings from \"../settings.js\";\nimport { isInteractiveTerminal } from \"../terminal.js\";\nimport { prettyPrintEnvironmentPrompt } from \"../utils/pretty-print-environment-prompt.js\";\n\n/**\n * Middleware that ensures a environment is provided in argv. If not, prompts the user.\n * Note: must be called after get account param and get project param.\n */\nexport async function fetchEnvironment(argv: { [key: string]: unknown }) {\n if (argv.environment && typeof argv.environment === \"string\") {\n return;\n }\n\n if (!argv.account || typeof argv.account !== \"string\") {\n throw new Error(\"Invalid state: account is not set.\");\n }\n if (!argv.project || typeof argv.project !== \"string\") {\n throw new Error(\"Invalid state: project is not set.\");\n }\n\n // 1. Check if the dir argument is set and if we are in a git repository\n // If we are, get the current branch and use that as the environment name.\n const branch = await getGitBranch(argv);\n\n if (branch && !argv[\"fetch-environments\"]) {\n // If the branch is set, use that as the environment name\n argv.environment = branch;\n } else {\n // In non-interactive environments, --environment must be passed explicitly.\n // We check here, before the API calls, to avoid unnecessary network round-trips.\n if (!isInteractiveTerminal()) {\n await printCriticalFailureToConsoleAndExit(\n \"Error: --environment is required in non-interactive environments (e.g. CI/CD).\\nUse the --environment flag to specify an environment name.\"\n );\n return;\n }\n\n const baseUrl = `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/environments`;\n\n const queryParams: Record<string, string> = {\n // This is safe because of the previous middleware where we set the account and project.\n accountName: argv.account!,\n projectName: argv.project!,\n };\n\n // Create the query string using URLSearchParams\n const url = new URL(baseUrl);\n url.search = new URLSearchParams(queryParams).toString();\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n // biome-ignore lint/style/useNamingConvention: External API property\n Authorization: `Bearer ${argv.authToken}`,\n },\n });\n\n if (response.ok) {\n const environmentJsonFromDeveloperAPI = (await response.json()) as {\n data: Environment[];\n };\n\n // Also fetch working-copy deployments, which are not returned by the\n // /v1/environments endpoint (it only returns self-managed and deployer-owned environments).\n const deploymentsUrl = new URL(\n `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${argv.account}/projects/${argv.project}/deployments`\n );\n const deploymentsResponse = await fetch(deploymentsUrl, {\n method: \"GET\",\n headers: {\n // biome-ignore lint/style/useNamingConvention: External API property\n Authorization: `Bearer ${argv.authToken}`,\n },\n });\n\n if (deploymentsResponse.ok) {\n const { data: deployments } = (await deploymentsResponse.json()) as {\n data: Array<{\n name: string;\n accountName: string;\n projectName: string;\n branchName: string;\n environmentType: string;\n createdOn: string;\n }>;\n };\n\n const workingCopies: Environment[] = deployments\n .filter((d) => d.environmentType === \"WORKING_COPY\")\n .map((d) => ({\n name: d.name,\n accountName: d.accountName,\n projectName: d.projectName,\n branchName: d.branchName,\n environmentType: \"working_copy\",\n createdOn: new Date(d.createdOn),\n }));\n\n environmentJsonFromDeveloperAPI.data.push(...workingCopies);\n } else {\n logger.debug(\n {\n status: deploymentsResponse.status,\n statusText: deploymentsResponse.statusText,\n },\n \"Failed to fetch working-copy deployments for project\"\n );\n }\n\n if (environmentJsonFromDeveloperAPI.data.length === 0) {\n await printCriticalFailureToConsoleAndExit(\n \"Error: You don't have any environments for this project to link against. First, deploy this project using zuplo deploy and then link against that.\"\n );\n }\n\n // TODO: This logic doesn't work for working copies anymore due to\n // https://github.com/zuplo/core/blob/main/apps/tenant-api/prisma/migrations/v2_20250711155424_add-working-copy-main-check/migration.sql\n // and https://github.com/zuplo/core/blob/6595268b9d2e5edfb3a20cbb086ccd363cf115f9/apps/tenant-api/src/routes/managed-dedicated/environments.ts#L96-L102\n // Leaving this logic commented out for now since we may want to bring it back.\n // let numDevelopmentEnvironments =\n // environmentJsonFromDeveloperAPI.data.filter((env) => {\n // return env.environmentType === \"development\";\n // }).length;\n\n // if (numDevelopmentEnvironments <= 0) {\n // // Create one on-the-fly\n // const createDevelopmenEnvironmentResponse = await fetch(`${baseUrl}`, {\n // method: \"POST\",\n // headers: {\n // authorization: `Bearer ${argv.authToken}`,\n // \"Content-Type\": \"application/json\",\n // },\n // body: JSON.stringify({\n // accountName: argv.account,\n // projectName: argv.project,\n // environmentType: \"development\",\n // }),\n // });\n\n // if (!createDevelopmenEnvironmentResponse.ok) {\n // console.log(await createDevelopmenEnvironmentResponse.json());\n // logger.debug(\n // {\n // status: createDevelopmenEnvironmentResponse.status,\n // statusText: createDevelopmenEnvironmentResponse.statusText,\n // },\n // \"Failed to create a new instance of development environment\"\n // );\n // await printCriticalFailureToConsoleAndExit(\n // \"Failed to create a new development environment. Please try again later.\"\n // );\n // }\n\n // numDevelopmentEnvironments++;\n\n // // Re-fetch\n // const updatedResponse = await fetch(url, {\n // headers: {\n // authorization: `Bearer ${argv.authToken}`,\n // },\n // });\n\n // environmentJsonFromDeveloperAPI = (await updatedResponse.json()) as {\n // data: Environment[];\n // };\n // }\n\n const environments = environmentJsonFromDeveloperAPI.data\n .map((env) => {\n return {\n // Pass false: we always show the real env name in the selection list,\n // never collapse development instances to \"Default for local development\".\n [prettyPrintEnvironmentPrompt(env, false)]: env.name,\n };\n })\n .reduce((acc, curr) => {\n // biome-ignore lint/performance/noAccumulatingSpread: Migrated from ESLint\n return { ...acc, ...curr };\n });\n\n try {\n argv.environment = await select({\n message: \"Select the environment\",\n choices: Object.entries(environments)\n .map(([key, value]) => {\n return {\n name: key,\n value: value,\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name)),\n });\n } catch (error) {\n if (error.isTtyError || error.name === \"ExitPromptError\") {\n process.exit(1);\n }\n logger.trace(\"Failed to select environment\", error);\n process.exit(1);\n }\n } else {\n logger.trace(\n {\n status: response.status,\n statusText: response.statusText,\n response: textOrJson(await response.text()),\n },\n \"Failed to request environments for project\"\n );\n await printCriticalFailureToConsoleAndExit(\n \"Error: Failed to request environments for the project.\"\n );\n }\n }\n}\nasync function getGitBranch(argv: { [key: string]: unknown }) {\n let branch: string | undefined;\n const dir = argv.dir;\n if (dir && typeof dir === \"string\") {\n const git = simpleGit({ baseDir: dir });\n const isGitRepo = await git.checkIsRepo();\n if (isGitRepo) {\n // Get the current branch from Git\n const status = await git.status();\n if (!status.current) {\n throw new Error(\"Invalid state: Directory is in detached head state.\");\n }\n branch = status.current.trim();\n\n // @NOTE - gitlab returns HEAD as the current branch when running git.status()\n // https://forum.gitlab.com/t/why-i-cant-get-the-branch-name/72462/6\n if (branch === \"HEAD\") {\n // Fetch remote branches to ensure the latest information\n await git.fetch([\"--all\"]);\n\n const branchCommit = await git.branch([\"-a\"]);\n const branchRef = await git.branch([\n \"-r\",\n \"--contains\",\n branchCommit.current,\n ]);\n if (branchRef?.all?.[0]) {\n const originBranch = branchRef.all[0];\n const cleanOriginBranch = originBranch.replace(/^origin\\//, \"\");\n if (!cleanOriginBranch) {\n throw new Error(\n \"Invalid state: Directory is in detached head state.\"\n );\n }\n branch = cleanOriginBranch.trim();\n }\n }\n }\n }\n return branch;\n}\n"]}
1
+ {"version":3,"file":"get-environ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,MAAM,iBAAiB,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;oBAChE,IAAI,CAAC,iBAAiB,EAAE,CAAC;wBACvB,MAAM,IAAI,KAAK,CACb,qDAAqD,CACtD,CAAC;oBACJ,CAAC;oBACD,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,CAAC;gBACpC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { select } from \"@inquirer/prompts\";\nimport { simpleGit } from \"simple-git\";\nimport { Environment } from \"../api/lib.js\";\nimport { logger } from \"../logger.js\";\nimport { printCriticalFailureToConsoleAndExit, textOrJson } from \"../output.js\";\nimport settings from \"../settings.js\";\nimport { isInteractiveTerminal } from \"../terminal.js\";\nimport { buildEnvironmentPromptChoices } from \"../utils/build-environment-prompt-choices.js\";\n\n/**\n * Middleware that ensures a environment is provided in argv. If not, prompts the user.\n * Note: must be called after get account param and get project param.\n */\nexport async function fetchEnvironment(argv: { [key: string]: unknown }) {\n if (argv.environment && typeof argv.environment === \"string\") {\n return;\n }\n\n if (!argv.account || typeof argv.account !== \"string\") {\n throw new Error(\"Invalid state: account is not set.\");\n }\n if (!argv.project || typeof argv.project !== \"string\") {\n throw new Error(\"Invalid state: project is not set.\");\n }\n\n // 1. Check if the dir argument is set and if we are in a git repository\n // If we are, get the current branch and use that as the environment name.\n const branch = await getGitBranch(argv);\n\n if (branch && !argv[\"fetch-environments\"]) {\n // If the branch is set, use that as the environment name\n argv.environment = branch;\n } else {\n // In non-interactive environments, --environment must be passed explicitly.\n // We check here, before the API calls, to avoid unnecessary network round-trips.\n if (!isInteractiveTerminal()) {\n await printCriticalFailureToConsoleAndExit(\n \"Error: --environment is required in non-interactive environments (e.g. CI/CD).\\nUse the --environment flag to specify an environment name.\"\n );\n return;\n }\n\n const baseUrl = `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/environments`;\n\n const queryParams: Record<string, string> = {\n // This is safe because of the previous middleware where we set the account and project.\n accountName: argv.account!,\n projectName: argv.project!,\n };\n\n // Create the query string using URLSearchParams\n const url = new URL(baseUrl);\n url.search = new URLSearchParams(queryParams).toString();\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n // biome-ignore lint/style/useNamingConvention: External API property\n Authorization: `Bearer ${argv.authToken}`,\n },\n });\n\n if (response.ok) {\n const environmentJsonFromDeveloperAPI = (await response.json()) as {\n data: Environment[];\n };\n\n // Also fetch working-copy deployments, which are not returned by the\n // /v1/environments endpoint (it only returns self-managed and deployer-owned environments).\n const deploymentsUrl = new URL(\n `${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${argv.account}/projects/${argv.project}/deployments`\n );\n const deploymentsResponse = await fetch(deploymentsUrl, {\n method: \"GET\",\n headers: {\n // biome-ignore lint/style/useNamingConvention: External API property\n Authorization: `Bearer ${argv.authToken}`,\n },\n });\n\n if (deploymentsResponse.ok) {\n const { data: deployments } = (await deploymentsResponse.json()) as {\n data: Array<{\n name: string;\n accountName: string;\n projectName: string;\n branchName: string;\n environmentType: string;\n createdOn: string;\n }>;\n };\n\n const workingCopies: Environment[] = deployments\n .filter((d) => d.environmentType === \"WORKING_COPY\")\n .map((d) => ({\n name: d.name,\n accountName: d.accountName,\n projectName: d.projectName,\n branchName: d.branchName,\n environmentType: \"working_copy\",\n createdOn: new Date(d.createdOn),\n }));\n\n environmentJsonFromDeveloperAPI.data.push(...workingCopies);\n } else {\n logger.debug(\n {\n status: deploymentsResponse.status,\n statusText: deploymentsResponse.statusText,\n },\n \"Failed to fetch working-copy deployments for project\"\n );\n }\n\n if (environmentJsonFromDeveloperAPI.data.length === 0) {\n await printCriticalFailureToConsoleAndExit(\n \"Error: You don't have any environments for this project to link against. First, deploy this project using zuplo deploy and then link against that.\"\n );\n }\n\n // TODO: This logic doesn't work for working copies anymore due to\n // https://github.com/zuplo/core/blob/main/apps/tenant-api/prisma/migrations/v2_20250711155424_add-working-copy-main-check/migration.sql\n // and https://github.com/zuplo/core/blob/6595268b9d2e5edfb3a20cbb086ccd363cf115f9/apps/tenant-api/src/routes/managed-dedicated/environments.ts#L96-L102\n // Leaving this logic commented out for now since we may want to bring it back.\n // let numDevelopmentEnvironments =\n // environmentJsonFromDeveloperAPI.data.filter((env) => {\n // return env.environmentType === \"development\";\n // }).length;\n\n // if (numDevelopmentEnvironments <= 0) {\n // // Create one on-the-fly\n // const createDevelopmenEnvironmentResponse = await fetch(`${baseUrl}`, {\n // method: \"POST\",\n // headers: {\n // authorization: `Bearer ${argv.authToken}`,\n // \"Content-Type\": \"application/json\",\n // },\n // body: JSON.stringify({\n // accountName: argv.account,\n // projectName: argv.project,\n // environmentType: \"development\",\n // }),\n // });\n\n // if (!createDevelopmenEnvironmentResponse.ok) {\n // console.log(await createDevelopmenEnvironmentResponse.json());\n // logger.debug(\n // {\n // status: createDevelopmenEnvironmentResponse.status,\n // statusText: createDevelopmenEnvironmentResponse.statusText,\n // },\n // \"Failed to create a new instance of development environment\"\n // );\n // await printCriticalFailureToConsoleAndExit(\n // \"Failed to create a new development environment. Please try again later.\"\n // );\n // }\n\n // numDevelopmentEnvironments++;\n\n // // Re-fetch\n // const updatedResponse = await fetch(url, {\n // headers: {\n // authorization: `Bearer ${argv.authToken}`,\n // },\n // });\n\n // environmentJsonFromDeveloperAPI = (await updatedResponse.json()) as {\n // data: Environment[];\n // };\n // }\n\n try {\n argv.environment = await select({\n message: \"Select the environment\",\n choices: buildEnvironmentPromptChoices(\n environmentJsonFromDeveloperAPI.data\n ),\n });\n } catch (error) {\n if (error.isTtyError || error.name === \"ExitPromptError\") {\n process.exit(1);\n }\n logger.trace(\"Failed to select environment\", error);\n process.exit(1);\n }\n } else {\n logger.trace(\n {\n status: response.status,\n statusText: response.statusText,\n response: textOrJson(await response.text()),\n },\n \"Failed to request environments for project\"\n );\n await printCriticalFailureToConsoleAndExit(\n \"Error: Failed to request environments for the project.\"\n );\n }\n }\n}\nasync function getGitBranch(argv: { [key: string]: unknown }) {\n let branch: string | undefined;\n const dir = argv.dir;\n if (dir && typeof dir === \"string\") {\n const git = simpleGit({ baseDir: dir });\n const isGitRepo = await git.checkIsRepo();\n if (isGitRepo) {\n // Get the current branch from Git\n const status = await git.status();\n if (!status.current) {\n throw new Error(\"Invalid state: Directory is in detached head state.\");\n }\n branch = status.current.trim();\n\n // @NOTE - gitlab returns HEAD as the current branch when running git.status()\n // https://forum.gitlab.com/t/why-i-cant-get-the-branch-name/72462/6\n if (branch === \"HEAD\") {\n // Fetch remote branches to ensure the latest information\n await git.fetch([\"--all\"]);\n\n const branchCommit = await git.branch([\"-a\"]);\n const branchRef = await git.branch([\n \"-r\",\n \"--contains\",\n branchCommit.current,\n ]);\n if (branchRef?.all?.[0]) {\n const originBranch = branchRef.all[0];\n const cleanOriginBranch = originBranch.replace(/^origin\\//, \"\");\n if (!cleanOriginBranch) {\n throw new Error(\n \"Invalid state: Directory is in detached head state.\"\n );\n }\n branch = cleanOriginBranch.trim();\n }\n }\n }\n }\n return branch;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { Separator } from "@inquirer/prompts";
2
+ import { Environment } from "../api/lib.js";
3
+ interface EnvironmentChoice {
4
+ name: string;
5
+ value: string;
6
+ description?: string;
7
+ }
8
+ export type EnvironmentPromptChoice = EnvironmentChoice | Separator;
9
+ export declare function buildEnvironmentPromptChoices(
10
+ envs: Environment[]
11
+ ): EnvironmentPromptChoice[];
12
+ export {};
13
+ //# sourceMappingURL=build-environment-prompt-choices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-environment-prompt-choices.d.ts","sourceRoot":"","sources":["../../../src/common/utils/build-environment-prompt-choices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAiBpE,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,WAAW,EAAE,GAClB,uBAAuB,EAAE,CAoE3B"}
@@ -0,0 +1,66 @@
1
+ import { Separator } from "@inquirer/prompts";
2
+ import { formatEnvironmentTypeLabel } from "./format-environment-type.js";
3
+ import { prettyPrintEnvironmentPrompt } from "./pretty-print-environment-prompt.js";
4
+ import { sortEnvironmentsForPrompt } from "./sort-environments-for-prompt.js";
5
+ export function buildEnvironmentPromptChoices(envs) {
6
+ const sorted = sortEnvironmentsForPrompt(envs);
7
+ const buckets = {
8
+ "working-copy": [],
9
+ preview: [],
10
+ production: [],
11
+ };
12
+ const other = [];
13
+ for (const env of sorted) {
14
+ const type = formatEnvironmentTypeLabel(env.environmentType);
15
+ if (type === "working-copy" ||
16
+ type === "preview" ||
17
+ type === "production") {
18
+ buckets[type].push(env);
19
+ }
20
+ else {
21
+ other.push(env);
22
+ }
23
+ }
24
+ const choices = [];
25
+ if (buckets["working-copy"].length > 0) {
26
+ choices.push(new Separator("── Working copy ──"));
27
+ for (const env of buckets["working-copy"]) {
28
+ choices.push({
29
+ name: prettyPrintEnvironmentPrompt(env),
30
+ value: env.name,
31
+ });
32
+ }
33
+ }
34
+ if (buckets.preview.length > 0) {
35
+ choices.push(new Separator("── Preview ──"));
36
+ for (const env of buckets.preview) {
37
+ choices.push({
38
+ name: prettyPrintEnvironmentPrompt(env),
39
+ value: env.name,
40
+ description: env.name,
41
+ });
42
+ }
43
+ }
44
+ if (buckets.production.length > 0) {
45
+ choices.push(new Separator("── Production ──"));
46
+ for (const env of buckets.production) {
47
+ choices.push({
48
+ name: prettyPrintEnvironmentPrompt(env),
49
+ value: env.name,
50
+ description: env.name,
51
+ });
52
+ }
53
+ }
54
+ if (other.length > 0) {
55
+ choices.push(new Separator("── Other ──"));
56
+ for (const env of other) {
57
+ choices.push({
58
+ name: prettyPrintEnvironmentPrompt(env),
59
+ value: env.name,
60
+ description: env.name,
61
+ });
62
+ }
63
+ }
64
+ return choices;
65
+ }
66
+ //# sourceMappingURL=build-environment-prompt-choices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-environment-prompt-choices.js","sourceRoot":"","sources":["../../../src/common/utils/build-environment-prompt-choices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAyB9E,MAAM,UAAU,6BAA6B,CAC3C,IAAmB;IAEnB,MAAM,MAAM,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAE/C,MAAM,OAAO,GAGT;QACF,cAAc,EAAE,EAAE;QAClB,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,EAAE;KACf,CAAC;IACF,MAAM,KAAK,GAAkB,EAAE,CAAC;IAChC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,0BAA0B,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC7D,IACE,IAAI,KAAK,cAAc;YACvB,IAAI,KAAK,SAAS;YAClB,IAAI,KAAK,YAAY,EACrB,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAA8B,EAAE,CAAC;IAE9C,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,CAAC,IA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O,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,4BAA4B,CAAC,GAAG,CAAC;gBACvC,KAAK,EAAE,GAAG,CAAC,IAAI;gBACf,WAAW,EAAE,GAAG,CAAC,IAAI;aACtB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { Separator } from \"@inquirer/prompts\";\nimport { Environment } from \"../api/lib.js\";\nimport { formatEnvironmentTypeLabel } from \"./format-environment-type.js\";\nimport { prettyPrintEnvironmentPrompt } from \"./pretty-print-environment-prompt.js\";\nimport { sortEnvironmentsForPrompt } from \"./sort-environments-for-prompt.js\";\n\ninterface EnvironmentChoice {\n name: string;\n value: string;\n description?: string;\n}\n\nexport type EnvironmentPromptChoice = EnvironmentChoice | Separator;\n\n/**\n * Builds the full inquirer choices array for the environment selection\n * prompt: working-copy first, preview alpha, production last, with a visible\n * `Separator` header introducing each non-empty bucket. The deployment slug\n * (`env.name`) is surfaced via the per-choice `description` field for\n * preview/production rows so it appears only when that row is active —\n * keeping the list itself tight while still letting users disambiguate two\n * envs that share a branch name.\n *\n * Any environment whose normalized type is not `working-copy`, `preview`, or\n * `production` falls into an `Other` bucket placed last. `formatEnvironmentTypeLabel`\n * passes unknown types through unchanged, so without this fallback a future\n * server-side type or a malformed value would silently drop the env from\n * the prompt and make it unselectable.\n */\nexport function buildEnvironmentPromptChoices(\n envs: Environment[]\n): EnvironmentPromptChoice[] {\n const sorted = sortEnvironmentsForPrompt(envs);\n\n const buckets: Record<\n \"working-copy\" | \"preview\" | \"production\",\n Environment[]\n > = {\n \"working-copy\": [],\n preview: [],\n production: [],\n };\n const other: Environment[] = [];\n for (const env of sorted) {\n const type = formatEnvironmentTypeLabel(env.environmentType);\n if (\n type === \"working-copy\" ||\n type === \"preview\" ||\n type === \"production\"\n ) {\n buckets[type].push(env);\n } else {\n other.push(env);\n }\n }\n\n const choices: EnvironmentPromptChoice[] = [];\n\n if (buckets[\"working-copy\"].length > 0) {\n choices.push(new Separator(\"── Working copy ──\"));\n for (const env of buckets[\"working-copy\"]) {\n choices.push({\n name: prettyPrintEnvironmentPrompt(env),\n value: env.name,\n });\n }\n }\n if (buckets.preview.length > 0) {\n choices.push(new Separator(\"── Preview ──\"));\n for (const env of buckets.preview) {\n choices.push({\n name: prettyPrintEnvironmentPrompt(env),\n value: env.name,\n description: env.name,\n });\n }\n }\n if (buckets.production.length > 0) {\n choices.push(new Separator(\"── Production ──\"));\n for (const env of buckets.production) {\n choices.push({\n name: prettyPrintEnvironmentPrompt(env),\n value: env.name,\n description: env.name,\n });\n }\n }\n if (other.length > 0) {\n choices.push(new Separator(\"── Other ──\"));\n for (const env of other) {\n choices.push({\n name: prettyPrintEnvironmentPrompt(env),\n value: env.name,\n description: env.name,\n });\n }\n }\n\n return choices;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=build-environment-prompt-choices.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-environment-prompt-choices.test.d.ts","sourceRoot":"","sources":["../../../src/common/utils/build-environment-prompt-choices.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,97 @@
1
+ import assert from "node:assert";
2
+ import { describe, it } from "node:test";
3
+ import { buildEnvironmentPromptChoices } from "./build-environment-prompt-choices.js";
4
+ function makeEnv(environmentType, name, branchName) {
5
+ return {
6
+ name,
7
+ accountName: "acme",
8
+ projectName: "my-project",
9
+ createdOn: null,
10
+ branchName,
11
+ environmentType,
12
+ };
13
+ }
14
+ function isSeparator(item) {
15
+ return (item != null &&
16
+ typeof item === "object" &&
17
+ item.type === "separator");
18
+ }
19
+ describe("buildEnvironmentPromptChoices", () => {
20
+ it("groups choices with a Separator header per non-empty bucket", () => {
21
+ const envs = [
22
+ makeEnv("preview", "env-test-staging-1", "staging"),
23
+ makeEnv("working_copy", "env-test-main-abc", "main"),
24
+ makeEnv("production", "env-test-prod-xyz", "main"),
25
+ makeEnv("preview", "env-test-feature-2", "feature-auth"),
26
+ ];
27
+ const choices = buildEnvironmentPromptChoices(envs);
28
+ assert.strictEqual(choices.length, 7);
29
+ assert.ok(isSeparator(choices[0]));
30
+ assert.ok(isSeparator(choices[2]));
31
+ assert.ok(isSeparator(choices[5]));
32
+ assert.deepStrictEqual(choices[1], {
33
+ name: "env-test-main-abc — recommended for local development",
34
+ value: "env-test-main-abc",
35
+ });
36
+ assert.deepStrictEqual(choices[3], {
37
+ name: "feature-auth",
38
+ value: "env-test-feature-2",
39
+ description: "env-test-feature-2",
40
+ });
41
+ assert.deepStrictEqual(choices[4], {
42
+ name: "staging",
43
+ value: "env-test-staging-1",
44
+ description: "env-test-staging-1",
45
+ });
46
+ assert.deepStrictEqual(choices[6], {
47
+ name: "main",
48
+ value: "env-test-prod-xyz",
49
+ description: "env-test-prod-xyz",
50
+ });
51
+ });
52
+ it("skips a Separator for an empty bucket", () => {
53
+ const envs = [
54
+ makeEnv("preview", "env-test-staging-1", "staging"),
55
+ makeEnv("preview", "env-test-feature-2", "feature-auth"),
56
+ ];
57
+ const choices = buildEnvironmentPromptChoices(envs);
58
+ const separators = choices.filter(isSeparator);
59
+ assert.strictEqual(separators.length, 1);
60
+ assert.strictEqual(choices.length, 3);
61
+ });
62
+ it("returns an empty array when there are no envs", () => {
63
+ assert.deepStrictEqual(buildEnvironmentPromptChoices([]), []);
64
+ });
65
+ it("normalizes all working-copy type spellings into the working-copy bucket", () => {
66
+ const envs = [
67
+ makeEnv("development", "env-test-main-1", "main"),
68
+ makeEnv("working_copy", "env-test-main-2", "main"),
69
+ makeEnv("working-copy", "env-test-main-3", "main"),
70
+ ];
71
+ const choices = buildEnvironmentPromptChoices(envs);
72
+ assert.strictEqual(choices.length, 4);
73
+ assert.ok(isSeparator(choices[0]));
74
+ });
75
+ it("places envs with unknown environmentType into an 'Other' bucket at the end", () => {
76
+ const envs = [
77
+ makeEnv("preview", "env-test-staging-1", "staging"),
78
+ makeEnv("staging", "env-test-mystery-zzz", "mystery-branch"),
79
+ ];
80
+ const choices = buildEnvironmentPromptChoices(envs);
81
+ assert.strictEqual(choices.length, 4);
82
+ assert.ok(isSeparator(choices[0]));
83
+ assert.deepStrictEqual(choices[1], {
84
+ name: "staging",
85
+ value: "env-test-staging-1",
86
+ description: "env-test-staging-1",
87
+ });
88
+ assert.ok(isSeparator(choices[2]));
89
+ assert.strictEqual(choices[2].separator, "── Other ──");
90
+ assert.deepStrictEqual(choices[3], {
91
+ name: "mystery-branch",
92
+ value: "env-test-mystery-zzz",
93
+ description: "env-test-mystery-zzz",
94
+ });
95
+ });
96
+ });
97
+ //# sourceMappingURL=build-environment-prompt-choices.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-environment-prompt-choices.test.js","sourceRoot":"","sources":["../../../src/common/utils/build-environment-prompt-choices.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAEtF,SAAS,OAAO,CACd,eAA+C,EAC/C,IAAY,EACZ,UAAkB;IAElB,OAAO;QACL,IAAI;QACJ,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,YAAY;QACzB,SAAS,EAAE,IAAI;QACf,UAAU;QACV,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACvB,IAA2B,CAAC,IAAI,KAAK,WAAW,CAClD,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;QACrE,MAAM,IAAI,GAAkB;YAC1B,OAAO,CAAC,SAAS,EAAE,oBAAoB,EAAE,SAAS,CAAC;YACnD,OAAO,CAAC,cAAc,EAAE,m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B,CACjB;SACF,CAAC;QAEF,MAAM,OAAO,GAAG,6BAA6B,CAAC,IAAI,CAAC,CAAC;QAEpD,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACtC,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,eAAe,CACpB,OAAO,CAAC,CAAC,CAA0D,EACnE;YACE,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,oBAAoB;YAC3B,WAAW,EAAE,oBAAoB;SAClC,CACF,CAAC;QACF,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,WAAW,CAAE,OAAO,CAAC,CAAC,CAAe,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QACvE,MAAM,CAAC,eAAe,CACpB,OAAO,CAAC,CAAC,CAA0D,EACnE;YACE,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EAAE,sBAAsB;SACpC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert\";\nimport { describe, it } from \"node:test\";\nimport { Separator } from \"@inquirer/prompts\";\nimport { Environment } from \"../api/lib.js\";\nimport { buildEnvironmentPromptChoices } from \"./build-environment-prompt-choices.js\";\n\nfunction makeEnv(\n environmentType: Environment[\"environmentType\"],\n name: string,\n branchName: string\n): Environment {\n return {\n name,\n accountName: \"acme\",\n projectName: \"my-project\",\n createdOn: null,\n branchName,\n environmentType,\n };\n}\n\nfunction isSeparator(item: unknown): item is Separator {\n return (\n item != null &&\n typeof item === \"object\" &&\n (item as { type?: unknown }).type === \"separator\"\n );\n}\n\ndescribe(\"buildEnvironmentPromptChoices\", () => {\n it(\"groups choices with a Separator header per non-empty bucket\", () => {\n const envs: Environment[] = [\n makeEnv(\"preview\", \"env-test-staging-1\", \"staging\"),\n makeEnv(\"working_copy\", \"env-test-main-abc\", \"main\"),\n makeEnv(\"production\", \"env-test-prod-xyz\", \"main\"),\n makeEnv(\"preview\", \"env-test-feature-2\", \"feature-auth\"),\n ];\n\n const choices = buildEnvironmentPromptChoices(envs);\n\n // Expected shape: [Sep(\"Working copy\"), wc, Sep(\"Preview\"), feat, staging, Sep(\"Production\"), prod]\n assert.strictEqual(choices.length, 7);\n assert.ok(isSeparator(choices[0]));\n assert.ok(isSeparator(choices[2]));\n assert.ok(isSeparator(choices[5]));\n\n // Working copy bucket\n assert.deepStrictEqual(\n choices[1] as { name: string; value: string; description?: string },\n {\n name: \"env-test-main-abc — recommended for local development\",\n value: \"env-test-main-abc\",\n }\n );\n\n // Preview bucket — alpha sorted, branchName as visible name, slug as description\n assert.deepStrictEqual(\n choices[3] as { name: string; value: string; description?: string },\n {\n name: \"feature-auth\",\n value: \"env-test-feature-2\",\n description: \"env-test-feature-2\",\n }\n );\n assert.deepStrictEqual(\n choices[4] as { name: string; value: string; description?: string },\n {\n name: \"staging\",\n value: \"env-test-staging-1\",\n description: \"env-test-staging-1\",\n }\n );\n\n // Production bucket\n assert.deepStrictEqual(\n choices[6] as { name: string; value: string; description?: string },\n {\n name: \"main\",\n value: \"env-test-prod-xyz\",\n description: \"env-test-prod-xyz\",\n }\n );\n });\n\n it(\"skips a Separator for an empty bucket\", () => {\n const envs: Environment[] = [\n makeEnv(\"preview\", \"env-test-staging-1\", \"staging\"),\n makeEnv(\"preview\", \"env-test-feature-2\", \"feature-auth\"),\n ];\n\n const choices = buildEnvironmentPromptChoices(envs);\n\n // Only one Separator — for the preview bucket\n const separators = choices.filter(isSeparator);\n assert.strictEqual(separators.length, 1);\n assert.strictEqual(choices.length, 3);\n });\n\n it(\"returns an empty array when there are no envs\", () => {\n assert.deepStrictEqual(buildEnvironmentPromptChoices([]), []);\n });\n\n it(\"normalizes all working-copy type spellings into the working-copy bucket\", () => {\n const envs: Environment[] = [\n makeEnv(\"development\", \"env-test-main-1\", \"main\"),\n makeEnv(\"working_copy\", \"env-test-main-2\", \"main\"),\n makeEnv(\"working-copy\", \"env-test-main-3\", \"main\"),\n ];\n\n const choices = buildEnvironmentPromptChoices(envs);\n\n // 1 Separator + 3 entries\n assert.strictEqual(choices.length, 4);\n assert.ok(isSeparator(choices[0]));\n });\n\n // Regression: an env whose normalized type isn't one of the three known\n // buckets must still be selectable. Without the \"Other\" fallback bucket a\n // future server-side env type or a malformed `environmentType` value would\n // silently disappear from the prompt.\n it(\"places envs with unknown environmentType into an 'Other' bucket at the end\", () => {\n const envs: Environment[] = [\n makeEnv(\"preview\", \"env-test-staging-1\", \"staging\"),\n // Cast through unknown to bypass the closed TS union — simulates the\n // server returning a value the CLI doesn't yet know about.\n makeEnv(\n \"staging\" as unknown as Environment[\"environmentType\"],\n \"env-test-mystery-zzz\",\n \"mystery-branch\"\n ),\n ];\n\n const choices = buildEnvironmentPromptChoices(envs);\n\n assert.strictEqual(choices.length, 4);\n assert.ok(isSeparator(choices[0]));\n assert.deepStrictEqual(\n choices[1] as { name: string; value: string; description?: string },\n {\n name: \"staging\",\n value: \"env-test-staging-1\",\n description: \"env-test-staging-1\",\n }\n );\n assert.ok(isSeparator(choices[2]));\n assert.strictEqual((choices[2] as Separator).separator, \"── Other ──\");\n assert.deepStrictEqual(\n choices[3] as { name: string; value: string; description?: string },\n {\n name: \"mystery-branch\",\n value: \"env-test-mystery-zzz\",\n description: \"env-test-mystery-zzz\",\n }\n );\n });\n});\n"]}
@@ -1,6 +1,3 @@
1
1
  import { Environment } from "../api/lib.js";
2
- export declare function prettyPrintEnvironmentPrompt(
3
- env: Environment,
4
- hasSingleDevelopmentInstance: boolean
5
- ): string;
2
+ export declare function prettyPrintEnvironmentPrompt(env: Environment): string;
6
3
  //# sourceMappingURL=pretty-print-environment-prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pretty-print-environment-prompt.d.ts","sourceRoot":"","sources":["../../../src/common/utils/pretty-print-environment-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,WAAW,EAChB,4BAA4B,EAAE,OAAO,UAatC"}
1
+ {"version":3,"file":"pretty-print-environment-prompt.d.ts","sourceRoot":"","sources":["../../../src/common/utils/pretty-print-environment-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAoB5C,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAOrE"}
@@ -1,14 +1,9 @@
1
1
  import { formatEnvironmentTypeLabel } from "./format-environment-type.js";
2
- export function prettyPrintEnvironmentPrompt(env, hasSingleDevelopmentInstance) {
2
+ export function prettyPrintEnvironmentPrompt(env) {
3
3
  const environmentType = formatEnvironmentTypeLabel(env.environmentType);
4
- const branchName = env.branchName;
5
- const name = env.name;
6
4
  if (environmentType === "working-copy") {
7
- const displayName = hasSingleDevelopmentInstance
8
- ? "Default for local development"
9
- : name;
10
- return `${displayName} (working-copy)`;
5
+ return `${env.name} recommended for local development`;
11
6
  }
12
- return `${name} (${environmentType}, ${branchName})`;
7
+ return env.branchName || env.name;
13
8
  }
14
9
  //# sourceMappingURL=pretty-print-environment-prompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pretty-print-environment-prompt.js","sourceRoot":"","sources":["../../../src/common/utils/pretty-print-environment-prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,MAAM,UAAU,4BAA4B,CAC1C,GAAgB,EAChB,4BAAqC;IAErC,MAAM,eAAe,GAAG,0BAA0B,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACxE,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;IAClC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAEtB,IAAI,eAAe,KAAK,cAAc,EAAE,CAAC;QACvC,MAAM,WAAW,GAAG,4BAA4B;YAC9C,CAAC,CAAC,+BAA+B;YACjC,CAAC,CAAC,IAAI,CAAC;QACT,OAAO,GAAG,WAAW,iBAAiB,CAAC;IACzC,CAAC;IACD,OAAO,GAAG,IAAI,KAAK,eAAe,KAAK,UAAU,GAAG,CAAC;AACvD,CAAC","sourcesContent":["import { Environment } from \"../api/lib.js\";\nimport { formatEnvironmentTypeLabel } from \"./format-environment-type.js\";\n\nexport function prettyPrintEnvironmentPrompt(\n env: Environment,\n hasSingleDevelopmentInstance: boolean\n) {\n const environmentType = formatEnvironmentTypeLabel(env.environmentType);\n const branchName = env.branchName;\n const name = env.name;\n\n if (environmentType === \"working-copy\") {\n const displayName = hasSingleDevelopmentInstance\n ? \"Default for local development\"\n : name;\n return `${displayName} (working-copy)`;\n }\n return `${name} (${environmentType}, ${branchName})`;\n}\n"]}
1
+ {"version":3,"file":"pretty-print-environment-prompt.js","sourceRoot":"","sources":["../../../src/common/utils/pretty-print-environment-prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAmB1E,MAAM,UAAU,4BAA4B,CAAC,GAAgB;IAC3D,MAAM,eAAe,GAAG,0BAA0B,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAExE,IAAI,eAAe,KAAK,cAAc,EAAE,CAAC;QACvC,OAAO,GAAG,GAAG,CAAC,IAAI,sCAAsC,CAAC;IAC3D,CAAC;IACD,OAAO,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,IAAI,CAAC;AACpC,CAAC","sourcesContent":["import { Environment } from \"../api/lib.js\";\nimport { formatEnvironmentTypeLabel } from \"./format-environment-type.js\";\n\n/**\n * The visible row label for one environment in the interactive selection\n * prompt. The leading characters drive `@inquirer/prompts/select`\n * type-to-jump matching (`name.toLowerCase().startsWith(searchTerm)`), so\n * what we put first determines how users search.\n *\n * - Working-copy items: lead with `env.name` (the only identifier they have)\n * plus the inline call-to-action hint.\n * - Preview/production items: lead with `env.branchName` (what the user\n * typed at deploy time, e.g. \"staging\") so keystrokes match. If\n * `branchName` is missing or empty, fall back to `env.name` (the slug) —\n * type-to-jump degrades to slug-prefix behavior in that case, which is\n * strictly better than rendering an empty row.\n *\n * The slug is surfaced via inquirer's per-choice `description` field at the\n * call site, so it shows only for the active row.\n */\nexport function prettyPrintEnvironmentPrompt(env: Environment): string {\n const environmentType = formatEnvironmentTypeLabel(env.environmentType);\n\n if (environmentType === \"working-copy\") {\n return `${env.name} recommended for local development`;\n }\n return env.branchName || env.name;\n}\n"]}
@@ -12,33 +12,31 @@ function makeEnv(environmentType, name = "my-env", branchName = "main") {
12
12
  };
13
13
  }
14
14
  describe("prettyPrintEnvironmentPrompt", () => {
15
- describe("working-copy variants all display as 'working-copy'", () => {
15
+ describe("working-copy rendering", () => {
16
16
  const workingCopyVariants = [
17
17
  "working_copy",
18
18
  "working-copy",
19
19
  "development",
20
20
  ];
21
21
  for (const envType of workingCopyVariants) {
22
- it(`shows working-copy label for environmentType="${envType}" (single instance)`, () => {
23
- const result = prettyPrintEnvironmentPrompt(makeEnv(envType), true);
24
- assert.ok(result.includes("(working-copy)"), `Expected "(working-copy)" in "${result}"`);
25
- assert.ok(!result.includes("(development)"), `Expected no "(development)" in "${result}"`);
26
- });
27
- it(`shows working-copy label for environmentType="${envType}" (multiple instances)`, () => {
28
- const result = prettyPrintEnvironmentPrompt(makeEnv(envType), false);
29
- assert.ok(result.includes("(working-copy)"), `Expected "(working-copy)" in "${result}"`);
30
- assert.ok(!result.includes("(development)"), `Expected no "(development)" in "${result}"`);
22
+ it(`uses env.name and the recommendation hint for environmentType="${envType}"`, () => {
23
+ const result = prettyPrintEnvironmentPrompt(makeEnv(envType, "wc-slug"));
24
+ assert.strictEqual(result, "wc-slug recommended for local development");
31
25
  });
32
26
  }
33
27
  });
34
- it("shows production label unchanged", () => {
35
- const result = prettyPrintEnvironmentPrompt(makeEnv("production", "prod-env", "main"), false);
36
- assert.ok(result.includes("production"), `Expected "production" in "${result}"`);
28
+ it("renders preview rows as the branch name only", () => {
29
+ const result = prettyPrintEnvironmentPrompt(makeEnv("preview", "env-test-staging-bb91e0b", "staging"));
30
+ assert.strictEqual(result, "staging");
31
+ assert.ok(result.startsWith("s"), `Expected "s" prefix in "${result}"`);
32
+ });
33
+ it("renders production rows as the branch name only", () => {
34
+ const result = prettyPrintEnvironmentPrompt(makeEnv("production", "env-test-prod-xyz789", "main"));
35
+ assert.strictEqual(result, "main");
37
36
  });
38
- it("shows preview label unchanged", () => {
39
- const result = prettyPrintEnvironmentPrompt(makeEnv("preview", "preview-env", "feature-branch"), false);
40
- assert.ok(result.includes("preview"), `Expected "preview" in "${result}"`);
41
- assert.ok(result.includes("feature-branch"), `Expected branch name in "${result}"`);
37
+ it("falls back to env.name when branchName is empty", () => {
38
+ const env = makeEnv("preview", "env-test-fallback-abc123", "");
39
+ assert.strictEqual(prettyPrintEnvironmentPrompt(env), "env-test-fallback-abc123");
42
40
  });
43
41
  });
44
42
  //# sourceMappingURL=pretty-print-environment-prompt.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pretty-print-environment-prompt.test.js","sourceRoot":"","sources":["../../../src/common/utils/pretty-print-environment-prompt.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAEpF,SAAS,OAAO,CACd,eAA+C,EAC/C,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,MAAM;IAEnB,OAAO;QACL,IAAI;QACJ,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,YAAY;QACzB,SAAS,EAAE,IAAI;QACf,UAAU;QACV,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,8BAA8B,EAAE,G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A6B,MAAM,GAAG,CACvC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,MAAM,GAAG,4BAA4B,CACzC,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,gBAAgB,CAAC,EACnD,KAAK,CACN,CAAC;QACF,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,0BAA0B,MAAM,GAAG,CAAC,CAAC;QAC3E,MAAM,CAAC,EAAE,CACP,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EACjC,4BAA4B,MAAM,GAAG,CACtC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert\";\nimport { describe, it } from \"node:test\";\nimport { Environment } from \"../api/lib.js\";\nimport { prettyPrintEnvironmentPrompt } from \"./pretty-print-environment-prompt.js\";\n\nfunction makeEnv(\n environmentType: Environment[\"environmentType\"],\n name = \"my-env\",\n branchName = \"main\"\n): Environment {\n return {\n name,\n accountName: \"acme\",\n projectName: \"my-project\",\n createdOn: null,\n branchName,\n environmentType,\n };\n}\n\ndescribe(\"prettyPrintEnvironmentPrompt\", () => {\n describe(\"working-copy variants all display as 'working-copy'\", () => {\n const workingCopyVariants: Environment[\"environmentType\"][] = [\n \"working_copy\",\n \"working-copy\",\n \"development\",\n ];\n for (const envType of workingCopyVariants) {\n it(`shows working-copy label for environmentType=\"${envType}\" (single instance)`, () => {\n const result = prettyPrintEnvironmentPrompt(makeEnv(envType), true);\n // The type label in parentheses must be (working-copy), not (development)\n assert.ok(\n result.includes(\"(working-copy)\"),\n `Expected \"(working-copy)\" in \"${result}\"`\n );\n assert.ok(\n !result.includes(\"(development)\"),\n `Expected no \"(development)\" in \"${result}\"`\n );\n });\n\n it(`shows working-copy label for environmentType=\"${envType}\" (multiple instances)`, () => {\n const result = prettyPrintEnvironmentPrompt(makeEnv(envType), false);\n assert.ok(\n result.includes(\"(working-copy)\"),\n `Expected \"(working-copy)\" in \"${result}\"`\n );\n assert.ok(\n !result.includes(\"(development)\"),\n `Expected no \"(development)\" in \"${result}\"`\n );\n });\n }\n });\n\n it(\"shows production label unchanged\", () => {\n const result = prettyPrintEnvironmentPrompt(\n makeEnv(\"production\", \"prod-env\", \"main\"),\n false\n );\n assert.ok(\n result.includes(\"production\"),\n `Expected \"production\" in \"${result}\"`\n );\n });\n\n it(\"shows preview label unchanged\", () => {\n const result = prettyPrintEnvironmentPrompt(\n makeEnv(\"preview\", \"preview-env\", \"feature-branch\"),\n false\n );\n assert.ok(result.includes(\"preview\"), `Expected \"preview\" in \"${result}\"`);\n assert.ok(\n result.includes(\"feature-branch\"),\n `Expected branch name in \"${result}\"`\n );\n });\n});\n"]}
1
+ {"version":3,"file":"pretty-print-environment-prompt.test.js","sourceRoot":"","sources":["../../../src/common/utils/pretty-print-environment-prompt.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAEpF,SAAS,OAAO,CACd,eAA+C,EAC/C,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,MAAM;IAEnB,OAAO;QACL,IAAI;QACJ,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,YAAY;QACzB,SAAS,EAAE,IAAI;QACf,UAAU;QACV,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,mBAAmB,GAAqC;YAC5D,cAAc;YACd,cAAc;YACd,aAAa;SACd,CAAC;QACF,KAAK,MAAM,OAAO,IAAI,mBAAmB,EAAE,CAAC;YAC1C,EAAE,CAAC,kEAAkE,OAAO,GAAG,EAAE,GAAG,EAAE;gBACpF,MAAM,MAAM,GAAG,4BAA4B,CACzC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAC5B,CAAC;gBAEF,MAAM,CAAC,WAAW,CAChB,MAAM,EACN,6CAA6C,CAC9C,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAMH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,MAAM,GAAG,4BAA4B,CACzC,OAAO,CAAC,SAAS,EAAE,0BAA0B,EAAE,SAAS,CAAC,CAC1D,CAAC;QAEF,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACtC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,2BAA2B,MAAM,GAAG,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,MAAM,GAAG,4BAA4B,CACzC,OAAO,CAAC,YAAY,EAAE,sBAAsB,EAAE,MAAM,CAAC,CACtD,CAAC;QAEF,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,EAAE,0BAA0B,EAAE,EAAE,CAAC,CAAC;QAE/D,MAAM,CAAC,WAAW,CAChB,4BAA4B,CAAC,GAAG,CAAC,EACjC,0BAA0B,CAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert\";\nimport { describe, it } from \"node:test\";\nimport { Environment } from \"../api/lib.js\";\nimport { prettyPrintEnvironmentPrompt } from \"./pretty-print-environment-prompt.js\";\n\nfunction makeEnv(\n environmentType: Environment[\"environmentType\"],\n name = \"my-env\",\n branchName = \"main\"\n): Environment {\n return {\n name,\n accountName: \"acme\",\n projectName: \"my-project\",\n createdOn: null,\n branchName,\n environmentType,\n };\n}\n\ndescribe(\"prettyPrintEnvironmentPrompt\", () => {\n describe(\"working-copy rendering\", () => {\n const workingCopyVariants: Environment[\"environmentType\"][] = [\n \"working_copy\",\n \"working-copy\",\n \"development\",\n ];\n for (const envType of workingCopyVariants) {\n it(`uses env.name and the recommendation hint for environmentType=\"${envType}\"`, () => {\n const result = prettyPrintEnvironmentPrompt(\n makeEnv(envType, \"wc-slug\")\n );\n\n assert.strictEqual(\n result,\n \"wc-slug recommended for local development\"\n );\n });\n }\n });\n\n // The leading character MUST be the user-typed name (env.branchName for\n // preview/production, env.name for working-copy). `@inquirer/prompts/select`\n // matches type-to-jump as `name.toLowerCase().startsWith(searchTerm)`, so a\n // leading slug like \"env-test-…\" or an ANSI escape silently breaks the filter.\n it(\"renders preview rows as the branch name only\", () => {\n const result = prettyPrintEnvironmentPrompt(\n makeEnv(\"preview\", \"env-test-staging-bb91e0b\", \"staging\")\n );\n\n assert.strictEqual(result, \"staging\");\n assert.ok(result.startsWith(\"s\"), `Expected \"s\" prefix in \"${result}\"`);\n });\n\n it(\"renders production rows as the branch name only\", () => {\n const result = prettyPrintEnvironmentPrompt(\n makeEnv(\"production\", \"env-test-prod-xyz789\", \"main\")\n );\n\n assert.strictEqual(result, \"main\");\n });\n\n it(\"falls back to env.name when branchName is empty\", () => {\n const env = makeEnv(\"preview\", \"env-test-fallback-abc123\", \"\");\n\n assert.strictEqual(\n prettyPrintEnvironmentPrompt(env),\n \"env-test-fallback-abc123\"\n );\n });\n});\n"]}
@@ -0,0 +1,5 @@
1
+ import { Environment } from "../api/lib.js";
2
+ export declare function sortEnvironmentsForPrompt(
3
+ envs: Environment[]
4
+ ): Environment[];
5
+ //# sourceMappingURL=sort-environments-for-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-environments-for-prompt.d.ts","sourceRoot":"","sources":["../../../src/common/utils/sort-environments-for-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAyB5C,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAa5E"}
@@ -0,0 +1,27 @@
1
+ import { formatEnvironmentTypeLabel } from "./format-environment-type.js";
2
+ const TYPE_ORDER = {
3
+ "working-copy": 0,
4
+ preview: 1,
5
+ production: 2,
6
+ };
7
+ const FALLBACK_ORDER = 3;
8
+ export function sortEnvironmentsForPrompt(envs) {
9
+ return [...envs].sort((a, b) => {
10
+ const aOrder = TYPE_ORDER[formatEnvironmentTypeLabel(a.environmentType)] ??
11
+ FALLBACK_ORDER;
12
+ const bOrder = TYPE_ORDER[formatEnvironmentTypeLabel(b.environmentType)] ??
13
+ FALLBACK_ORDER;
14
+ if (aOrder !== bOrder) {
15
+ return aOrder - bOrder;
16
+ }
17
+ return visibleSortKey(a).localeCompare(visibleSortKey(b));
18
+ });
19
+ }
20
+ function visibleSortKey(env) {
21
+ const type = formatEnvironmentTypeLabel(env.environmentType);
22
+ if (type === "working-copy") {
23
+ return env.name;
24
+ }
25
+ return env.branchName || env.name;
26
+ }
27
+ //# sourceMappingURL=sort-environments-for-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-environments-for-prompt.js","sourceRoot":"","sources":["../../../src/common/utils/sort-environments-for-prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,MAAM,UAAU,GAA2B;IACzC,cAAc,EAAE,CAAC;IACjB,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,CAAC;CACd,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,CAAC;AAgBzB,MAAM,UAAU,yBAAyB,CAAC,IAAmB;IAC3D,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7B,MAAM,MAAM,GACV,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;YACzD,cAAc,CAAC;QACjB,MAAM,MAAM,GACV,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;YACzD,cAAc,CAAC;QACjB,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACtB,OAAO,MAAM,GAAG,MAAM,CAAC;QACzB,CAAC;QACD,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,GAAgB;IACtC,MAAM,IAAI,GAAG,0BAA0B,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7D,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,IAAI,CAAC;AACpC,CAAC","sourcesContent":["import { Environment } from \"../api/lib.js\";\nimport { formatEnvironmentTypeLabel } from \"./format-environment-type.js\";\n\nconst TYPE_ORDER: Record<string, number> = {\n \"working-copy\": 0,\n preview: 1,\n production: 2,\n};\n\nconst FALLBACK_ORDER = 3;\n\n/**\n * Orders environments for display in the interactive selection prompt:\n * working-copy first, then preview envs alphabetically, then production\n * (alphabetically within each bucket).\n *\n * Working-copy is placed at the top because it is the recommended choice for\n * local development. Production is placed last to reduce the chance of an\n * accidental selection.\n *\n * Within-bucket ordering uses the same string the prompt actually displays:\n * `env.branchName` (the user-typed name) for preview/production, and\n * `env.name` (the slug) for working-copy. Sorting by anything else can let\n * the rendered list look non-alphabetical to the user.\n */\nexport function sortEnvironmentsForPrompt(envs: Environment[]): Environment[] {\n return [...envs].sort((a, b) => {\n const aOrder =\n TYPE_ORDER[formatEnvironmentTypeLabel(a.environmentType)] ??\n FALLBACK_ORDER;\n const bOrder =\n TYPE_ORDER[formatEnvironmentTypeLabel(b.environmentType)] ??\n FALLBACK_ORDER;\n if (aOrder !== bOrder) {\n return aOrder - bOrder;\n }\n return visibleSortKey(a).localeCompare(visibleSortKey(b));\n });\n}\n\nfunction visibleSortKey(env: Environment): string {\n const type = formatEnvironmentTypeLabel(env.environmentType);\n if (type === \"working-copy\") {\n return env.name;\n }\n return env.branchName || env.name;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sort-environments-for-prompt.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-environments-for-prompt.test.d.ts","sourceRoot":"","sources":["../../../src/common/utils/sort-environments-for-prompt.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,82 @@
1
+ import assert from "node:assert";
2
+ import { describe, it } from "node:test";
3
+ import { sortEnvironmentsForPrompt } from "./sort-environments-for-prompt.js";
4
+ function makeEnv(environmentType, name, branchName) {
5
+ return {
6
+ name,
7
+ accountName: "acme",
8
+ projectName: "my-project",
9
+ createdOn: null,
10
+ branchName: branchName ?? name,
11
+ environmentType,
12
+ };
13
+ }
14
+ describe("sortEnvironmentsForPrompt", () => {
15
+ it("orders working-copy first, then preview alpha, then production", () => {
16
+ const envs = [
17
+ makeEnv("production", "prod"),
18
+ makeEnv("preview", "staging-b"),
19
+ makeEnv("working_copy", "wc-1"),
20
+ makeEnv("preview", "staging-a"),
21
+ ];
22
+ const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);
23
+ assert.deepStrictEqual(result, ["wc-1", "staging-a", "staging-b", "prod"]);
24
+ });
25
+ it("sorts alphabetically within the same bucket", () => {
26
+ const envs = [
27
+ makeEnv("preview", "charlie"),
28
+ makeEnv("preview", "alpha"),
29
+ makeEnv("preview", "bravo"),
30
+ ];
31
+ const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);
32
+ assert.deepStrictEqual(result, ["alpha", "bravo", "charlie"]);
33
+ });
34
+ it("returns an empty array unchanged", () => {
35
+ assert.deepStrictEqual(sortEnvironmentsForPrompt([]), []);
36
+ });
37
+ it("treats every working-copy type spelling as the same bucket", () => {
38
+ const envs = [
39
+ makeEnv("production", "prod"),
40
+ makeEnv("development", "wc-c"),
41
+ makeEnv("working-copy", "wc-a"),
42
+ makeEnv("working_copy", "wc-b"),
43
+ ];
44
+ const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);
45
+ assert.deepStrictEqual(result, ["wc-a", "wc-b", "wc-c", "prod"]);
46
+ });
47
+ it("does not mutate the input array", () => {
48
+ const envs = [
49
+ makeEnv("production", "prod"),
50
+ makeEnv("working_copy", "wc"),
51
+ ];
52
+ const before = envs.map((e) => e.name);
53
+ sortEnvironmentsForPrompt(envs);
54
+ assert.deepStrictEqual(envs.map((e) => e.name), before);
55
+ });
56
+ it("sorts preview/production rows by branchName (the visible label), not slug", () => {
57
+ const envs = [
58
+ makeEnv("preview", "env-test-zzz", "apple"),
59
+ makeEnv("preview", "env-test-aaa", "zebra"),
60
+ makeEnv("preview", "env-test-mmm", "mango"),
61
+ ];
62
+ const result = sortEnvironmentsForPrompt(envs).map((e) => e.branchName);
63
+ assert.deepStrictEqual(result, ["apple", "mango", "zebra"]);
64
+ });
65
+ it("falls back to env.name when a preview env has no branchName", () => {
66
+ const envs = [
67
+ makeEnv("preview", "alpha-slug", "zebra"),
68
+ makeEnv("preview", "bravo-slug", ""),
69
+ ];
70
+ const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);
71
+ assert.deepStrictEqual(result, ["bravo-slug", "alpha-slug"]);
72
+ });
73
+ it("sorts working-copy rows by env.name (their visible label)", () => {
74
+ const envs = [
75
+ makeEnv("working_copy", "wc-zebra", "main"),
76
+ makeEnv("working_copy", "wc-apple", "main"),
77
+ ];
78
+ const result = sortEnvironmentsForPrompt(envs).map((e) => e.name);
79
+ assert.deepStrictEqual(result, ["wc-apple", "wc-zebra"]);
80
+ });
81
+ });
82
+ //# sourceMappingURL=sort-environments-for-prompt.test.js.map