mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-12 06:33:22 +08:00
chore: output version to version.json
This commit is contained in:
parent
c1bd66a82c
commit
0b3e3d9a32
3 changed files with 23 additions and 1 deletions
|
@ -103,6 +103,15 @@
|
|||
"value": "no-cache, no-store, must-revalidate"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"source": "/version.json",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Cache-Control",
|
||||
"value": "no-cache, no-store, must-revalidate"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
1
frontend/static/version.json
Normal file
1
frontend/static/version.json
Normal file
|
@ -0,0 +1 @@
|
|||
{ "version": "DEVELOPMENT_CLIENT" }
|
|
@ -7,6 +7,7 @@ import path from "node:path";
|
|||
import { splitVendorChunkPlugin } from "vite";
|
||||
import childProcess from "child_process";
|
||||
import { checker } from "vite-plugin-checker";
|
||||
import { writeFileSync } from "fs";
|
||||
|
||||
function pad(numbers, maxLength, fillString) {
|
||||
return numbers.map((number) =>
|
||||
|
@ -31,7 +32,7 @@ function buildClientVersion() {
|
|||
.execSync("git rev-parse --short HEAD")
|
||||
.toString();
|
||||
|
||||
return `${version}.${commitHash}`;
|
||||
return `${version}.${commitHash}`.replace(/\n/g, "");
|
||||
} catch (e) {
|
||||
return `${version}.unknown-hash`;
|
||||
}
|
||||
|
@ -57,6 +58,17 @@ export default {
|
|||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "generate-version-json",
|
||||
apply: "build",
|
||||
|
||||
closeBundle() {
|
||||
const version = buildClientVersion();
|
||||
const versionJson = JSON.stringify({ version });
|
||||
const versionPath = path.resolve(__dirname, "dist/version.json");
|
||||
writeFileSync(versionPath, versionJson);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "vite-plugin-webfonts-preview",
|
||||
apply: "build",
|
||||
|
|
Loading…
Reference in a new issue