mockaton 9.6.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -3
- package/README.md +4 -6
- package/package.json +2 -2
- package/src/Dashboard.js +1 -0
- package/src/Mockaton.js +19 -18
- package/src/cli.js +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,115 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
- 10.0.0 **Breaking Change**: Mockaton constructor is now async. So if you
|
|
4
|
+
use the programmatic launch, instead of the cli, change:
|
|
5
|
+
```js
|
|
6
|
+
Mockaton()
|
|
7
|
+
// to
|
|
8
|
+
await Mockaton()
|
|
9
|
+
```
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
-
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
- 9.6.0 dashboard: persist `groupByMethod` preference in localStorage
|
|
14
|
+
- 9.5.0 cli: new log level `verbose`
|
|
15
|
+
- 9.4.0 dashboard: user can resize panels
|
|
16
|
+
- 9.3.0 handle head requests for get mocks
|
|
17
|
+
- 9.2.0 dashboard: syntax highlight more xml files (such as html)
|
|
18
|
+
- 9.1.0 cli: new flag: --no-open
|
|
19
|
+
- 9.0.0 **Breaking Change**: Commander’s GET APIs have been consolidated into `commander.getState()`.
|
|
20
|
+
These were undocumented APIs, so you are likely not affected.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
- 8.27.0 dashboard: group by method checkbox
|
|
25
|
+
- 8.26.0 ui simplify mock-selector label text
|
|
26
|
+
- 8.25.0 --quiet and logLevel options
|
|
27
|
+
- 8.24.0 show iso date in logs and log static file dispatch
|
|
28
|
+
- 8.23.0 cli
|
|
29
|
+
- 8.22.0 xml syntax highlight
|
|
30
|
+
- 8.21.0 responsive mock list
|
|
31
|
+
- 8.20.0 revert progress bar (no clock spinner)
|
|
32
|
+
- 8.19.0 move puppeteer and pixaton to devDeps
|
|
33
|
+
- 8.18.0 cors. allow by default 'authorization' header
|
|
34
|
+
- 8.17.0 conditionally render proxy toggler
|
|
35
|
+
- 8.16.0 watch static mocks dir
|
|
36
|
+
- 8.15.0 add config.delayJitter
|
|
37
|
+
- 8.14.0 static files controls
|
|
38
|
+
- 8.13.0 highlight dir structure
|
|
39
|
+
- 8.12.0 Adds config.formatCollectedJSON
|
|
40
|
+
- 8.11.0 Allow all the HTTP methods Node.js supports
|
|
41
|
+
- 8.10.0 global delay field
|
|
42
|
+
- 8.9.0 long poll Add or Remove mocks
|
|
43
|
+
- 8.8.0 allow proxying individual routes
|
|
44
|
+
- 8.7.0 dashboard now highlights and previews 500 mocks when checking the 500 toggler
|
|
45
|
+
- 8.6.0 feat: save proxied checkbox
|
|
46
|
+
- 8.5.0 Add demo-app-vite
|
|
47
|
+
- 8.4.0 auto register/unregister mocks
|
|
48
|
+
- 8.3.0 feat `config.collectProxied`
|
|
49
|
+
- 8.2.0 Allow changing proxy fallback server from UI
|
|
50
|
+
- 8.1.0 describe http status code in payload viewer title
|
|
51
|
+
- 8.0.0 **Breaking change**: `config.plugins` are no longer an Object. Now they are an Array and they the
|
|
52
|
+
test is now a regex. So if you use custom plugins, change e.g.:
|
|
53
|
+
```js
|
|
54
|
+
plugins = {
|
|
55
|
+
'.js': jsToJsonPlugin,
|
|
56
|
+
'.ts': jsToJsonPlugin
|
|
57
|
+
}
|
|
58
|
+
// to
|
|
59
|
+
plugins = [
|
|
60
|
+
[/\.(js|ts)$/, jsToJsonPlugin], // Default
|
|
61
|
+
]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
- 7.8.0 support userland plugins
|
|
67
|
+
- 7.7.0 TypeScript mocks support
|
|
68
|
+
- 7.6.0 render list of static files
|
|
69
|
+
- 7.5.0 allowing previewing mock images
|
|
70
|
+
- 7.4.0 progress bar for payload viewer
|
|
71
|
+
- 7.3.0 Allow CORS Checkbox
|
|
72
|
+
- 7.2.0 add content-type as default header when allowing cors
|
|
73
|
+
- 7.1.0 CORS support
|
|
74
|
+
- 7.0.0 **Breaking change**: Split `PATCH mockaton/edit` into `selectMock` and `setRouteIsDelayed`.
|
|
75
|
+
So instead of:
|
|
76
|
+
```js
|
|
77
|
+
fetch(addr + '/mockaton/edit', {
|
|
78
|
+
method: 'PATCH',
|
|
79
|
+
body: JSON.stringify({
|
|
80
|
+
file: 'api/foo.200.GET.json',
|
|
81
|
+
delayed: true // optional
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
// change it to
|
|
86
|
+
await commander.select('api/foo.200.GET.json')
|
|
87
|
+
await commander.setMockIsDelayed('api/foo.200.GET.json', true)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
- 6.4.0 Default mock could be selected with the comment `(default)`
|
|
93
|
+
- 6.3.0 422 when trying to change a mock that doesn't exist on a route that has mocks
|
|
94
|
+
- 6.4.0 no partial comment search
|
|
95
|
+
- 6.3.0 Allow extending the mime list
|
|
96
|
+
- 6.2.0 Add `config.ignore` regex
|
|
97
|
+
- 6.1.0 remove `config.allowedExt`
|
|
98
|
+
- 6.0.0 **Breaking change**: Remove feature for using .md files for documentating APIs
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
- 5.0.0 **Breaking change**: .md files no longer use status code in the extension
|
|
103
|
+
- 4.0.0 **Breaking change**: rename `config.open` to `config.onReady`
|
|
104
|
+
- 3.0.0 **Breaking change**: `config.skipOpen` boolean to `config.open` function
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
- 2.3.0 style dashboard
|
|
109
|
+
- 2.2.0 Allow injecting `extraHeaders`
|
|
110
|
+
- 2.1.0 make auto-generate 500's configurable
|
|
111
|
+
- 2.0.0 **Breaking change**: Transforms no longer get a mock
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
- 1.1.0 Allow writing JSON mocks in JS
|
package/README.md
CHANGED
|
@@ -501,14 +501,12 @@ Defaults to `'normal'`.
|
|
|
501
501
|
|
|
502
502
|
```js
|
|
503
503
|
import { Mockaton } from 'mockaton'
|
|
504
|
-
import
|
|
504
|
+
import config from './mockaton.config.js'
|
|
505
505
|
|
|
506
|
-
const server = Mockaton(
|
|
507
|
-
|
|
508
|
-
|
|
506
|
+
const server = await Mockaton(
|
|
507
|
+
config // Not required, but it’s not read by default.
|
|
508
|
+
)
|
|
509
509
|
```
|
|
510
|
-
See [src/cli.js](src/cli.js) or [src/Mockaton.test.js](src/Mockaton.test.js) for more examples.
|
|
511
|
-
|
|
512
510
|
</details>
|
|
513
511
|
|
|
514
512
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "mockaton",
|
|
3
3
|
"description": "HTTP Mock Server",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "10.0.0",
|
|
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.22.3"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/Dashboard.js
CHANGED
|
@@ -644,6 +644,7 @@ Resizer.onUp = function () {
|
|
|
644
644
|
window.removeEventListener('pointermove', Resizer.onMove)
|
|
645
645
|
window.removeEventListener('pointerup', Resizer.onUp)
|
|
646
646
|
cancelAnimationFrame(Resizer.raf)
|
|
647
|
+
Resizer.raf = 0
|
|
647
648
|
document.body.style.userSelect = 'auto'
|
|
648
649
|
document.body.style.cursor = 'auto'
|
|
649
650
|
}
|
package/src/Mockaton.js
CHANGED
|
@@ -15,27 +15,28 @@ import { sendNoContent, sendInternalServerError, sendUnprocessableContent } from
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
export function Mockaton(options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
setup(options)
|
|
20
|
+
|
|
21
|
+
mockBrokerCollection.init()
|
|
22
|
+
staticCollection.init()
|
|
23
|
+
watchMocksDir()
|
|
24
|
+
watchStaticDir()
|
|
25
|
+
|
|
26
|
+
const server = createServer(onRequest)
|
|
27
|
+
server.on('error', reject)
|
|
28
|
+
server.listen(config.port, config.host, () => {
|
|
29
|
+
const { address, port } = server.address()
|
|
30
|
+
const url = `http://${address}:${port}`
|
|
31
|
+
const dashboardUrl = url + API.dashboard
|
|
32
|
+
logger.info('Listening', url)
|
|
33
|
+
logger.info('Dashboard', dashboardUrl)
|
|
34
|
+
config.onReady(dashboardUrl)
|
|
35
|
+
resolve(server)
|
|
36
|
+
})
|
|
33
37
|
})
|
|
34
|
-
|
|
35
|
-
return server
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
|
|
39
40
|
async function onRequest(req, response) {
|
|
40
41
|
response.on('error', logger.warn)
|
|
41
42
|
|
package/src/cli.js
CHANGED
|
@@ -36,7 +36,7 @@ catch (error) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
if (args.version)
|
|
39
|
+
if (args.version)
|
|
40
40
|
console.log(pkgJSON.version)
|
|
41
41
|
|
|
42
42
|
else if (args.help)
|
|
@@ -83,10 +83,7 @@ else {
|
|
|
83
83
|
if (args['no-open']) opts.onReady = () => {}
|
|
84
84
|
|
|
85
85
|
try {
|
|
86
|
-
Mockaton(opts)
|
|
87
|
-
console.error(error.message)
|
|
88
|
-
process.exit(1)
|
|
89
|
-
})
|
|
86
|
+
await Mockaton(opts)
|
|
90
87
|
}
|
|
91
88
|
catch (err) {
|
|
92
89
|
console.error(err?.message || err)
|