@domain-first/project-structure 2.8.1 → 2.9.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 CHANGED
@@ -118,7 +118,8 @@ src/
118
118
  └── react/
119
119
  ├── pages/
120
120
  ├── widgets/
121
- └── ui-kit/
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.
@@ -186,6 +187,7 @@ Enable `useReact` and choose **Scaffold React module** from the main menu. Modul
186
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`. |
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
 
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: '
@@ -1458,7 +1471,8 @@ const main = async ()=>{
1458
1471
  choices: [
1459
1472
  'New widget',
1460
1473
  'New page',
1461
- 'New UI-kit component'
1474
+ 'New UI-kit component',
1475
+ 'New shared hook'
1462
1476
  ]
1463
1477
  });
1464
1478
  switch(action){
@@ -1468,6 +1482,8 @@ const main = async ()=>{
1468
1482
  return void await scaffoldReactPage(reactFolder);
1469
1483
  case 'New UI-kit component':
1470
1484
  return void await scaffoldReactUIKitComponent(reactFolder);
1485
+ case 'New shared hook':
1486
+ return void await scaffoldReactSharedHook(reactFolder);
1471
1487
  default:
1472
1488
  return;
1473
1489
  }
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: '
@@ -1428,7 +1441,8 @@ const main = async ()=>{
1428
1441
  choices: [
1429
1442
  'New widget',
1430
1443
  'New page',
1431
- 'New UI-kit component'
1444
+ 'New UI-kit component',
1445
+ 'New shared hook'
1432
1446
  ]
1433
1447
  });
1434
1448
  switch(action){
@@ -1438,6 +1452,8 @@ const main = async ()=>{
1438
1452
  return void await scaffoldReactPage(reactFolder);
1439
1453
  case 'New UI-kit component':
1440
1454
  return void await scaffoldReactUIKitComponent(reactFolder);
1455
+ case 'New shared hook':
1456
+ return void await scaffoldReactSharedHook(reactFolder);
1441
1457
  default:
1442
1458
  return;
1443
1459
  }
@@ -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';
@@ -0,0 +1,2 @@
1
+ import type { Folder } from '../file-system';
2
+ export declare const scaffoldReactSharedHook: (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.8.1",
4
+ "version": "2.9.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",