b7862288d0
Project CI / AI game creator shell Rust crates (push) Successful in 1m31s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m1s
Project CI / Backend tests (push) Successful in 4m0s
Project CI / Frontend tests (push) Successful in 2m3s
Project CI / Native shell tests (push) Successful in 6m16s
Project CI / AI game creator shell Rust lane 2/2 (push) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (push) Has been cancelled
Project CI / Repository checks (push) Has been cancelled
Project CI / AI game creator shell web tests (push) Has been cancelled
- release 渠道复用正式产品名陶泥儿,安装包与更新归档不再包含 Release 文本。 - 保留 release identifier 与 release-win/release-mac 更新分区,更新渠道身份回归测试。 - 同步客户端发布、运维与项目记忆文档。
78 lines
2.7 KiB
JavaScript
78 lines
2.7 KiB
JavaScript
/**
|
||
* AGC 渠道 → 安装身份。
|
||
*
|
||
* 渠道同时决定两件事:
|
||
* - 更新端点:OSS 分区 `<channel>-win` / `<channel>-mac` 的清单地址;
|
||
* - 安装身份:`productName` 与 `identifier`。
|
||
*
|
||
* 安装身份决定 Windows 安装目录与卸载项、macOS `.app` 名字与 bundle id、
|
||
* Windows WebView2 数据目录以及 `%APPDATA%\<identifier>` 客户端数据目录。
|
||
* 因此不同渠道的包体在同一台设备上并存时互不顶掉,也不会共享登录态、
|
||
* 本地项目与运行锁。
|
||
*
|
||
* 默认渠道 `dev` 保持已发布客户端标识不变:升级链路与既有安装不能断;展示名显式标记为开发版。
|
||
*/
|
||
|
||
export const AGC_DEFAULT_CHANNEL = 'dev';
|
||
export const AGC_PRODUCT_NAME = '陶泥儿';
|
||
export const AGC_APP_IDENTIFIER = 'world.genarrative.ai-game-creator';
|
||
|
||
const reservedChannelNames = new Set([
|
||
'win',
|
||
'mac',
|
||
'windows',
|
||
'macos',
|
||
'darwin',
|
||
'linux',
|
||
]);
|
||
|
||
/** 校验渠道名:小写字母开头,允许数字与连字符,系统名不属于渠道。 */
|
||
export function validateReleaseChannel(channel) {
|
||
if (
|
||
typeof channel !== 'string' ||
|
||
!/^[a-z][a-z0-9-]{0,31}$/u.test(channel) ||
|
||
channel.endsWith('-') ||
|
||
reservedChannelNames.has(channel) ||
|
||
/-(win|mac)$/u.test(channel)
|
||
) {
|
||
throw new Error(
|
||
'发布渠道无效:请使用 dev、release 或最多 32 位的小写字母、数字和连字符名称,系统名称不属于渠道',
|
||
);
|
||
}
|
||
return channel;
|
||
}
|
||
|
||
export function resolveReleaseChannel(env = process.env) {
|
||
return validateReleaseChannel(env.AGC_UPDATE_CHANNEL?.trim() ?? 'dev');
|
||
}
|
||
|
||
/** 安装身份里的展示后缀:`dev` → `开发版`,`beta-2` → `Beta-2`;release 复用正式产品名。 */
|
||
export function channelDisplaySuffix(channel) {
|
||
if (channel === AGC_DEFAULT_CHANNEL) return '开发版';
|
||
return validateReleaseChannel(channel)
|
||
.split('-')
|
||
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
|
||
.join('-');
|
||
}
|
||
|
||
/**
|
||
* 渠道对应的安装身份。默认渠道保持既有 identifier 以兼容已安装客户端,
|
||
* 但展示名明确标记为开发版;release 复用正式产品名,其它渠道带展示后缀;
|
||
* 所有非默认渠道都派生独立 identifier,保证同一台设备上并存。
|
||
*/
|
||
export function resolveChannelInstallIdentity(channel = AGC_DEFAULT_CHANNEL) {
|
||
validateReleaseChannel(channel);
|
||
return Object.freeze({
|
||
productName:
|
||
channel === AGC_DEFAULT_CHANNEL
|
||
? `${AGC_PRODUCT_NAME}开发版`
|
||
: channel === 'release'
|
||
? AGC_PRODUCT_NAME
|
||
: `${AGC_PRODUCT_NAME} ${channelDisplaySuffix(channel)}`,
|
||
identifier:
|
||
channel === AGC_DEFAULT_CHANNEL
|
||
? AGC_APP_IDENTIFIER
|
||
: `${AGC_APP_IDENTIFIER}.${channel}`,
|
||
});
|
||
}
|