fimo 0.6.0 → 0.7.0-experimental.10

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 (297) hide show
  1. package/assets/skills/fimo/SKILL.md +2 -2
  2. package/assets/skills/fimo/references/locales.md +0 -8
  3. package/assets/skills/fimo/references/setup-react-router.md +2 -2
  4. package/assets/skills/fimo/references/ui.md +1 -1
  5. package/assets/skills/fimo-cli/references/content.md +0 -3
  6. package/assets/skills/fimo-cli/references/locales.md +0 -6
  7. package/assets/skills/fimo-migration/SKILL.md +22 -2
  8. package/assets/skills/fimo-migration/references/content.md +8 -0
  9. package/assets/skills/fimo-migration/references/manifest.md +35 -0
  10. package/assets/skills/fimo-migration/references/qa.md +24 -2
  11. package/assets/skills/fimo-migration/references/workflow.md +12 -1
  12. package/assets/skills/fimo-migration/references/wrap.md +617 -0
  13. package/assets/skills/fimo-studio/references/visual-editing.md +5 -3
  14. package/dist/build/vite/plugins/translations.d.ts +2 -8
  15. package/dist/build/vite/plugins/translations.d.ts.map +1 -1
  16. package/dist/build/vite/plugins/translations.js +3 -121
  17. package/dist/cli/bundle.json +1 -1
  18. package/dist/cli/index.js +29490 -21165
  19. package/dist/runtime/app/FimoProviders.d.ts +1 -11
  20. package/dist/runtime/app/FimoProviders.d.ts.map +1 -1
  21. package/dist/runtime/app/FimoProviders.js +2 -23
  22. package/dist/runtime/astro/index.d.ts +2 -0
  23. package/dist/runtime/astro/index.d.ts.map +1 -0
  24. package/dist/runtime/astro/index.js +3 -0
  25. package/dist/runtime/astro/server.d.ts +3 -0
  26. package/dist/runtime/astro/server.d.ts.map +1 -0
  27. package/dist/runtime/astro/server.js +6 -0
  28. package/dist/runtime/i18n/FimoLocaleContext.d.ts.map +1 -1
  29. package/dist/runtime/i18n/FimoLocaleContext.js +1 -0
  30. package/dist/runtime/next/FimoNextProviders.d.ts +24 -0
  31. package/dist/runtime/next/FimoNextProviders.d.ts.map +1 -0
  32. package/dist/runtime/next/FimoNextProviders.js +20 -0
  33. package/dist/runtime/next/FimoNextScripts.d.ts +10 -0
  34. package/dist/runtime/next/FimoNextScripts.d.ts.map +1 -0
  35. package/dist/runtime/next/FimoNextScripts.js +19 -0
  36. package/dist/runtime/next/index.d.ts +14 -0
  37. package/dist/runtime/next/index.d.ts.map +1 -0
  38. package/dist/runtime/next/index.js +14 -0
  39. package/dist/runtime/next/server.d.ts +2 -0
  40. package/dist/runtime/next/server.d.ts.map +1 -0
  41. package/dist/runtime/next/server.js +4 -0
  42. package/dist/runtime/nuxt/composables.d.ts +9 -0
  43. package/dist/runtime/nuxt/composables.d.ts.map +1 -0
  44. package/dist/runtime/nuxt/composables.js +57 -0
  45. package/dist/runtime/nuxt/index.d.ts +3 -0
  46. package/dist/runtime/nuxt/index.d.ts.map +1 -0
  47. package/dist/runtime/nuxt/index.js +6 -0
  48. package/dist/runtime/nuxt/server.d.ts +3 -0
  49. package/dist/runtime/nuxt/server.d.ts.map +1 -0
  50. package/dist/runtime/nuxt/server.js +6 -0
  51. package/dist/runtime/paths/get-fimo-paths.d.ts.map +1 -1
  52. package/dist/runtime/paths/get-fimo-paths.js +5 -15
  53. package/dist/runtime/primitives/labels-hook.d.ts +33 -0
  54. package/dist/runtime/primitives/labels-hook.d.ts.map +1 -0
  55. package/dist/runtime/primitives/labels-hook.js +41 -0
  56. package/dist/runtime/primitives/labels-store.d.ts +12 -0
  57. package/dist/runtime/primitives/labels-store.d.ts.map +1 -0
  58. package/dist/runtime/primitives/labels-store.js +60 -0
  59. package/dist/runtime/primitives/labels-store.test.d.ts +2 -0
  60. package/dist/runtime/primitives/labels-store.test.d.ts.map +1 -0
  61. package/dist/runtime/primitives/labels-store.test.js +66 -0
  62. package/dist/runtime/primitives/lib/useFimoLiveValue.d.ts +5 -3
  63. package/dist/runtime/primitives/lib/useFimoLiveValue.d.ts.map +1 -1
  64. package/dist/runtime/primitives/lib/useFimoLiveValue.js +11 -4
  65. package/dist/runtime/primitives/translations.d.ts +1 -27
  66. package/dist/runtime/primitives/translations.d.ts.map +1 -1
  67. package/dist/runtime/primitives/translations.js +7 -85
  68. package/dist/runtime/react/FimoSpaProviders.d.ts +36 -0
  69. package/dist/runtime/react/FimoSpaProviders.d.ts.map +1 -0
  70. package/dist/runtime/react/FimoSpaProviders.js +63 -0
  71. package/dist/runtime/react/index.d.ts +33 -0
  72. package/dist/runtime/react/index.d.ts.map +1 -0
  73. package/dist/runtime/react/index.js +39 -0
  74. package/dist/runtime/remix/FimoRemixProviders.d.ts +16 -0
  75. package/dist/runtime/remix/FimoRemixProviders.d.ts.map +1 -0
  76. package/dist/runtime/remix/FimoRemixProviders.js +12 -0
  77. package/dist/runtime/remix/FimoRemixScripts.d.ts +10 -0
  78. package/dist/runtime/remix/FimoRemixScripts.d.ts.map +1 -0
  79. package/dist/runtime/remix/FimoRemixScripts.js +19 -0
  80. package/dist/runtime/remix/index.d.ts +12 -0
  81. package/dist/runtime/remix/index.d.ts.map +1 -0
  82. package/dist/runtime/remix/index.js +11 -0
  83. package/dist/runtime/remix/server.d.ts +2 -0
  84. package/dist/runtime/remix/server.d.ts.map +1 -0
  85. package/dist/runtime/remix/server.js +2 -0
  86. package/dist/runtime/seo/buildSeoForPath.d.ts +3 -1
  87. package/dist/runtime/seo/buildSeoForPath.d.ts.map +1 -1
  88. package/dist/runtime/seo/buildSeoForPath.js +1 -4
  89. package/dist/runtime/shared/display-routes.d.ts +14 -0
  90. package/dist/runtime/shared/display-routes.d.ts.map +1 -0
  91. package/dist/runtime/shared/display-routes.js +25 -0
  92. package/dist/runtime/shared/fimo-config.server.d.ts.map +1 -1
  93. package/dist/runtime/shared/fimo-config.server.js +1 -0
  94. package/dist/runtime/shared/fimo-config.types.d.ts +2 -0
  95. package/dist/runtime/shared/fimo-config.types.d.ts.map +1 -1
  96. package/dist/runtime/shared/i18n-messages.d.ts +29 -0
  97. package/dist/runtime/shared/i18n-messages.d.ts.map +1 -0
  98. package/dist/runtime/shared/i18n-messages.js +79 -0
  99. package/dist/runtime/shared/i18n-messages.test.d.ts +2 -0
  100. package/dist/runtime/shared/i18n-messages.test.d.ts.map +1 -0
  101. package/dist/runtime/shared/i18n-messages.test.js +39 -0
  102. package/dist/runtime/shared/labels-fetch.pure.d.ts +17 -0
  103. package/dist/runtime/shared/labels-fetch.pure.d.ts.map +1 -0
  104. package/dist/runtime/shared/labels-fetch.pure.js +71 -0
  105. package/dist/runtime/shared/labels-fetch.server.d.ts +7 -0
  106. package/dist/runtime/shared/labels-fetch.server.d.ts.map +1 -0
  107. package/dist/runtime/shared/labels-fetch.server.js +97 -0
  108. package/dist/runtime/shared/labels-t.pure.d.ts +2 -0
  109. package/dist/runtime/shared/labels-t.pure.d.ts.map +1 -0
  110. package/dist/runtime/shared/labels-t.pure.js +10 -0
  111. package/dist/runtime/strapi/client.d.ts +26 -0
  112. package/dist/runtime/strapi/client.d.ts.map +1 -0
  113. package/dist/runtime/strapi/client.js +88 -0
  114. package/dist/runtime/strapi/client.test.d.ts +2 -0
  115. package/dist/runtime/strapi/client.test.d.ts.map +1 -0
  116. package/dist/runtime/strapi/client.test.js +64 -0
  117. package/dist/runtime/strapi/index.d.ts +5 -0
  118. package/dist/runtime/strapi/index.d.ts.map +1 -0
  119. package/dist/runtime/strapi/index.js +6 -0
  120. package/dist/runtime/strapi/reshape.d.ts +28 -0
  121. package/dist/runtime/strapi/reshape.d.ts.map +1 -0
  122. package/dist/runtime/strapi/reshape.js +79 -0
  123. package/dist/runtime/strapi/reshape.test.d.ts +2 -0
  124. package/dist/runtime/strapi/reshape.test.d.ts.map +1 -0
  125. package/dist/runtime/strapi/reshape.test.js +33 -0
  126. package/dist/runtime/svelte/index.d.ts +3 -0
  127. package/dist/runtime/svelte/index.d.ts.map +1 -0
  128. package/dist/runtime/svelte/index.js +7 -0
  129. package/dist/runtime/svelte/server.d.ts +3 -0
  130. package/dist/runtime/svelte/server.d.ts.map +1 -0
  131. package/dist/runtime/svelte/server.js +6 -0
  132. package/dist/runtime/vue/index.d.ts +3 -0
  133. package/dist/runtime/vue/index.d.ts.map +1 -0
  134. package/dist/runtime/vue/index.js +5 -0
  135. package/dist/runtime/vue/server.d.ts +3 -0
  136. package/dist/runtime/vue/server.d.ts.map +1 -0
  137. package/dist/runtime/vue/server.js +6 -0
  138. package/dist/runtime/wrapped/FimoFileLink.d.ts +17 -0
  139. package/dist/runtime/wrapped/FimoFileLink.d.ts.map +1 -0
  140. package/dist/runtime/wrapped/FimoFileLink.js +19 -0
  141. package/dist/runtime/wrapped/FimoMediaImage.d.ts +14 -0
  142. package/dist/runtime/wrapped/FimoMediaImage.d.ts.map +1 -0
  143. package/dist/runtime/wrapped/FimoMediaImage.js +20 -0
  144. package/dist/runtime/wrapped/FimoMediaVideo.d.ts +14 -0
  145. package/dist/runtime/wrapped/FimoMediaVideo.d.ts.map +1 -0
  146. package/dist/runtime/wrapped/FimoMediaVideo.js +20 -0
  147. package/dist/runtime/wrapped/FimoRichTextBlock.d.ts +23 -0
  148. package/dist/runtime/wrapped/FimoRichTextBlock.d.ts.map +1 -0
  149. package/dist/runtime/wrapped/FimoRichTextBlock.js +22 -0
  150. package/dist/runtime/wrapped/FimoText.d.ts +22 -0
  151. package/dist/runtime/wrapped/FimoText.d.ts.map +1 -0
  152. package/dist/runtime/wrapped/FimoText.js +20 -0
  153. package/dist/runtime/wrapped/WrappedContentContext.d.ts +28 -0
  154. package/dist/runtime/wrapped/WrappedContentContext.d.ts.map +1 -0
  155. package/dist/runtime/wrapped/WrappedContentContext.js +30 -0
  156. package/dist/runtime/wrapped/WrappedProviders.d.ts +33 -0
  157. package/dist/runtime/wrapped/WrappedProviders.d.ts.map +1 -0
  158. package/dist/runtime/wrapped/WrappedProviders.js +101 -0
  159. package/dist/runtime/wrapped/dom.d.ts +4 -0
  160. package/dist/runtime/wrapped/dom.d.ts.map +1 -0
  161. package/dist/runtime/wrapped/dom.js +23 -0
  162. package/dist/runtime/wrapped/dom.test.d.ts +2 -0
  163. package/dist/runtime/wrapped/dom.test.d.ts.map +1 -0
  164. package/dist/runtime/wrapped/dom.test.js +16 -0
  165. package/dist/runtime/wrapped/server.d.ts +77 -0
  166. package/dist/runtime/wrapped/server.d.ts.map +1 -0
  167. package/dist/runtime/wrapped/server.js +237 -0
  168. package/dist/runtime/wrapped/server.test.d.ts +2 -0
  169. package/dist/runtime/wrapped/server.test.d.ts.map +1 -0
  170. package/dist/runtime/wrapped/server.test.js +91 -0
  171. package/dist/scripts/apply-wrap-templates.d.ts +61 -0
  172. package/dist/scripts/apply-wrap-templates.js +132 -0
  173. package/dist/scripts/apply-wrap-templates.test.d.ts +1 -0
  174. package/dist/scripts/apply-wrap-templates.test.js +199 -0
  175. package/dist/scripts/apply-wrap.d.ts +46 -0
  176. package/dist/scripts/apply-wrap.js +278 -0
  177. package/dist/scripts/apply-wrap.test.d.ts +1 -0
  178. package/dist/scripts/apply-wrap.test.js +226 -0
  179. package/dist/scripts/cms/discover.d.ts +2 -0
  180. package/dist/scripts/cms/discover.js +17 -0
  181. package/dist/scripts/cms/example-content.d.ts +32 -0
  182. package/dist/scripts/cms/example-content.js +108 -0
  183. package/dist/scripts/cms/example-content.test.d.ts +1 -0
  184. package/dist/scripts/cms/example-content.test.js +66 -0
  185. package/dist/scripts/cms/strapi/detect.d.ts +2 -0
  186. package/dist/scripts/cms/strapi/detect.js +186 -0
  187. package/dist/scripts/cms/strapi/detect.test.d.ts +1 -0
  188. package/dist/scripts/cms/strapi/detect.test.js +56 -0
  189. package/dist/scripts/cms/strapi/index.d.ts +3 -0
  190. package/dist/scripts/cms/strapi/index.js +25 -0
  191. package/dist/scripts/cms/strapi/list-source.d.ts +17 -0
  192. package/dist/scripts/cms/strapi/list-source.js +90 -0
  193. package/dist/scripts/cms/strapi/list-source.test.d.ts +1 -0
  194. package/dist/scripts/cms/strapi/list-source.test.js +33 -0
  195. package/dist/scripts/cms/strapi/schema-map.d.ts +9 -0
  196. package/dist/scripts/cms/strapi/schema-map.js +149 -0
  197. package/dist/scripts/cms/strapi/schema-map.test.d.ts +1 -0
  198. package/dist/scripts/cms/strapi/schema-map.test.js +91 -0
  199. package/dist/scripts/cms/strapi/touchpoints.d.ts +31 -0
  200. package/dist/scripts/cms/strapi/touchpoints.js +145 -0
  201. package/dist/scripts/cms/strapi/touchpoints.test.d.ts +1 -0
  202. package/dist/scripts/cms/strapi/touchpoints.test.js +62 -0
  203. package/dist/scripts/cms/strapi/wire-client.d.ts +15 -0
  204. package/dist/scripts/cms/strapi/wire-client.js +107 -0
  205. package/dist/scripts/cms/strapi/wire-client.test.d.ts +1 -0
  206. package/dist/scripts/cms/strapi/wire-client.test.js +51 -0
  207. package/dist/scripts/cms/strapi/wiring.d.ts +17 -0
  208. package/dist/scripts/cms/strapi/wiring.js +36 -0
  209. package/dist/scripts/cms/strapi/wiring.test.d.ts +1 -0
  210. package/dist/scripts/cms/strapi/wiring.test.js +27 -0
  211. package/dist/scripts/cms/types.d.ts +117 -0
  212. package/dist/scripts/cms/types.js +11 -0
  213. package/dist/scripts/detect-framework.d.ts +39 -0
  214. package/dist/scripts/detect-framework.js +133 -0
  215. package/dist/scripts/detect-framework.test.d.ts +1 -0
  216. package/dist/scripts/detect-framework.test.js +122 -0
  217. package/dist/scripts/draft-rows.d.ts +19 -0
  218. package/dist/scripts/draft-rows.js +135 -0
  219. package/dist/scripts/draft-rows.test.d.ts +1 -0
  220. package/dist/scripts/draft-rows.test.js +113 -0
  221. package/dist/scripts/draft-schemas.d.ts +27 -0
  222. package/dist/scripts/draft-schemas.js +188 -0
  223. package/dist/scripts/draft-schemas.test.d.ts +1 -0
  224. package/dist/scripts/draft-schemas.test.js +152 -0
  225. package/dist/scripts/extract-translations.js +16 -11
  226. package/dist/scripts/extract-translations.test.d.ts +1 -0
  227. package/dist/scripts/extract-translations.test.js +66 -0
  228. package/dist/scripts/frameworks/astro/routes.d.ts +3 -0
  229. package/dist/scripts/frameworks/astro/routes.js +55 -0
  230. package/dist/scripts/frameworks/astro/template-style.d.ts +7 -0
  231. package/dist/scripts/frameworks/astro/template-style.js +19 -0
  232. package/dist/scripts/frameworks/discover.d.ts +70 -0
  233. package/dist/scripts/frameworks/discover.js +178 -0
  234. package/dist/scripts/frameworks/next/rewire.d.ts +30 -0
  235. package/dist/scripts/frameworks/next/rewire.js +258 -0
  236. package/dist/scripts/frameworks/next/rewire.test.d.ts +1 -0
  237. package/dist/scripts/frameworks/next/rewire.test.js +134 -0
  238. package/dist/scripts/frameworks/next/routes.d.ts +17 -0
  239. package/dist/scripts/frameworks/next/routes.js +134 -0
  240. package/dist/scripts/frameworks/next/routes.test.d.ts +1 -0
  241. package/dist/scripts/frameworks/next/routes.test.js +64 -0
  242. package/dist/scripts/frameworks/next/wiring.d.ts +33 -0
  243. package/dist/scripts/frameworks/next/wiring.js +186 -0
  244. package/dist/scripts/frameworks/next/wiring.test.d.ts +1 -0
  245. package/dist/scripts/frameworks/next/wiring.test.js +174 -0
  246. package/dist/scripts/frameworks/nuxt/routes.d.ts +3 -0
  247. package/dist/scripts/frameworks/nuxt/routes.js +54 -0
  248. package/dist/scripts/frameworks/nuxt/template-style.d.ts +9 -0
  249. package/dist/scripts/frameworks/nuxt/template-style.js +27 -0
  250. package/dist/scripts/frameworks/remix/routes.d.ts +3 -0
  251. package/dist/scripts/frameworks/remix/routes.js +50 -0
  252. package/dist/scripts/frameworks/support.d.ts +75 -0
  253. package/dist/scripts/frameworks/support.js +165 -0
  254. package/dist/scripts/frameworks/support.test.d.ts +1 -0
  255. package/dist/scripts/frameworks/support.test.js +87 -0
  256. package/dist/scripts/frameworks/sveltekit/routes.d.ts +3 -0
  257. package/dist/scripts/frameworks/sveltekit/routes.js +50 -0
  258. package/dist/scripts/frameworks/sveltekit/template-style.d.ts +9 -0
  259. package/dist/scripts/frameworks/sveltekit/template-style.js +54 -0
  260. package/dist/scripts/frameworks/vite/routes.d.ts +15 -0
  261. package/dist/scripts/frameworks/vite/routes.js +93 -0
  262. package/dist/scripts/frameworks/vite/routes.test.d.ts +1 -0
  263. package/dist/scripts/frameworks/vite/routes.test.js +73 -0
  264. package/dist/scripts/frameworks/vite/wiring.d.ts +10 -0
  265. package/dist/scripts/frameworks/vite/wiring.js +99 -0
  266. package/dist/scripts/frameworks/vite/wiring.test.d.ts +1 -0
  267. package/dist/scripts/frameworks/vite/wiring.test.js +88 -0
  268. package/dist/scripts/i18n-namespace.d.ts +25 -0
  269. package/dist/scripts/i18n-namespace.js +53 -0
  270. package/dist/scripts/lib/validation-report.d.ts +1 -0
  271. package/dist/scripts/lib/validation-report.js +3 -0
  272. package/dist/scripts/render-parity/capture.d.ts +56 -0
  273. package/dist/scripts/render-parity/capture.js +366 -0
  274. package/dist/scripts/render-parity/capture.test.d.ts +1 -0
  275. package/dist/scripts/render-parity/capture.test.js +306 -0
  276. package/dist/scripts/render-parity/compare.d.ts +59 -0
  277. package/dist/scripts/render-parity/compare.js +0 -0
  278. package/dist/scripts/render-parity/compare.test.d.ts +1 -0
  279. package/dist/scripts/render-parity/compare.test.js +98 -0
  280. package/dist/scripts/render-parity/normalize-html.d.ts +13 -0
  281. package/dist/scripts/render-parity/normalize-html.js +223 -0
  282. package/dist/scripts/render-parity/normalize-html.test.d.ts +1 -0
  283. package/dist/scripts/render-parity/normalize-html.test.js +58 -0
  284. package/dist/scripts/render-parity/types.d.ts +41 -0
  285. package/dist/scripts/render-parity/types.js +1 -0
  286. package/dist/scripts/resolve-routes.js +1 -1
  287. package/dist/scripts/scan-wrappable.d.ts +196 -0
  288. package/dist/scripts/scan-wrappable.js +1227 -0
  289. package/dist/scripts/scan-wrappable.test.d.ts +1 -0
  290. package/dist/scripts/scan-wrappable.test.js +521 -0
  291. package/dist/scripts/validate-route-metadata.js +11 -0
  292. package/package.json +92 -5
  293. package/release.json +2 -2
  294. package/templates/react-router/package.json +7 -10
  295. package/dist/runtime/paths/get-fimo-paths.test.d.ts +0 -2
  296. package/dist/runtime/paths/get-fimo-paths.test.d.ts.map +0 -1
  297. package/dist/runtime/paths/get-fimo-paths.test.js +0 -69
@@ -0,0 +1,62 @@
1
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { tmpdir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { afterEach, describe, expect, it } from 'vitest';
5
+ import { detectStrapiTouchpoints } from './touchpoints.js';
6
+ let dir;
7
+ function frontend(files) {
8
+ dir = mkdtempSync(join(tmpdir(), 'strapi-touchpoints-'));
9
+ for (const [rel, content] of Object.entries(files)) {
10
+ const full = join(dir, rel);
11
+ mkdirSync(join(full, '..'), { recursive: true });
12
+ writeFileSync(full, content);
13
+ }
14
+ return dir;
15
+ }
16
+ afterEach(() => {
17
+ if (dir) {
18
+ rmSync(dir, { recursive: true, force: true });
19
+ }
20
+ });
21
+ describe('detectStrapiTouchpoints', () => {
22
+ it('enumerates deps, call sites, and env for a still-wired frontend', () => {
23
+ const cwd = frontend({
24
+ 'package.json': JSON.stringify({
25
+ dependencies: { '@strapi/client': '^1.0.0', next: '16.0.0' },
26
+ devDependencies: { '@repo/strapi-types': 'workspace:*' },
27
+ }),
28
+ 'src/lib/strapi.ts': "import { strapi } from '@strapi/client';\nexport const client = strapi({ baseURL: process.env.STRAPI_URL });\n",
29
+ 'src/app/page.tsx': "const data = await client.collection('api::article.article').find();\n",
30
+ '.env': 'STRAPI_URL=https://cms.example.com\nNEXT_PUBLIC_STRAPI_URL=https://cms.example.com\nOTHER=1\n',
31
+ });
32
+ const result = detectStrapiTouchpoints(cwd);
33
+ expect(result.dependencies.sort()).toEqual(['@repo/strapi-types', '@strapi/client']);
34
+ expect(result.envVars.sort()).toEqual(['NEXT_PUBLIC_STRAPI_URL', 'STRAPI_URL']);
35
+ expect(result.callSites.map((site) => site.reason).sort()).toEqual(['env-ref', 'strapi-sdk-import', 'uid-ref']);
36
+ expect(result.callSites.find((site) => site.reason === 'strapi-sdk-import')?.file).toBe('src/lib/strapi.ts');
37
+ expect(result.clean).toBe(false);
38
+ });
39
+ it('reads a rewired frontend as clean — a lib/strapi.ts calling Fimo is not a touchpoint', () => {
40
+ const cwd = frontend({
41
+ 'package.json': JSON.stringify({ dependencies: { fimo: '0.7.0', next: '16.0.0' } }),
42
+ // Same filename, but now Fimo-backed: no Strapi references.
43
+ 'src/lib/strapi.ts': "import { fimoStrapiFetch } from 'fimo/strapi';\nexport const client = fimoStrapiFetch;\n",
44
+ 'src/app/page.tsx': "const data = await client('/articles');\n",
45
+ });
46
+ const result = detectStrapiTouchpoints(cwd);
47
+ expect(result.dependencies).toEqual([]);
48
+ expect(result.callSites).toEqual([]);
49
+ expect(result.clean).toBe(true);
50
+ });
51
+ it('flags a lingering STRAPI env reference in config even when deps are gone', () => {
52
+ const cwd = frontend({
53
+ 'package.json': JSON.stringify({ dependencies: { next: '16.0.0' } }),
54
+ 'next.config.mjs': 'export default { images: { domains: [process.env.STRAPI_MEDIA_URL] } };\n',
55
+ });
56
+ const result = detectStrapiTouchpoints(cwd);
57
+ expect(result.dependencies).toEqual([]);
58
+ expect(result.callSites).toHaveLength(1);
59
+ expect(result.callSites[0]).toMatchObject({ file: 'next.config.mjs', reason: 'env-ref' });
60
+ expect(result.clean).toBe(false);
61
+ });
62
+ });
@@ -0,0 +1,15 @@
1
+ import type { CmsCollectionSchema } from '../types.js';
2
+ /**
3
+ * Machine-wire a Strapi frontend to read from Fimo: emit the `fimo-strapi`
4
+ * module in the CMS client dir, then swap every bare `fetch(...)` in that dir
5
+ * to `fimoStrapiFetch(...)`. Because every Strapi client funnels through one
6
+ * `fetch`, this makes the WHOLE site read scaffolded content from Fimo — no
7
+ * per-method or per-call-site knowledge, no agent step. Unscaffolded types fall
8
+ * through to the live CMS inside the shim.
9
+ */
10
+ export interface StrapiWireResult {
11
+ changes: string[];
12
+ warnings: string[];
13
+ wired: boolean;
14
+ }
15
+ export declare function wireStrapiClient(cwd: string, clientDir: string, schemas: CmsCollectionSchema[]): StrapiWireResult;
@@ -0,0 +1,107 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { parseSync } from 'oxc-parser';
4
+ import { renderFimoStrapiModule } from './wiring.js';
5
+ function walk(node, visit) {
6
+ if (!node || typeof node !== 'object') {
7
+ return;
8
+ }
9
+ if (Array.isArray(node)) {
10
+ for (const child of node) {
11
+ walk(child, visit);
12
+ }
13
+ return;
14
+ }
15
+ const record = node;
16
+ if (typeof record.type === 'string') {
17
+ visit(record);
18
+ }
19
+ for (const [key, value] of Object.entries(record)) {
20
+ if (key !== 'type' && value && typeof value === 'object') {
21
+ walk(value, visit);
22
+ }
23
+ }
24
+ }
25
+ /** Callee spans of bare `fetch(...)` calls (not `x.fetch()` / `this.fetch()`). */
26
+ function bareFetchCallees(filePath, code) {
27
+ let program;
28
+ try {
29
+ program = parseSync(filePath, code).program;
30
+ }
31
+ catch {
32
+ return [];
33
+ }
34
+ const spans = [];
35
+ walk(program, (n) => {
36
+ if (n.type === 'CallExpression' && n.callee?.type === 'Identifier' && n.callee.name === 'fetch') {
37
+ spans.push({ start: n.callee.start, end: n.callee.end });
38
+ }
39
+ });
40
+ return spans;
41
+ }
42
+ function applyReplacements(code, edits) {
43
+ let next = code;
44
+ for (const edit of [...edits].sort((a, b) => b.start - a.start)) {
45
+ next = next.slice(0, edit.start) + edit.text + next.slice(edit.end);
46
+ }
47
+ return next;
48
+ }
49
+ function relativeImport(fromFile, toFile) {
50
+ const rel = path
51
+ .relative(path.dirname(fromFile), toFile)
52
+ .replace(/\.tsx?$/, '')
53
+ .split(path.sep)
54
+ .join('/');
55
+ return rel.startsWith('.') ? rel : `./${rel}`;
56
+ }
57
+ function sourceFiles(dir) {
58
+ const out = [];
59
+ const walkDir = (current) => {
60
+ for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
61
+ if (entry.name === 'node_modules' || entry.name.startsWith('.')) {
62
+ continue;
63
+ }
64
+ const full = path.join(current, entry.name);
65
+ if (entry.isDirectory()) {
66
+ walkDir(full);
67
+ }
68
+ else if (/\.(tsx?|jsx?|mjs)$/.test(entry.name)) {
69
+ out.push(full);
70
+ }
71
+ }
72
+ };
73
+ if (fs.existsSync(dir)) {
74
+ walkDir(dir);
75
+ }
76
+ return out;
77
+ }
78
+ export function wireStrapiClient(cwd, clientDir, schemas) {
79
+ const changes = [];
80
+ const warnings = [];
81
+ if (!fs.existsSync(clientDir)) {
82
+ return { changes, warnings: [`CMS client directory not found: ${path.relative(cwd, clientDir)}`], wired: false };
83
+ }
84
+ const modulePath = path.join(clientDir, 'fimo-strapi.ts');
85
+ fs.writeFileSync(modulePath, renderFimoStrapiModule(schemas));
86
+ changes.push(`generated ${path.relative(cwd, modulePath)}`);
87
+ let swapped = 0;
88
+ for (const file of sourceFiles(clientDir)) {
89
+ if (path.resolve(file) === path.resolve(modulePath)) {
90
+ continue;
91
+ }
92
+ const code = fs.readFileSync(file, 'utf8');
93
+ const spans = bareFetchCallees(file, code);
94
+ if (spans.length === 0) {
95
+ continue;
96
+ }
97
+ let next = applyReplacements(code, spans.map((span) => ({ ...span, text: 'fimoStrapiFetch' })));
98
+ next = `import { fimoStrapiFetch } from '${relativeImport(file, modulePath)}';\n${next}`;
99
+ fs.writeFileSync(file, next);
100
+ swapped += spans.length;
101
+ changes.push(`rewired ${path.relative(cwd, file)}: ${spans.length} fetch call(s) → fimoStrapiFetch`);
102
+ }
103
+ if (swapped === 0) {
104
+ warnings.push(`No bare fetch() call found under ${path.relative(cwd, clientDir)} — wire fimoStrapiFetch into the client manually.`);
105
+ }
106
+ return { changes, warnings, wired: swapped > 0 };
107
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,51 @@
1
+ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { tmpdir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { afterEach, describe, expect, it } from 'vitest';
5
+ import { wireStrapiClient } from './wire-client.js';
6
+ let dir;
7
+ const schemas = [
8
+ {
9
+ name: 'BlogPost',
10
+ label: 'Blog Post',
11
+ isSingleton: false,
12
+ localized: false,
13
+ fields: {},
14
+ sourceUid: 'api::blog-post.blog-post',
15
+ sourcePath: '/blog-posts',
16
+ },
17
+ ];
18
+ afterEach(() => {
19
+ if (dir) {
20
+ rmSync(dir, { recursive: true, force: true });
21
+ }
22
+ });
23
+ describe('wireStrapiClient', () => {
24
+ it('generates the fimo-strapi module and swaps bare fetch calls', () => {
25
+ dir = mkdtempSync(join(tmpdir(), 'wire-strapi-'));
26
+ const clientDir = join(dir, 'src', 'lib', 'strapi-api');
27
+ mkdirSync(clientDir, { recursive: true });
28
+ writeFileSync(join(clientDir, 'base.ts'), 'export async function req(url: string, init: RequestInit) {\n const response = await fetch(url, init);\n return response;\n}\n');
29
+ writeFileSync(join(clientDir, 'other.ts'), 'export const x = 1;\n');
30
+ const result = wireStrapiClient(dir, clientDir, schemas);
31
+ expect(result.wired).toBe(true);
32
+ const generated = readFileSync(join(clientDir, 'fimo-strapi.ts'), 'utf8');
33
+ expect(generated).toContain('createFimoStrapiFetch');
34
+ expect(generated).toContain("'blog-posts': 'BlogPost',");
35
+ const base = readFileSync(join(clientDir, 'base.ts'), 'utf8');
36
+ expect(base).toContain('await fimoStrapiFetch(url, init)');
37
+ expect(base).not.toContain('await fetch(');
38
+ expect(base).toContain("import { fimoStrapiFetch } from './fimo-strapi';");
39
+ // A file with no fetch stays untouched.
40
+ expect(readFileSync(join(clientDir, 'other.ts'), 'utf8')).not.toContain('fimoStrapiFetch');
41
+ });
42
+ it('warns when no bare fetch is found', () => {
43
+ dir = mkdtempSync(join(tmpdir(), 'wire-strapi-none-'));
44
+ const clientDir = join(dir, 'client');
45
+ mkdirSync(clientDir, { recursive: true });
46
+ writeFileSync(join(clientDir, 'base.ts'), 'export const x = 1;\n');
47
+ const result = wireStrapiClient(dir, clientDir, schemas);
48
+ expect(result.wired).toBe(false);
49
+ expect(result.warnings[0]).toContain('No bare fetch()');
50
+ });
51
+ });
@@ -0,0 +1,17 @@
1
+ import type { CmsCollectionSchema } from '../types.js';
2
+ /**
3
+ * Machine-wiring for the native `fimo/strapi` read adapter. From the scaffolded
4
+ * schemas it derives the Strapi-path → Fimo-type map (+ the singletons) and
5
+ * emits a tiny repo module that instantiates the Fimo-backed fetch. The
6
+ * migration then swaps the CMS client's `fetch` for `fimoStrapiFetch` — after
7
+ * which the whole site reads scaffolded content from Fimo, deterministically.
8
+ */
9
+ export interface StrapiWiring {
10
+ /** Strapi REST path segment (pluralName) → Fimo type name. */
11
+ types: Record<string, string>;
12
+ /** Fimo type names that are single types. */
13
+ singletons: string[];
14
+ }
15
+ export declare function strapiWiring(schemas: CmsCollectionSchema[]): StrapiWiring;
16
+ /** Emit the repo module (`fimo-strapi.ts`) that wires the fetch to Fimo. */
17
+ export declare function renderFimoStrapiModule(schemas: CmsCollectionSchema[]): string;
@@ -0,0 +1,36 @@
1
+ export function strapiWiring(schemas) {
2
+ const types = {};
3
+ const singletons = [];
4
+ for (const schema of schemas) {
5
+ const pluralName = schema.sourcePath.replace(/^\/+/, '');
6
+ if (pluralName) {
7
+ types[pluralName] = schema.name;
8
+ }
9
+ if (schema.isSingleton) {
10
+ singletons.push(schema.name);
11
+ }
12
+ }
13
+ return { types, singletons };
14
+ }
15
+ /** Emit the repo module (`fimo-strapi.ts`) that wires the fetch to Fimo. */
16
+ export function renderFimoStrapiModule(schemas) {
17
+ const { types, singletons } = strapiWiring(schemas);
18
+ const typeEntries = Object.entries(types)
19
+ .map(([pluralName, typeName]) => ` '${pluralName}': '${typeName}',`)
20
+ .join('\n');
21
+ return `// AUTO-GENERATED by \`fimo migrate --scaffold-cms\`. Serves this site's Strapi
22
+ // content reads from Fimo (scaffolded example content) through fimo/strapi.
23
+ // The migration points the CMS client's fetch at \`fimoStrapiFetch\`; reads for
24
+ // scaffolded types resolve from Fimo, everything else falls through to Strapi.
25
+ import { createFimoStrapiFetch } from 'fimo/strapi';
26
+
27
+ // Strapi REST path (pluralName) -> Fimo type name.
28
+ const TYPES: Record<string, string> = {
29
+ ${typeEntries}
30
+ };
31
+
32
+ const SINGLETONS = [${singletons.map((name) => `'${name}'`).join(', ')}];
33
+
34
+ export const fimoStrapiFetch = createFimoStrapiFetch({ types: TYPES, singletons: SINGLETONS });
35
+ `;
36
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { renderFimoStrapiModule, strapiWiring } from './wiring.js';
3
+ const schema = (name, sourcePath, isSingleton = false) => ({
4
+ name,
5
+ label: name,
6
+ isSingleton,
7
+ localized: false,
8
+ fields: {},
9
+ sourceUid: `api::${name.toLowerCase()}.${name.toLowerCase()}`,
10
+ sourcePath,
11
+ });
12
+ describe('strapiWiring', () => {
13
+ it('maps pluralName paths to Fimo types and lists singletons', () => {
14
+ const wiring = strapiWiring([schema('BlogPost', '/blog-posts'), schema('Global', '/globals', true)]);
15
+ expect(wiring.types).toEqual({ 'blog-posts': 'BlogPost', globals: 'Global' });
16
+ expect(wiring.singletons).toEqual(['Global']);
17
+ });
18
+ });
19
+ describe('renderFimoStrapiModule', () => {
20
+ it('emits a module importing fimo/strapi with the type map + singletons', () => {
21
+ const src = renderFimoStrapiModule([schema('BlogPost', '/blog-posts'), schema('Global', '/globals', true)]);
22
+ expect(src).toContain("import { createFimoStrapiFetch } from 'fimo/strapi';");
23
+ expect(src).toContain("'blog-posts': 'BlogPost',");
24
+ expect(src).toContain("const SINGLETONS = ['Global'];");
25
+ expect(src).toContain('export const fimoStrapiFetch = createFimoStrapiFetch({ types: TYPES, singletons: SINGLETONS });');
26
+ });
27
+ });
@@ -0,0 +1,117 @@
1
+ /**
2
+ * CMS-connector contract. A connector recognizes an external headless CMS
3
+ * behind a wrapped frontend and reads its content-type definitions into the
4
+ * neutral Fimo schema shape — WITHOUT connecting to the CMS at runtime.
5
+ *
6
+ * The connector seam mirrors the framework-adapter contract: a CMS's name and
7
+ * quirks live ONLY under `scripts/cms/<cms>/`. Everything above (the registry,
8
+ * the example-content generator, the orchestrator wiring) is CMS-neutral. A
9
+ * CMS name appearing in neutral code is a review finding.
10
+ */
11
+ /** Scalar Fimo field types (see `FieldTypeSchema` in api-contracts). */
12
+ export type FimoScalarType = 'string' | 'richtext' | 'media' | 'number' | 'boolean' | 'date' | 'json';
13
+ export interface FimoScalarField {
14
+ readonly type: FimoScalarType;
15
+ }
16
+ export interface FimoReferenceField {
17
+ readonly type: 'reference';
18
+ /** Single-target reference (Fimo type name). */
19
+ readonly target?: string;
20
+ /** Poly-target reference (Fimo type names). */
21
+ readonly targets?: string[];
22
+ /** True for to-many relations. */
23
+ readonly many?: boolean;
24
+ }
25
+ export type FimoFieldDef = FimoScalarField | FimoReferenceField;
26
+ /**
27
+ * One CMS content type mapped to the Fimo schema shape. `fields` is the exact
28
+ * pushable `contentType.fields` payload; `name`/`label`/`isSingleton` complete
29
+ * the `api.createSchema` call.
30
+ */
31
+ export interface CmsCollectionSchema {
32
+ /** Fimo type name (PascalCase — deterministic from the CMS singular name). */
33
+ readonly name: string;
34
+ /** Human display label. */
35
+ readonly label: string;
36
+ /** A single-document type (e.g. a Strapi singleType) → true; a collection → false. */
37
+ readonly isSingleton: boolean;
38
+ /** The CMS marks this type as localized → seed per configured locale. */
39
+ readonly localized: boolean;
40
+ readonly fields: Record<string, FimoFieldDef>;
41
+ /** Pre-computed example values for fields the generic generator can't shape
42
+ * from the Fimo field type alone (dynamic zones must be arrays, components
43
+ * objects). Keyed by field name; the generator uses these verbatim. */
44
+ readonly examples?: Record<string, unknown>;
45
+ /** Source CMS uid for provenance (e.g. `api::blog-post.blog-post`). */
46
+ readonly sourceUid: string;
47
+ /** Source REST path (e.g. `/blog-posts`) — informational for later rewire. */
48
+ readonly sourcePath: string;
49
+ }
50
+ /** What a connector reports about a detected CMS. */
51
+ export interface CmsDetection {
52
+ /** Connector name, capitalized for the data-source prompt (e.g. `Strapi`). */
53
+ readonly cms: string;
54
+ /** Host label recorded in the data-source decision. */
55
+ readonly host: string;
56
+ /** Absolute path to the CMS app root when co-located (monorepo), else null. */
57
+ readonly appDir: string | null;
58
+ /** Absolute path to the frontend's CMS client module dir (where the fetch
59
+ * lives), for machine-wiring the reads to Fimo. Null if not found. */
60
+ readonly clientDir: string | null;
61
+ /** Repo-relative files/signals that evidenced the detection. */
62
+ readonly evidence: string[];
63
+ /** Locales configured in the CMS, when discoverable (may be empty). */
64
+ readonly locales: string[];
65
+ }
66
+ export interface CmsConnector {
67
+ readonly detection: CmsDetection;
68
+ /**
69
+ * Read every content-type definition into the Fimo schema shape. Returns an
70
+ * empty array when the schemas are not locally available (decoupled CMS with
71
+ * no co-located source) — detection can still surface the source for a
72
+ * keep-live decision even when schema import is impossible.
73
+ */
74
+ readSchemas(): CmsCollectionSchema[];
75
+ /**
76
+ * Emit a generic list-read helper (as source text) the agent wires into the
77
+ * site's LIST views so they render the scaffolded example content from Fimo.
78
+ * Returns null when the CMS has no such helper. `serverImport` is the
79
+ * framework's Fimo server subpath (e.g. `fimo/next/server`) the helper imports
80
+ * `fetchEntries` from.
81
+ */
82
+ renderListSource?(schemas: CmsCollectionSchema[], serverImport: string): string | null;
83
+ /**
84
+ * Machine-wire the frontend's CMS reads to Fimo: emit the adapter module and
85
+ * swap the client's fetch, so the whole site reads scaffolded content from
86
+ * Fimo. Deterministic — no agent step.
87
+ */
88
+ wireClient?(cwd: string, schemas: CmsCollectionSchema[]): CmsWireResult;
89
+ /**
90
+ * Enumerate the frontend's remaining couplings to this CMS — the unwire
91
+ * worklist and the cutover gate (`clean`). Keys on actual CMS references, not
92
+ * filenames, so a client module rewritten to call Fimo reads as clean.
93
+ * Returns undefined for a connector without touchpoint detection.
94
+ */
95
+ detectTouchpoints?(cwd: string): CmsTouchpoints;
96
+ }
97
+ export interface CmsWireResult {
98
+ changes: string[];
99
+ warnings: string[];
100
+ wired: boolean;
101
+ }
102
+ export interface CmsTouchpointSite {
103
+ file: string;
104
+ line: number;
105
+ reason: string;
106
+ snippet: string;
107
+ }
108
+ export interface CmsTouchpoints {
109
+ /** SDK/client/type packages still declared in the frontend's package.json. */
110
+ dependencies: string[];
111
+ /** Source lines that still reach the CMS at runtime. */
112
+ callSites: CmsTouchpointSite[];
113
+ /** CMS base-URL / token env keys still present in dotenv files. */
114
+ envVars: string[];
115
+ /** No runtime coupling remains — the cutover is complete. */
116
+ clean: boolean;
117
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * CMS-connector contract. A connector recognizes an external headless CMS
3
+ * behind a wrapped frontend and reads its content-type definitions into the
4
+ * neutral Fimo schema shape — WITHOUT connecting to the CMS at runtime.
5
+ *
6
+ * The connector seam mirrors the framework-adapter contract: a CMS's name and
7
+ * quirks live ONLY under `scripts/cms/<cms>/`. Everything above (the registry,
8
+ * the example-content generator, the orchestrator wiring) is CMS-neutral. A
9
+ * CMS name appearing in neutral code is a review finding.
10
+ */
11
+ export {};
@@ -0,0 +1,39 @@
1
+ export type DetectedFramework = 'next' | 'react-router' | 'remix' | 'astro' | 'nuxt' | 'sveltekit' | 'vue' | 'vite';
2
+ export interface FrameworkDetection {
3
+ framework: DetectedFramework | null;
4
+ /** For Next.js: the app-router directory (`app` or `src/app`) when present. */
5
+ appDir?: string;
6
+ /** For Next.js: the pages-router directory (`pages` or `src/pages`) when present. */
7
+ pagesDir?: string;
8
+ /** A recognized framework that wrap migration does not support yet. */
9
+ unsupported?: string;
10
+ /** For bare Vite: the project depends on react, so .jsx/.tsx is React JSX. */
11
+ react?: boolean;
12
+ }
13
+ /**
14
+ * Detect the framework of an existing site from its package.json and layout.
15
+ * Used by `fimo init` (adopt-existing-site) and the wrap migration to decide
16
+ * how routes are discovered and which env flavor to write.
17
+ */
18
+ export declare function detectFramework(cwd: string): FrameworkDetection;
19
+ /** A frontend app found inside a workspace, adoptable by `fimo init`. */
20
+ export interface AdoptableApp {
21
+ /** Absolute directory of the app. */
22
+ dir: string;
23
+ /** Directory relative to the scan root (for display + as the init dirArg). */
24
+ relDir: string;
25
+ detection: FrameworkDetection;
26
+ }
27
+ /**
28
+ * Find frontend apps to adopt anywhere inside a directory tree. Most real
29
+ * sites are monorepos where the framework app is NOT at the root and NOT
30
+ * necessarily under `apps/` (`frontend/`, `sites/web`, `packages/marketing`,
31
+ * …) — `detectFramework(root)` returns null and `fimo init` would wrongly
32
+ * scaffold a new project. This walks the tree up to a bounded depth, running
33
+ * `detectFramework` on every directory that has a package.json and pruning
34
+ * `node_modules`/build output, so it finds the app wherever it lives without
35
+ * relying on a naming convention or a workspace manifest. The root itself is
36
+ * excluded (the caller checks it directly); descent stops at the first
37
+ * framework match in a subtree (an app's own subdirs are not separate apps).
38
+ */
39
+ export declare function findAdoptableApps(rootDir: string): AdoptableApp[];
@@ -0,0 +1,133 @@
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { join, relative } from 'node:path';
3
+ /**
4
+ * Detect the framework of an existing site from its package.json and layout.
5
+ * Used by `fimo init` (adopt-existing-site) and the wrap migration to decide
6
+ * how routes are discovered and which env flavor to write.
7
+ */
8
+ export function detectFramework(cwd) {
9
+ const pkgPath = join(cwd, 'package.json');
10
+ if (!existsSync(pkgPath)) {
11
+ return { framework: null };
12
+ }
13
+ let pkg;
14
+ try {
15
+ pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
16
+ }
17
+ catch {
18
+ return { framework: null };
19
+ }
20
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
21
+ if (deps.next) {
22
+ const appDir = ['app', 'src/app'].find((dir) => existsSync(join(cwd, dir)));
23
+ const pagesDir = ['pages', 'src/pages'].find((dir) => existsSync(join(cwd, dir)));
24
+ return { framework: 'next', appDir, pagesDir };
25
+ }
26
+ if (deps['react-router'] || deps['@react-router/dev']) {
27
+ return { framework: 'react-router' };
28
+ }
29
+ if (deps['@remix-run/react']) {
30
+ const pagesDir = ['app/routes'].find((dir) => existsSync(join(cwd, dir)));
31
+ return { framework: 'remix', pagesDir };
32
+ }
33
+ if (deps.astro) {
34
+ const pagesDir = ['src/pages'].find((dir) => existsSync(join(cwd, dir)));
35
+ return { framework: 'astro', pagesDir };
36
+ }
37
+ if (deps.nuxt) {
38
+ // 'src/pages' covers the common custom srcDir (nuxt.config `srcDir: './src'`).
39
+ const pagesDir = ['pages', 'app/pages', 'src/pages'].find((dir) => existsSync(join(cwd, dir)));
40
+ return { framework: 'nuxt', pagesDir };
41
+ }
42
+ if (deps['@sveltejs/kit']) {
43
+ const pagesDir = ['src/routes'].find((dir) => existsSync(join(cwd, dir)));
44
+ return { framework: 'sveltekit', pagesDir };
45
+ }
46
+ if (deps.vue && deps.vite) {
47
+ return { framework: 'vue' };
48
+ }
49
+ if (deps.vite) {
50
+ // A react dependency guarantees the JSX runtime: the --apply codemod and
51
+ // react-router route discovery are safe. Bare vite (Solid, Preact, lit)
52
+ // stays hands-off.
53
+ return { framework: 'vite', react: Boolean(deps.react) };
54
+ }
55
+ // Known frameworks we can NAME but not wrap yet — lets `fimo init` route
56
+ // honestly instead of silently falling through to create-new.
57
+ const unsupportedByDep = [
58
+ ['gatsby', 'Gatsby'],
59
+ ['@angular/core', 'Angular'],
60
+ ['@docusaurus/core', 'Docusaurus'],
61
+ ['@11ty/eleventy', 'Eleventy'],
62
+ ];
63
+ for (const [dep, name] of unsupportedByDep) {
64
+ if (deps[dep]) {
65
+ return { framework: null, unsupported: name };
66
+ }
67
+ }
68
+ return { framework: null };
69
+ }
70
+ const WORKSPACE_SKIP = new Set([
71
+ 'node_modules',
72
+ '.git',
73
+ 'dist',
74
+ 'build',
75
+ 'out',
76
+ '.next',
77
+ '.nuxt',
78
+ '.svelte-kit',
79
+ '.turbo',
80
+ '.vercel',
81
+ 'coverage',
82
+ ]);
83
+ /** How deep below the root the scan looks for a framework app (`apps/ui` is
84
+ * depth 2, `packages/frontend/web` is depth 3). */
85
+ const MAX_SCAN_DEPTH = 3;
86
+ /**
87
+ * Find frontend apps to adopt anywhere inside a directory tree. Most real
88
+ * sites are monorepos where the framework app is NOT at the root and NOT
89
+ * necessarily under `apps/` (`frontend/`, `sites/web`, `packages/marketing`,
90
+ * …) — `detectFramework(root)` returns null and `fimo init` would wrongly
91
+ * scaffold a new project. This walks the tree up to a bounded depth, running
92
+ * `detectFramework` on every directory that has a package.json and pruning
93
+ * `node_modules`/build output, so it finds the app wherever it lives without
94
+ * relying on a naming convention or a workspace manifest. The root itself is
95
+ * excluded (the caller checks it directly); descent stops at the first
96
+ * framework match in a subtree (an app's own subdirs are not separate apps).
97
+ */
98
+ export function findAdoptableApps(rootDir) {
99
+ const apps = [];
100
+ const walk = (dir, depth) => {
101
+ if (depth > MAX_SCAN_DEPTH) {
102
+ return;
103
+ }
104
+ if (dir !== rootDir && existsSync(join(dir, 'package.json'))) {
105
+ const detection = detectFramework(dir);
106
+ if (detection.framework) {
107
+ apps.push({ dir, relDir: relative(rootDir, dir), detection });
108
+ return; // don't descend into an app's own subtree
109
+ }
110
+ }
111
+ let entries;
112
+ try {
113
+ entries = readdirSync(dir, { withFileTypes: true });
114
+ }
115
+ catch {
116
+ return;
117
+ }
118
+ for (const entry of entries) {
119
+ if (entry.isDirectory() && !WORKSPACE_SKIP.has(entry.name) && !entry.name.startsWith('.')) {
120
+ walk(join(dir, entry.name), depth + 1);
121
+ }
122
+ }
123
+ };
124
+ walk(rootDir, 0);
125
+ // Shallower + apps/-conventional first (the most likely primary site), then
126
+ // alphabetical — the order the interactive picker presents them in.
127
+ return apps.sort((a, b) => {
128
+ const depthA = a.relDir.split('/').length;
129
+ const depthB = b.relDir.split('/').length;
130
+ const rank = (relDir) => (relDir.startsWith('apps/') ? 0 : 1);
131
+ return rank(a.relDir) - rank(b.relDir) || depthA - depthB || a.relDir.localeCompare(b.relDir);
132
+ });
133
+ }
@@ -0,0 +1 @@
1
+ export {};