Skip to content

Commit

Permalink
feat(backend): Add finish function after rebuild project
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed Feb 21, 2024
1 parent 9caed8b commit bfe4554
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 8 deletions.
29 changes: 29 additions & 0 deletions backend/functions/config/rebuild-required.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as fs from "fs";

import { ConfigType, configPath, getConfigFile } from "./get-config-file";

import { CustomError } from "@/utils/errors/CustomError";

export const setRebuildRequired = async ({
set
}: {
set: "themes" | "langs" | "plugins";
}) => {
const config = await getConfigFile();

const newData: ConfigType = {
...config,
rebuild_required: {
...config.rebuild_required,
[set]: true
}
};

fs.writeFile(configPath, JSON.stringify(newData, null, 2), "utf8", err => {
if (err)
throw new CustomError({
code: "ERR_CONFIG_WRITE",
message: "Error writing to config file"
});
});
};
3 changes: 3 additions & 0 deletions backend/src/admin/core/languages/create/create.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ShowCoreLanguages } from "@/src/core/languages/show/dto/show.obj";
import { CustomError } from "@/utils/errors/CustomError";
import { core_languages } from "../../database/schema/languages";
import { currentDate } from "@/functions/date";
import { setRebuildRequired } from "@/functions/config/rebuild-required";

@Injectable()
export class CreateAdminCoreLanguageService {
Expand Down Expand Up @@ -52,6 +53,8 @@ export class CreateAdminCoreLanguageService {
{ recursive: true }
);

await setRebuildRequired({ set: "langs" });

return newLanguage[0];
}
}
3 changes: 3 additions & 0 deletions backend/src/admin/core/languages/delete/delete.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DatabaseService } from "@/database/database.service";
import { NotFoundError } from "@/utils/errors/not-found-error";
import { core_languages } from "../../database/schema/languages";
import { CustomError } from "@/utils/errors/CustomError";
import { setRebuildRequired } from "@/functions/config/rebuild-required";

@Injectable()
export class DeleteAdminCoreLanguageService {
Expand Down Expand Up @@ -49,6 +50,8 @@ export class DeleteAdminCoreLanguageService {
rm(path, { recursive: true });
}

await setRebuildRequired({ set: "langs" });

return "Success!";
}
}
3 changes: 3 additions & 0 deletions backend/src/admin/core/languages/update/update.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { UpdateCoreAdminLanguagesArgs } from "./dto/update.args";

import { DatabaseService } from "@/database/database.service";
import { NotFoundError } from "@/utils/errors/not-found-error";
import { setRebuildRequired } from "@/functions/config/rebuild-required";

@Injectable()
export class UpdateAdminCoreLanguageService {
Expand Down Expand Up @@ -44,6 +45,8 @@ export class UpdateAdminCoreLanguageService {
});
});

await setRebuildRequired({ set: "langs" });

return "Success!";
}
}
5 changes: 0 additions & 5 deletions backend/types/config.type.ts

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN apk add --no-cache libc6-compat
FROM base AS deps
WORKDIR /app
COPY package.json ./
COPY config ./config
RUN pnpm i

# Build the app
Expand All @@ -24,7 +25,6 @@ ENV NEXT_PUBLIC_GRAPHQL_URL=${NEXT_PUBLIC_GRAPHQL_URL}
ARG NEXT_PUBLIC_BACKEND_URL
ENV NEXT_PUBLIC_BACKEND_URL=${NEXT_PUBLIC_BACKEND_URL}

RUN pnpm config:init
RUN pnpm build

# Run the app
Expand Down
2 changes: 1 addition & 1 deletion frontend/themes/1/core/layout/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const Header = () => {

<div className="ml-auto sm:flex gap-2 hidden">
<ThemeSwitcher />
<DarkLightModeSwitcher />
<LanguageSwitcher />
<DarkLightModeSwitcher />
</div>

<UserBar />
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"frontend:build": "cd frontend && pnpm build && cd ..",
"frontend:start": "cd frontend && pnpm start",
"frontend:dev": "cd frontend && pnpm dev",
"docker:test": "pnpm config:init && docker-compose -f ./docker-compose-prod.yml -p vitnode-test up -d --build && sudo docker exec -d vitnode_backend /bin/sh -c \"pnpm db\" && pnpm config:finish",
"docker:test": "pnpm config:init && docker-compose -f ./docker-compose-prod.yml -p vitnode-test up -d --build && docker exec -d vitnode_backend /bin/sh -c \"pnpm db\" && pnpm config:finish",
"docker:dev": "docker-compose -f ./docker-compose-dev.yml -p vitnode-dev up -d",
"docker:prod": "pnpm config:init && sudo docker compose -f ./docker-compose-prod.yml -p vitnode-prod up -d --build && sudo docker exec -d vitnode_backend /bin/sh -c \"pnpm db\" && pnpm config:finish",
"lint": "cd backend && pnpm lint && cd .. && cd frontend && pnpm lint && cd ..",
Expand Down

0 comments on commit bfe4554

Please sign in to comment.