@alevnyacow/nzmt 0.0.14 → 0.0.16

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.
Files changed (2) hide show
  1. package/bin/cli.js +20 -8
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -53,11 +53,12 @@ if (command === 'init-config') {
53
53
  "import { prisma } from '@/backend/infrastructure/prisma'",
54
54
  "import type { Prisma } from '@/backend/generated-prisma/client'",
55
55
  ],
56
- stores: './backend/stores',
57
- services: './backend/services',
58
- providers: './backend/providers',
59
- controllers: './backend/controllers'
60
- }
56
+ stores: './src/backend/stores',
57
+ services: './src/backend/services',
58
+ providers: './src/backend/providers',
59
+ controllers: './src/backend/controllers'
60
+ },
61
+ dependencyInjection: 'inversifyjs'
61
62
  }, null, '\t'))
62
63
  }
63
64
 
@@ -80,11 +81,10 @@ function camelizeVariants(str) {
80
81
  return [lowerCamel, upperCamel];
81
82
  }
82
83
 
83
-
84
84
  var [lowerCase, upperCase] = camelizeVariants(entityName)
85
85
 
86
86
  if (command === 'store') {
87
- const folder = config ? path.resolve(process.cwd(), config?.paths?.stores) : path.resolve(process.cwd(), entityName);
87
+ const folder = config ? path.resolve(process.cwd(), config?.paths?.stores, entityName) : path.resolve(process.cwd(), entityName);
88
88
 
89
89
  fs.mkdirSync(folder, { recursive: true })
90
90
 
@@ -119,20 +119,23 @@ if (command === 'store') {
119
119
  // RAM
120
120
 
121
121
  fs.writeFileSync(path.resolve(folder, `${entityName}.store.ram.ts`), [
122
+ config?.dependencyInjection === 'inversifyjs' ? "import { injectable } from 'inversify'" : undefined,
122
123
  "import { Store } from '@alevnyacow/nzmt'",
123
124
  `import { type ${upperCase}Store, ${lowerCase}StoreMetadata } from './${entityName}.store'`,
124
125
  "",
125
126
  `const CRUDInRAM = Store.InRAM(${lowerCase}StoreMetadata)`,
126
127
  "",
128
+ config?.dependencyInjection === 'inversifyjs' ? "@injectable()" : undefined,
127
129
  `export class ${upperCase}RAMStore extends CRUDInRAM implements ${upperCase}Store {`,
128
130
  "\t",
129
131
  "}"
130
- ].join('\n'))
132
+ ].filter(x => typeof x === 'string').join('\n'))
131
133
 
132
134
  // Prisma
133
135
 
134
136
  fs.writeFileSync(path.resolve(folder, `${entityName}.store.prisma.ts`), [
135
137
  ...config?.paths?.['prismaImport'] ?? [],
138
+ config?.dependencyInjection === 'inversifyjs' ? "import { injectable } from 'inversify'" : undefined,
136
139
  "import { Store } from '@alevnyacow/nzmt'",
137
140
  `import { type ${upperCase}Store, ${lowerCase}StoreMetadata } from './${entityName}.store'`,
138
141
  "",
@@ -171,6 +174,7 @@ if (command === 'store') {
171
174
  "\t}",
172
175
  "}",
173
176
  "",
177
+ config?.dependencyInjection === 'inversifyjs' ? "@injectable()" : undefined,
174
178
  `export class ${upperCase}PrismaStore implements ${upperCase}Store {`,
175
179
  `\tprivate method = Store.methods(${lowerCase}StoreMetadata);`,
176
180
  "",
@@ -234,5 +238,13 @@ if (command === 'store') {
234
238
  "\t});",
235
239
  "};"
236
240
  ].join('\n'))
241
+
242
+ // barrel
243
+
244
+ fs.writeFileSync(path.resolve(folder, 'index.ts'), [
245
+ `export * from './${entityName}.store.ts`,
246
+ `export * from './${entityName}.store.prisma.ts`,
247
+ `export * from './${entityName}.store.ram.ts`
248
+ ].join('\n'))
237
249
  }
238
250
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alevnyacow/nzmt",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Next Zod Modules Toolkit",
5
5
  "type": "module",
6
6
  "exports": {