dsh-ris-ide 1.8.1 → 1.8.2
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 +2 -2
- package/lib/client.js +311 -72
- package/lib/debug/vendor/README.md +14 -0
- package/lib/debug/vendor/jdwp/client.js +9 -4
- package/lib/debug/vendor/src/jdwp/client.ts +12 -5
- package/lib/index.js +794 -48
- package/lib/redirector.js +42 -2
- package/lib/risd/lifecycle.js +9 -3
- package/lib/risd/server.js +308 -13
- package/lib/risd/ui.js +149 -112
- package/lib/risd-client.js +4 -1
- package/lib/startup.js +27 -7
- package/package.json +2 -2
- package/test/client-viewer.test.mjs +188 -95
- package/test/clipboard.test.mjs +259 -0
- package/test/debug-engine.test.mjs +3 -1
- package/test/dsh-origin.test.mjs +4 -11
- package/test/dsh-window-refresh.test.mjs +166 -1
- package/test/harness.test.mjs +1 -1
- package/test/helpers/cmd.mjs +29 -0
- package/test/helpers/tgz.mjs +71 -0
- package/test/host-search.test.mjs +18 -11
- package/test/host-tail.test.mjs +119 -24
- package/test/proxy-route.test.mjs +61 -0
- package/test/proxy-window.test.mjs +5 -0
- package/test/proxy.test.mjs +13 -1
- package/test/proxybridge-bundle.test.mjs +1 -59
- package/test/redirector-bundle.test.mjs +21 -67
- package/test/redirector.test.mjs +41 -4
- package/test/risd-api.test.mjs +81 -28
- package/test/risd-bridge-degrade.test.mjs +3 -29
- package/test/risd-engine.test.mjs +13 -50
- package/test/risd-entry.test.mjs +0 -37
- package/test/risd-follow-start.test.mjs +101 -0
- package/test/risd-git.test.mjs +7 -5
- package/test/risd-handoff.test.mjs +6 -50
- package/test/risd-helpers.mjs +150 -3
- package/test/risd-host-p2.test.mjs +2 -30
- package/test/risd-lifecycle.test.mjs +25 -0
- package/test/risd-programs.test.mjs +4 -34
- package/test/risd-review-p2.test.mjs +0 -13
- package/test/risd-shutdown.test.mjs +5 -38
- package/test/risd-teardown.test.mjs +8 -27
- package/test/risd-ui.test.mjs +169 -13
- package/test/risd-write.test.mjs +2 -1
- package/test/startup-reconcile.test.mjs +44 -8
- package/test/proxy-restart.test.mjs +0 -39
|
@@ -19,6 +19,7 @@ import { tmpdir } from 'node:os'
|
|
|
19
19
|
import { join } from 'node:path'
|
|
20
20
|
|
|
21
21
|
import { __test } from '../lib/index.js'
|
|
22
|
+
import { HAS_BASH, HAS_GIT, skipWithout } from './helpers/cmd.mjs'
|
|
22
23
|
|
|
23
24
|
const {
|
|
24
25
|
handleRequest, searchWorkspaceContent,
|
|
@@ -80,14 +81,18 @@ async function makeRepoFixture(label) {
|
|
|
80
81
|
await writeFile(join(root, 'a.txt'), 'alpha\nbeta\nneedle one\nneedle two\nneedle three\n')
|
|
81
82
|
await mkdir(join(root, 'sub'), { recursive: true })
|
|
82
83
|
await writeFile(join(root, 'sub', 'b.txt'), 'x needle deep\n')
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
// 没有 git 的机器(Jenkins 裸镜像)里这些 fixture 测试整体跳过;这里仍然守住,
|
|
85
|
+
// 免得某个没加 skip 的调用方直接抛 ENOENT。
|
|
86
|
+
if (HAS_GIT) {
|
|
87
|
+
execFileSync('git', ['init', '-q'], { cwd: root })
|
|
88
|
+
execFileSync('git', ['add', '-A'], { cwd: root })
|
|
89
|
+
}
|
|
85
90
|
return root
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
// ── Content search helper ───────────────────────────────────────────────────
|
|
89
94
|
|
|
90
|
-
test('searchWorkspaceContent returns literal git-grep hits with absolute path, line and text', async () => {
|
|
95
|
+
test('searchWorkspaceContent returns literal git-grep hits with absolute path, line and text', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
91
96
|
const root = await makeRepoFixture('content')
|
|
92
97
|
const { hits, truncated, roots, files } = await searchWorkspaceContent(root, 'needle', 300, 8)
|
|
93
98
|
assert.deepEqual(roots, [root])
|
|
@@ -104,7 +109,7 @@ test('searchWorkspaceContent returns literal git-grep hits with absolute path, l
|
|
|
104
109
|
assert.deepEqual(regexHit.hits, [])
|
|
105
110
|
})
|
|
106
111
|
|
|
107
|
-
test('searchWorkspaceContent honours perFile and answers an empty hit list for no match', async () => {
|
|
112
|
+
test('searchWorkspaceContent honours perFile and answers an empty hit list for no match', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
108
113
|
const root = await makeRepoFixture('cap')
|
|
109
114
|
const capped = await searchWorkspaceContent(root, 'needle', 300, 2)
|
|
110
115
|
const fromA = capped.hits.filter((hit) => hit.path === join(root, 'a.txt'))
|
|
@@ -132,7 +137,7 @@ test('searchWorkspaceContent falls back to a case-insensitive walk without a git
|
|
|
132
137
|
|
|
133
138
|
// ── Content search route ────────────────────────────────────────────────────
|
|
134
139
|
|
|
135
|
-
test('GET /search-content serves hits and rejects a missing q or the wrong method', async () => {
|
|
140
|
+
test('GET /search-content serves hits and rejects a missing q or the wrong method', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
136
141
|
const root = await makeRepoFixture('content-route')
|
|
137
142
|
await withServer(async ({ base }) => {
|
|
138
143
|
const response = await fetch(`${base}${CONTENT_SEARCH_PATH}?sessionId=s1&q=needle&perFile=2&limit=50`)
|
|
@@ -189,8 +194,10 @@ async function makeTwoRootFixture(label) {
|
|
|
189
194
|
await mkdir(dir, { recursive: true })
|
|
190
195
|
await writeFile(join(dir, 'agent-one.txt'), 'needle one\nsecond needle\n')
|
|
191
196
|
await writeFile(join(dir, 'other.txt'), 'nothing here\n')
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
if (HAS_GIT) {
|
|
198
|
+
execFileSync('git', ['init', '-q'], { cwd: dir })
|
|
199
|
+
execFileSync('git', ['add', '-A'], { cwd: dir })
|
|
200
|
+
}
|
|
194
201
|
}
|
|
195
202
|
return root
|
|
196
203
|
}
|
|
@@ -219,7 +226,7 @@ test('createOrderedPages spends the row budget in root order, not arrival order'
|
|
|
219
226
|
assert.deepEqual(pages, [['a1', 'a2'], ['a3']])
|
|
220
227
|
})
|
|
221
228
|
|
|
222
|
-
test('GET /search/stream pages the filename matches in tree order and ends with done', async () => {
|
|
229
|
+
test('GET /search/stream pages the filename matches in tree order and ends with done', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
223
230
|
const root = await makeTwoRootFixture('stream-name')
|
|
224
231
|
await withServer(async ({ base }) => {
|
|
225
232
|
const response = await fetch(`${base}${SEARCH_STREAM_PATH}?sessionId=s1&q=agent&pageSize=1&limit=10`)
|
|
@@ -243,7 +250,7 @@ test('GET /search/stream pages the filename matches in tree order and ends with
|
|
|
243
250
|
}, root)
|
|
244
251
|
})
|
|
245
252
|
|
|
246
|
-
test('GET /search-content/stream pages grep hits and keeps the batch validation', async () => {
|
|
253
|
+
test('GET /search-content/stream pages grep hits and keeps the batch validation', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
247
254
|
const root = await makeTwoRootFixture('stream-content')
|
|
248
255
|
await withServer(async ({ base }) => {
|
|
249
256
|
const response = await fetch(`${base}${CONTENT_SEARCH_STREAM_PATH}?sessionId=s1&q=needle&pageSize=1&limit=10`)
|
|
@@ -269,7 +276,7 @@ test('GET /search-content/stream pages grep hits and keeps the batch validation'
|
|
|
269
276
|
}, root)
|
|
270
277
|
})
|
|
271
278
|
|
|
272
|
-
test('GET /search/stream stops early at limit and reports truncated', async () => {
|
|
279
|
+
test('GET /search/stream stops early at limit and reports truncated', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
273
280
|
const root = await makeTwoRootFixture('stream-limit')
|
|
274
281
|
await withServer(async ({ base }) => {
|
|
275
282
|
const response = await fetch(`${base}${SEARCH_STREAM_PATH}?sessionId=s1&q=agent&pageSize=2&limit=1`)
|
|
@@ -476,7 +483,7 @@ async function makeStartableFixture() {
|
|
|
476
483
|
return root
|
|
477
484
|
}
|
|
478
485
|
|
|
479
|
-
test('POST /start with restart:true stops the running instance before starting a fresh one', async () => {
|
|
486
|
+
test('POST /start with restart:true stops the running instance before starting a fresh one', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
480
487
|
const root = await makeStartableFixture()
|
|
481
488
|
await withServer(async ({ base }) => {
|
|
482
489
|
const programs = (await (await fetch(`${base}${PROGRAMS_PATH}?sessionId=s1&refresh=1`)).json()).programs
|
package/test/host-tail.test.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import { dirname, join, resolve } from 'node:path'
|
|
|
17
17
|
import { fileURLToPath } from 'node:url'
|
|
18
18
|
|
|
19
19
|
import { __test } from '../lib/index.js'
|
|
20
|
+
import { HAS_BASH, HAS_GIT, skipWithout } from './helpers/cmd.mjs'
|
|
20
21
|
|
|
21
22
|
const {
|
|
22
23
|
resolvePath, isLoopbackRequest, readTail, clampBytes, serveTail, serveStop, handleRequest,
|
|
@@ -315,7 +316,8 @@ test('readService reads the pidfile and reports liveness', async () => {
|
|
|
315
316
|
await writeFile(log, 'x\n')
|
|
316
317
|
assert.equal(await readService(log), undefined, 'no pidfile means no service')
|
|
317
318
|
|
|
318
|
-
|
|
319
|
+
// 一个“活着的无关进程”用 node 自己起,不依赖 sleep 这类外部程序(CI 裸镜像里没有)。
|
|
320
|
+
const child = spawn(process.execPath, ['-e', 'setTimeout(() => {}, 30000)'], { stdio: 'ignore' })
|
|
319
321
|
try {
|
|
320
322
|
await writeFile(`${log}${PID_SUFFIX}`, `${child.pid} ${process.pid} 1700000000000\n`)
|
|
321
323
|
const service = await readService(log)
|
|
@@ -339,7 +341,7 @@ test('the stop route refuses a PID that is not the wrapper script', async () =>
|
|
|
339
341
|
await withServer(async ({ base, cwd }) => {
|
|
340
342
|
const log = join(cwd, 'fake.log')
|
|
341
343
|
await writeFile(log, 'x\n')
|
|
342
|
-
const child = spawn('
|
|
344
|
+
const child = spawn(process.execPath, ['-e', 'setTimeout(() => {}, 30000)'], { stdio: 'ignore' })
|
|
343
345
|
try {
|
|
344
346
|
await writeFile(`${log}${PID_SUFFIX}`, `${child.pid} ${child.pid} 1\n`)
|
|
345
347
|
const response = await post(base, { sessionId: 's1', path: log })
|
|
@@ -380,7 +382,7 @@ test('the stop route answers no-service without a pidfile and refuses a foreign
|
|
|
380
382
|
})
|
|
381
383
|
})
|
|
382
384
|
|
|
383
|
-
test('the stop route terminates a real run-with-log.sh service end to end', async () => {
|
|
385
|
+
test('the stop route terminates a real run-with-log.sh service end to end', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
384
386
|
// Generous TERM→KILL grace: under the full parallel suite the wrapper can take
|
|
385
387
|
// longer than 5 s to trap TERM, reap `sleep` and write its exit banner; a 5 s
|
|
386
388
|
// grace SIGKILLs it first and the banner assertion below then fails.
|
|
@@ -425,7 +427,7 @@ test('the stop route terminates a real run-with-log.sh service end to end', asyn
|
|
|
425
427
|
}, { maxBytes: HARD_MAX_BYTES, restrictToCwd: false, stopGraceMs: 15000, minFreeMemoryBytes: 1 })
|
|
426
428
|
})
|
|
427
429
|
|
|
428
|
-
test('listInstances finds a real run-with-log.sh service and reports it verified', async () => {
|
|
430
|
+
test('listInstances finds a real run-with-log.sh service and reports it verified', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
429
431
|
const logDir = join(scratch, 'instances-live')
|
|
430
432
|
const log = join(logDir, 'instlive.log')
|
|
431
433
|
const wrapper = spawn(WRAPPER, ['instlive', 'sleep', '60'], {
|
|
@@ -457,7 +459,7 @@ test('listInstances ignores junk pidfiles and orders live instances first', asyn
|
|
|
457
459
|
assert.deepEqual(await listInstances(logDir), [], 'junk and pidfile-less logs are not instances')
|
|
458
460
|
})
|
|
459
461
|
|
|
460
|
-
test('the instances route lists services and refuses a directory outside the session cwd', async () => {
|
|
462
|
+
test('the instances route lists services and refuses a directory outside the session cwd', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
461
463
|
await withServer(async ({ base, cwd }) => {
|
|
462
464
|
const logDir = join(cwd, 'logs')
|
|
463
465
|
const log = join(logDir, 'routetest.log')
|
|
@@ -667,7 +669,7 @@ test('the programs route scans over HTTP and the start route refuses bad input',
|
|
|
667
669
|
}, undefined, root)
|
|
668
670
|
})
|
|
669
671
|
|
|
670
|
-
test('the start route launches a program through run-with-log.sh and stop terminates it', async () => {
|
|
672
|
+
test('the start route launches a program through run-with-log.sh and stop terminates it', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
671
673
|
const { root } = await makeStartableFixture()
|
|
672
674
|
await withServer(async ({ base }) => {
|
|
673
675
|
const listing = await fetch(`${base}${PROGRAMS_PATH}?sessionId=s1&refresh=1`)
|
|
@@ -916,7 +918,7 @@ test('the config route generates, refuses to clobber and updates in place', asyn
|
|
|
916
918
|
}, undefined, root)
|
|
917
919
|
})
|
|
918
920
|
|
|
919
|
-
test('the programs route reports config drift, and start honors startCommand/logName/grace', async () => {
|
|
921
|
+
test('the programs route reports config drift, and start honors startCommand/logName/grace', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
920
922
|
const { root } = await makeStartableFixture()
|
|
921
923
|
await ensureStateDir(root)
|
|
922
924
|
await writeFile(configPathOf(root), JSON.stringify({
|
|
@@ -1011,7 +1013,7 @@ test('resolveProgramRef matches by id, exact name and a unique fragment', () =>
|
|
|
1011
1013
|
assert.throws(() => resolveProgramRef(programs, { name: '-biz' }), /matches/)
|
|
1012
1014
|
})
|
|
1013
1015
|
|
|
1014
|
-
test('the tools list, start, read and stop a program through the shared core', async () => {
|
|
1016
|
+
test('the tools list, start, read and stop a program through the shared core', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
1015
1017
|
const { root } = await makeStartableFixture()
|
|
1016
1018
|
const { ctx, tools } = toolCtx(root)
|
|
1017
1019
|
const dispose = registerAgentTools(ctx, {})
|
|
@@ -1076,7 +1078,7 @@ test('the opens route drains the queue exactly once', async () => {
|
|
|
1076
1078
|
|
|
1077
1079
|
// ── Regressions: stop must free the port; tool output must be lossless JSON ─
|
|
1078
1080
|
|
|
1079
|
-
test('stopping a wrapped command kills its whole process group (pnpm-style grandchildren)', async () => {
|
|
1081
|
+
test('stopping a wrapped command kills its whole process group (pnpm-style grandchildren)', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
1080
1082
|
// The reported bug: `pnpm run dev` does not forward SIGTERM, so stopping only
|
|
1081
1083
|
// the runner left vite holding its port. The wrapper is spawned detached
|
|
1082
1084
|
// (own group) exactly like the host does it.
|
|
@@ -1106,7 +1108,7 @@ test('stopping a wrapped command kills its whole process group (pnpm-style grand
|
|
|
1106
1108
|
}
|
|
1107
1109
|
})
|
|
1108
1110
|
|
|
1109
|
-
test('a start whose command dies immediately fails loudly, with the log tail', async () => {
|
|
1111
|
+
test('a start whose command dies immediately fails loudly, with the log tail', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
1110
1112
|
const { root } = await makeStartableFixture()
|
|
1111
1113
|
await ensureStateDir(root)
|
|
1112
1114
|
await writeFile(configPathOf(root), JSON.stringify({
|
|
@@ -1134,7 +1136,7 @@ test('a start whose command dies immediately fails loudly, with the log tail', a
|
|
|
1134
1136
|
)
|
|
1135
1137
|
})
|
|
1136
1138
|
|
|
1137
|
-
test('every ris_dev_* result is lossless JSON (no undefined values)', async () => {
|
|
1139
|
+
test('every ris_dev_* result is lossless JSON (no undefined values)', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
1138
1140
|
const assertJsonSafe = (value, path = '$') => {
|
|
1139
1141
|
if (value === undefined) assert.fail(`undefined at ${path}`)
|
|
1140
1142
|
if (Array.isArray(value)) value.forEach((item, index) => assertJsonSafe(item, `${path}[${index}]`))
|
|
@@ -1166,7 +1168,7 @@ test('every ris_dev_* result is lossless JSON (no undefined values)', async () =
|
|
|
1166
1168
|
})
|
|
1167
1169
|
|
|
1168
1170
|
|
|
1169
|
-
test('ris_dev_status answers "is it up?" and ris_dev_restart restarts in place', async () => {
|
|
1171
|
+
test('ris_dev_status answers "is it up?" and ris_dev_restart restarts in place', { skip: skipWithout(HAS_BASH, 'bash') }, async () => {
|
|
1170
1172
|
const { root } = await makeStartableFixture()
|
|
1171
1173
|
const { ctx, tools } = toolCtx(root)
|
|
1172
1174
|
const dispose = registerAgentTools(ctx, {})
|
|
@@ -1776,7 +1778,7 @@ test('PKG_VERSION tracks package.json', async () => {
|
|
|
1776
1778
|
|
|
1777
1779
|
|
|
1778
1780
|
// ── gitignore-aware, compact-folding IDE tree ───────────────────────────────
|
|
1779
|
-
test('listIdeTree hides ignored files and folds package chains only under java', async () => {
|
|
1781
|
+
test('listIdeTree hides ignored files and folds package chains only under java', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
1780
1782
|
const { mkdtemp, mkdir, writeFile, rm } = await import('node:fs/promises')
|
|
1781
1783
|
const { execFile } = await import('node:child_process')
|
|
1782
1784
|
const { promisify } = await import('node:util')
|
|
@@ -1846,7 +1848,7 @@ test('listIdeTree hides ignored files and folds package chains only under java',
|
|
|
1846
1848
|
}
|
|
1847
1849
|
})
|
|
1848
1850
|
|
|
1849
|
-
test('a CRLF .gitignore with a trailing blank line does not hide empty folders', async () => {
|
|
1851
|
+
test('a CRLF .gitignore with a trailing blank line does not hide empty folders', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
1850
1852
|
const { mkdtemp, mkdir, writeFile, rm } = await import('node:fs/promises')
|
|
1851
1853
|
const { execFile } = await import('node:child_process')
|
|
1852
1854
|
const { promisify } = await import('node:util')
|
|
@@ -1880,7 +1882,7 @@ test('a CRLF .gitignore with a trailing blank line does not hide empty folders',
|
|
|
1880
1882
|
}
|
|
1881
1883
|
})
|
|
1882
1884
|
|
|
1883
|
-
test('findGitRoot walks up to the repo, and an unversioned tree lists raw', async () => {
|
|
1885
|
+
test('findGitRoot walks up to the repo, and an unversioned tree lists raw', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
1884
1886
|
const { mkdtemp, mkdir, writeFile, rm } = await import('node:fs/promises')
|
|
1885
1887
|
const { execFile } = await import('node:child_process')
|
|
1886
1888
|
const { promisify } = await import('node:util')
|
|
@@ -2045,12 +2047,8 @@ test('readTailWindow pages backwards with abutting, whole-line windows', async (
|
|
|
2045
2047
|
assert.ok(pages > 2, 'this file needed several pages')
|
|
2046
2048
|
})
|
|
2047
2049
|
|
|
2048
|
-
test('the SSE stream route is advertised', () => {
|
|
2049
|
-
assert.equal(__test.STREAM_PATH, `${__test.ROUTE_PREFIX}/stream`)
|
|
2050
|
-
})
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
2050
|
test('the SSE stream pushes a tail snapshot, then append deltas', async () => {
|
|
2051
|
+
assert.equal(__test.STREAM_PATH, `${__test.ROUTE_PREFIX}/stream`)
|
|
2054
2052
|
const { mkdtemp, writeFile, appendFile } = await import('node:fs/promises')
|
|
2055
2053
|
const { tmpdir } = await import('node:os')
|
|
2056
2054
|
const { join } = await import('node:path')
|
|
@@ -2122,7 +2120,7 @@ test('a stale session id still answers when the client sends an absolute cwd', a
|
|
|
2122
2120
|
})
|
|
2123
2121
|
|
|
2124
2122
|
// ── a fresh tree read must show a file created after the last listing ──
|
|
2125
|
-
test('fresh=1 re-reads the git-visible set so a just-copied file appears', async () => {
|
|
2123
|
+
test('fresh=1 re-reads the git-visible set so a just-copied file appears', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
2126
2124
|
const { mkdtemp, writeFile } = await import('node:fs/promises')
|
|
2127
2125
|
const { tmpdir } = await import('node:os')
|
|
2128
2126
|
const { join } = await import('node:path')
|
|
@@ -2149,7 +2147,7 @@ test('fresh=1 re-reads the git-visible set so a just-copied file appears', async
|
|
|
2149
2147
|
assert.ok(fresh.includes('a - 副本.txt'), 'fresh=1 reveals it')
|
|
2150
2148
|
})
|
|
2151
2149
|
|
|
2152
|
-
test('filter=all shows gitignored files, the default hides them', async () => {
|
|
2150
|
+
test('filter=all shows gitignored files, the default hides them', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
2153
2151
|
const { mkdtemp, mkdir, writeFile } = await import('node:fs/promises')
|
|
2154
2152
|
const { tmpdir } = await import('node:os')
|
|
2155
2153
|
const { join } = await import('node:path')
|
|
@@ -2254,7 +2252,7 @@ test('the tree topic pushes changed relative paths from a recursive watch', asyn
|
|
|
2254
2252
|
|
|
2255
2253
|
|
|
2256
2254
|
// ── filename search must never answer "nothing" just because cwd is a subdir ──
|
|
2257
|
-
test('searchWorkspaceFiles climbs to the enclosing repo and falls back to a raw walk', async () => {
|
|
2255
|
+
test('searchWorkspaceFiles climbs to the enclosing repo and falls back to a raw walk', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
2258
2256
|
const { mkdtemp, mkdir, writeFile } = await import('node:fs/promises')
|
|
2259
2257
|
const { tmpdir } = await import('node:os')
|
|
2260
2258
|
const { join } = await import('node:path')
|
|
@@ -2522,7 +2520,7 @@ test('the bundle route serves the built CodeMirror chunk and refuses other names
|
|
|
2522
2520
|
|
|
2523
2521
|
|
|
2524
2522
|
// ── the watch filter must use the tree's own ignore rules (no git per event) ──
|
|
2525
|
-
test('treeWatchAccepts keeps visible files and drops gitignored churn', async () => {
|
|
2523
|
+
test('treeWatchAccepts keeps visible files and drops gitignored churn', { skip: skipWithout(HAS_GIT, 'git') }, async () => {
|
|
2526
2524
|
const { mkdtemp, mkdir, writeFile } = await import('node:fs/promises')
|
|
2527
2525
|
const { tmpdir } = await import('node:os')
|
|
2528
2526
|
const { join } = await import('node:path')
|
|
@@ -2755,6 +2753,103 @@ test('pasted OS files upload and import into the tree', async () => {
|
|
|
2755
2753
|
assert.equal((await upload({ sessionId: 's1', cwd: dir, dir, name: 'bad\nname.bin' }, 'x')).status, 400)
|
|
2756
2754
|
})
|
|
2757
2755
|
|
|
2756
|
+
/** One `/fs/*` request against a fake ctx, answered by the real route. */
|
|
2757
|
+
async function callFsOp(ctx, pathname, body) {
|
|
2758
|
+
const { Readable } = await import('node:stream')
|
|
2759
|
+
const chunks = []
|
|
2760
|
+
const res = {
|
|
2761
|
+
status: 0,
|
|
2762
|
+
writeHead(status, headers) { this.status = status; this.headers = headers },
|
|
2763
|
+
write(chunk) { chunks.push(String(chunk)); return true },
|
|
2764
|
+
end(chunk) { if (chunk !== undefined && chunk !== null) chunks.push(String(chunk)) },
|
|
2765
|
+
on() {},
|
|
2766
|
+
}
|
|
2767
|
+
const req = Object.assign(Readable.from([JSON.stringify(body)]), {
|
|
2768
|
+
method: 'POST',
|
|
2769
|
+
url: `/dsh-ris-ide/${pathname}`,
|
|
2770
|
+
headers: { host: '127.0.0.1:3080' },
|
|
2771
|
+
})
|
|
2772
|
+
await __test.serveFsOp(ctx, req, res, {})
|
|
2773
|
+
const text = chunks.join('')
|
|
2774
|
+
return { status: res.status, body: text === '' ? undefined : JSON.parse(text) }
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2777
|
+
// ── workspace switch: the fence follows the workspace the page SHOWS ────────
|
|
2778
|
+
test('a declared cwd wins the fence when it is a registered workspace (m00220)', async () => {
|
|
2779
|
+
const { mkdtemp, mkdir } = await import('node:fs/promises')
|
|
2780
|
+
const { tmpdir } = await import('node:os')
|
|
2781
|
+
const { join } = await import('node:path')
|
|
2782
|
+
// `shown` is the workspace the panel displays, `old` the one its session header
|
|
2783
|
+
// still names — the pair that used to earn 「不能对工作区之外的路径执行新建文件夹」.
|
|
2784
|
+
const shown = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-shown-'))
|
|
2785
|
+
const old = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-old-'))
|
|
2786
|
+
await mkdir(join(shown, '.dsh-ris-ide'), { recursive: true })
|
|
2787
|
+
// No remembered window rows in this home: only the registry may name a workspace.
|
|
2788
|
+
const home = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-home-'))
|
|
2789
|
+
const previousHome = process.env.DSH_RIS_IDE_PROXY_HOME
|
|
2790
|
+
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
2791
|
+
try {
|
|
2792
|
+
const ctx = {
|
|
2793
|
+
sessions: { get: () => ({ header: { cwd: old } }) },
|
|
2794
|
+
get: (key) => (key === 'workspaceRegistry' ? { list: () => [{ path: shown, title: 'shown' }] } : undefined),
|
|
2795
|
+
}
|
|
2796
|
+
// Delete's first step (create the undo trash) runs inside the SHOWN workspace.
|
|
2797
|
+
const trash = await callFsOp(ctx, 'fs/mkdir', { sessionId: 's1', cwd: shown, path: join(shown, '.dsh-ris-ide', 'trash') })
|
|
2798
|
+
assert.equal(trash.status, 200, 'the shown workspace owns the request')
|
|
2799
|
+
// The fence still exists: a write into the OLD workspace's tree, or into a
|
|
2800
|
+
// directory dsh never registered, is refused as before.
|
|
2801
|
+
const crossWrite = await callFsOp(ctx, 'fs/mkdir', { sessionId: 's1', cwd: shown, path: join(old, 'evil') })
|
|
2802
|
+
assert.equal(crossWrite.status, 403)
|
|
2803
|
+
assert.equal(crossWrite.body.code, 'outside-workspace')
|
|
2804
|
+
const stray = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-stray-'))
|
|
2805
|
+
const unregistered = await callFsOp(ctx, 'fs/mkdir', { sessionId: 's1', cwd: stray, path: join(stray, 'x') })
|
|
2806
|
+
assert.equal(unregistered.status, 403, 'an arbitrary absolute cwd is never a licence')
|
|
2807
|
+
} finally {
|
|
2808
|
+
if (previousHome === undefined) delete process.env.DSH_RIS_IDE_PROXY_HOME
|
|
2809
|
+
else process.env.DSH_RIS_IDE_PROXY_HOME = previousHome
|
|
2810
|
+
}
|
|
2811
|
+
})
|
|
2812
|
+
|
|
2813
|
+
test('a copy may read from another registered workspace, a move may not (m00220)', async () => {
|
|
2814
|
+
const { mkdtemp, readFile, writeFile } = await import('node:fs/promises')
|
|
2815
|
+
const { tmpdir } = await import('node:os')
|
|
2816
|
+
const { join } = await import('node:path')
|
|
2817
|
+
const from = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-copy-from-'))
|
|
2818
|
+
const current = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-copy-to-'))
|
|
2819
|
+
const outside = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-copy-stray-'))
|
|
2820
|
+
await writeFile(join(from, 'notes.md'), '# copied\n')
|
|
2821
|
+
await writeFile(join(from, 'moved.md'), '# moved\n')
|
|
2822
|
+
const home = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-home-'))
|
|
2823
|
+
const previousHome = process.env.DSH_RIS_IDE_PROXY_HOME
|
|
2824
|
+
process.env.DSH_RIS_IDE_PROXY_HOME = home
|
|
2825
|
+
try {
|
|
2826
|
+
const ctx = {
|
|
2827
|
+
sessions: { get: () => ({ header: { cwd: current } }) },
|
|
2828
|
+
get: () => ({ list: () => [{ path: from, title: 'from' }, { path: current, title: 'current' }] }),
|
|
2829
|
+
}
|
|
2830
|
+
// The clipboard still names workspace A after switching to B: Ctrl+V copies.
|
|
2831
|
+
const copied = await callFsOp(ctx, 'fs/copy', { sessionId: 's1', cwd: current, from: join(from, 'notes.md'), toDir: current })
|
|
2832
|
+
assert.equal(copied.status, 200)
|
|
2833
|
+
assert.equal(await readFile(join(current, 'notes.md'), 'utf8'), '# copied\n')
|
|
2834
|
+
// A copy whose DESTINATION is outside the current tree is still refused: only
|
|
2835
|
+
// the read side widened.
|
|
2836
|
+
const writeOut = await callFsOp(ctx, 'fs/copy', { sessionId: 's1', cwd: current, from: join(from, 'notes.md'), toDir: from })
|
|
2837
|
+
assert.equal(writeOut.status, 403)
|
|
2838
|
+
assert.equal(writeOut.body.code, 'outside-workspace')
|
|
2839
|
+
// Moving across workspaces would relocate a tree out of its git boundary.
|
|
2840
|
+
const moved = await callFsOp(ctx, 'fs/move', { sessionId: 's1', cwd: current, from: join(from, 'moved.md'), toDir: current })
|
|
2841
|
+
assert.equal(moved.status, 403)
|
|
2842
|
+
// Only a workspace dsh knows may be read: a stray directory stays fenced.
|
|
2843
|
+
await writeFile(join(outside, 'secret.txt'), 'no')
|
|
2844
|
+
const stray = await callFsOp(ctx, 'fs/copy', { sessionId: 's1', cwd: current, from: join(outside, 'secret.txt'), toDir: current })
|
|
2845
|
+
assert.equal(stray.status, 403)
|
|
2846
|
+
assert.equal(stray.body.code, 'outside-workspace')
|
|
2847
|
+
} finally {
|
|
2848
|
+
if (previousHome === undefined) delete process.env.DSH_RIS_IDE_PROXY_HOME
|
|
2849
|
+
else process.env.DSH_RIS_IDE_PROXY_HOME = previousHome
|
|
2850
|
+
}
|
|
2851
|
+
})
|
|
2852
|
+
|
|
2758
2853
|
// ── the debug stream: a page reload must still show its pre-set breakpoints ──
|
|
2759
2854
|
test('the debug stream carries pending breakpoints, so a reload shows its dots', async () => {
|
|
2760
2855
|
const { mkdtemp } = await import('node:fs/promises')
|
|
@@ -14,6 +14,30 @@ process.env.DSH_RIS_IDE_PROXY_HOME = mkdtempSync(join(tmpdir(), 'ris-proxy-home-
|
|
|
14
14
|
|
|
15
15
|
import { __test } from '../lib/index.js'
|
|
16
16
|
import { readProxyConfig, writeProxyConfig } from '../lib/proxy.js'
|
|
17
|
+
import { __test as redirectorTest } from '../lib/redirector.js'
|
|
18
|
+
|
|
19
|
+
// Stub every probe that could reach the real Windows side for the whole file.
|
|
20
|
+
// Two reasons, and both are not theoretical: (1) saving the table in these tests
|
|
21
|
+
// runs the production reload path, which finds a bridge by probing and then
|
|
22
|
+
// restarts/stops it — with the user's ProxyBridge_CLI running that would kill it;
|
|
23
|
+
// (2) `Get-Process ProxyBridge_CLI` through powershell.exe takes seconds and times
|
|
24
|
+
// out, which made this file take 17-26 s and pass or fail depending on load.
|
|
25
|
+
const PROBE_HOOKS = {
|
|
26
|
+
windowsPids: () => [],
|
|
27
|
+
localProc: () => 0,
|
|
28
|
+
windowsPidsAsync: async () => [],
|
|
29
|
+
windowsAlive: () => false,
|
|
30
|
+
windowsAliveAsync: async () => false,
|
|
31
|
+
taskkill: () => 'ERROR: Access is denied.',
|
|
32
|
+
}
|
|
33
|
+
redirectorTest.setProbeHooks(PROBE_HOOKS)
|
|
34
|
+
process.on('exit', () => redirectorTest.resetProbeHooks())
|
|
35
|
+
// The Windows process listing spawns powershell.exe (3-4.5 s on WSL, and it reads
|
|
36
|
+
// the developer's real desktop). A fixed list is all this file needs: the picker
|
|
37
|
+
// assertions are about which names are *offered* (SOCKS-capable filtering), not
|
|
38
|
+
// about what happens to be running.
|
|
39
|
+
__test.setWindowsProgramProbe(() => ['java', 'git', 'node', 'curl', 'navicat', 'mysql', 'redis-cli'])
|
|
40
|
+
process.on('exit', () => __test.setWindowsProgramProbe(null))
|
|
17
41
|
|
|
18
42
|
/** A response face that collects the JSON body. */
|
|
19
43
|
function fakeRes() {
|
|
@@ -148,6 +172,43 @@ test('a reload rewrites the profile BEFORE restarting the interceptor', () => {
|
|
|
148
172
|
assert.ok(source.includes('redirector: Object.assign(redirectorStatusCached()'), 'the view uses it too')
|
|
149
173
|
})
|
|
150
174
|
|
|
175
|
+
test('the bridge restart action is wired on the card, in the daemon and in the plugin', () => {
|
|
176
|
+
// The bridge parses its profile when it starts, so a rule-table save can leave old
|
|
177
|
+
// rules intercepting; the card offers ONE enforcement button whose label follows
|
|
178
|
+
// the state, and a click restarts = stop, settle, start from the new profile.
|
|
179
|
+
// Source pins: stopRedirector/startRedirectors shell out to the real side with no
|
|
180
|
+
// injection point, so the ordering can only be asserted on the source here.
|
|
181
|
+
const read = (file) => readFileSync(new URL(`../${file}`, import.meta.url), 'utf8')
|
|
182
|
+
|
|
183
|
+
// The card: one button (no separate restart / elevate controls), the stale-reload
|
|
184
|
+
// label, and it asks the plugin for the restart instead of auto-starting a proxy.
|
|
185
|
+
const ui = read('lib/risd/ui.js')
|
|
186
|
+
assert.match(ui, /redirector-restart/)
|
|
187
|
+
assert.doesNotMatch(ui, /id="bridge-health-elevate"/)
|
|
188
|
+
assert.doesNotMatch(ui, /maybeStartProxy/)
|
|
189
|
+
|
|
190
|
+
// The daemon must understand the action, and a page-triggered restart may prompt
|
|
191
|
+
// (it is the user asking); background reconcilers must not.
|
|
192
|
+
const server = read('lib/risd/server.js')
|
|
193
|
+
const daemonAt = server.indexOf("action === 'redirector-restart'")
|
|
194
|
+
assert.ok(daemonAt > 0, 'daemon must handle redirector-restart')
|
|
195
|
+
const daemonBlock = server.slice(daemonAt, daemonAt + 600)
|
|
196
|
+
assert.match(daemonBlock, /await stopRedirector\(\)/)
|
|
197
|
+
assert.match(daemonBlock, /setTimeout\(resolve, 300\)/)
|
|
198
|
+
assert.match(daemonBlock, /await startRedirectors\(\{ interactive \}\)/)
|
|
199
|
+
assert.match(server, /const interactive = parsed\.interactive === true/)
|
|
200
|
+
|
|
201
|
+
// The plugin forwards the action to the daemon and can run it itself.
|
|
202
|
+
const index = read('lib/index.js')
|
|
203
|
+
assert.match(index, /'redirector-restart'/)
|
|
204
|
+
const pluginAt = index.indexOf("action === 'redirector-restart'")
|
|
205
|
+
assert.ok(pluginAt > 0, 'plugin must handle redirector-restart locally')
|
|
206
|
+
const pluginBlock = index.slice(pluginAt, pluginAt + 400)
|
|
207
|
+
assert.match(pluginBlock, /await stopRedirector\(\)/)
|
|
208
|
+
assert.match(pluginBlock, /setTimeout\(resolve, 300\)/)
|
|
209
|
+
assert.match(pluginBlock, /await startRedirectors\(\)/)
|
|
210
|
+
})
|
|
211
|
+
|
|
151
212
|
test('a save rendered from a stale table is refused, not applied', async () => {
|
|
152
213
|
// Two windows hold the same table; the second save must not silently drop the
|
|
153
214
|
// first one's row. The payload names the table it was rendered from.
|
|
@@ -10,6 +10,11 @@ test('the panel no longer opens a proxy dialog at all', () => {
|
|
|
10
10
|
// dsh); both console shapes lost their 🌐, so nothing in the plugin opens the
|
|
11
11
|
// in-panel dialog or the standalone proxy window any more.
|
|
12
12
|
assert.doesNotMatch(client, /data-action': 'compact-proxy'/)
|
|
13
|
+
// Neither console (header rows and the sidebar compact bar) pushes a 🌐 button
|
|
14
|
+
// any more, and the flag that opened the dialog is gone with it. Moved here from
|
|
15
|
+
// risd-entry.test.mjs, which only carried these two negative assertions.
|
|
16
|
+
assert.doesNotMatch(client, /consoleConfigActions\.push\(button\('🌐'/)
|
|
17
|
+
assert.doesNotMatch(client, /compactProxyOpen/)
|
|
13
18
|
assert.doesNotMatch(client, /setProxyOpen\(true\)|setCompactProxyOpen\(true\)/)
|
|
14
19
|
assert.doesNotMatch(client, /focus-ack/)
|
|
15
20
|
})
|
package/test/proxy.test.mjs
CHANGED
|
@@ -828,7 +828,12 @@ test('engine pid: a dead pidfile is cleared', () => {
|
|
|
828
828
|
test('engine pid: a marker-carrying process is reused and stoppable', async () => {
|
|
829
829
|
const dir = mkdtempSync(join(tmpdir(), 'ris-ide-pid-'))
|
|
830
830
|
mkdirSync(proxyHomeDir(), { recursive: true })
|
|
831
|
-
|
|
831
|
+
// `node -e CODE --marker=X` is read as a NODE OPTION, not as a script argument:
|
|
832
|
+
// node prints "bad option: --marker=…" and exits immediately, so the child was
|
|
833
|
+
// only sometimes seen alive in /proc (this test failed ~half the time on CI while
|
|
834
|
+
// passing locally). `--` ends option parsing, so the marker reaches the child's
|
|
835
|
+
// argv — and the child stays alive for the 60 s of its setTimeout.
|
|
836
|
+
const child = spawn(process.execPath, ['-e', 'setTimeout(() => {}, 60000)', '--', `--marker=${PROXY_MARKER}`], { stdio: 'ignore' })
|
|
832
837
|
let exited = false
|
|
833
838
|
child.once('exit', () => { exited = true })
|
|
834
839
|
try {
|
|
@@ -840,6 +845,10 @@ test('engine pid: a marker-carrying process is reused and stoppable', async () =
|
|
|
840
845
|
assert.equal(ready, true, 'the test child must look like the engine (marker in argv)')
|
|
841
846
|
writeFileSync(proxyPidPath(), String(child.pid))
|
|
842
847
|
assert.equal(proxyPid(dir), child.pid)
|
|
848
|
+
// Re-check right before the reuse call: if the child died in between, `startProxy`
|
|
849
|
+
// would see a stale/absent pidfile and try to spawn a REAL engine — leaving it
|
|
850
|
+
// running and binding the loopback ports after the test (that is what hung CI).
|
|
851
|
+
assert.equal(pidIsProxy(child.pid), true, 'the test child must still be alive before the reuse check')
|
|
843
852
|
const started = await startProxy(dir, { config: normalizeConfig({}) })
|
|
844
853
|
assert.equal(started.alreadyRunning, true)
|
|
845
854
|
assert.equal(started.pid, child.pid)
|
|
@@ -847,6 +856,9 @@ test('engine pid: a marker-carrying process is reused and stoppable', async () =
|
|
|
847
856
|
for (let attempt = 0; attempt < 100 && exited !== true; attempt += 1) await sleep(20)
|
|
848
857
|
assert.equal(exited, true)
|
|
849
858
|
} finally {
|
|
859
|
+
// If the reuse path was missed, `startProxy` may have spawned a real engine and
|
|
860
|
+
// left it owning 127.0.0.1:11081 — kill whatever the pidfile names, then the child.
|
|
861
|
+
try { await stopProxy(dir, { graceMs: 3000 }) } catch { /* nothing to stop */ }
|
|
850
862
|
try { child.kill('SIGKILL') } catch { /* already gone */ }
|
|
851
863
|
rmSync(proxyPidPath(), { force: true })
|
|
852
864
|
rmSync(dir, { recursive: true, force: true })
|
|
@@ -22,8 +22,8 @@ import {
|
|
|
22
22
|
import { tmpdir } from 'node:os'
|
|
23
23
|
import { dirname, join } from 'node:path'
|
|
24
24
|
import test from 'node:test'
|
|
25
|
-
import { gzipSync } from 'node:zlib'
|
|
26
25
|
|
|
26
|
+
import { fileContent, fetchServing, makeTgz } from './helpers/tgz.mjs'
|
|
27
27
|
import {
|
|
28
28
|
BUNDLE_SHA256,
|
|
29
29
|
BUNDLE_URLS,
|
|
@@ -56,47 +56,8 @@ const LAYOUT = [
|
|
|
56
56
|
'windows/WinDivert64.sys',
|
|
57
57
|
]
|
|
58
58
|
|
|
59
|
-
const fileContent = (rel) => `fixture bytes for ${rel}\n`
|
|
60
59
|
const shaOf = (bytes) => createHash('sha256').update(bytes).digest('hex')
|
|
61
60
|
|
|
62
|
-
/** Octal field: width-1 digits + NUL, as ustar spells numbers. */
|
|
63
|
-
const octalField = (value, width) => `${value.toString(8).padStart(width - 1, '0')}\0`
|
|
64
|
-
|
|
65
|
-
function tarHeader(name, size, { mode = 0o644, type = '0', linkname = '' } = {}) {
|
|
66
|
-
const header = Buffer.alloc(512, 0)
|
|
67
|
-
const encoded = Buffer.from(name, 'utf8')
|
|
68
|
-
assert.ok(encoded.length <= 100, `fixture name too long: ${name}`)
|
|
69
|
-
encoded.copy(header, 0)
|
|
70
|
-
header.write(octalField(mode, 8), 100, 'ascii')
|
|
71
|
-
header.write(octalField(0, 8), 108, 'ascii') // uid
|
|
72
|
-
header.write(octalField(0, 8), 116, 'ascii') // gid
|
|
73
|
-
header.write(octalField(size, 12), 124, 'ascii')
|
|
74
|
-
header.write(octalField(0, 12), 136, 'ascii') // mtime
|
|
75
|
-
header.write(' ', 148, 'ascii') // checksum placeholder
|
|
76
|
-
header.write(type, 156, 'ascii')
|
|
77
|
-
header.write(linkname < 101 ? linkname : linkname.slice(0, 100), 157, 'ascii')
|
|
78
|
-
header.write('ustar\0', 257, 'ascii')
|
|
79
|
-
header.write('00', 263, 'ascii')
|
|
80
|
-
let sum = 0
|
|
81
|
-
for (const byte of header) sum += byte
|
|
82
|
-
header.write(`${sum.toString(8).padStart(6, '0')}\0 `, 148, 'ascii')
|
|
83
|
-
return header
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** Build a real `.tgz` from `{name, content?, mode?, type?, linkname?}` entries. */
|
|
87
|
-
function makeTgz(entries, { prefix = '' } = {}) {
|
|
88
|
-
const chunks = []
|
|
89
|
-
for (const entry of entries) {
|
|
90
|
-
const content = Buffer.from(entry.content ?? fileContent(entry.name))
|
|
91
|
-
chunks.push(tarHeader(`${prefix}${entry.name}`, content.length, entry))
|
|
92
|
-
chunks.push(content)
|
|
93
|
-
const pad = (512 - (content.length % 512)) % 512
|
|
94
|
-
if (pad > 0) chunks.push(Buffer.alloc(pad))
|
|
95
|
-
}
|
|
96
|
-
chunks.push(Buffer.alloc(1024)) // end-of-archive: two zero blocks
|
|
97
|
-
return gzipSync(Buffer.concat(chunks))
|
|
98
|
-
}
|
|
99
|
-
|
|
100
61
|
const bundleTgz = (extra = []) => makeTgz([
|
|
101
62
|
...LAYOUT.map((rel) => ({
|
|
102
63
|
name: rel,
|
|
@@ -106,25 +67,6 @@ const bundleTgz = (extra = []) => makeTgz([
|
|
|
106
67
|
...extra,
|
|
107
68
|
])
|
|
108
69
|
|
|
109
|
-
/**
|
|
110
|
-
* `fetch` stand-in serving one body; `calls` counts invocations.
|
|
111
|
-
* `url` mimics `Response.url` after redirects; `headers` mimics the header bag.
|
|
112
|
-
*/
|
|
113
|
-
function fetchServing(body, options = {}) {
|
|
114
|
-
const calls = { count: 0 }
|
|
115
|
-
const impl = async (requested) => {
|
|
116
|
-
calls.count += 1
|
|
117
|
-
return {
|
|
118
|
-
ok: true,
|
|
119
|
-
status: 200,
|
|
120
|
-
url: options.url ?? requested,
|
|
121
|
-
headers: options.headers ?? { get: () => null },
|
|
122
|
-
arrayBuffer: async () => body.buffer.slice(body.byteOffset, body.byteOffset + body.length),
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return { impl, calls }
|
|
126
|
-
}
|
|
127
|
-
|
|
128
70
|
function tempHome() {
|
|
129
71
|
return mkdtempSync(join(tmpdir(), 'ris-ide-bundle-home-'))
|
|
130
72
|
}
|