mockaton 10.3.4 → 10.3.6
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/package.json +2 -2
- package/src/Dashboard.css +31 -18
- package/src/Dashboard.js +13 -10
- package/src/cli.js +2 -2
- package/src/config.js +8 -9
package/README.md
CHANGED
|
@@ -60,9 +60,9 @@ Nonetheless, there’s a programmatic API, which is handy
|
|
|
60
60
|
for setting up tests (see **Commander API** section below).
|
|
61
61
|
|
|
62
62
|
<picture>
|
|
63
|
-
<source media="(prefers-color-scheme: light)" srcset="pixaton-tests/macos/pic-for-readme.
|
|
64
|
-
<source media="(prefers-color-scheme: dark)" srcset="pixaton-tests/macos/pic-for-readme.
|
|
65
|
-
<img alt="Mockaton Dashboard" src="pixaton-tests/macos/pic-for-readme.
|
|
63
|
+
<source media="(prefers-color-scheme: light)" srcset="pixaton-tests/macos/pic-for-readme.vp761x720.light.gold.png">
|
|
64
|
+
<source media="(prefers-color-scheme: dark)" srcset="pixaton-tests/macos/pic-for-readme.vp761x720.dark.gold.png">
|
|
65
|
+
<img alt="Mockaton Dashboard" src="pixaton-tests/macos/pic-for-readme.vp761x720.light.gold.png">
|
|
66
66
|
</picture>
|
|
67
67
|
|
|
68
68
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "mockaton",
|
|
3
3
|
"description": "HTTP Mock Server",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "10.3.
|
|
5
|
+
"version": "10.3.6",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
8
8
|
"license": "MIT",
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"pixaton": "1.1.3",
|
|
30
|
-
"puppeteer": "24.
|
|
30
|
+
"puppeteer": "24.23.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/Dashboard.css
CHANGED
|
@@ -102,10 +102,6 @@ select, a, input, button {
|
|
|
102
102
|
|
|
103
103
|
a {
|
|
104
104
|
text-decoration: none;
|
|
105
|
-
|
|
106
|
-
&:hover {
|
|
107
|
-
text-decoration: underline;
|
|
108
|
-
}
|
|
109
105
|
}
|
|
110
106
|
|
|
111
107
|
a,
|
|
@@ -141,6 +137,7 @@ select {
|
|
|
141
137
|
}
|
|
142
138
|
&:disabled {
|
|
143
139
|
cursor: not-allowed;
|
|
140
|
+
opacity: 0.5;
|
|
144
141
|
}
|
|
145
142
|
}
|
|
146
143
|
|
|
@@ -151,22 +148,38 @@ header {
|
|
|
151
148
|
border-bottom: 1px solid var(--colorSecondaryActionBorder);
|
|
152
149
|
background: var(--colorHeaderBackground);
|
|
153
150
|
|
|
151
|
+
> img {
|
|
152
|
+
width: 120px;
|
|
153
|
+
align-self: end;
|
|
154
|
+
margin-right: 22px;
|
|
155
|
+
margin-bottom: 5px;
|
|
156
|
+
}
|
|
157
|
+
|
|
154
158
|
> div {
|
|
155
159
|
display: flex;
|
|
160
|
+
width: 100%;
|
|
156
161
|
flex-wrap: wrap;
|
|
157
162
|
align-items: flex-end;
|
|
158
163
|
gap: 16px 8px;
|
|
164
|
+
}
|
|
159
165
|
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
@media (max-width: 760px) {
|
|
167
|
+
> img {
|
|
168
|
+
width: 100px;
|
|
169
|
+
align-self: center;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
> div {
|
|
173
|
+
width: 400px;
|
|
174
|
+
.MenuTrigger {
|
|
175
|
+
margin-left: unset;
|
|
176
|
+
}
|
|
162
177
|
}
|
|
163
178
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
margin-right: 22px;
|
|
169
|
-
margin-bottom: 5px;
|
|
179
|
+
@media (max-width: 424px) {
|
|
180
|
+
> img {
|
|
181
|
+
display: none;
|
|
182
|
+
}
|
|
170
183
|
}
|
|
171
184
|
|
|
172
185
|
.Field {
|
|
@@ -237,6 +250,7 @@ header {
|
|
|
237
250
|
|
|
238
251
|
input + span {
|
|
239
252
|
margin: 0;
|
|
253
|
+
margin-right: 4px;
|
|
240
254
|
}
|
|
241
255
|
input:disabled + span {
|
|
242
256
|
opacity: 0.8;
|
|
@@ -253,7 +267,9 @@ header {
|
|
|
253
267
|
.ResetButton {
|
|
254
268
|
padding: 6px 12px;
|
|
255
269
|
border: 1px solid var(--colorRed);
|
|
270
|
+
margin-right: 8px;
|
|
256
271
|
margin-left: 4px;
|
|
272
|
+
outline-offset: 1px;
|
|
257
273
|
background: transparent;
|
|
258
274
|
color: var(--colorRed);
|
|
259
275
|
border-radius: 50px;
|
|
@@ -269,6 +285,7 @@ header {
|
|
|
269
285
|
height: 24px;
|
|
270
286
|
flex-shrink: 0;
|
|
271
287
|
align-self: end;
|
|
288
|
+
margin-bottom: 2px;
|
|
272
289
|
margin-left: auto;
|
|
273
290
|
fill: var(--colorSecondaryAction);
|
|
274
291
|
background: transparent;
|
|
@@ -278,6 +295,7 @@ header {
|
|
|
278
295
|
fill: var(--colorAccent);
|
|
279
296
|
}
|
|
280
297
|
}
|
|
298
|
+
|
|
281
299
|
}
|
|
282
300
|
|
|
283
301
|
.SettingsMenu {
|
|
@@ -362,10 +380,6 @@ main {
|
|
|
362
380
|
table {
|
|
363
381
|
border-collapse: collapse;
|
|
364
382
|
|
|
365
|
-
tr {
|
|
366
|
-
border-top: 3px solid transparent;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
383
|
th {
|
|
370
384
|
padding-bottom: 2px;
|
|
371
385
|
padding-left: 4px;
|
|
@@ -395,7 +409,6 @@ table {
|
|
|
395
409
|
|
|
396
410
|
&:hover {
|
|
397
411
|
background: var(--colorHover);
|
|
398
|
-
text-decoration: none;
|
|
399
412
|
}
|
|
400
413
|
&.chosen {
|
|
401
414
|
color: white;
|
|
@@ -404,7 +417,7 @@ table {
|
|
|
404
417
|
}
|
|
405
418
|
|
|
406
419
|
.MockSelector {
|
|
407
|
-
height:
|
|
420
|
+
height: 24px;
|
|
408
421
|
padding-right: 20px;
|
|
409
422
|
padding-left: 8px;
|
|
410
423
|
text-overflow: ellipsis;
|
package/src/Dashboard.js
CHANGED
|
@@ -15,12 +15,14 @@ const Strings = {
|
|
|
15
15
|
empty_response_body: '/* Empty Response Body */',
|
|
16
16
|
fallback_server: 'Fallback',
|
|
17
17
|
fallback_server_error: '⛔ Fallback Backend Error',
|
|
18
|
-
fallback_server_placeholder: 'Type
|
|
18
|
+
fallback_server_placeholder: 'Type backend address',
|
|
19
19
|
fetching: 'Fetching…',
|
|
20
20
|
got: 'Got',
|
|
21
21
|
group_by_method: 'Group by Method',
|
|
22
22
|
internal_server_error: 'Internal Server Error',
|
|
23
|
+
mock_selector: 'Mock Selector',
|
|
23
24
|
no_mocks_found: 'No mocks found',
|
|
25
|
+
none: 'None',
|
|
24
26
|
not_found: 'Not Found',
|
|
25
27
|
pick_comment: 'Pick Comment…',
|
|
26
28
|
preview: 'Preview',
|
|
@@ -28,6 +30,7 @@ const Strings = {
|
|
|
28
30
|
proxy_toggler: 'Proxy Toggler',
|
|
29
31
|
reset: 'Reset',
|
|
30
32
|
save_proxied: 'Save Mocks',
|
|
33
|
+
settings: 'Settings',
|
|
31
34
|
static_get: 'Static GET',
|
|
32
35
|
title: 'Mockaton'
|
|
33
36
|
}
|
|
@@ -158,11 +161,11 @@ function Header() {
|
|
|
158
161
|
}),
|
|
159
162
|
r('div', null,
|
|
160
163
|
GlobalDelayField(),
|
|
161
|
-
CookieSelector(),
|
|
162
164
|
BulkSelector(),
|
|
165
|
+
CookieSelector(),
|
|
163
166
|
ProxyFallbackField(),
|
|
164
|
-
ResetButton()
|
|
165
|
-
|
|
167
|
+
ResetButton(),
|
|
168
|
+
SettingsMenu())))
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
function SettingsMenu() {
|
|
@@ -199,6 +202,7 @@ function SettingsMenu() {
|
|
|
199
202
|
|
|
200
203
|
return (
|
|
201
204
|
r('button', {
|
|
205
|
+
title: Strings.settings,
|
|
202
206
|
onClick() {
|
|
203
207
|
if (!this.querySelector('menu'))
|
|
204
208
|
this.appendChild(MenuContent())
|
|
@@ -216,6 +220,7 @@ function CookieSelector() {
|
|
|
216
220
|
.catch(onError)
|
|
217
221
|
}
|
|
218
222
|
const disabled = cookies.length <= 1
|
|
223
|
+
const list = cookies.length ? cookies : [[Strings.none, true]]
|
|
219
224
|
return (
|
|
220
225
|
r('label', className(CSS.Field, CSS.CookieSelector),
|
|
221
226
|
r('span', null, Strings.cookie),
|
|
@@ -224,7 +229,7 @@ function CookieSelector() {
|
|
|
224
229
|
disabled,
|
|
225
230
|
title: disabled ? Strings.cookie_disabled_title : '',
|
|
226
231
|
onChange
|
|
227
|
-
},
|
|
232
|
+
}, list.map(([value, selected]) =>
|
|
228
233
|
r('option', { value, selected }, value)))))
|
|
229
234
|
}
|
|
230
235
|
|
|
@@ -248,7 +253,6 @@ function BulkSelector() {
|
|
|
248
253
|
r('span', null, Strings.bulk_select),
|
|
249
254
|
r('select', {
|
|
250
255
|
className: CSS.BulkSelector,
|
|
251
|
-
'data-qaid': 'BulkSelector',
|
|
252
256
|
autocomplete: 'off',
|
|
253
257
|
disabled,
|
|
254
258
|
title: disabled ? Strings.bulk_select_disabled_title : '',
|
|
@@ -469,7 +473,7 @@ function MockSelector(broker) {
|
|
|
469
473
|
r('select', {
|
|
470
474
|
onChange,
|
|
471
475
|
autocomplete: 'off',
|
|
472
|
-
'
|
|
476
|
+
'aria-label': Strings.mock_selector,
|
|
473
477
|
disabled: files.length <= 1,
|
|
474
478
|
...className(
|
|
475
479
|
CSS.MockSelector,
|
|
@@ -669,7 +673,7 @@ Resizer.panelWidth = 0
|
|
|
669
673
|
Resizer.onPointerDown = function (event) {
|
|
670
674
|
Resizer.initialX = event.clientX
|
|
671
675
|
Resizer.panelWidth = leftSideRef.current.clientWidth
|
|
672
|
-
addEventListener('pointerup', Resizer.onUp)
|
|
676
|
+
addEventListener('pointerup', Resizer.onUp, { once: true })
|
|
673
677
|
addEventListener('pointermove', Resizer.onMove)
|
|
674
678
|
document.body.style.userSelect = 'none'
|
|
675
679
|
document.body.style.cursor = 'col-resize'
|
|
@@ -684,7 +688,6 @@ Resizer.onMove = function (event) {
|
|
|
684
688
|
}
|
|
685
689
|
Resizer.onUp = function () {
|
|
686
690
|
removeEventListener('pointermove', Resizer.onMove)
|
|
687
|
-
removeEventListener('pointerup', Resizer.onUp)
|
|
688
691
|
cancelAnimationFrame(Resizer.raf)
|
|
689
692
|
Resizer.raf = 0
|
|
690
693
|
document.body.style.userSelect = 'auto'
|
|
@@ -715,7 +718,7 @@ function PayloadViewerTitle({ file, statusText }) {
|
|
|
715
718
|
const tokens = file.split('.')
|
|
716
719
|
const ext = tokens.pop()
|
|
717
720
|
const status = tokens.pop()
|
|
718
|
-
const urlAndMethod =
|
|
721
|
+
const urlAndMethod = tokens.join('.') + '.'
|
|
719
722
|
return (
|
|
720
723
|
r('span', null,
|
|
721
724
|
urlAndMethod,
|
package/src/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { resolve } from 'node:path'
|
|
4
4
|
import { parseArgs } from 'node:util'
|
|
5
5
|
|
|
6
6
|
import { isFile } from './utils/fs.js'
|
|
@@ -68,7 +68,7 @@ else if (args.config && !isFile(args.config)) {
|
|
|
68
68
|
process.exitCode = 1
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
71
|
-
const userConf =
|
|
71
|
+
const userConf = resolve(args.config ?? 'mockaton.config.js')
|
|
72
72
|
const opts = isFile(userConf)
|
|
73
73
|
? (await import(userConf)).default ?? {}
|
|
74
74
|
: {}
|
package/src/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
2
|
|
|
3
3
|
import { logger } from './utils/logger.js'
|
|
4
4
|
import { isDirectory } from './utils/fs.js'
|
|
@@ -16,8 +16,8 @@ import { validateCorsAllowedMethods, validateCorsAllowedOrigins } from './utils/
|
|
|
16
16
|
* ]
|
|
17
17
|
* }} */
|
|
18
18
|
const schema = {
|
|
19
|
-
mocksDir: [
|
|
20
|
-
staticDir: [
|
|
19
|
+
mocksDir: [resolve('mockaton-mocks'), isDirectory],
|
|
20
|
+
staticDir: [resolve('mockaton-static-mocks'), optional(isDirectory)],
|
|
21
21
|
ignore: [/(\.DS_Store|~)$/, is(RegExp)], // TODO think about .well-known/appspecific/com.chrome.devtools
|
|
22
22
|
|
|
23
23
|
host: ['127.0.0.1', is(String)],
|
|
@@ -69,13 +69,12 @@ export const ConfigValidator = Object.freeze(validators)
|
|
|
69
69
|
|
|
70
70
|
/** @param {Partial<Config>} options */
|
|
71
71
|
export function setup(options) {
|
|
72
|
-
if (options.mocksDir
|
|
73
|
-
options.mocksDir =
|
|
72
|
+
if (options.mocksDir)
|
|
73
|
+
options.mocksDir = resolve(options.mocksDir)
|
|
74
74
|
|
|
75
|
-
if (options.staticDir
|
|
76
|
-
options.staticDir =
|
|
77
|
-
|
|
78
|
-
if (!options.staticDir && !isDirectory(defaults.staticDir))
|
|
75
|
+
if (options.staticDir)
|
|
76
|
+
options.staticDir = resolve(options.staticDir)
|
|
77
|
+
else if (!isDirectory(defaults.staticDir))
|
|
79
78
|
options.staticDir = ''
|
|
80
79
|
|
|
81
80
|
Object.assign(config, options)
|