diff --git a/packages/backend/package.json b/packages/backend/package.json index b4c3910d..ffd680dc 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -29,7 +29,8 @@ "lint": "eslint .", "format": "prettier --write .", "format:check": "prettier --check .", - "db:load:fixtures": "DEBUG=snowball:* ts-node ./test/initialize-db.ts" + "db:load:fixtures": "DEBUG=snowball:* ts-node ./test/initialize-db.ts", + "db:delete": "DEBUG=snowball:* ts-node ./test/delete-db.ts" }, "devDependencies": { "@types/fs-extra": "^11.0.4", diff --git a/packages/backend/test/delete-db.ts b/packages/backend/test/delete-db.ts new file mode 100644 index 00000000..9fd6a9ab --- /dev/null +++ b/packages/backend/test/delete-db.ts @@ -0,0 +1,21 @@ +import * as fs from 'fs/promises'; +import debug from 'debug'; + +import { getConfig } from '../src/utils'; +import { Config } from '../src/config'; +import { DEFAULT_CONFIG_FILE_PATH } from '../src/constants'; + +const log = debug('snowball:delete-database'); + +const deleteFile = async (filePath: string) => { + await fs.unlink(filePath); + log(`File ${filePath} has been deleted.`); +}; + +const main = async () => { + const config = await getConfig(DEFAULT_CONFIG_FILE_PATH); + + deleteFile(config.database.dbPath); +}; + +main().catch(err => log(err)); diff --git a/packages/backend/test/initialize-db.ts b/packages/backend/test/initialize-db.ts index e89de0c1..ee647ca9 100644 --- a/packages/backend/test/initialize-db.ts +++ b/packages/backend/test/initialize-db.ts @@ -11,11 +11,12 @@ import { EnvironmentVariable } from '../src/entity/EnvironmentVariable'; import { Domain } from '../src/entity/Domain'; import { ProjectMember } from '../src/entity/ProjectMember'; import { Deployment } from '../src/entity/Deployment'; +import { getConfig } from '../src/utils'; +import { Config } from '../src/config'; +import { DEFAULT_CONFIG_FILE_PATH } from '../src/constants'; const log = debug('snowball:initialize-database'); -const DB_PATH = '../db/snowball'; - const USER_DATA_PATH = './fixtures/users.json'; const PROJECT_DATA_PATH = './fixtures/projects.json'; const ORGANIZATION_DATA_PATH = './fixtures/organizations.json'; @@ -103,12 +104,13 @@ const checkFileExists = async (filePath: string) => { }; const main = async () => { - const isDbPresent = await checkFileExists(path.resolve(__dirname, DB_PATH)); + const config = await getConfig(DEFAULT_CONFIG_FILE_PATH); + const isDbPresent = await checkFileExists(config.database.dbPath); if (!isDbPresent) { const dataSource = new DataSource({ type: 'better-sqlite3', - database: 'db/snowball', + database: config.database.dbPath, synchronize: true, logging: true, entities: [path.join(__dirname, '../src/entity/*')] diff --git a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx index d67d02d2..6d8846d5 100644 --- a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx +++ b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx @@ -86,7 +86,7 @@ const DeploymentDetailsCard = ({
- {relativeTimeMs(deployment.updatedAt)} ^ {deployment.author} + {relativeTimeMs(deployment.createdAt)} ^ {deployment.author} diff --git a/packages/frontend/src/components/projects/project/deployments/DeploymentDialogBodyCard.tsx b/packages/frontend/src/components/projects/project/deployments/DeploymentDialogBodyCard.tsx index 473cfd6e..46f48409 100644 --- a/packages/frontend/src/components/projects/project/deployments/DeploymentDialogBodyCard.tsx +++ b/packages/frontend/src/components/projects/project/deployments/DeploymentDialogBodyCard.tsx @@ -28,7 +28,7 @@ const DeploymentDialogBodyCard = ({ /> )} - deployment title + {deployment.title} ^ {deployment.branch} ^ {deployment.commit.hash}{' '} diff --git a/packages/frontend/src/types/project.ts b/packages/frontend/src/types/project.ts index 5f8c1e0a..8fb4dbf3 100644 --- a/packages/frontend/src/types/project.ts +++ b/packages/frontend/src/types/project.ts @@ -46,6 +46,7 @@ export interface DeploymentDetails { message: string; }; author: string; + createdAt: string; updatedAt: string; }