fimo 0.4.0 → 0.4.1-staging.2

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.
@@ -59,7 +59,7 @@ Workflow / CLI-side concerns (pushing schemas, generating images, managing label
59
59
  - **Raw HTML for schema content** — `<img src={post.coverImage.url}>` instead of `<Image value={post.coverImage}>`. The `fimo/ui` components carry metadata for inline editing in the admin.
60
60
  - **Raw `<a href>` for internal navigation** — causes full page reloads. Use `<FimoLink>` for locale-aware internal links or React Router `<Link>` when intentionally bypassing locale helpers. Reserve `<a>` for external links.
61
61
  - **Pulling stock photos from external URLs** — editors can't manage them. Use `fimo generate` (CLI).
62
- - **Editing generated `.ts` files** under `src/schemas/` or `src/forms/` — regenerated on every build.
62
+ - **Editing generated `.ts` files** under `src/schemas/` or `src/forms/` — regenerate them through `fimo validate` or the matching push command.
63
63
  - **Writing raw HTML in `richtext` fields** — must be Tiptap JSONContent.
64
64
  - **Calling `t()` with a dynamic first argument** — the key must be a string literal so the extractor finds it.
65
65
  - **Decorating the disposable starter** — `src/pages/Index.tsx` is throwaway scaffolding. On first real generation, replace it entirely.
@@ -80,7 +80,7 @@ The template uses **Vite + React 19 + TypeScript + Tailwind v4 + shadcn/ui + rea
80
80
  - Raw `<img>` for schema media → use `<Image>` (with width/height).
81
81
  - Hardcoded strings in JSX → wrap in `t('key')` and add the DB value with `fimo labels set`.
82
82
  - Calling `t()` with a dynamic first argument → key must be a string literal.
83
- - Editing generated `.ts` files under `src/schemas/` or `src/forms/` → regenerated on every build.
83
+ - Editing generated `.ts` files under `src/schemas/` or `src/forms/` → regenerate them through `fimo validate` or the matching push command.
84
84
  - Writing raw HTML into a `richtext` field → must be Tiptap JSONContent.
85
85
  - Hand-constructing a `FimoMedia` object to pass into `<Image>` → use `<StaticImage>` for non-schema images.
86
86
  - Decorating `src/pages/Index.tsx` → replace it on first real generation.
@@ -113,7 +113,7 @@ Use `"isSingleton": true` for a type with exactly one logical document. Generate
113
113
 
114
114
  ## When to run sync manually
115
115
 
116
- `fimo schemas push`, `fimo validate`, and the `fimo/vite` plugin all reuse the same schema generator. `schemas push` does not run route, label, agent, form, or project-wide checks. For a full local validation and codegen pass without updating the remote schema, use:
116
+ `fimo schemas push`, `fimo validate`, and the `fimo/vite` development watcher all reuse the same schema generator. Production builds do not rewrite generated source files. `schemas push` does not run route, label, agent, form, or project-wide checks. For a full local validation and codegen pass without updating the remote schema, use:
117
117
 
118
118
  ```bash
119
119
  fimo validate # runs all phases: codegen, lint, route validation, label checks
@@ -56,7 +56,7 @@ Use this when the user asks "who filled out the contact form?", "how many signup
56
56
 
57
57
  ## When to run sync manually
58
58
 
59
- The `fimo/vite` plugin auto-regenerates `src/forms/*.ts`. To regen outside vite, use:
59
+ The `fimo/vite` plugin regenerates `src/forms/*.ts` after form JSON changes during development. Before a production build, regenerate explicitly with:
60
60
 
61
61
  ```bash
62
62
  fimo validate # runs all phases: codegen, lint, route validation, label checks
@@ -1,13 +1,11 @@
1
1
  import type { Plugin } from 'vite';
2
2
  /**
3
- * Runs what `.fimo/pre-build.ts` used to do — schema + form TS generation —
4
- * as Vite hooks:
3
+ * Keeps generated schema + form clients in sync while the Vite dev server is
4
+ * running.
5
5
  *
6
- * - `buildStart`: fires once at the start of `vite build` AND `vite dev`.
7
- * Regenerates `src/schemas/*.ts` and `src/forms/*.ts` from the JSON sources.
8
- * - `configureServer`: during dev, watches `src/{schemas,forms}/**`/*`.json`
9
- * and re-runs the matching sync on change so Vite's HMR picks up the
10
- * freshly generated `.ts` files.
6
+ * Production builds are deliberately read-only. Explicit authoring commands
7
+ * (`fimo validate`, `fimo schemas push`, and `fimo forms push`) own initial
8
+ * generation before a build starts.
11
9
  */
12
10
  export default function contentSyncPlugin(): Plugin;
13
11
  //# sourceMappingURL=content-sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"content-sync.d.ts","sourceRoot":"","sources":["../../../../src/build/vite/plugins/content-sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAKlD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,IAAI,MAAM,CA2ClD"}
1
+ {"version":3,"file":"content-sync.d.ts","sourceRoot":"","sources":["../../../../src/build/vite/plugins/content-sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAKlD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,IAAI,MAAM,CAkClD"}
@@ -2,30 +2,21 @@ import { resolve } from 'path';
2
2
  import { syncForms } from '../../../scripts/sync-forms.js';
3
3
  import { syncSchemas } from '../../../scripts/sync-schemas.js';
4
4
  /**
5
- * Runs what `.fimo/pre-build.ts` used to do — schema + form TS generation —
6
- * as Vite hooks:
5
+ * Keeps generated schema + form clients in sync while the Vite dev server is
6
+ * running.
7
7
  *
8
- * - `buildStart`: fires once at the start of `vite build` AND `vite dev`.
9
- * Regenerates `src/schemas/*.ts` and `src/forms/*.ts` from the JSON sources.
10
- * - `configureServer`: during dev, watches `src/{schemas,forms}/**`/*`.json`
11
- * and re-runs the matching sync on change so Vite's HMR picks up the
12
- * freshly generated `.ts` files.
8
+ * Production builds are deliberately read-only. Explicit authoring commands
9
+ * (`fimo validate`, `fimo schemas push`, and `fimo forms push`) own initial
10
+ * generation before a build starts.
13
11
  */
14
12
  export default function contentSyncPlugin() {
15
13
  let rootDir = process.cwd();
16
- const runAll = () => {
17
- syncSchemas({ cwd: rootDir, verbose: false });
18
- syncForms({ cwd: rootDir, verbose: false });
19
- };
20
14
  return {
21
15
  name: 'vite-plugin-fimo-content-sync',
22
16
  enforce: 'pre',
23
17
  configResolved(config) {
24
18
  rootDir = config.root;
25
19
  },
26
- buildStart() {
27
- runAll();
28
- },
29
20
  configureServer(server) {
30
21
  const schemasGlob = resolve(rootDir, 'src/schemas');
31
22
  const formsGlob = resolve(rootDir, 'src/forms');
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=content-sync.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-sync.test.d.ts","sourceRoot":"","sources":["../../../../src/build/vite/plugins/content-sync.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,64 @@
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, vi } from 'vitest';
5
+ import contentSyncPlugin from './content-sync';
6
+ let scratch = null;
7
+ const pluginContext = {
8
+ addWatchFile: vi.fn(),
9
+ meta: {},
10
+ error: (error) => {
11
+ throw error;
12
+ },
13
+ info: () => undefined,
14
+ warn: () => undefined,
15
+ debug: () => undefined,
16
+ };
17
+ afterEach(() => {
18
+ if (scratch) {
19
+ rmSync(scratch, { recursive: true, force: true });
20
+ scratch = null;
21
+ }
22
+ vi.clearAllMocks();
23
+ });
24
+ function createProjectRoot() {
25
+ scratch = mkdtempSync(join(tmpdir(), 'fimo-content-sync-plugin-'));
26
+ mkdirSync(join(scratch, 'src/schemas'), { recursive: true });
27
+ return scratch;
28
+ }
29
+ function configurePlugin(plugin, root) {
30
+ if (typeof plugin.configResolved === 'function') {
31
+ plugin.configResolved.call(pluginContext, { root });
32
+ }
33
+ }
34
+ describe('contentSyncPlugin', () => {
35
+ it('does not mutate generated files during a production build', () => {
36
+ const plugin = contentSyncPlugin();
37
+ expect(plugin.buildStart).toBeUndefined();
38
+ expect(plugin.generateBundle).toBeUndefined();
39
+ expect(plugin.writeBundle).toBeUndefined();
40
+ });
41
+ it('regenerates schema clients after a schema changes in dev', () => {
42
+ const root = createProjectRoot();
43
+ const schemaPath = join(root, 'src/schemas/Post.json');
44
+ writeFileSync(schemaPath, JSON.stringify({ uid: 'Post', name: 'Posts', fields: { title: { type: 'string' } } }, null, 2));
45
+ const listeners = new Map();
46
+ const server = {
47
+ watcher: {
48
+ add: vi.fn(),
49
+ on: vi.fn((event, listener) => {
50
+ listeners.set(event, listener);
51
+ }),
52
+ },
53
+ };
54
+ const plugin = contentSyncPlugin();
55
+ configurePlugin(plugin, root);
56
+ if (typeof plugin.configureServer !== 'function') {
57
+ throw new Error('Expected configureServer hook');
58
+ }
59
+ plugin.configureServer.call(pluginContext, server);
60
+ listeners.get('change')?.(schemaPath);
61
+ expect(readFileSync(join(root, 'src/schemas/Post.ts'), 'utf8')).toContain('from "./Post.types";');
62
+ expect(readFileSync(join(root, 'src/schemas/Post.types.ts'), 'utf8')).toContain('export interface Post');
63
+ });
64
+ });
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "bundled": true,
3
3
  "bundler": "esbuild",
4
- "bundledAt": "2026-07-13T21:00:11.462Z",
5
- "cliVersion": "0.4.0",
4
+ "bundledAt": "2026-07-14T09:02:26.429Z",
5
+ "cliVersion": "0.4.1",
6
6
  "external": [
7
7
  "oxc-parser",
8
8
  "fsevents"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fimo",
3
- "version": "0.4.0",
3
+ "version": "0.4.1-staging.2",
4
4
  "description": "Fimo CLI - create, deploy, and manage Fimo projects",
5
5
  "bin": {
6
6
  "fimo": "dist/cli/index.js"
package/release.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "source": "npm",
3
- "apiUrl": "https://api.fimo.ai",
4
- "webUrl": "https://fimo.ai"
3
+ "apiUrl": "https://api.staging.fimo.team",
4
+ "webUrl": "https://staging.fimo.team"
5
5
  }
@@ -21,7 +21,7 @@
21
21
  "cmdk": "^1.1.1",
22
22
  "date-fns": "^4.1.0",
23
23
  "embla-carousel-react": "^8.6.0",
24
- "fimo": "0.4.0",
24
+ "fimo": "0.4.1-staging.2",
25
25
  "input-otp": "^1.4.2",
26
26
  "isbot": "^5",
27
27
  "lucide-react": "^0.577.0",