@domain-first/project-structure 2.8.1 → 2.9.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 +5 -3
- package/dist/index.cjs +48 -10
- package/dist/index.js +48 -10
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/scaffold-react-shared-hook.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,7 +118,8 @@ src/
|
|
|
118
118
|
└── react/
|
|
119
119
|
├── pages/
|
|
120
120
|
├── widgets/
|
|
121
|
-
|
|
121
|
+
├── ui-kit/
|
|
122
|
+
└── hooks/
|
|
122
123
|
```
|
|
123
124
|
|
|
124
125
|
This is an example of the accumulated output; creating a context alone creates its directory and, when enabled, its error namespace.
|
|
@@ -183,9 +184,10 @@ Enable `useReact` and choose **Scaffold React module** from the main menu. Modul
|
|
|
183
184
|
| ------------------------------ | ---------------------------------------------------------------------------------------------------------- |
|
|
184
185
|
| New page | `pages/<name>-page.tsx` with a typed props object and a component. |
|
|
185
186
|
| 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 → with separated ui | `<name>-widget.tsx`, `types.ts`, `ui/<name>-widget-ui.tsx`, `hooks/use-<name>-ui-model.ts`, and `index.ts`; with `storybookFramework`, also `ui/<name>-widget-ui.stories.tsx`. |
|
|
187
188
|
| New widget → headless | `<name>-widget.tsx`, types, a UI-model hook, and `index.ts`; the rendering component is supplied through the `UI` prop. |
|
|
188
189
|
| 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`. |
|
|
190
|
+
| New shared hook | `hooks/use-<name>.ts` with an app-wide hook, such as `use-debounce`; a leading `use-` in the name is not repeated. |
|
|
189
191
|
|
|
190
192
|
## Configuration
|
|
191
193
|
|
|
@@ -214,7 +216,7 @@ The project configuration is stored in `domain-first.project-structure.config.js
|
|
|
214
216
|
| `domainFirstPackages` | Explicit list of integrations used by templates. An empty array selects basic class templates where supported. |
|
|
215
217
|
| `defaultPersistenceLayerImplementation` | Suggested implementation label for execution commands and queries. |
|
|
216
218
|
| `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. |
|
|
219
|
+
| `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 and widget UI. Asked during setup only when React is enabled. |
|
|
218
220
|
| `testingLibrary` | Module imported by generated tests. Omit this field to disable test generation. Templates expect helpers such as `describe`, `test`, `expect`, and `beforeEach`. |
|
|
219
221
|
|
|
220
222
|
### Package integrations
|
package/dist/index.cjs
CHANGED
|
@@ -1269,6 +1269,19 @@ export const ${ClassName}Page: FC<${ClassName}PageProps> = (props) => {
|
|
|
1269
1269
|
}
|
|
1270
1270
|
`.trim());
|
|
1271
1271
|
};
|
|
1272
|
+
const scaffoldReactSharedHook = async (presentationReactFolder)=>{
|
|
1273
|
+
const name = await (0, prompts_namespaceObject.input)({
|
|
1274
|
+
message: 'Name without "use" (e.g. debounce): '
|
|
1275
|
+
});
|
|
1276
|
+
const { ClassName, fileName } = new UnknownFormatNaming(name.trim().replace(/^use-/, ''));
|
|
1277
|
+
presentationReactFolder.subitem([
|
|
1278
|
+
'hooks'
|
|
1279
|
+
]).createFile(`use-${fileName}.ts`, `
|
|
1280
|
+
export const use${ClassName} = () => {
|
|
1281
|
+
return {}
|
|
1282
|
+
}
|
|
1283
|
+
`.trim());
|
|
1284
|
+
};
|
|
1272
1285
|
const scaffoldReactUIKitComponent = async (presentationReactFolder)=>{
|
|
1273
1286
|
const name = await (0, prompts_namespaceObject.input)({
|
|
1274
1287
|
message: 'Name: '
|
|
@@ -1341,12 +1354,13 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
|
|
|
1341
1354
|
`.trim());
|
|
1342
1355
|
break;
|
|
1343
1356
|
case 'with separated ui':
|
|
1344
|
-
|
|
1357
|
+
{
|
|
1358
|
+
folder.createFile('types.ts', `
|
|
1345
1359
|
export type ${ClassName}WidgetProps = { }
|
|
1346
1360
|
|
|
1347
1361
|
export type ${ClassName}WidgetUIProps = { }
|
|
1348
1362
|
`.trim());
|
|
1349
|
-
|
|
1363
|
+
folder.createFile(`${widgetFileName}.tsx`, `
|
|
1350
1364
|
import { type FC } from 'react'
|
|
1351
1365
|
import type { ${ClassName}WidgetProps } from './types'
|
|
1352
1366
|
import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
|
|
@@ -1359,9 +1373,9 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
|
|
|
1359
1373
|
|
|
1360
1374
|
export type { ${ClassName}WidgetProps }
|
|
1361
1375
|
`.trim());
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1376
|
+
folder.subitem([
|
|
1377
|
+
'ui'
|
|
1378
|
+
]).createFile(`${uiFileName}.tsx`, `
|
|
1365
1379
|
import { FC } from 'react'
|
|
1366
1380
|
import type { ${ClassName}WidgetUIProps } from '../types'
|
|
1367
1381
|
|
|
@@ -1369,16 +1383,37 @@ export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
|
|
|
1369
1383
|
return <></>
|
|
1370
1384
|
}
|
|
1371
1385
|
`.trim());
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1386
|
+
const { storybookFramework } = ConfigFile.Instance.data;
|
|
1387
|
+
if (storybookFramework) folder.subitem([
|
|
1388
|
+
'ui'
|
|
1389
|
+
]).createFile(`${uiFileName}.stories.tsx`, `
|
|
1390
|
+
import type { Meta, StoryObj } from '${storybookFramework}'
|
|
1391
|
+
import { ${ClassName}WidgetUI } from './${uiFileName}'
|
|
1392
|
+
|
|
1393
|
+
const meta = {
|
|
1394
|
+
title: 'Widgets/${ClassName}',
|
|
1395
|
+
component: ${ClassName}WidgetUI
|
|
1396
|
+
} satisfies Meta<typeof ${ClassName}WidgetUI>
|
|
1397
|
+
|
|
1398
|
+
export default meta
|
|
1399
|
+
|
|
1400
|
+
type Story = StoryObj<typeof meta>
|
|
1401
|
+
|
|
1402
|
+
export const Default: Story = {
|
|
1403
|
+
args: {}
|
|
1404
|
+
}
|
|
1405
|
+
`.trim());
|
|
1406
|
+
folder.subitem([
|
|
1407
|
+
'hooks'
|
|
1408
|
+
]).createFile(`${uiModelFileName}.ts`, `
|
|
1375
1409
|
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
1376
1410
|
|
|
1377
1411
|
export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
|
|
1378
1412
|
return {}
|
|
1379
1413
|
}
|
|
1380
1414
|
`.trim());
|
|
1381
|
-
|
|
1415
|
+
break;
|
|
1416
|
+
}
|
|
1382
1417
|
case 'headless':
|
|
1383
1418
|
folder.createFile('types.ts', `
|
|
1384
1419
|
import { type FC } from 'react'
|
|
@@ -1458,7 +1493,8 @@ const main = async ()=>{
|
|
|
1458
1493
|
choices: [
|
|
1459
1494
|
'New widget',
|
|
1460
1495
|
'New page',
|
|
1461
|
-
'New UI-kit component'
|
|
1496
|
+
'New UI-kit component',
|
|
1497
|
+
'New shared hook'
|
|
1462
1498
|
]
|
|
1463
1499
|
});
|
|
1464
1500
|
switch(action){
|
|
@@ -1468,6 +1504,8 @@ const main = async ()=>{
|
|
|
1468
1504
|
return void await scaffoldReactPage(reactFolder);
|
|
1469
1505
|
case 'New UI-kit component':
|
|
1470
1506
|
return void await scaffoldReactUIKitComponent(reactFolder);
|
|
1507
|
+
case 'New shared hook':
|
|
1508
|
+
return void await scaffoldReactSharedHook(reactFolder);
|
|
1471
1509
|
default:
|
|
1472
1510
|
return;
|
|
1473
1511
|
}
|
package/dist/index.js
CHANGED
|
@@ -1239,6 +1239,19 @@ export const ${ClassName}Page: FC<${ClassName}PageProps> = (props) => {
|
|
|
1239
1239
|
}
|
|
1240
1240
|
`.trim());
|
|
1241
1241
|
};
|
|
1242
|
+
const scaffoldReactSharedHook = async (presentationReactFolder)=>{
|
|
1243
|
+
const name = await input({
|
|
1244
|
+
message: 'Name without "use" (e.g. debounce): '
|
|
1245
|
+
});
|
|
1246
|
+
const { ClassName, fileName } = new UnknownFormatNaming(name.trim().replace(/^use-/, ''));
|
|
1247
|
+
presentationReactFolder.subitem([
|
|
1248
|
+
'hooks'
|
|
1249
|
+
]).createFile(`use-${fileName}.ts`, `
|
|
1250
|
+
export const use${ClassName} = () => {
|
|
1251
|
+
return {}
|
|
1252
|
+
}
|
|
1253
|
+
`.trim());
|
|
1254
|
+
};
|
|
1242
1255
|
const scaffoldReactUIKitComponent = async (presentationReactFolder)=>{
|
|
1243
1256
|
const name = await input({
|
|
1244
1257
|
message: 'Name: '
|
|
@@ -1311,12 +1324,13 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
|
|
|
1311
1324
|
`.trim());
|
|
1312
1325
|
break;
|
|
1313
1326
|
case 'with separated ui':
|
|
1314
|
-
|
|
1327
|
+
{
|
|
1328
|
+
folder.createFile('types.ts', `
|
|
1315
1329
|
export type ${ClassName}WidgetProps = { }
|
|
1316
1330
|
|
|
1317
1331
|
export type ${ClassName}WidgetUIProps = { }
|
|
1318
1332
|
`.trim());
|
|
1319
|
-
|
|
1333
|
+
folder.createFile(`${widgetFileName}.tsx`, `
|
|
1320
1334
|
import { type FC } from 'react'
|
|
1321
1335
|
import type { ${ClassName}WidgetProps } from './types'
|
|
1322
1336
|
import { ${ClassName}WidgetUI } from './ui/${uiFileName}'
|
|
@@ -1329,9 +1343,9 @@ export const ${ClassName}Widget: FC<${ClassName}WidgetProps> = (props) => {
|
|
|
1329
1343
|
|
|
1330
1344
|
export type { ${ClassName}WidgetProps }
|
|
1331
1345
|
`.trim());
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1346
|
+
folder.subitem([
|
|
1347
|
+
'ui'
|
|
1348
|
+
]).createFile(`${uiFileName}.tsx`, `
|
|
1335
1349
|
import { FC } from 'react'
|
|
1336
1350
|
import type { ${ClassName}WidgetUIProps } from '../types'
|
|
1337
1351
|
|
|
@@ -1339,16 +1353,37 @@ export const ${ClassName}WidgetUI: FC<${ClassName}WidgetUIProps> = (props) => {
|
|
|
1339
1353
|
return <></>
|
|
1340
1354
|
}
|
|
1341
1355
|
`.trim());
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1356
|
+
const { storybookFramework } = ConfigFile.Instance.data;
|
|
1357
|
+
if (storybookFramework) folder.subitem([
|
|
1358
|
+
'ui'
|
|
1359
|
+
]).createFile(`${uiFileName}.stories.tsx`, `
|
|
1360
|
+
import type { Meta, StoryObj } from '${storybookFramework}'
|
|
1361
|
+
import { ${ClassName}WidgetUI } from './${uiFileName}'
|
|
1362
|
+
|
|
1363
|
+
const meta = {
|
|
1364
|
+
title: 'Widgets/${ClassName}',
|
|
1365
|
+
component: ${ClassName}WidgetUI
|
|
1366
|
+
} satisfies Meta<typeof ${ClassName}WidgetUI>
|
|
1367
|
+
|
|
1368
|
+
export default meta
|
|
1369
|
+
|
|
1370
|
+
type Story = StoryObj<typeof meta>
|
|
1371
|
+
|
|
1372
|
+
export const Default: Story = {
|
|
1373
|
+
args: {}
|
|
1374
|
+
}
|
|
1375
|
+
`.trim());
|
|
1376
|
+
folder.subitem([
|
|
1377
|
+
'hooks'
|
|
1378
|
+
]).createFile(`${uiModelFileName}.ts`, `
|
|
1345
1379
|
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
1346
1380
|
|
|
1347
1381
|
export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
|
|
1348
1382
|
return {}
|
|
1349
1383
|
}
|
|
1350
1384
|
`.trim());
|
|
1351
|
-
|
|
1385
|
+
break;
|
|
1386
|
+
}
|
|
1352
1387
|
case 'headless':
|
|
1353
1388
|
folder.createFile('types.ts', `
|
|
1354
1389
|
import { type FC } from 'react'
|
|
@@ -1428,7 +1463,8 @@ const main = async ()=>{
|
|
|
1428
1463
|
choices: [
|
|
1429
1464
|
'New widget',
|
|
1430
1465
|
'New page',
|
|
1431
|
-
'New UI-kit component'
|
|
1466
|
+
'New UI-kit component',
|
|
1467
|
+
'New shared hook'
|
|
1432
1468
|
]
|
|
1433
1469
|
});
|
|
1434
1470
|
switch(action){
|
|
@@ -1438,6 +1474,8 @@ const main = async ()=>{
|
|
|
1438
1474
|
return void await scaffoldReactPage(reactFolder);
|
|
1439
1475
|
case 'New UI-kit component':
|
|
1440
1476
|
return void await scaffoldReactUIKitComponent(reactFolder);
|
|
1477
|
+
case 'New shared hook':
|
|
1478
|
+
return void await scaffoldReactSharedHook(reactFolder);
|
|
1441
1479
|
default:
|
|
1442
1480
|
return;
|
|
1443
1481
|
}
|
|
@@ -12,5 +12,6 @@ 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-shared-hook';
|
|
15
16
|
export * from './scaffold-react-ui-kit-component';
|
|
16
17
|
export * from './scaffold-react-widget';
|