AndroidStation(原中控改造为纯设备端) - 只做三件事:UDP 48899 被桌面端发现、TCP 8087 推送 USB 扫码结果、离线语音播报 - 扫码不再经过 UI:去掉逐键重绘,50ms 自动提交,同一码重复扫码也一律上报 - 离线语音种子(数字/字母/“开始打包”/欢迎语)随包安装,MediaPlayer 播放,启动把音量拉满 - 启动播报「欢迎使用溯源系统,初始化已经完成,扫码即可开始打包」 - 移除 Device Owner / 设备管理员 / lock task / 网络与 IP 设置等非普通应用能力(仅保留开机自启) - 正式签名 keystore + release 签名配置,versionName/versionCode 可由打包脚本覆盖 发布脚手架 - backend/android_client:Android 正式包构建(build.ps1 + package.config.json) - backend/scripts/deploy/publish-android.cjs + npm run android:build / android:publish - 桌面端安装包改为 download/desktop,Android 为 download/android_client; version.json 仍走 /download/version.json(老客户端写死),新增 /download/android_client/version.json - 谷歌插件随桌面端 MSI 安装到 <安装目录>\extension,工具菜单新增「复制谷歌插件地址」 - git-safety-check 增加仓库级禁区(keystore.properties / *.jks / local.properties) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
90 lines
2.3 KiB
JavaScript
90 lines
2.3 KiB
JavaScript
'use strict';
|
|
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const { ROOT, runCommand } = require('./deploy-lib.cjs');
|
|
|
|
const VERSION_DIR = path.join(ROOT, 'versioning');
|
|
const VERSION_HISTORY_FILE = path.join(VERSION_DIR, 'package-version-history.jsonl');
|
|
const VERSION_CURRENT_FILE = path.join(VERSION_DIR, 'package-version-current.json');
|
|
|
|
function ensureVersionDir() {
|
|
fs.mkdirSync(VERSION_DIR, { recursive: true });
|
|
}
|
|
|
|
function getPackageMeta() {
|
|
const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8'));
|
|
const packageVersion = String(pkg.version || '0.0.0');
|
|
|
|
let gitCommit = '';
|
|
let gitCommitShort = '';
|
|
let gitBranch = '';
|
|
try {
|
|
gitCommit = runCommand('git', [ 'rev-parse', 'HEAD' ]);
|
|
gitCommitShort = runCommand('git', [ 'rev-parse', '--short', 'HEAD' ]);
|
|
gitBranch = runCommand('git', [ 'rev-parse', '--abbrev-ref', 'HEAD' ]);
|
|
} catch (error) {
|
|
gitCommit = '';
|
|
gitCommitShort = '';
|
|
gitBranch = '';
|
|
}
|
|
|
|
return {
|
|
packageVersion,
|
|
gitCommit,
|
|
gitCommitShort,
|
|
gitBranch,
|
|
};
|
|
}
|
|
|
|
function recordVersionUpdate(options = {}) {
|
|
ensureVersionDir();
|
|
|
|
const meta = getPackageMeta();
|
|
const entry = {
|
|
recordedAt: new Date().toISOString(),
|
|
source: options.source || 'manual',
|
|
note: options.note || '',
|
|
packageVersion: meta.packageVersion,
|
|
gitCommit: meta.gitCommit,
|
|
gitCommitShort: meta.gitCommitShort,
|
|
gitBranch: meta.gitBranch,
|
|
releaseVersion: options.releaseVersion || '',
|
|
deployRoot: options.deployRoot || '',
|
|
};
|
|
|
|
fs.appendFileSync(VERSION_HISTORY_FILE, `${JSON.stringify(entry)}\n`, 'utf8');
|
|
fs.writeFileSync(VERSION_CURRENT_FILE, `${JSON.stringify(entry, null, 2)}\n`, 'utf8');
|
|
return entry;
|
|
}
|
|
|
|
function readVersionHistory(limit = 20) {
|
|
if (!fs.existsSync(VERSION_HISTORY_FILE)) {
|
|
return [];
|
|
}
|
|
|
|
const lines = fs.readFileSync(VERSION_HISTORY_FILE, 'utf8')
|
|
.split(/\r?\n/)
|
|
.map(item => item.trim())
|
|
.filter(Boolean);
|
|
|
|
const take = Math.max(1, Number(limit || 20));
|
|
const records = [];
|
|
for (const line of lines.slice(-take)) {
|
|
try {
|
|
records.push(JSON.parse(line));
|
|
} catch (error) {
|
|
records.push({ raw: line });
|
|
}
|
|
}
|
|
return records;
|
|
}
|
|
|
|
module.exports = {
|
|
VERSION_CURRENT_FILE,
|
|
VERSION_DIR,
|
|
VERSION_HISTORY_FILE,
|
|
readVersionHistory,
|
|
recordVersionUpdate,
|
|
};
|