Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Create/delete plugins while restarting server #568

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backend",
"version": "0.0.10-canary.2",
"version": "0.0.10-canary.4",
"license": "MIT",
"scripts": {
"drizzle-kit": "drizzle-kit",
Expand All @@ -14,17 +14,16 @@
},
"dependencies": {
"@nestjs/apollo": "^12.2.0",
"@nestjs/common": "^10.4.4",
"@nestjs/config": "^3.2.3",
"@nestjs/core": "^10.4.4",
"@nestjs/common": "^10.4.5",
"@nestjs/core": "^10.4.5",
"@nestjs/graphql": "^12.2.0",
"@nestjs/jwt": "^10.2.0",
"@nestjs/platform-express": "^10.4.4",
"@nestjs/platform-express": "^10.4.5",
"@nestjs/schedule": "^4.1.1",
"@nestjs/serve-static": "^4.0.2",
"pg": "^8.13.0",
"react": "19.0.0-rc-6cf85185-20241014",
"react-dom": "19.0.0-rc-6cf85185-20241014",
"react": "19.0.0-rc-69d4b800-20241021",
"react-dom": "19.0.0-rc-69d4b800-20241021",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"vitnode-backend": "workspace:*",
Expand All @@ -39,18 +38,18 @@
"@graphql-codegen/typescript-document-nodes": "^4.0.10",
"@graphql-codegen/typescript-operations": "^4.3.0",
"@nestjs/cli": "^10.4.5",
"@nestjs/schematics": "^10.1.4",
"@nestjs/schematics": "^10.2.2",
"@react-email/components": "^0.0.25",
"@swc/cli": "^0.4.0",
"@types/express": "^4.17.21",
"@types/node": "^22.7.5",
"@types/node": "^22.7.8",
"@types/pg": "^8.11.10",
"@types/react": "^18.3.11",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"cross-env": "^7.0.3",
"drizzle-kit": "^0.25.0",
"drizzle-orm": "^0.34.1",
"drizzle-kit": "^0.26.2",
"drizzle-orm": "^0.35.3",
"eslint-config-typescript-vitnode": "workspace:*",
"object-path": "^0.11.8",
"source-map-support": "^0.5.21",
Expand Down
14 changes: 7 additions & 7 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "0.0.10-canary.2",
"version": "0.0.10-canary.4",
"author": "Maciej Piotr (aXenDev) Balcerzak",
"license": "GPL-3.0 license",
"scripts": {
Expand All @@ -17,27 +17,27 @@
},
"dependencies": {
"geist": "^1.3.1",
"lucide-react": "^0.451.0",
"next": "15.0.0-rc.1",
"next-intl": "3.21.0-canary.0",
"lucide-react": "^0.453.0",
"next": "15.0.0",
"next-intl": "3.23.1",
"react": "19.0.0-rc-6cf85185-20241014",
"react-dom": "19.0.0-rc-6cf85185-20241014",
"react-hook-form": "^7.53.0",
"react-hook-form": "^7.53.1",
"recharts": "^2.13.0",
"sonner": "^1.5.0",
"vitnode-frontend": "workspace:*",
"zod": "^3.23.8"
},
"devDependencies": {
"@graphql-codegen/cli": "^5.0.3",
"@types/node": "^22.7.5",
"@types/node": "^22.7.8",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"autoprefixer": "^10.4.20",
"eslint-config-typescript-vitnode": "workspace:*",
"graphql-tag": "^2.12.6",
"postcss": "^8.4.47",
"tailwindcss": "^3.4.13",
"tailwindcss": "^3.4.14",
"typescript": "^5.6.3"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"pnpm": {
"overrides": {
"react-is": "19.0.0-rc-6cf85185-20241014"
"react-is": "19.0.0-rc-69d4b800-20241021"
}
},
"workspaces": [
Expand All @@ -35,7 +35,7 @@
"eslint-config-typescript-vitnode": "workspace:*",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.8",
"turbo": "^2.1.3"
"turbo": "^2.2.3"
},
"packageManager": "pnpm@9.10.0"
}
10 changes: 5 additions & 5 deletions packages/backend-ai-google/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vitnode-backend-ai-google",
"version": "0.0.10-canary.2",
"version": "0.0.10-canary.4",
"description": "Google AI provider for VitNode projects.",
"author": "VitNode Team",
"license": "MIT",
Expand All @@ -27,14 +27,14 @@
],
"devDependencies": {
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.35",
"@types/node": "^22.7.5",
"ai": "^3.4.10",
"@swc/core": "^1.7.39",
"@types/node": "^22.7.8",
"ai": "^3.4.18",
"concurrently": "^9.0.1",
"eslint-config-typescript-vitnode": "workspace:*",
"typescript": "^5.6.3"
},
"dependencies": {
"@ai-sdk/google": "^0.0.51"
"@ai-sdk/google": "^0.0.52"
}
}
10 changes: 5 additions & 5 deletions packages/backend-ai-open-ai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vitnode-backend-ai-open-ai",
"version": "0.0.10-canary.2",
"version": "0.0.10-canary.4",
"description": "OpenAI provider for VitNode projects.",
"author": "VitNode Team",
"license": "MIT",
Expand All @@ -27,14 +27,14 @@
],
"devDependencies": {
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.35",
"@types/node": "^22.7.5",
"ai": "^3.4.10",
"@swc/core": "^1.7.39",
"@types/node": "^22.7.8",
"ai": "^3.4.18",
"concurrently": "^9.0.1",
"eslint-config-typescript-vitnode": "workspace:*",
"typescript": "^5.6.3"
},
"dependencies": {
"@ai-sdk/openai": "^0.0.67"
"@ai-sdk/openai": "^0.0.68"
}
}
6 changes: 3 additions & 3 deletions packages/backend-email-resend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vitnode-backend-email-resend",
"version": "0.0.10-canary.2",
"version": "0.0.10-canary.4",
"description": "Resend email provider for VitNode projects.",
"author": "VitNode Team",
"license": "MIT",
Expand All @@ -24,8 +24,8 @@
],
"devDependencies": {
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.35",
"@types/node": "^22.7.5",
"@swc/core": "^1.7.39",
"@types/node": "^22.7.8",
"concurrently": "^9.0.1",
"eslint-config-typescript-vitnode": "workspace:*",
"typescript": "^5.6.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/backend-email-smtp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vitnode-backend-email-smtp",
"version": "0.0.10-canary.2",
"version": "0.0.10-canary.4",
"description": "SMTP email provider for VitNode projects.",
"author": "VitNode Team",
"license": "MIT",
Expand All @@ -25,8 +25,8 @@
],
"devDependencies": {
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.35",
"@types/node": "^22.7.5",
"@swc/core": "^1.7.39",
"@types/node": "^22.7.8",
"@types/nodemailer": "^6.4.16",
"concurrently": "^9.0.1",
"eslint-config-typescript-vitnode": "workspace:*",
Expand Down
22 changes: 11 additions & 11 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vitnode-backend",
"version": "0.0.10-canary.2",
"version": "0.0.10-canary.4",
"description": "Backend wrapper for VitNode projects",
"author": "VitNode Team",
"license": "MIT",
Expand Down Expand Up @@ -60,13 +60,13 @@
"@graphql-codegen/typescript-document-nodes": "^4.0.10",
"@graphql-codegen/typescript-operations": "^4.3.0",
"@nestjs/apollo": "^12.2.0",
"@nestjs/config": "^3.2.3",
"@nestjs/config": "^3.3.0",
"@nestjs/jwt": "^10.2.0",
"@nestjs/serve-static": "^4.0.2",
"@react-email/render": "^1.0.1",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.35",
"ai": "^3.4.10",
"@swc/core": "^1.7.39",
"ai": "^3.4.18",
"busboy": "^1.6.0",
"cookie-parser": "^1.4.7",
"helmet": "^8.0.0",
Expand All @@ -78,8 +78,8 @@
},
"devDependencies": {
"@graphql-codegen/cli": "^5.0.3",
"@nestjs/common": "^10.4.4",
"@nestjs/core": "^10.4.4",
"@nestjs/common": "^10.4.5",
"@nestjs/core": "^10.4.5",
"@nestjs/graphql": "^12.2.0",
"@nestjs/schedule": "^4.1.1",
"@nestjs/throttler": "^6.2.1",
Expand All @@ -88,22 +88,22 @@
"@types/cookie-parser": "^1.4.7",
"@types/express": "^4.17.21",
"@types/http-errors": "^2.0.4",
"@types/node": "^22.7.5",
"@types/node": "^22.7.8",
"@types/object-path": "^0.11.4",
"@types/pg": "^8.11.10",
"@types/react": "^18.3.11",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"concurrently": "^9.0.1",
"dotenv": "^16.4.5",
"drizzle-kit": "^0.25.0",
"drizzle-orm": "^0.34.1",
"drizzle-kit": "^0.26.2",
"drizzle-orm": "^0.35.3",
"eslint-config-typescript-vitnode": "workspace:*",
"express": "^4.21.1",
"graphql": "^16.9.0",
"pg": "^8.13.0",
"react": "19.0.0-rc-6cf85185-20241014",
"react-dom": "19.0.0-rc-6cf85185-20241014",
"react": "19.0.0-rc-69d4b800-20241021",
"react-dom": "19.0.0-rc-69d4b800-20241021",
"ts-node": "^10.9.2",
"tsup": "^8.3.0",
"typescript": "^5.6.3"
Expand Down
54 changes: 29 additions & 25 deletions packages/backend/src/core/admin/plugins/create/create.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,38 +86,42 @@ export class CreateAdminPluginsService {
// Verify files and folders to check if they exist
this.verifyFilesService.verifyFiles({ code });

// Create basic files
await this.createFilesService.createFiles({
author,
author_url,
code,
description,
name,
support_url,
allow_default: true,
nav: [],
version: '0.0.1',
version_code: 1,
});
const [data] = await Promise.all([
// Insert into database
this.databaseService.db
.insert(core_plugins)
.values({
code,
description,
name,
support_url,
author,
author_url,
})
.returning(),

const [data] = await this.databaseService.db
.insert(core_plugins)
.values({
// Create basic files
this.createFilesService.createFiles({
author,
author_url,
code,
description,
name,
support_url,
author,
author_url,
})
.returning();
allow_default: true,
nav: [],
version: '0.0.1',
version_code: 1,
}),

// Create i18n files
await this.createLanguageFiles({ code, name });
// Create i18n files
this.createLanguageFiles({ code, name }),

// Modifying / Create files
await this.changeFilesService.changeFiles({ code, action: 'add' });
// Modifying / Create files
this.changeFilesService.changeFiles({ code, action: 'add' }),
this.changeFilesService.setServerToRestartConfig(),
]);

return data;
return data[0];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export class ChangeFilesAdminPluginsService {
}),
getEntryName: code => `typeof ${code}`,
reconstructFileContent: (imports, entries, originalContent) => {
// TODO: Remove console.log
// eslint-disable-next-line no-console
console.log({ imports, entries, originalContent });

let newContent = '';
imports.forEach((path, name) => {
newContent += `import type ${name} from '${path}';\n`;
Expand Down
Loading