@alevnyacow/nzmt 0.40.2 → 0.41.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.
Files changed (3) hide show
  1. package/README.md +5 -13
  2. package/bin/cli.js +41 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  <img src='https://img.shields.io/npm/l/%40alevnyacow%2Fnzmt'></img>
9
9
  </p>
10
10
 
11
- Scaffold full-stack modules in Next.js in seconds with **Next Zod Modules Toolkit (NZMT)**.
11
+ Scaffold Next.js full-stack modules in seconds with **Next Zod Modules Toolkit (NZMT)**.
12
12
 
13
13
  Get a domain-focused architecture with a contract-first approach out of the box.
14
14
 
@@ -23,8 +23,8 @@ https://stackblitz.com/edit/nzmt-playground
23
23
 
24
24
  # What you get
25
25
 
26
- Get production-ready backend + React Query hooks after one CLI command with NZMT. Install and initialize it, then run:
27
-
26
+ After installing and initializing NZMT, run one CLI command to generate a production-ready backend with React Query hooks:
27
+
28
28
  ```bash
29
29
  npx nzmt crud-api user
30
30
  ```
@@ -43,18 +43,10 @@ app/api/user/... # api routes
43
43
  ui/shared/queries/user/... # react queries
44
44
  ```
45
45
 
46
- Everything is already setup and ready-to-use after a few tweaks. See `Quick start with Prisma` section for more detailed information.
47
-
48
- NZMT also comes with useful infrastructure like DI, logging, in-memory stores, unified errors, and endpoint guards. All code is editable, so you stay in full control. Full `crud-api` is only one of cases, you can scaffold entities, stores, services, controllers and infrastructure helpers on its own and combine them any way you want. List of all NZMT cli commands is provided in `CLI commands glossary` sections.
46
+ Features DI, logging, in-memory stores, unified errors, and endpoint guards. Everything is ready after a few tweaks see `Quick start with Prisma` for details.
49
47
 
50
- Fully wired flow:
51
- ```bash
52
- # client fetching
53
- Client → React Query → API → Controller → Service → Store → DB
48
+ All code is editable — scaffold parts individually or together. CLI commands are listed in `CLI commands glossary`.
54
49
 
55
- # server actions
56
- Server Action → Service → Store → DB
57
- ```
58
50
 
59
51
  # Quick start with Prisma
60
52
 
package/bin/cli.js CHANGED
@@ -112,7 +112,8 @@ function createDefaultConfig() {
112
112
  valueObjects: '/domain/value-objects',
113
113
  sharedErrors: '/domain/errors',
114
114
  queries: '/ui/shared/queries',
115
- clientUtils: '/ui/shared/utils'
115
+ clientUtils: '/ui/shared/utils',
116
+ widgets: '/ui/widgets'
116
117
  },
117
118
  store: {
118
119
  prisma: {
@@ -135,7 +136,8 @@ function createDefaultConfig() {
135
136
  valueObjects: '/domain/value-objects',
136
137
  sharedErrors: '/domain/errors',
137
138
  queries: '/ui/shared/queries',
138
- clientUtils: '/ui/shared/utils'
139
+ clientUtils: '/ui/shared/utils',
140
+ widgets: '/ui/widgets'
139
141
  },
140
142
  services: {
141
143
  defaultInjections: []
@@ -1430,3 +1432,40 @@ if (command.toLowerCase() === 'crud-api') {
1430
1432
  process.exit(0)
1431
1433
  }
1432
1434
 
1435
+ function generateWidget(name, rootPath) {
1436
+ const [lowerCase, upperCase] = camelizeVariants(name)
1437
+
1438
+ const widgetsPath = config.paths.widgets
1439
+ const root = findProjectRoot()
1440
+
1441
+ const folder = path.resolve(root, widgetsPath, rootPath ?? '.', name)
1442
+ fs.mkdirSync(folder, { recursive: true })
1443
+
1444
+ fs.writeFileSync(path.resolve(folder, `${lowerCase}.widget.tsx`), [
1445
+ `import { FC } from 'react'`,
1446
+ `import styles from './${lowerCase}.widget.module.css'`,
1447
+ ``,
1448
+ `export type ${upperCase}WidgetProps = {}`,
1449
+ ``,
1450
+ `export const ${upperCase}Widget: FC<${upperCase}WidgetProps> = ({ }) => {`,
1451
+ `\treturn undefined`,
1452
+ `}`
1453
+ ].join('\n'))
1454
+
1455
+ fs.writeFileSync(path.resolve(folder, `${lowerCase}.widget.module.css`), [
1456
+ ''
1457
+ ].join('\n'))
1458
+
1459
+ fs.writeFileSync(path.resolve(folder, `index.ts`), [
1460
+ `export * from './${name}.widget'`
1461
+ ].join('\n'))
1462
+ }
1463
+
1464
+ if (command === 'w') {
1465
+ let rootPath = undefined
1466
+ const rootPathOption = (options ?? []).find(x => x.startsWith('root:'))
1467
+ if (rootPathOption) {
1468
+ rootPath = rootPathOption.split(':')[1]
1469
+ }
1470
+ generateWidget(entityName, rootPath)
1471
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alevnyacow/nzmt",
3
- "version": "0.40.2",
3
+ "version": "0.41.0",
4
4
  "description": "Next Zod Modules Toolkit",
5
5
  "keywords": ["next", "full-stack", "server", "backend", "cli", "scaffolding", "zod", "rest", "contract programming", "contract-first", "react-query", "ddd", "domain-driven"],
6
6
  "repository": {