dsh-ris-ide 1.7.0 → 1.7.1
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 +3 -3
- package/lib/client.js +729 -77
- package/lib/index.js +1091 -49
- package/lib/standalone/window.html +89 -14
- package/package.json +1 -1
- package/skills/dsh-ris-ide-debug/SKILL.md +2 -2
- package/test/client-viewer.test.mjs +297 -29
- package/test/clipboard.test.mjs +254 -0
- package/test/host-tail.test.mjs +136 -21
- package/test/windows.test.mjs +198 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tree's copy mirrored onto the OS clipboard so a file manager can paste it.
|
|
3
|
+
*
|
|
4
|
+
* A web page cannot publish a file list (Chromium refuses `text/uri-list` on
|
|
5
|
+
* `Clipboard.write`, and a synthetic `copy` event only yields Chrome's private
|
|
6
|
+
* flavour), so the Host builds the platform command. These tests pin the command
|
|
7
|
+
* shape and the route contract — never the real clipboard, which belongs to the
|
|
8
|
+
* developer's desktop, not to CI.
|
|
9
|
+
*/
|
|
10
|
+
import { test } from 'node:test'
|
|
11
|
+
import assert from 'node:assert/strict'
|
|
12
|
+
import { createServer } from 'node:http'
|
|
13
|
+
import { readFile } from 'node:fs/promises'
|
|
14
|
+
|
|
15
|
+
import { __test } from '../lib/index.js'
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
CLIPBOARD_FILES_PATH,
|
|
19
|
+
CLIPBOARD_READ_PATH,
|
|
20
|
+
CLIPBOARD_MAX_ENTRIES,
|
|
21
|
+
CLIPBOARD_MAX_PAYLOAD,
|
|
22
|
+
CLIPBOARD_STAGE_DIR,
|
|
23
|
+
clipboardScope,
|
|
24
|
+
stageClipboardCopy,
|
|
25
|
+
pruneClipboardStage,
|
|
26
|
+
clipboardStageMapping,
|
|
27
|
+
windowsClipboardScript,
|
|
28
|
+
windowsClipboardReadScript,
|
|
29
|
+
parseClipboardRead,
|
|
30
|
+
clipboardPathsToLinux,
|
|
31
|
+
readSystemFileClipboard,
|
|
32
|
+
writeSystemFileClipboard,
|
|
33
|
+
serveClipboardFiles,
|
|
34
|
+
serveClipboardRead,
|
|
35
|
+
isWsl,
|
|
36
|
+
} = __test
|
|
37
|
+
|
|
38
|
+
test('the clipboard route is one POST under the plugin prefix', () => {
|
|
39
|
+
assert.equal(CLIPBOARD_FILES_PATH, '/dsh-ris-ide/clipboard/files')
|
|
40
|
+
assert.equal(typeof serveClipboardFiles, 'function')
|
|
41
|
+
assert.equal(CLIPBOARD_MAX_ENTRIES, 200, 'one copy is a selection, not a whole disk')
|
|
42
|
+
assert.equal(CLIPBOARD_MAX_PAYLOAD, 256 * 1024, 'the stdin payload is bounded too')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test('the PowerShell script writes CF_HDROP with the intent Explorer reads', () => {
|
|
46
|
+
const copy = windowsClipboardScript(false)
|
|
47
|
+
assert.match(copy, /Add-Type -AssemblyName System\.Windows\.Forms/, 'the clipboard API comes from WinForms')
|
|
48
|
+
assert.match(copy, /\$data\.SetData\('FileDrop', \[string\[\]\]\$lines\)/, 'paths go in as a FileDrop list')
|
|
49
|
+
assert.match(copy, /\$data\.SetData\('Preferred DropEffect', \[byte\[\]\]@\(1,0,0,0\)\)/, 'copy is DROPEFFECT_COPY')
|
|
50
|
+
assert.match(copy, /\[System\.Windows\.Forms\.Clipboard\]::SetDataObject\(\$data, \$true\)/, 'the data is flushed, so it survives the PowerShell process')
|
|
51
|
+
assert.match(windowsClipboardScript(true), /\[byte\[\]\]@\(2,0,0,0\)/, 'cut is DROPEFFECT_MOVE')
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('no file name can reach the PowerShell script as code', async () => {
|
|
55
|
+
const source = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
56
|
+
// The script is a constant: the paths ride on stdin, one per line.
|
|
57
|
+
assert.match(source, /\[Console\]::OpenStandardInput\(\)/, 'the list is read from stdin')
|
|
58
|
+
assert.match(source, /\[Text\.Encoding\]::UTF8\.GetString/, 'stdin bytes are decoded as UTF-8')
|
|
59
|
+
assert.equal(/windowsPaths\.map\(powershellLiteral\)/.test(source), false, 'no path is interpolated into the script')
|
|
60
|
+
assert.equal(/function powershellLiteral/.test(source), false, 'the literal quoter is gone with the interpolation')
|
|
61
|
+
// …and the list is handed over as stdin, never as an argument vector entry.
|
|
62
|
+
assert.match(source, /'powershell\.exe', \['-NoProfile', '-NonInteractive', '-STA', '-EncodedCommand', encoded\], `\$\{windowsPaths\.join\('\\n'\)\}\\n`\)/)
|
|
63
|
+
// The route refuses names the line protocol cannot express.
|
|
64
|
+
assert.match(source, /复制到系统剪贴板不支持路径里的换行或控制字符/)
|
|
65
|
+
assert.match(source, /CLIPBOARD_MAX_PAYLOAD/)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('the Host owns the platform call, the client only asks for it', async () => {
|
|
69
|
+
assert.equal(typeof writeSystemFileClipboard, 'function')
|
|
70
|
+
assert.equal(typeof isWsl(), 'boolean', 'WSL detection is a platform fact, never request data')
|
|
71
|
+
const source = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
72
|
+
assert.match(source, /isLoopbackRequest\(req\)\) throw new TailError\('forbidden'/, 'the route is loopback-fenced')
|
|
73
|
+
assert.match(source, /paths\.length > CLIPBOARD_MAX_ENTRIES/, 'the count is capped')
|
|
74
|
+
assert.match(source, /'wslpath'/, 'WSL paths are translated for the Windows clipboard')
|
|
75
|
+
assert.match(source, /'linux-xclip'/, 'a GNOME desktop gets the copy|cut flavour')
|
|
76
|
+
assert.match(source, /'linux-wl-copy'/, 'a plain Wayland desktop falls back to text/uri-list')
|
|
77
|
+
assert.match(source, /'macos-appkit'/, 'Finder pasteboard is written through JXA')
|
|
78
|
+
// Every child process is spawned without a shell, with a hard timeout.
|
|
79
|
+
assert.equal(/shell: true/.test(source), false, 'no child is run through a shell')
|
|
80
|
+
assert.match(source, /child\.kill\('SIGKILL'\)/, 'a stuck helper is killed')
|
|
81
|
+
// macOS gets the paths as argv, not as JXA source.
|
|
82
|
+
assert.match(source, /'osascript', \['-l', 'JavaScript', '-e', script, \.\.\.paths\]/)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('the route rejects relative, missing, control-character and oversized lists before touching the clipboard', async () => {
|
|
86
|
+
const server = createServer((req, res) => { void serveClipboardFiles(undefined, req, res, {}) })
|
|
87
|
+
await new Promise((resolvePromise) => server.listen(0, '127.0.0.1', resolvePromise))
|
|
88
|
+
const base = `http://127.0.0.1:${server.address().port}/dsh-ris-ide/clipboard/files`
|
|
89
|
+
const post = (body) => fetch(base, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })
|
|
90
|
+
try {
|
|
91
|
+
assert.equal((await post({ paths: ['notes.txt'] })).status, 400, 'a relative path has no meaning on the OS clipboard')
|
|
92
|
+
assert.equal((await post({ paths: ['/definitely/not/here.txt'] })).status, 404, 'a stale row must not put a ghost on the clipboard')
|
|
93
|
+
assert.equal((await post({ paths: ['/tmp/it\nis.txt'] })).status, 400, 'a line break would split one name into two entries')
|
|
94
|
+
assert.equal((await post({ paths: ['/tmp/it\u0000is.txt'] })).status, 400, 'a NUL cannot survive a text channel')
|
|
95
|
+
const tooMany = Array.from({ length: CLIPBOARD_MAX_ENTRIES + 1 }, (_, index) => `/tmp/clip-${index}.txt`)
|
|
96
|
+
assert.equal((await post({ paths: tooMany })).status, 400, 'the cap is enforced')
|
|
97
|
+
assert.equal((await post({ paths: [] })).status, 400, 'an empty list is a caller bug')
|
|
98
|
+
// A COPY must be staged first, and staging needs the workspace. Without it the
|
|
99
|
+
// route refuses rather than publishing the originals.
|
|
100
|
+
const { mkdtemp, writeFile } = await import('node:fs/promises')
|
|
101
|
+
const { tmpdir } = await import('node:os')
|
|
102
|
+
const { join } = await import('node:path')
|
|
103
|
+
const real = join(await mkdtemp(join(tmpdir(), 'dsh-clip-route-')), 'a.txt')
|
|
104
|
+
await writeFile(real, 'x', 'utf8')
|
|
105
|
+
const noWorkspace = await post({ paths: [real] })
|
|
106
|
+
assert.equal(noWorkspace.status, 400, 'a copy that cannot be staged is refused')
|
|
107
|
+
assert.match((await noWorkspace.json()).message, /sessionId/, 'the message says why')
|
|
108
|
+
} finally {
|
|
109
|
+
await new Promise((resolvePromise) => server.close(resolvePromise))
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
test('the clipboard scope is read from the query string, like every tree route', () => {
|
|
114
|
+
const query = new URL('http://dsh.internal/dsh-ris-ide/clipboard/files?sessionId=session-1&cwd=%2Fw')
|
|
115
|
+
// The page puts the scope in the QUERY (that is how `clipboardQuery` builds it).
|
|
116
|
+
// Reading only the body made copy answer "复制到系统剪贴板需要 sessionId".
|
|
117
|
+
assert.deepEqual(clipboardScope({}, query), { sessionId: 'session-1', cwd: '/w' }, 'a page-built query resolves')
|
|
118
|
+
assert.deepEqual(clipboardScope({ sessionId: 'body', cwd: '/b' }, new URL('http://dsh.internal/x')), { sessionId: 'body', cwd: '/b' }, 'a body still works')
|
|
119
|
+
assert.deepEqual(clipboardScope({ sessionId: 'body' }, query), { sessionId: 'body', cwd: '/w' }, 'the body wins per field, the query fills the gap')
|
|
120
|
+
assert.deepEqual(clipboardScope({}, new URL('http://dsh.internal/x')), { sessionId: '', cwd: '' }, 'nothing carried reads as empty scope')
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
test('the clipboard can be READ back: Explorer copies reach the tree on WSL', () => {
|
|
124
|
+
assert.equal(CLIPBOARD_READ_PATH, '/dsh-ris-ide/clipboard/read')
|
|
125
|
+
assert.equal(typeof serveClipboardRead, 'function')
|
|
126
|
+
assert.equal(typeof readSystemFileClipboard, 'function')
|
|
127
|
+
// The read script is a constant too — it prints, it never interpolates a path.
|
|
128
|
+
const script = windowsClipboardReadScript()
|
|
129
|
+
assert.match(script, /Add-Type -AssemblyName System\.Windows\.Forms/)
|
|
130
|
+
assert.match(script, /GetDataObject\(\)/)
|
|
131
|
+
assert.match(script, /\$data\.GetData\("FileDrop"\)/)
|
|
132
|
+
assert.match(script, /"F:" \+ \[string\]\$file/, 'one line per file, so a name is never escaped as code')
|
|
133
|
+
assert.match(script, /"T:" \+ \[Convert\]::ToBase64String/, 'the text flavour is base64, so newlines survive')
|
|
134
|
+
const parsed = parseClipboardRead([
|
|
135
|
+
'F:' + ['C:', 'Users', 'dev', 'Desktop', 'README.md'].join('\\'),
|
|
136
|
+
'F:' + ['', '', 'wsl.localhost', 'Ubuntu-24.04', 'home', 'user', 'AGENTS.md'].join('\\'),
|
|
137
|
+
`T:${Buffer.from('hello\nworld', 'utf8').toString('base64')}`,
|
|
138
|
+
].join('\r\n'))
|
|
139
|
+
assert.deepEqual(parsed.files, [
|
|
140
|
+
['C:', 'Users', 'dev', 'Desktop', 'README.md'].join('\\'),
|
|
141
|
+
['', '', 'wsl.localhost', 'Ubuntu-24.04', 'home', 'user', 'AGENTS.md'].join('\\'),
|
|
142
|
+
])
|
|
143
|
+
assert.equal(parsed.text, 'hello\nworld')
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
test('Windows clipboard paths map to paths this filesystem can import', () => {
|
|
147
|
+
const wslRoot = ['', '', 'wsl.localhost', 'Ubuntu-24.04'].join('\\')
|
|
148
|
+
const otherRoot = ['', '', 'wsl.localhost', 'OtherDistro'].join('\\')
|
|
149
|
+
const serverRoot = ['', '', 'server', 'share'].join('\\')
|
|
150
|
+
const mapped = clipboardPathsToLinux([
|
|
151
|
+
wslRoot + '\\' + ['home', 'user', 'AGENTS.md'].join('\\'),
|
|
152
|
+
['', '', 'wsl$', 'Ubuntu-24.04'].join('\\') + '\\' + ['tmp', 'a b.txt'].join('\\'),
|
|
153
|
+
['C:', 'Users', 'dev', 'Desktop', 'README.md'].join('\\'),
|
|
154
|
+
otherRoot + '\\' + ['home', 'x.txt'].join('\\'),
|
|
155
|
+
serverRoot + '\\' + 'x.txt',
|
|
156
|
+
'/already/linux',
|
|
157
|
+
'/already/linux',
|
|
158
|
+
], { distro: 'Ubuntu-24.04' })
|
|
159
|
+
assert.deepEqual(mapped, [
|
|
160
|
+
'/' + ['home', 'user', 'AGENTS.md'].join('/'),
|
|
161
|
+
'/' + ['tmp', 'a b.txt'].join('/'),
|
|
162
|
+
'/' + ['mnt', 'c', 'Users', 'dev', 'Desktop', 'README.md'].join('/'),
|
|
163
|
+
'/already/linux',
|
|
164
|
+
], 'a foreign distro or an SMB share is not visible here; duplicates collapse')
|
|
165
|
+
assert.deepEqual(clipboardPathsToLinux([]), [])
|
|
166
|
+
assert.deepEqual(clipboardPathsToLinux('not a list'), [])
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
test('reading the clipboard is a loopback-fenced GET, never a write', async () => {
|
|
170
|
+
const source = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
171
|
+
assert.match(source, /const CLIPBOARD_READ_PATH = `\$\{ROUTE_PREFIX\}\/clipboard\/read`/)
|
|
172
|
+
assert.match(source, /if \(pathname === CLIPBOARD_READ_PATH\) \{/, 'the dispatch knows the route')
|
|
173
|
+
assert.match(source, /message: 'GET only'/, 'only a read is allowed on it')
|
|
174
|
+
assert.match(source, /async function serveClipboardRead\(ctx, req, res\) \{[\s\S]{0,400}isLoopbackRequest\(req\)\) throw new TailError\('forbidden'/,
|
|
175
|
+
'the same loopback fence as the write route')
|
|
176
|
+
assert.match(source, /'macos-appkit'[\s\S]{0,2000}'linux-wl-paste'/, 'each platform reads the flavour it wrote')
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
test('a COPY is published from a hidden staging area, never from the originals', async () => {
|
|
180
|
+
const { mkdtemp, mkdir, writeFile, readFile, stat, readdir } = await import('node:fs/promises')
|
|
181
|
+
const { tmpdir } = await import('node:os')
|
|
182
|
+
const { join } = await import('node:path')
|
|
183
|
+
const root = await mkdtemp(join(tmpdir(), 'dsh-clip-'))
|
|
184
|
+
const sourceFile = join(root, 'AGENTS.md')
|
|
185
|
+
await writeFile(sourceFile, '# agents\n', 'utf8')
|
|
186
|
+
const folder = join(root, 'docs')
|
|
187
|
+
await mkdir(folder)
|
|
188
|
+
await writeFile(join(folder, 'note.txt'), 'note', 'utf8')
|
|
189
|
+
|
|
190
|
+
const stage = await stageClipboardCopy(root, [sourceFile, folder])
|
|
191
|
+
assert.notEqual(stage, null, 'staging succeeds inside one filesystem')
|
|
192
|
+
assert.equal(stage.staged.length, 2)
|
|
193
|
+
assert.deepEqual(stage.originals, [sourceFile, folder])
|
|
194
|
+
assert.ok(stage.staged[0].startsWith(join(root, CLIPBOARD_STAGE_DIR)), 'the copy lives under the hidden stage')
|
|
195
|
+
assert.notEqual(stage.staged[0], sourceFile, 'the clipboard points at the copy, not the original')
|
|
196
|
+
// A plain file is a HARDLINK: same inode, no extra bytes, originals untouched.
|
|
197
|
+
assert.equal((await stat(stage.staged[0])).ino, (await stat(sourceFile)).ino, 'files are hard-linked, not duplicated')
|
|
198
|
+
assert.equal(await readFile(stage.staged[0], 'utf8'), '# agents\n')
|
|
199
|
+
assert.equal(await readFile(sourceFile, 'utf8'), '# agents\n', 'the original is still there')
|
|
200
|
+
// A directory cannot be hard-linked, but each FILE inside it is: the staged tree
|
|
201
|
+
// is a mirror of names, so a big folder costs inodes instead of bytes.
|
|
202
|
+
assert.equal((await stat(stage.staged[1])).isDirectory(), true)
|
|
203
|
+
assert.equal((await stat(join(stage.staged[1], 'note.txt'))).ino, (await stat(join(folder, 'note.txt'))).ino,
|
|
204
|
+
'files inside a staged folder are hard links too')
|
|
205
|
+
assert.equal(await readFile(join(stage.staged[1], 'note.txt'), 'utf8'), 'note')
|
|
206
|
+
assert.equal(await readFile(join(folder, 'note.txt'), 'utf8'), 'note')
|
|
207
|
+
|
|
208
|
+
// The manifest translates a staged path back to the original: Ctrl+C → Ctrl+V
|
|
209
|
+
// inside the tree must keep looking like the original selection.
|
|
210
|
+
const mapping = await clipboardStageMapping(root)
|
|
211
|
+
assert.equal(mapping.get(stage.staged[0]), sourceFile)
|
|
212
|
+
assert.equal(mapping.get(stage.staged[1]), folder)
|
|
213
|
+
|
|
214
|
+
// Old batches are pruned: the staging area cannot grow without bound.
|
|
215
|
+
for (let index = 0; index < 5; index += 1) await stageClipboardCopy(root, [sourceFile])
|
|
216
|
+
await pruneClipboardStage(root)
|
|
217
|
+
const batches = (await readdir(join(root, CLIPBOARD_STAGE_DIR), { withFileTypes: true }))
|
|
218
|
+
.filter((entry) => entry.isDirectory())
|
|
219
|
+
assert.ok(batches.length <= 3, 'only the recent batches survive')
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
test('only a COPY is staged; a cut still publishes the real file', async () => {
|
|
223
|
+
const source = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
224
|
+
assert.match(source, /if \(body\.cut !== true\) \{[\s\S]{0,600}stageClipboardCopy\(root, paths\)/,
|
|
225
|
+
'copy goes through the staging area')
|
|
226
|
+
assert.match(source, /published = stage\.staged/, 'the clipboard gets the staged paths, not the originals')
|
|
227
|
+
assert.match(source, /const mapping = await clipboardStageMapping\(root\)/, 'a read translates staged paths back')
|
|
228
|
+
assert.match(source, /files\.map\(\(path\) => mapping\.get\(resolve\(path\)\) \?\? path\)/)
|
|
229
|
+
assert.match(source, /if \(dirent\.name === IDE_STATE_DIR\) continue/, 'the state folder (trash/cache/stage) is never a tree row')
|
|
230
|
+
assert.match(source, /'\.dsh-ris-ide',/, 'the watcher ignores its churn')
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
test('the copy route reads the workspace scope the page actually sends', async () => {
|
|
234
|
+
const source = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
235
|
+
// The page builds `?sessionId&cwd` (see `clipboardQuery`). Reading only the JSON
|
|
236
|
+
// body made every real copy fail with "复制到系统剪贴板需要 sessionId".
|
|
237
|
+
assert.match(source, /const scope = clipboardScope\(body, url\)/, 'the route parses the query string')
|
|
238
|
+
assert.match(source, /const root = clipboardRoot\(ctx, scope\.sessionId, scope\.cwd\)/, 'the scope feeds the staging root')
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
test('a copy that cannot be staged fails instead of publishing the originals', async () => {
|
|
242
|
+
const source = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
243
|
+
// The old shape — stage, and on failure quietly hand out the real paths — is the
|
|
244
|
+
// silent downgrade that lets Explorer move files out of the workspace.
|
|
245
|
+
assert.equal(/stage === null[\s\S]{0,160}published = paths/.test(source), false,
|
|
246
|
+
'no silent fallback to the originals')
|
|
247
|
+
assert.equal(/stageClipboardCopy\(root, paths\)\n\s+if \(stage === null\)/.test(source), false)
|
|
248
|
+
assert.match(source, /超过 \$\{megabytes\} MB,已取消复制到系统剪贴板/, 'the toast stays short but says the copy was cancelled')
|
|
249
|
+
assert.match(source, /复制到系统剪贴板需要 sessionId/, 'without a workspace there is nothing to stage into')
|
|
250
|
+
// A real refusal is an error the page reports, not a "copied" toast.
|
|
251
|
+
const client = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
252
|
+
assert.match(client, /notify\('没能放到系统剪贴板:' \+ messageOf\(problem\)/)
|
|
253
|
+
assert.match(client, /if \(code === 'unsupported'\) \{/, 'only "no backend at all" still writes the paths as text')
|
|
254
|
+
})
|
package/test/host-tail.test.mjs
CHANGED
|
@@ -688,9 +688,20 @@ test('the start route launches a program through run-with-log.sh and stop termin
|
|
|
688
688
|
|
|
689
689
|
// ── User config: generate / drift / update ─────────────────────────────────
|
|
690
690
|
|
|
691
|
-
/**
|
|
691
|
+
/** Path of the workspace program config: inside the state folder, never a dotfile. */
|
|
692
|
+
function configPathOf(root) {
|
|
693
|
+
return join(root, '.dsh-ris-ide', 'config.json')
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/** Create the workspace state folder a config/settings fixture is written into. */
|
|
697
|
+
async function ensureStateDir(root) {
|
|
698
|
+
await mkdir(join(root, '.dsh-ris-ide'), { recursive: true })
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/** Write one `.dsh-ris-ide/config.json` fixture. */
|
|
692
702
|
async function writeConfig(root, doc) {
|
|
693
|
-
await
|
|
703
|
+
await ensureStateDir(root)
|
|
704
|
+
await writeFile(configPathOf(root), JSON.stringify(doc, null, 2))
|
|
694
705
|
}
|
|
695
706
|
|
|
696
707
|
test('readProgramConfig tolerates JSONC and ignores invalid rows', async () => {
|
|
@@ -699,7 +710,8 @@ test('readProgramConfig tolerates JSONC and ignores invalid rows', async () => {
|
|
|
699
710
|
assert.equal(empty.exists, false)
|
|
700
711
|
assert.deepEqual(empty.entries, [])
|
|
701
712
|
|
|
702
|
-
await
|
|
713
|
+
await ensureStateDir(root)
|
|
714
|
+
await writeFile(configPathOf(root), `{
|
|
703
715
|
// a comment
|
|
704
716
|
"programs": [
|
|
705
717
|
{ "name": "ok", "dir": "proj-a/ui", "startCommand": "true", },
|
|
@@ -712,13 +724,61 @@ test('readProgramConfig tolerates JSONC and ignores invalid rows', async () => {
|
|
|
712
724
|
assert.equal(cfg.entries.length, 1)
|
|
713
725
|
assert.equal(cfg.entries[0].name, 'ok')
|
|
714
726
|
|
|
715
|
-
await writeFile(
|
|
727
|
+
await writeFile(configPathOf(root), '{ nope')
|
|
716
728
|
const broken = await readProgramConfig(root)
|
|
717
729
|
assert.equal(broken.exists, true)
|
|
718
730
|
assert.match(broken.error, /JSON/)
|
|
719
731
|
assert.deepEqual(broken.entries, [])
|
|
720
732
|
})
|
|
721
733
|
|
|
734
|
+
test('the plugin keeps ONE hidden folder: legacy dot-folders and dotfiles fold in', async () => {
|
|
735
|
+
const root = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-state-'))
|
|
736
|
+
await mkdir(join(root, '.dsh-ris-ide-trash'), { recursive: true })
|
|
737
|
+
await writeFile(join(root, '.dsh-ris-ide-trash', 'parked.txt'), 'parked')
|
|
738
|
+
await mkdir(join(root, '.dsh-ris-ide-cache', 'sources'), { recursive: true })
|
|
739
|
+
await writeFile(join(root, '.dsh-ris-ide-cache', 'sources', 'A.java'), 'class A {}')
|
|
740
|
+
await writeFile(join(root, '.dsh-ris-ide.json'), JSON.stringify({ version: 1, programs: [] }))
|
|
741
|
+
await writeFile(join(root, '.dsh-ris-ide.settings.json'), JSON.stringify({ decompiler: { jar: '/opt/cfr/cfr.jar' } }))
|
|
742
|
+
|
|
743
|
+
const tree = await __test.listIdeTree(root, root)
|
|
744
|
+
assert.equal(tree.entries.some((entry) => entry.name === '.dsh-ris-ide'), false, 'the state folder is never a tree row')
|
|
745
|
+
assert.equal(tree.entries.some((entry) => entry.name === '.dsh-ris-ide.json'), false, 'nor the legacy config dotfile')
|
|
746
|
+
|
|
747
|
+
assert.equal(await readFile(join(root, '.dsh-ris-ide', 'trash', 'parked.txt'), 'utf8'), 'parked', 'a parked delete survives the move')
|
|
748
|
+
assert.equal(await readFile(join(root, '.dsh-ris-ide', 'cache', 'sources', 'A.java'), 'utf8'), 'class A {}')
|
|
749
|
+
assert.equal(existsSync(join(root, '.dsh-ris-ide', 'config.json')), true, 'the legacy config moved into the folder')
|
|
750
|
+
assert.equal(existsSync(join(root, '.dsh-ris-ide', 'settings.json')), true, 'and so did the settings file')
|
|
751
|
+
assert.equal(existsSync(join(root, '.dsh-ris-ide-trash')), false, 'the legacy folder is gone')
|
|
752
|
+
assert.equal(existsSync(join(root, '.dsh-ris-ide.json')), false, 'the legacy config dotfile is gone')
|
|
753
|
+
assert.equal(existsSync(join(root, '.dsh-ris-ide.settings.json')), false, 'the legacy settings dotfile is gone')
|
|
754
|
+
|
|
755
|
+
// A newer file at the new location wins: a legacy one is left alone, never overwritten.
|
|
756
|
+
await writeFile(configPathOf(root), JSON.stringify({ version: 1, programs: [] }))
|
|
757
|
+
const legacyAgain = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-legacy-'))
|
|
758
|
+
await mkdir(join(root, '.dsh-ris-ide'), { recursive: true })
|
|
759
|
+
assert.equal(existsSync(configPathOf(root)), true)
|
|
760
|
+
await rm(legacyAgain, { recursive: true, force: true })
|
|
761
|
+
})
|
|
762
|
+
|
|
763
|
+
test('a legacy entry that collides with a newer one is parked, never dropped', async () => {
|
|
764
|
+
const root = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-state-collide-'))
|
|
765
|
+
await mkdir(join(root, '.dsh-ris-ide', 'trash'), { recursive: true })
|
|
766
|
+
await writeFile(join(root, '.dsh-ris-ide', 'trash', 'parked.txt'), 'newer')
|
|
767
|
+
await mkdir(join(root, '.dsh-ris-ide-trash'), { recursive: true })
|
|
768
|
+
await writeFile(join(root, '.dsh-ris-ide-trash', 'parked.txt'), 'legacy')
|
|
769
|
+
|
|
770
|
+
await __test.listIdeTree(root, root)
|
|
771
|
+
|
|
772
|
+
const trash = join(root, '.dsh-ris-ide', 'trash')
|
|
773
|
+
assert.equal(await readFile(join(trash, 'parked.txt'), 'utf8'), 'newer', 'the newer file keeps the plain name')
|
|
774
|
+
const { readdir } = await import('node:fs/promises')
|
|
775
|
+
const parked = (await readdir(trash)).filter((name) => name.startsWith('parked.txt-legacy-'))
|
|
776
|
+
assert.equal(parked.length, 1, 'the older file is kept under a suffixed name')
|
|
777
|
+
assert.equal(await readFile(join(trash, parked[0]), 'utf8'), 'legacy', 'and its bytes survive')
|
|
778
|
+
assert.equal(existsSync(join(root, '.dsh-ris-ide-trash')), false, 'the legacy folder goes away once it is empty')
|
|
779
|
+
await rm(root, { recursive: true, force: true })
|
|
780
|
+
})
|
|
781
|
+
|
|
722
782
|
test('mergeProgramConfig applies user fields, adds manual programs and honors disabled', async () => {
|
|
723
783
|
const { root } = await makeProgramFixture()
|
|
724
784
|
const logsDir = join(root, 'logs')
|
|
@@ -804,7 +864,7 @@ test('the config route generates, refuses to clobber and updates in place', asyn
|
|
|
804
864
|
const firstBody = await first.json()
|
|
805
865
|
assert.equal(firstBody.ok, true)
|
|
806
866
|
assert.equal(firstBody.count, 2)
|
|
807
|
-
const configPath =
|
|
867
|
+
const configPath = configPathOf(root)
|
|
808
868
|
assert.equal(existsSync(configPath), true)
|
|
809
869
|
const text = await readFile(configPath, 'utf8')
|
|
810
870
|
assert.match(text, /dsh-ris-ide 程序配置/, 'the generated file carries a header comment')
|
|
@@ -835,7 +895,8 @@ test('the config route generates, refuses to clobber and updates in place', asyn
|
|
|
835
895
|
|
|
836
896
|
test('the programs route reports config drift, and start honors startCommand/logName/grace', async () => {
|
|
837
897
|
const { root } = await makeStartableFixture()
|
|
838
|
-
await
|
|
898
|
+
await ensureStateDir(root)
|
|
899
|
+
await writeFile(configPathOf(root), JSON.stringify({
|
|
839
900
|
version: 1,
|
|
840
901
|
programs: [{
|
|
841
902
|
name: 'tick-app',
|
|
@@ -855,7 +916,7 @@ test('the programs route reports config drift, and start honors startCommand/log
|
|
|
855
916
|
assert.equal(listing.config.status, 'updated', 'a forced rescan reconciles the config')
|
|
856
917
|
assert.equal(listing.config.drift.reconciled, true)
|
|
857
918
|
assert.equal(listing.programs.some((entry) => entry.name === 'ui-2'), true, 'the new program is listed')
|
|
858
|
-
assert.equal((await readFile(
|
|
919
|
+
assert.equal((await readFile(configPathOf(root), 'utf8')).includes('ui-2'), true, 'and written into the config')
|
|
859
920
|
|
|
860
921
|
const program = listing.programs.find((entry) => entry.name === 'tick-app')
|
|
861
922
|
assert.equal(program.logName, 'custom-tick', 'the config logName wins')
|
|
@@ -1024,7 +1085,8 @@ test('stopping a wrapped command kills its whole process group (pnpm-style grand
|
|
|
1024
1085
|
|
|
1025
1086
|
test('a start whose command dies immediately fails loudly, with the log tail', async () => {
|
|
1026
1087
|
const { root } = await makeStartableFixture()
|
|
1027
|
-
await
|
|
1088
|
+
await ensureStateDir(root)
|
|
1089
|
+
await writeFile(configPathOf(root), JSON.stringify({
|
|
1028
1090
|
version: 1,
|
|
1029
1091
|
programs: [{
|
|
1030
1092
|
name: 'tick-app',
|
|
@@ -1197,7 +1259,7 @@ test('the programs route generates a config on first open, then only touches it
|
|
|
1197
1259
|
await withServer(async ({ base }) => {
|
|
1198
1260
|
const first = await (await fetch(`${base}${PROGRAMS_PATH}?sessionId=s1`)).json()
|
|
1199
1261
|
assert.equal(first.config.status, 'generated', 'no config ⇒ scan + write one')
|
|
1200
|
-
const configPath =
|
|
1262
|
+
const configPath = configPathOf(root)
|
|
1201
1263
|
assert.equal(existsSync(configPath), true)
|
|
1202
1264
|
const generated = parseJsonc(await readFile(configPath, 'utf8'))
|
|
1203
1265
|
const spring = generated.programs.find((entry) => entry.kind === 'spring')
|
|
@@ -1281,7 +1343,7 @@ test('the generated config documents jvmArgs, and an update keeps the user defau
|
|
|
1281
1343
|
assert.deepEqual(spring.jvmArgs, [], 'every entry carries an editable jvmArgs list')
|
|
1282
1344
|
|
|
1283
1345
|
await withServer(async ({ base }) => {
|
|
1284
|
-
const configPath =
|
|
1346
|
+
const configPath = configPathOf(root)
|
|
1285
1347
|
const post = (body) => fetch(`${base}${CONFIG_PATH}`, {
|
|
1286
1348
|
method: 'POST',
|
|
1287
1349
|
headers: { 'content-type': 'application/json' },
|
|
@@ -2074,6 +2136,7 @@ test('filter=all shows gitignored files, the default hides them', async () => {
|
|
|
2074
2136
|
assert.ok(filteredNames.includes('visible.txt'))
|
|
2075
2137
|
assert.equal(filteredNames.includes('secret.txt'), false, 'the default hides gitignored files')
|
|
2076
2138
|
assert.equal(filteredNames.includes('ignored-dir'), false)
|
|
2139
|
+
assert.equal(filteredNames.includes('.git'), false, 'git metadata is filtered too')
|
|
2077
2140
|
assert.equal(filtered.git, true, 'the client needs to know git is what is filtering')
|
|
2078
2141
|
assert.equal(filtered.filtered, true)
|
|
2079
2142
|
|
|
@@ -2082,8 +2145,15 @@ test('filter=all shows gitignored files, the default hides them', async () => {
|
|
|
2082
2145
|
const allNames = all.entries.map((entry) => entry.name)
|
|
2083
2146
|
assert.ok(allNames.includes('secret.txt'))
|
|
2084
2147
|
assert.ok(allNames.includes('ignored-dir'))
|
|
2148
|
+
assert.ok(allNames.includes('.git'), '"show everything" keeps the .git row')
|
|
2085
2149
|
assert.equal(all.filtered, false)
|
|
2086
2150
|
assert.equal(all.git, true, 'git is still available, so the toggle can be turned back on')
|
|
2151
|
+
|
|
2152
|
+
// A nested repo is listed through its own root; `.git` is metadata there too.
|
|
2153
|
+
await mkdir(join(dir, 'nested'), { recursive: true })
|
|
2154
|
+
execFileSync('git', ['init', '-q'], { cwd: join(dir, 'nested') })
|
|
2155
|
+
const nested = await __test.listIdeTree(join(dir, 'nested'), dir)
|
|
2156
|
+
assert.equal(nested.entries.map((entry) => entry.name).includes('.git'), false, 'a nested repo hides its own .git')
|
|
2087
2157
|
})
|
|
2088
2158
|
|
|
2089
2159
|
// ── the tree topic: filesystem changes reach the browser without a manual ⟳ ──
|
|
@@ -2406,11 +2476,11 @@ test('the undo trash is never a tree row and move honours an explicit name', asy
|
|
|
2406
2476
|
await __test.serveFsOp({ sessions: { get: () => ({ header: { cwd: dir } }) } }, req, res, {})
|
|
2407
2477
|
return { status: res.status, body: JSON.parse(chunks.join('') || 'null') }
|
|
2408
2478
|
}
|
|
2409
|
-
await op('fs/mkdir', { sessionId: 's1', path: join(dir, '.dsh-ris-ide
|
|
2410
|
-
const parked = await op('fs/move', { sessionId: 's1', from: join(dir, 'src', 'A.java'), toDir: join(dir, '.dsh-ris-ide
|
|
2479
|
+
await op('fs/mkdir', { sessionId: 's1', path: join(dir, '.dsh-ris-ide', 'trash') })
|
|
2480
|
+
const parked = await op('fs/move', { sessionId: 's1', from: join(dir, 'src', 'A.java'), toDir: join(dir, '.dsh-ris-ide', 'trash'), name: '1730-A.java' })
|
|
2411
2481
|
assert.equal(parked.status, 200)
|
|
2412
|
-
assert.equal(parked.body.path, join(dir, '.dsh-ris-ide
|
|
2413
|
-
const restored = await op('fs/move', { sessionId: 's1', from: join(dir, '.dsh-ris-ide
|
|
2482
|
+
assert.equal(parked.body.path, join(dir, '.dsh-ris-ide', 'trash', '1730-A.java'))
|
|
2483
|
+
const restored = await op('fs/move', { sessionId: 's1', from: join(dir, '.dsh-ris-ide', 'trash', '1730-A.java'), toDir: join(dir, 'src'), name: 'A.java' })
|
|
2414
2484
|
assert.equal(restored.status, 200)
|
|
2415
2485
|
assert.equal(restored.body.path, join(dir, 'src', 'A.java'))
|
|
2416
2486
|
assert.equal((await readdir(join(dir, 'src'))).includes('A.java'), true)
|
|
@@ -2420,7 +2490,7 @@ test('the undo trash is never a tree row and move honours an explicit name', asy
|
|
|
2420
2490
|
|
|
2421
2491
|
// ── file-tree mutations (menu / shortcuts / drag&drop) ─────────────────────
|
|
2422
2492
|
test('fs op routes create, copy, move and remove without clobbering', async () => {
|
|
2423
|
-
const { mkdtemp, mkdir, readdir, readFile, writeFile: write } = await import('node:fs/promises')
|
|
2493
|
+
const { mkdtemp, mkdir, readdir, readFile, rm, writeFile: write } = await import('node:fs/promises')
|
|
2424
2494
|
const { tmpdir } = await import('node:os')
|
|
2425
2495
|
const { join } = await import('node:path')
|
|
2426
2496
|
const { Readable } = await import('node:stream')
|
|
@@ -2462,6 +2532,11 @@ test('fs op routes create, copy, move and remove without clobbering', async () =
|
|
|
2462
2532
|
assert.equal(await readFile(join(copyDir, 'Demo.java'), 'utf8'), 'class Demo {}')
|
|
2463
2533
|
// …and a second copy refuses the collision
|
|
2464
2534
|
assert.equal((await call('fs/copy', { sessionId: 's1', cwd: dir, from: join(pkgDir, 'Demo.java'), toDir: copyDir })).status, 409)
|
|
2535
|
+
// A destination given as a FILE means its folder — the tree hands over the
|
|
2536
|
+
// selected row, and "copy next to this file" is what a user means there.
|
|
2537
|
+
const besideCopy = await call('fs/copy', { sessionId: 's1', cwd: dir, from: join(pkgDir, 'Demo.java'), toDir: join(copyDir, 'Demo.java'), name: 'Beside.java' })
|
|
2538
|
+
assert.equal(besideCopy.status, 200)
|
|
2539
|
+
assert.equal(await readFile(join(copyDir, 'Beside.java'), 'utf8'), 'class Demo {}')
|
|
2465
2540
|
|
|
2466
2541
|
// move
|
|
2467
2542
|
const movedDir = join(dir, 'moved')
|
|
@@ -2478,6 +2553,26 @@ test('fs op routes create, copy, move and remove without clobbering', async () =
|
|
|
2478
2553
|
|
|
2479
2554
|
// the workspace root is never a legal mutation target
|
|
2480
2555
|
assert.equal((await call('fs/mkdir', { sessionId: 's1', cwd: dir, path: dir })).status, 409)
|
|
2556
|
+
|
|
2557
|
+
// A path is only a string from the page: a mutation never leaves the tree
|
|
2558
|
+
// root, so `../` (or an absolute path outside) cannot widen a delete.
|
|
2559
|
+
const escape = join(dir, '..', 'escape-me.txt')
|
|
2560
|
+
await write(escape, 'outside')
|
|
2561
|
+
const escaped = await call('fs/remove', { sessionId: 's1', cwd: dir, path: escape, recursive: true })
|
|
2562
|
+
assert.equal(escaped.status, 403)
|
|
2563
|
+
assert.equal(await readFile(escape, 'utf8'), 'outside', 'the outside file survives the attempt')
|
|
2564
|
+
await rm(escape, { force: true })
|
|
2565
|
+
assert.equal((await call('fs/copy', { sessionId: 's1', cwd: dir, from: join(pkgDir, 'Demo.java'), toDir: join(dir, '..') })).status, 403)
|
|
2566
|
+
|
|
2567
|
+
// Special characters are just characters: no shell ever sees this name, and
|
|
2568
|
+
// removing it leaves every sibling alone.
|
|
2569
|
+
const odd = join(copyDir, "; rm -rf * $(id) 'quoted' & echo.txt")
|
|
2570
|
+
await write(odd, 'safe')
|
|
2571
|
+
await write(join(copyDir, 'neighbour.txt'), 'keep')
|
|
2572
|
+
assert.equal((await call('fs/remove', { sessionId: 's1', cwd: dir, path: odd })).status, 200)
|
|
2573
|
+
assert.equal(await readFile(join(copyDir, 'neighbour.txt'), 'utf8'), 'keep')
|
|
2574
|
+
// …and a control character in a name is refused outright
|
|
2575
|
+
assert.equal((await call('fs/create', { sessionId: 's1', cwd: dir, path: join(copyDir, 'bad\nname.txt') })).status, 400)
|
|
2481
2576
|
})
|
|
2482
2577
|
|
|
2483
2578
|
test('pasted OS files upload and import into the tree', async () => {
|
|
@@ -2533,6 +2628,15 @@ test('pasted OS files upload and import into the tree', async () => {
|
|
|
2533
2628
|
assert.equal((await upload({ sessionId: 's1', cwd: dir, dir, name: 'pasted.bin', overwrite: '1' }, 'new')).status, 200)
|
|
2534
2629
|
assert.equal(await readFile(target, 'utf8'), 'new')
|
|
2535
2630
|
|
|
2631
|
+
// A paste aimed AT a file lands in that file's folder instead of failing: the
|
|
2632
|
+
// tree can hand over the selected file row as the destination.
|
|
2633
|
+
const besideUpload = await upload({ sessionId: 's1', cwd: dir, dir: target, name: 'beside.bin' }, 'b')
|
|
2634
|
+
assert.equal(besideUpload.status, 200)
|
|
2635
|
+
assert.equal(await readFile(join(dir, 'beside.bin'), 'utf8'), 'b')
|
|
2636
|
+
// …but a destination that does not exist is still refused
|
|
2637
|
+
const nowhere = await upload({ sessionId: 's1', cwd: dir, dir: join(dir, 'nope'), name: 'x.bin' }, 'x')
|
|
2638
|
+
assert.equal(nowhere.status, 400)
|
|
2639
|
+
|
|
2536
2640
|
// A path copied outside the workspace is imported in (the destination stays guarded).
|
|
2537
2641
|
const sourceFile = join(outside, 'notes.md')
|
|
2538
2642
|
await writeFile(sourceFile, '# hi\n')
|
|
@@ -2541,8 +2645,19 @@ test('pasted OS files upload and import into the tree', async () => {
|
|
|
2541
2645
|
assert.equal(await readFile(join(dir, 'notes.md'), 'utf8'), '# hi\n')
|
|
2542
2646
|
assert.equal((await importPath({ sessionId: 's1', cwd: dir, from: sourceFile, dir })).status, 409)
|
|
2543
2647
|
assert.equal((await importPath({ sessionId: 's1', cwd: dir, from: sourceFile, dir, overwrite: true })).status, 200)
|
|
2648
|
+
// the same file→folder rule governs a copied path
|
|
2649
|
+
const besideImport = await importPath({ sessionId: 's1', cwd: dir, from: sourceFile, dir: target, name: 'notes-beside.md' })
|
|
2650
|
+
assert.equal(besideImport.status, 200)
|
|
2651
|
+
assert.equal(await readFile(join(dir, 'notes-beside.md'), 'utf8'), '# hi\n')
|
|
2544
2652
|
// …and a leaf name can never escape the destination directory
|
|
2545
2653
|
assert.equal((await importPath({ sessionId: 's1', cwd: dir, from: sourceFile, dir, name: '../evil.md' })).status, 400)
|
|
2654
|
+
// The DESTINATION is guarded too: an overwrite paste (which removes the
|
|
2655
|
+
// colliding entry) can never be aimed at a directory outside the tree.
|
|
2656
|
+
assert.equal((await importPath({ sessionId: 's1', cwd: dir, from: sourceFile, dir: outside, name: 'notes.md', overwrite: true })).status, 403)
|
|
2657
|
+
assert.equal(await readFile(sourceFile, 'utf8'), '# hi\n', 'nothing outside the tree was touched')
|
|
2658
|
+
// A control character never reaches a file name (it would corrupt every
|
|
2659
|
+
// line-oriented protocol downstream).
|
|
2660
|
+
assert.equal((await upload({ sessionId: 's1', cwd: dir, dir, name: 'bad\nname.bin' }, 'x')).status, 400)
|
|
2546
2661
|
})
|
|
2547
2662
|
|
|
2548
2663
|
// ── the debug stream: a page reload must still show its pre-set breakpoints ──
|
|
@@ -2666,7 +2781,7 @@ test('a dependency class resolves from its sources.jar into the workspace cache'
|
|
|
2666
2781
|
assert.ok(resolved !== undefined, 'the sources.jar entry is found')
|
|
2667
2782
|
assert.equal(resolved.kind, 'sources')
|
|
2668
2783
|
assert.equal(resolved.jar, sources)
|
|
2669
|
-
assert.equal(resolved.path, join(cwd, '.dsh-ris-ide
|
|
2784
|
+
assert.equal(resolved.path, join(cwd, '.dsh-ris-ide', 'cache', 'sources', 'pkg.Dep.java'))
|
|
2670
2785
|
const text = await (await import('node:fs/promises')).readFile(resolved.path, 'utf8')
|
|
2671
2786
|
assert.match(text, /public class Dep/)
|
|
2672
2787
|
|
|
@@ -2702,7 +2817,7 @@ test('a rebuilt jar invalidates the cached dependency source', async () => {
|
|
|
2702
2817
|
assert.match(await read(again.path, 'utf8'), /rebuilt/)
|
|
2703
2818
|
assert.ok((await stat(again.path)).mtimeMs > firstInfo.mtimeMs)
|
|
2704
2819
|
|
|
2705
|
-
const manifest = await __test.readCacheManifest(join(cwd, '.dsh-ris-ide
|
|
2820
|
+
const manifest = await __test.readCacheManifest(join(cwd, '.dsh-ris-ide', 'cache'))
|
|
2706
2821
|
assert.equal(manifest.entries['sources/pkg.Dep.java'].kind, 'sources')
|
|
2707
2822
|
})
|
|
2708
2823
|
|
|
@@ -2711,7 +2826,7 @@ test('the dependency cache prunes aged and oversized entries', async () => {
|
|
|
2711
2826
|
const { tmpdir } = await import('node:os')
|
|
2712
2827
|
const { join } = await import('node:path')
|
|
2713
2828
|
const cwd = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-gc-'))
|
|
2714
|
-
const root = join(cwd, '.dsh-ris-ide
|
|
2829
|
+
const root = join(cwd, '.dsh-ris-ide', 'cache')
|
|
2715
2830
|
const dir = join(root, 'sources')
|
|
2716
2831
|
await mkdir(dir, { recursive: true })
|
|
2717
2832
|
const writeOne = async (name, text, ageMs) => {
|
|
@@ -2760,16 +2875,16 @@ test('the visual debug settings persist the decompiler jar without touching the
|
|
|
2760
2875
|
}, posted.res, {})
|
|
2761
2876
|
assert.equal(posted.res.status, 200)
|
|
2762
2877
|
assert.equal(posted.json().decompiler.jar, '/opt/cfr/cfr.jar')
|
|
2763
|
-
const settingsPath = join(dir, '.dsh-ris-ide
|
|
2878
|
+
const settingsPath = join(dir, '.dsh-ris-ide', 'settings.json')
|
|
2764
2879
|
const saved = JSON.parse(await read(settingsPath, 'utf8'))
|
|
2765
2880
|
assert.deepEqual(saved.decompiler, { jar: '/opt/cfr/cfr.jar', args: ['{classfile}'] })
|
|
2766
|
-
assert.equal(await read(join(dir, '.dsh-ris-ide.json'), 'utf8').catch(() => undefined), undefined, 'the program config stays untouched')
|
|
2881
|
+
assert.equal(await read(join(dir, '.dsh-ris-ide', 'config.json'), 'utf8').catch(() => undefined), undefined, 'the program config stays untouched')
|
|
2767
2882
|
|
|
2768
2883
|
const got = answer()
|
|
2769
2884
|
await __test.serveSettings(ctx, { method: 'GET', headers: { host: '127.0.0.1:3080' }, url: '/dsh-ris-ide/settings?sessionId=s1' }, got.res, {})
|
|
2770
2885
|
assert.equal(got.res.status, 200)
|
|
2771
2886
|
assert.equal(got.json().decompiler.jar, '/opt/cfr/cfr.jar')
|
|
2772
|
-
assert.equal(got.json().cacheDir, join(dir, '.dsh-ris-ide
|
|
2887
|
+
assert.equal(got.json().cacheDir, join(dir, '.dsh-ris-ide', 'cache'))
|
|
2773
2888
|
|
|
2774
2889
|
// Clearing the field removes the key from the settings file.
|
|
2775
2890
|
const cleared = answer()
|