fix(update): 修复云端安装交接并完善发布验收
修复隐藏缓存目录下载和响应收尾,使用原生助手校验安装包并确认交接。 补齐真实静默升级、便携版及中文路径验收,并按现行设备和科目授权契约更新回归。 服务端安装时生成独立密钥,覆盖升级保留既有配置;补齐安装包副本验证说明。
This commit is contained in:
1 parent
66be3a63b1
commit
71cc8eb605
19 files changed
+1424
-91
No files matched your search
@@ -0,0 +1,32 @@
|
||||
/** 首次安装生成独立密钥;覆盖升级不改变已有配置。 */
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const crypto = require('node:crypto');
|
||||
const MARKER = 'CLASSHELPER_GENERATE_SECRET_ON_INSTALL';
|
||||
function initialiseEnvironment(file = path.join(__dirname, '.env')) {
|
||||
const content = fs.readFileSync(file, 'utf8');
|
||||
const line = /^JWT_SECRET=CLASSHELPER_GENERATE_SECRET_ON_INSTALL\r?$/m;
|
||||
if (!line.test(content)) return false;
|
||||
const value = crypto.randomBytes(48).toString('hex');
|
||||
const temporary = file + '.initialising-' + crypto.randomUUID();
|
||||
try {
|
||||
fs.writeFileSync(temporary, content.replace(line, 'JWT_SECRET=' + value), {
|
||||
encoding: 'utf8',
|
||||
mode: 0o600,
|
||||
flag: 'wx',
|
||||
});
|
||||
fs.renameSync(temporary, file);
|
||||
} finally {
|
||||
fs.rmSync(temporary, { force: true });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
module.exports = { initialiseEnvironment, MARKER };
|
||||
if (require.main === module) {
|
||||
try {
|
||||
initialiseEnvironment();
|
||||
} catch (error) {
|
||||
console.error('服务端配置初始化失败:' + error.message);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user