create-forgeon 0.3.18 → 0.3.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-forgeon",
3
- "version": "0.3.18",
3
+ "version": "0.3.19",
4
4
  "description": "Forgeon project generator CLI",
5
5
  "license": "MIT",
6
6
  "author": "Forgeon",
@@ -172,38 +172,51 @@ function patchAppModule(targetRoot) {
172
172
  let content = fs.readFileSync(filePath, 'utf8').replace(/\r\n/g, '\n');
173
173
  content = content.replace(
174
174
  "import { authConfig, authEnvSchema, ForgeonAccountsModule } from '@forgeon/accounts-api';",
175
+ "import { ACCOUNTS_PERSISTENCE_PORT, authConfig, authEnvSchema, ForgeonAccountsModule, UsersModule } from '@forgeon/accounts-api';",
176
+ );
177
+ content = content.replace(
175
178
  "import { authConfig, authEnvSchema, ForgeonAccountsModule, UsersModule } from '@forgeon/accounts-api';",
179
+ "import { ACCOUNTS_PERSISTENCE_PORT, authConfig, authEnvSchema, ForgeonAccountsModule, UsersModule } from '@forgeon/accounts-api';",
176
180
  );
177
181
  content = ensureImportLine(
178
182
  content,
179
- "import { authConfig, authEnvSchema, ForgeonAccountsModule, UsersModule } from '@forgeon/accounts-api';",
183
+ "import { ACCOUNTS_PERSISTENCE_PORT, authConfig, authEnvSchema, ForgeonAccountsModule, UsersModule } from '@forgeon/accounts-api';",
180
184
  );
181
185
  content = ensureImportLine(
182
186
  content,
183
- "import { ForgeonAccountsDbPrismaModule } from './accounts/forgeon-accounts-db-prisma.module';",
187
+ "import { PrismaAccountsPersistenceStore } from './accounts/prisma-accounts-persistence.store';",
188
+ );
189
+ content = content.replace(
190
+ /^import \{ ForgeonAccountsDbPrismaModule \} from '\.\/accounts\/forgeon-accounts-db-prisma\.module';\r?\n/m,
191
+ '',
184
192
  );
185
193
  content = ensureLoadItem(content, 'authConfig');
186
194
  content = ensureValidatorSchema(content, 'authEnvSchema');
187
-
188
- if (!content.includes(' ForgeonAccountsDbPrismaModule,')) {
189
- if (content.includes(' DbPrismaModule,')) {
190
- content = ensureLineAfter(content, ' DbPrismaModule,', ' ForgeonAccountsDbPrismaModule,');
191
- } else {
192
- content = ensureLineAfter(content, ' CoreErrorsModule,', ' ForgeonAccountsDbPrismaModule,');
193
- }
194
- }
195
+ content = content.replace(/^\s*ForgeonAccountsDbPrismaModule,\r?\n/gm, '');
195
196
 
196
197
  const accountsModuleLine = ` ForgeonAccountsModule.register({
198
+ imports: [DbPrismaModule],
199
+ providers: [
200
+ PrismaAccountsPersistenceStore,
201
+ {
202
+ provide: ACCOUNTS_PERSISTENCE_PORT,
203
+ useExisting: PrismaAccountsPersistenceStore,
204
+ },
205
+ ],
197
206
  users: UsersModule.register({}),
198
207
  }),`;
199
- if (!content.includes('ForgeonAccountsModule.register({')) {
200
- if (content.includes(' ForgeonI18nModule.register({')) {
201
- content = ensureLineBefore(content, ' ForgeonI18nModule.register({', accountsModuleLine);
202
- } else if (content.includes(' ForgeonAccountsDbPrismaModule,')) {
203
- content = ensureLineAfter(content, ' ForgeonAccountsDbPrismaModule,', accountsModuleLine);
204
- } else {
205
- content = ensureLineAfter(content, ' CoreErrorsModule,', accountsModuleLine);
206
- }
208
+
209
+ if (content.includes(' ForgeonAccountsModule.register({')) {
210
+ content = content.replace(
211
+ / {4}ForgeonAccountsModule\.register\(\{[\s\S]*? {4}\}\),/m,
212
+ accountsModuleLine,
213
+ );
214
+ } else if (content.includes(' ForgeonI18nModule.register({')) {
215
+ content = ensureLineBefore(content, ' ForgeonI18nModule.register({', accountsModuleLine);
216
+ } else if (content.includes(' DbPrismaModule,')) {
217
+ content = ensureLineAfter(content, ' DbPrismaModule,', accountsModuleLine);
218
+ } else {
219
+ content = ensureLineAfter(content, ' CoreErrorsModule,', accountsModuleLine);
207
220
  }
208
221
 
209
222
  fs.writeFileSync(filePath, `${content.trimEnd()}\n`, 'utf8');
@@ -414,3 +427,5 @@ export function applyAccountsModule({ packageRoot, targetRoot }) {
414
427
  }
415
428
 
416
429
 
430
+
431
+
@@ -716,8 +716,11 @@ function assertAccountsWiring(projectRoot) {
716
716
  const appModule = fs.readFileSync(path.join(projectRoot, 'apps', 'api', 'src', 'app.module.ts'), 'utf8');
717
717
  assert.match(appModule, /authConfig/);
718
718
  assert.match(appModule, /authEnvSchema/);
719
- assert.match(appModule, /ForgeonAccountsDbPrismaModule/);
720
719
  assert.match(appModule, /ForgeonAccountsModule\.register\(\{/);
720
+ assert.match(appModule, /imports: \[DbPrismaModule\]/);
721
+ assert.match(appModule, /PrismaAccountsPersistenceStore/);
722
+ assert.match(appModule, /provide: ACCOUNTS_PERSISTENCE_PORT/);
723
+ assert.match(appModule, /useExisting: PrismaAccountsPersistenceStore/);
721
724
  assert.match(appModule, /UsersModule\.register\(\{\}\)/);
722
725
  assert.doesNotMatch(appModule, /AUTH_REFRESH_TOKEN_STORE/);
723
726
 
@@ -2643,3 +2646,7 @@ describe('addModule', () => {
2643
2646
 
2644
2647
 
2645
2648
 
2649
+
2650
+
2651
+
2652
+
@@ -1,17 +0,0 @@
1
- import { Module } from '@nestjs/common';
2
- import { ACCOUNTS_PERSISTENCE_PORT } from '@forgeon/accounts-api';
3
- import { DbPrismaModule } from '@forgeon/db-prisma';
4
- import { PrismaAccountsPersistenceStore } from './prisma-accounts-persistence.store';
5
-
6
- @Module({
7
- imports: [DbPrismaModule],
8
- providers: [
9
- PrismaAccountsPersistenceStore,
10
- {
11
- provide: ACCOUNTS_PERSISTENCE_PORT,
12
- useExisting: PrismaAccountsPersistenceStore,
13
- },
14
- ],
15
- exports: [ACCOUNTS_PERSISTENCE_PORT],
16
- })
17
- export class ForgeonAccountsDbPrismaModule {}