Skip to content

Commit 860e7cd

Browse files
author
linyuan.yang
committed
修改 bundle id
1 parent 87fd568 commit 860e7cd

6 files changed

Lines changed: 128 additions & 32 deletions

File tree

‎packages/app/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "module",
55
"scripts": {
66
"dev": "tauri dev",
7-
"dev:frontend": "npx kill-port 5181 && vite",
7+
"dev:frontend": "npx kill-port 1801 && vite",
88
"build": "tauri build",
99
"build:frontend": "vue-tsc -b --force && vite build",
1010
"tauri": "tauri",

‎packages/app/src-tauri/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "app"
33
version = "0.1.0"
44
description = "A Tauri App"
5-
authors = ["you"]
5+
authors = ["while"]
66
license = ""
77
repository = ""
88
edition = "2021"

‎packages/app/src-tauri/tauri.conf.json‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "nes-emulator",
44
"version": "../../../package.json",
5-
"identifier": "com.wandergame.nesemulator",
5+
"identifier": "com.while.nesemulator",
66
"build": {
77
"frontendDist": "../dist",
8-
"devUrl": "http://localhost:5181",
8+
"devUrl": "http://localhost:1801",
99
"beforeDevCommand": "npm run dev:frontend",
1010
"beforeBuildCommand": "npm run build:frontend"
1111
},
@@ -25,15 +25,23 @@
2525
},
2626
"bundle": {
2727
"active": true,
28+
"publisher": "while",
2829
"createUpdaterArtifacts": true,
29-
"targets": "all",
30+
"targets": ["nsis", "app", "dmg", "deb", "appimage"],
3031
"icon": [
3132
"icons/32x32.png",
3233
"icons/128x128.png",
3334
"icons/128x128@2x.png",
3435
"icons/icon.icns",
3536
"icons/icon.ico"
3637
],
38+
"windows": {
39+
"nsis": {
40+
"installMode": "both",
41+
"languages": ["SimpChinese", "English", "TradChinese"],
42+
"displayLanguageSelector": true
43+
}
44+
},
3745
"android": {
3846
"debugApplicationIdSuffix": ".debug"
3947
}

‎packages/app/vite.config.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ export default defineConfig({
1010
base: './',
1111
server: {
1212
host: host || false,
13-
port: 5181,
13+
port: 1801,
1414
strictPort: true,
1515
hmr: host
1616
? {
1717
protocol: 'ws',
1818
host,
19-
port: 5182,
19+
port: 1802,
2020
}
2121
: undefined,
2222
},

‎packages/web/vite.config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default defineConfig({
4444
// GitHub Pages 子路径部署需要相对资源路径。
4545
base: './',
4646
server: {
47-
port: 5180,
47+
port: 1800,
4848
strictPort: true,
4949
},
5050
build: {

‎scripts/release.cjs‎

Lines changed: 112 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
#!/usr/bin/env node
2+
/**
3+
* 一键发版:打印摘要 → 二次确认 → bump 版本 → commit → (tag 已存在时确认清理) → 打 tag → 推送。
4+
* 推送 tag 后触发 "Release App" workflow,由 GitHub Actions 完成构建与发布。
5+
*
6+
* 确认规则(参考 wmdebugger/scripts/release.js):
7+
* - tag 已存在(本地或远程):y/N 确认后删除旧 tag 再重打并推送
8+
* - tag 不存在:回车确认发版,Ctrl+C 取消
9+
*
10+
* 用法:
11+
* npm run release # 用当前版本,tag & push
12+
* npm run release patch # bump patch
13+
* npm run release minor|major
14+
* npm run release 0.2.0 # 指定版本号
15+
*/
216
const { execSync } = require('child_process');
17+
const readline = require('readline');
318
const path = require('path');
419
const fs = require('fs');
520

@@ -24,7 +39,11 @@ function run(cmd, opts = {}) {
2439
return execSync(cmd, { stdio: 'inherit', ...opts });
2540
}
2641

27-
function commandSucceeds(cmd) {
42+
function sh(cmd) {
43+
return execSync(cmd, { encoding: 'utf8' }).trim();
44+
}
45+
46+
function ok(cmd) {
2847
try {
2948
execSync(cmd, { stdio: 'ignore' });
3049
return true;
@@ -49,15 +68,22 @@ function bumpVersion(version, type) {
4968
}
5069

5170
function isWorkingTreeClean() {
52-
return execSync('git status --porcelain', { encoding: 'utf8' }).trim().length === 0;
71+
return sh('git status --porcelain').length === 0;
5372
}
5473

5574
function tagExists(tag) {
56-
return commandSucceeds(`git rev-parse -q --verify "refs/tags/${tag}"`);
75+
return ok(`git rev-parse -q --verify "refs/tags/${tag}"`);
5776
}
5877

5978
function remoteTagExists(tag) {
60-
return commandSucceeds(`git ls-remote --exit-code origin "refs/tags/${tag}"`);
79+
try {
80+
execSync(`git ls-remote --exit-code origin "refs/tags/${tag}"`, { stdio: 'ignore' });
81+
return true;
82+
} catch (error) {
83+
// git ls-remote 在远程可达但 ref 不存在时返回 2;其他错误(网络/权限)必须中断发版
84+
if (error && typeof error === 'object' && error.status === 2) return false;
85+
throw new Error(`无法检查 origin 上的 tag ${tag},请确认网络和 Git 权限`);
86+
}
6187
}
6288

6389
function deleteExistingTag(tag) {
@@ -72,7 +98,7 @@ function deleteExistingTag(tag) {
7298
function main() {
7399
const arg = process.argv[2];
74100
const root = path.resolve(__dirname, '..');
75-
// 版本以根 package.json 为准(tauri.conf.json 的 version 指向 ../../../package.json)
101+
// 版本以根 package.json 为准
76102
const pkgPath = path.join(root, PKG_JSON);
77103
const pkg = readJson(pkgPath);
78104

@@ -99,32 +125,94 @@ function main() {
99125

100126
const tag = `${TAG_PREFIX}${nextVersion}`;
101127

102-
console.log(`current : ${currentVersion}`);
103-
console.log(`next : ${nextVersion}`);
104-
console.log(`tag : ${tag}`);
105-
console.log('');
128+
// ---------- 前置检查(任何破坏性操作之前) ----------
129+
let status;
130+
try {
131+
status = sh('git status --porcelain');
132+
} catch {
133+
console.error('✗ 不在 git 仓库中');
134+
process.exit(1);
135+
}
136+
if (versionChanged && status) {
137+
console.error('✗ 工作区有未提交改动,请先 commit 或 stash:');
138+
console.error(status);
139+
process.exit(1);
140+
}
141+
142+
const branch = sh('git rev-parse --abbrev-ref HEAD');
143+
if (branch === 'HEAD') {
144+
console.error('✗ 当前处于 detached HEAD,请先 checkout 到发布分支');
145+
process.exit(1);
146+
}
106147

107-
if (versionChanged) {
108-
if (!isWorkingTreeClean()) {
109-
console.error('error: working tree not clean — commit or stash before releasing');
110-
process.exit(1);
148+
const originUrl = sh('git remote get-url origin');
149+
150+
// ---------- 打印发版摘要 ----------
151+
console.log('────────────────────────────────────────');
152+
console.log(` 当前版本: ${currentVersion}`);
153+
console.log(` 发布版本: ${tag}`);
154+
console.log(` 分支: ${branch}`);
155+
console.log(` 远程: ${originUrl}`);
156+
console.log('────────────────────────────────────────');
157+
158+
// ---------- tag 状态检测:确认前说明将删除已有还是新建 ----------
159+
const tagLocal = tagExists(tag);
160+
const tagRemote = remoteTagExists(tag);
161+
const tagWhere = [
162+
tagLocal ? '本地' : null,
163+
tagRemote ? 'origin 远程' : null,
164+
].filter(Boolean).join('、');
165+
166+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
167+
const ask = (prompt) => new Promise((resolve) => rl.question(prompt, resolve));
168+
169+
(async () => {
170+
let needClean = false;
171+
if (tagLocal || tagRemote) {
172+
console.log(` tag 状态: 已存在(${tagWhere})→ 将删除后重打`);
173+
const ans = await ask(`⚠ tag ${tag} 已存在(${tagWhere})。删除后重新打 tag 并推送?[y/N] `);
174+
if (ans.trim().toLowerCase() !== 'y') {
175+
console.log('✗ 已取消,未删除任何 tag,发版中止');
176+
rl.close();
177+
process.exit(1);
178+
}
179+
needClean = true;
180+
} else {
181+
console.log(' tag 状态: 新建');
182+
await ask('回车确认发版,Ctrl+C 取消...');
111183
}
112184

113-
pkg.version = nextVersion;
114-
writeJson(pkgPath, pkg);
185+
// ---------- 确认通过后才执行写操作 ----------
186+
if (versionChanged) {
187+
if (!isWorkingTreeClean()) {
188+
console.error('✗ 工作区有未提交改动,请先 commit 或 stash 后再发版');
189+
process.exit(1);
190+
}
115191

116-
run(`git add "${PKG_JSON}"`);
117-
run(`git commit -m "chore: release v${nextVersion}"`);
118-
}
192+
pkg.version = nextVersion;
193+
writeJson(pkgPath, pkg);
119194

120-
deleteExistingTag(tag);
195+
run(`git add "${PKG_JSON}"`);
196+
run(`git commit -m "chore: release v${nextVersion}"`);
197+
}
121198

122-
run(`git tag -a "${tag}" -m "nes-emulator v${nextVersion}"`);
123-
run('git push');
124-
run(`git push origin "${tag}"`);
199+
if (needClean) {
200+
deleteExistingTag(tag);
201+
console.log(`✓ 已清理旧 tag ${tag}`);
202+
}
125203

126-
console.log('');
127-
console.log(`✓ pushed tag ${tag} — workflow "${WORKFLOW_NAME}" triggered`);
204+
run(`git tag -a "${tag}" -m "nes-emulator v${nextVersion}"`);
205+
run('git push');
206+
run(`git push origin "${tag}"`);
207+
208+
console.log('');
209+
console.log(`✓ 发版完成!tag ${tag} 已推送 — workflow "${WORKFLOW_NAME}" 已触发`);
210+
rl.close();
211+
process.exit(0);
212+
})().catch((error) => {
213+
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
214+
process.exit(1);
215+
});
128216
}
129217

130218
main();

0 commit comments

Comments
 (0)