chore: remove un-used exports and dependencies

This commit is contained in:
Nicolas Meienberger 2023-08-16 21:30:51 +02:00 committed by Nicolas Meienberger
parent 5716034427
commit d62558f41d
10 changed files with 396 additions and 646 deletions

View file

@ -128,5 +128,8 @@ jobs:
- name: Build client
run: npm run build:next
- name: Run linter
run: npm run lint
- name: Run tsc
run: pnpm run tsc
- name: Run packages tsc
run: pnpm -r run tsc

View file

@ -3,6 +3,7 @@
"version": "1.6.0",
"description": "A homeserver for everyone",
"scripts": {
"knip": "knip",
"prepare": "mkdir -p state && echo \"{}\" > state/system-info.json && echo \"random-seed\" > state/seed",
"copy:migrations": "mkdir -p dist/migrations && cp -r ./src/server/migrations dist",
"test": "dotenv -e .env.test -- jest --colors",
@ -66,7 +67,6 @@
"lodash.merge": "^4.6.2",
"next": "13.4.7",
"next-intl": "^2.15.1",
"node-cron": "^3.0.1",
"pg": "^8.11.1",
"qrcode.react": "^3.1.0",
"react": "18.2.0",
@ -87,7 +87,6 @@
"tslib": "^2.5.3",
"uuid": "^9.0.0",
"validator": "^13.7.0",
"web-push": "^3.6.3",
"winston": "^3.9.0",
"zod": "^3.21.4",
"zustand": "^4.3.8"
@ -109,7 +108,6 @@
"@types/jest": "^29.5.2",
"@types/lodash.merge": "^4.6.7",
"@types/node": "20.3.2",
"@types/node-cron": "^3.0.8",
"@types/pg": "^8.10.2",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
@ -118,14 +116,11 @@
"@types/testing-library__jest-dom": "^5.14.6",
"@types/uuid": "^9.0.2",
"@types/validator": "^13.7.17",
"@types/web-push": "^3.3.2",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"@vitejs/plugin-react": "^4.0.1",
"@vitest/coverage-v8": "^0.32.2",
"concurrently": "^8.2.0",
"dotenv-cli": "^7.2.1",
"drizzle-kit": "^0.19.2",
"esbuild": "^0.16.17",
"eslint": "8.43.0",
"eslint-config-airbnb": "^19.0.4",
@ -143,6 +138,7 @@
"eslint-plugin-testing-library": "^5.11.0",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"knip": "^2.19.4",
"memfs": "^4.2.0",
"msw": "^1.2.2",
"next-router-mock": "^0.9.7",
@ -155,8 +151,7 @@
"typescript": "5.1.5",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.32.2",
"wait-for-expect": "^3.0.2",
"whatwg-fetch": "^3.6.2"
"wait-for-expect": "^3.0.2"
},
"msw": {
"workerDirectory": "public"

View file

@ -30,8 +30,8 @@
"devDependencies": {
"@faker-js/faker": "^8.0.2",
"@types/cli-progress": "^3.11.0",
"@types/inquirer": "^9.0.3",
"@types/node": "20.3.2",
"@types/web-push": "^3.3.2",
"dotenv-cli": "^7.2.1",
"esbuild": "^0.16.17",
"eslint-config-prettier": "^8.8.0",
@ -52,7 +52,6 @@
"cli-spinners": "^2.9.0",
"commander": "^11.0.0",
"dotenv": "^16.3.1",
"inquirer": "^9.2.8",
"log-update": "^5.0.1",
"semver": "^7.5.3",
"systeminformation": "^5.18.7",

View file

@ -30,6 +30,4 @@ const environmentSchema = z
};
});
export type Environment = z.infer<typeof environmentSchema>;
export const getEnv = () => environmentSchema.parse(process.env);

948
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -1,4 +0,0 @@
export type ContainerProps<T> = {
loading?: boolean;
error?: string;
} & T;

View file

@ -1,8 +1,8 @@
import { InferModel } from 'drizzle-orm';
import { pgTable, pgEnum, integer, varchar, timestamp, serial, boolean, text, jsonb } from 'drizzle-orm/pg-core';
export const updateStatusEnum = pgEnum('update_status_enum', ['SUCCESS', 'FAILED']);
export const appStatusEnum = pgEnum('app_status_enum', ['running', 'stopped', 'starting', 'stopping', 'updating', 'missing', 'installing', 'uninstalling']);
const updateStatusEnum = pgEnum('update_status_enum', ['SUCCESS', 'FAILED']);
const appStatusEnum = pgEnum('app_status_enum', ['running', 'stopped', 'starting', 'stopping', 'updating', 'missing', 'installing', 'uninstalling']);
const APP_STATUS = appStatusEnum.enumValues;
export type AppStatus = (typeof APP_STATUS)[number];

View file

@ -4,7 +4,7 @@ import { faker } from '@faker-js/faker';
import { TestDatabase, clearDatabase, closeDatabase, createDatabase } from '@/server/tests/test-utils';
import { appInfoSchema } from '@runtipi/shared';
import { setConfig } from '../../core/TipiConfig';
import { checkAppRequirements, checkEnvFile, getAppInfo, getAvailableApps, getUpdateInfo } from './apps.helpers';
import { checkAppRequirements, getAppInfo, getAvailableApps, getUpdateInfo } from './apps.helpers';
import { createAppConfig, insertApp } from '../../tests/apps.factory';
let db: TestDatabase;
@ -49,39 +49,6 @@ describe('Test: checkAppRequirements()', () => {
});
});
describe('Test: checkEnvFile()', () => {
it('Should not throw if all required fields are present', async () => {
// arrange
const appConfig = createAppConfig();
const app = await insertApp({}, appConfig, db);
// act
await checkEnvFile(app.id);
});
it('Should throw if a required field is missing', async () => {
// arrange
const fieldName = faker.lorem.word().toUpperCase();
const appConfig = createAppConfig({ form_fields: [{ env_variable: fieldName, type: 'text', label: 'test', required: true }] });
const app = await insertApp({}, appConfig, db);
const newAppEnv = 'APP_PORT=test\n';
fs.writeFileSync(`/app/storage/app-data/${app.id}/app.env`, newAppEnv);
// act & assert
await expect(checkEnvFile(app.id)).rejects.toThrowError('New info needed. App config needs to be updated');
});
it('Should throw if config.json is incorrect', async () => {
// arrange
const appConfig = createAppConfig();
const app = await insertApp({}, appConfig, db);
fs.writeFileSync(`/runtipi/apps/${app.id}/config.json`, 'invalid json');
// act & assert
await expect(checkEnvFile(app.id)).rejects.toThrowError(`App ${app.id} has invalid config.json file`);
});
});
describe('Test: appInfoSchema', () => {
it('should default form_field type to text if it is wrong', async () => {
// arrange

View file

@ -86,7 +86,7 @@ describe('Test: getVersion', () => {
const body = faker.lorem.words(10);
server.use(
rest.get('https://api.github.com/repos/meienberger/runtipi/releases/latest', (_, res, ctx) => {
return res(ctx.json({ name: `v${faker.string.numeric(1)}.${faker.string.numeric(1)}.${faker.string.numeric()}`, body }));
return res(ctx.json({ tag_name: `v${faker.string.numeric(1)}.${faker.string.numeric(1)}.${faker.string.numeric()}`, body }));
}),
);
@ -118,7 +118,7 @@ describe('Test: getVersion', () => {
// Arrange
server.use(
rest.get('https://api.github.com/repos/meienberger/runtipi/releases/latest', (_, res, ctx) => {
return res(ctx.json({ name: `v${faker.string.numeric(1)}.${faker.string.numeric(1)}.${faker.string.numeric()}` }));
return res(ctx.json({ tag_name: `v${faker.string.numeric(1)}.${faker.string.numeric(1)}.${faker.string.numeric()}` }));
}),
);

View file

@ -1,24 +0,0 @@
import fs from 'fs-extra';
/**
* This function reads the env file for the app with the provided id and returns a Map containing the key-value pairs of the environment variables.
* It reads the app.env file, splits it into individual environment variables, and stores them in a Map, with the environment variable name as the key and its value as the value.
*
* @param {string} id - App ID
*/
export const getAppEnvMap = async (id: string) => {
try {
const envFile = await fs.promises.readFile(`/app/storage/app-data/${id}/app.env`);
const envVars = envFile.toString().split('\n');
const envVarsMap = new Map<string, string>();
envVars.forEach((envVar) => {
const [key, value] = envVar.split('=');
if (key && value) envVarsMap.set(key, value);
});
return envVarsMap;
} catch (e) {
return new Map<string, string>();
}
};