@alevnyacow/nzmt 0.40.3 → 0.41.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/bin/cli.js +42 -2
- package/package.json +1 -1
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,41 @@ 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
|
+
if (entityName.includes('/')) {
|
|
1467
|
+
const splitData = entityName.split('/')
|
|
1468
|
+
entityName = splitData.pop()
|
|
1469
|
+
rootPath = splitData.join('/')
|
|
1470
|
+
}
|
|
1471
|
+
generateWidget(entityName, rootPath)
|
|
1472
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alevnyacow/nzmt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.1",
|
|
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": {
|