netlify 10.0.0 → 11.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/README.md CHANGED
@@ -123,7 +123,7 @@ try {
123
123
  deploy_id: '4567',
124
124
  })
125
125
  // Calls may fail!
126
- } catch (error) {
126
+ } catch {
127
127
  // handle error
128
128
  }
129
129
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "netlify",
3
3
  "description": "Netlify Node.js API client",
4
- "version": "10.0.0",
4
+ "version": "11.0.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "src/**/*.js",
@@ -10,11 +10,10 @@
10
10
  "exports": "./src/index.js",
11
11
  "main": "./src/index.js",
12
12
  "scripts": {
13
+ "prepare": "husky install node_modules/@netlify/eslint-config-node/.husky/",
13
14
  "prepublishOnly": "npm ci && npm test",
14
15
  "test": "run-s format test:dev",
15
16
  "format": "run-s format:check-fix:*",
16
- "format:lint": "eslint --ignore-path .gitignore --fix --cache --format=codeframe --max-warnings=0 \"src/**/*.js\"",
17
- "format:prettier": "prettier --ignore-path .gitignore --write --loglevel warn \"src/**/*.js\" \"*.{js,md,yml,json}\" \"!package-lock.json\"",
18
17
  "format:ci": "run-s format:check:*",
19
18
  "format:check-fix:lint": "run-e format:check:lint format:fix:lint",
20
19
  "format:check:lint": "cross-env-shell eslint $npm_package_config_eslint",
@@ -23,19 +22,13 @@
23
22
  "format:check:prettier": "cross-env-shell prettier --check $npm_package_config_prettier",
24
23
  "format:fix:prettier": "cross-env-shell prettier --write $npm_package_config_prettier",
25
24
  "test:dev": "ava",
26
- "test:ci": "nyc -r lcovonly -r text -r json ava",
25
+ "test:ci": "c8 -r lcovonly -r text -r json ava",
27
26
  "update-snapshots": "ava -u"
28
27
  },
29
28
  "config": {
30
29
  "eslint": "--ignore-path .gitignore --cache --format=codeframe --max-warnings=0 \"{src,tests,.github}/**/*.{cjs,mjs,js,md,html}\" \"*.{cjs,mjs,js,md,html}\" \".*.{cjs,mjs,js,md,html}\"",
31
30
  "prettier": "--ignore-path .gitignore --loglevel=warn \"{src,tests,.github}/**/*.{cjs,mjs,js,md,yml,json,html}\" \"*.{cjs,mjs,js,yml,json,html}\" \".*.{cjs,mjs,js,yml,json,html}\" \"!package-lock.json\" \"!CHANGELOG.md\""
32
31
  },
33
- "husky": {
34
- "hooks": {
35
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
36
- "pre-push": "npm run format"
37
- }
38
- },
39
32
  "license": "MIT",
40
33
  "author": "Netlify Inc.",
41
34
  "contributors": [
@@ -59,22 +52,22 @@
59
52
  "node client"
60
53
  ],
61
54
  "dependencies": {
62
- "@netlify/open-api": "^2.6.0",
55
+ "@netlify/open-api": "^2.8.0",
63
56
  "lodash.camelcase": "^4.3.0",
64
57
  "micro-api-client": "^3.3.0",
65
- "node-fetch": "^2.6.1",
58
+ "node-fetch": "^3.0.0",
66
59
  "omit.js": "^2.0.2",
67
- "p-wait-for": "^3.2.0",
60
+ "p-wait-for": "^4.0.0",
68
61
  "qs": "^6.9.6"
69
62
  },
70
63
  "devDependencies": {
71
- "@netlify/eslint-config-node": "^3.3.10",
64
+ "@netlify/eslint-config-node": "^5.1.4",
72
65
  "ava": "^3.0.0",
66
+ "c8": "^7.11.0",
73
67
  "from2-string": "^1.1.0",
74
- "husky": "^4.3.8",
68
+ "husky": "^7.0.4",
75
69
  "nock": "^13.0.0",
76
70
  "npm-run-all": "^4.1.5",
77
- "nyc": "^15.1.0",
78
71
  "uuid": "^8.3.2"
79
72
  },
80
73
  "engines": {
@@ -62,11 +62,9 @@ const makeRequestOrRetry = async function ({ url, method, defaultHeaders, agent,
62
62
  // Using a loop is simpler here
63
63
  for (let index = 0; index <= MAX_RETRY; index++) {
64
64
  const optsA = getOpts({ method, defaultHeaders, agent, requestParams, opts })
65
- // eslint-disable-next-line no-await-in-loop
66
65
  const { response, error } = await makeRequest(url, optsA)
67
66
 
68
67
  if (shouldRetry({ response, error }) && index !== MAX_RETRY) {
69
- // eslint-disable-next-line no-await-in-loop
70
68
  await waitForRetry(response)
71
69
  continue
72
70
  }
@@ -10,7 +10,7 @@ export const parseResponse = async function (response) {
10
10
 
11
11
  if (!response.ok) {
12
12
  const ErrorType = responseType === 'json' ? JSONHTTPError : TextHTTPError
13
- throw new ErrorType(response, parsedResponse)
13
+ throw addFallbackErrorMessage(new ErrorType(response, parsedResponse), textResponse)
14
14
  }
15
15
 
16
16
  return parsedResponse
@@ -33,14 +33,21 @@ const parseJsonResponse = function (response, textResponse, responseType) {
33
33
 
34
34
  try {
35
35
  return JSON.parse(textResponse)
36
- } catch (error) {
37
- throw new TextHTTPError(response, textResponse)
36
+ } catch {
37
+ throw addFallbackErrorMessage(new TextHTTPError(response, textResponse), textResponse)
38
38
  }
39
39
  }
40
40
 
41
+ const addFallbackErrorMessage = function (error, textResponse) {
42
+ error.message = error.message || textResponse
43
+ return error
44
+ }
45
+
41
46
  export const getFetchError = function (error, url, opts) {
42
47
  const data = omit.default(opts, ['Authorization'])
43
- error.name = 'FetchError'
48
+ if (error.name !== 'FetchError') {
49
+ error.name = 'FetchError'
50
+ }
44
51
  error.url = url
45
52
  error.data = data
46
53
  return error