workos 0.0.24 → 0.1.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 (305) hide show
  1. package/.claude-plugin/plugin.json +13 -0
  2. package/LICENSE +47 -0
  3. package/README.md +154 -1
  4. package/dist/bin.d.ts +2 -0
  5. package/dist/bin.js +163 -0
  6. package/dist/bin.js.map +1 -0
  7. package/dist/cli.config.d.ts +52 -0
  8. package/dist/cli.config.js +70 -0
  9. package/dist/cli.config.js.map +1 -0
  10. package/dist/package.json +87 -0
  11. package/dist/src/commands/install-skill.d.ts +20 -0
  12. package/dist/src/commands/install-skill.js +130 -0
  13. package/dist/src/commands/install-skill.js.map +1 -0
  14. package/dist/src/commands/install.d.ts +22 -0
  15. package/dist/src/commands/install.js +57 -0
  16. package/dist/src/commands/install.js.map +1 -0
  17. package/dist/src/commands/login.d.ts +1 -0
  18. package/dist/src/commands/login.js +141 -0
  19. package/dist/src/commands/login.js.map +1 -0
  20. package/dist/src/commands/logout.d.ts +1 -0
  21. package/dist/src/commands/logout.js +17 -0
  22. package/dist/src/commands/logout.js.map +1 -0
  23. package/dist/src/dashboard/components/AnimatedLogo.d.ts +8 -0
  24. package/dist/src/dashboard/components/AnimatedLogo.js +16 -0
  25. package/dist/src/dashboard/components/AnimatedLogo.js.map +1 -0
  26. package/dist/src/dashboard/components/CompletionView.d.ts +13 -0
  27. package/dist/src/dashboard/components/CompletionView.js +21 -0
  28. package/dist/src/dashboard/components/CompletionView.js.map +1 -0
  29. package/dist/src/dashboard/components/ConfirmPrompt.d.ts +9 -0
  30. package/dist/src/dashboard/components/ConfirmPrompt.js +25 -0
  31. package/dist/src/dashboard/components/ConfirmPrompt.js.map +1 -0
  32. package/dist/src/dashboard/components/CredentialsForm.d.ts +10 -0
  33. package/dist/src/dashboard/components/CredentialsForm.js +47 -0
  34. package/dist/src/dashboard/components/CredentialsForm.js.map +1 -0
  35. package/dist/src/dashboard/components/Dashboard.d.ts +3 -0
  36. package/dist/src/dashboard/components/Dashboard.js +100 -0
  37. package/dist/src/dashboard/components/Dashboard.js.map +1 -0
  38. package/dist/src/dashboard/components/DashboardLayout.d.ts +24 -0
  39. package/dist/src/dashboard/components/DashboardLayout.js +25 -0
  40. package/dist/src/dashboard/components/DashboardLayout.js.map +1 -0
  41. package/dist/src/dashboard/components/DiffPanel.d.ts +9 -0
  42. package/dist/src/dashboard/components/DiffPanel.js +136 -0
  43. package/dist/src/dashboard/components/DiffPanel.js.map +1 -0
  44. package/dist/src/dashboard/components/InlinePrompt.d.ts +8 -0
  45. package/dist/src/dashboard/components/InlinePrompt.js +19 -0
  46. package/dist/src/dashboard/components/InlinePrompt.js.map +1 -0
  47. package/dist/src/dashboard/components/OutputPanel.d.ts +10 -0
  48. package/dist/src/dashboard/components/OutputPanel.js +100 -0
  49. package/dist/src/dashboard/components/OutputPanel.js.map +1 -0
  50. package/dist/src/dashboard/components/Panel.d.ts +12 -0
  51. package/dist/src/dashboard/components/Panel.js +6 -0
  52. package/dist/src/dashboard/components/Panel.js.map +1 -0
  53. package/dist/src/dashboard/components/TextInput.d.ts +13 -0
  54. package/dist/src/dashboard/components/TextInput.js +57 -0
  55. package/dist/src/dashboard/components/TextInput.js.map +1 -0
  56. package/dist/src/dashboard/components/WelcomeArt.d.ts +2 -0
  57. package/dist/src/dashboard/components/WelcomeArt.js +9 -0
  58. package/dist/src/dashboard/components/WelcomeArt.js.map +1 -0
  59. package/dist/src/dashboard/hooks/useAnimation.d.ts +7 -0
  60. package/dist/src/dashboard/hooks/useAnimation.js +24 -0
  61. package/dist/src/dashboard/hooks/useAnimation.js.map +1 -0
  62. package/dist/src/dashboard/hooks/useKeyboard.d.ts +8 -0
  63. package/dist/src/dashboard/hooks/useKeyboard.js +18 -0
  64. package/dist/src/dashboard/hooks/useKeyboard.js.map +1 -0
  65. package/dist/src/dashboard/hooks/useTerminalSize.d.ts +8 -0
  66. package/dist/src/dashboard/hooks/useTerminalSize.js +23 -0
  67. package/dist/src/dashboard/hooks/useTerminalSize.js.map +1 -0
  68. package/dist/src/dashboard/index.d.ts +6 -0
  69. package/dist/src/dashboard/index.js +36 -0
  70. package/dist/src/dashboard/index.js.map +1 -0
  71. package/dist/src/dashboard/lib/diff-utils.d.ts +21 -0
  72. package/dist/src/dashboard/lib/diff-utils.js +271 -0
  73. package/dist/src/dashboard/lib/diff-utils.js.map +1 -0
  74. package/dist/src/dashboard/lib/logo-frames.d.ts +20 -0
  75. package/dist/src/dashboard/lib/logo-frames.js +109 -0
  76. package/dist/src/dashboard/lib/logo-frames.js.map +1 -0
  77. package/dist/src/dashboard/lib/welcome-art.d.ts +1 -0
  78. package/dist/src/dashboard/lib/welcome-art.js +5 -0
  79. package/dist/src/dashboard/lib/welcome-art.js.map +1 -0
  80. package/dist/src/dashboard/types.d.ts +5 -0
  81. package/dist/src/dashboard/types.js +2 -0
  82. package/dist/src/dashboard/types.js.map +1 -0
  83. package/dist/src/lib/__tests__/test-utils.d.ts +40 -0
  84. package/dist/src/lib/__tests__/test-utils.js +108 -0
  85. package/dist/src/lib/__tests__/test-utils.js.map +1 -0
  86. package/dist/src/lib/adapters/cli-adapter.d.ts +56 -0
  87. package/dist/src/lib/adapters/cli-adapter.js +318 -0
  88. package/dist/src/lib/adapters/cli-adapter.js.map +1 -0
  89. package/dist/src/lib/adapters/dashboard-adapter.d.ts +30 -0
  90. package/dist/src/lib/adapters/dashboard-adapter.js +97 -0
  91. package/dist/src/lib/adapters/dashboard-adapter.js.map +1 -0
  92. package/dist/src/lib/adapters/index.d.ts +3 -0
  93. package/dist/src/lib/adapters/index.js +3 -0
  94. package/dist/src/lib/adapters/index.js.map +1 -0
  95. package/dist/src/lib/adapters/types.d.ts +41 -0
  96. package/dist/src/lib/adapters/types.js +2 -0
  97. package/dist/src/lib/adapters/types.js.map +1 -0
  98. package/dist/src/lib/agent-interface.d.ts +75 -0
  99. package/dist/src/lib/agent-interface.js +563 -0
  100. package/dist/src/lib/agent-interface.js.map +1 -0
  101. package/dist/src/lib/agent-runner.d.ts +9 -0
  102. package/dist/src/lib/agent-runner.js +213 -0
  103. package/dist/src/lib/agent-runner.js.map +1 -0
  104. package/dist/src/lib/api.d.ts +25 -0
  105. package/dist/src/lib/api.js +120 -0
  106. package/dist/src/lib/api.js.map +1 -0
  107. package/dist/src/lib/config.d.ts +60 -0
  108. package/dist/src/lib/config.js +88 -0
  109. package/dist/src/lib/config.js.map +1 -0
  110. package/dist/src/lib/constants.d.ts +32 -0
  111. package/dist/src/lib/constants.js +53 -0
  112. package/dist/src/lib/constants.js.map +1 -0
  113. package/dist/src/lib/credentials.d.ts +19 -0
  114. package/dist/src/lib/credentials.js +55 -0
  115. package/dist/src/lib/credentials.js.map +1 -0
  116. package/dist/src/lib/env-writer.d.ts +14 -0
  117. package/dist/src/lib/env-writer.js +39 -0
  118. package/dist/src/lib/env-writer.js.map +1 -0
  119. package/dist/src/lib/events.d.ts +114 -0
  120. package/dist/src/lib/events.js +19 -0
  121. package/dist/src/lib/events.js.map +1 -0
  122. package/dist/src/lib/framework-config.d.ts +108 -0
  123. package/dist/src/lib/framework-config.js +11 -0
  124. package/dist/src/lib/framework-config.js.map +1 -0
  125. package/dist/src/lib/helper-functions.d.ts +1 -0
  126. package/dist/src/lib/helper-functions.js +2 -0
  127. package/dist/src/lib/helper-functions.js.map +1 -0
  128. package/dist/src/lib/port-detection.d.ts +7 -0
  129. package/dist/src/lib/port-detection.js +112 -0
  130. package/dist/src/lib/port-detection.js.map +1 -0
  131. package/dist/src/lib/progress-tracker.d.ts +22 -0
  132. package/dist/src/lib/progress-tracker.js +47 -0
  133. package/dist/src/lib/progress-tracker.js.map +1 -0
  134. package/dist/src/lib/run-with-core.d.ts +2 -0
  135. package/dist/src/lib/run-with-core.js +266 -0
  136. package/dist/src/lib/run-with-core.js.map +1 -0
  137. package/dist/src/lib/safe-tools.d.ts +2 -0
  138. package/dist/src/lib/safe-tools.js +212 -0
  139. package/dist/src/lib/safe-tools.js.map +1 -0
  140. package/dist/src/lib/settings.d.ts +59 -0
  141. package/dist/src/lib/settings.js +36 -0
  142. package/dist/src/lib/settings.js.map +1 -0
  143. package/dist/src/lib/token-refresh.d.ts +12 -0
  144. package/dist/src/lib/token-refresh.js +26 -0
  145. package/dist/src/lib/token-refresh.js.map +1 -0
  146. package/dist/src/lib/validation/build-validator.d.ts +9 -0
  147. package/dist/src/lib/validation/build-validator.js +118 -0
  148. package/dist/src/lib/validation/build-validator.js.map +1 -0
  149. package/dist/src/lib/validation/index.d.ts +3 -0
  150. package/dist/src/lib/validation/index.js +3 -0
  151. package/dist/src/lib/validation/index.js.map +1 -0
  152. package/dist/src/lib/validation/types.d.ts +41 -0
  153. package/dist/src/lib/validation/types.js +2 -0
  154. package/dist/src/lib/validation/types.js.map +1 -0
  155. package/dist/src/lib/validation/validator.d.ts +6 -0
  156. package/dist/src/lib/validation/validator.js +647 -0
  157. package/dist/src/lib/validation/validator.js.map +1 -0
  158. package/dist/src/lib/wizard-core.d.ts +200 -0
  159. package/dist/src/lib/wizard-core.js +392 -0
  160. package/dist/src/lib/wizard-core.js.map +1 -0
  161. package/dist/src/lib/wizard-core.types.d.ts +73 -0
  162. package/dist/src/lib/wizard-core.types.js +2 -0
  163. package/dist/src/lib/wizard-core.types.js.map +1 -0
  164. package/dist/src/lib/workos-management.d.ts +32 -0
  165. package/dist/src/lib/workos-management.js +142 -0
  166. package/dist/src/lib/workos-management.js.map +1 -0
  167. package/dist/src/nextjs/nextjs-wizard-agent.d.ts +6 -0
  168. package/dist/src/nextjs/nextjs-wizard-agent.js +97 -0
  169. package/dist/src/nextjs/nextjs-wizard-agent.js.map +1 -0
  170. package/dist/src/nextjs/utils.d.ts +8 -0
  171. package/dist/src/nextjs/utils.js +53 -0
  172. package/dist/src/nextjs/utils.js.map +1 -0
  173. package/dist/src/react/react-wizard-agent.d.ts +2 -0
  174. package/dist/src/react/react-wizard-agent.js +47 -0
  175. package/dist/src/react/react-wizard-agent.js.map +1 -0
  176. package/dist/src/react-router/react-router-wizard-agent.d.ts +6 -0
  177. package/dist/src/react-router/react-router-wizard-agent.js +103 -0
  178. package/dist/src/react-router/react-router-wizard-agent.js.map +1 -0
  179. package/dist/src/react-router/utils.d.ts +19 -0
  180. package/dist/src/react-router/utils.js +210 -0
  181. package/dist/src/react-router/utils.js.map +1 -0
  182. package/dist/src/run.d.ts +24 -0
  183. package/dist/src/run.js +48 -0
  184. package/dist/src/run.js.map +1 -0
  185. package/dist/src/steps/add-or-update-environment-variables.d.ts +10 -0
  186. package/dist/src/steps/add-or-update-environment-variables.js +155 -0
  187. package/dist/src/steps/add-or-update-environment-variables.js.map +1 -0
  188. package/dist/src/steps/index.d.ts +3 -0
  189. package/dist/src/steps/index.js +4 -0
  190. package/dist/src/steps/index.js.map +1 -0
  191. package/dist/src/steps/run-prettier.d.ts +5 -0
  192. package/dist/src/steps/run-prettier.js +54 -0
  193. package/dist/src/steps/run-prettier.js.map +1 -0
  194. package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +8 -0
  195. package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js +7 -0
  196. package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js.map +1 -0
  197. package/dist/src/steps/upload-environment-variables/index.d.ts +6 -0
  198. package/dist/src/steps/upload-environment-variables/index.js +57 -0
  199. package/dist/src/steps/upload-environment-variables/index.js.map +1 -0
  200. package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +14 -0
  201. package/dist/src/steps/upload-environment-variables/providers/vercel.js +104 -0
  202. package/dist/src/steps/upload-environment-variables/providers/vercel.js.map +1 -0
  203. package/dist/src/tanstack-start/tanstack-start-wizard-agent.d.ts +2 -0
  204. package/dist/src/tanstack-start/tanstack-start-wizard-agent.js +49 -0
  205. package/dist/src/tanstack-start/tanstack-start-wizard-agent.js.map +1 -0
  206. package/dist/src/telemetry.d.ts +2 -0
  207. package/dist/src/telemetry.js +29 -0
  208. package/dist/src/telemetry.js.map +1 -0
  209. package/dist/src/utils/analytics.d.ts +24 -0
  210. package/dist/src/utils/analytics.js +139 -0
  211. package/dist/src/utils/analytics.js.map +1 -0
  212. package/dist/src/utils/bash.d.ts +2 -0
  213. package/dist/src/utils/bash.js +17 -0
  214. package/dist/src/utils/bash.js.map +1 -0
  215. package/dist/src/utils/clack-utils.d.ts +93 -0
  216. package/dist/src/utils/clack-utils.js +397 -0
  217. package/dist/src/utils/clack-utils.js.map +1 -0
  218. package/dist/src/utils/clack.d.ts +5 -0
  219. package/dist/src/utils/clack.js +34 -0
  220. package/dist/src/utils/clack.js.map +1 -0
  221. package/dist/src/utils/cli-symbols.d.ts +32 -0
  222. package/dist/src/utils/cli-symbols.js +46 -0
  223. package/dist/src/utils/cli-symbols.js.map +1 -0
  224. package/dist/src/utils/debug.d.ts +7 -0
  225. package/dist/src/utils/debug.js +88 -0
  226. package/dist/src/utils/debug.js.map +1 -0
  227. package/dist/src/utils/env-parser.d.ts +5 -0
  228. package/dist/src/utils/env-parser.js +18 -0
  229. package/dist/src/utils/env-parser.js.map +1 -0
  230. package/dist/src/utils/environment.d.ts +4 -0
  231. package/dist/src/utils/environment.js +69 -0
  232. package/dist/src/utils/environment.js.map +1 -0
  233. package/dist/src/utils/errors.d.ts +3 -0
  234. package/dist/src/utils/errors.js +7 -0
  235. package/dist/src/utils/errors.js.map +1 -0
  236. package/dist/src/utils/logging.d.ts +9 -0
  237. package/dist/src/utils/logging.js +36 -0
  238. package/dist/src/utils/logging.js.map +1 -0
  239. package/dist/src/utils/package-json.d.ts +25 -0
  240. package/dist/src/utils/package-json.js +21 -0
  241. package/dist/src/utils/package-json.js.map +1 -0
  242. package/dist/src/utils/package-manager.d.ts +21 -0
  243. package/dist/src/utils/package-manager.js +167 -0
  244. package/dist/src/utils/package-manager.js.map +1 -0
  245. package/dist/src/utils/redact.d.ts +5 -0
  246. package/dist/src/utils/redact.js +29 -0
  247. package/dist/src/utils/redact.js.map +1 -0
  248. package/dist/src/utils/semver.d.ts +10 -0
  249. package/dist/src/utils/semver.js +43 -0
  250. package/dist/src/utils/semver.js.map +1 -0
  251. package/dist/src/utils/string.d.ts +1 -0
  252. package/dist/src/utils/string.js +6 -0
  253. package/dist/src/utils/string.js.map +1 -0
  254. package/dist/src/utils/telemetry-client.d.ts +15 -0
  255. package/dist/src/utils/telemetry-client.js +57 -0
  256. package/dist/src/utils/telemetry-client.js.map +1 -0
  257. package/dist/src/utils/telemetry-types.d.ts +51 -0
  258. package/dist/src/utils/telemetry-types.js +6 -0
  259. package/dist/src/utils/telemetry-types.js.map +1 -0
  260. package/dist/src/utils/types.d.ts +80 -0
  261. package/dist/src/utils/types.js +2 -0
  262. package/dist/src/utils/types.js.map +1 -0
  263. package/dist/src/utils/urls.d.ts +7 -0
  264. package/dist/src/utils/urls.js +8 -0
  265. package/dist/src/utils/urls.js.map +1 -0
  266. package/dist/src/utils/vendor/is-unicorn-supported.d.ts +1 -0
  267. package/dist/src/utils/vendor/is-unicorn-supported.js +21 -0
  268. package/dist/src/utils/vendor/is-unicorn-supported.js.map +1 -0
  269. package/dist/src/vanilla-js/vanilla-js-wizard-agent.d.ts +2 -0
  270. package/dist/src/vanilla-js/vanilla-js-wizard-agent.js +47 -0
  271. package/dist/src/vanilla-js/vanilla-js-wizard-agent.js.map +1 -0
  272. package/package.json +76 -84
  273. package/skills/workos-authkit-base/SKILL.md +113 -0
  274. package/skills/workos-authkit-nextjs/SKILL.md +115 -0
  275. package/skills/workos-authkit-react/SKILL.md +91 -0
  276. package/skills/workos-authkit-react-router/SKILL.md +106 -0
  277. package/skills/workos-authkit-tanstack-start/SKILL.md +104 -0
  278. package/skills/workos-authkit-vanilla-js/SKILL.md +81 -0
  279. package/build/apps/index.js +0 -50
  280. package/build/apps/slack.js +0 -151
  281. package/build/cli.js +0 -42
  282. package/build/config.js +0 -34
  283. package/build/dev.js +0 -5
  284. package/build/enable-api-access.png +0 -0
  285. package/build/groups.js +0 -480
  286. package/build/index.js +0 -3
  287. package/build/info.js +0 -69
  288. package/build/login.js +0 -161
  289. package/build/main.js +0 -214
  290. package/build/users.js +0 -402
  291. package/build/util.js +0 -157
  292. package/coverage/clover.xml +0 -66
  293. package/coverage/coverage-final.json +0 -4
  294. package/coverage/lcov-report/base.css +0 -212
  295. package/coverage/lcov-report/cli.ts.html +0 -329
  296. package/coverage/lcov-report/config.ts.html +0 -152
  297. package/coverage/lcov-report/index.html +0 -119
  298. package/coverage/lcov-report/prettify.css +0 -1
  299. package/coverage/lcov-report/prettify.js +0 -1
  300. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  301. package/coverage/lcov-report/sorter.js +0 -158
  302. package/coverage/lcov-report/util.ts.html +0 -350
  303. package/coverage/lcov.info +0 -121
  304. package/package-lock.json +0 -7617
  305. package/tests/util.test.ts +0 -35
@@ -0,0 +1,210 @@
1
+ import { major } from 'semver';
2
+ import fg from 'fast-glob';
3
+ import { abortIfCancelled, getPackageDotJson } from '../utils/clack-utils.js';
4
+ import clack from '../utils/clack.js';
5
+ import { getVersionBucket } from '../utils/semver.js';
6
+ import { IGNORE_PATTERNS, Integration } from '../lib/constants.js';
7
+ import { getPackageVersion } from '../utils/package-json.js';
8
+ import chalk from 'chalk';
9
+ import * as fs from 'node:fs';
10
+ import * as path from 'node:path';
11
+ import * as semver from 'semver';
12
+ export var ReactRouterMode;
13
+ (function (ReactRouterMode) {
14
+ ReactRouterMode["V6"] = "v6";
15
+ ReactRouterMode["V7_FRAMEWORK"] = "v7-framework";
16
+ ReactRouterMode["V7_DATA"] = "v7-data";
17
+ ReactRouterMode["V7_DECLARATIVE"] = "v7-declarative";
18
+ })(ReactRouterMode || (ReactRouterMode = {}));
19
+ /**
20
+ * Get React Router version bucket for analytics
21
+ */
22
+ export function getReactRouterVersionBucket(version) {
23
+ return getVersionBucket(version, 6);
24
+ }
25
+ /**
26
+ * Check if react-router.config.ts exists (indicates framework mode - React Router v7)
27
+ */
28
+ async function hasReactRouterConfig({ installDir }) {
29
+ const configMatches = await fg('**/react-router.config.@(ts|js|tsx|jsx)', {
30
+ dot: true,
31
+ cwd: installDir,
32
+ ignore: IGNORE_PATTERNS,
33
+ });
34
+ return configMatches.length > 0;
35
+ }
36
+ /**
37
+ * Search for createBrowserRouter usage in source files
38
+ */
39
+ async function hasCreateBrowserRouter({ installDir }) {
40
+ const sourceFiles = await fg('**/*.@(ts|tsx|js|jsx)', {
41
+ dot: true,
42
+ cwd: installDir,
43
+ ignore: IGNORE_PATTERNS,
44
+ });
45
+ for (const file of sourceFiles) {
46
+ try {
47
+ const filePath = path.join(installDir, file);
48
+ const content = fs.readFileSync(filePath, 'utf-8');
49
+ // Check for createBrowserRouter import or usage
50
+ if (content.includes('createBrowserRouter')) {
51
+ return true;
52
+ }
53
+ }
54
+ catch {
55
+ // Skip files that can't be read
56
+ continue;
57
+ }
58
+ }
59
+ return false;
60
+ }
61
+ /**
62
+ * Search for declarative BrowserRouter usage
63
+ */
64
+ async function hasDeclarativeRouter({ installDir }) {
65
+ const sourceFiles = await fg('**/*.@(ts|tsx|js|jsx)', {
66
+ dot: true,
67
+ cwd: installDir,
68
+ ignore: IGNORE_PATTERNS,
69
+ });
70
+ for (const file of sourceFiles) {
71
+ try {
72
+ const filePath = path.join(installDir, file);
73
+ const content = fs.readFileSync(filePath, 'utf-8');
74
+ // Check for BrowserRouter usage (JSX or import)
75
+ if (content.includes('<BrowserRouter') ||
76
+ (content.includes('BrowserRouter') &&
77
+ (content.includes('from "react-router-dom"') || content.includes("from 'react-router-dom'")))) {
78
+ return true;
79
+ }
80
+ }
81
+ catch {
82
+ // Skip files that can't be read
83
+ continue;
84
+ }
85
+ }
86
+ return false;
87
+ }
88
+ /**
89
+ * Detect React Router mode
90
+ */
91
+ export async function getReactRouterMode(options) {
92
+ const { installDir } = options;
93
+ // First, get the React Router version
94
+ const packageJson = await getPackageDotJson(options);
95
+ const reactRouterVersion = getPackageVersion('react-router-dom', packageJson) || getPackageVersion('react-router', packageJson);
96
+ if (!reactRouterVersion) {
97
+ // If we can't detect version, ask the user
98
+ clack.log.info(`Learn more about React Router modes: ${chalk.cyan('https://reactrouter.com/start/modes')}`);
99
+ const result = await abortIfCancelled(clack.select({
100
+ message: 'What React Router version and mode are you using?',
101
+ options: [
102
+ {
103
+ label: 'React Router v6',
104
+ value: ReactRouterMode.V6,
105
+ },
106
+ {
107
+ label: 'React Router v7 - Framework mode',
108
+ value: ReactRouterMode.V7_FRAMEWORK,
109
+ },
110
+ {
111
+ label: 'React Router v7 - Data mode',
112
+ value: ReactRouterMode.V7_DATA,
113
+ },
114
+ {
115
+ label: 'React Router v7 - Declarative mode',
116
+ value: ReactRouterMode.V7_DECLARATIVE,
117
+ },
118
+ ],
119
+ }), Integration.reactRouter);
120
+ return result;
121
+ }
122
+ const coercedVersion = semver.coerce(reactRouterVersion);
123
+ const majorVersion = coercedVersion ? major(coercedVersion) : null;
124
+ // If v6, return V6
125
+ if (majorVersion === 6) {
126
+ clack.log.info('Detected React Router v6');
127
+ return ReactRouterMode.V6;
128
+ }
129
+ // If v7, detect the mode
130
+ if (majorVersion === 7) {
131
+ // First check for framework mode (react-router.config.ts)
132
+ const hasConfig = await hasReactRouterConfig({ installDir });
133
+ if (hasConfig) {
134
+ clack.log.info('Detected React Router v7 - Framework mode');
135
+ return ReactRouterMode.V7_FRAMEWORK;
136
+ }
137
+ // Check for data mode (createBrowserRouter)
138
+ const hasDataMode = await hasCreateBrowserRouter({ installDir });
139
+ if (hasDataMode) {
140
+ clack.log.info('Detected React Router v7 - Data mode');
141
+ return ReactRouterMode.V7_DATA;
142
+ }
143
+ // Check for declarative mode (BrowserRouter)
144
+ const hasDeclarative = await hasDeclarativeRouter({ installDir });
145
+ if (hasDeclarative) {
146
+ clack.log.info('Detected React Router v7 - Declarative mode');
147
+ return ReactRouterMode.V7_DECLARATIVE;
148
+ }
149
+ // If v7 but can't detect mode, ask the user
150
+ clack.log.info(`Learn more about React Router modes: ${chalk.cyan('https://reactrouter.com/start/modes')}`);
151
+ const result = await abortIfCancelled(clack.select({
152
+ message: 'What React Router v7 mode are you using?',
153
+ options: [
154
+ {
155
+ label: 'Framework mode',
156
+ value: ReactRouterMode.V7_FRAMEWORK,
157
+ },
158
+ {
159
+ label: 'Data mode',
160
+ value: ReactRouterMode.V7_DATA,
161
+ },
162
+ {
163
+ label: 'Declarative mode',
164
+ value: ReactRouterMode.V7_DECLARATIVE,
165
+ },
166
+ ],
167
+ }), Integration.reactRouter);
168
+ return result;
169
+ }
170
+ // If version is not 6 or 7, default to asking
171
+ clack.log.info(`Learn more about React Router modes: ${chalk.cyan('https://reactrouter.com/start/modes')}`);
172
+ const result = await abortIfCancelled(clack.select({
173
+ message: 'What React Router version and mode are you using?',
174
+ options: [
175
+ {
176
+ label: 'React Router v6',
177
+ value: ReactRouterMode.V6,
178
+ },
179
+ {
180
+ label: 'React Router v7 - Framework mode',
181
+ value: ReactRouterMode.V7_FRAMEWORK,
182
+ },
183
+ {
184
+ label: 'React Router v7 - Data mode',
185
+ value: ReactRouterMode.V7_DATA,
186
+ },
187
+ {
188
+ label: 'React Router v7 - Declarative mode',
189
+ value: ReactRouterMode.V7_DECLARATIVE,
190
+ },
191
+ ],
192
+ }), Integration.reactRouter);
193
+ return result;
194
+ }
195
+ /**
196
+ * Get human-readable name for React Router mode
197
+ */
198
+ export function getReactRouterModeName(mode) {
199
+ switch (mode) {
200
+ case ReactRouterMode.V6:
201
+ return 'v6';
202
+ case ReactRouterMode.V7_FRAMEWORK:
203
+ return 'v7 Framework mode';
204
+ case ReactRouterMode.V7_DATA:
205
+ return 'v7 Data mode';
206
+ case ReactRouterMode.V7_DECLARATIVE:
207
+ return 'v7 Declarative mode';
208
+ }
209
+ }
210
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/react-router/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OA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B;gBACD;oBACE,KAAK,EAAE,kBAAkB;oBACzB,KAAK,EAAE,eAAe,CAAC,cAAc;iBACtC;aACF;SACF,CAAC,EACF,WAAW,CAAC,WAAW,CACxB,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,8CAA8C;IAC9C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,wCAAwC,KAAK,CAAC,IAAI,CAAC,qCAAqC,CAAC,EAAE,CAAC,CAAC;IAC5G,MAAM,MAAM,GAAoB,MAAM,gBAAgB,CACpD,KAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,mDAAmD;QAC5D,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,iBAAiB;gBACxB,KAAK,EAAE,eAAe,CAAC,EAAE;aAC1B;YACD;gBACE,KAAK,EAAE,kCAAkC;gBACzC,KAAK,EAAE,eAAe,CAAC,YAAY;aACpC;YACD;gBACE,KAAK,EAAE,6BAA6B;gBACpC,KAAK,EAAE,eAAe,CAAC,OAAO;aAC/B;YACD;gBACE,KAAK,EAAE,oCAAoC;gBAC3C,KAAK,EAAE,eAAe,CAAC,cAAc;aACtC;SACF;KACF,CAAC,EACF,WAAW,CAAC,WAAW,CACxB,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAqB;IAC1D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,eAAe,CAAC,EAAE;YACrB,OAAO,IAAI,CAAC;QACd,KAAK,eAAe,CAAC,YAAY;YAC/B,OAAO,mBAAmB,CAAC;QAC7B,KAAK,eAAe,CAAC,OAAO;YAC1B,OAAO,cAAc,CAAC;QACxB,KAAK,eAAe,CAAC,cAAc;YACjC,OAAO,qBAAqB,CAAC;IACjC,CAAC;AACH,CAAC","sourcesContent":["import { major } from 'semver';\nimport fg from 'fast-glob';\nimport { abortIfCancelled, getPackageDotJson } from '../utils/clack-utils.js';\nimport clack from '../utils/clack.js';\nimport { getVersionBucket } from '../utils/semver.js';\nimport type { WizardOptions } from '../utils/types.js';\nimport { IGNORE_PATTERNS, Integration } from '../lib/constants.js';\nimport { getPackageVersion } from '../utils/package-json.js';\nimport chalk from 'chalk';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as semver from 'semver';\n\nexport enum ReactRouterMode {\n V6 = 'v6', // React Router v6\n V7_FRAMEWORK = 'v7-framework', // React Router v7 with react-router.config.ts\n V7_DATA = 'v7-data', // React Router v7 with createBrowserRouter\n V7_DECLARATIVE = 'v7-declarative', // React Router v7 with BrowserRouter\n}\n\n/**\n * Get React Router version bucket for analytics\n */\nexport function getReactRouterVersionBucket(version: string | undefined): string {\n return getVersionBucket(version, 6);\n}\n\n/**\n * Check if react-router.config.ts exists (indicates framework mode - React Router v7)\n */\nasync function hasReactRouterConfig({ installDir }: Pick<WizardOptions, 'installDir'>): Promise<boolean> {\n const configMatches = await fg('**/react-router.config.@(ts|js|tsx|jsx)', {\n dot: true,\n cwd: installDir,\n ignore: IGNORE_PATTERNS,\n });\n\n return configMatches.length > 0;\n}\n\n/**\n * Search for createBrowserRouter usage in source files\n */\nasync function hasCreateBrowserRouter({ installDir }: Pick<WizardOptions, 'installDir'>): Promise<boolean> {\n const sourceFiles = await fg('**/*.@(ts|tsx|js|jsx)', {\n dot: true,\n cwd: installDir,\n ignore: IGNORE_PATTERNS,\n });\n\n for (const file of sourceFiles) {\n try {\n const filePath = path.join(installDir, file);\n const content = fs.readFileSync(filePath, 'utf-8');\n\n // Check for createBrowserRouter import or usage\n if (content.includes('createBrowserRouter')) {\n return true;\n }\n } catch {\n // Skip files that can't be read\n continue;\n }\n }\n\n return false;\n}\n\n/**\n * Search for declarative BrowserRouter usage\n */\nasync function hasDeclarativeRouter({ installDir }: Pick<WizardOptions, 'installDir'>): Promise<boolean> {\n const sourceFiles = await fg('**/*.@(ts|tsx|js|jsx)', {\n dot: true,\n cwd: installDir,\n ignore: IGNORE_PATTERNS,\n });\n\n for (const file of sourceFiles) {\n try {\n const filePath = path.join(installDir, file);\n const content = fs.readFileSync(filePath, 'utf-8');\n\n // Check for BrowserRouter usage (JSX or import)\n if (\n content.includes('<BrowserRouter') ||\n (content.includes('BrowserRouter') &&\n (content.includes('from \"react-router-dom\"') || content.includes(\"from 'react-router-dom'\")))\n ) {\n return true;\n }\n } catch {\n // Skip files that can't be read\n continue;\n }\n }\n\n return false;\n}\n\n/**\n * Detect React Router mode\n */\nexport async function getReactRouterMode(options: WizardOptions): Promise<ReactRouterMode> {\n const { installDir } = options;\n\n // First, get the React Router version\n const packageJson = await getPackageDotJson(options);\n const reactRouterVersion =\n getPackageVersion('react-router-dom', packageJson) || getPackageVersion('react-router', packageJson);\n\n if (!reactRouterVersion) {\n // If we can't detect version, ask the user\n clack.log.info(`Learn more about React Router modes: ${chalk.cyan('https://reactrouter.com/start/modes')}`);\n const result: ReactRouterMode = await abortIfCancelled(\n clack.select({\n message: 'What React Router version and mode are you using?',\n options: [\n {\n label: 'React Router v6',\n value: ReactRouterMode.V6,\n },\n {\n label: 'React Router v7 - Framework mode',\n value: ReactRouterMode.V7_FRAMEWORK,\n },\n {\n label: 'React Router v7 - Data mode',\n value: ReactRouterMode.V7_DATA,\n },\n {\n label: 'React Router v7 - Declarative mode',\n value: ReactRouterMode.V7_DECLARATIVE,\n },\n ],\n }),\n Integration.reactRouter,\n );\n return result;\n }\n\n const coercedVersion = semver.coerce(reactRouterVersion);\n const majorVersion = coercedVersion ? major(coercedVersion) : null;\n\n // If v6, return V6\n if (majorVersion === 6) {\n clack.log.info('Detected React Router v6');\n return ReactRouterMode.V6;\n }\n\n // If v7, detect the mode\n if (majorVersion === 7) {\n // First check for framework mode (react-router.config.ts)\n const hasConfig = await hasReactRouterConfig({ installDir });\n if (hasConfig) {\n clack.log.info('Detected React Router v7 - Framework mode');\n return ReactRouterMode.V7_FRAMEWORK;\n }\n\n // Check for data mode (createBrowserRouter)\n const hasDataMode = await hasCreateBrowserRouter({ installDir });\n if (hasDataMode) {\n clack.log.info('Detected React Router v7 - Data mode');\n return ReactRouterMode.V7_DATA;\n }\n\n // Check for declarative mode (BrowserRouter)\n const hasDeclarative = await hasDeclarativeRouter({ installDir });\n if (hasDeclarative) {\n clack.log.info('Detected React Router v7 - Declarative mode');\n return ReactRouterMode.V7_DECLARATIVE;\n }\n\n // If v7 but can't detect mode, ask the user\n clack.log.info(`Learn more about React Router modes: ${chalk.cyan('https://reactrouter.com/start/modes')}`);\n const result: ReactRouterMode = await abortIfCancelled(\n clack.select({\n message: 'What React Router v7 mode are you using?',\n options: [\n {\n label: 'Framework mode',\n value: ReactRouterMode.V7_FRAMEWORK,\n },\n {\n label: 'Data mode',\n value: ReactRouterMode.V7_DATA,\n },\n {\n label: 'Declarative mode',\n value: ReactRouterMode.V7_DECLARATIVE,\n },\n ],\n }),\n Integration.reactRouter,\n );\n return result;\n }\n\n // If version is not 6 or 7, default to asking\n clack.log.info(`Learn more about React Router modes: ${chalk.cyan('https://reactrouter.com/start/modes')}`);\n const result: ReactRouterMode = await abortIfCancelled(\n clack.select({\n message: 'What React Router version and mode are you using?',\n options: [\n {\n label: 'React Router v6',\n value: ReactRouterMode.V6,\n },\n {\n label: 'React Router v7 - Framework mode',\n value: ReactRouterMode.V7_FRAMEWORK,\n },\n {\n label: 'React Router v7 - Data mode',\n value: ReactRouterMode.V7_DATA,\n },\n {\n label: 'React Router v7 - Declarative mode',\n value: ReactRouterMode.V7_DECLARATIVE,\n },\n ],\n }),\n Integration.reactRouter,\n );\n return result;\n}\n\n/**\n * Get human-readable name for React Router mode\n */\nexport function getReactRouterModeName(mode: ReactRouterMode): string {\n switch (mode) {\n case ReactRouterMode.V6:\n return 'v6';\n case ReactRouterMode.V7_FRAMEWORK:\n return 'v7 Framework mode';\n case ReactRouterMode.V7_DATA:\n return 'v7 Data mode';\n case ReactRouterMode.V7_DECLARATIVE:\n return 'v7 Declarative mode';\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import type { Integration } from './lib/constants.js';
2
+ type Args = {
3
+ integration?: Integration;
4
+ debug?: boolean;
5
+ forceInstall?: boolean;
6
+ installDir?: string;
7
+ default?: boolean;
8
+ local?: boolean;
9
+ ci?: boolean;
10
+ skipAuth?: boolean;
11
+ apiKey?: string;
12
+ clientId?: string;
13
+ homepageUrl?: string;
14
+ redirectUri?: string;
15
+ dashboard?: boolean;
16
+ inspect?: boolean;
17
+ noValidate?: boolean;
18
+ };
19
+ /**
20
+ * Main entry point for the wizard CLI.
21
+ * Builds options from args and delegates to the core.
22
+ */
23
+ export declare function runWizard(argv: Args): Promise<void>;
24
+ export {};
@@ -0,0 +1,48 @@
1
+ import { readEnvironment } from './utils/environment.js';
2
+ import { runWithCore } from './lib/run-with-core.js';
3
+ import { createWizardEventEmitter } from './lib/events.js';
4
+ import path from 'path';
5
+ import { EventEmitter } from 'events';
6
+ EventEmitter.defaultMaxListeners = 50;
7
+ /**
8
+ * Main entry point for the wizard CLI.
9
+ * Builds options from args and delegates to the core.
10
+ */
11
+ export async function runWizard(argv) {
12
+ const options = buildOptions(argv);
13
+ await runWithCore(options);
14
+ }
15
+ /**
16
+ * Build WizardOptions from CLI args and environment.
17
+ */
18
+ function buildOptions(argv) {
19
+ const envArgs = readEnvironment();
20
+ const merged = { ...argv, ...envArgs };
21
+ const installDir = resolveInstallDir(merged.installDir);
22
+ return {
23
+ debug: merged.debug ?? false,
24
+ forceInstall: merged.forceInstall ?? false,
25
+ installDir,
26
+ local: merged.local ?? false,
27
+ ci: merged.ci ?? false,
28
+ skipAuth: merged.skipAuth ?? false,
29
+ apiKey: merged.apiKey,
30
+ clientId: merged.clientId,
31
+ homepageUrl: merged.homepageUrl,
32
+ redirectUri: merged.redirectUri,
33
+ dashboard: merged.dashboard ?? false,
34
+ integration: merged.integration,
35
+ inspect: merged.inspect ?? false,
36
+ noValidate: merged.noValidate ?? false,
37
+ emitter: createWizardEventEmitter(), // Will be replaced in runWithCore
38
+ };
39
+ }
40
+ /**
41
+ * Resolve install directory to absolute path.
42
+ */
43
+ function resolveInstallDir(dir) {
44
+ if (!dir)
45
+ return process.cwd();
46
+ return path.isAbsolute(dir) ? dir : path.join(process.cwd(), dir);
47
+ }
48
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,YAAY,CAAC,mBAAmB,GAAG,EAAE,CAAC;AAoBtC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAU;IACxC,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,IAAU;IAC9B,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;IAEvC,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAExD,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK;QAC5B,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,KAAK;QAC1C,UAAU;QACV,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK;QAC5B,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK;QACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;QAClC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,KAAK;QACpC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;QAChC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,KAAK;QACtC,OAAO,EAAE,wBAAwB,EAAE,EAAE,kCAAkC;KACxE,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,GAAY;IACrC,IAAI,CAAC,GAAG;QAAE,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;IAC/B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { readEnvironment } from './utils/environment.js';\nimport { runWithCore } from './lib/run-with-core.js';\nimport type { WizardOptions } from './utils/types.js';\nimport type { Integration } from './lib/constants.js';\nimport { createWizardEventEmitter } from './lib/events.js';\nimport path from 'path';\nimport { EventEmitter } from 'events';\n\nEventEmitter.defaultMaxListeners = 50;\n\ntype Args = {\n integration?: Integration;\n debug?: boolean;\n forceInstall?: boolean;\n installDir?: string;\n default?: boolean;\n local?: boolean;\n ci?: boolean;\n skipAuth?: boolean;\n apiKey?: string;\n clientId?: string;\n homepageUrl?: string;\n redirectUri?: string;\n dashboard?: boolean;\n inspect?: boolean;\n noValidate?: boolean;\n};\n\n/**\n * Main entry point for the wizard CLI.\n * Builds options from args and delegates to the core.\n */\nexport async function runWizard(argv: Args): Promise<void> {\n const options = buildOptions(argv);\n await runWithCore(options);\n}\n\n/**\n * Build WizardOptions from CLI args and environment.\n */\nfunction buildOptions(argv: Args): WizardOptions {\n const envArgs = readEnvironment();\n const merged = { ...argv, ...envArgs };\n\n const installDir = resolveInstallDir(merged.installDir);\n\n return {\n debug: merged.debug ?? false,\n forceInstall: merged.forceInstall ?? false,\n installDir,\n local: merged.local ?? false,\n ci: merged.ci ?? false,\n skipAuth: merged.skipAuth ?? false,\n apiKey: merged.apiKey,\n clientId: merged.clientId,\n homepageUrl: merged.homepageUrl,\n redirectUri: merged.redirectUri,\n dashboard: merged.dashboard ?? false,\n integration: merged.integration,\n inspect: merged.inspect ?? false,\n noValidate: merged.noValidate ?? false,\n emitter: createWizardEventEmitter(), // Will be replaced in runWithCore\n };\n}\n\n/**\n * Resolve install directory to absolute path.\n */\nfunction resolveInstallDir(dir?: string): string {\n if (!dir) return process.cwd();\n return path.isAbsolute(dir) ? dir : path.join(process.cwd(), dir);\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { Integration } from '../lib/constants.js';
2
+ export declare function addOrUpdateEnvironmentVariablesStep({ installDir, variables, integration, }: {
3
+ installDir: string;
4
+ variables: Record<string, string>;
5
+ integration: Integration;
6
+ }): Promise<{
7
+ relativeEnvFilePath: string;
8
+ addedEnvVariables: boolean;
9
+ addedGitignore: boolean;
10
+ }>;
@@ -0,0 +1,155 @@
1
+ import chalk from 'chalk';
2
+ import { traceStep } from '../telemetry.js';
3
+ import { analytics } from '../utils/analytics.js';
4
+ import clack from '../utils/clack.js';
5
+ import * as fs from 'fs';
6
+ import path from 'path';
7
+ function getDotGitignore(options) {
8
+ return path.join(options.installDir, '.gitignore');
9
+ }
10
+ export async function addOrUpdateEnvironmentVariablesStep({ installDir, variables, integration, }) {
11
+ return traceStep('add-or-update-environment-variables', async () => {
12
+ const envVarContent = Object.entries(variables)
13
+ .map(([key, value]) => `${key}=${value}`)
14
+ .join('\n');
15
+ const dotEnvLocalFilePath = path.join(installDir, '.env.local');
16
+ const dotEnvFilePath = path.join(installDir, '.env');
17
+ const targetEnvFilePath = fs.existsSync(dotEnvLocalFilePath) ? dotEnvLocalFilePath : dotEnvFilePath;
18
+ const dotEnvFileExists = fs.existsSync(targetEnvFilePath);
19
+ const relativeEnvFilePath = path.relative(installDir, targetEnvFilePath);
20
+ let addedGitignore = false;
21
+ let addedEnvVariables = false;
22
+ if (dotEnvFileExists) {
23
+ try {
24
+ let dotEnvFileContent = fs.readFileSync(targetEnvFilePath, 'utf8');
25
+ let updated = false;
26
+ for (const [key, value] of Object.entries(variables)) {
27
+ const regex = new RegExp(`^${key}=.*$`, 'm');
28
+ if (dotEnvFileContent.match(regex)) {
29
+ dotEnvFileContent = dotEnvFileContent.replace(regex, `${key}=${value}`);
30
+ updated = true;
31
+ }
32
+ else {
33
+ if (!dotEnvFileContent.endsWith('\n')) {
34
+ dotEnvFileContent += '\n';
35
+ }
36
+ dotEnvFileContent += `${key}=${value}\n`;
37
+ updated = true;
38
+ }
39
+ }
40
+ if (updated) {
41
+ await fs.promises.writeFile(targetEnvFilePath, dotEnvFileContent, {
42
+ encoding: 'utf8',
43
+ flag: 'w',
44
+ });
45
+ clack.log.success(`Updated environment variables in ${chalk.bold.cyan(relativeEnvFilePath)}`);
46
+ }
47
+ else {
48
+ clack.log.success(`${chalk.bold.cyan(relativeEnvFilePath)} already has the necessary environment variables.`);
49
+ }
50
+ addedEnvVariables = true;
51
+ }
52
+ catch (error) {
53
+ clack.log.warning(`Failed to update environment variables in ${chalk.bold.cyan(relativeEnvFilePath)}. Please update them manually.`);
54
+ analytics.capture('wizard interaction', {
55
+ action: 'failed to update environment variables',
56
+ integration,
57
+ error: error instanceof Error ? error.message : 'Unknown error',
58
+ });
59
+ return {
60
+ relativeEnvFilePath,
61
+ addedEnvVariables,
62
+ addedGitignore,
63
+ };
64
+ }
65
+ }
66
+ else {
67
+ try {
68
+ await fs.promises.writeFile(targetEnvFilePath, envVarContent, {
69
+ encoding: 'utf8',
70
+ flag: 'w',
71
+ });
72
+ clack.log.success(`Created ${chalk.bold.cyan(relativeEnvFilePath)} with environment variables.`);
73
+ addedEnvVariables = true;
74
+ }
75
+ catch (error) {
76
+ clack.log.warning(`Failed to create ${chalk.bold.cyan(relativeEnvFilePath)} with environment variables. Please add them manually.`);
77
+ analytics.capture('wizard interaction', {
78
+ action: 'failed to create environment variables',
79
+ integration,
80
+ error: error instanceof Error ? error.message : 'Unknown error',
81
+ });
82
+ return {
83
+ relativeEnvFilePath,
84
+ addedEnvVariables,
85
+ addedGitignore,
86
+ };
87
+ }
88
+ }
89
+ const gitignorePath = getDotGitignore({ installDir });
90
+ const envFileName = path.basename(targetEnvFilePath);
91
+ const envFiles = [envFileName];
92
+ if (gitignorePath) {
93
+ const gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
94
+ const missingEnvFiles = envFiles.filter((file) => !gitignoreContent.includes(file));
95
+ if (missingEnvFiles.length > 0) {
96
+ try {
97
+ const newGitignoreContent = `${gitignoreContent}\n${missingEnvFiles.join('\n')}`;
98
+ await fs.promises.writeFile(gitignorePath, newGitignoreContent, {
99
+ encoding: 'utf8',
100
+ flag: 'w',
101
+ });
102
+ clack.log.success(`Updated ${chalk.bold.cyan('.gitignore')} to include ${chalk.bold.cyan(envFileName)}.`);
103
+ addedGitignore = true;
104
+ }
105
+ catch (error) {
106
+ clack.log.warning(`Failed to update ${chalk.bold.cyan('.gitignore')} to include ${chalk.bold.cyan(envFileName)}.`);
107
+ analytics.capture('wizard interaction', {
108
+ action: 'failed to update gitignore',
109
+ integration,
110
+ error: error instanceof Error ? error.message : 'Unknown error',
111
+ });
112
+ return {
113
+ relativeEnvFilePath,
114
+ addedEnvVariables,
115
+ addedGitignore,
116
+ };
117
+ }
118
+ }
119
+ }
120
+ else {
121
+ try {
122
+ const newGitignoreContent = `${envFiles.join('\n')}\n`;
123
+ await fs.promises.writeFile(path.join(installDir, '.gitignore'), newGitignoreContent, {
124
+ encoding: 'utf8',
125
+ flag: 'w',
126
+ });
127
+ clack.log.success(`Created ${chalk.bold.cyan('.gitignore')} with environment files.`);
128
+ addedGitignore = true;
129
+ }
130
+ catch (error) {
131
+ clack.log.warning(`Failed to create ${chalk.bold.cyan('.gitignore')} with environment files.`);
132
+ analytics.capture('wizard interaction', {
133
+ action: 'failed to create gitignore',
134
+ integration,
135
+ error: error instanceof Error ? error.message : 'Unknown error',
136
+ });
137
+ return {
138
+ relativeEnvFilePath,
139
+ addedEnvVariables,
140
+ addedGitignore,
141
+ };
142
+ }
143
+ }
144
+ analytics.capture('wizard interaction', {
145
+ action: 'added environment variables',
146
+ integration,
147
+ });
148
+ return {
149
+ relativeEnvFilePath,
150
+ addedEnvVariables,
151
+ addedGitignore,
152
+ };
153
+ });
154
+ }
155
+ //# sourceMappingURL=add-or-update-environment-variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-or-update-environment-variables.js","sourceRoot":"","sources":["../../../src/steps/add-or-update-environment-variables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,SAAS,eAAe,CAAC,OAA+B;IACtD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mCAAmC,CAAC,EACxD,UAAU,EACV,SAAS,EACT,WAAW,GAKZ;IAKC,OAAO,SAAS,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACjE,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;aAC5C,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;aACxC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd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CAAC,0BAA0B,CAAC,CAAC;gBACtF,cAAc,GAAG,IAAI,CAAC;YACxB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,oBAAoB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;gBAE/F,SAAS,CAAC,OAAO,CAAC,oBAAoB,EAAE;oBACtC,MAAM,EAAE,4BAA4B;oBACpC,WAAW;oBACX,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;iBAChE,CAAC,CAAC;gBAEH,OAAO;oBACL,mBAAmB;oBACnB,iBAAiB;oBACjB,cAAc;iBACf,CAAC;YACJ,CAAC;QACH,CAAC;QAED,SAAS,CAAC,OAAO,CAAC,oBAAoB,EAAE;YACtC,MAAM,EAAE,6BAA6B;YACrC,WAAW;SACZ,CAAC,CAAC;QAEH,OAAO;YACL,mBAAmB;YACnB,iBAAiB;YACjB,cAAc;SACf,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import chalk from 'chalk';\nimport type { Integration } from '../lib/constants.js';\nimport { traceStep } from '../telemetry.js';\nimport { analytics } from '../utils/analytics.js';\nimport clack from '../utils/clack.js';\nimport * as fs from 'fs';\nimport path from 'path';\n\nfunction getDotGitignore(options: { installDir: string }): string {\n return path.join(options.installDir, '.gitignore');\n}\n\nexport async function addOrUpdateEnvironmentVariablesStep({\n installDir,\n variables,\n integration,\n}: {\n installDir: string;\n variables: Record<string, string>;\n integration: Integration;\n}): Promise<{\n relativeEnvFilePath: string;\n addedEnvVariables: boolean;\n addedGitignore: boolean;\n}> {\n return traceStep('add-or-update-environment-variables', async () => {\n const envVarContent = Object.entries(variables)\n .map(([key, value]) => `${key}=${value}`)\n .join('\\n');\n\n const dotEnvLocalFilePath = path.join(installDir, '.env.local');\n const dotEnvFilePath = path.join(installDir, '.env');\n const targetEnvFilePath = fs.existsSync(dotEnvLocalFilePath) ? dotEnvLocalFilePath : dotEnvFilePath;\n\n const dotEnvFileExists = fs.existsSync(targetEnvFilePath);\n\n const relativeEnvFilePath = path.relative(installDir, targetEnvFilePath);\n\n let addedGitignore = false;\n let addedEnvVariables = false;\n\n if (dotEnvFileExists) {\n try {\n let dotEnvFileContent = fs.readFileSync(targetEnvFilePath, 'utf8');\n let updated = false;\n\n for (const [key, value] of Object.entries(variables)) {\n const regex = new RegExp(`^${key}=.*$`, 'm');\n\n if (dotEnvFileContent.match(regex)) {\n dotEnvFileContent = dotEnvFileContent.replace(regex, `${key}=${value}`);\n updated = true;\n } else {\n if (!dotEnvFileContent.endsWith('\\n')) {\n dotEnvFileContent += '\\n';\n }\n dotEnvFileContent += `${key}=${value}\\n`;\n updated = true;\n }\n }\n\n if (updated) {\n await fs.promises.writeFile(targetEnvFilePath, dotEnvFileContent, {\n encoding: 'utf8',\n flag: 'w',\n });\n clack.log.success(`Updated environment variables in ${chalk.bold.cyan(relativeEnvFilePath)}`);\n } else {\n clack.log.success(`${chalk.bold.cyan(relativeEnvFilePath)} already has the necessary environment variables.`);\n }\n\n addedEnvVariables = true;\n } catch (error) {\n clack.log.warning(\n `Failed to update environment variables in ${chalk.bold.cyan(\n relativeEnvFilePath,\n )}. Please update them manually.`,\n );\n\n analytics.capture('wizard interaction', {\n action: 'failed to update environment variables',\n integration,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n\n return {\n relativeEnvFilePath,\n addedEnvVariables,\n addedGitignore,\n };\n }\n } else {\n try {\n await fs.promises.writeFile(targetEnvFilePath, envVarContent, {\n encoding: 'utf8',\n flag: 'w',\n });\n clack.log.success(`Created ${chalk.bold.cyan(relativeEnvFilePath)} with environment variables.`);\n\n addedEnvVariables = true;\n } catch (error) {\n clack.log.warning(\n `Failed to create ${chalk.bold.cyan(\n relativeEnvFilePath,\n )} with environment variables. Please add them manually.`,\n );\n\n analytics.capture('wizard interaction', {\n action: 'failed to create environment variables',\n integration,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n\n return {\n relativeEnvFilePath,\n addedEnvVariables,\n addedGitignore,\n };\n }\n }\n\n const gitignorePath = getDotGitignore({ installDir });\n\n const envFileName = path.basename(targetEnvFilePath);\n\n const envFiles = [envFileName];\n\n if (gitignorePath) {\n const gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');\n const missingEnvFiles = envFiles.filter((file) => !gitignoreContent.includes(file));\n\n if (missingEnvFiles.length > 0) {\n try {\n const newGitignoreContent = `${gitignoreContent}\\n${missingEnvFiles.join('\\n')}`;\n await fs.promises.writeFile(gitignorePath, newGitignoreContent, {\n encoding: 'utf8',\n flag: 'w',\n });\n clack.log.success(`Updated ${chalk.bold.cyan('.gitignore')} to include ${chalk.bold.cyan(envFileName)}.`);\n addedGitignore = true;\n } catch (error) {\n clack.log.warning(\n `Failed to update ${chalk.bold.cyan('.gitignore')} to include ${chalk.bold.cyan(envFileName)}.`,\n );\n\n analytics.capture('wizard interaction', {\n action: 'failed to update gitignore',\n integration,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n\n return {\n relativeEnvFilePath,\n addedEnvVariables,\n addedGitignore,\n };\n }\n }\n } else {\n try {\n const newGitignoreContent = `${envFiles.join('\\n')}\\n`;\n await fs.promises.writeFile(path.join(installDir, '.gitignore'), newGitignoreContent, {\n encoding: 'utf8',\n flag: 'w',\n });\n clack.log.success(`Created ${chalk.bold.cyan('.gitignore')} with environment files.`);\n addedGitignore = true;\n } catch (error) {\n clack.log.warning(`Failed to create ${chalk.bold.cyan('.gitignore')} with environment files.`);\n\n analytics.capture('wizard interaction', {\n action: 'failed to create gitignore',\n integration,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n\n return {\n relativeEnvFilePath,\n addedEnvVariables,\n addedGitignore,\n };\n }\n }\n\n analytics.capture('wizard interaction', {\n action: 'added environment variables',\n integration,\n });\n\n return {\n relativeEnvFilePath,\n addedEnvVariables,\n addedGitignore,\n };\n });\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './run-prettier.js';
2
+ export * from './add-or-update-environment-variables.js';
3
+ export * from './upload-environment-variables/index.js';
@@ -0,0 +1,4 @@
1
+ export * from './run-prettier.js';
2
+ export * from './add-or-update-environment-variables.js';
3
+ export * from './upload-environment-variables/index.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/steps/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0CAA0C,CAAC;AACzD,cAAc,yCAAyC,CAAC","sourcesContent":["export * from './run-prettier.js';\nexport * from './add-or-update-environment-variables.js';\nexport * from './upload-environment-variables/index.js';\n"]}
@@ -0,0 +1,5 @@
1
+ import type { Integration } from '../lib/constants.js';
2
+ import type { WizardOptions } from '../utils/types.js';
3
+ export declare function runPrettierStep({ installDir, integration, }: Pick<WizardOptions, 'installDir'> & {
4
+ integration: Integration;
5
+ }): Promise<void>;
@@ -0,0 +1,54 @@
1
+ import { traceStep } from '../telemetry.js';
2
+ import { analytics } from '../utils/analytics.js';
3
+ import clack from '../utils/clack.js';
4
+ import { getPackageDotJson, getUncommittedOrUntrackedFiles, isInGitRepo } from '../utils/clack-utils.js';
5
+ import { hasPackageInstalled } from '../utils/package-json.js';
6
+ import * as childProcess from 'node:child_process';
7
+ export async function runPrettierStep({ installDir, integration, }) {
8
+ return traceStep('run-prettier', async () => {
9
+ if (!isInGitRepo()) {
10
+ // We only run formatting on changed files. If we're not in a git repo, we can't find
11
+ // changed files. So let's early-return without showing any formatting-related messages.
12
+ return;
13
+ }
14
+ const changedOrUntrackedFiles = getUncommittedOrUntrackedFiles()
15
+ .map((filename) => {
16
+ return filename.startsWith('- ') ? filename.slice(2) : filename;
17
+ })
18
+ .join(' ');
19
+ if (!changedOrUntrackedFiles.length) {
20
+ // Likewise, if we can't find changed or untracked files, there's no point in running Prettier.
21
+ return;
22
+ }
23
+ const packageJson = await getPackageDotJson({ installDir });
24
+ const prettierInstalled = hasPackageInstalled('prettier', packageJson);
25
+ analytics.setTag('prettier-installed', prettierInstalled);
26
+ if (!prettierInstalled) {
27
+ return;
28
+ }
29
+ const prettierSpinner = clack.spinner();
30
+ prettierSpinner.start('Running Prettier on your files.');
31
+ try {
32
+ await new Promise((resolve, reject) => {
33
+ childProcess.exec(`npx prettier --ignore-unknown --write ${changedOrUntrackedFiles}`, (err) => {
34
+ if (err) {
35
+ reject(err);
36
+ }
37
+ else {
38
+ resolve();
39
+ }
40
+ });
41
+ });
42
+ }
43
+ catch (e) {
44
+ prettierSpinner.stop('Prettier failed to run. You may want to format the changes manually.');
45
+ return;
46
+ }
47
+ prettierSpinner.stop('Prettier has formatted your files.');
48
+ analytics.capture('wizard interaction', {
49
+ action: 'ran prettier',
50
+ integration,
51
+ });
52
+ });
53
+ }
54
+ //# sourceMappingURL=run-prettier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-prettier.js","sourceRoot":"","sources":["../../../src/steps/run-prettier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACzG,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EACpC,UAAU,EACV,WAAW,GAGZ;IACC,OAAO,SAAS,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE;QAC1C,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACnB,qFAAqF;YACrF,wFAAwF;YACxF,OAAO;QACT,CAAC;QAED,MAAM,uBAA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AC;QAE3D,SAAS,CAAC,OAAO,CAAC,oBAAoB,EAAE;YACtC,MAAM,EAAE,cAAc;YACtB,WAAW;SACZ,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Integration } from '../lib/constants.js';\nimport { traceStep } from '../telemetry.js';\nimport { analytics } from '../utils/analytics.js';\nimport clack from '../utils/clack.js';\nimport { getPackageDotJson, getUncommittedOrUntrackedFiles, isInGitRepo } from '../utils/clack-utils.js';\nimport { hasPackageInstalled } from '../utils/package-json.js';\nimport type { WizardOptions } from '../utils/types.js';\nimport * as childProcess from 'node:child_process';\n\nexport async function runPrettierStep({\n installDir,\n integration,\n}: Pick<WizardOptions, 'installDir'> & {\n integration: Integration;\n}): Promise<void> {\n return traceStep('run-prettier', async () => {\n if (!isInGitRepo()) {\n // We only run formatting on changed files. If we're not in a git repo, we can't find\n // changed files. So let's early-return without showing any formatting-related messages.\n return;\n }\n\n const changedOrUntrackedFiles = getUncommittedOrUntrackedFiles()\n .map((filename) => {\n return filename.startsWith('- ') ? filename.slice(2) : filename;\n })\n .join(' ');\n\n if (!changedOrUntrackedFiles.length) {\n // Likewise, if we can't find changed or untracked files, there's no point in running Prettier.\n return;\n }\n\n const packageJson = await getPackageDotJson({ installDir });\n const prettierInstalled = hasPackageInstalled('prettier', packageJson);\n\n analytics.setTag('prettier-installed', prettierInstalled);\n\n if (!prettierInstalled) {\n return;\n }\n\n const prettierSpinner = clack.spinner();\n prettierSpinner.start('Running Prettier on your files.');\n\n try {\n await new Promise<void>((resolve, reject) => {\n childProcess.exec(`npx prettier --ignore-unknown --write ${changedOrUntrackedFiles}`, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n });\n });\n } catch (e) {\n prettierSpinner.stop('Prettier failed to run. You may want to format the changes manually.');\n return;\n }\n\n prettierSpinner.stop('Prettier has formatted your files.');\n\n analytics.capture('wizard interaction', {\n action: 'ran prettier',\n integration,\n });\n });\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { WizardOptions } from '../../utils/types.js';
2
+ export declare abstract class EnvironmentProvider {
3
+ protected options: WizardOptions;
4
+ abstract name: string;
5
+ constructor(options: WizardOptions);
6
+ abstract detect(): Promise<boolean>;
7
+ abstract uploadEnvVars(vars: Record<string, string>): Promise<Record<string, boolean>>;
8
+ }
@@ -0,0 +1,7 @@
1
+ export class EnvironmentProvider {
2
+ options;
3
+ constructor(options) {
4
+ this.options = options;
5
+ }
6
+ }
7
+ //# sourceMappingURL=EnvironmentProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvironmentProvider.js","sourceRoot":"","sources":["../../../../src/steps/upload-environment-variables/EnvironmentProvider.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,mBAAmB;IAC7B,OAAO,CAAgB;IAIjC,YAAY,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CAKF","sourcesContent":["import type { WizardOptions } from '../../utils/types.js';\n\nexport abstract class EnvironmentProvider {\n protected options: WizardOptions;\n\n abstract name: string;\n\n constructor(options: WizardOptions) {\n this.options = options;\n }\n\n abstract detect(): Promise<boolean>;\n\n abstract uploadEnvVars(vars: Record<string, string>): Promise<Record<string, boolean>>;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { Integration } from '../../lib/constants.js';
2
+ import type { WizardOptions } from '../../utils/types.js';
3
+ export declare const uploadEnvironmentVariablesStep: (envVars: Record<string, string>, { integration, options, }: {
4
+ integration: Integration;
5
+ options: WizardOptions;
6
+ }) => Promise<string[]>;