msw 2.6.9 → 2.7.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/cli/init.js +9 -9
- package/cli/invariant.js +2 -2
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +2 -2
package/cli/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
|
-
const
|
|
3
|
+
const colors = require('picocolors')
|
|
4
4
|
const confirm = require('@inquirer/confirm').default
|
|
5
5
|
const invariant = require('./invariant')
|
|
6
6
|
const { SERVICE_WORKER_BUILD_PATH } = require('../config/constants')
|
|
@@ -34,7 +34,7 @@ module.exports = async function init(args) {
|
|
|
34
34
|
// will equal to false.
|
|
35
35
|
else if (args.save == null) {
|
|
36
36
|
console.log(`\
|
|
37
|
-
${
|
|
37
|
+
${colors.cyan(
|
|
38
38
|
'INFO',
|
|
39
39
|
)} In order to ease the future updates to the worker script,
|
|
40
40
|
we recommend saving the path to the worker directory in your package.json.`)
|
|
@@ -141,20 +141,20 @@ async function copyWorkerScript(destination, cwd) {
|
|
|
141
141
|
*/
|
|
142
142
|
function printSuccessMessage(paths) {
|
|
143
143
|
console.log(`
|
|
144
|
-
${
|
|
145
|
-
${paths.map((path) =>
|
|
144
|
+
${colors.green('Worker script successfully copied!')}
|
|
145
|
+
${paths.map((path) => colors.gray(` - ${path}\n`))}
|
|
146
146
|
Continue by describing the network in your application:
|
|
147
147
|
|
|
148
148
|
|
|
149
|
-
${
|
|
149
|
+
${colors.red(colors.bold('https://mswjs.io/docs/getting-started'))}
|
|
150
150
|
`)
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
function printFailureMessage(pathsWithErrors) {
|
|
154
154
|
console.error(`\
|
|
155
|
-
${
|
|
155
|
+
${colors.red('Copying the worker script failed at following paths:')}
|
|
156
156
|
${pathsWithErrors
|
|
157
|
-
.map(([path, error]) =>
|
|
157
|
+
.map(([path, error]) => colors.gray(` - ${path}`) + '\n' + ` ${error}`)
|
|
158
158
|
.join('\n\n')}
|
|
159
159
|
`)
|
|
160
160
|
}
|
|
@@ -167,7 +167,7 @@ function saveWorkerDirectory(packageJsonPath, publicDir) {
|
|
|
167
167
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
168
168
|
|
|
169
169
|
console.log(
|
|
170
|
-
|
|
170
|
+
colors.gray('Updating "msw.workerDirectory" at "%s"...'),
|
|
171
171
|
packageJsonPath,
|
|
172
172
|
)
|
|
173
173
|
|
|
@@ -200,7 +200,7 @@ function saveWorkerDirectory(packageJsonPath, publicDir) {
|
|
|
200
200
|
function promptWorkerDirectoryUpdate(message, packageJsonPath, publicDir) {
|
|
201
201
|
return confirm({
|
|
202
202
|
theme: {
|
|
203
|
-
prefix:
|
|
203
|
+
prefix: colors.yellowBright('?'),
|
|
204
204
|
},
|
|
205
205
|
message,
|
|
206
206
|
}).then((answer) => {
|
package/cli/invariant.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const colors = require('picocolors')
|
|
2
2
|
|
|
3
3
|
module.exports = function invariant(predicate, message, ...args) {
|
|
4
4
|
if (!predicate) {
|
|
5
|
-
console.error(
|
|
5
|
+
console.error(colors.red(message), ...args)
|
|
6
6
|
process.exit(1)
|
|
7
7
|
}
|
|
8
8
|
}
|
package/lib/mockServiceWorker.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Please do NOT serve this file on production.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const PACKAGE_VERSION = '2.
|
|
11
|
+
const PACKAGE_VERSION = '2.7.0'
|
|
12
12
|
const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
|
|
13
13
|
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
14
14
|
const activeClientIds = new Set()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "msw",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
|
|
5
5
|
"main": "./lib/core/index.js",
|
|
6
6
|
"module": "./lib/core/index.mjs",
|
|
@@ -127,12 +127,12 @@
|
|
|
127
127
|
"@open-draft/until": "^2.1.0",
|
|
128
128
|
"@types/cookie": "^0.6.0",
|
|
129
129
|
"@types/statuses": "^2.0.4",
|
|
130
|
-
"chalk": "^4.1.2",
|
|
131
130
|
"graphql": "^16.8.1",
|
|
132
131
|
"headers-polyfill": "^4.0.2",
|
|
133
132
|
"is-node-process": "^1.2.0",
|
|
134
133
|
"outvariant": "^1.4.3",
|
|
135
134
|
"path-to-regexp": "^6.3.0",
|
|
135
|
+
"picocolors": "^1.1.1",
|
|
136
136
|
"strict-event-emitter": "^0.5.1",
|
|
137
137
|
"type-fest": "^4.26.1",
|
|
138
138
|
"yargs": "^17.7.2"
|