@auto-engineer/design-system-importer 0.6.5 → 0.7.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.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +12 -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 +3 -3
- 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/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @auto-engineer/design-system-importer@0.
|
|
2
|
+
> @auto-engineer/design-system-importer@0.7.0 build /home/runner/work/auto-engineer/auto-engineer/packages/design-system-importer
|
|
3
3
|
> tsc && tsx ../../scripts/fix-esm-imports.ts && cp -r src/utils/templates dist/utils/
|
|
4
4
|
|
|
5
5
|
Fixed ESM imports in dist/
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[
|
|
12
|
-
|
|
13
|
-
[31m[39m
|
|
14
|
-
[?25h
|
|
1
|
+
|
|
2
|
+
> @auto-engineer/design-system-importer@0.7.0 test /home/runner/work/auto-engineer/auto-engineer/packages/design-system-importer
|
|
3
|
+
> vitest run
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[1m[46m RUN [49m[22m [36mv3.2.4 [39m[90m/home/runner/work/auto-engineer/auto-engineer/packages/design-system-importer[39m
|
|
7
|
+
|
|
8
|
+
No test files found, exiting with code 0
|
|
9
|
+
|
|
10
|
+
[2minclude: [22m[33m**/*.specs.{js,ts}[39m
|
|
11
|
+
[2mexclude: [22m[33m**/.tmp/**[2m, [22m**/node_modules/**[2m, [22m**/dist/**[39m
|
|
12
|
+
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
|
|
2
|
+
> @auto-engineer/design-system-importer@0.7.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/design-system-importer
|
|
3
|
+
> tsc --noEmit
|
|
4
|
+
|
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Design System Importer
|
|
2
2
|
|
|
3
3
|
Import your team's design system to build consistent, on-brand apps. Plugin for the Auto Engineer CLI that syncs shared styles, components, and tokens from design tools or code.
|
|
4
4
|
|
|
@@ -32,7 +32,7 @@ This plugin provides the following commands:
|
|
|
32
32
|
|
|
33
33
|
## Available Importers
|
|
34
34
|
|
|
35
|
-
- **Figma** – Import components directly from Figma. Use our [Auto plugin]() to export design tokens.
|
|
35
|
+
- **Figma** – Import components directly from Figma. Use our [Auto plugin](./) to export design tokens.
|
|
36
36
|
- **Code** – _(coming soon)_ Import tokens and components from an existing codebase.
|
|
37
37
|
- **NPM Package** – _(coming soon)_ Import a published design system as a dependency.
|
|
38
38
|
|
|
@@ -47,27 +47,23 @@ Import your design system directly from Figma and integrate it into your local p
|
|
|
47
47
|
|
|
48
48
|
### Setup
|
|
49
49
|
|
|
50
|
-
1. Generate a personal access token
|
|
50
|
+
1. Generate a personal access token\
|
|
51
51
|
Follow [these instructions](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens) from Figma.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Open your Figma file and copy the part of the URL after `/design/`.
|
|
55
|
-
|
|
52
|
+
2. Get your design system file ID\
|
|
53
|
+
Open your Figma file and copy the part of the URL after `/design/`
|
|
56
54
|
3. Configure environment variables
|
|
57
55
|
- `FIGMA_PERSONAL_TOKEN` – The token from your Figma account
|
|
58
56
|
- `FIGMA_FILE_ID` – The ID of the design file (found in the Figma URL after `/design/`)
|
|
59
|
-
|
|
60
|
-
4. Publish your components in Figma
|
|
57
|
+
4. Publish your components in Figma\
|
|
61
58
|
Right-click anywhere → Actions → Search for "Publish changes to library".
|
|
62
59
|
|
|
63
60
|
> (Optional) If you're using a public design system, you may need to move the file into one of your own Figma projects first.
|
|
64
61
|
|
|
65
62
|
5. Export tokens with the Auto plugin
|
|
66
|
-
- Install the [Auto plugin]()
|
|
63
|
+
- Install the [Auto plugin](./)
|
|
67
64
|
- Run it inside your Figma file
|
|
68
65
|
- Click "Export Tokens"
|
|
69
66
|
- Save the exported file inside the `.context` folder of your output directory
|
|
70
|
-
|
|
71
67
|
6. Run the importer
|
|
72
68
|
|
|
73
69
|
```bash
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Command, type Event } from '@auto-engineer/message-bus';
|
|
2
2
|
import { ImportStrategy } from '../index';
|
|
3
3
|
export type ImportDesignSystemCommand = Command<'ImportDesignSystem', {
|
|
4
4
|
outputDir: string;
|
|
@@ -12,29 +12,16 @@ export type DesignSystemImportFailedEvent = Event<'DesignSystemImportFailed', {
|
|
|
12
12
|
error: string;
|
|
13
13
|
outputDir: string;
|
|
14
14
|
}>;
|
|
15
|
-
declare const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
outputDir: string;
|
|
22
|
-
strategy?: keyof typeof ImportStrategy;
|
|
23
|
-
filterPath?: string;
|
|
24
|
-
}>;
|
|
25
|
-
timestamp?: Date;
|
|
26
|
-
requestId?: string;
|
|
27
|
-
correlationId?: string;
|
|
28
|
-
}>>;
|
|
15
|
+
export declare const commandHandler: import("@auto-engineer/message-bus").UnifiedCommandHandler<Readonly<{
|
|
16
|
+
type: "ImportDesignSystem";
|
|
17
|
+
data: Readonly<{
|
|
18
|
+
outputDir: string;
|
|
19
|
+
strategy?: keyof typeof ImportStrategy;
|
|
20
|
+
filterPath?: string;
|
|
29
21
|
}>;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
description: string;
|
|
36
|
-
required: boolean;
|
|
37
|
-
}[];
|
|
38
|
-
};
|
|
39
|
-
export default importDesignSystemCommandHandler;
|
|
22
|
+
timestamp?: Date;
|
|
23
|
+
requestId?: string;
|
|
24
|
+
correlationId?: string;
|
|
25
|
+
}>>;
|
|
26
|
+
export default commandHandler;
|
|
40
27
|
//# sourceMappingURL=import-design-system.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-design-system.d.ts","sourceRoot":"","sources":["../../src/commands/import-design-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"import-design-system.d.ts","sourceRoot":"","sources":["../../src/commands/import-design-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAwB,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAyC,cAAc,EAA2B,MAAM,UAAU,CAAC;AAS1G,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAC7C,oBAAoB,EACpB;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,OAAO,cAAc,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CACF,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAC3C,sBAAsB,EACtB;IACE,SAAS,EAAE,MAAM,CAAC;CACnB,CACF,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,KAAK,CAC/C,0BAA0B,EAC1B;IACE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CACF,CAAC;AAEF,eAAO,MAAM,cAAc;;;mBArBZ,MAAM;mBACN,MAAM,OAAO,cAAc;qBACzB,MAAM;;;;;GAuDrB,CAAC;AA+FH,eAAe,cAAc,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineCommandHandler } from '@auto-engineer/message-bus';
|
|
1
2
|
import { importDesignSystemComponentsFromFigma, ImportStrategy } from '../index.js';
|
|
2
3
|
import { FilterLoader } from '../utils/FilterLoader.js';
|
|
3
4
|
import createDebug from 'debug';
|
|
@@ -5,6 +6,42 @@ const debug = createDebug('design-system-importer:command');
|
|
|
5
6
|
const debugFilter = createDebug('design-system-importer:command:filter');
|
|
6
7
|
const debugHandler = createDebug('design-system-importer:command:handler');
|
|
7
8
|
const debugResult = createDebug('design-system-importer:command:result');
|
|
9
|
+
export const commandHandler = defineCommandHandler({
|
|
10
|
+
name: 'ImportDesignSystem',
|
|
11
|
+
alias: 'import:design-system',
|
|
12
|
+
description: 'Import Figma design system',
|
|
13
|
+
category: 'import',
|
|
14
|
+
fields: {
|
|
15
|
+
outputDir: {
|
|
16
|
+
description: 'Source directory for design system',
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
strategy: {
|
|
20
|
+
description: 'Import mode (e.g., WITH_COMPONENT_SETS)',
|
|
21
|
+
required: false,
|
|
22
|
+
},
|
|
23
|
+
filterPath: {
|
|
24
|
+
description: 'Optional filter file',
|
|
25
|
+
required: false,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
examples: [
|
|
29
|
+
'$ auto import:design-system --output-dir=./.context --strategy=WITH_COMPONENT_SETS --filter-path=./shadcn-filter.ts',
|
|
30
|
+
],
|
|
31
|
+
handle: async (command) => {
|
|
32
|
+
debug('CommandHandler executing for ImportDesignSystem');
|
|
33
|
+
const result = await handleImportDesignSystemCommandInternal(command);
|
|
34
|
+
if (result.type === 'DesignSystemImported') {
|
|
35
|
+
debug('Command handler completed: success');
|
|
36
|
+
debugResult('Design system imported successfully to %s', result.data.outputDir);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
debug('Command handler completed: failure - %s', result.data.error);
|
|
40
|
+
debugResult('Failed: %s', result.data.error);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
8
45
|
// Handler
|
|
9
46
|
async function loadFilterFunction(filterPath) {
|
|
10
47
|
if (typeof filterPath !== 'string' || filterPath.trim().length === 0) {
|
|
@@ -83,34 +120,6 @@ async function handleImportDesignSystemCommandInternal(command) {
|
|
|
83
120
|
return createFailureEvent(command, error, outputDir);
|
|
84
121
|
}
|
|
85
122
|
}
|
|
86
|
-
const importDesignSystemCommandHandler = {
|
|
87
|
-
name: 'ImportDesignSystem',
|
|
88
|
-
handle: async (command) => {
|
|
89
|
-
debug('CommandHandler executing for ImportDesignSystem');
|
|
90
|
-
const result = await handleImportDesignSystemCommandInternal(command);
|
|
91
|
-
if (result.type === 'DesignSystemImported') {
|
|
92
|
-
debug('Command handler completed: success');
|
|
93
|
-
debugResult('Design system imported successfully to %s', result.data.outputDir);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
debug('Command handler completed: failure - %s', result.data.error);
|
|
97
|
-
debugResult('Failed: %s', result.data.error);
|
|
98
|
-
}
|
|
99
|
-
return result;
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
// CLI manifest entry for this command
|
|
103
|
-
export const importDesignSystemManifest = {
|
|
104
|
-
handler: () => Promise.resolve({ default: importDesignSystemCommandHandler }),
|
|
105
|
-
description: 'Import Figma design system',
|
|
106
|
-
usage: 'import:design-system <src> <mode> [filter]',
|
|
107
|
-
examples: ['$ auto import:design-system ./.context WITH_COMPONENT_SETS ./shadcn-filter.ts'],
|
|
108
|
-
args: [
|
|
109
|
-
{ name: 'src', description: 'Source directory for design system', required: true },
|
|
110
|
-
{ name: 'mode', description: 'Import mode (e.g., WITH_COMPONENT_SETS)', required: true },
|
|
111
|
-
{ name: 'filter', description: 'Optional filter file', required: false },
|
|
112
|
-
],
|
|
113
|
-
};
|
|
114
123
|
// Default export is the command handler
|
|
115
|
-
export default
|
|
124
|
+
export default commandHandler;
|
|
116
125
|
//# sourceMappingURL=import-design-system.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-design-system.js","sourceRoot":"","sources":["../../src/commands/import-design-system.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"import-design-system.js","sourceRoot":"","sources":["../../src/commands/import-design-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,qCAAqC,EAAE,cAAc,EAA2B,MAAM,UAAU,CAAC;AAC1G,OAAO,EAAE,Y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,CAAC,sBAAsB,EAAE,OAAO,CAAC,aAAa,IAAI,MAAM,CAAC,CAAC;IAE/D,IAAI,CAAC;QACH,MAAM,gBAAgB,GAAG,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,mBAAmB,CAAC;QAClG,YAAY,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;QAExD,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAEtD,YAAY,CAAC,kDAAkD,CAAC,CAAC;QACjE,MAAM,qCAAqC,CAAC,SAAS,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QACnF,YAAY,CAAC,+BAA+B,CAAC,CAAC;QAC9C,YAAY,CAAC,qCAAqC,EAAE,SAAS,CAAC,CAAC;QAE/D,OAAO,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;AACH,CAAC;AAED,wCAAwC;AACxC,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figma-api.d.ts","sourceRoot":"","sources":["../src/figma-api.ts"],"names":[],"mappings":"AAcA,wBAAsB,kBAAkB,IAAI,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CA+B9G"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as dotenv from 'dotenv';
|
|
2
|
+
import * as Figma from 'figma-api';
|
|
3
|
+
import createDebug from 'debug';
|
|
4
|
+
dotenv.config();
|
|
5
|
+
const debugFigma = createDebug('design-system-importer:figma');
|
|
6
|
+
debugFigma('Initializing Figma API with personal access token');
|
|
7
|
+
const api = new Figma.Api({
|
|
8
|
+
personalAccessToken: process.env.FIGMA_PERSONAL_TOKEN,
|
|
9
|
+
});
|
|
10
|
+
debugFigma('Figma API initialized');
|
|
11
|
+
export async function getFigmaComponents() {
|
|
12
|
+
debugFigma('Fetching Figma components from file: %s', process.env.FIGMA_FILE_ID);
|
|
13
|
+
let components = [];
|
|
14
|
+
try {
|
|
15
|
+
debugFigma('Making API call to Figma...');
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
17
|
+
const response = await api.getFileComponentSets({ file_key: process.env.FIGMA_FILE_ID });
|
|
18
|
+
debugFigma('Figma API response received');
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
20
|
+
components = response.meta.component_sets.map((component) => {
|
|
21
|
+
debugFigma('Processing component: %s', component.name);
|
|
22
|
+
return {
|
|
23
|
+
name: component.name,
|
|
24
|
+
description: component.description,
|
|
25
|
+
thumbnail: component.thumbnail_url,
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
debugFigma('Successfully fetched %d components from Figma', components.length);
|
|
29
|
+
console.log('figma response: ', response);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
debugFigma('ERROR: Failed to fetch Figma components: %O', e);
|
|
33
|
+
console.error(e);
|
|
34
|
+
}
|
|
35
|
+
console.log(components.length);
|
|
36
|
+
return components;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=figma-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figma-api.js","sourceRoot":"","sources":["../src/figma-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,WAAW,CAAC;AACnC,OAAO,WAAW,MAAM,OAAO,CAAC;AAEhC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEh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,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FilterFunctionType } from './FigmaComponentsBuilder.js';
|
|
2
|
+
export declare enum ImportStrategy {
|
|
3
|
+
WITH_COMPONENTS = "WITH_COMPONENTS",
|
|
4
|
+
WITH_COMPONENT_SETS = "WITH_COMPONENT_SETS",
|
|
5
|
+
WITH_ALL_FIGMA_INSTANCES = "WITH_ALL_FIGMA_INSTANCES"
|
|
6
|
+
}
|
|
7
|
+
export declare function importDesignSystemComponentsFromFigma(outputDir: string, strategy?: ImportStrategy, filterFn?: FilterFunctionType): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=figma-importer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figma-importer.d.ts","sourceRoot":"","sources":["../src/figma-importer.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAQ9F,oBAAY,cAAc;IACxB,eAAe,oBAAoB;IACnC,mBAAmB,wBAAwB;IAC3C,wBAAwB,6BAA6B;CACtD;AAED,wBAAsB,qCAAqC,CACzD,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,cAAmD,EAC7D,QAAQ,CAAC,EAAE,kBAAkB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAqEf"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
import createDebug from 'debug';
|
|
4
|
+
import { FigmaComponentsBuilder } from './FigmaComponentsBuilder.js';
|
|
5
|
+
import { generateMarkdownFromComponents } from './markdown-generator.js';
|
|
6
|
+
const debug = createDebug('design-system-importer');
|
|
7
|
+
const debugComponents = createDebug('design-system-importer:components');
|
|
8
|
+
const debugMarkdown = createDebug('design-system-importer:markdown');
|
|
9
|
+
const debugFiles = createDebug('design-system-importer:files');
|
|
10
|
+
export var ImportStrategy;
|
|
11
|
+
(function (ImportStrategy) {
|
|
12
|
+
ImportStrategy["WITH_COMPONENTS"] = "WITH_COMPONENTS";
|
|
13
|
+
ImportStrategy["WITH_COMPONENT_SETS"] = "WITH_COMPONENT_SETS";
|
|
14
|
+
ImportStrategy["WITH_ALL_FIGMA_INSTANCES"] = "WITH_ALL_FIGMA_INSTANCES";
|
|
15
|
+
})(ImportStrategy || (ImportStrategy = {}));
|
|
16
|
+
export async function importDesignSystemComponentsFromFigma(outputDir, strategy = ImportStrategy.WITH_COMPONENT_SETS, filterFn) {
|
|
17
|
+
debug('Starting Figma design system import');
|
|
18
|
+
debug('Output directory: %s', outputDir);
|
|
19
|
+
debug('Import strategy: %s', strategy);
|
|
20
|
+
debug('Filter function provided: %s', filterFn ? 'yes' : 'no');
|
|
21
|
+
const figmaComponentsBuilder = new FigmaComponentsBuilder();
|
|
22
|
+
debugComponents('FigmaComponentsBuilder instance created');
|
|
23
|
+
if (strategy === ImportStrategy.WITH_COMPONENTS) {
|
|
24
|
+
debugComponents('Using strategy: WITH_COMPONENTS');
|
|
25
|
+
await figmaComponentsBuilder.withFigmaComponents();
|
|
26
|
+
}
|
|
27
|
+
else if (strategy === ImportStrategy.WITH_COMPONENT_SETS) {
|
|
28
|
+
debugComponents('Using strategy: WITH_COMPONENT_SETS');
|
|
29
|
+
await figmaComponentsBuilder.withFigmaComponentSets();
|
|
30
|
+
}
|
|
31
|
+
else if (strategy === ImportStrategy.WITH_ALL_FIGMA_INSTANCES) {
|
|
32
|
+
debugComponents('Using strategy: WITH_ALL_FIGMA_INSTANCES');
|
|
33
|
+
await figmaComponentsBuilder.withAllFigmaInstanceNames();
|
|
34
|
+
}
|
|
35
|
+
debugComponents('Strategy applied successfully');
|
|
36
|
+
// figmaComponentsBuilder.withFilteredNamesForMui();
|
|
37
|
+
// figmaComponentsBuilder.withFilteredNamesForShadcn();
|
|
38
|
+
if (filterFn) {
|
|
39
|
+
debugComponents('Applying custom filter function');
|
|
40
|
+
figmaComponentsBuilder.withFilter(filterFn);
|
|
41
|
+
}
|
|
42
|
+
debugComponents('Building Figma components...');
|
|
43
|
+
const figmaComponents = figmaComponentsBuilder.build();
|
|
44
|
+
debugComponents('Built %d Figma components', figmaComponents.length);
|
|
45
|
+
console.log(figmaComponents.length);
|
|
46
|
+
debugMarkdown('Generating markdown from Figma components');
|
|
47
|
+
const generatedComponentsMDFile = generateMarkdownFromComponents(figmaComponents);
|
|
48
|
+
debugMarkdown('Markdown generated, size: %d bytes', generatedComponentsMDFile.length);
|
|
49
|
+
// const mdWithImageAnalysis = await generateTextWithAI(
|
|
50
|
+
// `
|
|
51
|
+
// Given this markdown file content:
|
|
52
|
+
// ${generatedComponentsMDFile}
|
|
53
|
+
//
|
|
54
|
+
// ------ INSTRUCTIONS -------
|
|
55
|
+
// !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
|
|
56
|
+
// For every component Image: Analyze the given image and add to the given component.
|
|
57
|
+
// - add more content to the "Description:" part of the component.
|
|
58
|
+
// - add "Hierarchy:" part under the component, returning the parts a component is build of. like [Button, Input]
|
|
59
|
+
// `,
|
|
60
|
+
// AIProvider.OpenAI,
|
|
61
|
+
// { temperature: 0.2, maxTokens: 8000 },
|
|
62
|
+
// );
|
|
63
|
+
// await fs.mkdir(outputDir, { recursive: true });
|
|
64
|
+
// Parse the outputDir to determine if it's a file path or directory
|
|
65
|
+
const isFilePath = outputDir.endsWith('.md');
|
|
66
|
+
const actualOutputDir = isFilePath ? path.dirname(outputDir) : outputDir;
|
|
67
|
+
const fileName = isFilePath ? path.basename(outputDir) : 'design-system.md';
|
|
68
|
+
debugFiles('Creating output directory: %s', actualOutputDir);
|
|
69
|
+
await fs.mkdir(actualOutputDir, { recursive: true });
|
|
70
|
+
const outPath = path.join(actualOutputDir, fileName);
|
|
71
|
+
debugFiles('Writing markdown to: %s', outPath);
|
|
72
|
+
await fs.writeFile(outPath, generatedComponentsMDFile);
|
|
73
|
+
debugFiles('Design system markdown written successfully');
|
|
74
|
+
debug('Figma design system import complete');
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=figma-importer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figma-importer.js","sourceRoot":"","sources":["../src/figma-importer.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,sBAAsB,EAA2B,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAEzE,MAAM,KAAK,GAAG,WAAW,CAAC,wBAAwB,CAAC,CAAC;AACpD,MAAM,eAAe,GAAG,WAAW,CAAC,mCAAmC,CAAC,CAAC;AACzE,MAAM,aAAa,GAAG,WAAW,CAAC,iCAAiC,CAAC,CAAC;AACrE,MAAM,UAAU,GAAG,WAAW,CAAC,8BAA8B,CAAC,CAAC;AAE/D,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,qDAAmC,CAAA;IACnC,6DAA2C,CAAA;IAC3C,uEAAqD,CAAA;AACvD,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAED,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,SAAiB,EACjB,WAA2B,cAAc,CAAC,mBAAmB,EAC7D,QAA6B;IAE7B,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC7C,KAAK,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;IACzC,KAAK,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;IACvC,KAAK,CAAC,8BAA8B,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAA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,8BAA8B;IAC9B,4JAA4J;IAC5J,qFAAqF;IACrF,kEAAkE;IAClE,iHAAiH;IACjH,KAAK;IACL,uBAAuB;IACvB,2CAA2C;IAC3C,KAAK;IACL,kDAAkD;IAElD,oEAAoE;IACpE,MAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACzE,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC;IAE5E,UAAU,CAAC,+BAA+B,EAAE,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAErD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;IACrD,UAAU,CAAC,yBAAyB,EAAE,OAAO,CAAC,CAAC;IAC/C,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;IACvD,UAAU,CAAC,6CAA6C,CAAC,CAAC;IAE1D,KAAK,CAAC,qCAAqC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function getAllTsxFiles(dir: string): Promise<string[]>;
|
|
2
|
+
export declare function getComponentNameFromFile(filePath: string): string;
|
|
3
|
+
export declare function copyDesignSystemDocsAndUserPreferences(inputDir: string, outputDir: string): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=file-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-operations.d.ts","sourceRoot":"","sources":["../src/file-operations.ts"],"names":[],"mappings":"AAQA,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA0BnE;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOjE;AAwBD,wBAAsB,sCAAsC,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA6C/G"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
import createDebug from 'debug';
|
|
4
|
+
const debugFiles = createDebug('design-system-importer:files');
|
|
5
|
+
const debugComponents = createDebug('design-system-importer:components');
|
|
6
|
+
const debugCopy = createDebug('design-system-importer:copy');
|
|
7
|
+
export async function getAllTsxFiles(dir) {
|
|
8
|
+
debugFiles('Scanning directory for TSX files: %s', dir);
|
|
9
|
+
let results = [];
|
|
10
|
+
try {
|
|
11
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
12
|
+
debugFiles('Found %d entries in %s', entries.length, dir);
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
const fullPath = path.join(dir, entry.name);
|
|
15
|
+
if (entry.isDirectory()) {
|
|
16
|
+
debugFiles('Entering subdirectory: %s', entry.name);
|
|
17
|
+
const subResults = await getAllTsxFiles(fullPath);
|
|
18
|
+
results = results.concat(subResults);
|
|
19
|
+
debugFiles('Found %d TSX files in %s', subResults.length, entry.name);
|
|
20
|
+
}
|
|
21
|
+
else if (entry.isFile() && entry.name.endsWith('.tsx')) {
|
|
22
|
+
debugFiles('Found TSX file: %s', entry.name);
|
|
23
|
+
results.push(fullPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
debugFiles('Error reading directory %s: %O', dir, error);
|
|
29
|
+
}
|
|
30
|
+
debugFiles('Total TSX files found in %s: %d', dir, results.length);
|
|
31
|
+
return results;
|
|
32
|
+
}
|
|
33
|
+
export function getComponentNameFromFile(filePath) {
|
|
34
|
+
debugComponents('Extracting component name from: %s', filePath);
|
|
35
|
+
const file = path.basename(filePath, '.tsx');
|
|
36
|
+
// Capitalize first letter
|
|
37
|
+
const componentName = file.charAt(0).toUpperCase() + file.slice(1);
|
|
38
|
+
debugComponents('Component name: %s', componentName);
|
|
39
|
+
return componentName;
|
|
40
|
+
}
|
|
41
|
+
async function copyFile(inputDir, outputDir, file) {
|
|
42
|
+
const srcPath = path.join(inputDir, file);
|
|
43
|
+
const destPath = path.join(outputDir, file);
|
|
44
|
+
debugCopy('Attempting to copy file: %s from %s to %s', file, inputDir, outputDir);
|
|
45
|
+
// Check if source file exists
|
|
46
|
+
try {
|
|
47
|
+
await fs.access(srcPath);
|
|
48
|
+
debugCopy('Source file exists: %s', srcPath);
|
|
49
|
+
debugCopy('Creating output directory: %s', outputDir);
|
|
50
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
51
|
+
await fs.copyFile(srcPath, destPath);
|
|
52
|
+
debugCopy('Successfully copied %s to %s', file, destPath);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
// File doesn't exist, skip copying
|
|
56
|
+
debugCopy('File %s not found in %s, error: %O', file, inputDir, error);
|
|
57
|
+
console.log(`File ${file} not found in ${inputDir}, skipping...`, error);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export async function copyDesignSystemDocsAndUserPreferences(inputDir, outputDir) {
|
|
61
|
+
debugCopy('Copying design system docs from %s to %s', inputDir, outputDir);
|
|
62
|
+
// Ensure output directory exists
|
|
63
|
+
debugCopy('Creating output directory: %s', outputDir);
|
|
64
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
65
|
+
// Try to copy existing files
|
|
66
|
+
debugCopy('Copying design-system.md...');
|
|
67
|
+
await copyFile(inputDir, outputDir, 'design-system.md');
|
|
68
|
+
debugCopy('Copying design-system-principles.md...');
|
|
69
|
+
await copyFile(inputDir, outputDir, 'design-system-principles.md');
|
|
70
|
+
// If design-system.md doesn't exist in output, try to generate it from TSX files
|
|
71
|
+
const designSystemPath = path.join(outputDir, 'design-system.md');
|
|
72
|
+
debugCopy('Checking if design-system.md exists at: %s', designSystemPath);
|
|
73
|
+
try {
|
|
74
|
+
await fs.access(designSystemPath);
|
|
75
|
+
debugCopy('design-system.md already exists');
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
debugCopy('design-system.md does not exist, attempting to generate from TSX files');
|
|
79
|
+
// File doesn't exist, try to generate from TSX files if inputDir exists
|
|
80
|
+
try {
|
|
81
|
+
await fs.access(inputDir);
|
|
82
|
+
debugCopy('Input directory is accessible: %s', inputDir);
|
|
83
|
+
const { generateDesignSystemMarkdown } = await import('./markdown-generator.js');
|
|
84
|
+
const files = await getAllTsxFiles(inputDir);
|
|
85
|
+
if (files.length > 0) {
|
|
86
|
+
debugCopy('Found %d TSX files, generating design-system.md', files.length);
|
|
87
|
+
await generateDesignSystemMarkdown(inputDir, outputDir);
|
|
88
|
+
console.log(`Generated design-system.md from ${files.length} component files`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
debugCopy('No TSX files found in %s', inputDir);
|
|
92
|
+
console.log(`No .tsx files found in ${inputDir} to generate design-system.md`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
debugCopy('Input directory %s not accessible: %O', inputDir, error);
|
|
97
|
+
console.log(`Input directory ${inputDir} not accessible`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
debugCopy('Design system docs copy/generation complete');
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=file-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-operations.js","sourceRoot":"","sources":["../src/file-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,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|
-
export declare function importDesignSystemComponentsFromFigma(outputDir: string, strategy?: ImportStrategy, filterFn?: FilterFunctionType): Promise<void>;
|
|
1
|
+
export { generateDesignSystemMarkdown } from './markdown-generator.js';
|
|
2
|
+
export { copyDesignSystemDocsAndUserPreferences } from './file-operations.js';
|
|
3
|
+
export { importDesignSystemComponentsFromFigma, ImportStrategy } from './figma-importer.js';
|
|
4
|
+
export type { FilterFunctionType } from './FigmaComponentsBuilder.js';
|
|
5
|
+
export declare const COMMANDS: import("@auto-engineer/message-bus").UnifiedCommandHandler<Readonly<{
|
|
6
|
+
type: "ImportDesignSystem";
|
|
7
|
+
data: Readonly<{
|
|
8
|
+
outputDir: string;
|
|
9
|
+
strategy?: keyof typeof import("./figma-importer.js").ImportStrategy;
|
|
10
|
+
filterPath?: string;
|
|
11
|
+
}>;
|
|
12
|
+
timestamp?: Date;
|
|
13
|
+
requestId?: string;
|
|
14
|
+
correlationId?: string;
|
|
15
|
+
}>>[];
|
|
18
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,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;AAC5F,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAItE,eAAO,MAAM,QAAQ;;;;;;;;;;KAA8B,CAAC"}
|