Skip to content

Commit 993fee0

Browse files
committed
major: initial commit
0 parents  commit 993fee0

File tree

11 files changed

+342
-0
lines changed

11 files changed

+342
-0
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/node
6+
steps:
7+
- checkout
8+
- restore_cache:
9+
key: dependency-cache-{{ checksum "package.json" }}
10+
- run:
11+
command: yarn
12+
- save_cache:
13+
key: dependency-cache-{{ checksum "package.json" }}
14+
paths:
15+
- ./node_modules
16+
- run:
17+
name: test
18+
command: yarn run test

.eslintrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": [
3+
"plugin:cypress-dev/general",
4+
"plugin:cypress-dev/tests"
5+
],
6+
"rules": {
7+
"comma-dangle": "off",
8+
"no-console": "off"
9+
},
10+
"env": {
11+
"node": true,
12+
"es6": true
13+
}
14+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
.DS_Store
3+
npm-debug.log

.npmrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
registry=http://registry.npmjs.org/
2+
save-exact=true
3+
progress=false
4+
package-lock=false

.travis.yml

Whitespace-only changes.

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# get-windows-proxy
2+
3+
> Node.js module that finds a user's system proxy settings from their Windows registry settings.
4+
5+
[![NPM][npm-icon] ][npm-url]
6+
7+
[![Build status][ci-image] ][ci-url]
8+
[![semantic-release][semantic-image] ][semantic-url]
9+
10+
## Install
11+
12+
Requires [Node](https://nodejs.org/en/) version 6 or above.
13+
14+
```sh
15+
npm install --save get-windows-proxy
16+
```
17+
18+
## Usage
19+
20+
```js
21+
const getWindowsProxy = require('get-windows-proxy')
22+
23+
const proxy = getWindowsProxy()
24+
25+
if (typeof proxy !== undefined) {
26+
console.log('HTTP Proxy: ', proxy.httpProxy)
27+
console.log('Proxy exclusions: ', proxy.noProxy)
28+
29+
// Sample output:
30+
// HTTP Proxy: http://192.168.122.1:1337
31+
// Proxy exclusions: corporate-intranet.com,other-stuff.local,localhost,127.0.0.0/8,::1
32+
}
33+
```
34+
35+
## How does it work?
36+
37+
Windows generally stores proxy settings in the registry under
38+
`HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings`.
39+
This module uses [registry-js][registry-js] to read those values out. Then, if
40+
`ProxyEnable` is set to `1`, we know that the proxy is enabled. From there, we
41+
read the proxy server from `ProxyServer` and the proxy bypass list from
42+
`ProxyOverride`. Finally, these values are converted to values compatible with
43+
the `HTTP_PROXY` and `NO_PROXY` environment variables that most applications are
44+
compatible with, and returned to the user.
45+
46+
### Small print
47+
48+
Author: [Cypress.io](https://www.cypress.io) © 2019
49+
50+
License: MIT - do anything with the code, but don't blame me if it does not work.
51+
52+
Support: if you find any problems with this module, email / tweet /
53+
[open issue](https://github.com/cypress-io/get-windows-proxy/issues) on Github
54+
55+
## MIT License
56+
57+
Copyright (c) 2019 Cypress.io
58+
59+
Permission is hereby granted, free of charge, to any person
60+
obtaining a copy of this software and associated documentation
61+
files (the "Software"), to deal in the Software without
62+
restriction, including without limitation the rights to use,
63+
copy, modify, merge, publish, distribute, sublicense, and/or sell
64+
copies of the Software, and to permit persons to whom the
65+
Software is furnished to do so, subject to the following
66+
conditions:
67+
68+
The above copyright notice and this permission notice shall be
69+
included in all copies or substantial portions of the Software.
70+
71+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
72+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
73+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
74+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
75+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
76+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
77+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
78+
OTHER DEALINGS IN THE SOFTWARE.
79+
80+
[npm-icon]: https://nodei.co/npm/get-windows-proxy.svg?downloads=true
81+
[npm-url]: https://npmjs.org/package/get-windows-proxy
82+
[ci-image]: https://travis-ci.org/cypress-io/get-windows-proxy.svg?branch=master
83+
[ci-url]: https://travis-ci.org/cypress-io/get-windows-proxy
84+
[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
85+
[semantic-url]: https://github.com/semantic-release/semantic-release
86+
[registry-js]: https://github.com/desktop/registry-js/

issue_template.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Thank you for taking time to open a new issue. Please answer a few questions to help us fix it faster. You can delete text that is irrelevant to the issue.
2+
3+
## Is this a bug report or a feature request?
4+
5+
If this is a bug report, please provide as much info as possible
6+
7+
- version
8+
- platform
9+
- expected behavior
10+
- actual behavior
11+
12+
If this is a new feature request, please describe it below

package.json

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"name": "get-windows-proxy",
3+
"description": "Node.js module that finds a user's system proxy settings depending on their platform.",
4+
"version": "0.0.0-development",
5+
"author": "Zach Bloomquist <[email protected]>",
6+
"bugs": "https://github.com/cypress-io/get-windows-proxy/issues",
7+
"config": {
8+
"pre-git": {
9+
"commit-msg": "simple",
10+
"pre-commit": [
11+
"npm prune",
12+
"npm run deps",
13+
"npm test",
14+
"git add src/*.js",
15+
"npm run ban"
16+
],
17+
"pre-push": [
18+
"npm run unused-deps",
19+
"npm run secure",
20+
"npm run license",
21+
"npm run ban -- --all",
22+
"npm run size"
23+
],
24+
"post-commit": [],
25+
"post-merge": []
26+
}
27+
},
28+
"engines": {
29+
"node": ">=6"
30+
},
31+
"files": [
32+
"src/*.js",
33+
"!src/*-spec.js"
34+
],
35+
"homepage": "https://github.com/cypress-io/get-windows-proxy#readme",
36+
"keywords": [
37+
"http_proxy",
38+
"windows registry",
39+
"proxy"
40+
],
41+
"license": "MIT",
42+
"main": "src/",
43+
"private": false,
44+
"publishConfig": {
45+
"registry": "http://registry.npmjs.org/"
46+
},
47+
"repository": {
48+
"type": "git",
49+
"url": "https://github.com/cypress-io/get-windows-proxy.git"
50+
},
51+
"scripts": {
52+
"ban": "ban",
53+
"deps": "deps-ok && dependency-check --no-dev .",
54+
"issues": "git-issues",
55+
"license": "license-checker --production --onlyunknown --csv",
56+
"lint": "eslint --fix src/*.js",
57+
"prelint": "npm run pretty",
58+
"pretest": "npm run lint",
59+
"pretty": "prettier-eslint --write 'src/*.js'",
60+
"secure": "nsp check",
61+
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
62+
"test": "npm run unit",
63+
"unit": "mocha src/*-spec.js",
64+
"unused-deps": "dependency-check --unused --no-dev ."
65+
},
66+
"release": {
67+
"analyzeCommits": "simple-commit-message",
68+
"generateNotes": "github-post-release"
69+
},
70+
"devDependencies": {
71+
"ban-sensitive-files": "1.9.2",
72+
"chai": "4.2.0",
73+
"dependency-check": "3.3.0",
74+
"deps-ok": "1.4.1",
75+
"eslint": "5.14.1",
76+
"eslint-plugin-cypress-dev": "2.0.0",
77+
"eslint-plugin-mocha": "5.3.0",
78+
"git-issues": "1.3.1",
79+
"github-post-release": "1.13.1",
80+
"license-checker": "25.0.1",
81+
"mocha": "6.0.2",
82+
"nsp": "3.2.1",
83+
"pre-git": "3.17.1",
84+
"prettier-eslint-cli": "4.7.1",
85+
"semantic-action": "1.1.6",
86+
"sinon": "7.2.5"
87+
},
88+
"dependencies": {
89+
"debug": "4.1.1",
90+
"registry-js": "1.3.3"
91+
}
92+
}

renovate.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": [
3+
"config:base"
4+
],
5+
"automerge": true,
6+
"commitMessage": "{{semanticPrefix}}Update {{depName}} to {{newVersion}} 🌟",
7+
"prTitle": "{{semanticPrefix}}{{#if isPin}}Pin{{else}}Update{{/if}} dependency {{depName}} to version {{#if isRange}}{{newVersion}}{{else}}{{#if isMajor}}{{newVersionMajor}}.x{{else}}{{newVersion}}{{/if}}{{/if}} 🌟",
8+
"major": {
9+
"automerge": false
10+
},
11+
"minor": {
12+
"automerge": false
13+
},
14+
"prConcurrentLimit": 3,
15+
"prHourlyLimit": 2,
16+
"timezone": "America/New_York",
17+
"schedule": [
18+
"after 10pm and before 5am on every weekday",
19+
"every weekend"
20+
]
21+
}

src/get-windows-proxy-spec.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const { expect } = require('chai')
2+
const registry = require('registry-js')
3+
const sinon = require('sinon')
4+
5+
/* eslint-env mocha */
6+
const getWindowsProxy = require('.')
7+
8+
context('getWindowsProxy', () => {
9+
afterEach(() => {
10+
sinon.restore()
11+
})
12+
13+
it('returns Windows proxy info from registry', () => {
14+
sinon
15+
.stub(registry, 'enumerateValues')
16+
.returns([
17+
{ name: 'ProxyEnable', data: 1 },
18+
{ name: 'ProxyServer', data: 'proxy.foobaz:1234' },
19+
{ name: 'ProxyOverride', data: 'a.com;b.com;<local>' }
20+
])
21+
22+
expect(getWindowsProxy()).to.deep.eq({
23+
httpProxy: 'http://proxy.foobaz:1234',
24+
noProxy: 'a.com,b.com,localhost,127.0.0.0/8,::1'
25+
})
26+
})
27+
28+
it('returns undefined if proxy is disabled', () => {
29+
sinon
30+
.stub(registry, 'enumerateValues')
31+
.returns([
32+
{ name: 'ProxyEnable', data: 0 },
33+
{ name: 'ProxyServer', data: 'proxy.foobaz:1234' },
34+
{ name: 'ProxyOverride', data: 'a.com;b.com;<local>' }
35+
])
36+
37+
expect(getWindowsProxy()).to.be.undefined
38+
})
39+
})

0 commit comments

Comments
 (0)