create-forgeon 0.3.2 → 0.3.3

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.2",
3
+ "version": "0.3.3",
4
4
  "description": "Forgeon project generator CLI",
5
5
  "license": "MIT",
6
6
  "author": "Forgeon",
@@ -1261,6 +1261,48 @@ describe('addModule', () => {
1261
1261
  }
1262
1262
  });
1263
1263
 
1264
+ it('scans auth persistence as db-adapter participant while remaining triggerable from db-prisma install order', () => {
1265
+ const targetRoot = mkTmp('forgeon-module-jwt-db-scan-');
1266
+ const projectRoot = path.join(targetRoot, 'demo-jwt-db-scan');
1267
+ const templateRoot = path.join(packageRoot, 'templates', 'base');
1268
+
1269
+ try {
1270
+ scaffoldProject({
1271
+ templateRoot,
1272
+ packageRoot,
1273
+ targetRoot: projectRoot,
1274
+ projectName: 'demo-jwt-db-scan',
1275
+ frontend: 'react',
1276
+ db: 'prisma',
1277
+ dbPrismaEnabled: false,
1278
+ i18nEnabled: false,
1279
+ proxy: 'caddy',
1280
+ });
1281
+
1282
+ addModule({
1283
+ moduleId: 'jwt-auth',
1284
+ targetRoot: projectRoot,
1285
+ packageRoot,
1286
+ });
1287
+ addModule({
1288
+ moduleId: 'db-prisma',
1289
+ targetRoot: projectRoot,
1290
+ packageRoot,
1291
+ });
1292
+
1293
+ const scan = scanIntegrations({
1294
+ targetRoot: projectRoot,
1295
+ relatedModuleId: 'db-prisma',
1296
+ });
1297
+ const persistenceGroup = scan.groups.find((group) => group.id === 'auth-persistence');
1298
+
1299
+ assert.ok(persistenceGroup);
1300
+ assert.deepEqual(persistenceGroup.modules, ['jwt-auth', 'db-adapter']);
1301
+ } finally {
1302
+ fs.rmSync(targetRoot, { recursive: true, force: true });
1303
+ }
1304
+ });
1305
+
1264
1306
  it('applies logger then jwt-auth on db/i18n-disabled scaffold without breaking health controller syntax', () => {
1265
1307
  const targetRoot = mkTmp('forgeon-module-jwt-nodb-noi18n-');
1266
1308
  const projectRoot = path.join(targetRoot, 'demo-jwt-nodb-noi18n');
@@ -95,7 +95,8 @@ const INTEGRATION_GROUPS = [
95
95
  {
96
96
  id: 'auth-persistence',
97
97
  title: 'Auth Persistence Integration',
98
- modules: ['jwt-auth', 'db-prisma'],
98
+ participants: ['jwt-auth', 'db-adapter'],
99
+ relatedModules: ['jwt-auth', 'db-prisma'],
99
100
  description: [
100
101
  'Patch AppModule to wire AUTH_REFRESH_TOKEN_STORE to the current db-adapter implementation (today: PrismaAuthRefreshTokenStore)',
101
102
  'Add apps/api/src/auth/prisma-auth-refresh-token.store.ts',
@@ -109,7 +110,8 @@ const INTEGRATION_GROUPS = [
109
110
  {
110
111
  id: 'auth-rbac-claims',
111
112
  title: 'Auth Claims Integration',
112
- modules: ['jwt-auth', 'rbac'],
113
+ participants: ['jwt-auth', 'rbac'],
114
+ relatedModules: ['jwt-auth', 'rbac'],
113
115
  description: [
114
116
  'Extend AuthUser with optional permissions in @forgeon/auth-contracts',
115
117
  'Add demo RBAC claims to jwt-auth login and token payloads',
@@ -139,6 +141,20 @@ function detectModules(rootDir) {
139
141
  };
140
142
  }
141
143
 
144
+ function getGroupParticipants(group) {
145
+ return Array.isArray(group.participants) && group.participants.length > 0
146
+ ? group.participants
147
+ : Array.isArray(group.modules)
148
+ ? group.modules
149
+ : [];
150
+ }
151
+
152
+ function getGroupRelatedModules(group) {
153
+ return Array.isArray(group.relatedModules) && group.relatedModules.length > 0
154
+ ? group.relatedModules
155
+ : getGroupParticipants(group);
156
+ }
157
+
142
158
  function syncJwtDbPrisma({ rootDir, packageRoot, changedFiles }) {
143
159
  const appModulePath = path.join(rootDir, 'apps', 'api', 'src', 'app.module.ts');
144
160
  const schemaPath = path.join(rootDir, 'apps', 'api', 'prisma', 'schema.prisma');
@@ -385,7 +401,7 @@ export function syncIntegrations({ targetRoot, packageRoot, groupIds = null }) {
385
401
  availableGroups: available.map((group) => ({
386
402
  id: group.id,
387
403
  title: group.title,
388
- modules: [...group.modules],
404
+ modules: [...getGroupParticipants(group)],
389
405
  description: [...group.description],
390
406
  })),
391
407
  changedFiles: [...changedFiles].sort().map((filePath) => path.relative(rootDir, filePath)),
@@ -399,13 +415,13 @@ export function scanIntegrations({ targetRoot, relatedModuleId = null }) {
399
415
  (group) =>
400
416
  group.isAvailable(detected) &&
401
417
  group.isPending(rootDir) &&
402
- (!relatedModuleId || group.modules.includes(relatedModuleId)),
418
+ (!relatedModuleId || getGroupRelatedModules(group).includes(relatedModuleId)),
403
419
  );
404
420
  return {
405
421
  groups: available.map((group) => ({
406
422
  id: group.id,
407
423
  title: group.title,
408
- modules: [...group.modules],
424
+ modules: [...getGroupParticipants(group)],
409
425
  description: [...group.description],
410
426
  })),
411
427
  };
@@ -299,7 +299,7 @@ function run() {
299
299
  } else {
300
300
  summary.push({
301
301
  feature: 'jwt-auth + db-adapter (current provider: db-prisma)',
302
- result: { applied: false, reason: 'required modules are not both installed' },
302
+ result: { applied: false, reason: 'required components are not both available' },
303
303
  });
304
304
  }
305
305
 
@@ -311,7 +311,7 @@ function run() {
311
311
  } else {
312
312
  summary.push({
313
313
  feature: 'jwt-auth + rbac',
314
- result: { applied: false, reason: 'required modules are not both installed' },
314
+ result: { applied: false, reason: 'required components are not both available' },
315
315
  });
316
316
  }
317
317