@posthog/wizard 1.36.1 → 2.0.0

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 (464) hide show
  1. package/README.md +79 -0
  2. package/dist/bin.js +199 -12
  3. package/dist/bin.js.map +1 -1
  4. package/dist/src/__tests__/cli.test.js +7 -18
  5. package/dist/src/__tests__/cli.test.js.map +1 -1
  6. package/dist/src/__tests__/run.test.js +50 -5
  7. package/dist/src/__tests__/run.test.js.map +1 -1
  8. package/dist/src/__tests__/wizard-abort.test.js +127 -0
  9. package/dist/src/__tests__/wizard-abort.test.js.map +1 -0
  10. package/dist/src/{android → frameworks/android}/android-wizard-agent.d.ts +1 -1
  11. package/dist/src/{android → frameworks/android}/android-wizard-agent.js +2 -2
  12. package/dist/src/frameworks/android/android-wizard-agent.js.map +1 -0
  13. package/dist/src/{android → frameworks/android}/utils.d.ts +1 -1
  14. package/dist/src/{android → frameworks/android}/utils.js +1 -1
  15. package/dist/src/frameworks/android/utils.js.map +1 -0
  16. package/dist/src/{angular → frameworks/angular}/angular-wizard-agent.d.ts +1 -1
  17. package/dist/src/{angular → frameworks/angular}/angular-wizard-agent.js +9 -7
  18. package/dist/src/frameworks/angular/angular-wizard-agent.js.map +1 -0
  19. package/dist/src/{angular → frameworks/angular}/utils.js +1 -1
  20. package/dist/src/frameworks/angular/utils.js.map +1 -0
  21. package/dist/src/{astro → frameworks/astro}/astro-wizard-agent.d.ts +1 -1
  22. package/dist/src/{astro → frameworks/astro}/astro-wizard-agent.js +9 -7
  23. package/dist/src/frameworks/astro/astro-wizard-agent.js.map +1 -0
  24. package/dist/src/{astro → frameworks/astro}/utils.d.ts +2 -5
  25. package/dist/src/{astro → frameworks/astro}/utils.js +3 -52
  26. package/dist/src/frameworks/astro/utils.js.map +1 -0
  27. package/dist/src/{django → frameworks/django}/django-wizard-agent.d.ts +1 -1
  28. package/dist/src/{django → frameworks/django}/django-wizard-agent.js +3 -3
  29. package/dist/src/frameworks/django/django-wizard-agent.js.map +1 -0
  30. package/dist/src/{django → frameworks/django}/utils.d.ts +1 -1
  31. package/dist/src/{django → frameworks/django}/utils.js +6 -6
  32. package/dist/src/frameworks/django/utils.js.map +1 -0
  33. package/dist/src/frameworks/fastapi/fastapi-wizard-agent.d.ts +5 -0
  34. package/dist/src/{fastapi → frameworks/fastapi}/fastapi-wizard-agent.js +3 -32
  35. package/dist/src/frameworks/fastapi/fastapi-wizard-agent.js.map +1 -0
  36. package/dist/src/{fastapi → frameworks/fastapi}/utils.d.ts +1 -1
  37. package/dist/src/{fastapi → frameworks/fastapi}/utils.js +4 -4
  38. package/dist/src/frameworks/fastapi/utils.js.map +1 -0
  39. package/dist/src/{flask → frameworks/flask}/flask-wizard-agent.d.ts +1 -1
  40. package/dist/src/{flask → frameworks/flask}/flask-wizard-agent.js +3 -3
  41. package/dist/src/frameworks/flask/flask-wizard-agent.js.map +1 -0
  42. package/dist/src/{flask → frameworks/flask}/utils.d.ts +1 -1
  43. package/dist/src/{flask → frameworks/flask}/utils.js +7 -7
  44. package/dist/src/frameworks/flask/utils.js.map +1 -0
  45. package/dist/src/{javascript-node → frameworks/javascript-node}/javascript-node-wizard-agent.d.ts +1 -1
  46. package/dist/src/{javascript-node → frameworks/javascript-node}/javascript-node-wizard-agent.js +4 -4
  47. package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.js.map +1 -0
  48. package/dist/src/{javascript-web → frameworks/javascript-web}/javascript-web-wizard-agent.d.ts +1 -1
  49. package/dist/src/{javascript-web → frameworks/javascript-web}/javascript-web-wizard-agent.js +16 -14
  50. package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.js.map +1 -0
  51. package/dist/src/{javascript-web → frameworks/javascript-web}/utils.d.ts +6 -1
  52. package/dist/src/{javascript-web → frameworks/javascript-web}/utils.js +49 -1
  53. package/dist/src/frameworks/javascript-web/utils.js.map +1 -0
  54. package/dist/src/{laravel → frameworks/laravel}/laravel-wizard-agent.d.ts +1 -1
  55. package/dist/src/{laravel → frameworks/laravel}/laravel-wizard-agent.js +2 -2
  56. package/dist/src/frameworks/laravel/laravel-wizard-agent.js.map +1 -0
  57. package/dist/src/{laravel → frameworks/laravel}/utils.d.ts +1 -1
  58. package/dist/src/{laravel → frameworks/laravel}/utils.js +5 -5
  59. package/dist/src/frameworks/laravel/utils.js.map +1 -0
  60. package/dist/src/{nextjs → frameworks/nextjs}/nextjs-wizard-agent.d.ts +1 -1
  61. package/dist/src/{nextjs → frameworks/nextjs}/nextjs-wizard-agent.js +30 -8
  62. package/dist/src/frameworks/nextjs/nextjs-wizard-agent.js.map +1 -0
  63. package/dist/src/{nextjs → frameworks/nextjs}/utils.d.ts +5 -2
  64. package/dist/src/{nextjs → frameworks/nextjs}/utils.js +6 -20
  65. package/dist/src/frameworks/nextjs/utils.js.map +1 -0
  66. package/dist/src/{nuxt → frameworks/nuxt}/nuxt-wizard-agent.d.ts +1 -1
  67. package/dist/src/{nuxt → frameworks/nuxt}/nuxt-wizard-agent.js +11 -9
  68. package/dist/src/frameworks/nuxt/nuxt-wizard-agent.js.map +1 -0
  69. package/dist/src/{python → frameworks/python}/python-wizard-agent.d.ts +1 -1
  70. package/dist/src/{python → frameworks/python}/python-wizard-agent.js +3 -3
  71. package/dist/src/frameworks/python/python-wizard-agent.js.map +1 -0
  72. package/dist/src/{python → frameworks/python}/utils.d.ts +1 -1
  73. package/dist/src/frameworks/python/utils.js.map +1 -0
  74. package/dist/src/{rails → frameworks/rails}/rails-wizard-agent.d.ts +1 -1
  75. package/dist/src/{rails → frameworks/rails}/rails-wizard-agent.js +2 -2
  76. package/dist/src/frameworks/rails/rails-wizard-agent.js.map +1 -0
  77. package/dist/src/{rails → frameworks/rails}/utils.d.ts +1 -1
  78. package/dist/src/{rails → frameworks/rails}/utils.js +4 -4
  79. package/dist/src/frameworks/rails/utils.js.map +1 -0
  80. package/dist/src/{react-native → frameworks/react-native}/react-native-wizard-agent.d.ts +1 -1
  81. package/dist/src/{react-native → frameworks/react-native}/react-native-wizard-agent.js +9 -7
  82. package/dist/src/frameworks/react-native/react-native-wizard-agent.js.map +1 -0
  83. package/dist/src/{react-native → frameworks/react-native}/utils.d.ts +1 -1
  84. package/dist/src/{react-native → frameworks/react-native}/utils.js +7 -10
  85. package/dist/src/frameworks/react-native/utils.js.map +1 -0
  86. package/dist/src/{react-router → frameworks/react-router}/react-router-wizard-agent.d.ts +1 -1
  87. package/dist/src/{react-router → frameworks/react-router}/react-router-wizard-agent.js +15 -8
  88. package/dist/src/frameworks/react-router/react-router-wizard-agent.js.map +1 -0
  89. package/dist/src/frameworks/react-router/utils.d.ts +13 -0
  90. package/dist/src/{react-router → frameworks/react-router}/utils.js +14 -111
  91. package/dist/src/frameworks/react-router/utils.js.map +1 -0
  92. package/dist/src/{ruby → frameworks/ruby}/ruby-wizard-agent.d.ts +1 -1
  93. package/dist/src/{ruby → frameworks/ruby}/ruby-wizard-agent.js +2 -2
  94. package/dist/src/frameworks/ruby/ruby-wizard-agent.js.map +1 -0
  95. package/dist/src/{ruby → frameworks/ruby}/utils.d.ts +1 -1
  96. package/dist/src/{ruby → frameworks/ruby}/utils.js +1 -1
  97. package/dist/src/frameworks/ruby/utils.js.map +1 -0
  98. package/dist/src/{svelte → frameworks/svelte}/svelte-wizard-agent.d.ts +1 -1
  99. package/dist/src/{svelte → frameworks/svelte}/svelte-wizard-agent.js +5 -5
  100. package/dist/src/frameworks/svelte/svelte-wizard-agent.js.map +1 -0
  101. package/dist/src/{swift → frameworks/swift}/swift-wizard-agent.d.ts +1 -1
  102. package/dist/src/{swift → frameworks/swift}/swift-wizard-agent.js +2 -2
  103. package/dist/src/frameworks/swift/swift-wizard-agent.js.map +1 -0
  104. package/dist/src/{swift → frameworks/swift}/utils.d.ts +1 -1
  105. package/dist/src/frameworks/swift/utils.js.map +1 -0
  106. package/dist/src/{tanstack-router → frameworks/tanstack-router}/tanstack-router-wizard-agent.d.ts +1 -1
  107. package/dist/src/{tanstack-router → frameworks/tanstack-router}/tanstack-router-wizard-agent.js +15 -8
  108. package/dist/src/frameworks/tanstack-router/tanstack-router-wizard-agent.js.map +1 -0
  109. package/dist/src/frameworks/tanstack-router/utils.d.ts +11 -0
  110. package/dist/src/{tanstack-router → frameworks/tanstack-router}/utils.js +4 -47
  111. package/dist/src/frameworks/tanstack-router/utils.js.map +1 -0
  112. package/dist/src/{tanstack-start → frameworks/tanstack-start}/tanstack-start-wizard-agent.d.ts +1 -1
  113. package/dist/src/{tanstack-start → frameworks/tanstack-start}/tanstack-start-wizard-agent.js +9 -7
  114. package/dist/src/frameworks/tanstack-start/tanstack-start-wizard-agent.js.map +1 -0
  115. package/dist/src/{tanstack-start → frameworks/tanstack-start}/utils.js +1 -1
  116. package/dist/src/frameworks/tanstack-start/utils.js.map +1 -0
  117. package/dist/src/{vue → frameworks/vue}/vue-wizard-agent.d.ts +1 -1
  118. package/dist/src/{vue → frameworks/vue}/vue-wizard-agent.js +8 -8
  119. package/dist/src/frameworks/vue/vue-wizard-agent.js.map +1 -0
  120. package/dist/src/lib/__tests__/agent-interface.test.js +91 -19
  121. package/dist/src/lib/__tests__/agent-interface.test.js.map +1 -1
  122. package/dist/src/lib/agent-interface.d.ts +49 -2
  123. package/dist/src/lib/agent-interface.js +254 -40
  124. package/dist/src/lib/agent-interface.js.map +1 -1
  125. package/dist/src/lib/agent-runner.d.ts +4 -2
  126. package/dist/src/lib/agent-runner.js +132 -126
  127. package/dist/src/lib/agent-runner.js.map +1 -1
  128. package/dist/src/lib/api.d.ts +4 -4
  129. package/dist/src/lib/commandments.js +1 -0
  130. package/dist/src/lib/commandments.js.map +1 -1
  131. package/dist/src/lib/constants.d.ts +22 -9
  132. package/dist/src/lib/constants.js +35 -11
  133. package/dist/src/lib/constants.js.map +1 -1
  134. package/dist/src/lib/framework-config.d.ts +26 -0
  135. package/dist/src/lib/framework-config.js.map +1 -1
  136. package/dist/src/lib/health-checks/__tests__/health-checks.test.d.ts +18 -0
  137. package/dist/src/lib/health-checks/__tests__/health-checks.test.js +752 -0
  138. package/dist/src/lib/health-checks/__tests__/health-checks.test.js.map +1 -0
  139. package/dist/src/lib/health-checks/endpoints.d.ts +3 -0
  140. package/dist/src/lib/health-checks/endpoints.js +46 -0
  141. package/dist/src/lib/health-checks/endpoints.js.map +1 -0
  142. package/dist/src/lib/health-checks/index.d.ts +4 -0
  143. package/dist/src/lib/health-checks/index.js +23 -0
  144. package/dist/src/lib/health-checks/index.js.map +1 -0
  145. package/dist/src/lib/health-checks/readiness.d.ts +24 -0
  146. package/dist/src/lib/health-checks/readiness.js +119 -0
  147. package/dist/src/lib/health-checks/readiness.js.map +1 -0
  148. package/dist/src/lib/health-checks/statuspage.d.ts +9 -0
  149. package/dist/src/lib/health-checks/statuspage.js +105 -0
  150. package/dist/src/lib/health-checks/statuspage.js.map +1 -0
  151. package/dist/src/lib/health-checks/types.d.ts +31 -0
  152. package/dist/src/lib/health-checks/types.js +10 -0
  153. package/dist/src/lib/health-checks/types.js.map +1 -0
  154. package/dist/src/lib/middleware/benchmark.d.ts +2 -2
  155. package/dist/src/lib/middleware/benchmark.js +3 -3
  156. package/dist/src/lib/middleware/benchmark.js.map +1 -1
  157. package/dist/src/lib/middleware/benchmarks/json-writer.js +2 -2
  158. package/dist/src/lib/middleware/benchmarks/json-writer.js.map +1 -1
  159. package/dist/src/lib/middleware/benchmarks/summary.d.ts +2 -2
  160. package/dist/src/lib/middleware/benchmarks/summary.js +9 -9
  161. package/dist/src/lib/middleware/benchmarks/summary.js.map +1 -1
  162. package/dist/src/lib/middleware/types.d.ts +2 -2
  163. package/dist/src/lib/middleware/types.js.map +1 -1
  164. package/dist/src/lib/package-manager-detection.js +1 -1
  165. package/dist/src/lib/package-manager-detection.js.map +1 -1
  166. package/dist/src/lib/registry.js +21 -21
  167. package/dist/src/lib/registry.js.map +1 -1
  168. package/dist/src/lib/version.d.ts +1 -1
  169. package/dist/src/lib/version.js +1 -1
  170. package/dist/src/lib/version.js.map +1 -1
  171. package/dist/src/lib/wizard-session.d.ts +115 -0
  172. package/dist/src/lib/wizard-session.js +104 -0
  173. package/dist/src/lib/wizard-session.js.map +1 -0
  174. package/dist/src/lib/wizard-tools.js +13 -0
  175. package/dist/src/lib/wizard-tools.js.map +1 -1
  176. package/dist/src/run.d.ts +3 -1
  177. package/dist/src/run.js +73 -55
  178. package/dist/src/run.js.map +1 -1
  179. package/dist/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.js +18 -22
  180. package/dist/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.js.map +1 -1
  181. package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.d.ts +6 -6
  182. package/dist/src/steps/add-mcp-server-to-clients/clients/claude.d.ts +6 -6
  183. package/dist/src/steps/add-mcp-server-to-clients/clients/codex.d.ts +7 -7
  184. package/dist/src/steps/add-mcp-server-to-clients/clients/codex.js +8 -9
  185. package/dist/src/steps/add-mcp-server-to-clients/clients/codex.js.map +1 -1
  186. package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.d.ts +6 -6
  187. package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.d.ts +6 -6
  188. package/dist/src/steps/add-mcp-server-to-clients/clients/zed.d.ts +6 -6
  189. package/dist/src/steps/add-mcp-server-to-clients/defaults.d.ts +6 -6
  190. package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +5 -2
  191. package/dist/src/steps/add-mcp-server-to-clients/index.js +24 -107
  192. package/dist/src/steps/add-mcp-server-to-clients/index.js.map +1 -1
  193. package/dist/src/steps/add-or-update-environment-variables.js +15 -20
  194. package/dist/src/steps/add-or-update-environment-variables.js.map +1 -1
  195. package/dist/src/steps/index.d.ts +0 -1
  196. package/dist/src/steps/index.js +0 -1
  197. package/dist/src/steps/index.js.map +1 -1
  198. package/dist/src/steps/run-prettier.js +9 -11
  199. package/dist/src/steps/run-prettier.js.map +1 -1
  200. package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +6 -3
  201. package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js.map +1 -1
  202. package/dist/src/steps/upload-environment-variables/index.d.ts +3 -3
  203. package/dist/src/steps/upload-environment-variables/index.js +7 -35
  204. package/dist/src/steps/upload-environment-variables/index.js.map +1 -1
  205. package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +3 -2
  206. package/dist/src/steps/upload-environment-variables/providers/vercel.js +2 -2
  207. package/dist/src/steps/upload-environment-variables/providers/vercel.js.map +1 -1
  208. package/dist/src/ui/index.d.ts +8 -0
  209. package/dist/src/ui/index.js +17 -0
  210. package/dist/src/ui/index.js.map +1 -0
  211. package/dist/src/ui/logging-ui.d.ts +44 -0
  212. package/dist/src/ui/logging-ui.js +103 -0
  213. package/dist/src/ui/logging-ui.js.map +1 -0
  214. package/dist/src/ui/tui/App.d.ts +6 -0
  215. package/dist/src/ui/tui/App.js +10 -0
  216. package/dist/src/ui/tui/App.js.map +1 -0
  217. package/dist/src/ui/tui/__tests__/layout-helpers.test.js +68 -0
  218. package/dist/src/ui/tui/__tests__/layout-helpers.test.js.map +1 -0
  219. package/dist/src/ui/tui/__tests__/store.test.d.ts +1 -0
  220. package/dist/src/ui/tui/__tests__/store.test.js +723 -0
  221. package/dist/src/ui/tui/__tests__/store.test.js.map +1 -0
  222. package/dist/src/ui/tui/components/LearnCard.d.ts +10 -0
  223. package/dist/src/ui/tui/components/LearnCard.js +217 -0
  224. package/dist/src/ui/tui/components/LearnCard.js.map +1 -0
  225. package/dist/src/ui/tui/components/TipsCard.d.ts +9 -0
  226. package/dist/src/ui/tui/components/TipsCard.js +55 -0
  227. package/dist/src/ui/tui/components/TipsCard.js.map +1 -0
  228. package/dist/src/ui/tui/components/TitleBar.d.ts +6 -0
  229. package/dist/src/ui/tui/components/TitleBar.js +17 -0
  230. package/dist/src/ui/tui/components/TitleBar.js.map +1 -0
  231. package/dist/src/ui/tui/flows.d.ts +38 -0
  232. package/dist/src/ui/tui/flows.js +82 -0
  233. package/dist/src/ui/tui/flows.js.map +1 -0
  234. package/dist/src/ui/tui/hooks/useStdoutDimensions.d.ts +9 -0
  235. package/dist/src/ui/tui/hooks/useStdoutDimensions.js +37 -0
  236. package/dist/src/ui/tui/hooks/useStdoutDimensions.js.map +1 -0
  237. package/dist/src/ui/tui/ink-ui.d.ts +50 -0
  238. package/dist/src/ui/tui/ink-ui.js +108 -0
  239. package/dist/src/ui/tui/ink-ui.js.map +1 -0
  240. package/dist/src/ui/tui/package.json +1 -0
  241. package/dist/src/ui/tui/playground/PlaygroundApp.d.ts +12 -0
  242. package/dist/src/ui/tui/playground/PlaygroundApp.js +32 -0
  243. package/dist/src/ui/tui/playground/PlaygroundApp.js.map +1 -0
  244. package/dist/src/ui/tui/playground/demos/InputDemo.d.ts +4 -0
  245. package/dist/src/ui/tui/playground/demos/InputDemo.js +53 -0
  246. package/dist/src/ui/tui/playground/demos/InputDemo.js.map +1 -0
  247. package/dist/src/ui/tui/playground/demos/LayoutDemo.d.ts +5 -0
  248. package/dist/src/ui/tui/playground/demos/LayoutDemo.js +25 -0
  249. package/dist/src/ui/tui/playground/demos/LayoutDemo.js.map +1 -0
  250. package/dist/src/ui/tui/playground/demos/LogDemo.d.ts +5 -0
  251. package/dist/src/ui/tui/playground/demos/LogDemo.js +53 -0
  252. package/dist/src/ui/tui/playground/demos/LogDemo.js.map +1 -0
  253. package/dist/src/ui/tui/playground/demos/ProgressDemo.d.ts +5 -0
  254. package/dist/src/ui/tui/playground/demos/ProgressDemo.js +58 -0
  255. package/dist/src/ui/tui/playground/demos/ProgressDemo.js.map +1 -0
  256. package/dist/src/ui/tui/playground/demos/RunScreenDemo.d.ts +11 -0
  257. package/dist/src/ui/tui/playground/demos/RunScreenDemo.js +159 -0
  258. package/dist/src/ui/tui/playground/demos/RunScreenDemo.js.map +1 -0
  259. package/dist/src/ui/tui/playground/demos/WelcomeDemo.d.ts +9 -0
  260. package/dist/src/ui/tui/playground/demos/WelcomeDemo.js +15 -0
  261. package/dist/src/ui/tui/playground/demos/WelcomeDemo.js.map +1 -0
  262. package/dist/src/ui/tui/playground/start-playground.d.ts +4 -0
  263. package/dist/src/ui/tui/playground/start-playground.js +24 -0
  264. package/dist/src/ui/tui/playground/start-playground.js.map +1 -0
  265. package/dist/src/ui/tui/primitives/CardLayout.d.ts +12 -0
  266. package/dist/src/ui/tui/primitives/CardLayout.js +10 -0
  267. package/dist/src/ui/tui/primitives/CardLayout.js.map +1 -0
  268. package/dist/src/ui/tui/primitives/ConfirmationInput.d.ts +13 -0
  269. package/dist/src/ui/tui/primitives/ConfirmationInput.js +35 -0
  270. package/dist/src/ui/tui/primitives/ConfirmationInput.js.map +1 -0
  271. package/dist/src/ui/tui/primitives/ContentSequencer.d.ts +42 -0
  272. package/dist/src/ui/tui/primitives/ContentSequencer.js +137 -0
  273. package/dist/src/ui/tui/primitives/ContentSequencer.js.map +1 -0
  274. package/dist/src/ui/tui/primitives/DissolveTransition.d.ts +21 -0
  275. package/dist/src/ui/tui/primitives/DissolveTransition.js +149 -0
  276. package/dist/src/ui/tui/primitives/DissolveTransition.js.map +1 -0
  277. package/dist/src/ui/tui/primitives/EventPlanViewer.d.ts +9 -0
  278. package/dist/src/ui/tui/primitives/EventPlanViewer.js +9 -0
  279. package/dist/src/ui/tui/primitives/EventPlanViewer.js.map +1 -0
  280. package/dist/src/ui/tui/primitives/HNViewer.d.ts +7 -0
  281. package/dist/src/ui/tui/primitives/HNViewer.js +63 -0
  282. package/dist/src/ui/tui/primitives/HNViewer.js.map +1 -0
  283. package/dist/src/ui/tui/primitives/LinesBlock.d.ts +16 -0
  284. package/dist/src/ui/tui/primitives/LinesBlock.js +37 -0
  285. package/dist/src/ui/tui/primitives/LinesBlock.js.map +1 -0
  286. package/dist/src/ui/tui/primitives/LoadingBox.d.ts +8 -0
  287. package/dist/src/ui/tui/primitives/LoadingBox.js +10 -0
  288. package/dist/src/ui/tui/primitives/LoadingBox.js.map +1 -0
  289. package/dist/src/ui/tui/primitives/LogViewer.d.ts +11 -0
  290. package/dist/src/ui/tui/primitives/LogViewer.js +55 -0
  291. package/dist/src/ui/tui/primitives/LogViewer.js.map +1 -0
  292. package/dist/src/ui/tui/primitives/NodeBlock.d.ts +13 -0
  293. package/dist/src/ui/tui/primitives/NodeBlock.js +17 -0
  294. package/dist/src/ui/tui/primitives/NodeBlock.js.map +1 -0
  295. package/dist/src/ui/tui/primitives/PickerMenu.d.ts +20 -0
  296. package/dist/src/ui/tui/primitives/PickerMenu.js +134 -0
  297. package/dist/src/ui/tui/primitives/PickerMenu.js.map +1 -0
  298. package/dist/src/ui/tui/primitives/ProgressList.d.ts +15 -0
  299. package/dist/src/ui/tui/primitives/ProgressList.js +30 -0
  300. package/dist/src/ui/tui/primitives/ProgressList.js.map +1 -0
  301. package/dist/src/ui/tui/primitives/PromptLabel.d.ts +11 -0
  302. package/dist/src/ui/tui/primitives/PromptLabel.js +13 -0
  303. package/dist/src/ui/tui/primitives/PromptLabel.js.map +1 -0
  304. package/dist/src/ui/tui/primitives/ScreenContainer.d.ts +16 -0
  305. package/dist/src/ui/tui/primitives/ScreenContainer.js +36 -0
  306. package/dist/src/ui/tui/primitives/ScreenContainer.js.map +1 -0
  307. package/dist/src/ui/tui/primitives/ScreenErrorBoundary.d.ts +22 -0
  308. package/dist/src/ui/tui/primitives/ScreenErrorBoundary.js +35 -0
  309. package/dist/src/ui/tui/primitives/ScreenErrorBoundary.js.map +1 -0
  310. package/dist/src/ui/tui/primitives/SplitView.d.ts +11 -0
  311. package/dist/src/ui/tui/primitives/SplitView.js +9 -0
  312. package/dist/src/ui/tui/primitives/SplitView.js.map +1 -0
  313. package/dist/src/ui/tui/primitives/TabContainer.d.ts +23 -0
  314. package/dist/src/ui/tui/primitives/TabContainer.js +45 -0
  315. package/dist/src/ui/tui/primitives/TabContainer.js.map +1 -0
  316. package/dist/src/ui/tui/primitives/TextBlock.d.ts +41 -0
  317. package/dist/src/ui/tui/primitives/TextBlock.js +144 -0
  318. package/dist/src/ui/tui/primitives/TextBlock.js.map +1 -0
  319. package/dist/src/ui/tui/primitives/content-types.d.ts +37 -0
  320. package/dist/src/ui/tui/primitives/content-types.js +19 -0
  321. package/dist/src/ui/tui/primitives/content-types.js.map +1 -0
  322. package/dist/src/ui/tui/primitives/index.d.ts +24 -0
  323. package/dist/src/ui/tui/primitives/index.js +21 -0
  324. package/dist/src/ui/tui/primitives/index.js.map +1 -0
  325. package/dist/src/ui/tui/primitives/layout-helpers.d.ts +36 -0
  326. package/dist/src/ui/tui/primitives/layout-helpers.js +95 -0
  327. package/dist/src/ui/tui/primitives/layout-helpers.js.map +1 -0
  328. package/dist/src/ui/tui/primitives/text-helpers.d.ts +10 -0
  329. package/dist/src/ui/tui/primitives/text-helpers.js +43 -0
  330. package/dist/src/ui/tui/primitives/text-helpers.js.map +1 -0
  331. package/dist/src/ui/tui/router.d.ts +56 -0
  332. package/dist/src/ui/tui/router.js +94 -0
  333. package/dist/src/ui/tui/router.js.map +1 -0
  334. package/dist/src/ui/tui/screen-registry.d.ts +19 -0
  335. package/dist/src/ui/tui/screen-registry.js +34 -0
  336. package/dist/src/ui/tui/screen-registry.js.map +1 -0
  337. package/dist/src/ui/tui/screens/AuthScreen.d.ts +13 -0
  338. package/dist/src/ui/tui/screens/AuthScreen.js +20 -0
  339. package/dist/src/ui/tui/screens/AuthScreen.js.map +1 -0
  340. package/dist/src/ui/tui/screens/IntroScreen.d.ts +16 -0
  341. package/dist/src/ui/tui/screens/IntroScreen.js +63 -0
  342. package/dist/src/ui/tui/screens/IntroScreen.js.map +1 -0
  343. package/dist/src/ui/tui/screens/McpScreen.d.ts +24 -0
  344. package/dist/src/ui/tui/screens/McpScreen.js +112 -0
  345. package/dist/src/ui/tui/screens/McpScreen.js.map +1 -0
  346. package/dist/src/ui/tui/screens/OutageScreen.d.ts +10 -0
  347. package/dist/src/ui/tui/screens/OutageScreen.js +17 -0
  348. package/dist/src/ui/tui/screens/OutageScreen.js.map +1 -0
  349. package/dist/src/ui/tui/screens/OutroScreen.d.ts +11 -0
  350. package/dist/src/ui/tui/screens/OutroScreen.js +22 -0
  351. package/dist/src/ui/tui/screens/OutroScreen.js.map +1 -0
  352. package/dist/src/ui/tui/screens/RunScreen.d.ts +16 -0
  353. package/dist/src/ui/tui/screens/RunScreen.js +73 -0
  354. package/dist/src/ui/tui/screens/RunScreen.js.map +1 -0
  355. package/dist/src/ui/tui/screens/SettingsOverrideScreen.d.ts +10 -0
  356. package/dist/src/ui/tui/screens/SettingsOverrideScreen.js +24 -0
  357. package/dist/src/ui/tui/screens/SettingsOverrideScreen.js.map +1 -0
  358. package/dist/src/ui/tui/screens/SetupScreen.d.ts +13 -0
  359. package/dist/src/ui/tui/screens/SetupScreen.js +74 -0
  360. package/dist/src/ui/tui/screens/SetupScreen.js.map +1 -0
  361. package/dist/src/ui/tui/services/mcp-installer.d.ts +21 -0
  362. package/dist/src/ui/tui/services/mcp-installer.js +58 -0
  363. package/dist/src/ui/tui/services/mcp-installer.js.map +1 -0
  364. package/dist/src/ui/tui/start-tui.d.ts +9 -0
  365. package/dist/src/ui/tui/start-tui.js +41 -0
  366. package/dist/src/ui/tui/start-tui.js.map +1 -0
  367. package/dist/src/ui/tui/store.d.ts +132 -0
  368. package/dist/src/ui/tui/store.js +320 -0
  369. package/dist/src/ui/tui/store.js.map +1 -0
  370. package/dist/src/ui/tui/styles.d.ts +31 -0
  371. package/dist/src/ui/tui/styles.js +34 -0
  372. package/dist/src/ui/tui/styles.js.map +1 -0
  373. package/dist/src/ui/wizard-ui.d.ts +64 -0
  374. package/dist/src/ui/wizard-ui.js +19 -0
  375. package/dist/src/ui/wizard-ui.js.map +1 -0
  376. package/dist/src/utils/__tests__/setup-utils.test.d.ts +1 -0
  377. package/dist/src/utils/__tests__/{clack-utils.test.js → setup-utils.test.js} +31 -22
  378. package/dist/src/utils/__tests__/setup-utils.test.js.map +1 -0
  379. package/dist/src/utils/analytics.d.ts +18 -0
  380. package/dist/src/utils/analytics.js +53 -0
  381. package/dist/src/utils/analytics.js.map +1 -1
  382. package/dist/src/utils/anthropic-status.d.ts +1 -12
  383. package/dist/src/utils/anthropic-status.js +4 -56
  384. package/dist/src/utils/anthropic-status.js.map +1 -1
  385. package/dist/src/utils/custom-headers.d.ts +9 -0
  386. package/dist/src/utils/custom-headers.js +24 -0
  387. package/dist/src/utils/custom-headers.js.map +1 -0
  388. package/dist/src/utils/debug.js +2 -2
  389. package/dist/src/utils/debug.js.map +1 -1
  390. package/dist/src/utils/environment.js +4 -2
  391. package/dist/src/utils/environment.js.map +1 -1
  392. package/dist/src/utils/oauth.js +9 -10
  393. package/dist/src/utils/oauth.js.map +1 -1
  394. package/dist/src/utils/package-manager.js +13 -13
  395. package/dist/src/utils/package-manager.js.map +1 -1
  396. package/dist/src/utils/setup-utils.d.ts +76 -0
  397. package/dist/src/utils/setup-utils.js +364 -0
  398. package/dist/src/utils/setup-utils.js.map +1 -0
  399. package/dist/src/utils/wizard-abort.d.ts +13 -0
  400. package/dist/src/utils/wizard-abort.js +57 -0
  401. package/dist/src/utils/wizard-abort.js.map +1 -0
  402. package/package.json +19 -7
  403. package/dist/src/android/android-wizard-agent.js.map +0 -1
  404. package/dist/src/android/utils.js.map +0 -1
  405. package/dist/src/angular/angular-wizard-agent.js.map +0 -1
  406. package/dist/src/angular/utils.js.map +0 -1
  407. package/dist/src/astro/astro-wizard-agent.js.map +0 -1
  408. package/dist/src/astro/utils.js.map +0 -1
  409. package/dist/src/django/django-wizard-agent.js.map +0 -1
  410. package/dist/src/django/utils.js.map +0 -1
  411. package/dist/src/fastapi/fastapi-wizard-agent.d.ts +0 -7
  412. package/dist/src/fastapi/fastapi-wizard-agent.js.map +0 -1
  413. package/dist/src/fastapi/utils.js.map +0 -1
  414. package/dist/src/flask/flask-wizard-agent.js.map +0 -1
  415. package/dist/src/flask/utils.js.map +0 -1
  416. package/dist/src/javascript-node/javascript-node-wizard-agent.js.map +0 -1
  417. package/dist/src/javascript-web/javascript-web-wizard-agent.js.map +0 -1
  418. package/dist/src/javascript-web/utils.js.map +0 -1
  419. package/dist/src/laravel/laravel-wizard-agent.js.map +0 -1
  420. package/dist/src/laravel/utils.js.map +0 -1
  421. package/dist/src/mcp.d.ts +0 -8
  422. package/dist/src/mcp.js +0 -44
  423. package/dist/src/mcp.js.map +0 -1
  424. package/dist/src/nextjs/nextjs-wizard-agent.js.map +0 -1
  425. package/dist/src/nextjs/utils.js.map +0 -1
  426. package/dist/src/nuxt/nuxt-wizard-agent.js.map +0 -1
  427. package/dist/src/python/python-wizard-agent.js.map +0 -1
  428. package/dist/src/python/utils.js.map +0 -1
  429. package/dist/src/rails/rails-wizard-agent.js.map +0 -1
  430. package/dist/src/rails/utils.js.map +0 -1
  431. package/dist/src/react-native/react-native-wizard-agent.js.map +0 -1
  432. package/dist/src/react-native/utils.js.map +0 -1
  433. package/dist/src/react-router/react-router-wizard-agent.js.map +0 -1
  434. package/dist/src/react-router/utils.d.ts +0 -19
  435. package/dist/src/react-router/utils.js.map +0 -1
  436. package/dist/src/ruby/ruby-wizard-agent.js.map +0 -1
  437. package/dist/src/ruby/utils.js.map +0 -1
  438. package/dist/src/steps/__tests__/add-editor-rules.test.js +0 -208
  439. package/dist/src/steps/__tests__/add-editor-rules.test.js.map +0 -1
  440. package/dist/src/steps/add-editor-rules.d.ts +0 -8
  441. package/dist/src/steps/add-editor-rules.js +0 -71
  442. package/dist/src/steps/add-editor-rules.js.map +0 -1
  443. package/dist/src/svelte/svelte-wizard-agent.js.map +0 -1
  444. package/dist/src/swift/swift-wizard-agent.js.map +0 -1
  445. package/dist/src/swift/utils.js.map +0 -1
  446. package/dist/src/tanstack-router/tanstack-router-wizard-agent.js.map +0 -1
  447. package/dist/src/tanstack-router/utils.d.ts +0 -17
  448. package/dist/src/tanstack-router/utils.js.map +0 -1
  449. package/dist/src/tanstack-start/tanstack-start-wizard-agent.js.map +0 -1
  450. package/dist/src/tanstack-start/utils.js.map +0 -1
  451. package/dist/src/utils/__tests__/clack-utils.test.js.map +0 -1
  452. package/dist/src/utils/clack-utils.d.ts +0 -188
  453. package/dist/src/utils/clack-utils.js +0 -705
  454. package/dist/src/utils/clack-utils.js.map +0 -1
  455. package/dist/src/utils/clack.d.ts +0 -2
  456. package/dist/src/utils/clack.js +0 -9
  457. package/dist/src/utils/clack.js.map +0 -1
  458. package/dist/src/vue/vue-wizard-agent.js.map +0 -1
  459. /package/dist/src/{steps/__tests__/add-editor-rules.test.d.ts → __tests__/wizard-abort.test.d.ts} +0 -0
  460. /package/dist/src/{angular → frameworks/angular}/utils.d.ts +0 -0
  461. /package/dist/src/{python → frameworks/python}/utils.js +0 -0
  462. /package/dist/src/{swift → frameworks/swift}/utils.js +0 -0
  463. /package/dist/src/{tanstack-start → frameworks/tanstack-start}/utils.d.ts +0 -0
  464. /package/dist/src/{utils/__tests__/clack-utils.test.d.ts → ui/tui/__tests__/layout-helpers.test.d.ts} +0 -0
@@ -1,705 +0,0 @@
1
- "use strict";
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 });
39
- exports.abort = abort;
40
- exports.abortIfCancelled = abortIfCancelled;
41
- exports.printWelcome = printWelcome;
42
- exports.confirmContinueIfNoOrDirtyGitRepo = confirmContinueIfNoOrDirtyGitRepo;
43
- exports.isInGitRepo = isInGitRepo;
44
- exports.getUncommittedOrUntrackedFiles = getUncommittedOrUntrackedFiles;
45
- exports.askForItemSelection = askForItemSelection;
46
- exports.confirmContinueIfPackageVersionNotSupported = confirmContinueIfPackageVersionNotSupported;
47
- exports.isReact19Installed = isReact19Installed;
48
- exports.installPackage = installPackage;
49
- exports.ensurePackageIsInstalled = ensurePackageIsInstalled;
50
- exports.getPackageDotJson = getPackageDotJson;
51
- exports.tryGetPackageJson = tryGetPackageJson;
52
- exports.updatePackageDotJson = updatePackageDotJson;
53
- exports.getPackageManager = getPackageManager;
54
- exports.isUsingTypeScript = isUsingTypeScript;
55
- exports.getOrAskForProjectData = getOrAskForProjectData;
56
- exports.askForToolConfigPath = askForToolConfigPath;
57
- exports.showCopyPasteInstructions = showCopyPasteInstructions;
58
- exports.makeCodeSnippet = makeCodeSnippet;
59
- exports.createNewConfigFile = createNewConfigFile;
60
- exports.featureSelectionPrompt = featureSelectionPrompt;
61
- exports.askShouldInstallPackage = askShouldInstallPackage;
62
- exports.askShouldAddPackageOverride = askShouldAddPackageOverride;
63
- exports.askForAIConsent = askForAIConsent;
64
- const childProcess = __importStar(require("node:child_process"));
65
- const fs = __importStar(require("node:fs"));
66
- const os = __importStar(require("node:os"));
67
- const node_path_1 = require("node:path");
68
- const chalk_1 = __importDefault(require("chalk"));
69
- const telemetry_1 = require("../telemetry");
70
- const debug_1 = require("./debug");
71
- const package_json_1 = require("./package-json");
72
- const package_manager_1 = require("./package-manager");
73
- const semver_1 = require("./semver");
74
- const package_json_2 = require("./package-json");
75
- const constants_1 = require("../lib/constants");
76
- const analytics_1 = require("./analytics");
77
- const clack_1 = __importDefault(require("./clack"));
78
- const urls_1 = require("./urls");
79
- const registry_1 = require("../lib/registry");
80
- const oauth_1 = require("./oauth");
81
- const api_1 = require("../lib/api");
82
- async function abort(message, status) {
83
- await analytics_1.analytics.shutdown('cancelled');
84
- clack_1.default.outro(message ?? 'Wizard setup cancelled.');
85
- return process.exit(status ?? 1);
86
- }
87
- async function abortIfCancelled(input, integration) {
88
- await analytics_1.analytics.shutdown('cancelled');
89
- const resolvedInput = await input;
90
- if (clack_1.default.isCancel(resolvedInput) ||
91
- (typeof resolvedInput === 'symbol' &&
92
- resolvedInput.description === 'clack:cancel')) {
93
- const docsUrl = integration
94
- ? registry_1.FRAMEWORK_REGISTRY[integration].metadata.docsUrl
95
- : 'https://posthog.com/docs';
96
- clack_1.default.cancel(`Wizard setup cancelled. You can read the documentation for ${integration ?? 'PostHog'} at ${chalk_1.default.cyan(docsUrl)} to continue with the setup manually.`);
97
- process.exit(0);
98
- }
99
- else {
100
- return input;
101
- }
102
- }
103
- function printWelcome(options) {
104
- // eslint-disable-next-line no-console
105
- console.log('');
106
- clack_1.default.intro(chalk_1.default.inverse(` ${options.wizardName} `));
107
- }
108
- async function confirmContinueIfNoOrDirtyGitRepo(options) {
109
- return (0, telemetry_1.traceStep)('check-git-status', async () => {
110
- if (!isInGitRepo()) {
111
- // CI mode: auto-continue without git
112
- const continueWithoutGit = options.default || options.ci
113
- ? true
114
- : await abortIfCancelled(clack_1.default.confirm({
115
- message: 'You are not inside a git repository. The wizard will create and update files. Do you want to continue anyway?',
116
- }));
117
- analytics_1.analytics.setTag('continue-without-git', continueWithoutGit);
118
- if (!continueWithoutGit) {
119
- await abort(undefined, 0);
120
- }
121
- // return early to avoid checking for uncommitted files
122
- return;
123
- }
124
- const uncommittedOrUntrackedFiles = getUncommittedOrUntrackedFiles();
125
- if (uncommittedOrUntrackedFiles.length) {
126
- // CI mode: auto-continue with dirty repo
127
- if (options.ci) {
128
- clack_1.default.log.info(`CI mode: continuing with uncommitted/untracked files in repo`);
129
- analytics_1.analytics.setTag('continue-with-dirty-repo', true);
130
- return;
131
- }
132
- clack_1.default.log.warn(`You have uncommitted or untracked files in your repo:
133
-
134
- ${uncommittedOrUntrackedFiles.join('\n')}
135
-
136
- The wizard will create and update files.`);
137
- const continueWithDirtyRepo = await abortIfCancelled(clack_1.default.confirm({
138
- message: 'Do you want to continue anyway?',
139
- }));
140
- analytics_1.analytics.setTag('continue-with-dirty-repo', continueWithDirtyRepo);
141
- if (!continueWithDirtyRepo) {
142
- await abort(undefined, 0);
143
- }
144
- }
145
- });
146
- }
147
- function isInGitRepo() {
148
- try {
149
- childProcess.execSync('git rev-parse --is-inside-work-tree', {
150
- stdio: 'ignore',
151
- });
152
- return true;
153
- }
154
- catch {
155
- return false;
156
- }
157
- }
158
- function getUncommittedOrUntrackedFiles() {
159
- try {
160
- const gitStatus = childProcess
161
- .execSync('git status --porcelain=v1', {
162
- // we only care about stdout
163
- stdio: ['ignore', 'pipe', 'ignore'],
164
- })
165
- .toString();
166
- const files = gitStatus
167
- .split(os.EOL)
168
- .map((line) => line.trim())
169
- .filter(Boolean)
170
- .map((f) => `- ${f.split(/\s+/)[1]}`);
171
- return files;
172
- }
173
- catch {
174
- return [];
175
- }
176
- }
177
- async function askForItemSelection(items, message) {
178
- const selection = await abortIfCancelled(clack_1.default.select({
179
- maxItems: 12,
180
- message: message,
181
- options: items.map((item, index) => {
182
- return {
183
- value: { value: item, index: index },
184
- label: item,
185
- };
186
- }),
187
- }));
188
- return selection;
189
- }
190
- async function confirmContinueIfPackageVersionNotSupported({ packageId, packageName, packageVersion, acceptableVersions, note, }) {
191
- return (0, telemetry_1.traceStep)(`check-package-version`, async () => {
192
- analytics_1.analytics.setTag(`${packageName.toLowerCase()}-version`, packageVersion);
193
- const isSupportedVersion = (0, semver_1.fulfillsVersionRange)({
194
- acceptableVersions,
195
- version: packageVersion,
196
- canBeLatest: true,
197
- });
198
- if (isSupportedVersion) {
199
- analytics_1.analytics.setTag(`${packageName.toLowerCase()}-supported`, true);
200
- return;
201
- }
202
- clack_1.default.log.warn(`You have an unsupported version of ${packageName} installed:
203
-
204
- ${packageId}@${packageVersion}`);
205
- clack_1.default.note(note ??
206
- `Please upgrade to ${acceptableVersions} if you wish to use the PostHog wizard.`);
207
- const continueWithUnsupportedVersion = await abortIfCancelled(clack_1.default.confirm({
208
- message: 'Do you want to continue anyway?',
209
- }));
210
- analytics_1.analytics.setTag(`${packageName.toLowerCase()}-continue-with-unsupported-version`, continueWithUnsupportedVersion);
211
- if (!continueWithUnsupportedVersion) {
212
- await abort(undefined, 0);
213
- }
214
- });
215
- }
216
- async function isReact19Installed({ installDir, }) {
217
- try {
218
- const packageJson = await getPackageDotJson({ installDir });
219
- const reactVersion = (0, package_json_2.getPackageVersion)('react', packageJson);
220
- if (!reactVersion) {
221
- return false;
222
- }
223
- return (0, semver_1.fulfillsVersionRange)({
224
- version: reactVersion,
225
- acceptableVersions: '>=19.0.0',
226
- canBeLatest: true,
227
- });
228
- }
229
- catch (error) {
230
- return false;
231
- }
232
- }
233
- /**
234
- * Installs or updates a package with the user's package manager.
235
- *
236
- * IMPORTANT: This function modifies the `package.json`! Be sure to re-read
237
- * it if you make additional modifications to it after calling this function!
238
- */
239
- async function installPackage({ packageName, alreadyInstalled, askBeforeUpdating = true, packageNameDisplayLabel, packageManager, forceInstall = false, integration, installDir, }) {
240
- return (0, telemetry_1.traceStep)('install-package', async () => {
241
- if (alreadyInstalled && askBeforeUpdating) {
242
- const shouldUpdatePackage = await abortIfCancelled(clack_1.default.confirm({
243
- message: `The ${chalk_1.default.bold.cyan(packageNameDisplayLabel ?? packageName)} package is already installed. Do you want to update it to the latest version?`,
244
- }));
245
- if (!shouldUpdatePackage) {
246
- return {};
247
- }
248
- }
249
- const sdkInstallSpinner = clack_1.default.spinner();
250
- const pkgManager = packageManager || (await getPackageManager({ installDir }));
251
- // Most packages aren't compatible with React 19 yet, skip strict peer dependency checks if needed.
252
- const isReact19 = await isReact19Installed({ installDir });
253
- const legacyPeerDepsFlag = isReact19 && pkgManager.name === 'npm' ? '--legacy-peer-deps' : '';
254
- sdkInstallSpinner.start(`${alreadyInstalled ? 'Updating' : 'Installing'} ${chalk_1.default.bold.cyan(packageNameDisplayLabel ?? packageName)} with ${chalk_1.default.bold(pkgManager.label)}.`);
255
- try {
256
- await new Promise((resolve, reject) => {
257
- childProcess.exec(`${pkgManager.installCommand} ${packageName} ${pkgManager.flags} ${forceInstall ? pkgManager.forceInstallFlag : ''} ${legacyPeerDepsFlag}`.trim(), { cwd: installDir }, (err, stdout, stderr) => {
258
- if (err) {
259
- // Write a log file so we can better troubleshoot issues
260
- fs.writeFileSync((0, node_path_1.join)(process.cwd(), `posthog-wizard-installation-error-${Date.now()}.log`), JSON.stringify({
261
- stdout,
262
- stderr,
263
- }), { encoding: 'utf8' });
264
- reject(err);
265
- }
266
- else {
267
- resolve();
268
- }
269
- });
270
- });
271
- }
272
- catch (e) {
273
- sdkInstallSpinner.stop('Installation failed.');
274
- clack_1.default.log.error(`${chalk_1.default.red('Encountered the following error during installation:')}\n\n${e}\n\n${chalk_1.default.dim(`The wizard has created a \`posthog-wizard-installation-error-*.log\` file. If you think this issue is caused by the PostHog wizard, create an issue on GitHub and include the log file's content:\n${constants_1.ISSUES_URL}`)}`);
275
- await abort();
276
- }
277
- sdkInstallSpinner.stop(`${alreadyInstalled ? 'Updated' : 'Installed'} ${chalk_1.default.bold.cyan(packageNameDisplayLabel ?? packageName)} with ${chalk_1.default.bold(pkgManager.label)}.`);
278
- analytics_1.analytics.capture('wizard interaction', {
279
- action: 'package installed',
280
- package_name: packageName,
281
- package_manager: pkgManager.name,
282
- integration,
283
- });
284
- return { packageManager: pkgManager };
285
- });
286
- }
287
- /**
288
- * Checks if @param packageId is listed as a dependency in @param packageJson.
289
- * If not, it will ask users if they want to continue without the package.
290
- *
291
- * Use this function to check if e.g. a the framework of the SDK is installed
292
- *
293
- * @param packageJson the package.json object
294
- * @param packageId the npm name of the package
295
- * @param packageName a human readable name of the package
296
- */
297
- async function ensurePackageIsInstalled(packageJson, packageId, packageName) {
298
- return (0, telemetry_1.traceStep)('ensure-package-installed', async () => {
299
- const installed = (0, package_json_1.hasPackageInstalled)(packageId, packageJson);
300
- analytics_1.analytics.setTag(`${packageName.toLowerCase()}-installed`, installed);
301
- if (!installed) {
302
- const continueWithoutPackage = await abortIfCancelled(clack_1.default.confirm({
303
- message: `${packageName} does not seem to be installed. Do you still want to continue?`,
304
- initialValue: false,
305
- }));
306
- if (!continueWithoutPackage) {
307
- await abort(undefined, 0);
308
- }
309
- }
310
- });
311
- }
312
- async function getPackageDotJson({ installDir, }) {
313
- const packageJsonFileContents = await fs.promises
314
- .readFile((0, node_path_1.join)(installDir, 'package.json'), 'utf8')
315
- .catch(() => {
316
- clack_1.default.log.error('Could not find package.json. Make sure to run the wizard in the root of your app!');
317
- return abort();
318
- });
319
- let packageJson = undefined;
320
- try {
321
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
322
- packageJson = JSON.parse(packageJsonFileContents);
323
- }
324
- catch {
325
- clack_1.default.log.error(`Unable to parse your ${chalk_1.default.cyan('package.json')}. Make sure it has a valid format!`);
326
- await abort();
327
- }
328
- return packageJson || {};
329
- }
330
- /**
331
- * Try to get package.json, returning null if it doesn't exist.
332
- * Use this for detection purposes where missing package.json is expected (e.g., Python projects).
333
- */
334
- async function tryGetPackageJson({ installDir, }) {
335
- try {
336
- const packageJsonFileContents = await fs.promises.readFile((0, node_path_1.join)(installDir, 'package.json'), 'utf8');
337
- return JSON.parse(packageJsonFileContents);
338
- }
339
- catch {
340
- return null;
341
- }
342
- }
343
- async function updatePackageDotJson(packageDotJson, { installDir }) {
344
- try {
345
- await fs.promises.writeFile((0, node_path_1.join)(installDir, 'package.json'),
346
- // TODO: maybe figure out the original indentation
347
- JSON.stringify(packageDotJson, null, 2), {
348
- encoding: 'utf8',
349
- flag: 'w',
350
- });
351
- }
352
- catch {
353
- clack_1.default.log.error(`Unable to update your ${chalk_1.default.cyan('package.json')}.`);
354
- await abort();
355
- }
356
- }
357
- async function getPackageManager(options) {
358
- const detectedPackageManagers = (0, package_manager_1.detectAllPackageManagers)({
359
- installDir: options.installDir,
360
- });
361
- // If exactly one package manager detected, use it automatically
362
- if (detectedPackageManagers.length === 1) {
363
- const detectedPackageManager = detectedPackageManagers[0];
364
- analytics_1.analytics.setTag('package-manager', detectedPackageManager.name);
365
- return detectedPackageManager;
366
- }
367
- // CI mode: auto-select first detected or npm
368
- if (options.ci) {
369
- const selectedPackageManager = detectedPackageManagers.length > 0 ? detectedPackageManagers[0] : package_manager_1.NPM;
370
- clack_1.default.log.info(`CI mode: auto-selected package manager: ${selectedPackageManager.label}`);
371
- analytics_1.analytics.setTag('package-manager', selectedPackageManager.name);
372
- return selectedPackageManager;
373
- }
374
- // If multiple or no package managers detected, prompt user to select
375
- const pkgOptions = detectedPackageManagers.length > 0
376
- ? detectedPackageManagers
377
- : package_manager_1.packageManagers;
378
- const message = detectedPackageManagers.length > 1
379
- ? 'Multiple package managers detected. Please select one:'
380
- : 'Please select your package manager.';
381
- const selectedPackageManager = await abortIfCancelled(clack_1.default.select({
382
- message,
383
- options: pkgOptions.map((packageManager) => ({
384
- value: packageManager,
385
- label: packageManager.label,
386
- })),
387
- }));
388
- analytics_1.analytics.setTag('package-manager', selectedPackageManager.name);
389
- return selectedPackageManager;
390
- }
391
- function isUsingTypeScript({ installDir, }) {
392
- try {
393
- return fs.existsSync((0, node_path_1.join)(installDir, 'tsconfig.json'));
394
- }
395
- catch {
396
- return false;
397
- }
398
- }
399
- /**
400
- *
401
- * Use this function to get project data for the wizard.
402
- *
403
- * @param options wizard options
404
- * @returns project data (token, url)
405
- */
406
- async function getOrAskForProjectData(_options) {
407
- // CI mode: bypass OAuth, use personal API key for LLM gateway
408
- if (_options.ci && _options.apiKey) {
409
- clack_1.default.log.info('Using provided API key (CI mode - OAuth bypassed)');
410
- const cloudRegion = await (0, urls_1.detectRegionFromToken)(_options.apiKey);
411
- const host = (0, urls_1.getHostFromRegion)(cloudRegion);
412
- const cloudUrl = (0, urls_1.getCloudUrlFromRegion)(cloudRegion);
413
- const projectData = _options.projectId != null
414
- ? await fetchProjectDataById(_options.apiKey, _options.projectId, cloudUrl)
415
- : await fetchProjectDataWithApiKey(_options.apiKey, cloudUrl);
416
- return {
417
- host,
418
- projectApiKey: projectData.api_token,
419
- accessToken: _options.apiKey,
420
- projectId: projectData.id,
421
- cloudRegion,
422
- };
423
- }
424
- const { host, projectApiKey, accessToken, projectId, cloudRegion } = await (0, telemetry_1.traceStep)('login', () => askForWizardLogin({
425
- signup: _options.signup,
426
- }));
427
- if (!projectApiKey) {
428
- const cloudUrl = (0, urls_1.getCloudUrlFromRegion)(cloudRegion);
429
- clack_1.default.log.error(`Didn't receive a project API key. This shouldn't happen :(
430
-
431
- Please let us know if you think this is a bug in the wizard:
432
- ${chalk_1.default.cyan(constants_1.ISSUES_URL)}`);
433
- clack_1.default.log
434
- .info(`In the meantime, we'll add a dummy project API key (${chalk_1.default.cyan(`"${constants_1.DUMMY_PROJECT_API_KEY}"`)}) for you to replace later.
435
- You can find your Project API key here:
436
- ${chalk_1.default.cyan(`${cloudUrl}/settings/project#variables`)}`);
437
- }
438
- return {
439
- accessToken,
440
- host: host || constants_1.DEFAULT_HOST_URL,
441
- projectApiKey: projectApiKey || constants_1.DUMMY_PROJECT_API_KEY,
442
- projectId,
443
- cloudRegion,
444
- };
445
- }
446
- /**
447
- * Fetch project data for a specific project ID (for CI mode with --project-id).
448
- */
449
- async function fetchProjectDataById(apiKey, projectId, cloudUrl) {
450
- const projectData = await (0, api_1.fetchProjectData)(apiKey, projectId, cloudUrl);
451
- return {
452
- api_token: projectData.api_token,
453
- id: projectData.id,
454
- };
455
- }
456
- async function fetchProjectDataWithApiKey(apiKey, cloudUrl) {
457
- const userData = await (0, api_1.fetchUserData)(apiKey, cloudUrl);
458
- const projectId = userData.team?.id;
459
- if (!projectId) {
460
- throw new Error('Could not determine project ID from API key. Please ensure your API key has access to a project.');
461
- }
462
- try {
463
- const projectData = await (0, api_1.fetchProjectData)(apiKey, projectId, cloudUrl);
464
- return {
465
- api_token: projectData.api_token,
466
- id: projectId,
467
- };
468
- }
469
- catch (error) {
470
- throw new Error(`Failed to fetch project data for project ${projectId} (resolved from your user's last selected project in the PostHog app). This can happen if your API key is scoped to a different project or organization.\n\nTry passing --project-id or setting the POSTHOG_WIZARD_PROJECT_ID environment variable explicitly.`, { cause: error });
471
- }
472
- }
473
- async function askForWizardLogin(options) {
474
- const tokenResponse = await (0, oauth_1.performOAuthFlow)({
475
- scopes: [
476
- 'user:read',
477
- 'project:read',
478
- 'introspection',
479
- 'llm_gateway:read',
480
- 'dashboard:write',
481
- 'insight:write',
482
- 'query:read',
483
- ],
484
- signup: options.signup,
485
- });
486
- const projectId = tokenResponse.scoped_teams?.[0];
487
- if (projectId === undefined) {
488
- const error = new Error('No project access granted. Please authorize with project-level access.');
489
- analytics_1.analytics.captureException(error, {
490
- step: 'wizard_login',
491
- has_scoped_teams: !!tokenResponse.scoped_teams,
492
- });
493
- clack_1.default.log.error(error.message);
494
- await abort();
495
- }
496
- const cloudRegion = await (0, urls_1.detectRegionFromToken)(tokenResponse.access_token);
497
- const cloudUrl = (0, urls_1.getCloudUrlFromRegion)(cloudRegion);
498
- const host = (0, urls_1.getHostFromRegion)(cloudRegion);
499
- const projectData = await (0, api_1.fetchProjectData)(tokenResponse.access_token, projectId, cloudUrl);
500
- const userData = await (0, api_1.fetchUserData)(tokenResponse.access_token, cloudUrl);
501
- const data = {
502
- accessToken: tokenResponse.access_token,
503
- projectApiKey: projectData.api_token,
504
- host,
505
- distinctId: userData.distinct_id,
506
- projectId: projectId,
507
- cloudRegion,
508
- };
509
- clack_1.default.log.success(`Login complete. ${options.signup ? 'Welcome to PostHog! 🎉' : ''}`);
510
- analytics_1.analytics.setTag('opened-wizard-link', true);
511
- analytics_1.analytics.setDistinctId(data.distinctId);
512
- return data;
513
- }
514
- /**
515
- * Asks users if they have a config file for @param tool (e.g. Vite).
516
- * If yes, asks users to specify the path to their config file.
517
- *
518
- * Use this helper function as a fallback mechanism if the lookup for
519
- * a config file with its most usual location/name fails.
520
- *
521
- * @param toolName Name of the tool for which we're looking for the config file
522
- * @param configFileName Name of the most common config file name (e.g. vite.config.js)
523
- *
524
- * @returns a user path to the config file or undefined if the user doesn't have a config file
525
- */
526
- async function askForToolConfigPath(toolName, configFileName) {
527
- const hasConfig = await abortIfCancelled(clack_1.default.confirm({
528
- message: `Do you have a ${toolName} config file (e.g. ${chalk_1.default.cyan(configFileName)})?`,
529
- initialValue: true,
530
- }));
531
- if (!hasConfig) {
532
- return undefined;
533
- }
534
- return await abortIfCancelled(clack_1.default.text({
535
- message: `Please enter the path to your ${toolName} config file:`,
536
- placeholder: (0, node_path_1.join)('.', configFileName),
537
- validate: (value) => {
538
- if (!value) {
539
- return 'Please enter a path.';
540
- }
541
- try {
542
- fs.accessSync(value);
543
- }
544
- catch {
545
- return 'Could not access the file at this path.';
546
- }
547
- },
548
- }));
549
- }
550
- /**
551
- * Prints copy/paste-able instructions to the console.
552
- * Afterwards asks the user if they added the code snippet to their file.
553
- *
554
- * While there's no point in providing a "no" answer here, it gives users time to fulfill the
555
- * task before the wizard continues with additional steps.
556
- *
557
- * Use this function if you want to show users instructions on how to add/modify
558
- * code in their file. This is helpful if automatic insertion failed or is not possible/feasible.
559
- *
560
- * @param filename the name of the file to which the code snippet should be applied.
561
- * If a path is provided, only the filename will be used.
562
- *
563
- * @param codeSnippet the snippet to be printed. Use {@link makeCodeSnippet} to create the
564
- * diff-like format for visually highlighting unchanged or modified lines of code.
565
- *
566
- * @param hint (optional) a hint to be printed after the main instruction to add
567
- * the code from @param codeSnippet to their @param filename.
568
- *
569
- * TODO: refactor copy paste instructions across different wizards to use this function.
570
- * this might require adding a custom message parameter to the function
571
- */
572
- async function showCopyPasteInstructions(filename, codeSnippet, hint) {
573
- clack_1.default.log.step(`Add the following code to your ${chalk_1.default.cyan((0, node_path_1.basename)(filename))} file:${hint ? chalk_1.default.dim(` (${chalk_1.default.dim(hint)})`) : ''}`);
574
- // Padding the code snippet to be printed with a \n at the beginning and end
575
- // This makes it easier to distinguish the snippet from the rest of the output
576
- // Intentionally logging directly to console here so that the code can be copied/pasted directly
577
- // eslint-disable-next-line no-console
578
- console.log(`\n${codeSnippet}\n`);
579
- await abortIfCancelled(clack_1.default.select({
580
- message: 'Did you apply the snippet above?',
581
- options: [{ label: 'Yes, continue!', value: true }],
582
- initialValue: true,
583
- }));
584
- }
585
- /**
586
- * Crafts a code snippet that can be used to e.g.
587
- * - print copy/paste instructions to the console
588
- * - create a new config file.
589
- *
590
- * @param colors set this to true if you want the final snippet to be colored.
591
- * This is useful for printing the snippet to the console as part of copy/paste instructions.
592
- *
593
- * @param callback the callback that returns the formatted code snippet.
594
- * It exposes takes the helper functions for marking code as unchanged, new or removed.
595
- * These functions no-op if no special formatting should be applied
596
- * and otherwise apply the appropriate formatting/coloring.
597
- * (@see {@link CodeSnippetFormatter})
598
- *
599
- * @see {@link showCopyPasteInstructions} for the helper with which to display the snippet in the console.
600
- *
601
- * @returns a string containing the final, formatted code snippet.
602
- */
603
- function makeCodeSnippet(colors, callback) {
604
- const unchanged = (txt) => (colors ? chalk_1.default.grey(txt) : txt);
605
- const plus = (txt) => (colors ? chalk_1.default.greenBright(txt) : txt);
606
- const minus = (txt) => (colors ? chalk_1.default.redBright(txt) : txt);
607
- return callback(unchanged, plus, minus);
608
- }
609
- /**
610
- * Creates a new config file with the given @param filepath and @param codeSnippet.
611
- *
612
- * Use this function to create a new config file for users. This is useful
613
- * when users answered that they don't yet have a config file for a tool.
614
- *
615
- * (This doesn't mean that they don't yet have some other way of configuring
616
- * their tool but we can leave it up to them to figure out how to merge configs
617
- * here.)
618
- *
619
- * @param filepath absolute path to the new config file
620
- * @param codeSnippet the snippet to be inserted into the file
621
- * @param moreInformation (optional) the message to be printed after the file was created
622
- * For example, this can be a link to more information about configuring the tool.
623
- *
624
- * @returns true on success, false otherwise
625
- */
626
- async function createNewConfigFile(filepath, codeSnippet, { installDir }, moreInformation) {
627
- if (!(0, node_path_1.isAbsolute)(filepath)) {
628
- (0, debug_1.debug)(`createNewConfigFile: filepath is not absolute: ${filepath}`);
629
- return false;
630
- }
631
- const prettyFilename = chalk_1.default.cyan((0, node_path_1.relative)(installDir, filepath));
632
- try {
633
- await fs.promises.writeFile(filepath, codeSnippet);
634
- clack_1.default.log.success(`Added new ${prettyFilename} file.`);
635
- if (moreInformation) {
636
- clack_1.default.log.info(chalk_1.default.gray(moreInformation));
637
- }
638
- return true;
639
- }
640
- catch (e) {
641
- (0, debug_1.debug)(e);
642
- clack_1.default.log.warn(`Could not create a new ${prettyFilename} file. Please create one manually and follow the instructions below.`);
643
- }
644
- return false;
645
- }
646
- async function featureSelectionPrompt(features) {
647
- return (0, telemetry_1.traceStep)('feature-selection', async () => {
648
- const selectedFeatures = {};
649
- for (const feature of features) {
650
- const selected = await abortIfCancelled(clack_1.default.select({
651
- message: feature.prompt,
652
- initialValue: true,
653
- options: [
654
- {
655
- value: true,
656
- label: 'Yes',
657
- hint: feature.enabledHint,
658
- },
659
- {
660
- value: false,
661
- label: 'No',
662
- hint: feature.disabledHint,
663
- },
664
- ],
665
- }));
666
- selectedFeatures[feature.id] = selected;
667
- }
668
- return selectedFeatures;
669
- });
670
- }
671
- async function askShouldInstallPackage(pkgName) {
672
- return (0, telemetry_1.traceStep)(`ask-install-package`, () => abortIfCancelled(clack_1.default.confirm({
673
- message: `Do you want to install ${chalk_1.default.cyan(pkgName)}?`,
674
- })));
675
- }
676
- async function askShouldAddPackageOverride(pkgName, pkgVersion) {
677
- return (0, telemetry_1.traceStep)(`ask-add-package-override`, () => abortIfCancelled(clack_1.default.confirm({
678
- message: `Do you want to add an override for ${chalk_1.default.cyan(pkgName)} version ${chalk_1.default.cyan(pkgVersion)}?`,
679
- })));
680
- }
681
- async function askForAIConsent(options) {
682
- return await (0, telemetry_1.traceStep)('ask-for-ai-consent', async () => {
683
- // CI mode: auto-consent to AI
684
- const aiConsent = options.default || options.ci
685
- ? true
686
- : await abortIfCancelled(clack_1.default.select({
687
- message: 'This setup wizard uses AI, are you happy to continue? ✨',
688
- options: [
689
- {
690
- label: 'Yes',
691
- value: true,
692
- hint: 'We will use AI to help you setup PostHog quickly',
693
- },
694
- {
695
- label: 'No',
696
- value: false,
697
- hint: "I don't like AI",
698
- },
699
- ],
700
- initialValue: true,
701
- }));
702
- return aiConsent;
703
- });
704
- }
705
- //# sourceMappingURL=clack-utils.js.map