diff --git a/package.json b/package.json index eceba242..74f75f79 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fosrl/pangolin", - "version": "1.0.0-beta.10", + "version": "0.0.0", "private": true, "type": "module", "description": "Tunneled Reverse Proxy Management Server with Identity and Access Control and Dashboard UI", diff --git a/server/lib/config.ts b/server/lib/config.ts index 14e96af1..f2d8a161 100644 --- a/server/lib/config.ts +++ b/server/lib/config.ts @@ -6,6 +6,7 @@ import { fromError } from "zod-validation-error"; import { __DIRNAME, APP_PATH, + APP_VERSION, configFilePath1, configFilePath2 } from "@server/lib/consts"; @@ -239,11 +240,7 @@ export class Config { throw new Error(`Invalid configuration file: ${errors}`); } - const appVersion = loadAppVersion(); - if (!appVersion) { - throw new Error("Could not load the application version"); - } - process.env.APP_VERSION = appVersion; + process.env.APP_VERSION = APP_VERSION; process.env.NEXT_PORT = parsedConfig.data.server.next_port.toString(); process.env.SERVER_EXTERNAL_PORT = diff --git a/server/lib/consts.ts b/server/lib/consts.ts index a444f9c5..2f505ae1 100644 --- a/server/lib/consts.ts +++ b/server/lib/consts.ts @@ -1,6 +1,8 @@ import path from "path"; import { fileURLToPath } from "url"; -import { existsSync } from "fs"; + +// This is a placeholder value replaced by the build process +export const APP_VERSION = "1.0.0-beta.12"; export const __FILENAME = fileURLToPath(import.meta.url); export const __DIRNAME = path.dirname(__FILENAME); diff --git a/server/lib/loadAppVersion.ts b/server/lib/loadAppVersion.ts deleted file mode 100644 index 80d9f558..00000000 --- a/server/lib/loadAppVersion.ts +++ /dev/null @@ -1,16 +0,0 @@ -import path from "path"; -import { __DIRNAME } from "@server/lib/consts"; -import fs from "fs"; - -export function loadAppVersion() { - const packageJsonPath = path.join("package.json"); - let packageJson: any; - if (fs.existsSync && fs.existsSync(packageJsonPath)) { - const packageJsonContent = fs.readFileSync(packageJsonPath, "utf8"); - packageJson = JSON.parse(packageJsonContent); - - if (packageJson.version) { - return packageJson.version; - } - } -} diff --git a/server/setup/migrations.ts b/server/setup/migrations.ts index b06f176c..e0e25f15 100644 --- a/server/setup/migrations.ts +++ b/server/setup/migrations.ts @@ -3,8 +3,7 @@ import db, { exists } from "@server/db"; import path from "path"; import semver from "semver"; import { versionMigrations } from "@server/db/schema"; -import { __DIRNAME } from "@server/lib/consts"; -import { loadAppVersion } from "@server/lib/loadAppVersion"; +import { __DIRNAME, APP_VERSION } from "@server/lib/consts"; import { SqliteError } from "better-sqlite3"; import m1 from "./scripts/1.0.0-beta1"; import m2 from "./scripts/1.0.0-beta2"; @@ -34,10 +33,7 @@ await runMigrations(); export async function runMigrations() { try { - const appVersion = loadAppVersion(); - if (!appVersion) { - throw new Error("APP_VERSION is not set in the environment"); - } + const appVersion = APP_VERSION; if (exists) { await executeScripts();