@alevnyacow/nzmt 0.0.14 → 0.0.15

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