@dxtmisha/scripts 0.7.10 → 0.7.12

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 (37) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +42 -173
  3. package/bin/design-figma.ts +10 -0
  4. package/bin/design-screenshot.ts +7 -0
  5. package/bin/design-types.ts +3 -1
  6. package/package.json +12 -8
  7. package/src/classes/BrowserItem.ts +375 -0
  8. package/src/classes/Design/DesignFigma.ts +34 -0
  9. package/src/classes/Design/DesignScreenshot.ts +123 -0
  10. package/src/classes/Design/DesignTypes.ts +79 -29
  11. package/src/classes/FigmaApi.ts +190 -0
  12. package/src/classes/Properties/PropertiesConfig.ts +9 -0
  13. package/src/config.ts +1 -0
  14. package/src/library.ts +5 -1
  15. package/src/media/templates/componentDoc/figma/run-figma.ts +26 -0
  16. package/src/media/templates/packages/nitro/README.md +1 -0
  17. package/src/media/templates/packages/nitro/index.html +2 -0
  18. package/src/media/templates/packages/nitro/package.json +25 -0
  19. package/src/media/templates/packages/nitro/server/plugins/ui-plugin.ts +7 -0
  20. package/src/media/templates/packages/nitro/server/routes/api/hello.ts +13 -0
  21. package/src/media/templates/packages/nitro/src/App.vue +10 -0
  22. package/src/media/templates/packages/nitro/src/entry-client.ts +12 -0
  23. package/src/media/templates/packages/nitro/src/entry-server.ts +29 -0
  24. package/src/media/templates/packages/nitro/src/main.ts +14 -0
  25. package/src/media/templates/packages/nitro/src/pages/HomePage.vue +8 -0
  26. package/src/media/templates/packages/nitro/src/router.ts +11 -0
  27. package/src/media/templates/packages/nitro/src/style.scss +0 -0
  28. package/src/media/templates/packages/nitro/src/templates/main.html +21 -0
  29. package/src/media/templates/packages/nitro/src/vite-env.d.ts +11 -0
  30. package/src/media/templates/packages/nitro/tsconfig.app.json +15 -0
  31. package/src/media/templates/packages/nitro/tsconfig.json +7 -0
  32. package/src/media/templates/packages/nitro/tsconfig.node.json +12 -0
  33. package/src/media/templates/packages/nitro/vite.config.ts +17 -0
  34. package/src/types/configTypes.ts +3 -0
  35. package/src/types/figmaApiTypes.ts +337 -0
  36. package/src/types/screenshotTypes.ts +35 -5
  37. package/src/functions/takeScreenshot.ts +0 -49
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [0.7.11] - 2026-05-05
6
+
7
+ ### Added
8
+ - **Figma API**: Implemented a robust Figma API client (`FigmaApi`, `DesignFigma`) supporting file retrieval, node filtering, image generation, and style metadata extraction.
9
+ - **Storybook Integration**: Configured Storybook to monitor the `demo-test` directory, enabling better testing and visualization of experimental components.
10
+ - **Browser Automation**: Introduced a dedicated `BrowserItem` class to encapsulate Puppeteer logic, supporting advanced features like custom wait states and extended viewport heights.
11
+
12
+ ### Changed / Improved
13
+ - **Automated Screenshots**: Overhauled the `DesignScreenshot` class to handle server lifecycle and capture triggers more reliably. Standardized screenshot constants (timeouts, quality, and browser arguments).
14
+ - **Library Exports**: Streamlined library exports by centralizing design and browser-related utilities.
15
+ - **Type Generation**: Updated `DesignTypes` to force `ServerStorage` error status during generation. Fixed a type generation issue in `DesignReplace` to ensure flexible string types in component property templates.
package/README.md CHANGED
@@ -1,30 +1,40 @@
1
1
  # @dxtmisha/scripts
2
2
 
3
- 🛠️ **Development scripts and CLI tools** for DXT UI projects - automated component generation, library building and project management tools.
4
-
5
3
  [![npm version](https://badge.fury.io/js/@dxtmisha%2Fscripts.svg)](https://www.npmjs.com/package/@dxtmisha/scripts)
6
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
- [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
5
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen)](https://nodejs.org/)
6
+
7
+ `@dxtmisha/scripts` is a powerful suite of development scripts and CLI tools designed specifically for automating workflows in modern UI libraries.
8
+
9
+ ## Why this library?
10
+
11
+ Maintaining a UI library inevitably involves a lot of repetitive boilerplate: creating component files, writing basic props interfaces, setting up Storybook configuration, keeping index barrel files updated, and maintaining documentation. Typically each project solves these by copying and pasting folders or writing ad-hoc shell scripts that break over time.
12
+
13
+ `scripts` brings all these solutions together in one place — thoughtful, tested, and ready to use. It automates the mundane work, providing a cohesive toolset to scaffold components, generate documentation (including AI-assisted text), and automatically manage library exports, ensuring your UI project remains structured and easy to scale.
14
+
15
+ ## What does it do?
16
+
17
+ For **component scaffolding** — automatic generation of full Vue component templates. A single command sets up `.vue` files, `props.ts`, `styleToken.scss`, and barrel exports, complete with TypeScript definitions.
8
18
 
9
- ## 🚀 Installation
19
+ For **design system orchestration** — a robust suite of classes to parse TypeScript props, manage constructor configurations, and synchronize design tokens.
20
+
21
+ For **documentation & Storybook** — tools to generate `.stories.ts` and `.mdx` files automatically. It can even utilize Google's AI (Gemini) or Anthropic's Claude to generate component descriptions and technical docs.
22
+
23
+ For **Figma integration** — a complete Figma API client capable of fetching styles, analyzing design nodes, and translating them into usable code structures.
24
+
25
+ For **visual testing** — browser automation using Puppeteer to capture and process component screenshots across different states and themes.
26
+
27
+ For **library management** — automated maintenance of `index.ts` files (barrel exports) across packages, ensuring all components and utilities are correctly exposed.
28
+
29
+ ## Installation
10
30
 
11
31
  ```bash
12
32
  npm install -D @dxtmisha/scripts
13
33
  ```
14
34
 
15
- > **Note:** TypeScript sources are shipped directly. Requires a TypeScript runner like `vite-node`, `tsx` or manual transpilation.
16
-
17
- ## ✨ Features
18
-
19
- - 🏗️ **Component scaffolding** - automatic Vue component generation with TypeScript
20
- - 🎯 **AI integration** - Google AI (Gemini) powered code generation
21
- - 🔧 **CLI commands** - ready-to-use command line tools
22
- - 📝 **Documentation generation** - automatic Storybook and MDX creation
23
- - ⚡ **Library management** - export barrel file maintenance
24
- - 🎨 **Design system tools** - constructor and properties management
25
- - 📦 **TypeScript source** - no build step required
35
+ > **Note:** TypeScript sources are shipped directly. Requires a TypeScript runner like `vite-node`, `tsx`, or manual transpilation.
26
36
 
27
- ## 📖 Quick Start
37
+ ## Quick Start
28
38
 
29
39
  ### CLI Commands
30
40
 
@@ -32,7 +42,7 @@ npm install -D @dxtmisha/scripts
32
42
  # Generate component scaffolds in empty directories
33
43
  npx dxt-component
34
44
 
35
- # Generate wiki documentation for specific component
45
+ # Generate wiki documentation for a specific component
36
46
  npx dxt-component-wiki MyButton
37
47
 
38
48
  # Build component constructors
@@ -48,180 +58,39 @@ npx dxt-ui
48
58
  ### Programmatic Usage
49
59
 
50
60
  ```typescript
51
- import {
52
- ComponentCreator,
53
- DesignComponent,
54
- AiGoogle,
55
- LibraryExport
56
- } from '@dxtmisha/scripts'
61
+ import { ComponentCreator, AiGoogle, LibraryExport } from '@dxtmisha/scripts'
57
62
 
58
63
  // Generate component scaffolds
59
64
  const creator = new ComponentCreator()
60
- creator.make() // Scans and creates templates for empty component dirs
65
+ creator.make()
61
66
 
62
67
  // AI-powered generation
63
68
  const ai = new AiGoogle()
64
- ai.addPrompt('You are a Vue component expert')
65
69
  ai.setModel('gemini-1.5-flash')
66
70
  const result = await ai.generate('Create props interface for Button component')
67
71
 
68
72
  // Library export management
69
73
  const library = new LibraryExport()
70
- library.make() // Rebuilds barrel export files
71
- ```
72
-
73
- ## 📚 Available utilities
74
-
75
- ### 🏗️ Core Classes
76
-
77
- #### Component Generation
78
- ```typescript
79
- import { ComponentCreator, ComponentItem, ComponentWiki } from '@dxtmisha/scripts'
80
-
81
- // Bulk component scaffolding
82
- const creator = new ComponentCreator()
83
- creator.make() // Creates templates in all empty component directories
84
-
85
- // Single component generation
86
- const item = new ComponentItem('/path/to/component')
87
- item.make() // Creates complete component file set
88
-
89
- // Documentation generation
90
- const wiki = new ComponentWiki('Button')
91
- wiki.make() // Generates Storybook files
92
- ```
93
-
94
- #### AI Integration
95
- ```typescript
96
- import { AiAbstract, AiGoogle } from '@dxtmisha/scripts'
97
-
98
- const ai = new AiGoogle()
99
-
100
- // Prompt management
101
- ai.addPrompt('Context line 1')
102
- ai.addPrompt('Context line 2')
103
- ai.resetPrompt() // Clear all prompts
104
-
105
- // Configuration
106
- ai.setKey('your-api-key')
107
- ai.setModel('gemini-1.5-flash')
108
-
109
- // Generation
110
- const response = await ai.generate('Generate TypeScript interface')
111
- ```
112
-
113
- #### Design System Tools
114
- ```typescript
115
- import {
116
- DesignComponent,
117
- DesignConstructor,
118
- DesignTypescript,
119
- DesignStructure
120
- } from '@dxtmisha/scripts'
121
-
122
- // Component orchestration
123
- const component = new DesignComponent('Button', { variant: 'primary' })
124
- component.make() // Creates: props.ts, styleToken.scss, Component.vue, etc.
125
-
126
- // TypeScript analysis
127
- const ts = new DesignTypescript('/path/to/props.ts')
128
- const props = ts.getType('ButtonProps')?.props // Extract prop definitions
129
- ```
130
-
131
- ### 🎯 Vue Composables
132
-
133
- ```typescript
134
- import { useAi } from '@dxtmisha/scripts'
135
-
136
- // Reactive AI integration
137
- const { ai, generate, loading, error } = useAi()
138
-
139
- // Usage in Vue component
140
- const result = await generate('Create component documentation')
141
- ```
142
-
143
- ### 🔧 Utility Functions
144
-
145
- ```typescript
146
- import {
147
- getComponentPaths,
148
- getConstructorProperties,
149
- getNameDirByPaths
150
- } from '@dxtmisha/scripts'
151
-
152
- // Path utilities
153
- const paths = getComponentPaths('/components/Button')
154
- const properties = getConstructorProperties()
155
- const dirName = getNameDirByPaths(['src', 'components', 'Button'])
156
- ```
157
-
158
- ## 🎯 CLI Commands Reference
159
-
160
- | Command | Purpose | Arguments | Output |
161
- |---------|---------|-----------|---------|
162
- | `dxt-component` | Component scaffolding | None (scans all) | Creates templates in empty dirs |
163
- | `dxt-component-wiki` | Wiki generation | `<ComponentName>` | Generates .stories.ts and .mdx |
164
- | `dxt-constructor` | Constructor build | None | Updates constructor files |
165
- | `dxt-library` | Library exports | None | Rebuilds barrel exports |
166
- | `dxt-ui` | Full UI build | None | Complete project generation |
167
-
168
- ## 🏗️ Generated File Structure
169
-
170
- When using `DesignComponent`, the following files are created:
171
-
172
- ```
173
- MyComponent/
174
- ├── properties.json # Design tokens binding
175
- ├── props.ts # TypeScript props + defaults
176
- ├── styleToken.scss # SCSS tokens and imports
177
- ├── MyComponent.vue # Vue SFC template
178
- ├── index.ts # Component export
179
- ├── wiki.ts # Storybook controls
180
- ├── MyComponent.stories.ts # Storybook configuration
181
- └── MyComponent.mdx # MDX documentation
182
- ```
183
-
184
- ## 🎯 Use cases
185
-
186
- ### AI-Assisted Development
187
- ```typescript
188
- import { AiGoogle } from '@dxtmisha/scripts'
189
-
190
- async function generateComponentDocs(componentName: string) {
191
- const ai = new AiGoogle()
192
- ai.addPrompt('You are a technical writer for Vue components')
193
- ai.addPrompt('Write clear, concise documentation')
194
-
195
- const docs = await ai.generate(`
196
- Create documentation for ${componentName} component.
197
- Include usage examples and prop descriptions.
198
- `)
199
-
200
- return docs
201
- }
74
+ library.make()
202
75
  ```
203
76
 
204
- ## 📦 Requirements
77
+ ## Principles
205
78
 
206
- **Core Dependencies:**
207
- - Node.js ≥18.0.0
208
- - TypeScript ≥5.0.0
79
+ - **Developer Experience First** — commands are simple, outputs are predictable. You shouldn't have to write boilerplate.
80
+ - **TypeScript-first** — strict typing and autocomplete out of the box. Ships source directly, making it easy to integrate into modern tooling environments.
81
+ - **AI-Enhanced** — embraces LLMs to speed up tedious documentation and scaffolding tasks.
82
+ - **Clean API** — predictable behavior and clear naming for programmatically managing UI systems.
209
83
 
210
- **Peer Dependencies (install separately):**
211
- - `@dxtmisha/functional` ≥1.0.3 - utility functions
212
- - `@dxtmisha/configuration` ≥0.3.9 - build configurations
213
- - `@dxtmisha/wiki` ≥0.23.5 - storybook utilities
214
- - `@dxtmisha/styles` ≥1.0.2 - styling system
215
- - `vue` ≥3.0.0 - Vue framework (when needed)
84
+ ## Documentation
216
85
 
217
- ## 📄 License
86
+ Full API reference, examples, and guides:
218
87
 
219
- MIT © [dxtmisha](https://github.com/dxtmisha)
88
+ **[📖 https://dxtmisha.github.io/dxt-ui/](https://dxtmisha.github.io/dxt-ui/)**
220
89
 
221
- ## 🐛 Report an issue
90
+ ## Difference from other tools
222
91
 
223
- [GitHub Issues](https://github.com/dxtmisha/dxt-ui/issues)
92
+ - **`@dxtmisha/scripts`** — specifically tailored for the internal architecture of DXT UI, integrating deeply with our property management and Storybook setup. Not a generic scaffolding tool like Yeoman or Plop.
224
93
 
225
- ---
94
+ ## License
226
95
 
227
- ⭐ **Give us a star** if these scripts helped accelerate your development!
96
+ [MIT](LICENSE)
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env vite-node
2
+
3
+ import { DesignFigma } from '../src/classes/Design/DesignFigma'
4
+
5
+ const fileKey: string = process.argv?.[2] ?? 'fileKey'
6
+ const nodeId: string = process.argv?.[3] ?? 'nodeId'
7
+
8
+ new DesignFigma(fileKey, nodeId)
9
+ .make()
10
+ .then()
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env vite-node
2
+
3
+ import { DesignScreenshot } from '../src/classes/Design/DesignScreenshot'
4
+
5
+ new DesignScreenshot()
6
+ .make()
7
+ .then()
@@ -4,4 +4,6 @@ import { DesignTypes } from '../src/classes/Design/DesignTypes'
4
4
 
5
5
  const dir: string = process.argv?.[2] ?? 'dist'
6
6
 
7
- new DesignTypes(dir).make()
7
+ new DesignTypes(dir)
8
+ .make()
9
+ .then()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dxtmisha/scripts",
3
3
  "private": false,
4
- "version": "0.7.10",
4
+ "version": "0.7.12",
5
5
  "type": "module",
6
6
  "description": "Development scripts and CLI tools for DXT UI projects - automated component generation, library building and project management tools",
7
7
  "keywords": [
@@ -34,9 +34,10 @@
34
34
  "files": [
35
35
  "bin/",
36
36
  "src/",
37
+ "CHANGELOG.md",
38
+ "LICENSE",
37
39
  "README.md",
38
- "package.json",
39
- "LICENSE"
40
+ "package.json"
40
41
  ],
41
42
  "main": "./src/library.ts",
42
43
  "module": "./src/library.ts",
@@ -46,9 +47,11 @@
46
47
  "dxt-component": "bin/design-component.ts",
47
48
  "dxt-component-wiki": "bin/design-component-wiki.ts",
48
49
  "dxt-constructor": "bin/design-constructor.ts",
50
+ "dxt-figma-layout": "bin/design-figma.ts",
49
51
  "dxt-flags": "bin/design-flags.ts",
50
52
  "dxt-library": "bin/design-library.ts",
51
53
  "dxt-package": "bin/design-package.ts",
54
+ "dxt-screenshot": "bin/design-screenshot.ts",
52
55
  "dxt-types": "bin/design-types.ts",
53
56
  "dxt-ui": "bin/design-ui.ts",
54
57
  "dxt-wiki-storm": "bin/design-wiki-storm.ts"
@@ -64,15 +67,16 @@
64
67
  "node": ">=20.0.0"
65
68
  },
66
69
  "dependencies": {
67
- "@anthropic-ai/sdk": "^0.89.0",
70
+ "@anthropic-ai/sdk": "*",
68
71
  "@dxtmisha/configuration": "*",
69
72
  "@dxtmisha/functional": "*",
70
73
  "@dxtmisha/functional-basic": "*",
71
74
  "@dxtmisha/media": "*",
75
+ "@dxtmisha/styles": "*",
72
76
  "@dxtmisha/wiki": "*",
73
- "@google/genai": "^1.50.1",
74
- "puppeteer": "^24.41.0",
75
- "typescript": "^6.0.2",
76
- "vue": "^3.5.32"
77
+ "@google/genai": "*",
78
+ "puppeteer": "*",
79
+ "typescript": "*",
80
+ "vue": "*"
77
81
  }
78
82
  }