@auto-engineer/design-system-importer 0.13.3 → 0.15.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 (43) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +22 -0
  3. package/README.md +180 -45
  4. package/dist/src/FigmaComponentsBuilder.js +1 -1
  5. package/dist/src/FigmaComponentsBuilder.js.map +1 -1
  6. package/dist/src/commands/import-design-system.d.ts.map +1 -1
  7. package/dist/src/commands/import-design-system.js +7 -3
  8. package/dist/src/commands/import-design-system.js.map +1 -1
  9. package/dist/src/figma-api.js +1 -1
  10. package/dist/src/figma-api.js.map +1 -1
  11. package/dist/src/figma-importer.d.ts +1 -1
  12. package/dist/src/figma-importer.d.ts.map +1 -1
  13. package/dist/src/figma-importer.js +2 -2
  14. package/dist/src/figma-importer.js.map +1 -1
  15. package/dist/src/file-operations.js +2 -2
  16. package/dist/src/file-operations.js.map +1 -1
  17. package/dist/src/index.d.ts +3 -3
  18. package/dist/src/index.d.ts.map +1 -1
  19. package/dist/src/index.js +2 -2
  20. package/dist/src/index.js.map +1 -1
  21. package/dist/src/markdown-generator.js +2 -2
  22. package/dist/src/markdown-generator.js.map +1 -1
  23. package/dist/src/utils/FilterLoader.d.ts.map +1 -1
  24. package/dist/src/utils/FilterLoader.js +6 -6
  25. package/dist/src/utils/FilterLoader.js.map +1 -1
  26. package/dist/src/utils/templates/tsx-export.mjs +13 -9
  27. package/dist/src/utils/templates/tsx-final-loader.mjs +1 -1
  28. package/dist/src/utils/templates/tsx-loader.mjs +4 -5
  29. package/dist/src/utils/templates/tsx-wrapper.mjs +14 -12
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +3 -7
  32. package/src/FigmaComponentsBuilder.ts +1 -1
  33. package/src/commands/import-design-system.ts +8 -4
  34. package/src/figma-api.ts +1 -1
  35. package/src/figma-importer.ts +3 -3
  36. package/src/file-operations.ts +2 -2
  37. package/src/index.ts +4 -3
  38. package/src/markdown-generator.ts +2 -2
  39. package/src/utils/FilterLoader.ts +7 -7
  40. package/src/utils/templates/tsx-export.mjs +13 -9
  41. package/src/utils/templates/tsx-final-loader.mjs +1 -1
  42. package/src/utils/templates/tsx-loader.mjs +4 -5
  43. package/src/utils/templates/tsx-wrapper.mjs +14 -12
package/package.json CHANGED
@@ -15,22 +15,18 @@
15
15
  "dependencies": {
16
16
  "figma-api": "2.0.2-beta",
17
17
  "tsx": "^3.12.7",
18
- "@auto-engineer/message-bus": "0.13.3"
18
+ "@auto-engineer/message-bus": "0.15.0"
19
19
  },
20
20
  "devDependencies": {
21
- "@auto-engineer/cli": "0.13.3"
21
+ "@auto-engineer/cli": "0.15.0"
22
22
  },
23
- "version": "0.13.3",
23
+ "version": "0.15.0",
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/src/utils/",
27
27
  "test": "vitest run --reporter=dot",
28
28
  "test:coverage": "vitest run --coverage",
29
- "lint": "eslint 'src/**/*.ts' --max-warnings 0 --config ../../eslint.config.ts",
30
29
  "type-check": "tsc --noEmit",
31
- "format": "prettier --write \"**/*.{js,ts,json,md,yml,yaml}\" --ignore-path ../../.prettierignore --log-level warn",
32
- "lint:fix": "eslint 'src/**/*.ts' --fix --config ../../eslint.config.ts",
33
- "format:fix": "prettier --write \"**/*.{js,ts,json,md,yml,yaml}\" --ignore-path ../../.prettierignore --log-level warn",
34
30
  "link:dev": "pnpm build && pnpm link --global",
35
31
  "unlink:dev": "pnpm unlink --global"
36
32
  }
@@ -1,6 +1,6 @@
1
+ import createDebug from 'debug';
1
2
  import * as dotenv from 'dotenv';
2
3
  import * as Figma from 'figma-api';
3
- import createDebug from 'debug';
4
4
 
5
5
  const debug = createDebug('auto:design-system-importer:figma-builder');
6
6
  const debugComponents = createDebug('auto:design-system-importer:figma-builder:components');
@@ -1,7 +1,7 @@
1
- import { type Command, type Event, defineCommandHandler } from '@auto-engineer/message-bus';
2
- import { importDesignSystemComponentsFromFigma, ImportStrategy, type FilterFunctionType } from '../index';
3
- import { FilterLoader } from '../utils/FilterLoader';
1
+ import { type Command, defineCommandHandler, type Event } from '@auto-engineer/message-bus';
4
2
  import createDebug from 'debug';
3
+ import { type FilterFunctionType, ImportStrategy, importDesignSystemComponentsFromFigma } from '../index';
4
+ import { FilterLoader } from '../utils/FilterLoader';
5
5
 
6
6
  const debug = createDebug('auto:design-system-importer:command');
7
7
  const debugFilter = createDebug('auto:design-system-importer:command:filter');
@@ -37,6 +37,7 @@ export const commandHandler = defineCommandHandler<
37
37
  (command: ImportDesignSystemCommand) => Promise<DesignSystemImportedEvent | DesignSystemImportFailedEvent>
38
38
  >({
39
39
  name: 'ImportDesignSystem',
40
+ displayName: 'Import Design System',
40
41
  alias: 'import:design-system',
41
42
  description: 'Import Figma design system',
42
43
  category: 'import',
@@ -56,7 +57,10 @@ export const commandHandler = defineCommandHandler<
56
57
  examples: [
57
58
  '$ auto import:design-system --output-dir=./.context --strategy=WITH_COMPONENT_SETS --filter-path=./shadcn-filter.ts',
58
59
  ],
59
- events: ['ImportDesignSystemCompleted', 'ImportDesignSystemFailed'],
60
+ events: [
61
+ { name: 'ImportDesignSystemCompleted', displayName: 'Design System Imported' },
62
+ { name: 'ImportDesignSystemFailed', displayName: 'Design System Import Failed' },
63
+ ],
60
64
  handle: async (command: Command): Promise<DesignSystemImportedEvent | DesignSystemImportFailedEvent> => {
61
65
  const typedCommand = command as ImportDesignSystemCommand;
62
66
  debug('CommandHandler executing for ImportDesignSystem');
package/src/figma-api.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import createDebug from 'debug';
1
2
  import * as dotenv from 'dotenv';
2
3
  import * as Figma from 'figma-api';
3
- import createDebug from 'debug';
4
4
 
5
5
  dotenv.config();
6
6
 
@@ -1,7 +1,7 @@
1
- import * as path from 'path';
2
- import * as fs from 'fs/promises';
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
3
  import createDebug from 'debug';
4
- import { type FilterFunctionType } from './FigmaComponentsBuilder.js';
4
+ import type { FilterFunctionType } from './FigmaComponentsBuilder.js';
5
5
  import { generateMarkdownFromComponents } from './markdown-generator.js';
6
6
 
7
7
  const debug = createDebug('auto:design-system-importer');
@@ -1,5 +1,5 @@
1
- import * as path from 'path';
2
- import * as fs from 'fs/promises';
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
3
  import createDebug from 'debug';
4
4
 
5
5
  const debugFiles = createDebug('auto:design-system-importer:files');
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
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';
2
+
5
3
  export type { FilterFunctionType } from './FigmaComponentsBuilder.js';
4
+ export { ImportStrategy, importDesignSystemComponentsFromFigma } from './figma-importer.js';
5
+ export { copyDesignSystemDocsAndUserPreferences } from './file-operations.js';
6
+ export { generateDesignSystemMarkdown } from './markdown-generator.js';
6
7
 
7
8
  // Command exports
8
9
  import importDesignSystemHandler from './commands/import-design-system.js';
@@ -1,5 +1,5 @@
1
- import * as path from 'path';
2
- import * as fs from 'fs/promises';
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
3
  import createDebug from 'debug';
4
4
  import { getAllTsxFiles, getComponentNameFromFile } from './file-operations.js';
5
5
 
@@ -1,10 +1,10 @@
1
- import { extname, resolve as resolvePath, dirname, join } from 'path';
2
- import { pathToFileURL, fileURLToPath } from 'url';
3
- import { existsSync, readFileSync, writeFileSync, mkdtempSync, rmSync } from 'fs';
4
- import { spawnSync } from 'child_process';
5
- import { tmpdir } from 'os';
6
- import type { FilterFunctionType } from '../FigmaComponentsBuilder';
1
+ import { spawnSync } from 'node:child_process';
2
+ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3
+ import { tmpdir } from 'node:os';
4
+ import { dirname, extname, join, resolve as resolvePath } from 'node:path';
5
+ import { fileURLToPath, pathToFileURL } from 'node:url';
7
6
  import createDebug from 'debug';
7
+ import type { FilterFunctionType } from '../FigmaComponentsBuilder';
8
8
 
9
9
  const debug = createDebug('auto:design-system-importer:filter-loader');
10
10
  const debugLoad = createDebug('auto:design-system-importer:filter-loader:load');
@@ -181,7 +181,7 @@ export class FilterLoader {
181
181
  debugStrategy('Successfully parsed filter code, creating function');
182
182
  // Create a function from the filter code
183
183
  // eslint-disable-next-line @typescript-eslint/no-implied-eval, @typescript-eslint/no-unsafe-call
184
- const filter = new Function('return ' + output.filterCode)() as FilterFunctionType;
184
+ const filter = new Function(`return ${output.filterCode}`)() as FilterFunctionType;
185
185
  debugStrategy('Filter function created successfully');
186
186
  return filter;
187
187
  }
@@ -5,13 +5,17 @@ const filter = filterModule.filter || filterModule.default;
5
5
 
6
6
  if (typeof filter === 'function') {
7
7
  // Output the filter as a module we can import
8
- console.log(JSON.stringify({
9
- success: true,
10
- filterCode: filter.toString()
11
- }));
8
+ console.log(
9
+ JSON.stringify({
10
+ success: true,
11
+ filterCode: filter.toString(),
12
+ }),
13
+ );
12
14
  } else {
13
- console.log(JSON.stringify({
14
- success: false,
15
- error: 'No filter function found'
16
- }));
17
- }
15
+ console.log(
16
+ JSON.stringify({
17
+ success: false,
18
+ error: 'No filter function found',
19
+ }),
20
+ );
21
+ }
@@ -7,4 +7,4 @@ register('tsx', import.meta.url);
7
7
  const filterModule = await import('__FILTER_PATH__');
8
8
 
9
9
  // Export the filter function
10
- export const filter = filterModule.filter || filterModule.default;
10
+ export const filter = filterModule.filter || filterModule.default;
@@ -1,13 +1,12 @@
1
- import { register } from 'node:module';
1
+ import { createRequire, register } from 'node:module';
2
2
  import { pathToFileURL } from 'node:url';
3
- import { createRequire } from 'node:module';
4
3
 
5
4
  // Try to find and register tsx
6
5
  try {
7
6
  // First try to find tsx in the project's node_modules
8
7
  const require = createRequire(import.meta.url);
9
8
  let tsxPath;
10
-
9
+
11
10
  try {
12
11
  // Try to resolve tsx from the current working directory
13
12
  tsxPath = require.resolve('tsx/esm/api', { paths: [process.cwd()] });
@@ -20,7 +19,7 @@ try {
20
19
  tsxPath = require.resolve('tsx');
21
20
  }
22
21
  }
23
-
22
+
24
23
  // Import tsx and register it
25
24
  const tsx = await import(tsxPath);
26
25
  if (tsx.register) {
@@ -45,4 +44,4 @@ if (typeof filter !== 'function') {
45
44
  }
46
45
 
47
46
  // Export it so we can use it
48
- export { filter };
47
+ export { filter };
@@ -1,15 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  // This script tests if the filter can be loaded and executed
3
- import('__FILTER_PATH__').then(module => {
4
- const filter = module.filter || module.default;
5
- if (typeof filter === 'function') {
6
- // Test it works
7
- filter({ name: 'test', type: 'COMPONENT', children: [] });
8
- process.exit(0);
9
- } else {
3
+ import('__FILTER_PATH__')
4
+ .then((module) => {
5
+ const filter = module.filter || module.default;
6
+ if (typeof filter === 'function') {
7
+ // Test it works
8
+ filter({ name: 'test', type: 'COMPONENT', children: [] });
9
+ process.exit(0);
10
+ } else {
11
+ process.exit(1);
12
+ }
13
+ })
14
+ .catch((err) => {
15
+ console.error(err);
10
16
  process.exit(1);
11
- }
12
- }).catch(err => {
13
- console.error(err);
14
- process.exit(1);
15
- });
17
+ });