@alevnyacow/nzmt 0.26.2 → 0.26.4
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 +22 -6
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -152,6 +152,15 @@ function initSharedErrors() {
|
|
|
152
152
|
fs.writeFileSync(path.resolve(folder, 'index.ts'), "export * from './shared-error-codes'")
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
function initTSHelpers() {
|
|
156
|
+
const config = loadConfig()
|
|
157
|
+
const folder = path.resolve(process.cwd(), `${config.coreFolder}${config.paths.infrastructure}`)
|
|
158
|
+
|
|
159
|
+
fs.writeFileSync(path.resolve(folder, 'ts-helpers.ts'), [
|
|
160
|
+
"export type PublicFields<A> = { [k in keyof A]: A[k] }",
|
|
161
|
+
].join('\n'))
|
|
162
|
+
}
|
|
163
|
+
|
|
155
164
|
function initVO() {
|
|
156
165
|
const config = loadConfig()
|
|
157
166
|
const voFolder = path.resolve(process.cwd(), `${config.coreFolder}${config.paths.valueObjects}`)
|
|
@@ -409,15 +418,23 @@ function generateInfrastructure(upperCase, lowerCase) {
|
|
|
409
418
|
fs.mkdirSync(folder, { recursive: true })
|
|
410
419
|
|
|
411
420
|
fs.writeFileSync(path.resolve(folder, `${entityName}.ts`), [
|
|
421
|
+
`import { Module } from '@alevnyacow/nzmt'`,
|
|
422
|
+
'',
|
|
423
|
+
`export const ${lowerCase}InfrastructureMetadata = {`,
|
|
424
|
+
`\tname: '${upperCase}Infrastructure',`,
|
|
425
|
+
`\tschemas: {}`,
|
|
426
|
+
`} satisfies Module.Metadata`,
|
|
427
|
+
'',
|
|
412
428
|
`export class ${upperCase} {`,
|
|
413
|
-
`\
|
|
429
|
+
`\tprivate methods = Module.methods(${lowerCase}InfrastructureMetadata)`,
|
|
414
430
|
`}`
|
|
415
431
|
].join('\n'))
|
|
416
432
|
|
|
417
433
|
fs.writeFileSync(path.resolve(folder, `${entityName}.mock.ts`), [
|
|
434
|
+
`import { PublicFields } from '@/${config.paths.infrastructure}/ts-helpers'`,
|
|
418
435
|
`import { ${upperCase} } from './${entityName}'`,
|
|
419
436
|
'',
|
|
420
|
-
`export class Mock${upperCase} implements
|
|
437
|
+
`export class Mock${upperCase} implements PublicFields<${upperCase}> {`,
|
|
421
438
|
`\t`,
|
|
422
439
|
`}`
|
|
423
440
|
].join('\n'))
|
|
@@ -532,6 +549,7 @@ if (command.toLowerCase() === 'init') {
|
|
|
532
549
|
initPrisma()
|
|
533
550
|
initLogger()
|
|
534
551
|
initGuards()
|
|
552
|
+
initTSHelpers()
|
|
535
553
|
|
|
536
554
|
process.exit(0)
|
|
537
555
|
}
|
|
@@ -823,7 +841,6 @@ if (command.toLowerCase() === 'value-object' || command === 'vo') {
|
|
|
823
841
|
|
|
824
842
|
function generateProvider(lowerCase, upperCase) {
|
|
825
843
|
const folder = config?.paths?.providers ? path.resolve(process.cwd(), `${config.coreFolder}${config?.paths?.providers}`, entityName) : path.resolve(process.cwd(), entityName);
|
|
826
|
-
const providerType = options.find(x => x.startsWith('pt:'))?.split(':')?.at(1) ?? 'API'
|
|
827
844
|
|
|
828
845
|
fs.mkdirSync(folder, { recursive: true })
|
|
829
846
|
|
|
@@ -835,16 +852,15 @@ function generateProvider(lowerCase, upperCase) {
|
|
|
835
852
|
`\tname: '${upperCase}Provider',`,
|
|
836
853
|
`\tschemas: {}`,
|
|
837
854
|
`} satisfies Module.Metadata`,
|
|
838
|
-
``,
|
|
839
|
-
`const methods = Module.methods(${lowerCase}ProviderMetadata)`,
|
|
840
855
|
'',
|
|
841
856
|
`export class ${upperCase}Provider {`,
|
|
842
|
-
`\
|
|
857
|
+
`\tprivate methods = Module.methods(${lowerCase}ProviderMetadata)`,
|
|
843
858
|
`}`
|
|
844
859
|
].join('\n'))
|
|
845
860
|
|
|
846
861
|
// Mock
|
|
847
862
|
fs.writeFileSync(path.resolve(folder, `${entityName}.provider.mock.ts`), [
|
|
863
|
+
`import { PublicFields } from '@/${config.paths.infrastructure}/ts-helpers'`,
|
|
848
864
|
`import { ${upperCase}Provider } from './${entityName}.provider'`,
|
|
849
865
|
'',
|
|
850
866
|
`export class ${upperCase}MockProvider implements ${upperCase}Provider {`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alevnyacow/nzmt",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.4",
|
|
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": {
|