@alevnyacow/nzmt 0.0.38 → 0.0.40
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 +14 -10
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -74,10 +74,6 @@ function createDefaultConfig() {
|
|
|
74
74
|
|
|
75
75
|
fs.writeFileSync(path.resolve(projectRoot, 'nzmt.config.json'), JSON.stringify({
|
|
76
76
|
paths: {
|
|
77
|
-
prismaImport: [
|
|
78
|
-
"import { prisma } from '@/backend/infrastructure/prisma'",
|
|
79
|
-
"import type { Prisma } from '@/backend/generated-prisma/client'",
|
|
80
|
-
],
|
|
81
77
|
stores: './src/backend/stores',
|
|
82
78
|
services: './src/backend/services',
|
|
83
79
|
providers: './src/backend/providers',
|
|
@@ -87,8 +83,16 @@ function createDefaultConfig() {
|
|
|
87
83
|
},
|
|
88
84
|
dependencyInjection: {
|
|
89
85
|
inversifyjs: {
|
|
90
|
-
|
|
86
|
+
storeTokensImport: "import { DIStores } from '@/backend/di'"
|
|
91
87
|
}
|
|
88
|
+
},
|
|
89
|
+
store: {
|
|
90
|
+
prisma: {
|
|
91
|
+
import: [
|
|
92
|
+
"import { prisma } from '@/backend/infrastructure/prisma'",
|
|
93
|
+
"import type { Prisma } from '@/backend/generated-prisma/client'",
|
|
94
|
+
]
|
|
95
|
+
},
|
|
92
96
|
}
|
|
93
97
|
}, null, '\t'))
|
|
94
98
|
}
|
|
@@ -151,7 +155,7 @@ function generateStores(lowerCase, upperCase) {
|
|
|
151
155
|
// Prisma
|
|
152
156
|
|
|
153
157
|
fs.writeFileSync(path.resolve(folder, `${entityName}.store.prisma.ts`), [
|
|
154
|
-
...config?.
|
|
158
|
+
...config?.store?.prisma?.import ?? [],
|
|
155
159
|
config?.dependencyInjection?.inversifyjs ? "import { injectable } from 'inversify'" : undefined,
|
|
156
160
|
"import { Store } from '@alevnyacow/nzmt'",
|
|
157
161
|
`import { type ${upperCase}Store, ${lowerCase}StoreMetadata } from './${entityName}.store'`,
|
|
@@ -319,6 +323,7 @@ function generateService(lowerCase, upperCase, withCrud) {
|
|
|
319
323
|
fs.mkdirSync(folder, { recursive: true })
|
|
320
324
|
|
|
321
325
|
// Metadata
|
|
326
|
+
const [lowerCaseService, upperCaseService] = camelizeVariants(serviceName)
|
|
322
327
|
|
|
323
328
|
if (withCrud) {
|
|
324
329
|
fs.writeFileSync(path.resolve(folder, `${serviceName}.service.metadata.ts`), [
|
|
@@ -370,7 +375,7 @@ function generateService(lowerCase, upperCase, withCrud) {
|
|
|
370
375
|
"\t}",
|
|
371
376
|
"} satisfies Module.Metadata",
|
|
372
377
|
"",
|
|
373
|
-
`export type ${
|
|
378
|
+
`export type ${upperCaseService}ServiceDTOs = Module.DTOs<typeof ${lowerCaseService}sServiceMetadata>`
|
|
374
379
|
].filter(x => typeof x === 'string').join('\n'))
|
|
375
380
|
} else {
|
|
376
381
|
fs.writeFileSync(path.resolve(folder, `${serviceName}.service.metadata.ts`), [
|
|
@@ -388,17 +393,16 @@ function generateService(lowerCase, upperCase, withCrud) {
|
|
|
388
393
|
// Service body
|
|
389
394
|
|
|
390
395
|
if (withCrud) {
|
|
391
|
-
const [lowerCaseService, upperCaseService] = camelizeVariants(serviceName)
|
|
392
396
|
fs.writeFileSync(path.resolve(folder, `${serviceName}.service.ts`), [
|
|
393
397
|
config?.dependencyInjection?.inversifyjs ? "import { injectable, inject } from 'inversify'" : undefined,
|
|
394
|
-
config?.dependencyInjection?.inversifyjs?.
|
|
398
|
+
config?.dependencyInjection?.inversifyjs?.storeTokensImport ?? undefined,
|
|
395
399
|
`import type { ${upperCase}Store } from '${config?.paths?.stores?.replace('./src', '@')}/${entityName}'`,
|
|
396
400
|
`import { ${lowerCaseService}ServiceMetadata } from './${serviceName}.service.metadata'`,
|
|
397
401
|
"import { Module } from '@alevnyacow/nzmt'",
|
|
398
402
|
config?.dependencyInjection?.inversifyjs ? "@injectable()" : undefined,
|
|
399
403
|
`export class ${upperCaseService}Service {`,
|
|
400
404
|
`\tconstructor(`,
|
|
401
|
-
config?.dependencyInjection?.inversifyjs?.
|
|
405
|
+
config?.dependencyInjection?.inversifyjs?.storeTokensImport ? `\t\t@inject(${getImportName(config?.dependencyInjection?.inversifyjs?.storeTokensImport)}.${lowerCase}s)` : undefined,
|
|
402
406
|
`\t\tprivate readonly ${lowerCase}s: ${upperCase}Store`,
|
|
403
407
|
'\t) { }',
|
|
404
408
|
'\t',
|