@alevnyacow/nzmt 0.26.3 → 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 +15 -8
- 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}`)
|
|
@@ -415,18 +424,17 @@ function generateInfrastructure(upperCase, lowerCase) {
|
|
|
415
424
|
`\tname: '${upperCase}Infrastructure',`,
|
|
416
425
|
`\tschemas: {}`,
|
|
417
426
|
`} satisfies Module.Metadata`,
|
|
418
|
-
``,
|
|
419
|
-
`const methods = Module.methods(${lowerCase}InfrastructureMetadata)`,
|
|
420
427
|
'',
|
|
421
428
|
`export class ${upperCase} {`,
|
|
422
|
-
`\
|
|
429
|
+
`\tprivate methods = Module.methods(${lowerCase}InfrastructureMetadata)`,
|
|
423
430
|
`}`
|
|
424
431
|
].join('\n'))
|
|
425
432
|
|
|
426
433
|
fs.writeFileSync(path.resolve(folder, `${entityName}.mock.ts`), [
|
|
434
|
+
`import { PublicFields } from '@/${config.paths.infrastructure}/ts-helpers'`,
|
|
427
435
|
`import { ${upperCase} } from './${entityName}'`,
|
|
428
436
|
'',
|
|
429
|
-
`export class Mock${upperCase} implements
|
|
437
|
+
`export class Mock${upperCase} implements PublicFields<${upperCase}> {`,
|
|
430
438
|
`\t`,
|
|
431
439
|
`}`
|
|
432
440
|
].join('\n'))
|
|
@@ -541,6 +549,7 @@ if (command.toLowerCase() === 'init') {
|
|
|
541
549
|
initPrisma()
|
|
542
550
|
initLogger()
|
|
543
551
|
initGuards()
|
|
552
|
+
initTSHelpers()
|
|
544
553
|
|
|
545
554
|
process.exit(0)
|
|
546
555
|
}
|
|
@@ -832,7 +841,6 @@ if (command.toLowerCase() === 'value-object' || command === 'vo') {
|
|
|
832
841
|
|
|
833
842
|
function generateProvider(lowerCase, upperCase) {
|
|
834
843
|
const folder = config?.paths?.providers ? path.resolve(process.cwd(), `${config.coreFolder}${config?.paths?.providers}`, entityName) : path.resolve(process.cwd(), entityName);
|
|
835
|
-
const providerType = options.find(x => x.startsWith('pt:'))?.split(':')?.at(1) ?? 'API'
|
|
836
844
|
|
|
837
845
|
fs.mkdirSync(folder, { recursive: true })
|
|
838
846
|
|
|
@@ -844,16 +852,15 @@ function generateProvider(lowerCase, upperCase) {
|
|
|
844
852
|
`\tname: '${upperCase}Provider',`,
|
|
845
853
|
`\tschemas: {}`,
|
|
846
854
|
`} satisfies Module.Metadata`,
|
|
847
|
-
``,
|
|
848
|
-
`const methods = Module.methods(${lowerCase}ProviderMetadata)`,
|
|
849
855
|
'',
|
|
850
856
|
`export class ${upperCase}Provider {`,
|
|
851
|
-
`\
|
|
857
|
+
`\tprivate methods = Module.methods(${lowerCase}ProviderMetadata)`,
|
|
852
858
|
`}`
|
|
853
859
|
].join('\n'))
|
|
854
860
|
|
|
855
861
|
// Mock
|
|
856
862
|
fs.writeFileSync(path.resolve(folder, `${entityName}.provider.mock.ts`), [
|
|
863
|
+
`import { PublicFields } from '@/${config.paths.infrastructure}/ts-helpers'`,
|
|
857
864
|
`import { ${upperCase}Provider } from './${entityName}.provider'`,
|
|
858
865
|
'',
|
|
859
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": {
|