@domain-first/project-structure 2.7.4 → 2.8.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 +5 -1
- package/dist/config-file.d.ts +1 -0
- package/dist/index.cjs +52 -2
- package/dist/index.js +52 -2
- package/dist/unknown-format-naming.spec.d.ts +1 -0
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/scaffold-react-ui-kit-component.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,7 +117,8 @@ src/
|
|
|
117
117
|
├── rest/
|
|
118
118
|
└── react/
|
|
119
119
|
├── pages/
|
|
120
|
-
|
|
120
|
+
├── widgets/
|
|
121
|
+
└── ui-kit/
|
|
121
122
|
```
|
|
122
123
|
|
|
123
124
|
This is an example of the accumulated output; creating a context alone creates its directory and, when enabled, its error namespace.
|
|
@@ -184,6 +185,7 @@ Enable `useReact` and choose **Scaffold React module** from the main menu. Modul
|
|
|
184
185
|
| New widget → monolithic | `widgets/<name>/index.tsx` with props and rendering in one file. |
|
|
185
186
|
| New widget → with separated ui | Widget entry point, `types.ts`, `ui/index.tsx`, and `hooks/use-ui-model.ts`. |
|
|
186
187
|
| New widget → headless | Widget entry point, types, and a UI-model hook; the rendering component is supplied through the `UI` prop. |
|
|
188
|
+
| New UI-kit component | `ui-kit/<name>/index.tsx` with a typed props object and a component; with `storybookFramework`, also `<name>.stories.tsx`. |
|
|
187
189
|
|
|
188
190
|
## Configuration
|
|
189
191
|
|
|
@@ -201,6 +203,7 @@ The project configuration is stored in `domain-first.project-structure.config.js
|
|
|
201
203
|
],
|
|
202
204
|
"defaultPersistenceLayerImplementation": "prisma",
|
|
203
205
|
"useReact": true,
|
|
206
|
+
"storybookFramework": "@storybook/react-vite",
|
|
204
207
|
"testingLibrary": "vitest"
|
|
205
208
|
}
|
|
206
209
|
```
|
|
@@ -211,6 +214,7 @@ The project configuration is stored in `domain-first.project-structure.config.js
|
|
|
211
214
|
| `domainFirstPackages` | Explicit list of integrations used by templates. An empty array selects basic class templates where supported. |
|
|
212
215
|
| `defaultPersistenceLayerImplementation` | Suggested implementation label for execution commands and queries. |
|
|
213
216
|
| `useReact` | Shows or hides the React module menu. |
|
|
217
|
+
| `storybookFramework` | Storybook framework package imported by generated stories (`Meta`, `StoryObj`), e.g. `@storybook/react-vite`. Omit this field to skip stories for UI-kit components. Asked during setup only when React is enabled. |
|
|
214
218
|
| `testingLibrary` | Module imported by generated tests. Omit this field to disable test prompts. Templates expect helpers such as `describe`, `test`, `expect`, and `beforeEach`. |
|
|
215
219
|
|
|
216
220
|
### Package integrations
|
package/dist/config-file.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ declare const configSchema: z.ZodObject<{
|
|
|
10
10
|
}>>;
|
|
11
11
|
defaultPersistenceLayerImplementation: z.ZodString;
|
|
12
12
|
useReact: z.ZodBoolean;
|
|
13
|
+
storybookFramework: z.ZodOptional<z.ZodString>;
|
|
13
14
|
testingLibrary: z.ZodOptional<z.ZodString>;
|
|
14
15
|
}, z.core.$strip>;
|
|
15
16
|
export declare class ConfigFile {
|
package/dist/index.cjs
CHANGED
|
@@ -126,6 +126,7 @@ const configSchema = external_zod_default().object({
|
|
|
126
126
|
])),
|
|
127
127
|
defaultPersistenceLayerImplementation: external_zod_default().string(),
|
|
128
128
|
useReact: external_zod_default().boolean(),
|
|
129
|
+
storybookFramework: external_zod_default().string().optional(),
|
|
129
130
|
testingLibrary: external_zod_default().string().optional()
|
|
130
131
|
});
|
|
131
132
|
class ConfigFile {
|
|
@@ -171,6 +172,14 @@ const initializeUseCase = async ()=>{
|
|
|
171
172
|
const useReact = await (0, prompts_namespaceObject.confirm)({
|
|
172
173
|
message: 'Use React'
|
|
173
174
|
});
|
|
175
|
+
let storybookFramework;
|
|
176
|
+
const withStorybook = useReact ? await (0, prompts_namespaceObject.confirm)({
|
|
177
|
+
message: 'Use Storybook'
|
|
178
|
+
}) : false;
|
|
179
|
+
if (withStorybook) storybookFramework = await (0, prompts_namespaceObject.input)({
|
|
180
|
+
message: 'Storybook framework package:',
|
|
181
|
+
default: '@storybook/react-vite'
|
|
182
|
+
});
|
|
174
183
|
let testingLibrary;
|
|
175
184
|
const withTests = await (0, prompts_namespaceObject.confirm)({
|
|
176
185
|
message: 'Scaffold unit tests'
|
|
@@ -184,6 +193,7 @@ const initializeUseCase = async ()=>{
|
|
|
184
193
|
domainFirstPackages,
|
|
185
194
|
defaultPersistenceLayerImplementation,
|
|
186
195
|
useReact,
|
|
196
|
+
storybookFramework,
|
|
187
197
|
testingLibrary
|
|
188
198
|
});
|
|
189
199
|
const { path } = new ProjectRoot();
|
|
@@ -222,7 +232,7 @@ class UnknownFormatNaming {
|
|
|
222
232
|
this.camelCase = source.substring(0, 1).toLowerCase() + source.substring(1);
|
|
223
233
|
this.PascalCase = source.substring(0, 1).toUpperCase() + source.substring(1);
|
|
224
234
|
}
|
|
225
|
-
const words = source.split('-');
|
|
235
|
+
const words = source.split('-').filter((word)=>!!word);
|
|
226
236
|
this.camelCase = words.map((word, index)=>0 === index ? word.toLowerCase() : word[0].toUpperCase() + word.slice(1).toLowerCase()).join('');
|
|
227
237
|
this.PascalCase = words.map((word)=>word[0].toUpperCase() + word.slice(1).toLowerCase()).join('');
|
|
228
238
|
}
|
|
@@ -1286,6 +1296,43 @@ export const ${ClassName}Page: FC<${ClassName}PageProps> = (props) => {
|
|
|
1286
1296
|
}
|
|
1287
1297
|
`.trim());
|
|
1288
1298
|
};
|
|
1299
|
+
const scaffoldReactUIKitComponent = async (presentationReactFolder)=>{
|
|
1300
|
+
const name = await (0, prompts_namespaceObject.input)({
|
|
1301
|
+
message: 'Name: '
|
|
1302
|
+
});
|
|
1303
|
+
const { ClassName, fileName } = new UnknownFormatNaming(name);
|
|
1304
|
+
const componentFolder = presentationReactFolder.subitem([
|
|
1305
|
+
'ui-kit',
|
|
1306
|
+
fileName
|
|
1307
|
+
]);
|
|
1308
|
+
componentFolder.createFile('index.tsx', `
|
|
1309
|
+
import { type FC } from 'react'
|
|
1310
|
+
|
|
1311
|
+
export type ${ClassName}Props = {}
|
|
1312
|
+
|
|
1313
|
+
export const ${ClassName}: FC<${ClassName}Props> = (props) => {
|
|
1314
|
+
return <></>
|
|
1315
|
+
}
|
|
1316
|
+
`.trim());
|
|
1317
|
+
const { storybookFramework } = ConfigFile.Instance.data;
|
|
1318
|
+
if (storybookFramework) componentFolder.createFile(`${fileName}.stories.tsx`, `
|
|
1319
|
+
import type { Meta, StoryObj } from '${storybookFramework}'
|
|
1320
|
+
import { ${ClassName} } from '.'
|
|
1321
|
+
|
|
1322
|
+
const meta = {
|
|
1323
|
+
title: 'UI-kit/${ClassName}',
|
|
1324
|
+
component: ${ClassName}
|
|
1325
|
+
} satisfies Meta<typeof ${ClassName}>
|
|
1326
|
+
|
|
1327
|
+
export default meta
|
|
1328
|
+
|
|
1329
|
+
type Story = StoryObj<typeof meta>
|
|
1330
|
+
|
|
1331
|
+
export const Default: Story = {
|
|
1332
|
+
args: {}
|
|
1333
|
+
}
|
|
1334
|
+
`.trim());
|
|
1335
|
+
};
|
|
1289
1336
|
const scaffoldReactWidget = async (presentationReactFolder)=>{
|
|
1290
1337
|
const widgetName = await (0, prompts_namespaceObject.input)({
|
|
1291
1338
|
message: 'Name: '
|
|
@@ -1432,7 +1479,8 @@ const main = async ()=>{
|
|
|
1432
1479
|
message: 'Module: ',
|
|
1433
1480
|
choices: [
|
|
1434
1481
|
'New widget',
|
|
1435
|
-
'New page'
|
|
1482
|
+
'New page',
|
|
1483
|
+
'New UI-kit component'
|
|
1436
1484
|
]
|
|
1437
1485
|
});
|
|
1438
1486
|
switch(action){
|
|
@@ -1440,6 +1488,8 @@ const main = async ()=>{
|
|
|
1440
1488
|
return void await scaffoldReactWidget(reactFolder);
|
|
1441
1489
|
case 'New page':
|
|
1442
1490
|
return void await scaffoldReactPage(reactFolder);
|
|
1491
|
+
case 'New UI-kit component':
|
|
1492
|
+
return void await scaffoldReactUIKitComponent(reactFolder);
|
|
1443
1493
|
default:
|
|
1444
1494
|
return;
|
|
1445
1495
|
}
|
package/dist/index.js
CHANGED
|
@@ -96,6 +96,7 @@ const configSchema = zod.object({
|
|
|
96
96
|
])),
|
|
97
97
|
defaultPersistenceLayerImplementation: zod.string(),
|
|
98
98
|
useReact: zod.boolean(),
|
|
99
|
+
storybookFramework: zod.string().optional(),
|
|
99
100
|
testingLibrary: zod.string().optional()
|
|
100
101
|
});
|
|
101
102
|
class ConfigFile {
|
|
@@ -141,6 +142,14 @@ const initializeUseCase = async ()=>{
|
|
|
141
142
|
const useReact = await prompts_confirm({
|
|
142
143
|
message: 'Use React'
|
|
143
144
|
});
|
|
145
|
+
let storybookFramework;
|
|
146
|
+
const withStorybook = useReact ? await prompts_confirm({
|
|
147
|
+
message: 'Use Storybook'
|
|
148
|
+
}) : false;
|
|
149
|
+
if (withStorybook) storybookFramework = await input({
|
|
150
|
+
message: 'Storybook framework package:',
|
|
151
|
+
default: '@storybook/react-vite'
|
|
152
|
+
});
|
|
144
153
|
let testingLibrary;
|
|
145
154
|
const withTests = await prompts_confirm({
|
|
146
155
|
message: 'Scaffold unit tests'
|
|
@@ -154,6 +163,7 @@ const initializeUseCase = async ()=>{
|
|
|
154
163
|
domainFirstPackages,
|
|
155
164
|
defaultPersistenceLayerImplementation,
|
|
156
165
|
useReact,
|
|
166
|
+
storybookFramework,
|
|
157
167
|
testingLibrary
|
|
158
168
|
});
|
|
159
169
|
const { path } = new ProjectRoot();
|
|
@@ -192,7 +202,7 @@ class UnknownFormatNaming {
|
|
|
192
202
|
this.camelCase = source.substring(0, 1).toLowerCase() + source.substring(1);
|
|
193
203
|
this.PascalCase = source.substring(0, 1).toUpperCase() + source.substring(1);
|
|
194
204
|
}
|
|
195
|
-
const words = source.split('-');
|
|
205
|
+
const words = source.split('-').filter((word)=>!!word);
|
|
196
206
|
this.camelCase = words.map((word, index)=>0 === index ? word.toLowerCase() : word[0].toUpperCase() + word.slice(1).toLowerCase()).join('');
|
|
197
207
|
this.PascalCase = words.map((word)=>word[0].toUpperCase() + word.slice(1).toLowerCase()).join('');
|
|
198
208
|
}
|
|
@@ -1256,6 +1266,43 @@ export const ${ClassName}Page: FC<${ClassName}PageProps> = (props) => {
|
|
|
1256
1266
|
}
|
|
1257
1267
|
`.trim());
|
|
1258
1268
|
};
|
|
1269
|
+
const scaffoldReactUIKitComponent = async (presentationReactFolder)=>{
|
|
1270
|
+
const name = await input({
|
|
1271
|
+
message: 'Name: '
|
|
1272
|
+
});
|
|
1273
|
+
const { ClassName, fileName } = new UnknownFormatNaming(name);
|
|
1274
|
+
const componentFolder = presentationReactFolder.subitem([
|
|
1275
|
+
'ui-kit',
|
|
1276
|
+
fileName
|
|
1277
|
+
]);
|
|
1278
|
+
componentFolder.createFile('index.tsx', `
|
|
1279
|
+
import { type FC } from 'react'
|
|
1280
|
+
|
|
1281
|
+
export type ${ClassName}Props = {}
|
|
1282
|
+
|
|
1283
|
+
export const ${ClassName}: FC<${ClassName}Props> = (props) => {
|
|
1284
|
+
return <></>
|
|
1285
|
+
}
|
|
1286
|
+
`.trim());
|
|
1287
|
+
const { storybookFramework } = ConfigFile.Instance.data;
|
|
1288
|
+
if (storybookFramework) componentFolder.createFile(`${fileName}.stories.tsx`, `
|
|
1289
|
+
import type { Meta, StoryObj } from '${storybookFramework}'
|
|
1290
|
+
import { ${ClassName} } from '.'
|
|
1291
|
+
|
|
1292
|
+
const meta = {
|
|
1293
|
+
title: 'UI-kit/${ClassName}',
|
|
1294
|
+
component: ${ClassName}
|
|
1295
|
+
} satisfies Meta<typeof ${ClassName}>
|
|
1296
|
+
|
|
1297
|
+
export default meta
|
|
1298
|
+
|
|
1299
|
+
type Story = StoryObj<typeof meta>
|
|
1300
|
+
|
|
1301
|
+
export const Default: Story = {
|
|
1302
|
+
args: {}
|
|
1303
|
+
}
|
|
1304
|
+
`.trim());
|
|
1305
|
+
};
|
|
1259
1306
|
const scaffoldReactWidget = async (presentationReactFolder)=>{
|
|
1260
1307
|
const widgetName = await input({
|
|
1261
1308
|
message: 'Name: '
|
|
@@ -1402,7 +1449,8 @@ const main = async ()=>{
|
|
|
1402
1449
|
message: 'Module: ',
|
|
1403
1450
|
choices: [
|
|
1404
1451
|
'New widget',
|
|
1405
|
-
'New page'
|
|
1452
|
+
'New page',
|
|
1453
|
+
'New UI-kit component'
|
|
1406
1454
|
]
|
|
1407
1455
|
});
|
|
1408
1456
|
switch(action){
|
|
@@ -1410,6 +1458,8 @@ const main = async ()=>{
|
|
|
1410
1458
|
return void await scaffoldReactWidget(reactFolder);
|
|
1411
1459
|
case 'New page':
|
|
1412
1460
|
return void await scaffoldReactPage(reactFolder);
|
|
1461
|
+
case 'New UI-kit component':
|
|
1462
|
+
return void await scaffoldReactUIKitComponent(reactFolder);
|
|
1413
1463
|
default:
|
|
1414
1464
|
return;
|
|
1415
1465
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,4 +12,5 @@ export * from './scaffold-new-presentation-service';
|
|
|
12
12
|
export * from './scaffold-new-query';
|
|
13
13
|
export * from './scaffold-new-use-case';
|
|
14
14
|
export * from './scaffold-react-page';
|
|
15
|
+
export * from './scaffold-react-ui-kit-component';
|
|
15
16
|
export * from './scaffold-react-widget';
|