From 5ac607d7f164daebc7dce5c520538194400f2503 Mon Sep 17 00:00:00 2001 From: Ayobami Akingbade Date: Sat, 18 Nov 2023 00:49:45 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(packages):=20remo?= =?UTF-8?q?ve=20old=20packages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 --------- package-lock.json | 12 --------- package.json | 2 -- .../npm-packages/npm-packages.controller.ts | 16 ----------- .../npm-packages/npm-packages.service.ts | 2 +- src/bin/index.ts | 27 ++++++++++--------- src/pages/api/healthcheck/index.ts | 5 ---- src/pages/api/npm-packages/install.ts | 15 ----------- 8 files changed, 15 insertions(+), 76 deletions(-) delete mode 100644 src/backend/npm-packages/npm-packages.controller.ts delete mode 100644 src/pages/api/npm-packages/install.ts diff --git a/README.md b/README.md index 3692f76ed..efaffde01 100644 --- a/README.md +++ b/README.md @@ -186,18 +186,6 @@ DashPress is provided **"as is"** without any **warranty**. _For more information and to report security issues, please refer to our [security documentation](docs/SECURITY.md)._ -## Built With -- [KnexJS](https://github.com/knex/knex) -- [React](https://github.com/facebook/react) -- [NextJS](https://github.com/vercel/next.js) -- [Typescript](https://github.com/microsoft/TypeScript) -- [React Query](https://github.com/TanStack/query) -- [React Table](https://github.com/TanStack/table) -- [React Final Form](https://github.com/final-form/react-final-form) -- [Styled-components](https://github.com/styled-components/styled-components) -- [Class Validator](https://github.com/typestack/class-validator) -- [Zustand](https://github.com/pmndrs/zustand) - ## License This project is licensed under the **GNU Affero General Public License v3.0**. diff --git a/package-lock.json b/package-lock.json index 66803b2ad..9d09236e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,6 @@ "@types/react": "^18.0.11", "@types/react-datepicker": "^4.4.1", "@types/styled-components": "^5.1.25", - "@types/uuid": "^8.3.4", "axios": "^1.2.1", "bcrypt": "^5.0.1", "change-case": "^4.1.2", @@ -74,7 +73,6 @@ "styled-components": "^5.3.6", "terminal-link": "^3.0.0", "tiny-skeleton-loader-react": "^1.2.1", - "uuid": "^8.3.2", "winston": "^3.8.2", "zod": "^3.21.4", "zustand": "3.4.2" @@ -9141,11 +9139,6 @@ "integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==", "dev": true }, - "node_modules/@types/uuid": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", - "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==" - }, "node_modules/@types/warning": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.0.tgz", @@ -39702,11 +39695,6 @@ "integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==", "dev": true }, - "@types/uuid": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", - "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==" - }, "@types/warning": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.0.tgz", diff --git a/package.json b/package.json index 3b4a98cdd..ed71e9dfe 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "@types/react": "^18.0.11", "@types/react-datepicker": "^4.4.1", "@types/styled-components": "^5.1.25", - "@types/uuid": "^8.3.4", "axios": "^1.2.1", "bcrypt": "^5.0.1", "change-case": "^4.1.2", @@ -97,7 +96,6 @@ "styled-components": "^5.3.6", "terminal-link": "^3.0.0", "tiny-skeleton-loader-react": "^1.2.1", - "uuid": "^8.3.2", "winston": "^3.8.2", "zod": "^3.21.4", "zustand": "3.4.2" diff --git a/src/backend/npm-packages/npm-packages.controller.ts b/src/backend/npm-packages/npm-packages.controller.ts deleted file mode 100644 index de5b867ed..000000000 --- a/src/backend/npm-packages/npm-packages.controller.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { - NpmPackagesApiService, - npmPackagesApiService, -} from "./npm-packages.service"; - -export class NpmPackagesApiController { - constructor(private _npmPackagesApiService: NpmPackagesApiService) {} - - async installPackages() { - await this._npmPackagesApiService.installPackages(); - } -} - -export const npmPackagesApiController = new NpmPackagesApiController( - npmPackagesApiService -); diff --git a/src/backend/npm-packages/npm-packages.service.ts b/src/backend/npm-packages/npm-packages.service.ts index a64225b61..05b4504ff 100644 --- a/src/backend/npm-packages/npm-packages.service.ts +++ b/src/backend/npm-packages/npm-packages.service.ts @@ -30,7 +30,7 @@ export class NpmPackagesApiService implements IApplicationService { await this.installPackages(); } - async installPackages(): Promise { + private async installPackages(): Promise { const dir = "npm-temp"; if (!fs.existsSync(dir)) { diff --git a/src/bin/index.ts b/src/bin/index.ts index 582e87e21..71de4634e 100644 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -1,7 +1,20 @@ /* eslint-disable no-console */ import * as randomstring from "randomstring"; +import { npmPackagesApiService } from "backend/npm-packages/npm-packages.service"; import { checkNodeVersion } from "./checkNodeVersion"; +const replaceRandomCharaters = (envContent: string) => { + return ["CREDENTIALS_ENCRYPTION_KEY", "AUTH_TOKEN_KEY"].reduce( + (reducedEnvContent, currentKey) => { + return reducedEnvContent.replace( + `${currentKey}=RANDOM_CHARACTERS`, + `${currentKey}=${randomstring.generate(128)}` + ); + }, + envContent + ); +}; + (async () => { const path = require("path"); const fs = require("fs-extra"); @@ -10,18 +23,6 @@ import { checkNodeVersion } from "./checkNodeVersion"; const { default: fetch } = await import("node-fetch"); - const replaceRandomCharaters = (envContent: string) => { - return ["CREDENTIALS_ENCRYPTION_KEY", "AUTH_TOKEN_KEY"].reduce( - (reducedEnvContent, currentKey) => { - return reducedEnvContent.replace( - `${currentKey}=RANDOM_CHARACTERS`, - `${currentKey}=${randomstring.generate(128)}` - ); - }, - envContent - ); - }; - const defaultEnv = () => { if (fs.existsSync(path.join(process.cwd(), "./.env.local"))) { return; @@ -95,7 +96,7 @@ import { checkNodeVersion } from "./checkNodeVersion"; )} `); - // TODO Doing the npm package thing here + await npmPackagesApiService.bootstrap(); const { stdout, stderr } = execa("npm", ["run", "start"], { cwd: path.join(__dirname, ".."), diff --git a/src/pages/api/healthcheck/index.ts b/src/pages/api/healthcheck/index.ts index 393631b33..2ee8a6ca2 100644 --- a/src/pages/api/healthcheck/index.ts +++ b/src/pages/api/healthcheck/index.ts @@ -12,7 +12,6 @@ import { configApiService } from "backend/lib/config/config.service"; import { rolesApiService } from "backend/roles/roles.service"; import { schemasApiService } from "backend/schema/schema.service"; import { usersApiService } from "backend/users/users.service"; -// import { npmPackagesApiService } from "backend/npm-packages/npm-packages.service"; import { storageApiService } from "backend/storage/storage.service"; import { actionsApiService } from "backend/actions/actions.service"; import { dashboardWidgetsApiService } from "backend/dashboard-widgets/dashboard-widgets.service"; @@ -41,12 +40,8 @@ export default requestHandler( await storageApiService.bootstrap(); await listOrderApiService.bootstrap(); - // await npmPackagesApiService.bootstrap(); - await bootstrapPortalServices(); - // await npmPackagesApiService.installPackages(); - await tempStorageApiService.bootstrap(); } catch (error) { noop(); diff --git a/src/pages/api/npm-packages/install.ts b/src/pages/api/npm-packages/install.ts deleted file mode 100644 index 9e3ad4ca2..000000000 --- a/src/pages/api/npm-packages/install.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { npmPackagesApiController } from "backend/npm-packages/npm-packages.controller"; -import { requestHandler } from "backend/lib/request"; - -export default requestHandler( - { - GET: async () => { - return await npmPackagesApiController.installPackages(); - }, - }, - [ - { - _type: "anyBody", - }, - ] -);