mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-06 10:53:15 +08:00
.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import * as http from 'http'
|
||||
import * as https from 'https'
|
||||
import proxy from 'proxy'
|
||||
import { ProxyServer, createProxy } from "proxy";
|
||||
import { ProxyAgent, fetch as undiciFetch } from "undici";
|
||||
|
||||
@@ -18,7 +17,7 @@ describe('@actions/github', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// Start proxy server
|
||||
proxyServer = proxy()
|
||||
proxyServer = createProxy()
|
||||
await new Promise<void>(resolve => {
|
||||
const port = Number(proxyUrl.split(':')[2])
|
||||
proxyServer.listen(port, () => resolve())
|
||||
@@ -50,22 +49,7 @@ describe('@actions/github', () => {
|
||||
return
|
||||
}
|
||||
|
||||
const myFetch: typeof undiciFetch = (url, opts) => {
|
||||
return undiciFetch(url, {
|
||||
...opts,
|
||||
dispatcher: new ProxyAgent({
|
||||
uri: proxyUrl,
|
||||
keepAliveTimeout: 10,
|
||||
keepAliveMaxTimeout: 10,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
const octokit = getOctokit(token, {
|
||||
request: {
|
||||
fetch: myFetch
|
||||
}
|
||||
})
|
||||
const octokit = getOctokit(token)
|
||||
|
||||
const branch = await octokit.rest.repos.getBranch({
|
||||
owner: 'actions',
|
||||
@@ -82,22 +66,18 @@ describe('@actions/github', () => {
|
||||
return
|
||||
}
|
||||
process.env['https_proxy'] = proxyUrl
|
||||
const myFetch: typeof undiciFetch = (url, opts) => {
|
||||
return undiciFetch(url, {
|
||||
...opts,
|
||||
dispatcher: new ProxyAgent({
|
||||
uri: proxyUrl,
|
||||
keepAliveTimeout: 10,
|
||||
keepAliveMaxTimeout: 10,
|
||||
}),
|
||||
});
|
||||
};
|
||||
// const myFetch: typeof undiciFetch = (url, opts) => {
|
||||
// return undiciFetch(url, {
|
||||
// ...opts,
|
||||
// dispatcher: new ProxyAgent({
|
||||
// uri: proxyUrl,
|
||||
// keepAliveTimeout: 10,
|
||||
// keepAliveMaxTimeout: 10,
|
||||
// }),
|
||||
// });
|
||||
// };
|
||||
|
||||
const octokit = getOctokit(token, {
|
||||
request: {
|
||||
fetch: myFetch
|
||||
}
|
||||
})
|
||||
const octokit = getOctokit(token)
|
||||
|
||||
const repository = await octokit.graphql(
|
||||
'{repository(owner:"actions", name:"toolkit"){name}}'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as http from 'http'
|
||||
import proxy from 'proxy'
|
||||
import { createProxy } from 'proxy'
|
||||
import {getOctokit} from '../src/github'
|
||||
import {GitHub, getOctokitOptions} from '../src/utils'
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('@actions/github', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// Start proxy server
|
||||
proxyServer = proxy()
|
||||
proxyServer = createProxy()
|
||||
await new Promise<void>(resolve => {
|
||||
const port = Number(proxyUrl.split(':')[2])
|
||||
proxyServer.listen(port, () => resolve())
|
||||
|
||||
771
packages/github/package-lock.json
generated
771
packages/github/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -38,12 +38,14 @@
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@octokit/core": "^3.6.0",
|
||||
"@octokit/plugin-paginate-rest": "^2.17.0",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^5.13.0"
|
||||
"@actions/http-client": "file:../http-client/actions-http-client-3.0.0.tgz",
|
||||
"@octokit/core": "^4.2.4",
|
||||
"@octokit/plugin-paginate-rest": "^6.1.2",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^7.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"proxy": "^1.0.2"
|
||||
"@types/proxy": "^1.0.1",
|
||||
"proxy": "^2.1.1",
|
||||
"undici": "^5.25.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as http from 'http'
|
||||
import * as httpClient from '@actions/http-client'
|
||||
import {OctokitOptions} from '@octokit/core/dist-types/types'
|
||||
import { ProxyServer, createProxy } from "proxy";
|
||||
import { ProxyAgent, fetch as undiciFetch } from "undici";
|
||||
import { ProxyAgent, Agent, fetch as undiciFetch } from "undici";
|
||||
|
||||
export function getAuthString(
|
||||
token: string,
|
||||
@@ -22,15 +22,17 @@ export function getProxyAgent(destinationUrl: string): http.Agent {
|
||||
return hc.getAgent(destinationUrl)
|
||||
}
|
||||
|
||||
export function getNewProxyAgent(destinationUrl: string): ProxyAgent | Agent {
|
||||
const hc = new httpClient.HttpClient()
|
||||
return hc.getNewAgent(destinationUrl)
|
||||
}
|
||||
|
||||
export function getProxyFetchAgent(destinationUrl): any {
|
||||
const httpAgent = getNewProxyAgent(destinationUrl)
|
||||
const myFetch: typeof undiciFetch = (url, opts) => {
|
||||
return undiciFetch(url, {
|
||||
...opts,
|
||||
dispatcher: new ProxyAgent({
|
||||
uri: destinationUrl,
|
||||
keepAliveTimeout: 10,
|
||||
keepAliveMaxTimeout: 10,
|
||||
}),
|
||||
dispatcher: httpAgent,
|
||||
});
|
||||
};
|
||||
return myFetch;
|
||||
|
||||
Reference in New Issue
Block a user