mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-28 15:25:27 +08:00
Publish branch server bundles for thin desktop builds
This commit is contained in:
@@ -180,6 +180,20 @@ async function pathExists(filePath) {
|
||||
}
|
||||
}
|
||||
|
||||
async function readServerBundleConfig(appRoot) {
|
||||
try {
|
||||
const raw = await fs.readFile(path.join(appRoot, 'electron', 'server-bundle-config.json'), 'utf8');
|
||||
const config = JSON.parse(raw);
|
||||
return {
|
||||
releaseTag: typeof config.releaseTag === 'string' && config.releaseTag.trim()
|
||||
? config.releaseTag.trim()
|
||||
: '',
|
||||
};
|
||||
} catch {
|
||||
return { releaseTag: '' };
|
||||
}
|
||||
}
|
||||
|
||||
function getServerCwd(appRoot, serverEntry) {
|
||||
const normalizedEntry = path.resolve(serverEntry);
|
||||
const bundledEntry = path.resolve(appRoot, 'dist-server', 'server', 'index.js');
|
||||
@@ -371,8 +385,10 @@ export class LocalServerController {
|
||||
if (!this.appVersion) {
|
||||
throw new Error('Cannot install local server: app version is unknown.');
|
||||
}
|
||||
const bundleConfig = await readServerBundleConfig(this.appRoot);
|
||||
const installer = new ServerInstaller({
|
||||
version: this.appVersion,
|
||||
bundleReleaseTag: bundleConfig.releaseTag,
|
||||
onLog: (line) => this.appendStartupLog(line),
|
||||
});
|
||||
return installer.ensureInstalled();
|
||||
|
||||
@@ -35,6 +35,7 @@ export class ServerInstaller {
|
||||
arch = process.arch,
|
||||
installRoot = process.env.CLOUDCLI_SERVER_DIR || DEFAULT_INSTALL_ROOT,
|
||||
bundleBaseUrl = process.env.CLOUDCLI_SERVER_BUNDLE_URL || DEFAULT_BUNDLE_BASE_URL,
|
||||
bundleReleaseTag = process.env.CLOUDCLI_SERVER_BUNDLE_RELEASE_TAG || '',
|
||||
onLog,
|
||||
} = {}) {
|
||||
if (!version) throw new Error('ServerInstaller requires the app version');
|
||||
@@ -43,6 +44,7 @@ export class ServerInstaller {
|
||||
this.arch = mapArch(arch);
|
||||
this.installRoot = installRoot;
|
||||
this.bundleBaseUrl = bundleBaseUrl.replace(/\/+$/, '');
|
||||
this.bundleReleaseTag = bundleReleaseTag || `v${this.version}`;
|
||||
this.onLog = typeof onLog === 'function' ? onLog : () => {};
|
||||
}
|
||||
|
||||
@@ -61,7 +63,7 @@ export class ServerInstaller {
|
||||
}
|
||||
|
||||
getBundleUrl() {
|
||||
const url = new URL(`${this.bundleBaseUrl}/v${this.version}/${this.getBundleName()}`);
|
||||
const url = new URL(`${this.bundleBaseUrl}/${this.bundleReleaseTag}/${this.getBundleName()}`);
|
||||
if (url.protocol !== 'https:' && !(url.protocol === 'http:' && LOCAL_DOWNLOAD_HOSTS.has(url.hostname))) {
|
||||
throw new Error(`Refusing unsupported server bundle URL: ${url.toString()}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user