fimo 0.4.0-staging.2 → 0.4.1-staging.1
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.
- package/assets/skills/fimo/SKILL.md +1 -1
- package/assets/skills/fimo/references/ui.md +1 -1
- package/assets/skills/fimo-cli/references/content.md +1 -1
- package/assets/skills/fimo-cli/references/forms.md +1 -1
- package/dist/build/vite/plugins/content-sync.d.ts +5 -7
- package/dist/build/vite/plugins/content-sync.d.ts.map +1 -1
- package/dist/build/vite/plugins/content-sync.js +5 -14
- package/dist/build/vite/plugins/content-sync.test.d.ts +2 -0
- package/dist/build/vite/plugins/content-sync.test.d.ts.map +1 -0
- package/dist/build/vite/plugins/content-sync.test.js +64 -0
- package/dist/cli/bundle.json +1 -1
- package/package.json +1 -1
- package/templates/react-router/package.json +1 -1
|
@@ -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/` —
|
|
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/` →
|
|
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`
|
|
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
|
|
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
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Keeps generated schema + form clients in sync while the Vite dev server is
|
|
4
|
+
* running.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
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
|
|
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
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Keeps generated schema + form clients in sync while the Vite dev server is
|
|
6
|
+
* running.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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 @@
|
|
|
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
|
+
});
|
package/dist/cli/bundle.json
CHANGED
package/package.json
CHANGED