fix: stamp build commit metadata
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
Docs: https://docs.clawd.bot
|
||||
|
||||
## 2026.1.16-2
|
||||
|
||||
### Changes
|
||||
- CLI: stamp build commit into dist metadata so banners show the commit in npm installs.
|
||||
|
||||
## 2026.1.16-1
|
||||
|
||||
### Highlights
|
||||
@@ -9,7 +14,7 @@ Docs: https://docs.clawd.bot
|
||||
- Media: add inbound media understanding (image/audio/video) with provider + CLI fallbacks. https://docs.clawd.bot/nodes/media-understanding
|
||||
- Plugins: add Zalo Personal plugin (`@clawdbot/zalouser`) and unify channel directory for plugins. (#1032) — thanks @suminhthanh. https://docs.clawd.bot/plugins/zalouser
|
||||
- Models: add Vercel AI Gateway auth choice + onboarding updates. (#1016) — thanks @timolins. https://docs.clawd.bot/providers/vercel-ai-gateway
|
||||
- Sessions: add `session.identityLinks` for cross-platform DM session linking. (#1033) — thanks @thewilloftheshadow. https://docs.clawd.bot/concepts/session
|
||||
- Sessions: add `session.identityLinks` for cross-platform DM session li nking. (#1033) — thanks @thewilloftheshadow. https://docs.clawd.bot/concepts/session
|
||||
- Web search: add `country`/`language` parameters (schema + Brave API) and docs. (#1046) — thanks @YuriNachos. https://docs.clawd.bot/tools/web
|
||||
|
||||
### Breaking
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clawdbot",
|
||||
"version": "2026.1.16-1",
|
||||
"version": "2026.1.16-2",
|
||||
"description": "WhatsApp gateway CLI (Baileys web) with Pi RPC agent",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
@@ -66,7 +66,7 @@
|
||||
"docs:bin": "bun build scripts/docs-list.ts --compile --outfile bin/docs-list",
|
||||
"docs:dev": "cd docs && mint dev",
|
||||
"docs:build": "cd docs && pnpm dlx --reporter append-only mint broken-links",
|
||||
"build": "tsc -p tsconfig.json && tsx scripts/canvas-a2ui-copy.ts && tsx scripts/copy-hook-metadata.ts",
|
||||
"build": "tsc -p tsconfig.json && tsx scripts/canvas-a2ui-copy.ts && tsx scripts/copy-hook-metadata.ts && tsx scripts/write-build-info.ts",
|
||||
"plugins:sync": "tsx scripts/sync-plugin-versions.ts",
|
||||
"release:check": "tsx scripts/release-check.ts",
|
||||
"ui:install": "node scripts/ui.js install",
|
||||
|
||||
48
scripts/write-build-info.ts
Normal file
48
scripts/write-build-info.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { execSync } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const distDir = path.join(rootDir, "dist");
|
||||
const pkgPath = path.join(rootDir, "package.json");
|
||||
|
||||
const readPackageVersion = () => {
|
||||
try {
|
||||
const raw = fs.readFileSync(pkgPath, "utf8");
|
||||
const parsed = JSON.parse(raw) as { version?: string };
|
||||
return parsed.version ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const resolveCommit = () => {
|
||||
const envCommit = process.env.GIT_COMMIT?.trim() || process.env.GIT_SHA?.trim();
|
||||
if (envCommit) return envCommit;
|
||||
try {
|
||||
return execSync("git rev-parse HEAD", {
|
||||
cwd: rootDir,
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
})
|
||||
.toString()
|
||||
.trim();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const version = readPackageVersion();
|
||||
const commit = resolveCommit();
|
||||
|
||||
const buildInfo = {
|
||||
version,
|
||||
commit,
|
||||
builtAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
fs.mkdirSync(distDir, { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(distDir, "build-info.json"),
|
||||
`${JSON.stringify(buildInfo, null, 2)}\n`,
|
||||
);
|
||||
@@ -51,6 +51,18 @@ const readCommitFromPackageJson = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const readCommitFromBuildInfo = () => {
|
||||
try {
|
||||
const require = createRequire(import.meta.url);
|
||||
const info = require("../build-info.json") as {
|
||||
commit?: string | null;
|
||||
};
|
||||
return formatCommit(info.commit ?? null);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export const resolveCommitHash = (options: { cwd?: string; env?: NodeJS.ProcessEnv } = {}) => {
|
||||
if (cachedCommit !== undefined) return cachedCommit;
|
||||
const env = options.env ?? process.env;
|
||||
@@ -60,6 +72,11 @@ export const resolveCommitHash = (options: { cwd?: string; env?: NodeJS.ProcessE
|
||||
cachedCommit = normalized;
|
||||
return cachedCommit;
|
||||
}
|
||||
const buildInfoCommit = readCommitFromBuildInfo();
|
||||
if (buildInfoCommit) {
|
||||
cachedCommit = buildInfoCommit;
|
||||
return cachedCommit;
|
||||
}
|
||||
const pkgCommit = readCommitFromPackageJson();
|
||||
if (pkgCommit) {
|
||||
cachedCommit = pkgCommit;
|
||||
|
||||
Reference in New Issue
Block a user