Files
lobe-chat/scripts/electronWorkflow/setDesktopVersion.ts
T
Innei fcdaf9d814 🔧 chore: update eslint v2 configuration and suppressions (#12133)
* v2 init

* chore: update eslint suppressions and package dependencies

- Removed several eslint suppressions related to array sorting and reversing from eslint-suppressions.json to clean up the configuration.
- Updated @lobehub/lint package version from 2.0.0-beta.6 to 2.0.0-beta.7 in package.json for improvements and bug fixes.
- Made minor formatting adjustments in vitest.config.mts and various SKILL.md files for better readability and consistency.

Signed-off-by: Innei <tukon479@gmail.com>

* fix: clean up import statements and formatting

- Removed unnecessary whitespace in replaceComponentImports.ts for improved readability.
- Standardized import statements in contextEngineering.ts and createAgentExecutors.ts by adding missing spaces for consistency.

Signed-off-by: Innei <tukon479@gmail.com>

* chore: update eslint suppressions and clean up code formatting

* 🐛 fix: use vi.hoisted for mock variable initialization

Fix TDZ error in persona service test by using vi.hoisted() to ensure
mock variables are available when vi.mock factory runs.

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-02-11 13:04:48 +08:00

114 lines
3.5 KiB
TypeScript

import path from 'node:path';
import fs from 'fs-extra';
type ReleaseType = 'stable' | 'beta' | 'nightly';
// 获取脚本的命令行参数
const version = process.argv[2];
const releaseType = process.argv[3] as ReleaseType;
// 验证参数
if (!version || !releaseType) {
console.error(
'Missing parameters. Usage: bun run setDesktopVersion.ts <version> <stable|beta|nightly>',
);
process.exit(1);
}
if (!['stable', 'beta', 'nightly'].includes(releaseType)) {
console.error(
`Invalid release type: ${releaseType}. Must be one of 'stable', 'beta', 'nightly'.`,
);
process.exit(1);
}
// 获取根目录
const rootDir = path.resolve(__dirname, '../..');
// 桌面应用 package.json 的路径
const desktopPackageJsonPath = path.join(rootDir, 'apps/desktop/package.json');
const buildDir = path.join(rootDir, 'apps/desktop/build');
// 更新应用图标
function updateAppIcon(type: 'beta' | 'nightly') {
console.log(`📦 Updating app icon for ${type} version...`);
try {
const iconSuffix = type === 'beta' ? 'beta' : 'nightly';
const iconMappings = [
{ ext: '.png', source: `icon-${iconSuffix}.png`, target: 'icon.png' },
{ ext: '.icns', source: `Icon-${iconSuffix}.icns`, target: 'Icon.icns' },
{ ext: '.ico', source: `icon-${iconSuffix}.ico`, target: 'icon.ico' },
];
for (const mapping of iconMappings) {
const sourceFile = path.join(buildDir, mapping.source);
const targetFile = path.join(buildDir, mapping.target);
if (fs.existsSync(sourceFile)) {
if (sourceFile !== targetFile) {
fs.copyFileSync(sourceFile, targetFile);
console.log(` ✅ Copied ${mapping.source} to ${mapping.target}`);
}
} else {
console.warn(` ⚠️ Warning: Source icon not found: ${sourceFile}`);
}
}
} catch (error) {
console.error(' ❌ Error updating icons:', error);
// 不终止程序,继续处理 package.json
}
}
function updatePackageJson() {
console.log(`⚙️ Updating ${desktopPackageJsonPath} for ${releaseType} version ${version}...`);
try {
if (!fs.existsSync(desktopPackageJsonPath)) {
console.error(`❌ Error: File not found ${desktopPackageJsonPath}`);
process.exit(1);
}
const packageJson = fs.readJSONSync(desktopPackageJsonPath);
// 始终更新版本号
packageJson.version = version;
// 根据 releaseType 修改其他字段
switch (releaseType) {
case 'stable': {
packageJson.productName = 'LobeHub';
packageJson.name = 'lobehub-desktop';
console.log('🌟 Setting as Stable version.');
break;
}
case 'beta': {
packageJson.productName = 'LobeHub-Beta'; // Or 'LobeHub-Beta' if preferred
packageJson.name = 'lobehub-desktop-beta'; // Or 'lobehub-desktop' if preferred
console.log('🧪 Setting as Beta version.');
updateAppIcon('beta');
break;
}
case 'nightly': {
packageJson.productName = 'LobeHub-Nightly'; // Or 'LobeHub-Nightly'
packageJson.name = 'lobehub-desktop-nightly'; // Or 'lobehub-desktop-nightly'
console.log('🌙 Setting as Nightly version.');
updateAppIcon('nightly');
break;
}
}
// 写回文件
fs.writeJsonSync(desktopPackageJsonPath, packageJson, { spaces: 2 });
console.log(
`✅ Desktop app package.json updated successfully for ${releaseType} version ${version}.`,
);
} catch (error) {
console.error('❌ Error updating package.json:', error);
process.exit(1);
}
}
// 执行更新
updatePackageJson();