@domain-first/project-structure 2.8.0 → 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 +7 -7
- package/dist/index.cjs +29 -51
- package/dist/index.js +29 -51
- package/package.json +1 -1
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
|
|
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
|
|
|
@@ -161,7 +161,7 @@ With `@domain-first/wire`, generators create `wireClass` factories. Repositories
|
|
|
161
161
|
|
|
162
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.
|
|
163
163
|
|
|
164
|
-
When `testingLibrary` is configured, supported generators
|
|
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.
|
|
165
165
|
|
|
166
166
|
### REST endpoints
|
|
167
167
|
|
|
@@ -182,10 +182,10 @@ Enable `useReact` and choose **Scaffold React module** from the main menu. Modul
|
|
|
182
182
|
| Generator | Output |
|
|
183
183
|
| ------------------------------ | ---------------------------------------------------------------------------------------------------------- |
|
|
184
184
|
| New page | `pages/<name>-page.tsx` with a typed props object and a component. |
|
|
185
|
-
| New widget → monolithic | `widgets/<name
|
|
186
|
-
| New widget → with separated ui |
|
|
187
|
-
| New widget → headless |
|
|
188
|
-
| New UI-kit component | `ui-kit/<name
|
|
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`. |
|
|
189
189
|
|
|
190
190
|
## Configuration
|
|
191
191
|
|
|
@@ -215,7 +215,7 @@ The project configuration is stored in `domain-first.project-structure.config.js
|
|
|
215
215
|
| `defaultPersistenceLayerImplementation` | Suggested implementation label for execution commands and queries. |
|
|
216
216
|
| `useReact` | Shows or hides the React module menu. |
|
|
217
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
|
|
218
|
+
| `testingLibrary` | Module imported by generated tests. Omit this field to disable test generation. Templates expect helpers such as `describe`, `test`, `expect`, and `beforeEach`. |
|
|
219
219
|
|
|
220
220
|
### Package integrations
|
|
221
221
|
|
package/dist/index.cjs
CHANGED
|
@@ -254,10 +254,7 @@ const scaffoldNewAggregateUseCase = async (boundedContextFolder)=>{
|
|
|
254
254
|
message: 'Aggregate name:'
|
|
255
255
|
});
|
|
256
256
|
const aggregateNaming = new UnknownFormatNaming(aggregateName);
|
|
257
|
-
|
|
258
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
259
|
-
message: 'Scaffold unit-tests'
|
|
260
|
-
});
|
|
257
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
261
258
|
const withRepository = await (0, prompts_namespaceObject.confirm)({
|
|
262
259
|
message: 'With Repository'
|
|
263
260
|
});
|
|
@@ -375,10 +372,7 @@ const scaffoldNewApplicationPort = async (boundedContextFolder)=>{
|
|
|
375
372
|
message: 'Name: '
|
|
376
373
|
});
|
|
377
374
|
const naming = new UnknownFormatNaming(name);
|
|
378
|
-
|
|
379
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
380
|
-
message: 'Scaffold unit-tests'
|
|
381
|
-
});
|
|
375
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
382
376
|
const wiringFolder = boundedContextFolder.subitem([
|
|
383
377
|
'wiring',
|
|
384
378
|
'application-ports'
|
|
@@ -472,10 +466,7 @@ const scaffoldNewApplicationService = async (boundedContextFolder)=>{
|
|
|
472
466
|
message: 'Name: '
|
|
473
467
|
});
|
|
474
468
|
const naming = new UnknownFormatNaming(name);
|
|
475
|
-
|
|
476
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
477
|
-
message: 'Scaffold unit-tests'
|
|
478
|
-
});
|
|
469
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
479
470
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
480
471
|
const wiringFolder = boundedContextFolder.subitem([
|
|
481
472
|
'wiring',
|
|
@@ -551,10 +542,7 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
551
542
|
const commandName = await (0, prompts_namespaceObject.input)({
|
|
552
543
|
message: 'Name: '
|
|
553
544
|
});
|
|
554
|
-
|
|
555
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
556
|
-
message: 'Scaffold unit-tests'
|
|
557
|
-
});
|
|
545
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
558
546
|
const naming = new UnknownFormatNaming(commandName);
|
|
559
547
|
const commandType = await (0, prompts_namespaceObject.select)({
|
|
560
548
|
choices: [
|
|
@@ -736,10 +724,7 @@ const scaffoldNewDomainService = async (boundedContextFolder)=>{
|
|
|
736
724
|
message: 'Name:'
|
|
737
725
|
});
|
|
738
726
|
const naming = new UnknownFormatNaming(portName);
|
|
739
|
-
|
|
740
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
741
|
-
message: 'Scaffold unit-tests'
|
|
742
|
-
});
|
|
727
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
743
728
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
744
729
|
const domainServicesFolder = boundedContextFolder.subitem([
|
|
745
730
|
'domain',
|
|
@@ -925,10 +910,7 @@ const scaffoldNewInfrastructureService = async (boundedContextFolder)=>{
|
|
|
925
910
|
message: 'Name: '
|
|
926
911
|
});
|
|
927
912
|
const naming = new UnknownFormatNaming(name);
|
|
928
|
-
|
|
929
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
930
|
-
message: 'Scaffold unit-tests'
|
|
931
|
-
});
|
|
913
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
932
914
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
933
915
|
const wiringFolder = boundedContextFolder.subitem([
|
|
934
916
|
'wiring',
|
|
@@ -975,10 +957,7 @@ const scaffoldNewPresentationService = async (boundedContextFolder)=>{
|
|
|
975
957
|
message: 'Name: '
|
|
976
958
|
});
|
|
977
959
|
const naming = new UnknownFormatNaming(name);
|
|
978
|
-
|
|
979
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
980
|
-
message: 'Scaffold unit-tests'
|
|
981
|
-
});
|
|
960
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
982
961
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
983
962
|
const wiringFolder = boundedContextFolder.subitem([
|
|
984
963
|
'wiring',
|
|
@@ -1033,10 +1012,7 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
1033
1012
|
message: 'Name: '
|
|
1034
1013
|
});
|
|
1035
1014
|
const naming = new UnknownFormatNaming(queryName);
|
|
1036
|
-
|
|
1037
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
1038
|
-
message: 'Scaffold unit-tests'
|
|
1039
|
-
});
|
|
1015
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
1040
1016
|
const queryType = await (0, prompts_namespaceObject.select)({
|
|
1041
1017
|
choices: [
|
|
1042
1018
|
'Execution (with infrastructure implementation)',
|
|
@@ -1221,10 +1197,7 @@ const scaffoldNewUseCase = async (boundedContextFolder)=>{
|
|
|
1221
1197
|
message: 'Name: '
|
|
1222
1198
|
});
|
|
1223
1199
|
const naming = new UnknownFormatNaming(useCaseName);
|
|
1224
|
-
|
|
1225
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await (0, prompts_namespaceObject.confirm)({
|
|
1226
|
-
message: 'Scaffold unit-tests'
|
|
1227
|
-
});
|
|
1200
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
1228
1201
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
1229
1202
|
useCasesFolder.createFile(`${naming.fileName}-use-case.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
1230
1203
|
import { defineHandler } from '@domain-first/handlers'
|
|
@@ -1305,7 +1278,8 @@ const scaffoldReactUIKitComponent = async (presentationReactFolder)=>{
|
|
|
1305
1278
|
'ui-kit',
|
|
1306
1279
|
fileName
|
|
1307
1280
|
]);
|
|
1308
|
-
componentFolder.createFile('index.
|
|
1281
|
+
componentFolder.createFile('index.ts', `export * from './${fileName}'`);
|
|
1282
|
+
componentFolder.createFile(`${fileName}.tsx`, `
|
|
1309
1283
|
import { type FC } from 'react'
|
|
1310
1284
|
|
|
1311
1285
|
export type ${ClassName}Props = {}
|
|
@@ -1317,7 +1291,7 @@ export const ${ClassName}: FC<${ClassName}Props> = (props) => {
|
|
|
1317
1291
|
const { storybookFramework } = ConfigFile.Instance.data;
|
|
1318
1292
|
if (storybookFramework) componentFolder.createFile(`${fileName}.stories.tsx`, `
|
|
1319
1293
|
import type { Meta, StoryObj } from '${storybookFramework}'
|
|
1320
|
-
import { ${ClassName} } from '
|
|
1294
|
+
import { ${ClassName} } from './${fileName}'
|
|
1321
1295
|
|
|
1322
1296
|
const meta = {
|
|
1323
1297
|
title: 'UI-kit/${ClassName}',
|
|
@@ -1350,9 +1324,13 @@ const scaffoldReactWidget = async (presentationReactFolder)=>{
|
|
|
1350
1324
|
'widgets',
|
|
1351
1325
|
fileName
|
|
1352
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}'`);
|
|
1353
1331
|
switch(widgetType){
|
|
1354
1332
|
case 'monolithic':
|
|
1355
|
-
folder.createFile(
|
|
1333
|
+
folder.createFile(`${widgetFileName}.tsx`, `
|
|
1356
1334
|
import { type FC } from 'react'
|
|
1357
1335
|
|
|
1358
1336
|
export type ${ClassName}WidgetProps = {}
|
|
@@ -1368,14 +1346,14 @@ export type ${ClassName}WidgetProps = { }
|
|
|
1368
1346
|
|
|
1369
1347
|
export type ${ClassName}WidgetUIProps = { }
|
|
1370
1348
|
`.trim());
|
|
1371
|
-
folder.createFile(
|
|
1349
|
+
folder.createFile(`${widgetFileName}.tsx`, `
|
|
1372
1350
|
import { type FC } from 'react'
|
|
1373
1351
|
import type { ${ClassName}WidgetProps } from './types'
|
|
1374
|
-
import { ${ClassName}WidgetUI } from './ui'
|
|
1375
|
-
import {
|
|
1352
|
+
import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
|
|
1353
|
+
import { use${ClassName}UIModel } from './hooks/${uiModelFileName}'
|
|
1376
1354
|
|
|
1377
1355
|
export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
|
|
1378
|
-
const uiModel =
|
|
1356
|
+
const uiModel = use${ClassName}UIModel(props)
|
|
1379
1357
|
return <${ClassName}WidgetUI {...uiModel} />
|
|
1380
1358
|
}
|
|
1381
1359
|
|
|
@@ -1383,7 +1361,7 @@ export type { ${ClassName}WidgetProps }
|
|
|
1383
1361
|
`.trim());
|
|
1384
1362
|
folder.subitem([
|
|
1385
1363
|
'ui'
|
|
1386
|
-
]).createFile(
|
|
1364
|
+
]).createFile(`${uiFileName}.tsx`, `
|
|
1387
1365
|
import { FC } from 'react'
|
|
1388
1366
|
import type { ${ClassName}WidgetUIProps } from '../types'
|
|
1389
1367
|
|
|
@@ -1393,10 +1371,10 @@ export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
|
|
|
1393
1371
|
`.trim());
|
|
1394
1372
|
folder.subitem([
|
|
1395
1373
|
'hooks'
|
|
1396
|
-
]).createFile(
|
|
1374
|
+
]).createFile(`${uiModelFileName}.ts`, `
|
|
1397
1375
|
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
1398
1376
|
|
|
1399
|
-
export const
|
|
1377
|
+
export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
|
|
1400
1378
|
return {}
|
|
1401
1379
|
}
|
|
1402
1380
|
`.trim());
|
|
@@ -1412,13 +1390,13 @@ export type ${ClassName}WidgetProps = {
|
|
|
1412
1390
|
}
|
|
1413
1391
|
|
|
1414
1392
|
`.trim());
|
|
1415
|
-
folder.createFile(
|
|
1393
|
+
folder.createFile(`${widgetFileName}.tsx`, `
|
|
1416
1394
|
import { type FC } from 'react'
|
|
1417
1395
|
import type { ${ClassName}WidgetProps } from './types'
|
|
1418
|
-
import {
|
|
1396
|
+
import { use${ClassName}UIModel } from './hooks/${uiModelFileName}'
|
|
1419
1397
|
|
|
1420
1398
|
export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
|
|
1421
|
-
const uiModel =
|
|
1399
|
+
const uiModel = use${ClassName}UIModel(props)
|
|
1422
1400
|
return <props.UI {...uiModel} />
|
|
1423
1401
|
}
|
|
1424
1402
|
|
|
@@ -1426,10 +1404,10 @@ export type { ${ClassName}WidgetProps }
|
|
|
1426
1404
|
`.trim());
|
|
1427
1405
|
folder.subitem([
|
|
1428
1406
|
'hooks'
|
|
1429
|
-
]).createFile(
|
|
1407
|
+
]).createFile(`${uiModelFileName}.ts`, `
|
|
1430
1408
|
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
1431
1409
|
|
|
1432
|
-
export const
|
|
1410
|
+
export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps, 'UI'>): ${ClassName}WidgetUIProps => {
|
|
1433
1411
|
return {}
|
|
1434
1412
|
}
|
|
1435
1413
|
`.trim());
|
package/dist/index.js
CHANGED
|
@@ -224,10 +224,7 @@ const scaffoldNewAggregateUseCase = async (boundedContextFolder)=>{
|
|
|
224
224
|
message: 'Aggregate name:'
|
|
225
225
|
});
|
|
226
226
|
const aggregateNaming = new UnknownFormatNaming(aggregateName);
|
|
227
|
-
|
|
228
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
229
|
-
message: 'Scaffold unit-tests'
|
|
230
|
-
});
|
|
227
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
231
228
|
const withRepository = await prompts_confirm({
|
|
232
229
|
message: 'With Repository'
|
|
233
230
|
});
|
|
@@ -345,10 +342,7 @@ const scaffoldNewApplicationPort = async (boundedContextFolder)=>{
|
|
|
345
342
|
message: 'Name: '
|
|
346
343
|
});
|
|
347
344
|
const naming = new UnknownFormatNaming(name);
|
|
348
|
-
|
|
349
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
350
|
-
message: 'Scaffold unit-tests'
|
|
351
|
-
});
|
|
345
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
352
346
|
const wiringFolder = boundedContextFolder.subitem([
|
|
353
347
|
'wiring',
|
|
354
348
|
'application-ports'
|
|
@@ -442,10 +436,7 @@ const scaffoldNewApplicationService = async (boundedContextFolder)=>{
|
|
|
442
436
|
message: 'Name: '
|
|
443
437
|
});
|
|
444
438
|
const naming = new UnknownFormatNaming(name);
|
|
445
|
-
|
|
446
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
447
|
-
message: 'Scaffold unit-tests'
|
|
448
|
-
});
|
|
439
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
449
440
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
450
441
|
const wiringFolder = boundedContextFolder.subitem([
|
|
451
442
|
'wiring',
|
|
@@ -521,10 +512,7 @@ const scaffoldNewCommand = async (boundedContextFolder)=>{
|
|
|
521
512
|
const commandName = await input({
|
|
522
513
|
message: 'Name: '
|
|
523
514
|
});
|
|
524
|
-
|
|
525
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
526
|
-
message: 'Scaffold unit-tests'
|
|
527
|
-
});
|
|
515
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
528
516
|
const naming = new UnknownFormatNaming(commandName);
|
|
529
517
|
const commandType = await prompts_select({
|
|
530
518
|
choices: [
|
|
@@ -706,10 +694,7 @@ const scaffoldNewDomainService = async (boundedContextFolder)=>{
|
|
|
706
694
|
message: 'Name:'
|
|
707
695
|
});
|
|
708
696
|
const naming = new UnknownFormatNaming(portName);
|
|
709
|
-
|
|
710
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
711
|
-
message: 'Scaffold unit-tests'
|
|
712
|
-
});
|
|
697
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
713
698
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
714
699
|
const domainServicesFolder = boundedContextFolder.subitem([
|
|
715
700
|
'domain',
|
|
@@ -895,10 +880,7 @@ const scaffoldNewInfrastructureService = async (boundedContextFolder)=>{
|
|
|
895
880
|
message: 'Name: '
|
|
896
881
|
});
|
|
897
882
|
const naming = new UnknownFormatNaming(name);
|
|
898
|
-
|
|
899
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
900
|
-
message: 'Scaffold unit-tests'
|
|
901
|
-
});
|
|
883
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
902
884
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
903
885
|
const wiringFolder = boundedContextFolder.subitem([
|
|
904
886
|
'wiring',
|
|
@@ -945,10 +927,7 @@ const scaffoldNewPresentationService = async (boundedContextFolder)=>{
|
|
|
945
927
|
message: 'Name: '
|
|
946
928
|
});
|
|
947
929
|
const naming = new UnknownFormatNaming(name);
|
|
948
|
-
|
|
949
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
950
|
-
message: 'Scaffold unit-tests'
|
|
951
|
-
});
|
|
930
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
952
931
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
953
932
|
const wiringFolder = boundedContextFolder.subitem([
|
|
954
933
|
'wiring',
|
|
@@ -1003,10 +982,7 @@ const scaffoldNewQuery = async (boundedContextFolder)=>{
|
|
|
1003
982
|
message: 'Name: '
|
|
1004
983
|
});
|
|
1005
984
|
const naming = new UnknownFormatNaming(queryName);
|
|
1006
|
-
|
|
1007
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
1008
|
-
message: 'Scaffold unit-tests'
|
|
1009
|
-
});
|
|
985
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
1010
986
|
const queryType = await prompts_select({
|
|
1011
987
|
choices: [
|
|
1012
988
|
'Execution (with infrastructure implementation)',
|
|
@@ -1191,10 +1167,7 @@ const scaffoldNewUseCase = async (boundedContextFolder)=>{
|
|
|
1191
1167
|
message: 'Name: '
|
|
1192
1168
|
});
|
|
1193
1169
|
const naming = new UnknownFormatNaming(useCaseName);
|
|
1194
|
-
|
|
1195
|
-
if (ConfigFile.Instance.data.testingLibrary) scaffoldUnitTests = await prompts_confirm({
|
|
1196
|
-
message: 'Scaffold unit-tests'
|
|
1197
|
-
});
|
|
1170
|
+
const scaffoldUnitTests = Boolean(ConfigFile.Instance.data.testingLibrary);
|
|
1198
1171
|
const withWiring = ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/wire');
|
|
1199
1172
|
useCasesFolder.createFile(`${naming.fileName}-use-case.ts`, ConfigFile.Instance.data.domainFirstPackages.includes('@domain-first/handlers') ? `
|
|
1200
1173
|
import { defineHandler } from '@domain-first/handlers'
|
|
@@ -1275,7 +1248,8 @@ const scaffoldReactUIKitComponent = async (presentationReactFolder)=>{
|
|
|
1275
1248
|
'ui-kit',
|
|
1276
1249
|
fileName
|
|
1277
1250
|
]);
|
|
1278
|
-
componentFolder.createFile('index.
|
|
1251
|
+
componentFolder.createFile('index.ts', `export * from './${fileName}'`);
|
|
1252
|
+
componentFolder.createFile(`${fileName}.tsx`, `
|
|
1279
1253
|
import { type FC } from 'react'
|
|
1280
1254
|
|
|
1281
1255
|
export type ${ClassName}Props = {}
|
|
@@ -1287,7 +1261,7 @@ export const ${ClassName}: FC<${ClassName}Props> = (props) => {
|
|
|
1287
1261
|
const { storybookFramework } = ConfigFile.Instance.data;
|
|
1288
1262
|
if (storybookFramework) componentFolder.createFile(`${fileName}.stories.tsx`, `
|
|
1289
1263
|
import type { Meta, StoryObj } from '${storybookFramework}'
|
|
1290
|
-
import { ${ClassName} } from '
|
|
1264
|
+
import { ${ClassName} } from './${fileName}'
|
|
1291
1265
|
|
|
1292
1266
|
const meta = {
|
|
1293
1267
|
title: 'UI-kit/${ClassName}',
|
|
@@ -1320,9 +1294,13 @@ const scaffoldReactWidget = async (presentationReactFolder)=>{
|
|
|
1320
1294
|
'widgets',
|
|
1321
1295
|
fileName
|
|
1322
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}'`);
|
|
1323
1301
|
switch(widgetType){
|
|
1324
1302
|
case 'monolithic':
|
|
1325
|
-
folder.createFile(
|
|
1303
|
+
folder.createFile(`${widgetFileName}.tsx`, `
|
|
1326
1304
|
import { type FC } from 'react'
|
|
1327
1305
|
|
|
1328
1306
|
export type ${ClassName}WidgetProps = {}
|
|
@@ -1338,14 +1316,14 @@ export type ${ClassName}WidgetProps = { }
|
|
|
1338
1316
|
|
|
1339
1317
|
export type ${ClassName}WidgetUIProps = { }
|
|
1340
1318
|
`.trim());
|
|
1341
|
-
folder.createFile(
|
|
1319
|
+
folder.createFile(`${widgetFileName}.tsx`, `
|
|
1342
1320
|
import { type FC } from 'react'
|
|
1343
1321
|
import type { ${ClassName}WidgetProps } from './types'
|
|
1344
|
-
import { ${ClassName}WidgetUI } from './ui'
|
|
1345
|
-
import {
|
|
1322
|
+
import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
|
|
1323
|
+
import { use${ClassName}UIModel } from './hooks/${uiModelFileName}'
|
|
1346
1324
|
|
|
1347
1325
|
export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
|
|
1348
|
-
const uiModel =
|
|
1326
|
+
const uiModel = use${ClassName}UIModel(props)
|
|
1349
1327
|
return <${ClassName}WidgetUI {...uiModel} />
|
|
1350
1328
|
}
|
|
1351
1329
|
|
|
@@ -1353,7 +1331,7 @@ export type { ${ClassName}WidgetProps }
|
|
|
1353
1331
|
`.trim());
|
|
1354
1332
|
folder.subitem([
|
|
1355
1333
|
'ui'
|
|
1356
|
-
]).createFile(
|
|
1334
|
+
]).createFile(`${uiFileName}.tsx`, `
|
|
1357
1335
|
import { FC } from 'react'
|
|
1358
1336
|
import type { ${ClassName}WidgetUIProps } from '../types'
|
|
1359
1337
|
|
|
@@ -1363,10 +1341,10 @@ export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
|
|
|
1363
1341
|
`.trim());
|
|
1364
1342
|
folder.subitem([
|
|
1365
1343
|
'hooks'
|
|
1366
|
-
]).createFile(
|
|
1344
|
+
]).createFile(`${uiModelFileName}.ts`, `
|
|
1367
1345
|
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
1368
1346
|
|
|
1369
|
-
export const
|
|
1347
|
+
export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
|
|
1370
1348
|
return {}
|
|
1371
1349
|
}
|
|
1372
1350
|
`.trim());
|
|
@@ -1382,13 +1360,13 @@ export type ${ClassName}WidgetProps = {
|
|
|
1382
1360
|
}
|
|
1383
1361
|
|
|
1384
1362
|
`.trim());
|
|
1385
|
-
folder.createFile(
|
|
1363
|
+
folder.createFile(`${widgetFileName}.tsx`, `
|
|
1386
1364
|
import { type FC } from 'react'
|
|
1387
1365
|
import type { ${ClassName}WidgetProps } from './types'
|
|
1388
|
-
import {
|
|
1366
|
+
import { use${ClassName}UIModel } from './hooks/${uiModelFileName}'
|
|
1389
1367
|
|
|
1390
1368
|
export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
|
|
1391
|
-
const uiModel =
|
|
1369
|
+
const uiModel = use${ClassName}UIModel(props)
|
|
1392
1370
|
return <props.UI {...uiModel} />
|
|
1393
1371
|
}
|
|
1394
1372
|
|
|
@@ -1396,10 +1374,10 @@ export type { ${ClassName}WidgetProps }
|
|
|
1396
1374
|
`.trim());
|
|
1397
1375
|
folder.subitem([
|
|
1398
1376
|
'hooks'
|
|
1399
|
-
]).createFile(
|
|
1377
|
+
]).createFile(`${uiModelFileName}.ts`, `
|
|
1400
1378
|
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
1401
1379
|
|
|
1402
|
-
export const
|
|
1380
|
+
export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps, 'UI'>): ${ClassName}WidgetUIProps => {
|
|
1403
1381
|
return {}
|
|
1404
1382
|
}
|
|
1405
1383
|
`.trim());
|