mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 08:12:40 +10:00
feat: allow clients to fetch drop version
This commit is contained in:
@ -1,6 +1,20 @@
|
|||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
|
import { execSync } from "node:child_process";
|
||||||
|
|
||||||
const dropVersion = "v0.3.0";
|
// get drop version
|
||||||
|
const dropVersion =
|
||||||
|
process.env.BUILD_DROP_VERSION === undefined
|
||||||
|
? "v0.3.0-alpha.1"
|
||||||
|
: process.env.BUILD_DROP_VERSION;
|
||||||
|
// example nightly: "v0.3.0-nightly.2025.05.28"
|
||||||
|
|
||||||
|
// get git ref or supply during build
|
||||||
|
const commitHash =
|
||||||
|
process.env.BUILD_GIT_REF === undefined
|
||||||
|
? execSync("git rev-parse --short HEAD").toString().trim()
|
||||||
|
: process.env.BUILD_GIT_REF;
|
||||||
|
|
||||||
|
console.log(`Building Drop ${dropVersion} #${commitHash}`);
|
||||||
|
|
||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
@ -42,16 +56,17 @@ export default defineNuxtConfig({
|
|||||||
plugins: [tailwindcss()],
|
plugins: [tailwindcss()],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
runtimeConfig: {
|
||||||
|
gitRef: commitHash,
|
||||||
|
dropVersion: dropVersion,
|
||||||
|
},
|
||||||
|
|
||||||
app: {
|
app: {
|
||||||
head: {
|
head: {
|
||||||
link: [{ rel: "icon", href: "/favicon.ico" }],
|
link: [{ rel: "icon", href: "/favicon.ico" }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
appConfig: {
|
|
||||||
dropVersion: dropVersion,
|
|
||||||
},
|
|
||||||
|
|
||||||
routeRules: {
|
routeRules: {
|
||||||
"/api/**": { cors: true },
|
"/api/**": { cors: true },
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
|
import { systemConfig } from "~/server/internal/config/sys-conf";
|
||||||
|
|
||||||
export default defineEventHandler((_h3) => {
|
export default defineEventHandler((_h3) => {
|
||||||
return {
|
return {
|
||||||
appName: "Drop",
|
appName: "Drop",
|
||||||
|
version: systemConfig.getDropVersion(),
|
||||||
|
ref: systemConfig.getGitRef(),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,13 +1,23 @@
|
|||||||
class SystemConfig {
|
class SystemConfig {
|
||||||
private libraryFolder = process.env.LIBRARY ?? "./.data/library";
|
private libraryFolder = process.env.LIBRARY ?? "./.data/library";
|
||||||
private dataFolder = process.env.DATA ?? "./.data/data";
|
private dataFolder = process.env.DATA ?? "./.data/data";
|
||||||
private dropVersion = "v0.3.0";
|
|
||||||
|
private dropVersion;
|
||||||
|
private gitRef;
|
||||||
|
|
||||||
private checkForUpdates =
|
private checkForUpdates =
|
||||||
process.env.CHECK_FOR_UPDATES !== undefined &&
|
process.env.CHECK_FOR_UPDATES !== undefined &&
|
||||||
process.env.CHECK_FOR_UPDATES.toLocaleLowerCase() === "true"
|
process.env.CHECK_FOR_UPDATES.toLocaleLowerCase() === "true"
|
||||||
? true
|
? true
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
// get drop version and git ref from nuxt config
|
||||||
|
const config = useRuntimeConfig();
|
||||||
|
this.dropVersion = config.dropVersion;
|
||||||
|
this.gitRef = config.gitRef;
|
||||||
|
}
|
||||||
|
|
||||||
getLibraryFolder() {
|
getLibraryFolder() {
|
||||||
return this.libraryFolder;
|
return this.libraryFolder;
|
||||||
}
|
}
|
||||||
@ -20,6 +30,10 @@ class SystemConfig {
|
|||||||
return this.dropVersion;
|
return this.dropVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getGitRef() {
|
||||||
|
return this.gitRef;
|
||||||
|
}
|
||||||
|
|
||||||
shouldCheckForUpdates() {
|
shouldCheckForUpdates() {
|
||||||
return this.checkForUpdates;
|
return this.checkForUpdates;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user