@auto-engineer/design-system-importer 0.6.5 → 0.8.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +13 -14
- package/.turbo/turbo-type-check.log +4 -5
- package/CHANGELOG.md +11 -0
- package/README.md +7 -11
- package/dist/commands/import-design-system.d.ts +12 -25
- package/dist/commands/import-design-system.d.ts.map +1 -1
- package/dist/commands/import-design-system.js +38 -29
- package/dist/commands/import-design-system.js.map +1 -1
- package/dist/figma-api.d.ts +6 -0
- package/dist/figma-api.d.ts.map +1 -0
- package/dist/figma-api.js +38 -0
- package/dist/figma-api.js.map +1 -0
- package/dist/figma-importer.d.ts +8 -0
- package/dist/figma-importer.d.ts.map +1 -0
- package/dist/figma-importer.js +76 -0
- package/dist/figma-importer.js.map +1 -0
- package/dist/file-operations.d.ts +4 -0
- package/dist/file-operations.d.ts.map +1 -0
- package/dist/file-operations.js +102 -0
- package/dist/file-operations.js.map +1 -0
- package/dist/index.d.ts +15 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -282
- package/dist/index.js.map +1 -1
- package/dist/markdown-generator.d.ts +7 -0
- package/dist/markdown-generator.d.ts.map +1 -0
- package/dist/markdown-generator.js +44 -0
- package/dist/markdown-generator.js.map +1 -0
- package/package.json +7 -7
- package/src/commands/import-design-system.ts +40 -33
- package/src/figma-api.ts +46 -0
- package/src/figma-importer.ts +91 -0
- package/src/file-operations.ts +113 -0
- package/src/index.ts +9 -333
- package/src/markdown-generator.ts +56 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/.turbo/turbo-format.log +0 -15
- package/.turbo/turbo-lint.log +0 -5
- package/dist/cli-manifest.d.ts +0 -3
- package/dist/cli-manifest.d.ts.map +0 -1
- package/dist/cli-manifest.js +0 -35
- package/dist/cli-manifest.js.map +0 -1
- package/src/cli-manifest.ts +0 -37
package/dist/index.js
CHANGED
|
@@ -1,283 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
// import { AIProvider, generateTextWithAI } from '@auto-engineer/ai-gateway';
|
|
9
|
-
const debug = createDebug('design-system-importer');
|
|
10
|
-
const debugFiles = createDebug('design-system-importer:files');
|
|
11
|
-
const debugFigma = createDebug('design-system-importer:figma');
|
|
12
|
-
const debugMarkdown = createDebug('design-system-importer:markdown');
|
|
13
|
-
const debugComponents = createDebug('design-system-importer:components');
|
|
14
|
-
const debugCopy = createDebug('design-system-importer:copy');
|
|
15
|
-
dotenv.config();
|
|
16
|
-
debug('Design system importer initialized');
|
|
17
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
-
debugFigma('Initializing Figma API with personal access token');
|
|
19
|
-
const api = new Figma.Api({
|
|
20
|
-
personalAccessToken: process.env.FIGMA_PERSONAL_TOKEN,
|
|
21
|
-
});
|
|
22
|
-
debugFigma('Figma API initialized');
|
|
23
|
-
async function getAllTsxFiles(dir) {
|
|
24
|
-
debugFiles('Scanning directory for TSX files: %s', dir);
|
|
25
|
-
let results = [];
|
|
26
|
-
try {
|
|
27
|
-
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
28
|
-
debugFiles('Found %d entries in %s', entries.length, dir);
|
|
29
|
-
for (const entry of entries) {
|
|
30
|
-
const fullPath = path.join(dir, entry.name);
|
|
31
|
-
if (entry.isDirectory()) {
|
|
32
|
-
debugFiles('Entering subdirectory: %s', entry.name);
|
|
33
|
-
const subResults = await getAllTsxFiles(fullPath);
|
|
34
|
-
results = results.concat(subResults);
|
|
35
|
-
debugFiles('Found %d TSX files in %s', subResults.length, entry.name);
|
|
36
|
-
}
|
|
37
|
-
else if (entry.isFile() && entry.name.endsWith('.tsx')) {
|
|
38
|
-
debugFiles('Found TSX file: %s', entry.name);
|
|
39
|
-
results.push(fullPath);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
debugFiles('Error reading directory %s: %O', dir, error);
|
|
45
|
-
}
|
|
46
|
-
debugFiles('Total TSX files found in %s: %d', dir, results.length);
|
|
47
|
-
return results;
|
|
48
|
-
}
|
|
49
|
-
function getComponentNameFromFile(filePath) {
|
|
50
|
-
debugComponents('Extracting component name from: %s', filePath);
|
|
51
|
-
const file = path.basename(filePath, '.tsx');
|
|
52
|
-
// Capitalize first letter
|
|
53
|
-
const componentName = file.charAt(0).toUpperCase() + file.slice(1);
|
|
54
|
-
debugComponents('Component name: %s', componentName);
|
|
55
|
-
return componentName;
|
|
56
|
-
}
|
|
57
|
-
export async function generateDesignSystemMarkdown(inputDir, outputDir) {
|
|
58
|
-
debugMarkdown('Generating design system markdown from: %s to: %s', inputDir, outputDir);
|
|
59
|
-
const files = await getAllTsxFiles(inputDir);
|
|
60
|
-
if (files.length === 0) {
|
|
61
|
-
debugMarkdown('WARNING: No .tsx files found in input directory');
|
|
62
|
-
console.warn('No .tsx files found in input directory.');
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
debugMarkdown('Processing %d TSX files', files.length);
|
|
66
|
-
const componentNames = files.map(getComponentNameFromFile).sort();
|
|
67
|
-
debugMarkdown('Found %d unique components', componentNames.length);
|
|
68
|
-
let md = '# Design System\n\n## Components\n\n';
|
|
69
|
-
for (const name of componentNames) {
|
|
70
|
-
md += `- ${name}\n`;
|
|
71
|
-
debugMarkdown('Added component to markdown: %s', name);
|
|
72
|
-
}
|
|
73
|
-
debugMarkdown('Creating output directory: %s', outputDir);
|
|
74
|
-
await fs.mkdir(outputDir, { recursive: true });
|
|
75
|
-
const outPath = path.join(outputDir, 'design-system.md');
|
|
76
|
-
debugMarkdown('Writing markdown to: %s', outPath);
|
|
77
|
-
await fs.writeFile(outPath, md);
|
|
78
|
-
debugMarkdown('Markdown file written successfully, size: %d bytes', md.length);
|
|
79
|
-
}
|
|
80
|
-
export * from './commands/import-design-system.js';
|
|
81
|
-
export { CLI_MANIFEST } from './cli-manifest.js';
|
|
82
|
-
async function copyFile(inputDir, outputDir, file) {
|
|
83
|
-
const srcPath = path.join(inputDir, file);
|
|
84
|
-
const destPath = path.join(outputDir, file);
|
|
85
|
-
debugCopy('Attempting to copy file: %s from %s to %s', file, inputDir, outputDir);
|
|
86
|
-
// Check if source file exists
|
|
87
|
-
try {
|
|
88
|
-
await fs.access(srcPath);
|
|
89
|
-
debugCopy('Source file exists: %s', srcPath);
|
|
90
|
-
debugCopy('Creating output directory: %s', outputDir);
|
|
91
|
-
await fs.mkdir(outputDir, { recursive: true });
|
|
92
|
-
await fs.copyFile(srcPath, destPath);
|
|
93
|
-
debugCopy('Successfully copied %s to %s', file, destPath);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
// File doesn't exist, skip copying
|
|
97
|
-
debugCopy('File %s not found in %s, error: %O', file, inputDir, error);
|
|
98
|
-
console.log(`File ${file} not found in ${inputDir}, skipping...`, error);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
export async function copyDesignSystemDocsAndUserPreferences(inputDir, outputDir) {
|
|
102
|
-
debugCopy('Copying design system docs from %s to %s', inputDir, outputDir);
|
|
103
|
-
// Ensure output directory exists
|
|
104
|
-
debugCopy('Creating output directory: %s', outputDir);
|
|
105
|
-
await fs.mkdir(outputDir, { recursive: true });
|
|
106
|
-
// Try to copy existing files
|
|
107
|
-
debugCopy('Copying design-system.md...');
|
|
108
|
-
await copyFile(inputDir, outputDir, 'design-system.md');
|
|
109
|
-
debugCopy('Copying design-system-principles.md...');
|
|
110
|
-
await copyFile(inputDir, outputDir, 'design-system-principles.md');
|
|
111
|
-
// If design-system.md doesn't exist in output, try to generate it from TSX files
|
|
112
|
-
const designSystemPath = path.join(outputDir, 'design-system.md');
|
|
113
|
-
debugCopy('Checking if design-system.md exists at: %s', designSystemPath);
|
|
114
|
-
try {
|
|
115
|
-
await fs.access(designSystemPath);
|
|
116
|
-
debugCopy('design-system.md already exists');
|
|
117
|
-
}
|
|
118
|
-
catch {
|
|
119
|
-
debugCopy('design-system.md does not exist, attempting to generate from TSX files');
|
|
120
|
-
// File doesn't exist, try to generate from TSX files if inputDir exists
|
|
121
|
-
try {
|
|
122
|
-
await fs.access(inputDir);
|
|
123
|
-
debugCopy('Input directory is accessible: %s', inputDir);
|
|
124
|
-
const files = await getAllTsxFiles(inputDir);
|
|
125
|
-
if (files.length > 0) {
|
|
126
|
-
debugCopy('Found %d TSX files, generating design-system.md', files.length);
|
|
127
|
-
await generateDesignSystemMarkdown(inputDir, outputDir);
|
|
128
|
-
console.log(`Generated design-system.md from ${files.length} component files`);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
debugCopy('No TSX files found in %s', inputDir);
|
|
132
|
-
console.log(`No .tsx files found in ${inputDir} to generate design-system.md`);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
debugCopy('Input directory %s not accessible: %O', inputDir, error);
|
|
137
|
-
console.log(`Input directory ${inputDir} not accessible`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
debugCopy('Design system docs copy/generation complete');
|
|
141
|
-
}
|
|
142
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
143
|
-
async function getFigmaComponents() {
|
|
144
|
-
debugFigma('Fetching Figma components from file: %s', process.env.FIGMA_FILE_ID);
|
|
145
|
-
let components = [];
|
|
146
|
-
try {
|
|
147
|
-
debugFigma('Making API call to Figma...');
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
149
|
-
const response = await api.getFileComponentSets({ file_key: process.env.FIGMA_FILE_ID });
|
|
150
|
-
debugFigma('Figma API response received');
|
|
151
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
152
|
-
components = response.meta.component_sets.map((component) => {
|
|
153
|
-
debugFigma('Processing component: %s', component.name);
|
|
154
|
-
return {
|
|
155
|
-
name: component.name,
|
|
156
|
-
description: component.description,
|
|
157
|
-
thumbnail: component.thumbnail_url,
|
|
158
|
-
};
|
|
159
|
-
});
|
|
160
|
-
debugFigma('Successfully fetched %d components from Figma', components.length);
|
|
161
|
-
console.log('figma response: ', response);
|
|
162
|
-
}
|
|
163
|
-
catch (e) {
|
|
164
|
-
debugFigma('ERROR: Failed to fetch Figma components: %O', e);
|
|
165
|
-
console.error(e);
|
|
166
|
-
}
|
|
167
|
-
console.log(components.length);
|
|
168
|
-
return components;
|
|
169
|
-
}
|
|
170
|
-
export function generateMarkdownFromComponents(components) {
|
|
171
|
-
debugMarkdown('Generating markdown from %d components', components.length);
|
|
172
|
-
let md = '# Design System\n\n## Components\n\n';
|
|
173
|
-
if (components.length === 0) {
|
|
174
|
-
debugMarkdown('WARNING: No components found to generate markdown');
|
|
175
|
-
console.warn('No components found');
|
|
176
|
-
}
|
|
177
|
-
for (const [index, component] of components.entries()) {
|
|
178
|
-
debugMarkdown('Processing component %d/%d: %s', index + 1, components.length, component.name);
|
|
179
|
-
md += `### ${component.name}\nDescription: ${component.description}\nImage: \n\n`;
|
|
180
|
-
debugMarkdown('Added component %s with description length: %d', component.name, component.description.length);
|
|
181
|
-
}
|
|
182
|
-
debugMarkdown('Generated markdown document, total size: %d bytes', md.length);
|
|
183
|
-
return md;
|
|
184
|
-
}
|
|
185
|
-
export var ImportStrategy;
|
|
186
|
-
(function (ImportStrategy) {
|
|
187
|
-
ImportStrategy["WITH_COMPONENTS"] = "WITH_COMPONENTS";
|
|
188
|
-
ImportStrategy["WITH_COMPONENT_SETS"] = "WITH_COMPONENT_SETS";
|
|
189
|
-
ImportStrategy["WITH_ALL_FIGMA_INSTANCES"] = "WITH_ALL_FIGMA_INSTANCES";
|
|
190
|
-
})(ImportStrategy || (ImportStrategy = {}));
|
|
191
|
-
export async function importDesignSystemComponentsFromFigma(outputDir, strategy = ImportStrategy.WITH_COMPONENT_SETS, filterFn) {
|
|
192
|
-
debug('Starting Figma design system import');
|
|
193
|
-
debug('Output directory: %s', outputDir);
|
|
194
|
-
debug('Import strategy: %s', strategy);
|
|
195
|
-
debug('Filter function provided: %s', filterFn ? 'yes' : 'no');
|
|
196
|
-
const figmaComponentsBuilder = new FigmaComponentsBuilder();
|
|
197
|
-
debugComponents('FigmaComponentsBuilder instance created');
|
|
198
|
-
if (strategy === ImportStrategy.WITH_COMPONENTS) {
|
|
199
|
-
debugComponents('Using strategy: WITH_COMPONENTS');
|
|
200
|
-
await figmaComponentsBuilder.withFigmaComponents();
|
|
201
|
-
}
|
|
202
|
-
else if (strategy === ImportStrategy.WITH_COMPONENT_SETS) {
|
|
203
|
-
debugComponents('Using strategy: WITH_COMPONENT_SETS');
|
|
204
|
-
await figmaComponentsBuilder.withFigmaComponentSets();
|
|
205
|
-
}
|
|
206
|
-
else if (strategy === ImportStrategy.WITH_ALL_FIGMA_INSTANCES) {
|
|
207
|
-
debugComponents('Using strategy: WITH_ALL_FIGMA_INSTANCES');
|
|
208
|
-
await figmaComponentsBuilder.withAllFigmaInstanceNames();
|
|
209
|
-
}
|
|
210
|
-
debugComponents('Strategy applied successfully');
|
|
211
|
-
// figmaComponentsBuilder.withFilteredNamesForMui();
|
|
212
|
-
// figmaComponentsBuilder.withFilteredNamesForShadcn();
|
|
213
|
-
if (filterFn) {
|
|
214
|
-
debugComponents('Applying custom filter function');
|
|
215
|
-
figmaComponentsBuilder.withFilter(filterFn);
|
|
216
|
-
}
|
|
217
|
-
debugComponents('Building Figma components...');
|
|
218
|
-
const figmaComponents = figmaComponentsBuilder.build();
|
|
219
|
-
debugComponents('Built %d Figma components', figmaComponents.length);
|
|
220
|
-
console.log(figmaComponents.length);
|
|
221
|
-
debugMarkdown('Generating markdown from Figma components');
|
|
222
|
-
const generatedComponentsMDFile = generateMarkdownFromComponents(figmaComponents);
|
|
223
|
-
debugMarkdown('Markdown generated, size: %d bytes', generatedComponentsMDFile.length);
|
|
224
|
-
// const mdWithImageAnalysis = await generateTextWithAI(
|
|
225
|
-
// `
|
|
226
|
-
// Given this markdown file content:
|
|
227
|
-
// ${generatedComponentsMDFile}
|
|
228
|
-
//
|
|
229
|
-
// ------ INSTRUCTIONS -------
|
|
230
|
-
// !IMPORTANT: Only return with Markdown content, nothing else, I will be putting this straight in a .md file. Don't even start the file with \`\`\`markdown
|
|
231
|
-
// For every component Image: Analyze the given image and add to the given component.
|
|
232
|
-
// - add more content to the "Description:" part of the component.
|
|
233
|
-
// - add "Hierarchy:" part under the component, returning the parts a component is build of. like [Button, Input]
|
|
234
|
-
// `,
|
|
235
|
-
// AIProvider.OpenAI,
|
|
236
|
-
// { temperature: 0.2, maxTokens: 8000 },
|
|
237
|
-
// );
|
|
238
|
-
// await fs.mkdir(outputDir, { recursive: true });
|
|
239
|
-
// Parse the outputDir to determine if it's a file path or directory
|
|
240
|
-
const isFilePath = outputDir.endsWith('.md');
|
|
241
|
-
const actualOutputDir = isFilePath ? path.dirname(outputDir) : outputDir;
|
|
242
|
-
const fileName = isFilePath ? path.basename(outputDir) : 'design-system.md';
|
|
243
|
-
debugFiles('Creating output directory: %s', actualOutputDir);
|
|
244
|
-
await fs.mkdir(actualOutputDir, { recursive: true });
|
|
245
|
-
const outPath = path.join(actualOutputDir, fileName);
|
|
246
|
-
debugFiles('Writing markdown to: %s', outPath);
|
|
247
|
-
await fs.writeFile(outPath, generatedComponentsMDFile);
|
|
248
|
-
debugFiles('Design system markdown written successfully');
|
|
249
|
-
debug('Figma design system import complete');
|
|
250
|
-
}
|
|
251
|
-
// Check if this file is being run directly
|
|
252
|
-
if (process.argv[1] === __filename) {
|
|
253
|
-
const [, , outputDir] = process.argv;
|
|
254
|
-
if (!outputDir) {
|
|
255
|
-
console.error('Usage: tsx src/index.ts <outputDir>');
|
|
256
|
-
process.exit(1);
|
|
257
|
-
}
|
|
258
|
-
// generateDesignSystemMarkdown(inputDir, outputDir)
|
|
259
|
-
// .then(() => {
|
|
260
|
-
// console.log(`design-system.md generated in ${outputDir}`);
|
|
261
|
-
// })
|
|
262
|
-
// .catch((err) => {
|
|
263
|
-
// console.error('Error generating design-system.md:', err);
|
|
264
|
-
// process.exit(1);
|
|
265
|
-
// });
|
|
266
|
-
// copyDesignSystemDocsAndUserPreferences(inputDir, outputDir)
|
|
267
|
-
// .then(() => {
|
|
268
|
-
// console.log(`design-system.md copied to ${outputDir}`);
|
|
269
|
-
// })
|
|
270
|
-
// .catch((err) => {
|
|
271
|
-
// console.error('Error copying design-system.md:', err);
|
|
272
|
-
// process.exit(1);
|
|
273
|
-
// });
|
|
274
|
-
importDesignSystemComponentsFromFigma(outputDir)
|
|
275
|
-
.then(() => {
|
|
276
|
-
console.log(`design-system.md generated to ${outputDir}`);
|
|
277
|
-
})
|
|
278
|
-
.catch((err) => {
|
|
279
|
-
console.error('Error generating design-system.md:', err);
|
|
280
|
-
process.exit(1);
|
|
281
|
-
});
|
|
282
|
-
}
|
|
1
|
+
// Barrel exports
|
|
2
|
+
export { generateDesignSystemMarkdown } from './markdown-generator.js';
|
|
3
|
+
export { copyDesignSystemDocsAndUserPreferences } from './file-operations.js';
|
|
4
|
+
export { importDesignSystemComponentsFromFigma, ImportStrategy } from './figma-importer.js';
|
|
5
|
+
// Command exports
|
|
6
|
+
import importDesignSystemHandler from './commands/import-design-system.js';
|
|
7
|
+
export const COMMANDS = [importDesignSystemHandler];
|
|
283
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,WAAW,CAAC;AACnC,OAAO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C;IACrC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,oDAAoD;IACpD,kBAAkB;IAClB,iEAAiE;IACjE,OAAO;IACP,sBAAsB;IACtB,gEAAgE;IAChE,uBAAuB;IACvB,QAAQ;IACR,8DAA8D;IAC9D,kBAAkB;IAClB,8DAA8D;IAC9D,OAAO;IACP,sBAAsB;IACtB,6DAA6D;IAC7D,uBAAuB;IACvB,QAAQ;IACR,qCAAqC,CAAC,SAAS,CAAC;SAC7C,IAAI,CAAC,GAAG,EAAE;QACT,OAAO,CAAC,GAAG,CAAC,iCAAiC,SAAS,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,sCAAsC,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,qCAAqC,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG5F,kBAAkB;AAClB,OAAO,yBAAyB,MAAM,oCAAoC,CAAC;AAC3E,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,yBAAyB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function generateDesignSystemMarkdown(inputDir: string, outputDir: string): Promise<void>;
|
|
2
|
+
export declare function generateMarkdownFromComponents(components: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
thumbnail: string;
|
|
6
|
+
}[]): string;
|
|
7
|
+
//# sourceMappingURL=markdown-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-generator.d.ts","sourceRoot":"","sources":["../src/markdown-generator.ts"],"names":[],"mappings":"AAOA,wBAAsB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BrG;AAED,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAAE,GACrE,MAAM,CAiBR"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
import createDebug from 'debug';
|
|
4
|
+
import { getAllTsxFiles, getComponentNameFromFile } from './file-operations.js';
|
|
5
|
+
const debugMarkdown = createDebug('design-system-importer:markdown');
|
|
6
|
+
export async function generateDesignSystemMarkdown(inputDir, outputDir) {
|
|
7
|
+
debugMarkdown('Generating design system markdown from: %s to: %s', inputDir, outputDir);
|
|
8
|
+
const files = await getAllTsxFiles(inputDir);
|
|
9
|
+
if (files.length === 0) {
|
|
10
|
+
debugMarkdown('WARNING: No .tsx files found in input directory');
|
|
11
|
+
console.warn('No .tsx files found in input directory.');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
debugMarkdown('Processing %d TSX files', files.length);
|
|
15
|
+
const componentNames = files.map(getComponentNameFromFile).sort();
|
|
16
|
+
debugMarkdown('Found %d unique components', componentNames.length);
|
|
17
|
+
let md = '# Design System\n\n## Components\n\n';
|
|
18
|
+
for (const name of componentNames) {
|
|
19
|
+
md += `- ${name}\n`;
|
|
20
|
+
debugMarkdown('Added component to markdown: %s', name);
|
|
21
|
+
}
|
|
22
|
+
debugMarkdown('Creating output directory: %s', outputDir);
|
|
23
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
24
|
+
const outPath = path.join(outputDir, 'design-system.md');
|
|
25
|
+
debugMarkdown('Writing markdown to: %s', outPath);
|
|
26
|
+
await fs.writeFile(outPath, md);
|
|
27
|
+
debugMarkdown('Markdown file written successfully, size: %d bytes', md.length);
|
|
28
|
+
}
|
|
29
|
+
export function generateMarkdownFromComponents(components) {
|
|
30
|
+
debugMarkdown('Generating markdown from %d components', components.length);
|
|
31
|
+
let md = '# Design System\n\n## Components\n\n';
|
|
32
|
+
if (components.length === 0) {
|
|
33
|
+
debugMarkdown('WARNING: No components found to generate markdown');
|
|
34
|
+
console.warn('No components found');
|
|
35
|
+
}
|
|
36
|
+
for (const [index, component] of components.entries()) {
|
|
37
|
+
debugMarkdown('Processing component %d/%d: %s', index + 1, components.length, component.name);
|
|
38
|
+
md += `### ${component.name}\nDescription: ${component.description}\nImage: \n\n`;
|
|
39
|
+
debugMarkdown('Added component %s with description length: %d', component.name, component.description.length);
|
|
40
|
+
}
|
|
41
|
+
debugMarkdown('Generated markdown document, total size: %d bytes', md.length);
|
|
42
|
+
return md;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=markdown-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-generator.js","sourceRoot":"","sources":["../src/markdown-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,WAAW,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhF,MAAM,aAAa,GAAG,WAAW,CAAC,iCAAiC,CAAC,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,QAAgB,EAAE,SAAiB;IACpF,aAAa,CAAC,mDAAmD,EAAE,QAAQ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U,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,aAAa,CAAC,mDAAmD,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;QACtD,aAAa,CAAC,gCAAgC,EAAE,KAAK,GAAG,CAAC,EAAE,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9F,EAAE,IAAI,OAAO,SAAS,CAAC,IAAI,kBAAkB,SAAS,CAAC,WAAW,cAAc,SAAS,CAAC,IAAI,WAAW,SAAS,CAAC,SAAS,OAAO,CAAC;QACpI,aAAa,CAAC,gDAAgD,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAChH,CAAC;IAED,aAAa,CAAC,mDAAmD,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IAC9E,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auto-engineer/design-system-importer",
|
|
3
|
-
"version": "0.6.5",
|
|
4
3
|
"type": "module",
|
|
5
4
|
"main": "./dist/index.js",
|
|
6
5
|
"types": "./dist/index.d.ts",
|
|
@@ -14,24 +13,25 @@
|
|
|
14
13
|
"access": "public"
|
|
15
14
|
},
|
|
16
15
|
"dependencies": {
|
|
17
|
-
"@auto-engineer/message-bus": "^0.5.5",
|
|
18
16
|
"figma-api": "2.0.2-beta",
|
|
19
|
-
"tsx": "^3.12.7"
|
|
17
|
+
"tsx": "^3.12.7",
|
|
18
|
+
"@auto-engineer/message-bus": "0.8.1"
|
|
20
19
|
},
|
|
21
20
|
"devDependencies": {
|
|
22
|
-
"@auto-engineer/cli": "
|
|
21
|
+
"@auto-engineer/cli": "0.8.1"
|
|
23
22
|
},
|
|
23
|
+
"version": "0.8.1",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"start": "tsx src/index.ts",
|
|
26
26
|
"build": "tsc && tsx ../../scripts/fix-esm-imports.ts && cp -r src/utils/templates dist/utils/",
|
|
27
27
|
"dev": "tsc --watch",
|
|
28
|
-
"test": "vitest run",
|
|
28
|
+
"test": "vitest run --reporter=dot",
|
|
29
29
|
"test:coverage": "vitest run --coverage",
|
|
30
30
|
"lint": "eslint 'src/**/*.ts' --max-warnings 0 --config ../../eslint.config.ts",
|
|
31
31
|
"type-check": "tsc --noEmit",
|
|
32
|
-
"format": "prettier --write \"**/*.{js,ts,json,md,yml,yaml}\" --ignore-path ../../.prettierignore",
|
|
32
|
+
"format": "prettier --write \"**/*.{js,ts,json,md,yml,yaml}\" --ignore-path ../../.prettierignore --log-level warn",
|
|
33
33
|
"lint:fix": "eslint 'src/**/*.ts' --fix --config ../../eslint.config.ts",
|
|
34
|
-
"format:fix": "prettier --write \"**/*.{js,ts,json,md,yml,yaml}\" --ignore-path ../../.prettierignore",
|
|
34
|
+
"format:fix": "prettier --write \"**/*.{js,ts,json,md,yml,yaml}\" --ignore-path ../../.prettierignore --log-level warn",
|
|
35
35
|
"link:dev": "pnpm build && pnpm link --global",
|
|
36
36
|
"unlink:dev": "pnpm unlink --global"
|
|
37
37
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Command, type Event, defineCommandHandler } from '@auto-engineer/message-bus';
|
|
2
2
|
import { importDesignSystemComponentsFromFigma, ImportStrategy, type FilterFunctionType } from '../index';
|
|
3
3
|
import { FilterLoader } from '../utils/FilterLoader';
|
|
4
4
|
import createDebug from 'debug';
|
|
@@ -32,6 +32,44 @@ export type DesignSystemImportFailedEvent = Event<
|
|
|
32
32
|
}
|
|
33
33
|
>;
|
|
34
34
|
|
|
35
|
+
export const commandHandler = defineCommandHandler<ImportDesignSystemCommand>({
|
|
36
|
+
name: 'ImportDesignSystem',
|
|
37
|
+
alias: 'import:design-system',
|
|
38
|
+
description: 'Import Figma design system',
|
|
39
|
+
category: 'import',
|
|
40
|
+
fields: {
|
|
41
|
+
outputDir: {
|
|
42
|
+
description: 'Source directory for design system',
|
|
43
|
+
required: true,
|
|
44
|
+
},
|
|
45
|
+
strategy: {
|
|
46
|
+
description: 'Import mode (e.g., WITH_COMPONENT_SETS)',
|
|
47
|
+
required: false,
|
|
48
|
+
},
|
|
49
|
+
filterPath: {
|
|
50
|
+
description: 'Optional filter file',
|
|
51
|
+
required: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
examples: [
|
|
55
|
+
'$ auto import:design-system --output-dir=./.context --strategy=WITH_COMPONENT_SETS --filter-path=./shadcn-filter.ts',
|
|
56
|
+
],
|
|
57
|
+
handle: async (
|
|
58
|
+
command: ImportDesignSystemCommand,
|
|
59
|
+
): Promise<DesignSystemImportedEvent | DesignSystemImportFailedEvent> => {
|
|
60
|
+
debug('CommandHandler executing for ImportDesignSystem');
|
|
61
|
+
const result = await handleImportDesignSystemCommandInternal(command);
|
|
62
|
+
if (result.type === 'DesignSystemImported') {
|
|
63
|
+
debug('Command handler completed: success');
|
|
64
|
+
debugResult('Design system imported successfully to %s', result.data.outputDir);
|
|
65
|
+
} else {
|
|
66
|
+
debug('Command handler completed: failure - %s', result.data.error);
|
|
67
|
+
debugResult('Failed: %s', result.data.error);
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
35
73
|
// Handler
|
|
36
74
|
async function loadFilterFunction(filterPath?: string): Promise<FilterFunctionType | undefined> {
|
|
37
75
|
if (typeof filterPath !== 'string' || filterPath.trim().length === 0) {
|
|
@@ -124,36 +162,5 @@ async function handleImportDesignSystemCommandInternal(
|
|
|
124
162
|
}
|
|
125
163
|
}
|
|
126
164
|
|
|
127
|
-
const importDesignSystemCommandHandler: CommandHandler<ImportDesignSystemCommand> = {
|
|
128
|
-
name: 'ImportDesignSystem',
|
|
129
|
-
handle: async (
|
|
130
|
-
command: ImportDesignSystemCommand,
|
|
131
|
-
): Promise<DesignSystemImportedEvent | DesignSystemImportFailedEvent> => {
|
|
132
|
-
debug('CommandHandler executing for ImportDesignSystem');
|
|
133
|
-
const result = await handleImportDesignSystemCommandInternal(command);
|
|
134
|
-
if (result.type === 'DesignSystemImported') {
|
|
135
|
-
debug('Command handler completed: success');
|
|
136
|
-
debugResult('Design system imported successfully to %s', result.data.outputDir);
|
|
137
|
-
} else {
|
|
138
|
-
debug('Command handler completed: failure - %s', result.data.error);
|
|
139
|
-
debugResult('Failed: %s', result.data.error);
|
|
140
|
-
}
|
|
141
|
-
return result;
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
// CLI manifest entry for this command
|
|
146
|
-
export const importDesignSystemManifest = {
|
|
147
|
-
handler: () => Promise.resolve({ default: importDesignSystemCommandHandler }),
|
|
148
|
-
description: 'Import Figma design system',
|
|
149
|
-
usage: 'import:design-system <src> <mode> [filter]',
|
|
150
|
-
examples: ['$ auto import:design-system ./.context WITH_COMPONENT_SETS ./shadcn-filter.ts'],
|
|
151
|
-
args: [
|
|
152
|
-
{ name: 'src', description: 'Source directory for design system', required: true },
|
|
153
|
-
{ name: 'mode', description: 'Import mode (e.g., WITH_COMPONENT_SETS)', required: true },
|
|
154
|
-
{ name: 'filter', description: 'Optional filter file', required: false },
|
|
155
|
-
],
|
|
156
|
-
};
|
|
157
|
-
|
|
158
165
|
// Default export is the command handler
|
|
159
|
-
export default
|
|
166
|
+
export default commandHandler;
|
package/src/figma-api.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as dotenv from 'dotenv';
|
|
2
|
+
import * as Figma from 'figma-api';
|
|
3
|
+
import createDebug from 'debug';
|
|
4
|
+
|
|
5
|
+
dotenv.config();
|
|
6
|
+
|
|
7
|
+
const debugFigma = createDebug('design-system-importer:figma');
|
|
8
|
+
|
|
9
|
+
debugFigma('Initializing Figma API with personal access token');
|
|
10
|
+
const api = new Figma.Api({
|
|
11
|
+
personalAccessToken: process.env.FIGMA_PERSONAL_TOKEN as string,
|
|
12
|
+
});
|
|
13
|
+
debugFigma('Figma API initialized');
|
|
14
|
+
|
|
15
|
+
export async function getFigmaComponents(): Promise<{ name: string; description: string; thumbnail: string }[]> {
|
|
16
|
+
debugFigma('Fetching Figma components from file: %s', process.env.FIGMA_FILE_ID);
|
|
17
|
+
let components: { name: string; description: string; thumbnail: string }[] = [];
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
debugFigma('Making API call to Figma...');
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
22
|
+
const response = await api.getFileComponentSets({ file_key: process.env.FIGMA_FILE_ID });
|
|
23
|
+
debugFigma('Figma API response received');
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
26
|
+
components = response.meta.component_sets.map(
|
|
27
|
+
(component: { name: string; description: string; thumbnail_url: string }) => {
|
|
28
|
+
debugFigma('Processing component: %s', component.name);
|
|
29
|
+
return {
|
|
30
|
+
name: component.name,
|
|
31
|
+
description: component.description,
|
|
32
|
+
thumbnail: component.thumbnail_url,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
debugFigma('Successfully fetched %d components from Figma', components.length);
|
|
38
|
+
console.log('figma response: ', response);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
debugFigma('ERROR: Failed to fetch Figma components: %O', e);
|
|
41
|
+
console.error(e);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.log(components.length);
|
|
45
|
+
return components;
|
|
46
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
import createDebug from 'debug';
|
|
4
|
+
import { FigmaComponentsBuilder, type FilterFunctionType } from './FigmaComponentsBuilder.js';
|
|
5
|
+
import { generateMarkdownFromComponents } from './markdown-generator.js';
|
|
6
|
+
|
|
7
|
+
const debug = createDebug('design-system-importer');
|
|
8
|
+
const debugComponents = createDebug('design-system-importer:components');
|
|
9
|
+
const debugMarkdown = createDebug('design-system-importer:markdown');
|
|
10
|
+
const debugFiles = createDebug('design-system-importer:files');
|
|
11
|
+
|
|
12
|
+
export enum ImportStrategy {
|
|
13
|
+
WITH_COMPONENTS = 'WITH_COMPONENTS',
|
|
14
|
+
WITH_COMPONENT_SETS = 'WITH_COMPONENT_SETS',
|
|
15
|
+
WITH_ALL_FIGMA_INSTANCES = 'WITH_ALL_FIGMA_INSTANCES',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function importDesignSystemComponentsFromFigma(
|
|
19
|
+
outputDir: string,
|
|
20
|
+
strategy: ImportStrategy = ImportStrategy.WITH_COMPONENT_SETS,
|
|
21
|
+
filterFn?: FilterFunctionType,
|
|
22
|
+
): Promise<void> {
|
|
23
|
+
debug('Starting Figma design system import');
|
|
24
|
+
debug('Output directory: %s', outputDir);
|
|
25
|
+
debug('Import strategy: %s', strategy);
|
|
26
|
+
debug('Filter function provided: %s', filterFn ? 'yes' : 'no');
|
|
27
|
+
|
|
28
|
+
const figmaComponentsBuilder = new FigmaComponentsBuilder();
|
|
29
|
+
debugComponents('FigmaComponentsBuilder instance created');
|
|
30
|
+
|
|
31
|
+
if (strategy === ImportStrategy.WITH_COMPONENTS) {
|
|
32
|
+
debugComponents('Using strategy: WITH_COMPONENTS');
|
|
33
|
+
await figmaComponentsBuilder.withFigmaComponents();
|
|
34
|
+
} else if (strategy === ImportStrategy.WITH_COMPONENT_SETS) {
|
|
35
|
+
debugComponents('Using strategy: WITH_COMPONENT_SETS');
|
|
36
|
+
await figmaComponentsBuilder.withFigmaComponentSets();
|
|
37
|
+
} else if (strategy === ImportStrategy.WITH_ALL_FIGMA_INSTANCES) {
|
|
38
|
+
debugComponents('Using strategy: WITH_ALL_FIGMA_INSTANCES');
|
|
39
|
+
await figmaComponentsBuilder.withAllFigmaInstanceNames();
|
|
40
|
+
}
|
|
41
|
+
debugComponents('Strategy applied successfully');
|
|
42
|
+
|
|
43
|
+
// figmaComponentsBuilder.withFilteredNamesForMui();
|
|
44
|
+
// figmaComponentsBuilder.withFilteredNamesForShadcn();
|
|
45
|
+
|
|
46
|
+
if (filterFn) {
|
|
47
|
+
debugComponents('Applying custom filter function');
|
|
48
|
+
figmaComponentsBuilder.withFilter(filterFn);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
debugComponents('Building Figma components...');
|
|
52
|
+
const figmaComponents = figmaComponentsBuilder.build();
|
|
53
|
+
debugComponents('Built %d Figma components', figmaComponents.length);
|
|
54
|
+
|
|
55
|
+
console.log(figmaComponents.length);
|
|
56
|
+
|
|
57
|
+
debugMarkdown('Generating markdown from Figma components');
|
|
58
|
+
const generatedComponentsMDFile = generateMarkdownFromComponents(figmaComponents);
|
|
59
|
+
debugMarkdown('Markdown generated, size: %d bytes', generatedComponentsMDFile.length);
|
|
60
|
+
|
|
61
|
+
// const mdWithImageAnalysis = await generateTextWithAI(
|
|
62
|
+
// `
|
|
63
|
+
// Given this markdown file content:
|
|
64
|
+
// ${generatedComponentsMDFile}
|
|
65
|
+
//
|
|
66
|
+
// ------ INSTRUCTIONS -------
|
|
67
|
+
// !IMPORTANT: Only return with Markdown content, nothing else, I will be putting this straight in a .md file. Don't even start the file with \`\`\`markdown
|
|
68
|
+
// For every component Image: Analyze the given image and add to the given component.
|
|
69
|
+
// - add more content to the "Description:" part of the component.
|
|
70
|
+
// - add "Hierarchy:" part under the component, returning the parts a component is build of. like [Button, Input]
|
|
71
|
+
// `,
|
|
72
|
+
// undefined,
|
|
73
|
+
// { temperature: 0.2, maxTokens: 8000 },
|
|
74
|
+
// );
|
|
75
|
+
// await fs.mkdir(outputDir, { recursive: true });
|
|
76
|
+
|
|
77
|
+
// Parse the outputDir to determine if it's a file path or directory
|
|
78
|
+
const isFilePath = outputDir.endsWith('.md');
|
|
79
|
+
const actualOutputDir = isFilePath ? path.dirname(outputDir) : outputDir;
|
|
80
|
+
const fileName = isFilePath ? path.basename(outputDir) : 'design-system.md';
|
|
81
|
+
|
|
82
|
+
debugFiles('Creating output directory: %s', actualOutputDir);
|
|
83
|
+
await fs.mkdir(actualOutputDir, { recursive: true });
|
|
84
|
+
|
|
85
|
+
const outPath = path.join(actualOutputDir, fileName);
|
|
86
|
+
debugFiles('Writing markdown to: %s', outPath);
|
|
87
|
+
await fs.writeFile(outPath, generatedComponentsMDFile);
|
|
88
|
+
debugFiles('Design system markdown written successfully');
|
|
89
|
+
|
|
90
|
+
debug('Figma design system import complete');
|
|
91
|
+
}
|