mirror of
https://github.com/yan-istart/IStart-Note-AI-Plugin.git
synced 2026-07-22 06:51:37 +00:00
feat(build): append timestamp build number to dist version
Production builds now output version as '2.0.0+YYYYMMDDHHmm' in dist/manifest.json. Source manifest.json stays at '2.0.0'. This allows identifying exact builds without bumping the semver, useful during development and beta testing.
This commit is contained in:
parent
22dfb1becf
commit
80abd101b6
1 changed files with 20 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import esbuild from "esbuild";
|
||||
import process from "process";
|
||||
import { builtinModules } from "module";
|
||||
import { copyFileSync, mkdirSync } from "fs";
|
||||
import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
||||
|
||||
const banner = `/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
|
|
@ -42,8 +42,26 @@ const context = await esbuild.context({
|
|||
if (prod) {
|
||||
await context.rebuild();
|
||||
mkdirSync("dist", { recursive: true });
|
||||
copyFileSync("manifest.json", "dist/manifest.json");
|
||||
|
||||
// Generate build number: version+YYYYMMDDHHmm
|
||||
const manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
|
||||
const now = new Date();
|
||||
const buildStamp = [
|
||||
now.getFullYear(),
|
||||
String(now.getMonth() + 1).padStart(2, "0"),
|
||||
String(now.getDate()).padStart(2, "0"),
|
||||
String(now.getHours()).padStart(2, "0"),
|
||||
String(now.getMinutes()).padStart(2, "0"),
|
||||
].join("");
|
||||
const buildVersion = `${manifest.version}+${buildStamp}`;
|
||||
|
||||
// Write dist/manifest.json with build version
|
||||
const distManifest = { ...manifest, version: buildVersion };
|
||||
writeFileSync("dist/manifest.json", JSON.stringify(distManifest, null, 2) + "\n");
|
||||
|
||||
copyFileSync("styles.css", "dist/styles.css");
|
||||
|
||||
console.log(`Build complete: ${buildVersion}`);
|
||||
process.exit(0);
|
||||
} else {
|
||||
await context.watch();
|
||||
|
|
|
|||
Loading…
Reference in a new issue