dsh-ris-ide 1.7.2 → 1.8.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.
- package/README.md +43 -4
- package/bin/check-listing.mjs +247 -0
- package/bin/proxy-janitor.mjs +183 -0
- package/bin/risd.mjs +287 -0
- package/bin/run-with-log.ps1 +43 -5
- package/lib/client-codemirror.js +92 -66
- package/lib/client.js +774 -89
- package/lib/index.js +2256 -21
- package/lib/janitor.js +377 -0
- package/lib/proxy.js +1577 -0
- package/lib/proxybridge-bundle.js +798 -0
- package/lib/redirector.js +2558 -0
- package/lib/risd/build.js +91 -0
- package/lib/risd/debug.js +374 -0
- package/lib/risd/git.js +207 -0
- package/lib/risd/leases.js +124 -0
- package/lib/risd/lifecycle.js +148 -0
- package/lib/risd/log.js +59 -0
- package/lib/risd/ping.js +94 -0
- package/lib/risd/programs.js +348 -0
- package/lib/risd/server.js +1478 -0
- package/lib/risd/state.js +137 -0
- package/lib/risd/ui.js +1705 -0
- package/lib/risd/view.js +79 -0
- package/lib/risd-client.js +282 -0
- package/lib/standalone/window.html +14 -16
- package/lib/startup.js +114 -0
- package/package.json +7 -2
- package/skills/dsh-ris-ide-debug/SKILL.md +37 -2
- package/test/client-build.test.mjs +113 -0
- package/test/client-viewer.test.mjs +314 -20
- package/test/companion.test.mjs +65 -0
- package/test/dsh-origin.test.mjs +140 -0
- package/test/dsh-window-refresh.test.mjs +100 -0
- package/test/harness.test.mjs +9 -0
- package/test/host-noloop.test.mjs +74 -0
- package/test/host-tail.test.mjs +54 -5
- package/test/host-window.test.mjs +4 -4
- package/test/inherit-engine.test.mjs +175 -0
- package/test/install-phase.test.mjs +36 -0
- package/test/janitor.test.mjs +172 -0
- package/test/lifecycle.test.mjs +109 -0
- package/test/merge-owners.test.mjs +155 -0
- package/test/proxy-restart.test.mjs +37 -0
- package/test/proxy-route.test.mjs +599 -0
- package/test/proxy-window.test.mjs +45 -0
- package/test/proxy.test.mjs +914 -0
- package/test/proxybridge-bundle.test.mjs +687 -0
- package/test/redirector-bundle.test.mjs +391 -0
- package/test/redirector.test.mjs +571 -0
- package/test/risd-api.test.mjs +470 -0
- package/test/risd-bridge-degrade.test.mjs +101 -0
- package/test/risd-build.test.mjs +20 -0
- package/test/risd-cli-home.test.mjs +50 -0
- package/test/risd-client.test.mjs +130 -0
- package/test/risd-debug.test.mjs +261 -0
- package/test/risd-election.test.mjs +104 -0
- package/test/risd-engine.test.mjs +132 -0
- package/test/risd-entry.test.mjs +118 -0
- package/test/risd-git.test.mjs +109 -0
- package/test/risd-handoff.test.mjs +116 -0
- package/test/risd-heal.test.mjs +50 -0
- package/test/risd-helpers.mjs +108 -0
- package/test/risd-host-p2.test.mjs +147 -0
- package/test/risd-janitor-guard.test.mjs +46 -0
- package/test/risd-lease.test.mjs +83 -0
- package/test/risd-lifecycle.test.mjs +210 -0
- package/test/risd-log-follow.test.mjs +227 -0
- package/test/risd-mode.test.mjs +161 -0
- package/test/risd-ping.test.mjs +99 -0
- package/test/risd-programs.test.mjs +169 -0
- package/test/risd-review-p2.test.mjs +217 -0
- package/test/risd-shutdown.test.mjs +97 -0
- package/test/risd-teardown.test.mjs +87 -0
- package/test/risd-tools.test.mjs +211 -0
- package/test/risd-ui.test.mjs +445 -0
- package/test/risd-write.test.mjs +170 -0
- package/test/startup-reconcile.test.mjs +100 -0
- package/test/windows.test.mjs +37 -2
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Startup reconciliation: leftovers that no longer match today's rules/state.
|
|
2
|
+
// A reboot kills every process we started (engine, daemon, bridge) but NOT the two
|
|
3
|
+
// machine-level side effects — the scoped git entry and the parked ProxyBridgeSvc —
|
|
4
|
+
// so the next start must undo what is provably ours and leave everything else alone.
|
|
5
|
+
import assert from 'node:assert/strict'
|
|
6
|
+
import { spawnSync } from 'node:child_process'
|
|
7
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
8
|
+
import { tmpdir } from 'node:os'
|
|
9
|
+
import { join } from 'node:path'
|
|
10
|
+
import { after, before, test } from 'node:test'
|
|
11
|
+
import { reconcileStartupLeftovers } from '../lib/startup.js'
|
|
12
|
+
|
|
13
|
+
let root
|
|
14
|
+
let home
|
|
15
|
+
let gitConfig
|
|
16
|
+
|
|
17
|
+
function git(args) {
|
|
18
|
+
const res = spawnSync('git', args, { encoding: 'utf8', env: process.env })
|
|
19
|
+
assert.equal(res.status, 0, `git ${args.join(' ')}: ${res.stderr}`)
|
|
20
|
+
return res.stdout.trim()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function gitGet(key) {
|
|
24
|
+
const res = spawnSync('git', ['config', '--global', '--get', key], { encoding: 'utf8', env: process.env })
|
|
25
|
+
assert.ok(res.status === 0 || res.status === 1, `git --get ${key}: ${res.stderr}`)
|
|
26
|
+
return res.status === 0 ? res.stdout.trim() : ''
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function writeGitState(state) {
|
|
30
|
+
writeFileSync(join(home, 'git-proxy.json'), `${JSON.stringify(state)}\n`, 'utf8')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
before(() => {
|
|
34
|
+
root = mkdtempSync(join(tmpdir(), 'dsh-ris-ide-startup-'))
|
|
35
|
+
home = join(root, 'home')
|
|
36
|
+
mkdirSync(home, { recursive: true })
|
|
37
|
+
gitConfig = join(root, 'gitconfig')
|
|
38
|
+
writeFileSync(gitConfig, '', 'utf8')
|
|
39
|
+
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
40
|
+
process.env.GIT_CONFIG_GLOBAL = gitConfig
|
|
41
|
+
process.env.GIT_CONFIG_NOSYSTEM = '1'
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
after(() => {
|
|
45
|
+
delete process.env.DSH_RIS_IDE_PROXY_HOME
|
|
46
|
+
delete process.env.GIT_CONFIG_GLOBAL
|
|
47
|
+
delete process.env.GIT_CONFIG_NOSYSTEM
|
|
48
|
+
rmSync(root, { recursive: true, force: true })
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test('a clean machine is a no-op', async () => {
|
|
52
|
+
const result = await reconcileStartupLeftovers()
|
|
53
|
+
assert.equal(result.ok, true)
|
|
54
|
+
assert.deepEqual(result.notes, [])
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('a git entry from a dead engine is removed (it is ours)', async () => {
|
|
58
|
+
const key = 'http.https://git.example.com/.proxy'
|
|
59
|
+
const value = 'socks5h://10.0.0.1:1080'
|
|
60
|
+
writeGitState({ key, host: 'git.example.com', value })
|
|
61
|
+
git(['config', '--global', key, value])
|
|
62
|
+
const result = await reconcileStartupLeftovers()
|
|
63
|
+
assert.ok(result.notes.some((note) => /git 代理/.test(note)), result.notes.join('; '))
|
|
64
|
+
assert.equal(gitGet(key), '')
|
|
65
|
+
assert.equal(existsSync(join(home, 'git-proxy.json')), false, 'state file is gone')
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('a foreign git value is left alone', async () => {
|
|
69
|
+
const key = 'http.https://other.example.com/.proxy'
|
|
70
|
+
writeGitState({ key, host: 'other.example.com', value: 'socks5h://10.0.0.1:1080' })
|
|
71
|
+
git(['config', '--global', key, 'http://corp-proxy:3128'])
|
|
72
|
+
const result = await reconcileStartupLeftovers()
|
|
73
|
+
assert.ok(result.notes.some((note) => /保留了/.test(note)), result.notes.join('; '))
|
|
74
|
+
assert.equal(gitGet(key), 'http://corp-proxy:3128')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
test('a stale pidfile and a dead risd.json are cleared', async () => {
|
|
78
|
+
writeFileSync(join(home, 'proxy.pid'), '999999\n', 'utf8')
|
|
79
|
+
writeFileSync(join(home, 'risd.json'), `${JSON.stringify({ pid: 999999, port: 1, token: 'x', apiVersion: 1 })}\n`, 'utf8')
|
|
80
|
+
const result = await reconcileStartupLeftovers()
|
|
81
|
+
assert.equal(existsSync(join(home, 'proxy.pid')), false, 'stale pidfile removed')
|
|
82
|
+
assert.equal(existsSync(join(home, 'risd.json')), false, 'dead daemon state removed')
|
|
83
|
+
assert.ok(result.notes.length >= 2, result.notes.join('; '))
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('a parked ProxyBridgeSvc is restored and its state cleared', async () => {
|
|
87
|
+
const dir = join(home, 'proxybridge')
|
|
88
|
+
mkdirSync(dir, { recursive: true })
|
|
89
|
+
writeFileSync(join(dir, 'proxybridge-service.json'), `${JSON.stringify({
|
|
90
|
+
at: Date.now(), stoppedByUs: true, originalStartType: 'Automatic', parkedOnManual: true,
|
|
91
|
+
})}\n`, 'utf8')
|
|
92
|
+
const result = await reconcileStartupLeftovers()
|
|
93
|
+
assert.ok(result.notes.some((note) => /ProxyBridgeSvc/.test(note)), result.notes.join('; '))
|
|
94
|
+
assert.equal(existsSync(join(dir, 'proxybridge-service.json')), false, 'service state cleared')
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
test('the git config file is only touched for our own entries', () => {
|
|
98
|
+
const text = readFileSync(gitConfig, 'utf8')
|
|
99
|
+
assert.doesNotMatch(text, /git\.example\.com/)
|
|
100
|
+
})
|
package/test/windows.test.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import { readFile } from 'node:fs/promises'
|
|
|
16
16
|
import { join } from 'node:path'
|
|
17
17
|
|
|
18
18
|
import { __test } from '../lib/index.js'
|
|
19
|
+
import { isBashDialectCommand, resolveWindowsRuntime } from '../lib/index.js'
|
|
19
20
|
|
|
20
21
|
const {
|
|
21
22
|
WINDOWS_PATH,
|
|
@@ -161,8 +162,9 @@ test('clicking the IDE button closes the old window and opens a fresh one', () =
|
|
|
161
162
|
assert.match(clientSource, /await requestStandaloneWindowClose\(windowName\)/, 'a dead registration cannot block the next open')
|
|
162
163
|
assert.match(clientSource, /channel\.postMessage\(\{ type: 'close' \}\)/, 'the old window is told to close itself')
|
|
163
164
|
assert.match(clientSource, /if \(state\.alive !== true\) \{ release\(\); resolve\(true\); return \}/, 'the handshake waits for the stream to go')
|
|
164
|
-
assert.match(clientSource, /window\.open\(url\.href, windowName
|
|
165
|
-
assert.doesNotMatch(clientSource, /window\.open\(
|
|
165
|
+
assert.match(clientSource, /window\.open\(url\.href, windowName\)/, 'the new window is opened directly, as a normal window (no blank popup)')
|
|
166
|
+
assert.doesNotMatch(clientSource, /window\.open\(url\.href, windowName, features\)/, 'no sized popup any more')
|
|
167
|
+
assert.doesNotMatch(clientSource, /window\.open\('', windowName/, 'no blank popup that has to be closed again')
|
|
166
168
|
assert.doesNotMatch(clientSource, /settleStandaloneWindow/)
|
|
167
169
|
assert.match(windowHtml, /function closeForOpener\(\)/, 'the window can close itself on request')
|
|
168
170
|
assert.match(windowHtml, /if \(data\.type === 'close'\) \{/, 'the lock holder obeys the close request')
|
|
@@ -196,3 +198,36 @@ test('a restarted host makes every pane drop its stale error and re-read', () =>
|
|
|
196
198
|
assert.match(clientSource, /doc\.kind !== 'error'/, 'only documents that failed are retried (edits are kept)')
|
|
197
199
|
assert.match(clientSource, /setError\(undefined\)\n return true/, 'a successful background read also clears the tree banner')
|
|
198
200
|
})
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
test('a bash-dialect startCommand keeps Git Bash under runtime=auto', () => {
|
|
204
|
+
// `auto` prefers the native PowerShell wrapper, which runs custom commands
|
|
205
|
+
// through cmd.exe; `$(cat cp.txt)` and `exec java` die there without a word
|
|
206
|
+
// (review A2-P1-2). Commands that need a POSIX shell must fall back to Git Bash.
|
|
207
|
+
assert.equal(isBashDialectCommand('mvn compile && exec java -cp "$(cat target/cp.txt)" App'), true)
|
|
208
|
+
assert.equal(isBashDialectCommand('java -jar app.jar --home=$HOME'), true)
|
|
209
|
+
assert.equal(isBashDialectCommand('cd target && java -cp "${CLASSPATH}" App'), true)
|
|
210
|
+
assert.equal(isBashDialectCommand('export JAVA_HOME=/opt/jdk && java -jar app.jar'), true)
|
|
211
|
+
assert.equal(isBashDialectCommand('npm run dev'), false)
|
|
212
|
+
assert.equal(isBashDialectCommand(''), false)
|
|
213
|
+
// An explicit powershell request is respected even for a bash-dialect command;
|
|
214
|
+
// the wrapper then fails loudly instead of silently running under cmd.exe.
|
|
215
|
+
assert.deepEqual(resolveWindowsRuntime('powershell', undefined, { bashDialect: true }), { runtime: 'powershell' })
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
test('PowerShell commands are not mistaken for bash dialect', () => {
|
|
219
|
+
// `$env:NAME` is how PowerShell spells an environment variable, `$x = 1` is an
|
|
220
|
+
// assignment and `-Command` names powershell itself; none of those can run under
|
|
221
|
+
// Git Bash. Treating them as bash forced Git Bash (or failed with `no-bash` when
|
|
222
|
+
// it was not installed) for the most common PowerShell startCommand (review C3-P1-1).
|
|
223
|
+
assert.equal(isBashDialectCommand('pwsh -NoProfile -Command "$env:JAVA_HOME\\bin\\java -jar app.jar"'), false)
|
|
224
|
+
assert.equal(isBashDialectCommand('powershell -Command "$x = 1; .\\run.ps1"'), false)
|
|
225
|
+
assert.equal(isBashDialectCommand('pwsh -File .\\run.ps1 -Workspace C:\\work'), false)
|
|
226
|
+
assert.equal(isBashDialectCommand('$env:JAVA_HOME = "C:\\jdk"; & "$env:JAVA_HOME\\bin\\java" -jar app.jar'), false)
|
|
227
|
+
assert.equal(isBashDialectCommand('$root = Split-Path -Parent $MyInvocation.MyCommand.Path'), false)
|
|
228
|
+
assert.equal(isBashDialectCommand('Start-Process java -ArgumentList @("-jar","app.jar")'), false)
|
|
229
|
+
// Still bash: `$(...)`, backticks, `${...}`, exec/export/source, ALL-CAPS $VAR.
|
|
230
|
+
assert.equal(isBashDialectCommand('exec java -cp "$(cat cp.txt)" App'), true)
|
|
231
|
+
assert.equal(isBashDialectCommand('java -jar `cat jar.txt`'), true)
|
|
232
|
+
assert.equal(isBashDialectCommand('source ./env.sh && java -jar app.jar'), true)
|
|
233
|
+
})
|