mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-31 15:09:39 +02:00
pull app version from consts instead of package.json
This commit is contained in:
parent
889f8e1394
commit
94ce5edc61
5 changed files with 8 additions and 29 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@fosrl/pangolin",
|
"name": "@fosrl/pangolin",
|
||||||
"version": "1.0.0-beta.10",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Tunneled Reverse Proxy Management Server with Identity and Access Control and Dashboard UI",
|
"description": "Tunneled Reverse Proxy Management Server with Identity and Access Control and Dashboard UI",
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { fromError } from "zod-validation-error";
|
||||||
import {
|
import {
|
||||||
__DIRNAME,
|
__DIRNAME,
|
||||||
APP_PATH,
|
APP_PATH,
|
||||||
|
APP_VERSION,
|
||||||
configFilePath1,
|
configFilePath1,
|
||||||
configFilePath2
|
configFilePath2
|
||||||
} from "@server/lib/consts";
|
} from "@server/lib/consts";
|
||||||
|
@ -239,11 +240,7 @@ export class Config {
|
||||||
throw new Error(`Invalid configuration file: ${errors}`);
|
throw new Error(`Invalid configuration file: ${errors}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const appVersion = loadAppVersion();
|
process.env.APP_VERSION = APP_VERSION;
|
||||||
if (!appVersion) {
|
|
||||||
throw new Error("Could not load the application version");
|
|
||||||
}
|
|
||||||
process.env.APP_VERSION = appVersion;
|
|
||||||
|
|
||||||
process.env.NEXT_PORT = parsedConfig.data.server.next_port.toString();
|
process.env.NEXT_PORT = parsedConfig.data.server.next_port.toString();
|
||||||
process.env.SERVER_EXTERNAL_PORT =
|
process.env.SERVER_EXTERNAL_PORT =
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { fileURLToPath } from "url";
|
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 __FILENAME = fileURLToPath(import.meta.url);
|
||||||
export const __DIRNAME = path.dirname(__FILENAME);
|
export const __DIRNAME = path.dirname(__FILENAME);
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,8 +3,7 @@ import db, { exists } from "@server/db";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
import { versionMigrations } from "@server/db/schema";
|
import { versionMigrations } from "@server/db/schema";
|
||||||
import { __DIRNAME } from "@server/lib/consts";
|
import { __DIRNAME, APP_VERSION } from "@server/lib/consts";
|
||||||
import { loadAppVersion } from "@server/lib/loadAppVersion";
|
|
||||||
import { SqliteError } from "better-sqlite3";
|
import { SqliteError } from "better-sqlite3";
|
||||||
import m1 from "./scripts/1.0.0-beta1";
|
import m1 from "./scripts/1.0.0-beta1";
|
||||||
import m2 from "./scripts/1.0.0-beta2";
|
import m2 from "./scripts/1.0.0-beta2";
|
||||||
|
@ -34,10 +33,7 @@ await runMigrations();
|
||||||
|
|
||||||
export async function runMigrations() {
|
export async function runMigrations() {
|
||||||
try {
|
try {
|
||||||
const appVersion = loadAppVersion();
|
const appVersion = APP_VERSION;
|
||||||
if (!appVersion) {
|
|
||||||
throw new Error("APP_VERSION is not set in the environment");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
await executeScripts();
|
await executeScripts();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue