@idevconn/create-icore 0.7.2 → 0.9.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.
Files changed (87) hide show
  1. package/README.md +44 -9
  2. package/dist/cli.js +689 -363
  3. package/dist/index.cjs +806 -358
  4. package/dist/index.d.cts +12 -3
  5. package/dist/index.d.ts +12 -3
  6. package/dist/index.js +798 -351
  7. package/dist/manifest/audit.js +122 -0
  8. package/package.json +1 -1
  9. package/templates/apps/api/src/app/app.module.ts +2 -6
  10. package/templates/apps/api/src/app/features.module.ts +9 -0
  11. package/templates/apps/api/src/app/gateway-services.ts +7 -0
  12. package/templates/apps/api/src/main.ts +1 -5
  13. package/templates/apps/microservices/auth/src/app/app.module.ts +4 -93
  14. package/templates/apps/microservices/auth/src/app/auth.provider.ts +9 -0
  15. package/templates/apps/microservices/notes/src/app/app.module.ts +4 -86
  16. package/templates/apps/microservices/notes/src/app/db.provider.ts +9 -0
  17. package/templates/apps/microservices/upload/src/app/app.module.ts +4 -140
  18. package/templates/apps/microservices/upload/src/app/storage.provider.ts +9 -0
  19. package/templates/apps/templates/client-antd/src/components/layout/LayoutSider.tsx +15 -23
  20. package/templates/apps/templates/client-antd/src/nav.config.ts +17 -0
  21. package/templates/apps/templates/client-mui/src/components/layout/LayoutSider.tsx +19 -20
  22. package/templates/apps/templates/client-mui/src/nav.config.ts +17 -0
  23. package/templates/apps/templates/client-shadcn/src/components/layout/LayoutSider.tsx +20 -16
  24. package/templates/apps/templates/client-shadcn/src/nav.config.ts +17 -0
  25. package/templates/libs/auth-strategies/firebase/eslint.config.mjs +1 -0
  26. package/templates/libs/auth-strategies/firebase/package.json +4 -0
  27. package/templates/libs/auth-strategies/firebase/src/index.ts +1 -0
  28. package/templates/libs/auth-strategies/firebase/src/lib/__tests__/firebase-auth.module.unit.test.ts +49 -0
  29. package/templates/libs/auth-strategies/firebase/src/lib/firebase-auth.module.ts +41 -0
  30. package/templates/libs/auth-strategies/firebase/tsconfig.json +2 -0
  31. package/templates/libs/auth-strategies/mongodb/package.json +8 -1
  32. package/templates/libs/auth-strategies/mongodb/src/index.ts +1 -0
  33. package/templates/libs/auth-strategies/mongodb/src/lib/__tests__/mongodb-auth.module.unit.test.ts +16 -0
  34. package/templates/libs/auth-strategies/mongodb/src/lib/mongodb-auth.module.ts +45 -0
  35. package/templates/libs/auth-strategies/mongodb/tsconfig.json +2 -0
  36. package/templates/libs/auth-strategies/supabase/eslint.config.mjs +1 -0
  37. package/templates/libs/auth-strategies/supabase/package.json +3 -0
  38. package/templates/libs/auth-strategies/supabase/src/index.ts +1 -0
  39. package/templates/libs/auth-strategies/supabase/src/lib/__tests__/supabase-auth.module.unit.test.ts +43 -0
  40. package/templates/libs/auth-strategies/supabase/src/lib/supabase-auth.module.ts +41 -0
  41. package/templates/libs/auth-strategies/supabase/tsconfig.json +2 -0
  42. package/templates/libs/db-strategies/firestore/eslint.config.mjs +1 -1
  43. package/templates/libs/db-strategies/firestore/package.json +4 -0
  44. package/templates/libs/db-strategies/firestore/src/index.ts +1 -0
  45. package/templates/libs/db-strategies/firestore/src/lib/__tests__/firestore-db.module.unit.test.ts +37 -0
  46. package/templates/libs/db-strategies/firestore/src/lib/firestore-db.module.ts +41 -0
  47. package/templates/libs/db-strategies/firestore/tsconfig.json +2 -0
  48. package/templates/libs/db-strategies/mongodb/package.json +4 -1
  49. package/templates/libs/db-strategies/mongodb/src/index.ts +1 -0
  50. package/templates/libs/db-strategies/mongodb/src/lib/__tests__/mongodb-db.module.unit.test.ts +14 -0
  51. package/templates/libs/db-strategies/mongodb/src/lib/mongodb-db.module.ts +41 -0
  52. package/templates/libs/db-strategies/mongodb/tsconfig.json +2 -0
  53. package/templates/libs/db-strategies/supabase/eslint.config.mjs +6 -1
  54. package/templates/libs/db-strategies/supabase/package.json +3 -0
  55. package/templates/libs/db-strategies/supabase/src/index.ts +1 -0
  56. package/templates/libs/db-strategies/supabase/src/lib/__tests__/supabase-db.module.unit.test.ts +32 -0
  57. package/templates/libs/db-strategies/supabase/src/lib/supabase-db.module.ts +41 -0
  58. package/templates/libs/db-strategies/supabase/tsconfig.json +2 -0
  59. package/templates/libs/shared/src/strategies/__tests__/provide-strategy.unit.test.ts +73 -0
  60. package/templates/libs/shared/src/strategies/index.ts +1 -0
  61. package/templates/libs/shared/src/strategies/provide-strategy.ts +44 -0
  62. package/templates/libs/storage-strategies/cloudinary/eslint.config.mjs +1 -1
  63. package/templates/libs/storage-strategies/cloudinary/package.json +4 -0
  64. package/templates/libs/storage-strategies/cloudinary/src/index.ts +1 -0
  65. package/templates/libs/storage-strategies/cloudinary/src/lib/__tests__/cloudinary-storage.module.unit.test.ts +40 -0
  66. package/templates/libs/storage-strategies/cloudinary/src/lib/cloudinary-storage.module.ts +85 -0
  67. package/templates/libs/storage-strategies/cloudinary/tsconfig.json +2 -0
  68. package/templates/libs/storage-strategies/firebase/eslint.config.mjs +1 -1
  69. package/templates/libs/storage-strategies/firebase/package.json +4 -0
  70. package/templates/libs/storage-strategies/firebase/src/index.ts +1 -0
  71. package/templates/libs/storage-strategies/firebase/src/lib/__tests__/firebase-storage.module.unit.test.ts +42 -0
  72. package/templates/libs/storage-strategies/firebase/src/lib/firebase-storage.module.ts +46 -0
  73. package/templates/libs/storage-strategies/firebase/tsconfig.json +2 -0
  74. package/templates/libs/storage-strategies/mongodb/package.json +4 -1
  75. package/templates/libs/storage-strategies/mongodb/src/index.ts +1 -0
  76. package/templates/libs/storage-strategies/mongodb/src/lib/__tests__/mongodb-storage.module.unit.test.ts +14 -0
  77. package/templates/libs/storage-strategies/mongodb/src/lib/mongodb-storage.module.ts +41 -0
  78. package/templates/libs/storage-strategies/mongodb/tsconfig.json +2 -0
  79. package/templates/libs/storage-strategies/supabase/eslint.config.mjs +1 -0
  80. package/templates/libs/storage-strategies/supabase/package.json +3 -0
  81. package/templates/libs/storage-strategies/supabase/src/index.ts +1 -0
  82. package/templates/libs/storage-strategies/supabase/src/lib/__tests__/supabase-storage.module.unit.test.ts +46 -0
  83. package/templates/libs/storage-strategies/supabase/src/lib/supabase-storage.module.ts +46 -0
  84. package/templates/libs/storage-strategies/supabase/tsconfig.json +2 -0
  85. package/templates/package.json +1 -1
  86. package/templates/tools/create-icore/_template-shell/package.json +1 -1
  87. package/templates/tsconfig.base.json +1 -1
@@ -0,0 +1,41 @@
1
+ import { Module, DynamicModule } from '@nestjs/common';
2
+ import { ConfigService } from '@nestjs/config';
3
+ import { MongooseModule, getConnectionToken } from '@nestjs/mongoose';
4
+ import { Connection } from 'mongoose';
5
+ import { buildStrategyWithFallback, FakeStorageStrategy } from '@icore/shared';
6
+ import type { StorageStrategy } from '@icore/shared';
7
+ import { MongoDbStorageStrategy } from './mongodb-storage.strategy';
8
+
9
+ export const MONGODB_STORAGE_REQUIRED_ENV = ['MONGODB_URI'];
10
+
11
+ @Module({})
12
+ export class MongoDbStorageModule {
13
+ static forRoot(envPath: string): DynamicModule {
14
+ return {
15
+ module: MongoDbStorageModule,
16
+ imports: [
17
+ MongooseModule.forRootAsync({
18
+ useFactory: (cfg: ConfigService) => ({ uri: cfg.get<string>('MONGODB_URI') }),
19
+ inject: [ConfigService],
20
+ }),
21
+ ],
22
+ providers: [
23
+ {
24
+ provide: 'StorageStrategy',
25
+ useFactory: (cfg: ConfigService, connection: Connection): StorageStrategy =>
26
+ buildStrategyWithFallback<StorageStrategy>({
27
+ service: 'upload MS',
28
+ provider: 'mongodb',
29
+ requiredEnv: MONGODB_STORAGE_REQUIRED_ENV,
30
+ cfg,
31
+ envPath,
32
+ build: () => new MongoDbStorageStrategy({ connection }),
33
+ fake: () => new FakeStorageStrategy(),
34
+ }),
35
+ inject: [ConfigService, getConnectionToken()],
36
+ },
37
+ ],
38
+ exports: ['StorageStrategy'],
39
+ };
40
+ }
41
+ }
@@ -2,6 +2,8 @@
2
2
  "extends": "../../../tsconfig.base.json",
3
3
  "compilerOptions": {
4
4
  "module": "commonjs",
5
+ "experimentalDecorators": true,
6
+ "emitDecoratorMetadata": true,
5
7
  "forceConsistentCasingInFileNames": true,
6
8
  "strict": true,
7
9
  "importHelpers": true,
@@ -12,6 +12,7 @@ export default [
12
12
  '{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}',
13
13
  '{projectRoot}/vitest.config.{js,ts,mjs,mts}',
14
14
  ],
15
+ ignoredDependencies: ['@nestjs/testing', 'vitest'],
15
16
  },
16
17
  ],
17
18
  },
@@ -7,10 +7,13 @@
7
7
  "types": "./src/index.ts",
8
8
  "dependencies": {
9
9
  "@icore/shared": "*",
10
+ "@nestjs/common": "^11.1.24",
11
+ "@nestjs/config": "^4.0.4",
10
12
  "@supabase/supabase-js": "^2.0.0",
11
13
  "tslib": "^2.3.0"
12
14
  },
13
15
  "devDependencies": {
16
+ "@nestjs/testing": "^11.0.0",
14
17
  "vitest": "^4.0.0"
15
18
  }
16
19
  }
@@ -1,2 +1,3 @@
1
1
  export * from './lib/supabase-storage.strategy';
2
2
  export * from './lib/testing/mock-supabase-storage';
3
+ export * from './lib/supabase-storage.module';
@@ -0,0 +1,46 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { Global, Module } from '@nestjs/common';
3
+ import { Test } from '@nestjs/testing';
4
+ import { ConfigService } from '@nestjs/config';
5
+ import {
6
+ SupabaseStorageModule,
7
+ SUPABASE_STORAGE_REQUIRED_ENV,
8
+ } from '../supabase-storage.module.js';
9
+ import { SupabaseStorageStrategy } from '../supabase-storage.strategy.js';
10
+
11
+ @Global()
12
+ @Module({
13
+ providers: [{ provide: ConfigService, useValue: makeCfg() }],
14
+ exports: [ConfigService],
15
+ })
16
+ class StubConfigModule {}
17
+
18
+ let ENV: Record<string, string | undefined> = {};
19
+ function makeCfg() {
20
+ return {
21
+ get: (k: string) => ENV[k],
22
+ getOrThrow: (k: string) => ENV[k],
23
+ } as unknown as ConfigService;
24
+ }
25
+
26
+ describe('SupabaseStorageModule', () => {
27
+ it('declares its required env', () => {
28
+ expect(SUPABASE_STORAGE_REQUIRED_ENV).toEqual([
29
+ 'SUPABASE_URL',
30
+ 'SUPABASE_SERVICE_ROLE_KEY',
31
+ 'SUPABASE_STORAGE_BUCKET',
32
+ ]);
33
+ });
34
+
35
+ it('provides a real SupabaseStorageStrategy under StorageStrategy when env present', async () => {
36
+ ENV = {
37
+ SUPABASE_URL: 'https://x.supabase.co',
38
+ SUPABASE_SERVICE_ROLE_KEY: 'svc',
39
+ SUPABASE_STORAGE_BUCKET: 'uploads',
40
+ };
41
+ const ref = await Test.createTestingModule({
42
+ imports: [StubConfigModule, SupabaseStorageModule.forRoot('.env')],
43
+ }).compile();
44
+ expect(ref.get('StorageStrategy')).toBeInstanceOf(SupabaseStorageStrategy);
45
+ });
46
+ });
@@ -0,0 +1,46 @@
1
+ import { Module, DynamicModule } from '@nestjs/common';
2
+ import { ConfigService } from '@nestjs/config';
3
+ import { createClient } from '@supabase/supabase-js';
4
+ import { buildStrategyWithFallback, FakeStorageStrategy } from '@icore/shared';
5
+ import type { StorageStrategy } from '@icore/shared';
6
+ import { SupabaseStorageStrategy } from './supabase-storage.strategy';
7
+
8
+ export const SUPABASE_STORAGE_REQUIRED_ENV = [
9
+ 'SUPABASE_URL',
10
+ 'SUPABASE_SERVICE_ROLE_KEY',
11
+ 'SUPABASE_STORAGE_BUCKET',
12
+ ];
13
+
14
+ @Module({})
15
+ export class SupabaseStorageModule {
16
+ static forRoot(envPath: string): DynamicModule {
17
+ return {
18
+ module: SupabaseStorageModule,
19
+ providers: [
20
+ {
21
+ provide: 'StorageStrategy',
22
+ useFactory: (cfg: ConfigService): StorageStrategy =>
23
+ buildStrategyWithFallback<StorageStrategy>({
24
+ service: 'upload MS',
25
+ provider: 'supabase',
26
+ requiredEnv: SUPABASE_STORAGE_REQUIRED_ENV,
27
+ cfg,
28
+ envPath,
29
+ build: () =>
30
+ new SupabaseStorageStrategy({
31
+ client: createClient(
32
+ cfg.getOrThrow<string>('SUPABASE_URL'),
33
+ cfg.getOrThrow<string>('SUPABASE_SERVICE_ROLE_KEY'),
34
+ { auth: { autoRefreshToken: false, persistSession: false } },
35
+ ),
36
+ bucket: cfg.getOrThrow<string>('SUPABASE_STORAGE_BUCKET'),
37
+ }),
38
+ fake: () => new FakeStorageStrategy(),
39
+ }),
40
+ inject: [ConfigService],
41
+ },
42
+ ],
43
+ exports: ['StorageStrategy'],
44
+ };
45
+ }
46
+ }
@@ -3,6 +3,8 @@
3
3
  "compilerOptions": {
4
4
  "module": "node16",
5
5
  "moduleResolution": "node16",
6
+ "experimentalDecorators": true,
7
+ "emitDecoratorMetadata": true,
6
8
  "forceConsistentCasingInFileNames": true,
7
9
  "strict": true,
8
10
  "importHelpers": true,
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@eslint/js": "^9.18.0",
27
- "@icore/vite-plugins": "workspace:*",
27
+ "@icore/vite-plugins": "*",
28
28
  "@nestjs/schematics": "^11.0.0",
29
29
  "@nestjs/testing": "^11.0.0",
30
30
  "@nx/devkit": "22.7.5",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@eslint/js": "^9.18.0",
27
- "@icore/vite-plugins": "workspace:*",
27
+ "@icore/vite-plugins": "*",
28
28
  "@nestjs/schematics": "^11.0.0",
29
29
  "@nestjs/testing": "^11.0.0",
30
30
  "@nx/devkit": "22.7.5",
@@ -37,5 +37,5 @@
37
37
  "@icore/auth-mongodb": ["./libs/auth-strategies/mongodb/src/index.ts"]
38
38
  }
39
39
  },
40
- "exclude": ["node_modules", "dist", ".nx"]
40
+ "exclude": ["node_modules", "dist", ".nx", "tools/create-icore/templates"]
41
41
  }