@alevnyacow/nzmt 0.41.2 → 0.42.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/bin/cli.js +64 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1469,4 +1469,68 @@ if (command === 'w') {
|
|
|
1469
1469
|
rootPath = splitData.join('/')
|
|
1470
1470
|
}
|
|
1471
1471
|
generateWidget(entityName, rootPath)
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
function generateLayoutedWidget(name, rootPath) {
|
|
1475
|
+
const [lowerCase, upperCase] = camelizeVariants(name)
|
|
1476
|
+
|
|
1477
|
+
const widgetsPath = config.paths.widgets
|
|
1478
|
+
const root = findProjectRoot()
|
|
1479
|
+
|
|
1480
|
+
const folder = path.resolve(root, `${config.coreFolder}${widgetsPath}`, rootPath ?? '.', name)
|
|
1481
|
+
fs.mkdirSync(folder, { recursive: true })
|
|
1482
|
+
|
|
1483
|
+
fs.writeFileSync(path.resolve(folder, `${name}.headless-widget.tsx`), [
|
|
1484
|
+
`import { FC } from 'react'`,
|
|
1485
|
+
`import { ${upperCase}WidgetLayoutProps } from './${name}.widget-layout'`,
|
|
1486
|
+
``,
|
|
1487
|
+
`export type ${upperCase}HeadlessWidgetProps = {`,
|
|
1488
|
+
`\tLayout: FC<${upperCase}WidgetLayoutProps>,`,
|
|
1489
|
+
``,
|
|
1490
|
+
`export const ${upperCase}HeadlessWidget: FC<${upperCase}HeadlessWidgetProps> = ({ Layout }) => {`,
|
|
1491
|
+
`\treturn <Layout />`,
|
|
1492
|
+
`}`
|
|
1493
|
+
].join('\n'))
|
|
1494
|
+
|
|
1495
|
+
fs.writeFileSync(path.resolve(folder, `${name}.widget-layout.module.css`), [
|
|
1496
|
+
''
|
|
1497
|
+
].join('\n'))
|
|
1498
|
+
|
|
1499
|
+
fs.writeFileSync(path.resolve(folder, `${name}.widget-layout.tsx`), [
|
|
1500
|
+
`import { FC } from 'react'`,
|
|
1501
|
+
`import styles from './${name}.widget-layout.module.css'`,
|
|
1502
|
+
``,
|
|
1503
|
+
`export type ${upperCase}WidgetLayoutProps = {}`,
|
|
1504
|
+
``,
|
|
1505
|
+
`export const ${upperCase}WidgetLayout: FC<${upperCase}WidgetLayoutProps> = ({}) => {`,
|
|
1506
|
+
`\treturn undefined`,
|
|
1507
|
+
`}`
|
|
1508
|
+
].join('\n'))
|
|
1509
|
+
|
|
1510
|
+
fs.writeFileSync(path.resolve(folder, `${name}.widget.tsx`), [
|
|
1511
|
+
`import { FC } from 'react'`,
|
|
1512
|
+
`import { ${upperCase}HeadlessWidget, ${upperCase}HeadlessWidgetProps } from './${name}.headless-widget'`,
|
|
1513
|
+
`import { ${upperCase}WidgetLayout } from './${name}.widget-layout'`,
|
|
1514
|
+
``,
|
|
1515
|
+
`export type ${upperCase}WidgetProps = Omit<${upperCase}HeadlessWidgetProps, 'Layout'>`,
|
|
1516
|
+
``,
|
|
1517
|
+
`export const ${upperCase}Widget: FC<${upperCase}WidgetProps> = (props) => {`,
|
|
1518
|
+
`\treturn <${upperCase}HeadlessWidget Layout={${upperCase}WidgetLayout} {...props}/>`,
|
|
1519
|
+
`}`
|
|
1520
|
+
].join('\n'))
|
|
1521
|
+
|
|
1522
|
+
fs.writeFileSync(path.resolve(folder, `index.ts`), [
|
|
1523
|
+
`export * from './${name}.widget'`
|
|
1524
|
+
].join('\n'))
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
|
|
1528
|
+
if (command === 'lw') {
|
|
1529
|
+
let rootPath = undefined
|
|
1530
|
+
if (entityName.includes('/')) {
|
|
1531
|
+
const splitData = entityName.split('/')
|
|
1532
|
+
entityName = splitData.pop()
|
|
1533
|
+
rootPath = splitData.join('/')
|
|
1534
|
+
}
|
|
1535
|
+
generateLayoutedWidget(entityName, rootPath)
|
|
1472
1536
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alevnyacow/nzmt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.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": {
|