From 777db8f57b65a36fa2749ab1e8acd6075a76b382 Mon Sep 17 00:00:00 2001 From: zhaojisen <1301338853@qq.com> Date: Mon, 15 Jun 2026 11:03:57 +0800 Subject: [PATCH] fix: client productor name --- scripts/set-product-name.mjs | 52 +++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/scripts/set-product-name.mjs b/scripts/set-product-name.mjs index d71697baf..51d9f59df 100644 --- a/scripts/set-product-name.mjs +++ b/scripts/set-product-name.mjs @@ -1,38 +1,46 @@ -import fs from 'node:fs' -import path from 'node:path' +import fs from 'node:fs'; +import path from 'node:path'; + +const DEFAULT_PRODUCT_NAME = 'JumpServerClient'; +const DEFAULT_PUBLISHER = 'jumpserver'; +const CUSTOM_PUBLISHER = 'sangfor'; function parseArgs(argv) { - const args = argv.slice(2) - let name + const args = argv.slice(2); + let name; for (let i = 0; i < args.length; i++) { - const a = args[i] + const a = args[i]; if (a === '--name' || a === '-n') { - name = args[i + 1] - i++ - continue + name = args[i + 1]; + i++; + continue; } if (a.startsWith('--name=')) { - name = a.slice('--name='.length) - continue + name = a.slice('--name='.length); + continue; } } - return { name } + return { name }; } -const { name: rawName } = parseArgs(process.argv) -const name = (rawName || process.env.CLIENT_NAME || '').trim() +const { name: rawName } = parseArgs(process.argv); +const name = (rawName || process.env.CLIENT_NAME || '').trim(); if (!name) { - console.error('Missing --name "" (or CLIENT_NAME).') - process.exit(2) + console.error('Missing --name "" (or CLIENT_NAME).'); + process.exit(2); } -const repoRoot = process.cwd() -const confPath = path.join(repoRoot, 'src-tauri', 'tauri.conf.json') -const conf = JSON.parse(fs.readFileSync(confPath, 'utf8')) - -conf.productName = name +const repoRoot = process.cwd(); +const confPath = path.join(repoRoot, 'src-tauri', 'tauri.conf.json'); +const conf = JSON.parse(fs.readFileSync(confPath, 'utf8')); -fs.writeFileSync(confPath, JSON.stringify(conf, null, 2) + '\n') -console.log(`Set src-tauri/tauri.conf.json productName to "${name}".`) +conf.productName = name; +// Windows uses bundle.publisher as the publisher shown in "Programs and Features". +// Keep the upstream publisher for JumpServerClient and use Sangfor for custom builds such as OSMClient. +conf.bundle.publisher = name === DEFAULT_PRODUCT_NAME ? DEFAULT_PUBLISHER : CUSTOM_PUBLISHER; +fs.writeFileSync(confPath, `${JSON.stringify(conf, null, 2)}\n`); +console.log( + `Set src-tauri/tauri.conf.json productName to "${name}" and publisher to "${conf.bundle.publisher}".` +);