grunt-connect-proxy3
Advanced tools
Comparing version 2.2.0 to 3.0.1
@@ -0,7 +1,21 @@ | ||
# grunt-connect-proxy3 changelog | ||
### [3.0.1](https://github.com/ext/grunt-connect-proxy/compare/v3.0.0...v3.0.1) (2021-02-21) | ||
### Dependency upgrades | ||
- **deps:** update dependency http-proxy to v1.18.1 ([7b43bb5](https://github.com/ext/grunt-connect-proxy/commit/7b43bb5d7f743300e99c84c38a6ec5bf2ddba664)) | ||
# `grunt-connect-proxy3` changelog | ||
## Upcoming release | ||
## 3.0.0 (2020-04-11) | ||
- BREAKING CHANGE: drop node 8 support | ||
- Update dependencies | ||
- Drop `grunt-eslint` dependency. | ||
## 2.2.0 (2019-06-26) | ||
- Bumped dependencies | ||
## 2.1.1 (2019-06-18) | ||
@@ -8,0 +22,0 @@ |
const utils = module.exports; | ||
const grunt = require("grunt"); | ||
let proxies = []; | ||
const rewrite = function(req) { | ||
return function(rule) { | ||
const rewrite = function (req) { | ||
return function (rule) { | ||
if (rule.from.test(req.url)) { | ||
@@ -12,15 +12,15 @@ req.url = req.url.replace(rule.from, rule.to); | ||
utils.registerProxy = function(proxy) { | ||
utils.registerProxy = function (proxy) { | ||
proxies.push(proxy); | ||
}; | ||
utils.proxies = function() { | ||
utils.proxies = function () { | ||
return proxies; | ||
}; | ||
utils.reset = function() { | ||
utils.reset = function () { | ||
proxies = []; | ||
}; | ||
utils.validateRewrite = function(rule) { | ||
utils.validateRewrite = function (rule) { | ||
if ( | ||
@@ -38,6 +38,6 @@ !rule || | ||
utils.processRewrites = function(rewrites) { | ||
utils.processRewrites = function (rewrites) { | ||
const rules = []; | ||
Object.keys(rewrites || {}).forEach(function(from) { | ||
Object.keys(rewrites || {}).forEach(function (from) { | ||
const rule = { | ||
@@ -62,3 +62,3 @@ from: from, | ||
utils.matchContext = function(context, url) { | ||
utils.matchContext = function (context, url) { | ||
let negativeContexts; | ||
@@ -69,13 +69,13 @@ let contexts = context; | ||
} | ||
const positiveContexts = contexts.filter(function(c) { | ||
const positiveContexts = contexts.filter(function (c) { | ||
return c.charAt(0) !== "!"; | ||
}); | ||
negativeContexts = contexts.filter(function(c) { | ||
negativeContexts = contexts.filter(function (c) { | ||
return c.charAt(0) === "!"; | ||
}); | ||
// Remove the '!' character from the contexts | ||
negativeContexts = negativeContexts.map(function(c) { | ||
negativeContexts = negativeContexts.map(function (c) { | ||
return c.slice(1); | ||
}); | ||
const negativeMatch = negativeContexts.find(function(c) { | ||
const negativeMatch = negativeContexts.find(function (c) { | ||
return url.lastIndexOf(c, 0) === 0; | ||
@@ -87,3 +87,3 @@ }); | ||
} | ||
const positiveMatch = positiveContexts.find(function(c) { | ||
const positiveMatch = positiveContexts.find(function (c) { | ||
return url.lastIndexOf(c, 0) === 0; | ||
@@ -95,3 +95,3 @@ }); | ||
utils.getTargetUrl = function(options) { | ||
utils.getTargetUrl = function (options) { | ||
let protocol = options.ws ? "ws" : "http"; | ||
@@ -116,3 +116,3 @@ if (options.https) { | ||
proxies.forEach(function(proxy) { | ||
proxies.forEach(function (proxy) { | ||
if ( | ||
@@ -157,9 +157,9 @@ !proxied && | ||
if (hiddenHeaders && hiddenHeaders.length > 0) { | ||
hiddenHeaders = hiddenHeaders.map(function(header) { | ||
hiddenHeaders = hiddenHeaders.map(function (header) { | ||
return header.toLowerCase(); | ||
}); | ||
proxy.server.on("proxyRes", function(proxyRes) { | ||
proxy.server.on("proxyRes", function (proxyRes) { | ||
const headers = proxyRes.headers; | ||
hiddenHeaders.forEach(function(header) { | ||
hiddenHeaders.forEach(function (header) { | ||
if (header in headers) { | ||
@@ -173,3 +173,3 @@ delete headers[header]; | ||
utils.proxyRequest = function(req, res, next) { | ||
utils.proxyRequest = function (req, res, next) { | ||
let proxied = false; | ||
@@ -179,3 +179,3 @@ | ||
proxies.forEach(function(proxy) { | ||
proxies.forEach(function (proxy) { | ||
if ( | ||
@@ -191,3 +191,3 @@ !proxied && | ||
if (proxy.config.headers != null) { | ||
Object.entries(proxy.config.headers).forEach(function([ | ||
Object.entries(proxy.config.headers).forEach(function ([ | ||
key, | ||
@@ -200,3 +200,3 @@ value, | ||
proxy.server.proxyRequest(req, res, proxy.server, function(err) { | ||
proxy.server.proxyRequest(req, res, proxy.server, function (err) { | ||
if (proxy.config.errorHandler) { | ||
@@ -203,0 +203,0 @@ grunt.log.verbose.writeln( |
108
package.json
{ | ||
"name": "grunt-connect-proxy3", | ||
"version": "3.0.1", | ||
"description": "Provides a http proxy as middleware for grunt connect.", | ||
"version": "2.2.0", | ||
"keywords": [ | ||
"gruntplugin", | ||
"proxy", | ||
"connect", | ||
"http", | ||
"grunt" | ||
], | ||
"homepage": "https://github.com/ext/grunt-connect-proxy", | ||
"bugs": { | ||
"url": "https://github.com/ext/grunt-connect-proxy/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ext/grunt-connect-proxy.git" | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
@@ -14,16 +29,3 @@ "name": "Drewz", | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/ext/grunt-connect-proxy.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/ext/grunt-connect-proxy/issues" | ||
}, | ||
"keywords": [ | ||
"gruntplugin", | ||
"proxy", | ||
"connect", | ||
"http", | ||
"grunt" | ||
], | ||
"main": "tasks/connect_proxy.js", | ||
"files": [ | ||
@@ -33,59 +35,41 @@ "lib", | ||
], | ||
"license": "MIT", | ||
"main": "tasks/connect_proxy.js", | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"postversion": "git push --follow-tags", | ||
"prettier:check": "prettier '**/*.{ts,js,json,md,scss,vue}' --list-different", | ||
"prettier:write": "prettier '**/*.{ts,js,json,md,scss,vue}' --write", | ||
"test": "grunt eslint test", | ||
"version": "sv-update-changelog -i && git add CHANGELOG.md" | ||
"eslint": "eslint .", | ||
"prepare": "husky install", | ||
"prettier:check": "prettier . --check", | ||
"prettier:write": "prettier . --write", | ||
"test": "grunt test" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.{ts,js,json,md,scss}": [ | ||
"prettier --write", | ||
"git add" | ||
] | ||
"*.{ts,js,json,md,scss}": "prettier --write" | ||
}, | ||
"renovate": { | ||
"extends": [ | ||
"config:js-lib" | ||
], | ||
"automerge": true, | ||
"automergeType": "branch", | ||
"prCreation": "not-pending", | ||
"unpublishSafe": true, | ||
"major": { | ||
"automerge": false | ||
} | ||
"dependencies": { | ||
"http-proxy": "1.18.1" | ||
}, | ||
"devDependencies": { | ||
"@html-validate/semantic-release-config": "^1.2.6", | ||
"eslint": "7.20.0", | ||
"eslint-config-prettier": "7.2.0", | ||
"eslint-config-sidvind": "1.3.2", | ||
"eslint-plugin-prettier": "3.3.1", | ||
"grunt": "1.3.0", | ||
"grunt-contrib-clean": "2.0.0", | ||
"grunt-contrib-connect": "3.0.0", | ||
"grunt-contrib-nodeunit": "2.1.0", | ||
"husky": "5.1.0", | ||
"lint-staged": "10.5.4", | ||
"prettier": "2.2.1", | ||
"semantic-release": "^17.3.9" | ||
}, | ||
"peerDependencies": { | ||
"grunt": "^1.0.1" | ||
}, | ||
"dependencies": { | ||
"http-proxy": "1.17.0" | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"devDependencies": { | ||
"@sidvind/build-scripts": "1.0.0", | ||
"eslint": "6.0.1", | ||
"eslint-config-prettier": "6.0.0", | ||
"eslint-config-sidvind": "1.3.2", | ||
"eslint-plugin-prettier": "3.1.0", | ||
"grunt": "1.0.4", | ||
"grunt-contrib-clean": "2.0.0", | ||
"grunt-contrib-connect": "2.0.0", | ||
"grunt-contrib-nodeunit": "2.0.0", | ||
"grunt-eslint": "21.1.0", | ||
"husky": "2.5.0", | ||
"is-ci": "2.0.0", | ||
"lint-staged": "8.2.1", | ||
"prettier": "1.18.2" | ||
"renovate": { | ||
"extends": [ | ||
"@html-validate" | ||
] | ||
} | ||
} |
@@ -132,3 +132,3 @@ [![NPM version][npm-image]][npm-url] | ||
```js | ||
grunt.registerTask("server", function(target) { | ||
grunt.registerTask("server", function (target) { | ||
grunt.task.run([ | ||
@@ -221,3 +221,3 @@ "clean:server", | ||
"^/changingcontext": "/anothercontext", | ||
"^/updating(context)": function(match, p1) { | ||
"^/updating(context)": function (match, p1) { | ||
return "/new" + p1; | ||
@@ -309,3 +309,3 @@ }, | ||
grunt.registerTask("e2etest", function(target) { | ||
grunt.registerTask("e2etest", function (target) { | ||
grunt.task.run(["configureProxies:server2", "open", "karma"]); | ||
@@ -312,0 +312,0 @@ }); |
@@ -11,7 +11,7 @@ /* | ||
module.exports = function(grunt) { | ||
module.exports = function (grunt) { | ||
grunt.registerTask( | ||
"configureProxies", | ||
"Configure any specified connect proxies.", | ||
function(config) { | ||
function (config) { | ||
// setup proxy | ||
@@ -21,3 +21,3 @@ const httpProxy = require("http-proxy"); | ||
let proxyOptions = []; | ||
const validateProxyConfig = function(proxyOption) { | ||
const validateProxyConfig = function (proxyOption) { | ||
if ( | ||
@@ -60,3 +60,3 @@ proxyOption.host === undefined || | ||
} | ||
proxyOptions.forEach(function(proxy) { | ||
proxyOptions.forEach(function (proxy) { | ||
proxyOption = Object.assign( | ||
@@ -69,3 +69,3 @@ { | ||
rules: [], | ||
errorHandler: function() {}, | ||
errorHandler: function () {}, | ||
ws: false, | ||
@@ -91,3 +91,3 @@ }, | ||
}) | ||
.on("error", function(err) { | ||
.on("error", function (err) { | ||
grunt.log.error("Proxy error: ", err.code); | ||
@@ -94,0 +94,0 @@ }), |
21299
13
+ Addedeventemitter3@4.0.7(transitive)
+ Addedhttp-proxy@1.18.1(transitive)
- Removedeventemitter3@3.1.2(transitive)
- Removedhttp-proxy@1.17.0(transitive)
Updatedhttp-proxy@1.18.1