Skip to content

Commit d3a5c97

Browse files
author
Nevo David
committed
feat: check plugins
1 parent 0bea6c9 commit d3a5c97

15 files changed

+182
-15
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ Thumbs.db
5454
*.tsbuildinfo
5555

5656
# ignore Secrets folder
57-
.secrets/
57+
.secrets/

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "libraries/plugins/src/list/--force"]
2+
path = libraries/plugins/src/list/--force
3+
url = git@notifire:gitroomhq/public-api.git
4+
[submodule "libraries/plugins/src/list/public-api"]
5+
path = libraries/plugins/src/list/public-api
6+
url = git@notifire:gitroomhq/public-api.git

apps/backend/src/app.module.ts

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
import {Global, Module} from '@nestjs/common';
1+
import { Global, Module } from '@nestjs/common';
22

3-
import {DatabaseModule} from "@gitroom/nestjs-libraries/database/prisma/database.module";
4-
import {ApiModule} from "@gitroom/backend/api/api.module";
5-
import {APP_GUARD} from "@nestjs/core";
6-
import {PoliciesGuard} from "@gitroom/backend/services/auth/permissions/permissions.guard";
3+
import { DatabaseModule } from '@gitroom/nestjs-libraries/database/prisma/database.module';
4+
import { ApiModule } from '@gitroom/backend/api/api.module';
5+
import { APP_GUARD } from '@nestjs/core';
6+
import { PoliciesGuard } from '@gitroom/backend/services/auth/permissions/permissions.guard';
77
import { BullMqModule } from '@gitroom/nestjs-libraries/bull-mq-transport-new/bull.mq.module';
8+
import { PluginModule } from '@gitroom/plugins/plugin.module';
89

910
@Global()
1011
@Module({
11-
imports: [BullMqModule, DatabaseModule, ApiModule],
12+
imports: [BullMqModule, DatabaseModule, ApiModule, PluginModule],
1213
controllers: [],
13-
providers: [{
14-
provide: APP_GUARD,
15-
useClass: PoliciesGuard
16-
}],
14+
providers: [
15+
{
16+
provide: APP_GUARD,
17+
useClass: PoliciesGuard,
18+
},
19+
],
1720
get exports() {
1821
return [...this.imports];
19-
}
22+
},
2023
})
2124
export class AppModule {}

apps/frontend/next-env.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.

build.plugins.js

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const { readdirSync, statSync, writeFileSync } = require('fs');
2+
const { join } = require('path');
3+
4+
function isNonEmptyFolder(folderPath) {
5+
const items = readdirSync(folderPath);
6+
// Check if there are any items in the folder
7+
return items.some((item) => {
8+
const fullPath = join(folderPath, item);
9+
// Check if the item is a file or a non-empty directory
10+
const stats = statSync(fullPath);
11+
if (stats.isDirectory()) {
12+
return isNonEmptyFolder(fullPath); // Recursively check subfolders
13+
}
14+
return true; // It's a file
15+
});
16+
}
17+
18+
// Function to get all non-empty folders
19+
function getNonEmptyFolders(rootFolder) {
20+
const result = [];
21+
const items = readdirSync(rootFolder);
22+
23+
items.forEach((item) => {
24+
const fullPath = join(rootFolder, item);
25+
const stats = statSync(fullPath);
26+
if (stats.isDirectory() && isNonEmptyFolder(fullPath)) {
27+
result.push(item);
28+
}
29+
});
30+
31+
return result;
32+
}
33+
const abc = [
34+
'a',
35+
'b',
36+
'c',
37+
'd',
38+
'e',
39+
'f',
40+
'g',
41+
'h',
42+
'i',
43+
'j',
44+
'k',
45+
'l',
46+
'm',
47+
'n',
48+
'o',
49+
'p',
50+
'q',
51+
'r',
52+
's',
53+
't',
54+
'u',
55+
'v',
56+
'w',
57+
'x',
58+
'y',
59+
'z',
60+
];
61+
const list = getNonEmptyFolders('./libraries/plugins/src/list');
62+
const fileContent = `${list
63+
.map((p, index) => {
64+
return `import Module${abc[
65+
index
66+
].toUpperCase()} from '@gitroom/plugins/list/${p}/backend/module';`;
67+
})
68+
.join('\n')}
69+
70+
export default [${list
71+
.map((p, index) => {
72+
return `Module${abc[index].toUpperCase()}`;
73+
})
74+
.join(', ')}];
75+
`;
76+
77+
writeFileSync('./libraries/plugins/src/plugins.ts', fileContent);

libraries/plugins/.eslintrc.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}

libraries/plugins/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# plugins
2+
3+
This library was generated with [Nx](https://nx.dev).

libraries/plugins/project.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "plugins",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libraries/plugins/src",
5+
"projectType": "library",
6+
"targets": {
7+
"lint": {
8+
"executor": "@nx/eslint:lint",
9+
"outputs": ["{options.outputFile}"]
10+
}
11+
},
12+
"tags": []
13+
}

libraries/plugins/src/list/public-api

Submodule public-api added at ebdb67c
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {Global, Module} from '@nestjs/common';
2+
import module from './plugins';
3+
4+
@Global()
5+
@Module({
6+
imports: [...module],
7+
controllers: [],
8+
providers: [],
9+
get exports() {
10+
return [...this.imports];
11+
}
12+
})
13+
export class PluginModule {}

libraries/plugins/src/plugins.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
export default [];

libraries/plugins/tsconfig.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"noImplicitOverride": true,
8+
"noImplicitReturns": true,
9+
"noFallthroughCasesInSwitch": true
10+
},
11+
"files": [],
12+
"include": [],
13+
"references": [
14+
{
15+
"path": "./tsconfig.lib.json"
16+
}
17+
]
18+
}

libraries/plugins/tsconfig.lib.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"declaration": true,
6+
"types": ["node"]
7+
},
8+
"include": ["src/**/*.ts"],
9+
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"]
10+
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"build:frontend": "npx nx run frontend:build:production",
1313
"dev:frontend": "npx nx run frontend:serve:development",
1414
"dev:backend": "npx nx run backend:serve:development",
15+
"update-plugins": "node ./build.plugins.js",
1516
"dev:workers": "npx nx run workers:serve:development",
1617
"dev:cron": "npx nx run cron:serve:development",
1718
"dev:docker": "docker compose -f ./docker-compose.dev.yaml up -d",
@@ -27,7 +28,7 @@
2728
"prisma-reset": "cd ./libraries/nestjs-libraries/src/database/prisma && npx prisma db push --force-reset && npx prisma db push",
2829
"docker-build": "./var/docker/docker-build.sh",
2930
"docker-create": "./var/docker/docker-create.sh",
30-
"postinstall": "npm run prisma-generate"
31+
"postinstall": "npm run update-plugins && npm run prisma-generate"
3132
},
3233
"private": true,
3334
"dependencies": {

tsconfig.base.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"@gitroom/helpers/*": ["libraries/helpers/src/*"],
2727
"@gitroom/nestjs-libraries/*": ["libraries/nestjs-libraries/src/*"],
2828
"@gitroom/react/*": ["libraries/react-shared-libraries/src/*"],
29-
"@gitroom/workers/*": ["apps/workers/src/*"]
29+
"@gitroom/plugins/*": ["libraries/plugins/src/*"],
30+
"@gitroom/workers/*": ["apps/workers/src/*"],
3031
}
3132
},
3233
"exclude": ["node_modules", "tmp"]

0 commit comments

Comments
 (0)