@alevnyacow/nzmt 0.2.4 → 0.3.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 +12 -2
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -439,6 +439,7 @@ if (command === 'store') {
|
|
|
439
439
|
|
|
440
440
|
function generateEntity(upperCase) {
|
|
441
441
|
const folder = config?.paths?.entities ? path.resolve(process.cwd(), config?.paths?.entities, entityName) : path.resolve(process.cwd(), entityName);
|
|
442
|
+
const fields = options.filter(x => x.startsWith('f:')).flatMap(x => x.split(':')[1]).join(',').split(',').map(x => x.split('-'))
|
|
442
443
|
|
|
443
444
|
fs.mkdirSync(folder, { recursive: true })
|
|
444
445
|
|
|
@@ -451,7 +452,11 @@ function generateEntity(upperCase) {
|
|
|
451
452
|
`export class ${upperCase} {`,
|
|
452
453
|
"\tstatic schema = z.object({",
|
|
453
454
|
"\t\tid: Entities.Identifier.schema,",
|
|
454
|
-
|
|
455
|
+
fields.length ?
|
|
456
|
+
fields.map(([fieldName, description]) => {
|
|
457
|
+
return `\t\t${fieldName}: z.${description.split('.').join('().')}(),`
|
|
458
|
+
}).join('\n')
|
|
459
|
+
: "\t\t",
|
|
455
460
|
"\t})",
|
|
456
461
|
"\t",
|
|
457
462
|
`\tprivate constructor(private readonly data: ${upperCase}Model) {}`,
|
|
@@ -479,6 +484,7 @@ if (command === 'entity') {
|
|
|
479
484
|
|
|
480
485
|
function generateValueObject(upperCase) {
|
|
481
486
|
const folder = config?.paths?.valueObjects ? path.resolve(process.cwd(), config?.paths?.valueObjects, entityName) : path.resolve(process.cwd(), entityName);
|
|
487
|
+
const fields = options.filter(x => x.startsWith('f:')).flatMap(x => x.split(':')[1]).join(',').split(',').map(x => x.split('-'))
|
|
482
488
|
|
|
483
489
|
fs.mkdirSync(folder, { recursive: true })
|
|
484
490
|
|
|
@@ -489,7 +495,11 @@ function generateValueObject(upperCase) {
|
|
|
489
495
|
"",
|
|
490
496
|
`export class ${upperCase} {`,
|
|
491
497
|
"\tstatic schema = z.object({",
|
|
492
|
-
|
|
498
|
+
fields.length ?
|
|
499
|
+
fields.map(([fieldName, description]) => {
|
|
500
|
+
return `\t\t${fieldName}: z.${description.split('.').join('().')}(),`
|
|
501
|
+
}).join('\n')
|
|
502
|
+
: "\t\t",
|
|
493
503
|
"\t})",
|
|
494
504
|
"\t",
|
|
495
505
|
`\tprivate constructor(private readonly data: ${upperCase}Model) {}`,
|