multi-terminals 0.0.0-stage → 0.5.5

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.
package/README.md CHANGED
@@ -1,3 +1,66 @@
1
- # Temporary Holding Version
1
+ # MultiTerminals(多端)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 轻量的 Windows 多项目终端工作台:左侧组织工作区和项目,右侧运行终端,支持标签、分屏、
4
+ 搜索、文件链接与 agent 会话恢复。
5
+
6
+ **关窗口不会结束终端;关终端标签会结束对应进程。** 终端由独立进程 daemon 持有,
7
+ 所以关掉窗口、升级应用,里面正在跑的构建和 agent 会话都还在。
8
+
9
+ ## 安装
10
+
11
+ ```powershell
12
+ npm i -g multi-terminals
13
+ multi-terminals
14
+ ```
15
+
16
+ 第二条命令如果发现还没装,会打开安装向导;装完之后再执行一次就是启动。
17
+
18
+ 不想全局安装的话,可以直接跑:
19
+
20
+ ```powershell
21
+ npx multi-terminals
22
+ ```
23
+
24
+ ## 系统要求
25
+
26
+ - Windows 10 1809 或更高版本,x64
27
+ - Node.js 18 或更高(只用来跑安装命令;应用本身不依赖 Node)
28
+ - WebView2 运行时 —— 安装程序会自己检查,缺了就装
29
+
30
+ 安装程序以当前用户身份安装到 `%LOCALAPPDATA%\MultiTerminals`,**不需要管理员权限**,
31
+ 并在开始菜单建立快捷方式、在「应用和功能」里登记卸载项。
32
+
33
+ ## 命令
34
+
35
+ ```powershell
36
+ multi-terminals # 启动;还没装就先装再启动
37
+ multi-terminals install # 打开安装向导(已安装则是升级)
38
+ multi-terminals install --silent # 无人值守安装,装完直接启动
39
+ multi-terminals uninstall # 卸载
40
+ multi-terminals --version
41
+ multi-terminals --help
42
+ ```
43
+
44
+ `--dry-run` 只打印将要执行的命令行,不真的执行任何东西。
45
+
46
+ ## 升级
47
+
48
+ 再跑一次 `multi-terminals install` 即可,它会装成同一个包的最新版本。
49
+
50
+ **安装和升级会关闭正在运行的 MultiTerminals 窗口**(交互模式会先问一句,`--silent` 下不问)。
51
+ **终端不会因此中断**:安装程序只会结束界面进程,而终端由另一个进程 daemon 持有,
52
+ 且 daemon 并不从安装目录运行,安装程序碰不到它。重新打开应用时,之前的终端会原样回来。
53
+
54
+ 工作区、标签和布局保存在 `%APPDATA%\MultiTerminals`,安装、升级、卸载**都不会删除**。
55
+ 卸载只移除程序本身;要清掉数据得手动删这个目录。
56
+
57
+ ## 卸载
58
+
59
+ ```powershell
60
+ multi-terminals uninstall
61
+ ```
62
+
63
+ 也可以从「设置 → 应用和功能」里卸载,或直接运行
64
+ `%LOCALAPPDATA%\MultiTerminals\uninstall.exe`。
65
+
66
+ `npm uninstall -g multi-terminals` 移除的只是安装命令,不会卸载应用本身。
@@ -0,0 +1,186 @@
1
+ // Install and launch MultiTerminals — the npm face of a Windows desktop app.
2
+ //
3
+ // multi-terminals # launch it, installing first if it is not there yet
4
+ // multi-terminals install # run the installer this package carries
5
+ // multi-terminals install --silent # unattended install, then launch
6
+ // multi-terminals uninstall # run the installed uninstaller
7
+ // multi-terminals --dry-run # print the command lines, touch nothing
8
+ //
9
+ // This package is a delivery vehicle, not the app. The app is an NSIS installer that
10
+ // registers itself in Add/Remove Programs and puts a shortcut in the Start Menu, and
11
+ // nothing an npm package does replaces that — so the installer rides along inside the
12
+ // tarball and this script runs it.
13
+ //
14
+ // Two installer behaviours shape the flags here. Both come from Tauri's NSIS template
15
+ // (`CheckIfAppIsRunning` in `utils.nsh`, the finish page in `installer.nsi`):
16
+ //
17
+ // - It closes a running MultiTerminals window. Interactively it asks first; under
18
+ // `/S` it does not ask. Either way your terminals survive — the daemon is a
19
+ // different process and does not run from the install directory.
20
+ // - It offers to launch the app from its finish page, and that page is skipped under
21
+ // `/S`. So only the silent path needs a launch from here; launching after an
22
+ // interactive install would race the finish page and start two windows.
23
+
24
+ import { execFileSync, spawn, spawnSync } from 'node:child_process'
25
+ import { existsSync, readFileSync, readdirSync } from 'node:fs'
26
+ import path from 'node:path'
27
+ import { fileURLToPath } from 'node:url'
28
+
29
+ const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
30
+ const { version } = JSON.parse(readFileSync(path.join(packageRoot, 'package.json'), 'utf8'))
31
+
32
+ /** What the app is called once installed. `tauri.conf.json` builds it as `multiterminals`. */
33
+ const APP_EXE = 'multiterminals.exe'
34
+ const PRODUCT_NAME = 'MultiTerminals'
35
+ /** Where the installer registers itself, so a moved install is still found. */
36
+ const UNINSTALL_KEY = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MultiTerminals'
37
+
38
+ const args = process.argv.slice(2)
39
+ const flag = (...names) => names.some((name) => args.includes(name))
40
+ const command = args.find((arg) => !arg.startsWith('-')) ?? 'run'
41
+ const dryRun = flag('--dry-run')
42
+
43
+ const USAGE = `MultiTerminals ${version} —— Windows 多项目终端工作台
44
+
45
+ 用法:
46
+ multi-terminals 启动应用;还没装就先装再启动
47
+ multi-terminals install 运行本包携带的安装程序
48
+ multi-terminals install --silent
49
+ 无人值守安装,装完直接启动
50
+ multi-terminals uninstall 运行已装好的卸载程序
51
+ multi-terminals --version 打印版本
52
+ multi-terminals --help 显示这段说明
53
+
54
+ 选项:
55
+ -s, --silent 安装时不弹向导(等价于 NSIS 的 /S)
56
+ --dry-run 只打印将要执行的命令行,不真的执行
57
+
58
+ 说明:
59
+ 安装程序会关闭正在运行的 MultiTerminals 窗口(交互模式会先问一句,--silent 下不问)。
60
+ 终端不会因此中断:终端由独立进程 daemon 持有,安装程序不会碰它。
61
+ 工作区、标签和布局保存在 %APPDATA%\\MultiTerminals,安装、升级、卸载都不会删除。`
62
+
63
+ function fail(message, code = 1) {
64
+ console.error(message)
65
+ process.exit(code)
66
+ }
67
+
68
+ /** The installer this package carries. Exactly one, or the tarball is not what we think. */
69
+ function findInstaller() {
70
+ const found = readdirSync(packageRoot).filter((name) => name.endsWith('-setup.exe'))
71
+ if (found.length === 0) {
72
+ fail(`${packageRoot} carries no installer; the package is incomplete or was packed without its prepack step`, 1)
73
+ }
74
+ if (found.length > 1) {
75
+ fail(`${packageRoot} carries ${found.length} installers (${found.join(', ')}); refusing to guess which one`, 1)
76
+ }
77
+ return path.join(packageRoot, found[0])
78
+ }
79
+
80
+ /** Where a previous install put the app, or null. Registry first, default location second. */
81
+ function installedDir() {
82
+ try {
83
+ const out = execFileSync('reg', ['query', UNINSTALL_KEY, '/v', 'InstallLocation'], { encoding: 'utf8' })
84
+ const match = /InstallLocation\s+REG_SZ\s+(.*)/.exec(out)
85
+ // The value is stored *with* its quotes — `"C:\Users\x\AppData\Local\MultiTerminals"` —
86
+ // so trimming whitespace is not enough and a quoted path will not resolve.
87
+ if (match) return match[1].trim().replace(/^"|"$/g, '')
88
+ } catch {
89
+ // No registry entry: either never installed, or installed by something that did not
90
+ // register. The default location below is what answers the second case.
91
+ }
92
+ const fallback = process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, PRODUCT_NAME) : null
93
+ return fallback && existsSync(fallback) ? fallback : null
94
+ }
95
+
96
+ /** The installed executable, or null. */
97
+ function installedApp() {
98
+ const dir = installedDir()
99
+ if (!dir) return null
100
+ const exe = path.join(dir, APP_EXE)
101
+ return existsSync(exe) ? exe : null
102
+ }
103
+
104
+ function runInstaller({ silent }) {
105
+ const installer = findInstaller()
106
+ const installerArgs = silent ? ['/S'] : []
107
+ const line = [installer, ...installerArgs].join(' ')
108
+ if (dryRun) {
109
+ console.log(`[dry-run] ${line}`)
110
+ return
111
+ }
112
+ console.log(silent ? 'installing (silent)…' : '正在打开安装向导…')
113
+ const result = spawnSync(installer, installerArgs, { stdio: 'inherit', windowsHide: false })
114
+ if (result.error) fail(`could not run the installer: ${result.error.message}`)
115
+ // NSIS reports its own failures in a dialog and still exits 0 often enough that the
116
+ // exit code alone proves nothing; the install existing afterwards is the real check,
117
+ // and the caller makes it.
118
+ }
119
+
120
+ function launch(exe) {
121
+ if (dryRun) {
122
+ console.log(`[dry-run] ${exe}`)
123
+ return
124
+ }
125
+ const child = spawn(exe, [], { detached: true, stdio: 'ignore' })
126
+ child.unref()
127
+ console.log(`已启动 ${exe}`)
128
+ }
129
+
130
+ if (flag('--help', '-h') || command === 'help') {
131
+ console.log(USAGE)
132
+ process.exit(0)
133
+ }
134
+ if (flag('--version', '-v') || command === 'version') {
135
+ console.log(version)
136
+ process.exit(0)
137
+ }
138
+
139
+ if (process.platform !== 'win32') {
140
+ fail('MultiTerminals 是 Windows x64 应用,这个包在别的平台上装不了。')
141
+ }
142
+
143
+ switch (command) {
144
+ case 'run': {
145
+ const already = installedApp()
146
+ if (already) {
147
+ launch(already)
148
+ break
149
+ }
150
+ // Nothing is installed, so there is no window to close and nobody to race: the
151
+ // wizard can run and its finish page offers the launch.
152
+ runInstaller({ silent: false })
153
+ const now = installedApp()
154
+ if (dryRun) break
155
+ if (!now) fail('安装似乎没有完成:注册表里没有 MultiTerminals,默认目录下也没有可执行文件。', 1)
156
+ console.log(`已安装到 ${now}\n向导最后一页可以勾选启动;也可以再执行一次 multi-terminals。`)
157
+ break
158
+ }
159
+ case 'install': {
160
+ runInstaller({ silent: flag('--silent', '-s') })
161
+ if (dryRun) break
162
+ const now = installedApp()
163
+ if (!now) fail('安装似乎没有完成:注册表里没有 MultiTerminals,默认目录下也没有可执行文件。', 1)
164
+ // The finish page is skipped under `/S`, so a silent install leaves nothing running.
165
+ if (flag('--silent', '-s')) launch(now)
166
+ else console.log(`已安装到 ${now}`)
167
+ break
168
+ }
169
+ case 'uninstall': {
170
+ const dir = installedDir()
171
+ const uninstaller = dir ? path.join(dir, 'uninstall.exe') : null
172
+ if (!uninstaller || !existsSync(uninstaller)) {
173
+ fail('没有找到卸载程序;MultiTerminals 可能本来就没装。', 2)
174
+ }
175
+ if (dryRun) {
176
+ console.log(`[dry-run] ${uninstaller}`)
177
+ break
178
+ }
179
+ const result = spawnSync(uninstaller, [], { stdio: 'inherit', windowsHide: false })
180
+ if (result.error) fail(`could not run the uninstaller: ${result.error.message}`)
181
+ console.log('工作区、标签和布局仍保留在 %APPDATA%\\MultiTerminals,需要的话请手动删除。')
182
+ break
183
+ }
184
+ default:
185
+ fail(`未知命令:${command}\n\n${USAGE}`, 2)
186
+ }
package/package.json CHANGED
@@ -1,6 +1,34 @@
1
1
  {
2
2
  "name": "multi-terminals",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.5.5",
4
+ "description": "轻量的 Windows 多项目终端工作台:关窗口不会结束终端",
5
+ "keywords": [
6
+ "terminal",
7
+ "workspace",
8
+ "windows",
9
+ "tauri",
10
+ "shell",
11
+ "pty"
12
+ ],
13
+ "license": "MIT",
14
+ "type": "module",
15
+ "bin": {
16
+ "multi-terminals": "bin/multi-terminals.mjs"
17
+ },
18
+ "files": [
19
+ "bin/",
20
+ "*.exe"
21
+ ],
22
+ "os": [
23
+ "win32"
24
+ ],
25
+ "cpu": [
26
+ "x64"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "scripts": {
32
+ "prepack": "node ../scripts/sync-npm-package.mjs"
33
+ }
34
+ }