@semantic-release/github
Advanced tools
Comparing version 4.2.18 to 4.3.0
@@ -46,3 +46,3 @@ const url = require('url'); | ||
details: `The [labels option](${linkify( | ||
'README.md#labels' | ||
'README.md#options' | ||
)}) option, if defined, must be an \`Array\` of non empty \`String\`. | ||
@@ -55,3 +55,3 @@ | ||
details: `The [assignees option](${linkify( | ||
'README.md#assignees' | ||
'README.md#options' | ||
)}) option must be an \`Array\` of non empty \`Strings\`. | ||
@@ -67,2 +67,10 @@ | ||
}), | ||
EINVALIDPROXY: ({proxy}) => ({ | ||
message: 'Invalid `proxy` option.', | ||
details: `The [proxy option](${linkify( | ||
'README.md#proxy' | ||
)}) option must be a \`String\` or an \`Objects\` with a \`host\` and a \`port\` property. | ||
Your configuration for the \`proxy\` option is \`${stringify(proxy)}\`.`, | ||
}), | ||
EMISSINGREPO: ({owner, repo}) => ({ | ||
@@ -69,0 +77,0 @@ message: `The repository ${owner}/${repo} doesn't exist.`, |
@@ -11,7 +11,7 @@ const {template} = require('lodash'); | ||
module.exports = async (pluginConfig, {options: {branch, repositoryUrl}, errors, logger}) => { | ||
const {githubToken, githubUrl, githubApiPathPrefix, failComment, failTitle, labels, assignees} = resolveConfig( | ||
const {githubToken, githubUrl, githubApiPathPrefix, proxy, failComment, failTitle, labels, assignees} = resolveConfig( | ||
pluginConfig | ||
); | ||
const {name: repo, owner} = parseGithubUrl(repositoryUrl); | ||
const github = getClient({githubToken, githubUrl, githubApiPathPrefix}); | ||
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy}); | ||
const body = failComment ? template(failComment)({branch, errors}) : getFailComment(branch, errors); | ||
@@ -18,0 +18,0 @@ const [srIssue] = await findSRIssues(github, failTitle, owner, repo); |
@@ -0,1 +1,2 @@ | ||
const url = require('url'); | ||
const {memoize} = require('lodash'); | ||
@@ -6,2 +7,4 @@ const Octokit = require('@octokit/rest'); | ||
const urljoin = require('url-join'); | ||
const HttpProxyAgent = require('http-proxy-agent'); | ||
const HttpsProxyAgent = require('https-proxy-agent'); | ||
@@ -101,2 +104,3 @@ /** | ||
githubApiPathPrefix, | ||
proxy, | ||
retry = DEFAULT_RETRY, | ||
@@ -107,5 +111,12 @@ limit = RATE_LIMITS, | ||
const baseUrl = githubUrl && urljoin(githubUrl, githubApiPathPrefix); | ||
const github = new Octokit({baseUrl}); | ||
const github = new Octokit({ | ||
baseUrl, | ||
agent: proxy | ||
? baseUrl && url.parse(baseUrl).protocol.replace(':', '') === 'http' | ||
? new HttpProxyAgent(proxy) | ||
: new HttpsProxyAgent(proxy) | ||
: undefined, | ||
}); | ||
github.authenticate({type: 'token', token: githubToken}); | ||
return new Proxy(github, handler(retry, limit, new Bottleneck({minTime: globalLimit}))); | ||
}; |
@@ -12,5 +12,5 @@ const {basename, extname} = require('path'); | ||
module.exports = async (pluginConfig, {options: {branch, repositoryUrl}, nextRelease: {gitTag, notes}, logger}) => { | ||
const {githubToken, githubUrl, githubApiPathPrefix, assets} = resolveConfig(pluginConfig); | ||
const {githubToken, githubUrl, githubApiPathPrefix, proxy, assets} = resolveConfig(pluginConfig); | ||
const {name: repo, owner} = parseGithubUrl(repositoryUrl); | ||
const github = getClient({githubToken, githubUrl, githubApiPathPrefix}); | ||
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy}); | ||
const release = {owner, repo, tag_name: gitTag, name: gitTag, target_commitish: branch, body: notes}; // eslint-disable-line camelcase | ||
@@ -17,0 +17,0 @@ |
@@ -6,2 +6,3 @@ const {isUndefined, castArray} = require('lodash'); | ||
githubApiPathPrefix, | ||
proxy, | ||
assets, | ||
@@ -17,2 +18,3 @@ successComment, | ||
githubApiPathPrefix: githubApiPathPrefix || process.env.GH_PREFIX || process.env.GITHUB_PREFIX || '', | ||
proxy: proxy || process.env.HTTP_PROXY, | ||
assets: assets ? castArray(assets) : assets, | ||
@@ -19,0 +21,0 @@ successComment, |
@@ -17,5 +17,5 @@ const {isUndefined, uniqBy, template, flatten} = require('lodash'); | ||
) => { | ||
const {githubToken, githubUrl, githubApiPathPrefix, successComment, failTitle} = resolveConfig(pluginConfig); | ||
const {githubToken, githubUrl, githubApiPathPrefix, proxy, successComment, failTitle} = resolveConfig(pluginConfig); | ||
const {name: repo, owner} = parseGithubUrl(repositoryUrl); | ||
const github = getClient({githubToken, githubUrl, githubApiPathPrefix}); | ||
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy}); | ||
const releaseInfos = releases.filter(release => Boolean(release.name)); | ||
@@ -22,0 +22,0 @@ const shas = commits.map(commit => commit.hash); |
@@ -1,2 +0,2 @@ | ||
const {isString, isPlainObject, isUndefined, isArray} = require('lodash'); | ||
const {isString, isPlainObject, isUndefined, isArray, isNumber} = require('lodash'); | ||
const parseGithubUrl = require('parse-github-url'); | ||
@@ -14,2 +14,4 @@ const urlJoin = require('url-join'); | ||
const VALIDATORS = { | ||
proxy: proxy => | ||
isNonEmptyString(proxy) || (isPlainObject(proxy) && isNonEmptyString(proxy.host) && isNumber(proxy.port)), | ||
assets: isArrayOf( | ||
@@ -26,5 +28,5 @@ asset => isStringOrStringArray(asset) || (isPlainObject(asset) && isStringOrStringArray(asset.path)) | ||
module.exports = async (pluginConfig, {options: {repositoryUrl}, logger}) => { | ||
const {githubToken, githubUrl, githubApiPathPrefix, ...options} = resolveConfig(pluginConfig); | ||
const {githubToken, githubUrl, githubApiPathPrefix, proxy, ...options} = resolveConfig(pluginConfig); | ||
const errors = Object.entries(options).reduce( | ||
const errors = Object.entries({...options, proxy}).reduce( | ||
(errors, [option, value]) => | ||
@@ -46,4 +48,4 @@ !isUndefined(value) && value !== false && !VALIDATORS[option](value) | ||
errors.push(getError('EINVALIDGITHUBURL')); | ||
} else if (githubToken) { | ||
const github = getClient({githubToken, githubUrl, githubApiPathPrefix}); | ||
} else if (githubToken && !errors.find(({code}) => code === 'EINVALIDPROXY')) { | ||
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy}); | ||
@@ -50,0 +52,0 @@ try { |
{ | ||
"name": "@semantic-release/github", | ||
"description": "Set of semantic-release plugins for publishing a GitHub release", | ||
"version": "4.2.18", | ||
"version": "4.3.0", | ||
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)", | ||
@@ -26,2 +26,4 @@ "bugs": { | ||
"globby": "^8.0.0", | ||
"http-proxy-agent": "^2.1.0", | ||
"https-proxy-agent": "^2.2.1", | ||
"issue-parser": "^2.0.0", | ||
@@ -43,4 +45,6 @@ "lodash": "^4.17.4", | ||
"nyc": "^12.0.1", | ||
"proxy": "^0.2.4", | ||
"proxyquire": "^2.0.0", | ||
"semantic-release": "^15.0.0", | ||
"server-destroy": "^1.0.1", | ||
"sinon": "^6.0.0", | ||
@@ -47,0 +51,0 @@ "tempy": "^0.2.1", |
@@ -53,2 +53,3 @@ # @semantic-release/github | ||
| `githubApiPathPrefix` | The GitHub Enterprise API prefix. | `GH_PREFIX` or `GITHUB_PREFIX` environment variable. | | ||
| `proxy` | The proxy to use to access the GitHub API. See [proxy](#proxy). | `HTTP_PROXY` environment variable. | | ||
| `assets` | An array of files to upload to the release. See [assets](#assets). | - | | ||
@@ -63,6 +64,24 @@ | `successComment` | The comment added to each issue and pull request resolved by the release. See [successComment](#successcomment). | `:tada: This issue has been resolved in version ${nextRelease.version} :tada:\n\nThe release is available on [GitHub release](<github_release_url>)` | | ||
#### proxy | ||
Can be a the proxy URL or and `Object` with the following properties: | ||
| Property | Description | Default | | ||
|---------------|----------------------------------------------------------------|--------------------------------------| | ||
| `host` | **Required.** Proxy host to connect to. | - | | ||
| `port` | **Required.** Proxy port to connect to. | File name extracted from the `path`. | | ||
| `secureProxy` | If `true`, then use TLS to connect to the proxy. | `false` | | ||
| `headers` | Additional HTTP headers to be sent on the HTTP CONNECT method. | - | | ||
See [node-https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent#new-httpsproxyagentobject-options) and [node-http-proxy-agent](https://github.com/TooTallNate/node-http-proxy-agent) for additional details. | ||
##### proxy examples | ||
`'http://168.63.76.32:3128'`: use the proxy running on host `168.63.76.32` and port `3128` for each GitHub API request. | ||
`{host: '168.63.76.32', port: 3128, headers: {Foo: 'bar'}}`: use the proxy running on host `168.63.76.32` and port `3128` for each GitHub API request, setting the `Foo` header value to `bar`. | ||
#### assets | ||
Can be a [glob](https://github.com/isaacs/node-glob#glob-primer) or and `Array` of | ||
[globs](https://github.com/isaacs/node-glob#glob-primer) and `Object`s with the following properties | ||
[globs](https://github.com/isaacs/node-glob#glob-primer) and `Object`s with the following properties: | ||
@@ -81,3 +100,3 @@ | Property | Description | Default | | ||
Files can be included even if they have a match in `.gitignore`. | ||
**Note**: If a file has a match in `assets` it will be included even if it also has a match in `.gitignore`. | ||
@@ -84,0 +103,0 @@ ##### assets examples |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50770
648
198
16
14
8
2
+ Addedhttp-proxy-agent@^2.1.0
+ Addedhttps-proxy-agent@^2.2.1