@intijs/cli 0.0.0-stage → 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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -2
  3. package/bin/inti-dev.ts +40 -0
  4. package/bin/inti.js +54 -0
  5. package/dist/commands/dev.d.ts +2 -0
  6. package/dist/commands/dev.d.ts.map +1 -0
  7. package/dist/commands/dev.js +12 -0
  8. package/dist/commands/generate.d.ts +25 -0
  9. package/dist/commands/generate.d.ts.map +1 -0
  10. package/dist/commands/generate.js +149 -0
  11. package/dist/commands/sync.d.ts +2 -0
  12. package/dist/commands/sync.d.ts.map +1 -0
  13. package/dist/commands/sync.js +114 -0
  14. package/dist/generator/ai-generator.d.ts +14 -0
  15. package/dist/generator/ai-generator.d.ts.map +1 -0
  16. package/dist/generator/ai-generator.js +55 -0
  17. package/dist/generator/component-generator.d.ts +42 -0
  18. package/dist/generator/component-generator.d.ts.map +1 -0
  19. package/dist/generator/component-generator.js +228 -0
  20. package/dist/generator/index.d.ts +5 -0
  21. package/dist/generator/index.d.ts.map +1 -0
  22. package/dist/generator/index.js +3 -0
  23. package/dist/generator/sdk-generator.d.ts +7 -0
  24. package/dist/generator/sdk-generator.d.ts.map +1 -0
  25. package/dist/generator/sdk-generator.js +114 -0
  26. package/dist/generator/types-generator.d.ts +16 -0
  27. package/dist/generator/types-generator.d.ts.map +1 -0
  28. package/dist/generator/types-generator.js +155 -0
  29. package/dist/index.d.ts +8 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +7 -0
  32. package/package.json +49 -4
  33. package/src/commands/dev.ts +14 -0
  34. package/src/commands/generate.ts +194 -0
  35. package/src/commands/sync.ts +134 -0
  36. package/src/generator/ai-generator.ts +62 -0
  37. package/src/generator/component-generator.ts +314 -0
  38. package/src/generator/index.ts +4 -0
  39. package/src/generator/types-generator.ts +167 -0
  40. package/src/index.ts +10 -0
@@ -0,0 +1,228 @@
1
+ /**
2
+ * @module component-generator
3
+ * Generates Astro component files from CMS schema introspection.
4
+ * Each collection in the schema produces a ready-to-use `.astro` component
5
+ * with typed props, semantic HTML, and Visual Bridge compatibility attributes.
6
+ */
7
+ // ============================================
8
+ // Title-like field heuristics
9
+ // ============================================
10
+ /** Field names that should be rendered as headings rather than paragraphs */
11
+ const TITLE_FIELD_PATTERNS = [
12
+ 'title', 'name', 'heading', 'headline', 'subject', 'label',
13
+ ];
14
+ /**
15
+ * Determine whether a field name looks like a "title" field.
16
+ * Used to decide between `<h2>` and `<p>` for plain string fields.
17
+ */
18
+ function isTitleField(fieldName) {
19
+ const lower = fieldName.toLowerCase();
20
+ return TITLE_FIELD_PATTERNS.some(p => lower === p || lower.endsWith(`_${p}`) || lower.endsWith(`${p}`));
21
+ }
22
+ // ============================================
23
+ // Kebab-case helper
24
+ // ============================================
25
+ /**
26
+ * Convert a PascalCase or camelCase string to kebab-case.
27
+ * e.g. `BlogPost` → `blog-post`
28
+ */
29
+ function toKebabCase(str) {
30
+ return str
31
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
32
+ .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
33
+ .toLowerCase();
34
+ }
35
+ // ============================================
36
+ // Component Content Generation
37
+ // ============================================
38
+ /**
39
+ * Generate the complete `.astro` file content for a single collection.
40
+ */
41
+ function generateComponentContent(collection, options) {
42
+ const { name, fields } = collection;
43
+ const kebab = toKebabCase(name);
44
+ const styled = options.style === 'styled';
45
+ // --- Frontmatter ---
46
+ const frontmatterLines = ['---'];
47
+ if (options.includeJsDoc) {
48
+ frontmatterLines.push('/**', ` * ${name} Block Component`, ` * Auto-generated by Inti CLI - Customize as needed`, ` * @see https://github.com/intijs/inti/blob/main/apps/docs/src/content/docs/registry/components.mdx`, ' */');
49
+ }
50
+ frontmatterLines.push(`import type { ${name} } from '../../lib/inti/inti.types';`);
51
+ frontmatterLines.push('');
52
+ if (options.includeProps) {
53
+ frontmatterLines.push('interface Props {');
54
+ if (options.includeJsDoc)
55
+ frontmatterLines.push(' /** Block data from CMS */');
56
+ frontmatterLines.push(` data: ${name};`);
57
+ if (options.includeJsDoc)
58
+ frontmatterLines.push(' /** Block ID for Visual Bridge */');
59
+ frontmatterLines.push(' blockId?: string;');
60
+ if (options.includeJsDoc)
61
+ frontmatterLines.push(' /** Document ID in CMS */');
62
+ frontmatterLines.push(' documentId?: string;');
63
+ frontmatterLines.push('}');
64
+ frontmatterLines.push('');
65
+ }
66
+ frontmatterLines.push('const { data, blockId, documentId } = Astro.props;');
67
+ frontmatterLines.push('---');
68
+ // --- Template ---
69
+ const templateLines = [];
70
+ const sectionClass = styled
71
+ ? `class="inti-block inti-block--${kebab} p-6"`
72
+ : `class="inti-block inti-block--${kebab}"`;
73
+ templateLines.push('');
74
+ templateLines.push(`<section`);
75
+ templateLines.push(` ${sectionClass}`);
76
+ templateLines.push(` data-inti-block="${name}"`);
77
+ templateLines.push(` data-inti-block-id={blockId}`);
78
+ templateLines.push(` data-inti-document-id={documentId}`);
79
+ templateLines.push(`>`);
80
+ // Render each field
81
+ for (const field of fields) {
82
+ const fieldLines = generateFieldMarkup(field, styled);
83
+ templateLines.push(...fieldLines);
84
+ }
85
+ templateLines.push(`</section>`);
86
+ return [...frontmatterLines, ...templateLines, ''].join('\n');
87
+ }
88
+ /**
89
+ * Generate the HTML template lines for a single schema field.
90
+ */
91
+ function generateFieldMarkup(field, styled) {
92
+ const { name: f, type, required } = field;
93
+ const lines = [];
94
+ const indent = ' ';
95
+ // Determine whether the field needs conditional rendering
96
+ const needsConditional = !required;
97
+ /**
98
+ * Wraps content lines in a conditional `{data.field && (...)}` block
99
+ * when the field is optional.
100
+ */
101
+ const wrap = (inner) => {
102
+ if (!needsConditional) {
103
+ return inner.map(l => `${indent}${l}`);
104
+ }
105
+ const out = [];
106
+ out.push('');
107
+ out.push(`${indent}{data.${f} && (`);
108
+ inner.forEach(l => out.push(`${indent}${indent}${l}`));
109
+ out.push(`${indent})}`);
110
+ return out;
111
+ };
112
+ switch (type) {
113
+ case 'string':
114
+ if (isTitleField(f)) {
115
+ lines.push(...wrap([
116
+ styled
117
+ ? `<h2 class="text-3xl font-bold mb-4">{data.${f}}</h2>`
118
+ : `<h2>{data.${f}}</h2>`,
119
+ ]));
120
+ }
121
+ else {
122
+ lines.push(...wrap([
123
+ styled
124
+ ? `<p class="mb-2">{data.${f}}</p>`
125
+ : `<p>{data.${f}}</p>`,
126
+ ]));
127
+ }
128
+ break;
129
+ case 'text':
130
+ case 'richtext':
131
+ lines.push(...wrap([
132
+ styled
133
+ ? `<div class="prose max-w-none" set:html={data.${f}} />`
134
+ : `<div set:html={data.${f}} />`,
135
+ ]));
136
+ break;
137
+ case 'media':
138
+ lines.push(...wrap([
139
+ styled ? `<figure class="mb-6">` : `<figure>`,
140
+ ` <img`,
141
+ ` src={data.${f}.url}`,
142
+ ` alt={data.${f}.alt || ''}`,
143
+ ` loading="lazy"`,
144
+ styled
145
+ ? ` class="w-full rounded-lg object-cover"`
146
+ : ` `,
147
+ ` />`,
148
+ `</figure>`,
149
+ ]));
150
+ break;
151
+ case 'number':
152
+ lines.push(...wrap([
153
+ styled
154
+ ? `<span class="font-mono">{data.${f}}</span>`
155
+ : `<span>{data.${f}}</span>`,
156
+ ]));
157
+ break;
158
+ case 'boolean':
159
+ lines.push('');
160
+ lines.push(`${indent}{data.${f} && (`);
161
+ lines.push(`${indent}${indent}${styled
162
+ ? `<span class="inline-block px-2 py-1 text-sm bg-green-100 text-green-800 rounded">${f}</span>`
163
+ : `<span>${f}</span>`}`);
164
+ lines.push(`${indent})}`);
165
+ break;
166
+ case 'date':
167
+ case 'datetime':
168
+ lines.push(...wrap([
169
+ `<time`,
170
+ ` datetime={new Date(data.${f}).toISOString()}`,
171
+ styled
172
+ ? ` class="text-sm text-gray-500 mb-4 block"`
173
+ : ` `,
174
+ `>`,
175
+ ` {new Date(data.${f}).toLocaleDateString()}`,
176
+ `</time>`,
177
+ ]));
178
+ break;
179
+ case 'relation':
180
+ lines.push('');
181
+ lines.push(`${indent}<!-- TODO: Render related "${f}" data (relation) -->`);
182
+ lines.push(`${indent}<slot name="${f}" />`);
183
+ break;
184
+ case 'json':
185
+ lines.push(...wrap([
186
+ `<pre>{JSON.stringify(data.${f}, null, 2)}</pre>`,
187
+ ]));
188
+ break;
189
+ case 'blocks':
190
+ case 'component':
191
+ lines.push('');
192
+ lines.push(`${indent}<!-- TODO: Render nested "${f}" blocks/components -->`);
193
+ lines.push(`${indent}<slot name="${f}" />`);
194
+ break;
195
+ default:
196
+ lines.push(...wrap([
197
+ `<span>{data.${f}}</span>`,
198
+ ]));
199
+ break;
200
+ }
201
+ return lines;
202
+ }
203
+ // ============================================
204
+ // Public API
205
+ // ============================================
206
+ /**
207
+ * Generate Astro component files for every collection in the schema.
208
+ *
209
+ * @param schema - The introspected CMS schema definition
210
+ * @param options - Generation options (output dir, style, overwrite, etc.)
211
+ * @returns An array of {@link GeneratedComponent} objects ready for writing to disk
212
+ */
213
+ export function generateAstroComponents(schema, options) {
214
+ const { outputDir, overwrite = false, style = 'styled', includeProps = true, includeJsDoc = true, } = options;
215
+ const resolvedOpts = { style, includeProps, includeJsDoc };
216
+ return schema.collections.map(collection => {
217
+ const filename = `${collection.name}.astro`;
218
+ const fullPath = `${outputDir}/${filename}`;
219
+ return {
220
+ name: collection.name,
221
+ filename,
222
+ path: fullPath,
223
+ content: generateComponentContent(collection, resolvedOpts),
224
+ // `isNew` is determined at write-time by the command; default true here
225
+ isNew: true,
226
+ };
227
+ });
228
+ }
@@ -0,0 +1,5 @@
1
+ export { generateTypeDefinitions } from './types-generator.js';
2
+ export { generateAIManifest, generateMockData } from './ai-generator.js';
3
+ export { generateAstroComponents } from './component-generator.js';
4
+ export type { ComponentGeneratorOptions, GeneratedComponent } from './component-generator.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,YAAY,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { generateTypeDefinitions } from './types-generator.js';
2
+ export { generateAIManifest, generateMockData } from './ai-generator.js';
3
+ export { generateAstroComponents } from './component-generator.js';
@@ -0,0 +1,7 @@
1
+ import type { SchemaDefinition } from '@inti/core/adapters';
2
+ /**
3
+ * Generate SDK functions from schema
4
+ * Creates typed functions for data access
5
+ */
6
+ export declare function generateSDK(schema: SchemaDefinition): string;
7
+ //# sourceMappingURL=sdk-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-generator.d.ts","sourceRoot":"","sources":["../../src/generator/sdk-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAiC,MAAM,qBAAqB,CAAC;AAE3F;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CA+D5D"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Generate SDK functions from schema
3
+ * Creates typed functions for data access
4
+ */
5
+ export function generateSDK(schema) {
6
+ const collectionFunctions = schema.collections.map(collection => generateCollectionFunctions(collection));
7
+ return `// AUTO-GENERATED BY INTI SYNC - DO NOT EDIT
8
+ // Source: ${schema.source}
9
+ // Version: ${schema.version}
10
+ // Generated at: ${new Date().toISOString()}
11
+
12
+ import type { ${schema.collections.map(c => c.name).join(', ')} } from './inti.types';
13
+
14
+ // ============================================
15
+ // SDK Configuration
16
+ // ============================================
17
+
18
+ interface SDKConfig {
19
+ endpoint: string;
20
+ token?: string;
21
+ }
22
+
23
+ let config: SDKConfig = {
24
+ endpoint: process.env.INTI_ENDPOINT || '',
25
+ token: process.env.INTI_TOKEN
26
+ };
27
+
28
+ export function configureSDK(userConfig: SDKConfig) {
29
+ config = { ...config, ...userConfig };
30
+ }
31
+
32
+ // ============================================
33
+ // Base Request Helper
34
+ // ============================================
35
+
36
+ async function request<T>(path: string, options?: RequestInit): Promise<T> {
37
+ const url = \`\${config.endpoint}\${path}\`;
38
+ const headers: Record<string, string> = {
39
+ 'Content-Type': 'application/json',
40
+ ...options?.headers as Record<string, string>
41
+ };
42
+
43
+ if (config.token) {
44
+ headers['Authorization'] = \`Bearer \${config.token}\`;
45
+ }
46
+
47
+ const response = await fetch(url, {
48
+ ...options,
49
+ headers
50
+ });
51
+
52
+ if (!response.ok) {
53
+ throw new Error(\`API Error: \${response.status} \${response.statusText}\`);
54
+ }
55
+
56
+ return response.json();
57
+ }
58
+
59
+ // ============================================
60
+ // Collection SDK Functions
61
+ // ============================================
62
+
63
+ ${collectionFunctions.join('\n\n')}
64
+ `;
65
+ }
66
+ function generateCollectionFunctions(collection) {
67
+ const name = collection.name;
68
+ const lowerName = name.toLowerCase();
69
+ const pluralName = pluralize(name);
70
+ const idField = collection.fields.find(f => f.name === 'id');
71
+ const slugField = collection.fields.find(f => f.name === 'slug');
72
+ let functions = [];
73
+ // getAll function
74
+ functions.push(`/**
75
+ * Get all ${pluralName}
76
+ */
77
+ export async function get${pluralName}(): Promise<${name}[]> {
78
+ return request<${name}[]>('/api/${lowerName}');
79
+ }`);
80
+ // getById function (if id field exists)
81
+ if (idField) {
82
+ functions.push(`/**
83
+ * Get ${name} by ID
84
+ */
85
+ export async function get${name}ById(id: string): Promise<${name} | null> {
86
+ return request<${name} | null>(\`/api/${lowerName}/\${id}\`);
87
+ }`);
88
+ }
89
+ // getBySlug function (if slug field exists)
90
+ if (slugField) {
91
+ functions.push(`/**
92
+ * Get ${name} by slug
93
+ */
94
+ export async function get${name}BySlug(slug: string): Promise<${name} | null> {
95
+ return request<${name} | null>(\`/api/${lowerName}/slug/\${slug}\`);
96
+ }`);
97
+ }
98
+ return functions.join('\n\n');
99
+ }
100
+ /**
101
+ * Simple pluralization (handles basic cases)
102
+ */
103
+ function pluralize(word) {
104
+ // Handle words ending in y -> ies
105
+ if (word.endsWith('y') && !word.endsWith('ay') && !word.endsWith('ey') && !word.endsWith('iy') && !word.endsWith('oy') && !word.endsWith('uy')) {
106
+ return word.slice(0, -1) + 'ies';
107
+ }
108
+ // Handle words ending in s, x, z, ch, sh -> es
109
+ if (word.endsWith('s') || word.endsWith('x') || word.endsWith('z') || word.endsWith('ch') || word.endsWith('sh')) {
110
+ return word + 'es';
111
+ }
112
+ // Default: add s
113
+ return word + 's';
114
+ }
@@ -0,0 +1,16 @@
1
+ import type { SchemaDefinition } from '@intijs/core/adapters';
2
+ /**
3
+ * Generates `inti.types.ts` from the CMS schema.
4
+ *
5
+ * The types describe what the adapters return, not the CMS API:
6
+ * content is always read with the adapter, and this only gives it shape.
7
+ * That is why dates are strings (they arrive as JSON) and media accept
8
+ * either an id or an object (each CMS returns one or the other).
9
+ *
10
+ * The generated file has to compile with nothing but `@intijs/core`
11
+ * installed: a test compiles it with `tsc --strict`. It used to
12
+ * reference a `MediaAsset` it neither declared nor imported, and a single
13
+ * image field was enough to break compilation.
14
+ */
15
+ export declare function generateTypeDefinitions(schema: SchemaDefinition): string;
16
+ //# sourceMappingURL=types-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-generator.d.ts","sourceRoot":"","sources":["../../src/generator/types-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAA+B,MAAM,uBAAuB,CAAC;AAE3F;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAkCxE"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Generates `inti.types.ts` from the CMS schema.
3
+ *
4
+ * The types describe what the adapters return, not the CMS API:
5
+ * content is always read with the adapter, and this only gives it shape.
6
+ * That is why dates are strings (they arrive as JSON) and media accept
7
+ * either an id or an object (each CMS returns one or the other).
8
+ *
9
+ * The generated file has to compile with nothing but `@intijs/core`
10
+ * installed: a test compiles it with `tsc --strict`. It used to
11
+ * reference a `MediaAsset` it neither declared nor imported, and a single
12
+ * image field was enough to break compilation.
13
+ */
14
+ export function generateTypeDefinitions(schema) {
15
+ const interfaces = schema.collections.map((collection) => generateCollectionInterface(collection));
16
+ const blockCollections = schema.collections.filter((collection) => collection.blockType);
17
+ return `// AUTO-GENERATED BY INTI SYNC - DO NOT EDIT
18
+ // Source: ${schema.source}
19
+ // Version: ${schema.version}
20
+ // Generated at: ${new Date().toISOString()}
21
+
22
+ import type { IntiBlock } from '@intijs/core/types';
23
+
24
+ /**
25
+ * A media item as the adapter returns it: an id or an object, depending on the
26
+ * CMS and the field's configuration. <IntiImage> accepts both.
27
+ */
28
+ export type IntiMedia =
29
+ | string
30
+ | { url?: string; alt?: string; width?: number; height?: number; [key: string]: unknown };
31
+
32
+ ${interfaces.join('\n\n')}
33
+
34
+ // ============================================
35
+ // Collection Names (for type-safe references)
36
+ // ============================================
37
+
38
+ export type CollectionName =
39
+ ${schema.collections.map((c) => ` | '${c.name}'`).join('\n') || " never"};
40
+ ${generateTypedBlocks(blockCollections)}
41
+ // ============================================
42
+ // Helper Types
43
+ // ============================================
44
+
45
+ export type WithId<T> = T & { id: string };
46
+ `;
47
+ }
48
+ /**
49
+ * Types for a page's blocks: a `type → data` map and a
50
+ * union discriminated by `type`. With it, checking `block.type` leaves
51
+ * `block.data` typed:
52
+ *
53
+ * const blocks = page.blocks as IntiTypedBlock[];
54
+ * if (blocks[0].type === 'hero') blocks[0].data.headline; // string
55
+ */
56
+ function generateTypedBlocks(collections) {
57
+ if (collections.length === 0) {
58
+ return `
59
+ // This CMS does not describe its block types in the schema, so a page's
60
+ // blocks cannot be typed.
61
+ export type IntiTypedBlock = IntiBlock;
62
+ `;
63
+ }
64
+ const entries = collections
65
+ .map((collection) => ` ${JSON.stringify(collection.blockType)}: ${collection.name};`)
66
+ .join('\n');
67
+ return `
68
+ // ============================================
69
+ // Typed blocks
70
+ // ============================================
71
+
72
+ /** Data for each block type, by its \`IntiBlock.type\` */
73
+ export interface IntiBlockDataMap {
74
+ ${entries}
75
+ }
76
+
77
+ /**
78
+ * A page block with its data typed according to its \`type\`.
79
+ *
80
+ * The adapter returns \`IntiBlock[]\`; this gives it shape without changing anything at
81
+ * runtime:
82
+ *
83
+ * \`\`\`ts
84
+ * const blocks = page.blocks as IntiTypedBlock[];
85
+ * for (const block of blocks) {
86
+ * if (block.type === ${JSON.stringify(collections[0].blockType)}) block.data; // typed
87
+ * }
88
+ * \`\`\`
89
+ */
90
+ export type IntiTypedBlock = {
91
+ [K in keyof IntiBlockDataMap]: Omit<IntiBlock, 'type' | 'data'> & {
92
+ type: K;
93
+ data: IntiBlockDataMap[K];
94
+ };
95
+ }[keyof IntiBlockDataMap];
96
+ `;
97
+ }
98
+ function generateCollectionInterface(collection) {
99
+ const fields = collection.fields.map((field) => {
100
+ const tsType = fieldTypeToTypescript(field.type);
101
+ const optional = field.required ? '' : '?';
102
+ const docs = [field.description, fieldTypeNote(field.type)].filter(Boolean).join(' — ');
103
+ const jsDoc = docs ? ` /** ${docs} */\n` : '';
104
+ return `${jsDoc} ${safeKey(field.name)}${optional}: ${tsType};`;
105
+ });
106
+ const jsDoc = collection.description ? `/**\n * ${collection.description}\n */\n` : '';
107
+ return `${jsDoc}export interface ${collection.name} {
108
+ ${fields.join('\n')}
109
+ }`;
110
+ }
111
+ /** A field name with hyphens or spaces needs quotes */
112
+ function safeKey(name) {
113
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? name : JSON.stringify(name);
114
+ }
115
+ function fieldTypeToTypescript(type) {
116
+ switch (type) {
117
+ case 'string':
118
+ case 'text':
119
+ case 'richtext':
120
+ return 'string';
121
+ case 'number':
122
+ return 'number';
123
+ case 'boolean':
124
+ return 'boolean';
125
+ // They arrive as JSON: they are ISO strings, not Date objects. Typing them as
126
+ // Date let `date.getTime()` compile, which fails at runtime.
127
+ case 'date':
128
+ case 'datetime':
129
+ return 'string';
130
+ case 'media':
131
+ return 'IntiMedia';
132
+ case 'relation':
133
+ return 'string';
134
+ case 'blocks':
135
+ return 'IntiBlock[]';
136
+ case 'json':
137
+ case 'component':
138
+ return 'Record<string, unknown>';
139
+ default:
140
+ return 'unknown';
141
+ }
142
+ }
143
+ function fieldTypeNote(type) {
144
+ switch (type) {
145
+ case 'date':
146
+ case 'datetime':
147
+ return 'ISO 8601';
148
+ case 'richtext':
149
+ return 'HTML';
150
+ case 'relation':
151
+ return 'id of the related entry';
152
+ default:
153
+ return undefined;
154
+ }
155
+ }
@@ -0,0 +1,8 @@
1
+ export { syncCommand } from './commands/sync.js';
2
+ export { devCommand } from './commands/dev.js';
3
+ export { generateCommand } from './commands/generate.js';
4
+ export type { GenerateCommandOptions } from './commands/generate.js';
5
+ export { generateTypeDefinitions } from './generator/index.js';
6
+ export { generateAstroComponents } from './generator/index.js';
7
+ export type { ComponentGeneratorOptions, GeneratedComponent } from './generator/index.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,YAAY,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // CLI exports
2
+ export { syncCommand } from './commands/sync.js';
3
+ export { devCommand } from './commands/dev.js';
4
+ export { generateCommand } from './commands/generate.js';
5
+ // Generator exports
6
+ export { generateTypeDefinitions } from './generator/index.js';
7
+ export { generateAstroComponents } from './generator/index.js';
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@intijs/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "author": "Victor Antinori Broce",
7
+ "homepage": "https://github.com/intijs/inti/tree/main/packages/cli#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/intijs/inti.git",
11
+ "directory": "packages/cli"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/intijs/inti/issues"
15
+ },
16
+ "description": "CLI for Inti.js — reads your CMS schema and generates TypeScript types for its blocks",
17
+ "bin": {
18
+ "inti": "./bin/inti.js"
19
+ },
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/index.js",
25
+ "types": "./dist/index.d.ts"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "bin",
31
+ "src"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "prepare": "node ../../scripts/prepare-package.mjs",
36
+ "dev": "tsc --watch",
37
+ "clean": "rm -rf dist",
38
+ "test": "bun test",
39
+ "prepublishOnly": "npm run build"
40
+ },
41
+ "dependencies": {
42
+ "@intijs/core": "^0.1.0"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^20.0.0",
46
+ "typescript": "^5.7.3"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ }
51
+ }
@@ -0,0 +1,14 @@
1
+ export async function devCommand(args: string[] = []) {
2
+ // Runs `astro dev` with the given arguments. It adds nothing of its own.
3
+ console.log('Running astro dev…\n');
4
+
5
+ const { spawn } = await import('child_process');
6
+ const astro = spawn('astro', ['dev', ...args], {
7
+ stdio: 'inherit',
8
+ shell: true
9
+ });
10
+
11
+ astro.on('close', (code) => {
12
+ process.exit(code || 0);
13
+ });
14
+ }