@fastagent-sh/voicenote 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/install.mjs +17 -5
  2. package/package.json +1 -1
package/install.mjs CHANGED
@@ -23,18 +23,21 @@ function fail(message) {
23
23
  process.exit(1)
24
24
  }
25
25
 
26
- if (process.platform !== 'darwin') {
27
- fail(`目前只有 macOS 版本(检测到 ${process.platform})。`)
26
+ if (process.platform !== 'darwin' && process.platform !== 'win32') {
27
+ fail(`目前只有 macOS 和 Windows 版本(检测到 ${process.platform})。`)
28
28
  }
29
29
 
30
30
  const release = await fetch(`https://api.github.com/repos/${REPO}/releases/latest`, {
31
31
  headers: { accept: 'application/vnd.github+json' },
32
32
  }).then(r => r.ok ? r.json() : fail(`读取发布信息失败(HTTP ${r.status})。`))
33
33
 
34
- // The zip is what ships the .app; the dmg is for people who download by hand.
34
+ // macOS: the zip carries the .app (the dmg is for manual downloads).
35
+ // Windows: the NSIS installer, which we hand to the system to run.
35
36
  const wanted = process.arch === 'arm64' ? 'arm64' : 'x64'
36
- const asset = (release.assets ?? []).find(a => a.name.endsWith('-mac.zip') && a.name.includes(wanted))
37
- if (!asset) fail(`这个版本没有 ${wanted} 的 macOS 包(${release.tag_name})。`)
37
+ const asset = (release.assets ?? []).find(a => process.platform === 'win32'
38
+ ? a.name.endsWith('.exe')
39
+ : a.name.endsWith('-mac.zip') && a.name.includes(wanted))
40
+ if (!asset) fail(`这个版本没有 ${process.platform} 的安装包(${release.tag_name})。`)
38
41
 
39
42
  console.log(`下载 VoiceNote ${release.tag_name.replace(/^app-v/, '')}(${(asset.size / 1e6).toFixed(0)} MB)…`)
40
43
  const work = await mkdtemp(join(tmpdir(), 'voicenote-install-'))
@@ -44,6 +47,15 @@ try {
44
47
  if (!download.ok) fail(`下载失败(HTTP ${download.status})。`)
45
48
  await writeFile(zipPath, Buffer.from(await download.arrayBuffer()))
46
49
 
50
+ if (process.platform === 'win32') {
51
+ console.log('运行安装程序…')
52
+ // The NSIS installer is one-click: it installs and starts the app.
53
+ execFileSync(zipPath, [], { stdio: 'inherit' })
54
+ console.log('\n✓ 安装完成,VoiceNote 会自动启动。')
55
+ console.log(' 首次运行如果 Windows 提示"未知发布者",点「更多信息 → 仍要运行」。\n')
56
+ process.exit(0)
57
+ }
58
+
47
59
  const target = join(APPS, 'VoiceNote.app')
48
60
  if (existsSync(target)) {
49
61
  console.log('替换已安装的版本…')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastagent-sh/voicenote",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Installs the VoiceNote desktop app (macOS). The command line tool is @fastagent-sh/vn.",
5
5
  "type": "module",
6
6
  "license": "MIT",