@domain-first/project-structure 2.7.5 → 2.8.1

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 CHANGED
@@ -52,7 +52,7 @@ On the first run, the CLI asks for:
52
52
  | `@domain-first` packages | The integrations to use in generated templates. |
53
53
  | Default persistence implementation | A label such as `prisma`, used as the suggested implementation for execution commands and queries. |
54
54
  | React | Whether to show the React module menu. |
55
- | Unit tests | Whether to offer test generation, and which module to import test helpers from. Suggested module: `vitest`. |
55
+ | Unit tests | Whether to generate tests, and which module to import test helpers from. Suggested module: `vitest`. |
56
56
 
57
57
  Setup writes `domain-first.project-structure.config.json` beside your `package.json` and creates shared helpers for the selected `wire` and `errors` integrations. That first run then exits.
58
58
 
@@ -117,7 +117,8 @@ src/
117
117
  ├── rest/
118
118
  └── react/
119
119
  ├── pages/
120
- └── widgets/
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.
@@ -160,7 +161,7 @@ With `@domain-first/wire`, generators create `wireClass` factories. Repositories
160
161
 
161
162
  Implementation names such as `prisma`, `api`, `in-memory`, and `mock` determine names and locations for generated classes. Add the database queries, API calls, or in-memory behavior yourself. Fill in the dependency lists in wiring factories as you implement constructors.
162
163
 
163
- When `testingLibrary` is configured, supported generators ask whether to add `.spec.ts` files. These start with construction or wiring checks; extend them with tests for your business behavior. Repository, command, query, and port test templates reference wiring factories, so use the wiring integration or adapt those tests to your own construction setup.
164
+ When `testingLibrary` is configured, supported generators always add `.spec.ts` files. These start with construction or wiring checks; extend them with tests for your business behavior. Repository, command, query, and port test templates reference wiring factories, so use the wiring integration or adapt those tests to your own construction setup.
164
165
 
165
166
  ### REST endpoints
166
167
 
@@ -181,9 +182,10 @@ Enable `useReact` and choose **Scaffold React module** from the main menu. Modul
181
182
  | Generator | Output |
182
183
  | ------------------------------ | ---------------------------------------------------------------------------------------------------------- |
183
184
  | New page | `pages/<name>-page.tsx` with a typed props object and a component. |
184
- | New widget → monolithic | `widgets/<name>/index.tsx` with props and rendering in one file. |
185
- | New widget → with separated ui | Widget entry point, `types.ts`, `ui/index.tsx`, and `hooks/use-ui-model.ts`. |
186
- | New widget → headless | Widget entry point, types, and a UI-model hook; the rendering component is supplied through the `UI` prop. |
185
+ | New widget → monolithic | `widgets/<name>/<name>-widget.tsx` with props and rendering in one file, re-exported from `index.ts`. |
186
+ | New widget → with separated ui | `<name>-widget.tsx`, `types.ts`, `ui/<name>-widget-ui.tsx`, `hooks/use-<name>-ui-model.ts`, and `index.ts`. |
187
+ | New widget → headless | `<name>-widget.tsx`, types, a UI-model hook, and `index.ts`; the rendering component is supplied through the `UI` prop. |
188
+ | New UI-kit component | `ui-kit/<name>/<name>.tsx` with a typed props object and a component, re-exported from `index.ts`; 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,7 +214,8 @@ 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. |
214
- | `testingLibrary` | Module imported by generated tests. Omit this field to disable test prompts. Templates expect helpers such as `describe`, `test`, `expect`, and `beforeEach`. |
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. |
218
+ | `testingLibrary` | Module imported by generated tests. Omit this field to disable test generation. Templates expect helpers such as `describe`, `test`, `expect`, and `beforeEach`. |
215
219
 
216
220
  ### Package integrations
217
221
 
@@ -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();
@@ -244,10 +254,7 @@ const scaffoldNewAggregateUseCase = async (boundedContextFolder)=>{
244
254
  message: 'Aggregate name:'
245
255
  });
246
256
  const aggregateNaming = new UnknownFormatNaming(aggregateName);
247
- let scaffoldUnitTests;
248
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
249
- message: 'Scaffold unit-tests'
250
- });
257
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
251
258
  const withRepository = await (0, prompts_namespaceObject.confirm)({
252
259
  message: 'With Repository'
253
260
  });
@@ -365,10 +372,7 @@ const scaffoldNewApplicationPort = async (boundedContextFolder)=>{
365
372
  message: 'Name: '
366
373
  });
367
374
  const naming = new UnknownFormatNaming(name);
368
- let scaffoldUnitTests;
369
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
370
- message: 'Scaffold unit-tests'
371
- });
375
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
372
376
  const wiringFolder = boundedContextFolder.subitem([
373
377
  'wiring',
374
378
  'application-ports'
@@ -462,10 +466,7 @@ const scaffoldNewApplicationService = async (boundedContextFolder)=>{
462
466
  message: 'Name: '
463
467
  });
464
468
  const naming = new UnknownFormatNaming(name);
465
- let scaffoldUnitTests;
466
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
467
- message: 'Scaffold unit-tests'
468
- });
469
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
469
470
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
470
471
  const wiringFolder = boundedContextFolder.subitem([
471
472
  'wiring',
@@ -541,10 +542,7 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
541
542
  const commandName = await (0, prompts_namespaceObject.input)({
542
543
  message: 'Name: '
543
544
  });
544
- let scaffoldUnitTests;
545
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
546
- message: 'Scaffold unit-tests'
547
- });
545
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
548
546
  const naming = new UnknownFormatNaming(commandName);
549
547
  const commandType = await (0, prompts_namespaceObject.select)({
550
548
  choices: [
@@ -726,10 +724,7 @@ const scaffoldNewDomainService = async (boundedContextFolder)=>{
726
724
  message: 'Name:'
727
725
  });
728
726
  const naming = new UnknownFormatNaming(portName);
729
- let scaffoldUnitTests;
730
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
731
- message: 'Scaffold unit-tests'
732
- });
727
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
733
728
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
734
729
  const domainServicesFolder = boundedContextFolder.subitem([
735
730
  'domain',
@@ -915,10 +910,7 @@ const scaffoldNewInfrastructureService = async (boundedContextFolder)=>{
915
910
  message: 'Name: '
916
911
  });
917
912
  const naming = new UnknownFormatNaming(name);
918
- let scaffoldUnitTests;
919
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
920
- message: 'Scaffold unit-tests'
921
- });
913
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
922
914
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
923
915
  const wiringFolder = boundedContextFolder.subitem([
924
916
  'wiring',
@@ -965,10 +957,7 @@ const scaffoldNewPresentationService = async (boundedContextFolder)=>{
965
957
  message: 'Name: '
966
958
  });
967
959
  const naming = new UnknownFormatNaming(name);
968
- let scaffoldUnitTests;
969
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
970
- message: 'Scaffold unit-tests'
971
- });
960
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
972
961
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
973
962
  const wiringFolder = boundedContextFolder.subitem([
974
963
  'wiring',
@@ -1023,10 +1012,7 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
1023
1012
  message: 'Name: '
1024
1013
  });
1025
1014
  const naming = new UnknownFormatNaming(queryName);
1026
- let scaffoldUnitTests;
1027
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
1028
- message: 'Scaffold unit-tests'
1029
- });
1015
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
1030
1016
  const queryType = await (0, prompts_namespaceObject.select)({
1031
1017
  choices: [
1032
1018
  'Execution (with infrastructure implementation)',
@@ -1211,10 +1197,7 @@ const scaffoldNewUseCase = async (boundedContextFolder)=>{
1211
1197
  message: 'Name: '
1212
1198
  });
1213
1199
  const naming = new UnknownFormatNaming(useCaseName);
1214
- let scaffoldUnitTests;
1215
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
1216
- message: 'Scaffold unit-tests'
1217
- });
1200
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
1218
1201
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
1219
1202
  useCasesFolder.createFile(`${naming.fileName}-use-case.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
1220
1203
  import { defineHandler } from '@domain-first/handlers'
@@ -1286,6 +1269,44 @@ export const ${ClassName}Page: FC<${ClassName}PageProps> = (props) => {
1286
1269
  }
1287
1270
  `.trim());
1288
1271
  };
1272
+ const scaffoldReactUIKitComponent = async (presentationReactFolder)=>{
1273
+ const name = await (0, prompts_namespaceObject.input)({
1274
+ message: 'Name: '
1275
+ });
1276
+ const { ClassName, fileName } = new UnknownFormatNaming(name);
1277
+ const componentFolder = presentationReactFolder.subitem([
1278
+ 'ui-kit',
1279
+ fileName
1280
+ ]);
1281
+ componentFolder.createFile('index.ts', `export * from './${fileName}'`);
1282
+ componentFolder.createFile(`${fileName}.tsx`, `
1283
+ import { type FC } from 'react'
1284
+
1285
+ export type ${ClassName}Props = {}
1286
+
1287
+ export const ${ClassName}: FC<${ClassName}Props> = (props) => {
1288
+ return <></>
1289
+ }
1290
+ `.trim());
1291
+ const { storybookFramework } = ConfigFile.Instance.data;
1292
+ if (storybookFramework) componentFolder.createFile(`${fileName}.stories.tsx`, `
1293
+ import type { Meta, StoryObj } from '${storybookFramework}'
1294
+ import { ${ClassName} } from './${fileName}'
1295
+
1296
+ const meta = {
1297
+ title: 'UI-kit/${ClassName}',
1298
+ component: ${ClassName}
1299
+ } satisfies Meta<typeof ${ClassName}>
1300
+
1301
+ export default meta
1302
+
1303
+ type Story = StoryObj<typeof meta>
1304
+
1305
+ export const Default: Story = {
1306
+ args: {}
1307
+ }
1308
+ `.trim());
1309
+ };
1289
1310
  const scaffoldReactWidget = async (presentationReactFolder)=>{
1290
1311
  const widgetName = await (0, prompts_namespaceObject.input)({
1291
1312
  message: 'Name: '
@@ -1303,9 +1324,13 @@ const scaffoldReactWidget = async (presentationReactFolder)=>{
1303
1324
  'widgets',
1304
1325
  fileName
1305
1326
  ]);
1327
+ const widgetFileName = `${fileName}-widget`;
1328
+ const uiFileName = `${fileName}-widget-ui`;
1329
+ const uiModelFileName = `use-${fileName}-ui-model`;
1330
+ folder.createFile('index.ts', `export * from './${widgetFileName}'`);
1306
1331
  switch(widgetType){
1307
1332
  case 'monolithic':
1308
- folder.createFile('index.tsx', `
1333
+ folder.createFile(`${widgetFileName}.tsx`, `
1309
1334
  import { type FC } from 'react'
1310
1335
 
1311
1336
  export type ${ClassName}WidgetProps = {}
@@ -1321,14 +1346,14 @@ export type ${ClassName}WidgetProps = { }
1321
1346
 
1322
1347
  export type ${ClassName}WidgetUIProps = { }
1323
1348
  `.trim());
1324
- folder.createFile('index.tsx', `
1349
+ folder.createFile(`${widgetFileName}.tsx`, `
1325
1350
  import { type FC } from 'react'
1326
1351
  import type { ${ClassName}WidgetProps } from './types'
1327
- import { ${ClassName}WidgetUI } from './ui'
1328
- import { useUIModel } from './hooks/use-ui-model'
1352
+ import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
1353
+ import { use${ClassName}UIModel } from './hooks/${uiModelFileName}'
1329
1354
 
1330
1355
  export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1331
- const uiModel = useUIModel(props)
1356
+ const uiModel = use${ClassName}UIModel(props)
1332
1357
  return <${ClassName}WidgetUI {...uiModel} />
1333
1358
  }
1334
1359
 
@@ -1336,7 +1361,7 @@ export type { ${ClassName}WidgetProps }
1336
1361
  `.trim());
1337
1362
  folder.subitem([
1338
1363
  'ui'
1339
- ]).createFile('index.tsx', `
1364
+ ]).createFile(`${uiFileName}.tsx`, `
1340
1365
  import { FC } from 'react'
1341
1366
  import type { ${ClassName}WidgetUIProps } from '../types'
1342
1367
 
@@ -1346,10 +1371,10 @@ export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
1346
1371
  `.trim());
1347
1372
  folder.subitem([
1348
1373
  'hooks'
1349
- ]).createFile('use-ui-model.ts', `
1374
+ ]).createFile(`${uiModelFileName}.ts`, `
1350
1375
  import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
1351
1376
 
1352
- export const useUIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
1377
+ export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
1353
1378
  return {}
1354
1379
  }
1355
1380
  `.trim());
@@ -1365,13 +1390,13 @@ export type ${ClassName}WidgetProps = {
1365
1390
  }
1366
1391
 
1367
1392
  `.trim());
1368
- folder.createFile('index.tsx', `
1393
+ folder.createFile(`${widgetFileName}.tsx`, `
1369
1394
  import { type FC } from 'react'
1370
1395
  import type { ${ClassName}WidgetProps } from './types'
1371
- import { useUIModel } from './hooks/use-ui-model'
1396
+ import { use${ClassName}UIModel } from './hooks/${uiModelFileName}'
1372
1397
 
1373
1398
  export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1374
- const uiModel = useUIModel(props)
1399
+ const uiModel = use${ClassName}UIModel(props)
1375
1400
  return <props.UI {...uiModel} />
1376
1401
  }
1377
1402
 
@@ -1379,10 +1404,10 @@ export type { ${ClassName}WidgetProps }
1379
1404
  `.trim());
1380
1405
  folder.subitem([
1381
1406
  'hooks'
1382
- ]).createFile('use-ui-model.ts', `
1407
+ ]).createFile(`${uiModelFileName}.ts`, `
1383
1408
  import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
1384
1409
 
1385
- export const useUIModel = (widgetProps: Omit<${ClassName}WidgetProps, 'UI'>): ${ClassName}WidgetUIProps => {
1410
+ export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps, 'UI'>): ${ClassName}WidgetUIProps => {
1386
1411
  return {}
1387
1412
  }
1388
1413
  `.trim());
@@ -1432,7 +1457,8 @@ const main = async ()=>{
1432
1457
  message: 'Module: ',
1433
1458
  choices: [
1434
1459
  'New widget',
1435
- 'New page'
1460
+ 'New page',
1461
+ 'New UI-kit component'
1436
1462
  ]
1437
1463
  });
1438
1464
  switch(action){
@@ -1440,6 +1466,8 @@ const main = async ()=>{
1440
1466
  return void await scaffoldReactWidget(reactFolder);
1441
1467
  case 'New page':
1442
1468
  return void await scaffoldReactPage(reactFolder);
1469
+ case 'New UI-kit component':
1470
+ return void await scaffoldReactUIKitComponent(reactFolder);
1443
1471
  default:
1444
1472
  return;
1445
1473
  }
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();
@@ -214,10 +224,7 @@ const scaffoldNewAggregateUseCase = async (boundedContextFolder)=>{
214
224
  message: 'Aggregate name:'
215
225
  });
216
226
  const aggregateNaming = new UnknownFormatNaming(aggregateName);
217
- let scaffoldUnitTests;
218
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
219
- message: 'Scaffold unit-tests'
220
- });
227
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
221
228
  const withRepository = await prompts_confirm({
222
229
  message: 'With Repository'
223
230
  });
@@ -335,10 +342,7 @@ const scaffoldNewApplicationPort = async (boundedContextFolder)=>{
335
342
  message: 'Name: '
336
343
  });
337
344
  const naming = new UnknownFormatNaming(name);
338
- let scaffoldUnitTests;
339
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
340
- message: 'Scaffold unit-tests'
341
- });
345
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
342
346
  const wiringFolder = boundedContextFolder.subitem([
343
347
  'wiring',
344
348
  'application-ports'
@@ -432,10 +436,7 @@ const scaffoldNewApplicationService = async (boundedContextFolder)=>{
432
436
  message: 'Name: '
433
437
  });
434
438
  const naming = new UnknownFormatNaming(name);
435
- let scaffoldUnitTests;
436
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
437
- message: 'Scaffold unit-tests'
438
- });
439
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
439
440
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
440
441
  const wiringFolder = boundedContextFolder.subitem([
441
442
  'wiring',
@@ -511,10 +512,7 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
511
512
  const commandName = await input({
512
513
  message: 'Name: '
513
514
  });
514
- let scaffoldUnitTests;
515
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
516
- message: 'Scaffold unit-tests'
517
- });
515
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
518
516
  const naming = new UnknownFormatNaming(commandName);
519
517
  const commandType = await prompts_select({
520
518
  choices: [
@@ -696,10 +694,7 @@ const scaffoldNewDomainService = async (boundedContextFolder)=>{
696
694
  message: 'Name:'
697
695
  });
698
696
  const naming = new UnknownFormatNaming(portName);
699
- let scaffoldUnitTests;
700
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
701
- message: 'Scaffold unit-tests'
702
- });
697
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
703
698
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
704
699
  const domainServicesFolder = boundedContextFolder.subitem([
705
700
  'domain',
@@ -885,10 +880,7 @@ const scaffoldNewInfrastructureService = async (boundedContextFolder)=>{
885
880
  message: 'Name: '
886
881
  });
887
882
  const naming = new UnknownFormatNaming(name);
888
- let scaffoldUnitTests;
889
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
890
- message: 'Scaffold unit-tests'
891
- });
883
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
892
884
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
893
885
  const wiringFolder = boundedContextFolder.subitem([
894
886
  'wiring',
@@ -935,10 +927,7 @@ const scaffoldNewPresentationService = async (boundedContextFolder)=>{
935
927
  message: 'Name: '
936
928
  });
937
929
  const naming = new UnknownFormatNaming(name);
938
- let scaffoldUnitTests;
939
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
940
- message: 'Scaffold unit-tests'
941
- });
930
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
942
931
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
943
932
  const wiringFolder = boundedContextFolder.subitem([
944
933
  'wiring',
@@ -993,10 +982,7 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
993
982
  message: 'Name: '
994
983
  });
995
984
  const naming = new UnknownFormatNaming(queryName);
996
- let scaffoldUnitTests;
997
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
998
- message: 'Scaffold unit-tests'
999
- });
985
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
1000
986
  const queryType = await prompts_select({
1001
987
  choices: [
1002
988
  'Execution (with infrastructure implementation)',
@@ -1181,10 +1167,7 @@ const scaffoldNewUseCase = async (boundedContextFolder)=>{
1181
1167
  message: 'Name: '
1182
1168
  });
1183
1169
  const naming = new UnknownFormatNaming(useCaseName);
1184
- let scaffoldUnitTests;
1185
- if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
1186
- message: 'Scaffold unit-tests'
1187
- });
1170
+ const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
1188
1171
  const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
1189
1172
  useCasesFolder.createFile(`${naming.fileName}-use-case.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
1190
1173
  import { defineHandler } from '@domain-first/handlers'
@@ -1256,6 +1239,44 @@ export const ${ClassName}Page: FC<${ClassName}PageProps> = (props) => {
1256
1239
  }
1257
1240
  `.trim());
1258
1241
  };
1242
+ const scaffoldReactUIKitComponent = async (presentationReactFolder)=>{
1243
+ const name = await input({
1244
+ message: 'Name: '
1245
+ });
1246
+ const { ClassName, fileName } = new UnknownFormatNaming(name);
1247
+ const componentFolder = presentationReactFolder.subitem([
1248
+ 'ui-kit',
1249
+ fileName
1250
+ ]);
1251
+ componentFolder.createFile('index.ts', `export * from './${fileName}'`);
1252
+ componentFolder.createFile(`${fileName}.tsx`, `
1253
+ import { type FC } from 'react'
1254
+
1255
+ export type ${ClassName}Props = {}
1256
+
1257
+ export const ${ClassName}: FC<${ClassName}Props> = (props) => {
1258
+ return <></>
1259
+ }
1260
+ `.trim());
1261
+ const { storybookFramework } = ConfigFile.Instance.data;
1262
+ if (storybookFramework) componentFolder.createFile(`${fileName}.stories.tsx`, `
1263
+ import type { Meta, StoryObj } from '${storybookFramework}'
1264
+ import { ${ClassName} } from './${fileName}'
1265
+
1266
+ const meta = {
1267
+ title: 'UI-kit/${ClassName}',
1268
+ component: ${ClassName}
1269
+ } satisfies Meta<typeof ${ClassName}>
1270
+
1271
+ export default meta
1272
+
1273
+ type Story = StoryObj<typeof meta>
1274
+
1275
+ export const Default: Story = {
1276
+ args: {}
1277
+ }
1278
+ `.trim());
1279
+ };
1259
1280
  const scaffoldReactWidget = async (presentationReactFolder)=>{
1260
1281
  const widgetName = await input({
1261
1282
  message: 'Name: '
@@ -1273,9 +1294,13 @@ const scaffoldReactWidget = async (presentationReactFolder)=>{
1273
1294
  'widgets',
1274
1295
  fileName
1275
1296
  ]);
1297
+ const widgetFileName = `${fileName}-widget`;
1298
+ const uiFileName = `${fileName}-widget-ui`;
1299
+ const uiModelFileName = `use-${fileName}-ui-model`;
1300
+ folder.createFile('index.ts', `export * from './${widgetFileName}'`);
1276
1301
  switch(widgetType){
1277
1302
  case 'monolithic':
1278
- folder.createFile('index.tsx', `
1303
+ folder.createFile(`${widgetFileName}.tsx`, `
1279
1304
  import { type FC } from 'react'
1280
1305
 
1281
1306
  export type ${ClassName}WidgetProps = {}
@@ -1291,14 +1316,14 @@ export type ${ClassName}WidgetProps = { }
1291
1316
 
1292
1317
  export type ${ClassName}WidgetUIProps = { }
1293
1318
  `.trim());
1294
- folder.createFile('index.tsx', `
1319
+ folder.createFile(`${widgetFileName}.tsx`, `
1295
1320
  import { type FC } from 'react'
1296
1321
  import type { ${ClassName}WidgetProps } from './types'
1297
- import { ${ClassName}WidgetUI } from './ui'
1298
- import { useUIModel } from './hooks/use-ui-model'
1322
+ import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
1323
+ import { use${ClassName}UIModel } from './hooks/${uiModelFileName}'
1299
1324
 
1300
1325
  export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1301
- const uiModel = useUIModel(props)
1326
+ const uiModel = use${ClassName}UIModel(props)
1302
1327
  return <${ClassName}WidgetUI {...uiModel} />
1303
1328
  }
1304
1329
 
@@ -1306,7 +1331,7 @@ export type { ${ClassName}WidgetProps }
1306
1331
  `.trim());
1307
1332
  folder.subitem([
1308
1333
  'ui'
1309
- ]).createFile('index.tsx', `
1334
+ ]).createFile(`${uiFileName}.tsx`, `
1310
1335
  import { FC } from 'react'
1311
1336
  import type { ${ClassName}WidgetUIProps } from '../types'
1312
1337
 
@@ -1316,10 +1341,10 @@ export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
1316
1341
  `.trim());
1317
1342
  folder.subitem([
1318
1343
  'hooks'
1319
- ]).createFile('use-ui-model.ts', `
1344
+ ]).createFile(`${uiModelFileName}.ts`, `
1320
1345
  import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
1321
1346
 
1322
- export const useUIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
1347
+ export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
1323
1348
  return {}
1324
1349
  }
1325
1350
  `.trim());
@@ -1335,13 +1360,13 @@ export type ${ClassName}WidgetProps = {
1335
1360
  }
1336
1361
 
1337
1362
  `.trim());
1338
- folder.createFile('index.tsx', `
1363
+ folder.createFile(`${widgetFileName}.tsx`, `
1339
1364
  import { type FC } from 'react'
1340
1365
  import type { ${ClassName}WidgetProps } from './types'
1341
- import { useUIModel } from './hooks/use-ui-model'
1366
+ import { use${ClassName}UIModel } from './hooks/${uiModelFileName}'
1342
1367
 
1343
1368
  export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
1344
- const uiModel = useUIModel(props)
1369
+ const uiModel = use${ClassName}UIModel(props)
1345
1370
  return <props.UI {...uiModel} />
1346
1371
  }
1347
1372
 
@@ -1349,10 +1374,10 @@ export type { ${ClassName}WidgetProps }
1349
1374
  `.trim());
1350
1375
  folder.subitem([
1351
1376
  'hooks'
1352
- ]).createFile('use-ui-model.ts', `
1377
+ ]).createFile(`${uiModelFileName}.ts`, `
1353
1378
  import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
1354
1379
 
1355
- export const useUIModel = (widgetProps: Omit<${ClassName}WidgetProps, 'UI'>): ${ClassName}WidgetUIProps => {
1380
+ export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps, 'UI'>): ${ClassName}WidgetUIProps => {
1356
1381
  return {}
1357
1382
  }
1358
1383
  `.trim());
@@ -1402,7 +1427,8 @@ const main = async ()=>{
1402
1427
  message: 'Module: ',
1403
1428
  choices: [
1404
1429
  'New widget',
1405
- 'New page'
1430
+ 'New page',
1431
+ 'New UI-kit component'
1406
1432
  ]
1407
1433
  });
1408
1434
  switch(action){
@@ -1410,6 +1436,8 @@ const main = async ()=>{
1410
1436
  return void await scaffoldReactWidget(reactFolder);
1411
1437
  case 'New page':
1412
1438
  return void await scaffoldReactPage(reactFolder);
1439
+ case 'New UI-kit component':
1440
+ return void await scaffoldReactUIKitComponent(reactFolder);
1413
1441
  default:
1414
1442
  return;
1415
1443
  }
@@ -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';
@@ -0,0 +1,2 @@
1
+ import type { Folder } from '../file-system';
2
+ export declare const scaffoldReactUIKitComponent: (presentationReactFolder: Folder) => Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@domain-first/project-structure",
3
3
  "description": "Build and manage your Domain-First project structure with CLI",
4
- "version": "2.7.5",
4
+ "version": "2.8.1",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",