mockaton 13.11.0 → 13.11.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 +11 -8
- package/package.json +1 -1
- package/skills/mockaton/SKILL.md +8 -5
- package/src/client/ApiConstants.js +1 -1
- package/src/client/IndexHtml.js +1 -1
- package/src/client/app-header.css +231 -0
- package/src/client/app-header.js +30 -19
- package/src/client/app-mock-list.css +340 -0
- package/src/client/app-mock-list.js +370 -0
- package/src/client/app-payload-viewer.css +90 -0
- package/src/client/app-payload-viewer.js +4 -4
- package/src/client/app-store.js +1 -0
- package/src/client/app.css +0 -654
- package/src/client/app.js +18 -360
- package/src/client/utils/css.js +7 -0
- package/src/client/utils/watcherDev.js +4 -1
- package/src/server/Api.js +18 -18
- package/src/server/Mockaton.js +1 -1
- package/src/server/Mockaton.test.js +5 -4
- package/src/server/cli.js +37 -33
- package/src/server/cli.test.js +2 -4
- package/src/server/utils/HttpServerResponse.test.js +7 -9
- package/src/server/utils/WatcherDevClient.js +1 -1
- package/src/server/utils/fs.js +1 -1
- package/src/server/utils/openInBrowser.js +15 -10
|
@@ -4,19 +4,17 @@ import { createServer } from 'node:http'
|
|
|
4
4
|
import { tmpdir } from 'node:os'
|
|
5
5
|
import { equal } from 'node:assert/strict'
|
|
6
6
|
import { join } from 'node:path'
|
|
7
|
-
import {
|
|
7
|
+
import { rmdir } from 'node:fs/promises'
|
|
8
8
|
|
|
9
9
|
import { ServerResponse } from './HttpServerResponse.js'
|
|
10
10
|
|
|
11
|
-
describe('ServerResponse', () => {
|
|
11
|
+
describe('ServerResponse', { concurrency: true }, () => {
|
|
12
12
|
const FILE = '0123456789'
|
|
13
|
+
const tmpDir = mkdtempSync(join(tmpdir(), 'response-'))
|
|
14
|
+
writeFileSync(join(tmpDir, 'test.txt'), FILE)
|
|
13
15
|
|
|
14
|
-
let
|
|
16
|
+
let server, addr
|
|
15
17
|
before(async () => {
|
|
16
|
-
tmpDir = mkdtempSync(join(tmpdir(), 'response-'))
|
|
17
|
-
tmpFile = join(tmpDir, 'test.txt')
|
|
18
|
-
writeFileSync(tmpFile, FILE)
|
|
19
|
-
|
|
20
18
|
server = createServer({ ServerResponse }, (req, response) => {
|
|
21
19
|
const file = join(tmpDir, req.url)
|
|
22
20
|
if (req.headers.range)
|
|
@@ -26,14 +24,14 @@ describe('ServerResponse', () => {
|
|
|
26
24
|
})
|
|
27
25
|
|
|
28
26
|
await new Promise(resolve => server.listen(0, () => {
|
|
29
|
-
addr = `http://127.0.0.1:${
|
|
27
|
+
addr = `http://127.0.0.1:${server.address().port}`
|
|
30
28
|
resolve()
|
|
31
29
|
}))
|
|
32
30
|
})
|
|
33
31
|
|
|
34
32
|
after(async () => {
|
|
35
33
|
server?.close()
|
|
36
|
-
await
|
|
34
|
+
await rmdir(tmpDir, { recursive: true, force: true })
|
|
37
35
|
})
|
|
38
36
|
|
|
39
37
|
|
|
@@ -12,7 +12,7 @@ const devClientWatcher = new class extends EventEmitter {
|
|
|
12
12
|
// Although `client/IndexHtml.js` is watched, it returns a stale version.
|
|
13
13
|
// i.e., it would need to be a dynamic import + cache busting.
|
|
14
14
|
export function watchDevSPA(dir) {
|
|
15
|
-
watch(dir, (_, file) => {
|
|
15
|
+
watch(dir, { recursive: true }, (_, file) => {
|
|
16
16
|
devClientWatcher.emit(file)
|
|
17
17
|
})
|
|
18
18
|
}
|
package/src/server/utils/fs.js
CHANGED
|
@@ -34,7 +34,7 @@ export async function rm(path) {
|
|
|
34
34
|
export async function resolveIn(baseDir, file) {
|
|
35
35
|
try {
|
|
36
36
|
const parent = await realpath(baseDir)
|
|
37
|
-
const child = resolve(join(parent, file))
|
|
37
|
+
const child = resolve(join(parent, file)) // realpath not needed because we don't write symlinks
|
|
38
38
|
return child.startsWith(join(parent, sep))
|
|
39
39
|
? child
|
|
40
40
|
: null
|
|
@@ -11,22 +11,27 @@ export const openInBrowser = (async () => {
|
|
|
11
11
|
})()
|
|
12
12
|
|
|
13
13
|
function _openInBrowser(address) {
|
|
14
|
-
let
|
|
14
|
+
let command = ''
|
|
15
|
+
let args = [address]
|
|
16
|
+
|
|
15
17
|
switch (process.platform) {
|
|
16
18
|
case 'darwin':
|
|
17
|
-
|
|
19
|
+
command = '/usr/bin/open'
|
|
18
20
|
break
|
|
21
|
+
|
|
19
22
|
case 'win32':
|
|
20
|
-
|
|
23
|
+
command = 'cmd'
|
|
24
|
+
args = ['/c', 'start', '', address]
|
|
21
25
|
break
|
|
26
|
+
|
|
22
27
|
default:
|
|
23
|
-
|
|
28
|
+
command = ['xdg-open', 'gnome-open', 'kde-open'].find(function hasCommand(cmd) {
|
|
29
|
+
const { status } = spawnSync('command', ['-v', cmd], { stdio: 'ignore' })
|
|
30
|
+
return status === 0
|
|
31
|
+
})
|
|
24
32
|
}
|
|
25
|
-
if (opener)
|
|
26
|
-
spawnSync(opener, [address])
|
|
27
|
-
}
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return status === 0
|
|
34
|
+
if (command)
|
|
35
|
+
spawnSync(command, args)
|
|
32
36
|
}
|
|
37
|
+
|