@alevnyacow/nzmt 0.7.5 → 0.8.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 +33 -33
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -97,15 +97,15 @@ function createDefaultConfig() {
|
|
|
97
97
|
|
|
98
98
|
fs.writeFileSync(path.resolve(projectRoot, 'nzmt.config.json'), JSON.stringify(prismaClientPath ? {
|
|
99
99
|
paths: {
|
|
100
|
-
di: './
|
|
101
|
-
stores: './
|
|
102
|
-
services: './
|
|
103
|
-
providers: './
|
|
104
|
-
controllers: './
|
|
105
|
-
infrastructure: './
|
|
106
|
-
entities: './
|
|
107
|
-
valueObjects: './
|
|
108
|
-
queries: './
|
|
100
|
+
di: './server/di',
|
|
101
|
+
stores: './server/stores',
|
|
102
|
+
services: './server/services',
|
|
103
|
+
providers: './server/providers',
|
|
104
|
+
controllers: './server/controllers',
|
|
105
|
+
infrastructure: './server/infrastructure',
|
|
106
|
+
entities: './shared/entities',
|
|
107
|
+
valueObjects: './shared/value-objects',
|
|
108
|
+
queries: './client/shared/queries',
|
|
109
109
|
},
|
|
110
110
|
store: {
|
|
111
111
|
prisma: {
|
|
@@ -114,15 +114,15 @@ function createDefaultConfig() {
|
|
|
114
114
|
}
|
|
115
115
|
} : {
|
|
116
116
|
paths: {
|
|
117
|
-
di: './
|
|
118
|
-
stores: './
|
|
119
|
-
services: './
|
|
120
|
-
providers: './
|
|
121
|
-
controllers: './
|
|
122
|
-
infrastructure: './
|
|
123
|
-
entities: './
|
|
124
|
-
valueObjects: './
|
|
125
|
-
queries: './
|
|
117
|
+
di: './server/di',
|
|
118
|
+
stores: './server/stores',
|
|
119
|
+
services: './server/services',
|
|
120
|
+
providers: './server/providers',
|
|
121
|
+
controllers: './server/controllers',
|
|
122
|
+
infrastructure: './server/infrastructure',
|
|
123
|
+
entities: './shared/entities',
|
|
124
|
+
valueObjects: './shared/value-objects',
|
|
125
|
+
queries: './client/shared/queries',
|
|
126
126
|
}
|
|
127
127
|
}, null, '\t'))
|
|
128
128
|
}
|
|
@@ -312,7 +312,7 @@ function initPrisma() {
|
|
|
312
312
|
insertBeforeLineInFile(
|
|
313
313
|
diEntriesPath,
|
|
314
314
|
'type DIEntries =',
|
|
315
|
-
`import { prismaClient } from '${config?.paths?.infrastructure.replace('
|
|
315
|
+
`import { prismaClient } from '${config?.paths?.infrastructure.replace('.', '@')}/prisma'`
|
|
316
316
|
)
|
|
317
317
|
|
|
318
318
|
insertAfterLineInFile(
|
|
@@ -356,7 +356,7 @@ function initLogger() {
|
|
|
356
356
|
insertBeforeLineInFile(
|
|
357
357
|
diEntriesPath,
|
|
358
358
|
'type DIEntries =',
|
|
359
|
-
`import { ConsoleLogger } from '${config?.paths?.infrastructure.replace('
|
|
359
|
+
`import { ConsoleLogger } from '${config?.paths?.infrastructure.replace('.', '@')}/logger'`
|
|
360
360
|
)
|
|
361
361
|
|
|
362
362
|
insertAfterLineInFile(
|
|
@@ -386,7 +386,7 @@ function generateStores(lowerCase, upperCase, withEntityPreset) {
|
|
|
386
386
|
|
|
387
387
|
fs.writeFileSync(path.resolve(folder, `${entityName}.store.ts`), [
|
|
388
388
|
"import type { Store } from '@alevnyacow/nzmt'",
|
|
389
|
-
withEntity ? `import { ${upperCase} } from '${config?.paths?.entities.replace('
|
|
389
|
+
withEntity ? `import { ${upperCase} } from '${config?.paths?.entities.replace('.', '@')}/${entityName}'` : undefined,
|
|
390
390
|
"",
|
|
391
391
|
`export const ${lowerCase}StoreMetadata = {`,
|
|
392
392
|
"\tmodels: {",
|
|
@@ -430,7 +430,7 @@ function generateStores(lowerCase, upperCase, withEntityPreset) {
|
|
|
430
430
|
if (prismaPath) {
|
|
431
431
|
fs.writeFileSync(path.resolve(folder, `${entityName}.store.prisma.ts`), [
|
|
432
432
|
`import type { Prisma, PrismaClient } from '${prismaPath}'`,
|
|
433
|
-
`import { DITokens } from '${config?.paths?.di?.replace('
|
|
433
|
+
`import { DITokens } from '${config?.paths?.di?.replace('.', '@')}'`,
|
|
434
434
|
"import { injectable } from 'inversify'",
|
|
435
435
|
"import { Store } from '@alevnyacow/nzmt'",
|
|
436
436
|
`import { type ${upperCase}Store, ${lowerCase}StoreMetadata } from './${entityName}.store'`,
|
|
@@ -554,7 +554,7 @@ function generateStores(lowerCase, upperCase, withEntityPreset) {
|
|
|
554
554
|
insertBeforeLineInFile(
|
|
555
555
|
diEntriesPath,
|
|
556
556
|
'type DIEntries =',
|
|
557
|
-
prismaPath ? `import { ${upperCase}PrismaStore, ${upperCase}RAMStore } from '${config?.paths?.stores.replace('
|
|
557
|
+
prismaPath ? `import { ${upperCase}PrismaStore, ${upperCase}RAMStore } from '${config?.paths?.stores.replace('.', '@')}/${entityName}'` : `import { ${upperCase}RAMStore } from '${config?.paths?.stores.replace('.', '@')}/${entityName}'`
|
|
558
558
|
)
|
|
559
559
|
|
|
560
560
|
insertAfterLineInFile(
|
|
@@ -711,7 +711,7 @@ function generateProvider(lowerCase, upperCase) {
|
|
|
711
711
|
insertBeforeLineInFile(
|
|
712
712
|
diEntriesPath,
|
|
713
713
|
'type DIEntries =',
|
|
714
|
-
`import { ${upperCase}MockProvider, ${upperCase}${providerType}Provider } from '${config?.paths?.providers.replace('
|
|
714
|
+
`import { ${upperCase}MockProvider, ${upperCase}${providerType}Provider } from '${config?.paths?.providers.replace('.', '@')}/${entityName}}'`
|
|
715
715
|
)
|
|
716
716
|
|
|
717
717
|
insertAfterLineInFile(
|
|
@@ -744,10 +744,10 @@ function generateService(lowerCase, upperCase) {
|
|
|
744
744
|
}
|
|
745
745
|
|
|
746
746
|
if (i.endsWith('Store')) {
|
|
747
|
-
return `import { ${i} } from '${config?.paths?.stores?.replace('
|
|
747
|
+
return `import { ${i} } from '${config?.paths?.stores?.replace('.', '@')}/${toKebabFromPascal(i).slice(0, -'-store'.length)}'`
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
-
return `import { ${i} } from '${config?.paths?.infrastructure?.replace('
|
|
750
|
+
return `import { ${i} } from '${config?.paths?.infrastructure?.replace('.', '@')}/${toKebabFromPascal(i)}'`
|
|
751
751
|
})
|
|
752
752
|
|
|
753
753
|
fs.mkdirSync(folder, { recursive: true })
|
|
@@ -770,7 +770,7 @@ function generateService(lowerCase, upperCase) {
|
|
|
770
770
|
|
|
771
771
|
fs.writeFileSync(path.resolve(folder, `${entityName}.service.ts`), [
|
|
772
772
|
"import { injectable } from 'inversify'",
|
|
773
|
-
injections.length ? `import { DITokens } from '${config?.paths?.di?.replace('
|
|
773
|
+
injections.length ? `import { DITokens } from '${config?.paths?.di?.replace('.', '@')}'` : undefined,
|
|
774
774
|
`import { ${lowerCase}ServiceMetadata } from './${entityName}.service.metadata'`,
|
|
775
775
|
"import { Module } from '@alevnyacow/nzmt'",
|
|
776
776
|
...importInjections,
|
|
@@ -801,7 +801,7 @@ function generateService(lowerCase, upperCase) {
|
|
|
801
801
|
insertBeforeLineInFile(
|
|
802
802
|
diEntriesPath,
|
|
803
803
|
'type DIEntries =',
|
|
804
|
-
`import { ${upperCase}Service } from '${config?.paths?.services.replace('
|
|
804
|
+
`import { ${upperCase}Service } from '${config?.paths?.services.replace('.', '@')}/${entityName}'`
|
|
805
805
|
)
|
|
806
806
|
|
|
807
807
|
insertAfterLineInFile(
|
|
@@ -828,14 +828,14 @@ function generateController(upperCase, lowerCase) {
|
|
|
828
828
|
}
|
|
829
829
|
|
|
830
830
|
if (i.endsWith('Store')) {
|
|
831
|
-
return `import { ${i} } from '${config?.paths?.stores?.replace('
|
|
831
|
+
return `import { ${i} } from '${config?.paths?.stores?.replace('.', '@')}/${toKebabFromPascal(i).slice(0, -'-store'.length)}'`
|
|
832
832
|
}
|
|
833
833
|
|
|
834
834
|
if (i.endsWith('Service')) {
|
|
835
|
-
return `import { ${i} } from '${config?.paths?.services?.replace('
|
|
835
|
+
return `import { ${i} } from '${config?.paths?.services?.replace('.', '@')}/${toKebabFromPascal(i).slice(0, -'-service'.length)}'`
|
|
836
836
|
}
|
|
837
837
|
|
|
838
|
-
return `import { ${i} } from '${config?.paths?.infrastructure?.replace('
|
|
838
|
+
return `import { ${i} } from '${config?.paths?.infrastructure?.replace('.', '@')}/${toKebabFromPascal(i)}'`
|
|
839
839
|
})
|
|
840
840
|
|
|
841
841
|
fs.mkdirSync(folder, { recursive: true })
|
|
@@ -858,7 +858,7 @@ function generateController(upperCase, lowerCase) {
|
|
|
858
858
|
fs.writeFileSync(path.resolve(folder, `${entityName}.controller.ts`), [
|
|
859
859
|
`import { Controller } from '@alevnyacow/nzmt'`,
|
|
860
860
|
`import { injectable } from 'inversify'`,
|
|
861
|
-
`import { DITokens } from '${config?.paths?.di?.replace('
|
|
861
|
+
`import { DITokens } from '${config?.paths?.di?.replace('.', '@')}'`,
|
|
862
862
|
`import { ${lowerCase}ControllerMetadata } from './${entityName}.controller.metadata'`,
|
|
863
863
|
...importInjections,
|
|
864
864
|
``,
|
|
@@ -887,7 +887,7 @@ function generateController(upperCase, lowerCase) {
|
|
|
887
887
|
insertBeforeLineInFile(
|
|
888
888
|
diEntriesPath,
|
|
889
889
|
'type DIEntries =',
|
|
890
|
-
`import { ${upperCase}Controller } from '${config?.paths?.controllers.replace('
|
|
890
|
+
`import { ${upperCase}Controller } from '${config?.paths?.controllers.replace('.', '@')}/${entityName}'`
|
|
891
891
|
)
|
|
892
892
|
|
|
893
893
|
insertAfterLineInFile(
|