@starodubenko/fsd-gen 0.1.0 → 1.0.0-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/README.md +172 -0
- package/dist/config/defineConfig.d.ts +1 -1
- package/dist/config/defineConfig.d.ts.map +1 -1
- package/dist/config/types.d.ts +59 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/generators/generate.d.ts +1 -5
- package/dist/lib/generators/generate.d.ts.map +1 -1
- package/dist/lib/generators/generate.js +2 -2
- package/dist/lib/helpers/presetHelpers.d.ts +1 -27
- package/dist/lib/helpers/presetHelpers.d.ts.map +1 -1
- package/dist/lib/helpers/presetHelpers.js +24 -9
- package/dist/lib/helpers/presetHelpers.spec.d.ts +2 -0
- package/dist/lib/helpers/presetHelpers.spec.d.ts.map +1 -0
- package/dist/lib/helpers/presetHelpers.spec.js +36 -0
- package/dist/lib/helpers/templateHelpers.d.ts +20 -0
- package/dist/lib/helpers/templateHelpers.d.ts.map +1 -0
- package/dist/lib/helpers/templateHelpers.js +23 -0
- package/dist/lib/jsx/components.d.ts +38 -0
- package/dist/lib/jsx/components.d.ts.map +1 -0
- package/dist/lib/jsx/components.js +40 -0
- package/dist/lib/jsx/jsx-runtime.d.ts +20 -0
- package/dist/lib/jsx/jsx-runtime.d.ts.map +1 -0
- package/dist/lib/jsx/jsx-runtime.js +7 -0
- package/dist/lib/jsx/renderer.d.ts +2 -0
- package/dist/lib/jsx/renderer.d.ts.map +1 -0
- package/dist/lib/jsx/renderer.js +24 -0
- package/dist/lib/preset/actionExecution.d.ts +2 -2
- package/dist/lib/preset/actionExecution.d.ts.map +1 -1
- package/dist/lib/preset/actionExecution.js +39 -4
- package/dist/lib/preset/actionExecution.spec.d.ts +2 -0
- package/dist/lib/preset/actionExecution.spec.d.ts.map +1 -0
- package/dist/lib/preset/actionExecution.spec.js +178 -0
- package/dist/lib/preset/presetDiscovery.d.ts +10 -4
- package/dist/lib/preset/presetDiscovery.d.ts.map +1 -1
- package/dist/lib/preset/presetDiscovery.js +29 -21
- package/dist/lib/preset/presetLoading.d.ts.map +1 -1
- package/dist/lib/preset/presetLoading.js +2 -1
- package/dist/lib/templates/templateLoader.d.ts +7 -5
- package/dist/lib/templates/templateLoader.d.ts.map +1 -1
- package/dist/lib/templates/templateLoader.js +44 -7
- package/package.json +2 -2
- package/templates/entity/model-ui-basic/Component.tsx +18 -7
- package/templates/feature/ui-model-basic/Component.tsx +18 -7
- package/templates/page/ui-basic/Component.tsx +18 -7
- package/templates/preset/table/entity/model.ts +10 -4
- package/templates/preset/table/feature/buttons.tsx +12 -6
- package/templates/preset/table/page/page.tsx +30 -8
- package/templates/preset/table/widget/table.tsx +28 -11
- package/templates/shared/ui-basic/Component.tsx +17 -6
- package/templates/widget/ui-basic/Component.tsx +18 -7
- package/templates/entity/model-ui-basic/Component.styles.ts +0 -1
- package/templates/feature/ui-model-basic/Component.styles.ts +0 -1
- package/templates/page/ui-basic/Component.styles.ts +0 -1
- package/templates/shared/ui-basic/Component.styles.ts +0 -1
- package/templates/widget/ui-basic/Component.styles.ts +0 -1
package/README.md
CHANGED
|
@@ -45,17 +45,189 @@ Create an `fsdgen.config.ts` in your project root:
|
|
|
45
45
|
import { defineConfig } from '@starodubenko/fsd-gen';
|
|
46
46
|
|
|
47
47
|
export default defineConfig({
|
|
48
|
+
/**
|
|
49
|
+
* Root directory of the source code.
|
|
50
|
+
* Defaults to "src".
|
|
51
|
+
*/
|
|
48
52
|
rootDir: 'src',
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Alias configuration.
|
|
56
|
+
* Maps import aliases to their relative paths from root.
|
|
57
|
+
*/
|
|
49
58
|
aliases: {
|
|
50
59
|
'@entities': './src/entities',
|
|
51
60
|
'@features': './src/features',
|
|
52
61
|
'@widgets': './src/widgets',
|
|
53
62
|
'@pages': './src/pages',
|
|
54
63
|
'@shared': './src/shared',
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Directory containing custom templates.
|
|
68
|
+
* Can be relative to the config file.
|
|
69
|
+
*/
|
|
70
|
+
templatesDir: './.fsd-templates',
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Naming convention enforcement.
|
|
74
|
+
* "strict" | "warn" | "off"
|
|
75
|
+
*/
|
|
76
|
+
naming: 'warn',
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 📂 Template Structure
|
|
81
|
+
|
|
82
|
+
To customize templates, creating a `templatesDir` (e.g., `.fsd-templates`) allows you to override default templates. The structure should mirror the generator's internal organization:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
.fsd-templates/
|
|
86
|
+
├── entity/
|
|
87
|
+
│ └── model-ui/ # Template name (e.g., used by default or specified)
|
|
88
|
+
│ └── sub/ # Optional subdirectory
|
|
89
|
+
│ └── Component.tsx
|
|
90
|
+
├── feature/
|
|
91
|
+
│ └── ...
|
|
92
|
+
├── page/
|
|
93
|
+
│ └── ...
|
|
94
|
+
├── widget/
|
|
95
|
+
│ └── ...
|
|
96
|
+
└── preset/
|
|
97
|
+
└── my-preset/ # Custom preset
|
|
98
|
+
├── entity/
|
|
99
|
+
├── feature/
|
|
100
|
+
└── preset.ts # Preset definition
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## 📝 Templated Component Example
|
|
104
|
+
|
|
105
|
+
Templates can either be standard files using **EJS** syntax or **TypeScript functions** that return the file content string.
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
**Example: `Component.tsx`**
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import type { GeneratorContext } from '@starodubenko/fsd-gen';
|
|
112
|
+
|
|
113
|
+
export default ({
|
|
114
|
+
base: { baseName },
|
|
115
|
+
template: { componentName },
|
|
116
|
+
layer: {
|
|
117
|
+
entity: { apiPath: apiImportPath, importPath: entityImportPath }
|
|
118
|
+
}
|
|
119
|
+
}: GeneratorContext) => `
|
|
120
|
+
import styled from '@emotion/styled';
|
|
121
|
+
import type { ${baseName} } from '${entityImportPath}/model/model';
|
|
122
|
+
import { useCreate${baseName} } from '${apiImportPath}';
|
|
123
|
+
|
|
124
|
+
const Button = styled.button\`
|
|
125
|
+
padding: 0.5rem 1rem;
|
|
126
|
+
margin: 0 0.5rem;
|
|
127
|
+
border-radius: 4px;
|
|
128
|
+
border: none;
|
|
129
|
+
background-color: #007bff;
|
|
130
|
+
color: white;
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
|
|
133
|
+
&:disabled {
|
|
134
|
+
background-color: #ccc;
|
|
135
|
+
cursor: not-allowed;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&:hover:not(:disabled) {
|
|
139
|
+
background-color: #0056b3;
|
|
55
140
|
}
|
|
141
|
+
\`;
|
|
142
|
+
|
|
143
|
+
export const ${componentName}Button = () => {
|
|
144
|
+
const { mutate, isLoading } = useCreate${baseName}();
|
|
145
|
+
return (
|
|
146
|
+
<Button onClick={() => mutate({ /* mock data */ } as unknown as Omit<${baseName}, 'id'>)} disabled={isLoading}>
|
|
147
|
+
{isLoading ? 'Creating...' : 'Create ${baseName}'}
|
|
148
|
+
</Button>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
`;
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Available Variables (`GeneratorContext`):**
|
|
155
|
+
|
|
156
|
+
Assuming input name is **"User"** and default configuration:
|
|
157
|
+
|
|
158
|
+
| Variable | Description | Example Value |
|
|
159
|
+
| :--- | :--- | :--- |
|
|
160
|
+
| `componentName` | Name of the component being generated | `UserCard` |
|
|
161
|
+
| `sliceName` | Name of the current slice | `User` |
|
|
162
|
+
| `layer` | Current FSD layer | `entity` |
|
|
163
|
+
| `base.name` | Original user input name | `User` |
|
|
164
|
+
| `layer.entity.importPath` | Resolved import path for entity | `@entities/User` |
|
|
165
|
+
| `layer.features.slice` | Feature slice name (with prefix) | `ManageUser` |
|
|
166
|
+
| `layer.features.importPath` | Feature import path | `@features/ManageUser` |
|
|
167
|
+
| `layer.widget.slice` | Widget slice name | `User` |
|
|
168
|
+
| `layer.widget.importPath` | Widget import path | `@widgets/User` |
|
|
169
|
+
| `layer.page.slice` | Page slice name (with suffix) | `UserPage` |
|
|
170
|
+
| `layer.page.importPath` | Page import path | `@pages/UserPage` |
|
|
171
|
+
|
|
172
|
+
> **Note:** Paths vary based on your `aliases` configuration.
|
|
173
|
+
|
|
174
|
+
## 🔧 Advanced Preset Configuration
|
|
175
|
+
|
|
176
|
+
You can define sophisticated presets with custom logic, naming conventions, and routing.
|
|
177
|
+
|
|
178
|
+
**Example `preset.ts`:**
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { definePreset, createPresetHelpers } from '@starodubenko/fsd-gen';
|
|
182
|
+
|
|
183
|
+
export default definePreset(({ name, config }) => {
|
|
184
|
+
// Generate helpers with custom naming conventions
|
|
185
|
+
const helpers = createPresetHelpers(name, config, {
|
|
186
|
+
featurePrefix: 'Manage',
|
|
187
|
+
widgetSuffix: 'Widget',
|
|
188
|
+
pageSuffix: 'Page'
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
// Automatically scan folders in this preset directory
|
|
193
|
+
discoveryMode: 'auto',
|
|
194
|
+
|
|
195
|
+
// Expose helpers as variables to all templates
|
|
196
|
+
variables: {
|
|
197
|
+
...helpers,
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
// enforce naming conventions for discovery
|
|
201
|
+
conventions: {
|
|
202
|
+
featureSlicePrefix: 'Manage',
|
|
203
|
+
widgetSliceSuffix: 'Widget',
|
|
204
|
+
pageSliceSuffix: 'Page'
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
// Configure automatic routing (e.g. for App.tsx injection)
|
|
208
|
+
routing: {
|
|
209
|
+
path: `/${name.toLowerCase()}`,
|
|
210
|
+
}
|
|
211
|
+
};
|
|
56
212
|
});
|
|
57
213
|
```
|
|
58
214
|
|
|
215
|
+
**Available Variables (`GeneratorContext`) with Custom Config:**
|
|
216
|
+
|
|
217
|
+
Assuming input name is **"User"** and the configuration above:
|
|
218
|
+
|
|
219
|
+
| Variable | Description | Example Value |
|
|
220
|
+
| :--- | :--- | :--- |
|
|
221
|
+
| `base.name` | Original user input name | `User` |
|
|
222
|
+
| `layer.features.slice` | Feature slice name (prefix 'Manage') | `ManageUser` |
|
|
223
|
+
| `layer.features.importPath` | Feature import path | `@features/ManageUser` |
|
|
224
|
+
| `layer.widget.slice` | Widget slice name (suffix 'Widget') | `UserWidget` |
|
|
225
|
+
| `layer.widget.importPath` | Widget import path | `@widgets/UserWidget` |
|
|
226
|
+
| `layer.page.slice` | Page slice name (suffix 'Page') | `UserPage` |
|
|
227
|
+
| `layer.page.importPath` | Page import path | `@pages/UserPage` |
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
59
231
|
## License
|
|
60
232
|
|
|
61
233
|
MIT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineConfig.d.ts","sourceRoot":"","sources":["../../src/config/defineConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"defineConfig.d.ts","sourceRoot":"","sources":["../../src/config/defineConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAE/D"}
|
package/dist/config/types.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export interface PresetConfig {
|
|
|
77
77
|
/** Optional discovery mode ('auto' = scan directories, 'manual' = use actions array) */
|
|
78
78
|
discoveryMode?: (typeof DISCOVERY_MODES)[keyof typeof DISCOVERY_MODES];
|
|
79
79
|
/** Global variables available in all templates */
|
|
80
|
-
variables?: Record<string,
|
|
80
|
+
variables?: Record<string, any>;
|
|
81
81
|
/** Manual action definitions (required when discoveryMode is 'manual' or undefined) */
|
|
82
82
|
actions?: PresetAction[];
|
|
83
83
|
/** Convention overrides for auto-discovery mode */
|
|
@@ -95,4 +95,62 @@ export interface PresetConfigArgs {
|
|
|
95
95
|
export type PresetConfigFn = (args: PresetConfigArgs) => PresetConfig;
|
|
96
96
|
export declare function definePreset(config: PresetConfig): PresetConfig;
|
|
97
97
|
export declare function definePreset(config: PresetConfigFn): PresetConfigFn;
|
|
98
|
+
export interface TemplateContext extends Record<string, any> {
|
|
99
|
+
componentName: string;
|
|
100
|
+
sliceName: string;
|
|
101
|
+
template: {
|
|
102
|
+
componentName: string;
|
|
103
|
+
sliceName: string;
|
|
104
|
+
layer: string;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export interface PresetHelpers {
|
|
108
|
+
base: {
|
|
109
|
+
/** Base name (same as input name) */
|
|
110
|
+
name: string;
|
|
111
|
+
/** Base name alias */
|
|
112
|
+
baseName: string;
|
|
113
|
+
};
|
|
114
|
+
layer: {
|
|
115
|
+
entity: {
|
|
116
|
+
/** Import path for entity layer (with or without alias) */
|
|
117
|
+
importPath: string;
|
|
118
|
+
/** Import path for entity API (usually /ui or /api) */
|
|
119
|
+
apiPath: string;
|
|
120
|
+
};
|
|
121
|
+
features: {
|
|
122
|
+
/** Feature slice name */
|
|
123
|
+
slice: string;
|
|
124
|
+
/** Import path for feature layer */
|
|
125
|
+
importPath: string;
|
|
126
|
+
};
|
|
127
|
+
widget: {
|
|
128
|
+
/** Widget slice name */
|
|
129
|
+
slice: string;
|
|
130
|
+
/** Import path for widget layer */
|
|
131
|
+
importPath: string;
|
|
132
|
+
};
|
|
133
|
+
page: {
|
|
134
|
+
/** Page slice name */
|
|
135
|
+
slice: string;
|
|
136
|
+
/** Import path for page layer */
|
|
137
|
+
importPath: string;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export interface PresetHelperOptions {
|
|
142
|
+
/** Prefix for feature slice names (default: 'Manage') */
|
|
143
|
+
featurePrefix?: string;
|
|
144
|
+
/** Suffix for widget slice names (default: 'Table') */
|
|
145
|
+
widgetSuffix?: string;
|
|
146
|
+
/** Suffix for page slice names (default: 'Page') */
|
|
147
|
+
pageSuffix?: string;
|
|
148
|
+
}
|
|
149
|
+
export interface GeneratorContext extends PresetHelpers, Record<string, any> {
|
|
150
|
+
template: {
|
|
151
|
+
componentName: string;
|
|
152
|
+
sliceName: string;
|
|
153
|
+
layer: string;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
98
156
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAoB,MAAM,qBAAqB,CAAC;AAEhH,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEjE,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;CAC7D;AAED,eAAO,MAAM,aAAa,EAAE,YAI3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAEhF,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC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AAC;SACnB,CAAC;QACF,QAAQ,EAAE;YACN,yBAAyB;YACzB,KAAK,EAAE,MAAM,CAAC;YACd,oCAAoC;YACpC,UAAU,EAAE,MAAM,CAAC;SACtB,CAAC;QACF,MAAM,EAAE;YACJ,wBAAwB;YACxB,KAAK,EAAE,MAAM,CAAC;YACd,mCAAmC;YACnC,UAAU,EAAE,MAAM,CAAC;SACtB,CAAC;QACF,IAAI,EAAE;YACF,sBAAsB;YACtB,KAAK,EAAE,MAAM,CAAC;YACd,iCAAiC;YACjC,UAAU,EAAE,MAAM,CAAC;SACtB,CAAC;KACL,CAAC;CACL;AAED,MAAM,WAAW,mBAAmB;IAChC,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACxE,QAAQ,EAAE;QACN,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC;CACL"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { defineConfig } from './config/defineConfig.js';
|
|
2
|
-
export { definePreset, type PresetConfig, type PresetConfigArgs, type PresetConfigFn, type FsdGenConfig, type ConventionConfig, type PresetAction } from './config/types.js';
|
|
3
|
-
export { createPresetHelpers
|
|
2
|
+
export { definePreset, type PresetConfig, type PresetConfigArgs, type PresetConfigFn, type FsdGenConfig, type ConventionConfig, type PresetAction, type TemplateContext, type PresetHelpers, type PresetHelperOptions, type GeneratorContext } from './config/types.js';
|
|
3
|
+
export { createPresetHelpers } from './lib/helpers/presetHelpers.js';
|
|
4
4
|
//# 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":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACxQ,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { FsdPaths } from '../naming/resolvePaths.js';
|
|
2
2
|
import { ACTION_TYPES } from '../constants.js';
|
|
3
|
-
|
|
4
|
-
componentName: string;
|
|
5
|
-
sliceName: string;
|
|
6
|
-
layer: string;
|
|
7
|
-
}
|
|
3
|
+
import { TemplateContext } from '../../config/types.js';
|
|
8
4
|
/**
|
|
9
5
|
* Resolve which template to use for the given layer
|
|
10
6
|
* @returns Object with templatePath and layerArg for template loading
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/lib/generators/generate.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGrD,OAAO,EAAsE,YAAY,EAAE,MAAM,iBAAiB,CAAC;A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AAE,MAAM,iBAYtB;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,eAAe,EACxB,gBAAgB,CAAC,EAAE,MAAM,EACzB,YAAY,CAAC,EAAE,MAAM,iBA2BtB"}
|
|
@@ -83,8 +83,8 @@ export async function generateStyles(paths, context, templatePath, templatesDir)
|
|
|
83
83
|
*/
|
|
84
84
|
export async function generateComponent(paths, context, templateOverride, templatesDir) {
|
|
85
85
|
// Step 1: Resolve template type
|
|
86
|
-
const { templatePath, layerArg } = resolveTemplateType(context.layer, templateOverride);
|
|
87
|
-
console.log(`Using template: ${templateOverride ? templatePath : context.layer + '/' + templatePath}`);
|
|
86
|
+
const { templatePath, layerArg } = resolveTemplateType(context.template.layer, templateOverride);
|
|
87
|
+
console.log(`Using template: ${templateOverride ? templatePath : context.template.layer + '/' + templatePath}`);
|
|
88
88
|
// Step 2: Get templates directory
|
|
89
89
|
const effectiveTemplatesDir = templatesDir || (await loadConfig()).templatesDir;
|
|
90
90
|
// Step 3: Load template
|
|
@@ -4,33 +4,7 @@
|
|
|
4
4
|
* Provides utility functions for creating preset helpers that standardize naming conventions,
|
|
5
5
|
* path resolution, and variable generation for preset authors.
|
|
6
6
|
*/
|
|
7
|
-
import { FsdGenConfig } from '../../config/types.js';
|
|
8
|
-
export interface PresetHelpers {
|
|
9
|
-
/** Base name (same as input name) */
|
|
10
|
-
baseName: string;
|
|
11
|
-
/** Import path for entity layer (with or without alias) */
|
|
12
|
-
entityImportPath: string;
|
|
13
|
-
/** Feature slice name (e.g., 'ManageUser') */
|
|
14
|
-
featureSlice: string;
|
|
15
|
-
/** Import path for feature layer */
|
|
16
|
-
featureImportPath: string;
|
|
17
|
-
/** Widget slice name (e.g., 'UserTable') */
|
|
18
|
-
widgetSlice: string;
|
|
19
|
-
/** Import path for widget layer */
|
|
20
|
-
widgetImportPath: string;
|
|
21
|
-
/** Page slice name (e.g., 'UserPage') */
|
|
22
|
-
pageSlice: string;
|
|
23
|
-
/** Import path for page layer */
|
|
24
|
-
pageImportPath: string;
|
|
25
|
-
}
|
|
26
|
-
export interface PresetHelperOptions {
|
|
27
|
-
/** Prefix for feature slice names (default: 'Manage') */
|
|
28
|
-
featurePrefix?: string;
|
|
29
|
-
/** Suffix for widget slice names (default: 'Table') */
|
|
30
|
-
widgetSuffix?: string;
|
|
31
|
-
/** Suffix for page slice names (default: 'Page') */
|
|
32
|
-
pageSuffix?: string;
|
|
33
|
-
}
|
|
7
|
+
import type { FsdGenConfig, PresetHelpers, PresetHelperOptions } from '../../config/types.js';
|
|
34
8
|
/**
|
|
35
9
|
* Helper function to resolve import paths and slice names for presets.
|
|
36
10
|
* Automatically handles FSD layer aliases if configured.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presetHelpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers/presetHelpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"presetHelpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers/presetHelpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,mBAAwB,GAClC,aAAa,CA0Df"}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export function createPresetHelpers(name, config, options = {}) {
|
|
22
|
-
const { featurePrefix = 'Manage', widgetSuffix = '
|
|
22
|
+
const { featurePrefix = 'Manage', widgetSuffix = '', pageSuffix = 'Page' } = options;
|
|
23
23
|
const aliases = config.aliases || {};
|
|
24
24
|
const hasEntAlias = !!aliases['@entities'];
|
|
25
25
|
const hasFeatAlias = !!aliases['@features'];
|
|
@@ -28,6 +28,7 @@ export function createPresetHelpers(name, config, options = {}) {
|
|
|
28
28
|
const entityImportPath = hasEntAlias
|
|
29
29
|
? `@entities/${name}`
|
|
30
30
|
: `../../../entities/${name}`;
|
|
31
|
+
const apiImportPath = `${entityImportPath}/ui`;
|
|
31
32
|
const featureSlice = `${featurePrefix}${name}`;
|
|
32
33
|
const featureImportPath = hasFeatAlias
|
|
33
34
|
? `@features/${featureSlice}`
|
|
@@ -41,13 +42,27 @@ export function createPresetHelpers(name, config, options = {}) {
|
|
|
41
42
|
? `@pages/${pageSlice}`
|
|
42
43
|
: `../../../pages/${pageSlice}`;
|
|
43
44
|
return {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
base: {
|
|
46
|
+
baseName: name,
|
|
47
|
+
name,
|
|
48
|
+
},
|
|
49
|
+
layer: {
|
|
50
|
+
entity: {
|
|
51
|
+
importPath: entityImportPath,
|
|
52
|
+
apiPath: apiImportPath,
|
|
53
|
+
},
|
|
54
|
+
features: {
|
|
55
|
+
slice: featureSlice,
|
|
56
|
+
importPath: featureImportPath,
|
|
57
|
+
},
|
|
58
|
+
widget: {
|
|
59
|
+
slice: widgetSlice,
|
|
60
|
+
importPath: widgetImportPath,
|
|
61
|
+
},
|
|
62
|
+
page: {
|
|
63
|
+
slice: pageSlice,
|
|
64
|
+
importPath: pageImportPath,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
52
67
|
};
|
|
53
68
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presetHelpers.spec.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers/presetHelpers.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createPresetHelpers } from './presetHelpers';
|
|
3
|
+
describe('presetHelpers', () => {
|
|
4
|
+
describe('createPresetHelpers', () => {
|
|
5
|
+
it('should return all required PresetHelpers fields', () => {
|
|
6
|
+
const name = 'TestEntity';
|
|
7
|
+
const config = {
|
|
8
|
+
rootDir: 'src',
|
|
9
|
+
aliases: { '@': './src' }
|
|
10
|
+
};
|
|
11
|
+
const helpers = createPresetHelpers(name, config);
|
|
12
|
+
expect(helpers).toHaveProperty('base');
|
|
13
|
+
expect(helpers).toHaveProperty('layer');
|
|
14
|
+
expect(helpers.base).toHaveProperty('name');
|
|
15
|
+
expect(helpers.layer).toHaveProperty('entity');
|
|
16
|
+
expect(helpers.layer).toHaveProperty('features');
|
|
17
|
+
expect(helpers.layer).toHaveProperty('widget');
|
|
18
|
+
expect(helpers.layer).toHaveProperty('page');
|
|
19
|
+
});
|
|
20
|
+
it('should correctly format paths and names with defaults', () => {
|
|
21
|
+
const name = 'User';
|
|
22
|
+
const config = {};
|
|
23
|
+
const helpers = createPresetHelpers(name, config);
|
|
24
|
+
expect(helpers.base.baseName).toBe('User');
|
|
25
|
+
expect(helpers.base.name).toBe('User');
|
|
26
|
+
expect(helpers.layer.entity.importPath).toBe('../../../entities/User');
|
|
27
|
+
expect(helpers.layer.entity.apiPath).toBe('../../../entities/User/ui');
|
|
28
|
+
expect(helpers.layer.features.slice).toBe('ManageUser');
|
|
29
|
+
expect(helpers.layer.features.importPath).toBe('../../../features/ManageUser');
|
|
30
|
+
expect(helpers.layer.widget.slice).toBe('UserTable');
|
|
31
|
+
expect(helpers.layer.widget.importPath).toBe('../../../widgets/UserTable');
|
|
32
|
+
expect(helpers.layer.page.slice).toBe('UserPage');
|
|
33
|
+
expect(helpers.layer.page.importPath).toBe('../../../pages/UserPage');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tagged template literal helper for TSX syntax highlighting.
|
|
3
|
+
* Returns the exact string content (identity function).
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { tsx } from '@starodubenko/fsd-gen';
|
|
8
|
+
*
|
|
9
|
+
* const template = tsx\`
|
|
10
|
+
* export const Component = () => <div>Hello</div>;
|
|
11
|
+
* \`;
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function tsx(strings: TemplateStringsArray, ...values: any[]): string;
|
|
15
|
+
/**
|
|
16
|
+
* Tagged template literal helper for CSS syntax highlighting.
|
|
17
|
+
* Returns the exact string content (identity function).
|
|
18
|
+
*/
|
|
19
|
+
export declare function css(strings: TemplateStringsArray, ...values: any[]): string;
|
|
20
|
+
//# sourceMappingURL=templateHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateHelpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers/templateHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAE3E;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAE3E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tagged template literal helper for TSX syntax highlighting.
|
|
3
|
+
* Returns the exact string content (identity function).
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { tsx } from '@starodubenko/fsd-gen';
|
|
8
|
+
*
|
|
9
|
+
* const template = tsx\`
|
|
10
|
+
* export const Component = () => <div>Hello</div>;
|
|
11
|
+
* \`;
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export function tsx(strings, ...values) {
|
|
15
|
+
return String.raw({ raw: strings }, ...values);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Tagged template literal helper for CSS syntax highlighting.
|
|
19
|
+
* Returns the exact string content (identity function).
|
|
20
|
+
*/
|
|
21
|
+
export function css(strings, ...values) {
|
|
22
|
+
return String.raw({ raw: strings }, ...values);
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const File: ({ children }: {
|
|
2
|
+
children: any;
|
|
3
|
+
}) => any;
|
|
4
|
+
export declare const Pragma: ({ text }: {
|
|
5
|
+
text: string;
|
|
6
|
+
}) => string;
|
|
7
|
+
export declare const Import: ({ default: defaultImport, named, from }: {
|
|
8
|
+
default?: string;
|
|
9
|
+
named?: string | string[];
|
|
10
|
+
from: string;
|
|
11
|
+
}) => string;
|
|
12
|
+
export declare const Const: ({ name, type, value, export: isExport, children }: {
|
|
13
|
+
name: string;
|
|
14
|
+
type?: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
export?: boolean;
|
|
17
|
+
children?: any;
|
|
18
|
+
}) => string;
|
|
19
|
+
export declare const Interface: ({ name, export: isExport, children }: {
|
|
20
|
+
name: string;
|
|
21
|
+
export?: boolean;
|
|
22
|
+
children: any;
|
|
23
|
+
}) => string;
|
|
24
|
+
export declare const Function: ({ name, params, returnType, export: isExport, children }: {
|
|
25
|
+
name: string;
|
|
26
|
+
params?: string;
|
|
27
|
+
returnType?: string;
|
|
28
|
+
export?: boolean;
|
|
29
|
+
children: any;
|
|
30
|
+
}) => string;
|
|
31
|
+
export declare const ArrowFunction: ({ name, params, returnType, export: isExport, children }: {
|
|
32
|
+
name: string;
|
|
33
|
+
params?: string;
|
|
34
|
+
returnType?: string;
|
|
35
|
+
export?: boolean;
|
|
36
|
+
children: any;
|
|
37
|
+
}) => string;
|
|
38
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/lib/jsx/components.ts"],"names":[],"mappings":"AAC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
return Array.isArray(children) ? children.join('\n') : children;
|
|
3
|
+
};
|
|
4
|
+
export const Pragma = ({ text }) => {
|
|
5
|
+
return `"${text}";\n`;
|
|
6
|
+
};
|
|
7
|
+
export const Import = ({ default: defaultImport, named, from }) => {
|
|
8
|
+
const parts = [];
|
|
9
|
+
if (defaultImport)
|
|
10
|
+
parts.push(defaultImport);
|
|
11
|
+
if (named) {
|
|
12
|
+
if (Array.isArray(named)) {
|
|
13
|
+
parts.push(`{ ${named.join(', ')} }`);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
parts.push(`{ ${named} }`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return `import ${parts.join(', ')} from '${from}';`;
|
|
20
|
+
};
|
|
21
|
+
export const Const = ({ name, type, value, export: isExport, children }) => {
|
|
22
|
+
const prefix = isExport ? 'export const' : 'const';
|
|
23
|
+
const typeStr = type ? `: ${type}` : '';
|
|
24
|
+
const content = children || value;
|
|
25
|
+
return `${prefix} ${name}${typeStr} = ${content};`;
|
|
26
|
+
};
|
|
27
|
+
export const Interface = ({ name, export: isExport, children }) => {
|
|
28
|
+
const prefix = isExport ? 'export interface' : 'interface';
|
|
29
|
+
return `${prefix} ${name} {\n${children}\n}`;
|
|
30
|
+
};
|
|
31
|
+
export const Function = ({ name, params, returnType, export: isExport, children }) => {
|
|
32
|
+
const prefix = isExport ? 'export function' : 'function';
|
|
33
|
+
const ret = returnType ? `: ${returnType}` : '';
|
|
34
|
+
return `${prefix} ${name}(${params || ''})${ret} {\n${children}\n}`;
|
|
35
|
+
};
|
|
36
|
+
export const ArrowFunction = ({ name, params, returnType, export: isExport, children }) => {
|
|
37
|
+
const prefix = isExport ? 'export const' : 'const';
|
|
38
|
+
const ret = returnType ? `: ${returnType}` : '';
|
|
39
|
+
return `${prefix} ${name} = (${params || ''})${ret} => {\n${children}\n};`;
|
|
40
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare namespace JSX {
|
|
2
|
+
interface IntrinsicElements {
|
|
3
|
+
[elemName: string]: any;
|
|
4
|
+
}
|
|
5
|
+
interface ElementClass {
|
|
6
|
+
render: any;
|
|
7
|
+
}
|
|
8
|
+
interface ElementChildrenAttribute {
|
|
9
|
+
children: {};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export interface VNode {
|
|
13
|
+
type: any;
|
|
14
|
+
props: any;
|
|
15
|
+
key?: any;
|
|
16
|
+
}
|
|
17
|
+
export declare function jsx(type: any, props: any, key?: any): VNode;
|
|
18
|
+
export declare function jsxs(type: any, props: any, key?: any): VNode;
|
|
19
|
+
export declare const Fragment: unique symbol;
|
|
20
|
+
//# sourceMappingURL=jsx-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../../src/lib/jsx/jsx-runtime.ts"],"names":[],"mappings":"AAAA,yBAAiB,GAAG,CAAC;IACjB,UAAiB,iBAAiB;QAC9B,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;KAC3B;IACD,UAAiB,YAAY;QACzB,MAAM,EAAE,GAAG,CAAC;KACf;IACD,UAAiB,wBAAwB;QACrC,QAAQ,EAAE,EAAE,CAAC;KAChB;CACJ;AAED,MAAM,WAAW,KAAK;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,GAAG,CAAC;IACX,GAAG,CAAC,EAAE,GAAG,CAAC;CACb;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAE3D;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAE5D;AAED,eAAO,MAAM,QAAQ,eAAiC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../src/lib/jsx/renderer.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CA6BxC"}
|