@nghitrum/dsforge 0.1.5-alpha.1 → 0.1.5-alpha.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.
- package/README.md +22 -29
- package/dist/chunk-A7VW6SII.js +436 -0
- package/dist/chunk-YUPXTQZ5.js +118 -0
- package/dist/{chunk-RI3XDGKU.js → chunk-ZZRPNO6Z.js} +12 -17
- package/dist/cli/index.js +292 -310
- package/dist/componentDefinitions-5LFCNFQY.js +8 -0
- package/dist/{emitter-ZNRPJ4D6.js → emitter-IC77G4QF.js} +1 -1
- package/dist/generateAiFolder-3OOFWBH7.js +70 -0
- package/dist/generateComponentJson-XBEUWCW6.js +16 -0
- package/dist/generateComponentMetadata-2L5VNERD.js +13 -0
- package/dist/generateRegistry-3MEZDJAJ.js +19 -0
- package/dist/{html-6SIG34W5.js → html-XGJ22SXB.js} +385 -123
- package/dist/index.d.ts +12 -0
- package/dist/index.js +150 -46
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// src/adapters/react/generateAiFolder.ts
|
|
2
|
+
function generateSystemPrompt(systemName, tokens, componentNames) {
|
|
3
|
+
const tokenLines = Object.entries(tokens).map(([cssVar, values]) => `${cssVar.padEnd(35)} ${values.light} (dark: ${values.dark})`).join("\n");
|
|
4
|
+
const pkgName = systemName.toLowerCase().replace(/\s+/g, "-");
|
|
5
|
+
return `# ${systemName} \u2014 AI Context
|
|
6
|
+
|
|
7
|
+
You are helping a developer build UI using the ${systemName} design system, generated by dsforge.
|
|
8
|
+
|
|
9
|
+
## Rules
|
|
10
|
+
- Never hardcode colours, spacing, or typography values
|
|
11
|
+
- Always use CSS custom properties from this design system
|
|
12
|
+
- Always import components from '${pkgName}'
|
|
13
|
+
- Never install or suggest third-party component libraries
|
|
14
|
+
|
|
15
|
+
## Tokens
|
|
16
|
+
${tokenLines}
|
|
17
|
+
|
|
18
|
+
## Available Components
|
|
19
|
+
${componentNames.join(", ")}
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
import { ${componentNames.slice(0, 3).join(", ")} } from '${pkgName}'
|
|
23
|
+
import '${pkgName}/tokens/base.css'
|
|
24
|
+
`;
|
|
25
|
+
}
|
|
26
|
+
function generateComponentsJson(systemName, components, metadatas) {
|
|
27
|
+
const metaMap = Object.fromEntries(metadatas.map((m) => [m.name, m]));
|
|
28
|
+
const pkgName = systemName.toLowerCase().replace(/\s+/g, "-");
|
|
29
|
+
const combined = components.map((c) => ({
|
|
30
|
+
name: c.name,
|
|
31
|
+
import: `import { ${c.name} } from '${pkgName}'`,
|
|
32
|
+
description: c.description,
|
|
33
|
+
props: c.props,
|
|
34
|
+
examples: c.examples.slice(0, 2),
|
|
35
|
+
tokens: Object.keys(c.cssVars.light),
|
|
36
|
+
aiGuidance: metaMap[c.name]?.aiGuidance ?? []
|
|
37
|
+
}));
|
|
38
|
+
return JSON.stringify({ system: systemName, components: combined }, null, 2);
|
|
39
|
+
}
|
|
40
|
+
function generateCursorContext(systemName) {
|
|
41
|
+
return `# Design System Context for Cursor
|
|
42
|
+
|
|
43
|
+
This project uses the ${systemName} design system. When generating any UI code:
|
|
44
|
+
|
|
45
|
+
1. Import components from '${systemName.toLowerCase().replace(/\s+/g, "-")}'
|
|
46
|
+
2. Use CSS variables from tokens/base.css for all visual values
|
|
47
|
+
3. Refer to ai/components.json for the full component API and usage rules
|
|
48
|
+
|
|
49
|
+
@file ../ai/system-prompt.md
|
|
50
|
+
@file ../ai/components.json
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
function generateCopilotInstructions(systemName) {
|
|
54
|
+
const pkgName = systemName.toLowerCase().replace(/\s+/g, "-");
|
|
55
|
+
return `# GitHub Copilot Instructions
|
|
56
|
+
|
|
57
|
+
This project uses the ${systemName} design system.
|
|
58
|
+
|
|
59
|
+
- Always import components from '${pkgName}'
|
|
60
|
+
- Never hardcode colour, spacing, or typography values \u2014 use CSS custom properties
|
|
61
|
+
- Refer to ai/components.json for component APIs, props, and usage guidance
|
|
62
|
+
- Refer to ai/system-prompt.md for design system rules
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
generateComponentsJson,
|
|
67
|
+
generateCopilotInstructions,
|
|
68
|
+
generateCursorContext,
|
|
69
|
+
generateSystemPrompt
|
|
70
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_JSON_DEFINITIONS
|
|
3
|
+
} from "./chunk-A7VW6SII.js";
|
|
4
|
+
|
|
5
|
+
// src/adapters/react/generateComponentJson.ts
|
|
6
|
+
function generateComponentJson(name, resolvedCssVars) {
|
|
7
|
+
const definition = COMPONENT_JSON_DEFINITIONS[name];
|
|
8
|
+
if (!definition) throw new Error(`No JSON definition found for component: ${name}`);
|
|
9
|
+
return {
|
|
10
|
+
...definition,
|
|
11
|
+
cssVars: resolvedCssVars
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
generateComponentJson
|
|
16
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_METADATA_DEFINITIONS
|
|
3
|
+
} from "./chunk-A7VW6SII.js";
|
|
4
|
+
|
|
5
|
+
// src/adapters/react/generateComponentMetadata.ts
|
|
6
|
+
function generateComponentMetadata(name) {
|
|
7
|
+
const definition = COMPONENT_METADATA_DEFINITIONS[name];
|
|
8
|
+
if (!definition) throw new Error(`No metadata definition found for component: ${name}`);
|
|
9
|
+
return definition;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
generateComponentMetadata
|
|
13
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/adapters/react/generateRegistry.ts
|
|
2
|
+
function generateRegistry(systemName, version, components) {
|
|
3
|
+
return {
|
|
4
|
+
$schema: "https://ui.shadcn.com/schema/registry.json",
|
|
5
|
+
name: systemName,
|
|
6
|
+
version,
|
|
7
|
+
description: `Design system generated by dsforge`,
|
|
8
|
+
items: components.map((c) => ({
|
|
9
|
+
name: c.name.toLowerCase(),
|
|
10
|
+
type: "registry:ui",
|
|
11
|
+
description: c.description,
|
|
12
|
+
files: [{ path: `components/${c.name}/${c.name}.tsx`, type: "registry:component" }],
|
|
13
|
+
cssVars: c.cssVars
|
|
14
|
+
}))
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
generateRegistry
|
|
19
|
+
};
|