mirror of
https://github.com/PR0M3TH3AN/bitgate.git
synced 2026-10-27 08:31:00 +00:00
Widget styles now prefer --bitgate-* custom properties, falling back to the deprecated --gov-* names and then the existing defaults so current pages and overrides keep working. Browser bundles and ESM entry points expose VERSION (and window.bitgate.version) from package.json. Document allowlist on the widget policy preset list. Sync the lockfile so npm ci sees @bitgate/standalone. Co-authored-by: thePR0M3TH3AN <[email protected]>
31 lines
913 B
JavaScript
31 lines
913 B
JavaScript
/**
|
|
* esbuild plugin: replace `@bitgate/core`'s version module with the value from
|
|
* package.json so browser bundles cannot drift from the package.
|
|
*/
|
|
import { readFileSync } from "node:fs";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
|
|
/** @returns {string} */
|
|
export function readLibraryVersion() {
|
|
return JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8")).version;
|
|
}
|
|
|
|
/**
|
|
* @param {string} [injected]
|
|
* @returns {import("esbuild").Plugin}
|
|
*/
|
|
export function bitgateVersionPlugin(injected = readLibraryVersion()) {
|
|
return {
|
|
name: "bitgate-version",
|
|
setup(pluginBuild) {
|
|
pluginBuild.onLoad({ filter: /[/\\]core[/\\]src[/\\]version\.js$/ }, () => ({
|
|
contents: `export const VERSION = ${JSON.stringify(injected)};\n`,
|
|
loader: "js",
|
|
}));
|
|
},
|
|
};
|
|
}
|