@alevnyacow/nzmt 0.0.37 → 0.0.39
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 +13 -9
- 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'`,
|
|
@@ -391,18 +395,18 @@ function generateService(lowerCase, upperCase, withCrud) {
|
|
|
391
395
|
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',
|
|
405
|
-
`\tprivate method = Module.methods(${
|
|
409
|
+
`\tprivate method = Module.methods(${lowerCaseService}ServiceMetadata)`,
|
|
406
410
|
'\t',
|
|
407
411
|
`\tcreate = this.method('create', this.${lowerCase}s.create);`,
|
|
408
412
|
'\t',
|