chore(release): single-source app version + add pnpm bump
- WebUI sidebar/login display and OneBot get_version_info now read the root package.json version via Vite `define`, removing hardcoded literals in webui/src/types.ts and core/onebot/actions/info.ts. - tools/bump-version.mjs (exposed as `pnpm bump <ver>`) syncs the version field across the root and all five workspace packages. - Bump everything to 1.7.8.
This commit is contained in:
13 files changed
+79
-10
No files matched your search
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "snowluma-monorepo",
|
||||
"version": "0.1.0",
|
||||
"version": "1.7.8",
|
||||
"description": "SnowLuma monorepo workspace (pnpm)",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
@@ -16,7 +16,8 @@
|
||||
"test:watch": "pnpm --filter @snowluma/core test:watch",
|
||||
"typecheck": "pnpm -r --if-present typecheck",
|
||||
"lint": "pnpm -r --if-present lint",
|
||||
"start": "node dist/index.mjs"
|
||||
"start": "node dist/index.mjs",
|
||||
"bump": "node tools/bump-version.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^10.1.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@snowluma/core",
|
||||
"version": "0.1.0",
|
||||
"version": "1.7.8",
|
||||
"description": "SnowLuma core - NTQQ packet sniffer with Node.js native addon",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
Vendored
+1
@@ -1 +1,2 @@
|
||||
declare const __BUILD_WEBUI__: boolean;
|
||||
declare const __APP_VERSION__: string;
|
||||
@@ -12,10 +12,13 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
return okResponse({ online, good: online });
|
||||
});
|
||||
|
||||
// __APP_VERSION__ is injected by Vite from the monorepo root package.json;
|
||||
// it's undefined under vitest (no define plugin), so fall back to 'dev'.
|
||||
const appVersion = typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : 'dev';
|
||||
h.registerAction('get_version_info', async () => {
|
||||
return okResponse({
|
||||
app_name: 'SnowLuma',
|
||||
app_version: '0.1.0-node',
|
||||
app_version: `${appVersion}-node`,
|
||||
protocol_version: 'v11',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,6 +11,11 @@ const distDir = path.resolve(repoRoot, 'dist');
|
||||
const runtimeDir = path.resolve(repoRoot, 'packages', 'runtime');
|
||||
const nativeDir = path.resolve(runtimeDir, 'native');
|
||||
|
||||
// Single source of truth for the user-facing app version: monorepo root package.json.
|
||||
const rootPkg = JSON.parse(
|
||||
fs.readFileSync(path.resolve(repoRoot, 'package.json'), 'utf-8'),
|
||||
) as { version: string };
|
||||
|
||||
// vite-plugin-cp consumes globs through globby; on Windows we must use POSIX-style separators.
|
||||
const toPosix = (p: string) => p.replace(/\\/g, '/');
|
||||
|
||||
@@ -119,7 +124,8 @@ const BaseConfig = (source_map: boolean = false) => defineConfig({
|
||||
emptyOutDir: true
|
||||
},
|
||||
define: {
|
||||
__BUILD_WEBUI__: process.env.BUILD_WEBUI === 'true'
|
||||
__BUILD_WEBUI__: process.env.BUILD_WEBUI === 'true',
|
||||
__APP_VERSION__: JSON.stringify(rootPkg.version)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@snowluma/runtime",
|
||||
"version": "0.1.0",
|
||||
"version": "1.7.8",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "index.mjs",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "MotricSeven",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
"version": "0.1.0",
|
||||
"version": "1.7.8",
|
||||
"description": "TypeScript SDK for SnowLuma OneBot HTTP and WebSocket transports",
|
||||
"keywords": [
|
||||
"snowluma",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@snowluma/websocket",
|
||||
"version": "0.1.0",
|
||||
"version": "1.7.8",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "webui",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.7.8",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
declare const __APP_VERSION__: string;
|
||||
@@ -1,5 +1,6 @@
|
||||
export const APP_NAME = 'SnowLuma';
|
||||
export const APP_VERSION = '0.1.0';
|
||||
// Injected at build time by Vite from the monorepo root package.json.
|
||||
export const APP_VERSION = __APP_VERSION__;
|
||||
|
||||
export interface QQInfo {
|
||||
uin: string;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { defineConfig } from 'vite';
|
||||
@@ -6,6 +7,11 @@ import tailwindcss from '@tailwindcss/vite';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
// Single source of truth for the user-facing app version: monorepo root package.json.
|
||||
const rootPkg = JSON.parse(
|
||||
fs.readFileSync(path.resolve(__dirname, '../../package.json'), 'utf-8'),
|
||||
) as { version: string };
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [tailwindcss(), react()],
|
||||
resolve: {
|
||||
@@ -13,6 +19,9 @@ export default defineConfig({
|
||||
'@': path.resolve(__dirname, 'src'),
|
||||
},
|
||||
},
|
||||
define: {
|
||||
__APP_VERSION__: JSON.stringify(rootPkg.version),
|
||||
},
|
||||
server: {
|
||||
port: 5178,
|
||||
strictPort: false,
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env node
|
||||
// Sync the `version` field across the monorepo root and every workspace package.
|
||||
// Usage: pnpm bump <version> (e.g. pnpm bump 0.2.0)
|
||||
import { readFile, writeFile, readdir } from 'node:fs/promises';
|
||||
import { existsSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const repoRoot = path.resolve(__dirname, '..');
|
||||
|
||||
const nextVersion = process.argv[2];
|
||||
if (!nextVersion) {
|
||||
console.error('Usage: pnpm bump <version> (e.g. pnpm bump 0.2.0)');
|
||||
process.exit(1);
|
||||
}
|
||||
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(nextVersion)) {
|
||||
console.error(`Invalid semver: "${nextVersion}"`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
async function updatePkg(file) {
|
||||
const raw = await readFile(file, 'utf-8');
|
||||
const pkg = JSON.parse(raw);
|
||||
const prev = pkg.version;
|
||||
if (prev === nextVersion) {
|
||||
console.log(` = ${path.relative(repoRoot, file)} (already ${nextVersion})`);
|
||||
return;
|
||||
}
|
||||
pkg.version = nextVersion;
|
||||
// Preserve trailing newline if the original file had one.
|
||||
const trailing = raw.endsWith('\n') ? '\n' : '';
|
||||
await writeFile(file, JSON.stringify(pkg, null, 2) + trailing);
|
||||
console.log(` ✓ ${path.relative(repoRoot, file)}: ${prev} → ${nextVersion}`);
|
||||
}
|
||||
|
||||
const files = [path.join(repoRoot, 'package.json')];
|
||||
const packagesDir = path.join(repoRoot, 'packages');
|
||||
for (const entry of await readdir(packagesDir, { withFileTypes: true })) {
|
||||
if (!entry.isDirectory()) continue;
|
||||
const pkgFile = path.join(packagesDir, entry.name, 'package.json');
|
||||
if (existsSync(pkgFile)) files.push(pkgFile);
|
||||
}
|
||||
|
||||
console.log(`Bumping ${files.length} package.json files to ${nextVersion}:`);
|
||||
for (const file of files) await updatePkg(file);
|
||||
console.log('Done.');
|
||||
Reference in new issue
Block a user