mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-08-04 05:40:58 +00:00
73 lines
2 KiB
TypeScript
73 lines
2 KiB
TypeScript
import { readFileSync, writeFileSync } from 'fs';
|
|
import { join } from 'path';
|
|
import yaml from 'js-yaml';
|
|
|
|
import { BRAND } from '../packages/shared/src/branding.ts';
|
|
|
|
type MutableRecord = Record<string, unknown>;
|
|
|
|
function section(config: MutableRecord, key: string): MutableRecord {
|
|
const existing = config[key];
|
|
if (
|
|
existing &&
|
|
typeof existing === 'object' &&
|
|
!Array.isArray(existing)
|
|
) {
|
|
return existing as MutableRecord;
|
|
}
|
|
|
|
const next: MutableRecord = {};
|
|
config[key] = next;
|
|
return next;
|
|
}
|
|
|
|
const electronDir = join(process.cwd(), 'apps', 'electron');
|
|
const inputPath = join(electronDir, 'electron-builder.yml');
|
|
const outputPath = join(electronDir, 'electron-builder.generated.yml');
|
|
const config = yaml.load(readFileSync(inputPath, 'utf8')) as MutableRecord;
|
|
const artifactName = `${BRAND.artifactPrefix}-\${arch}.\${ext}`;
|
|
|
|
config.appId = BRAND.appId;
|
|
config.productName = BRAND.productName;
|
|
config.copyright = BRAND.copyright;
|
|
|
|
const extraMetadata = section(config, 'extraMetadata');
|
|
extraMetadata.main = 'dist/main.cjs';
|
|
extraMetadata.name = BRAND.artifactPrefix.toLowerCase();
|
|
|
|
const mac = section(config, 'mac');
|
|
mac.icon = BRAND.assets.macIcon;
|
|
mac.artifactName = artifactName;
|
|
|
|
const dmg = section(config, 'dmg');
|
|
dmg.artifactName = `${BRAND.artifactPrefix}-\${arch}.dmg`;
|
|
dmg.icon = BRAND.assets.macIcon;
|
|
dmg.title = BRAND.productName;
|
|
|
|
const win = section(config, 'win');
|
|
win.icon = BRAND.assets.winIcon;
|
|
win.artifactName = artifactName;
|
|
|
|
const linux = section(config, 'linux');
|
|
linux.icon = BRAND.assets.linuxIcon;
|
|
linux.artifactName = artifactName;
|
|
|
|
if (BRAND.updates) {
|
|
if (BRAND.updates.provider === 'github') {
|
|
config.publish = {
|
|
provider: BRAND.updates.provider,
|
|
owner: BRAND.updates.owner,
|
|
repo: BRAND.updates.repo,
|
|
};
|
|
} else {
|
|
config.publish = {
|
|
provider: BRAND.updates.provider,
|
|
url: BRAND.updates.url,
|
|
};
|
|
}
|
|
} else {
|
|
delete config.publish;
|
|
}
|
|
|
|
writeFileSync(outputPath, yaml.dump(config, { lineWidth: -1 }));
|
|
console.log(`Generated ${outputPath} for ${BRAND.id}`);
|