code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function toCommandProperties(annotationProperties) { if (!Object.keys(annotationProperties).length) { return {}; } return { title: annotationProperties.title, file: annotationProperties.file, line: annotationProperties.startLine, endLine: annotationProperties.endLine, col: annotationProperties.startColumn, endColumn: annotationProperties.endColumn }; }
@param annotationProperties @returns The command properties to send with the actual annotation command See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
toCommandProperties
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function exec(commandLine, args, options) { return __awaiter(this, void 0, void 0, function* () { const commandArgs = tr.argStringToArray(commandLine); if (commandArgs.length === 0) { throw new Error(`Parameter 'commandLine' cannot be null or empty.`); } // Path to tool to execute should be first arg const toolPath = commandArgs[0]; args = commandArgs.slice(1).concat(args || []); const runner = new tr.ToolRunner(toolPath, args, options); return runner.exec(); }); }
Exec a command. Output will be streamed to the live console. Returns promise with return code @param commandLine command to execute (can include additional args). Must be correctly escaped. @param args optional arguments for tool. Escaping is handled by the lib. @param options optional exec options. See ExecOptions @returns Promise<number> exit code
exec
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getExecOutput(commandLine, args, options) { var _a, _b; return __awaiter(this, void 0, void 0, function* () { let stdout = ''; let stderr = ''; //Using string decoder covers the case where a mult-byte character is split const stdoutDecoder = new string_decoder_1.StringDecoder('utf8'); const stderrDecoder = new string_decoder_1.StringDecoder('utf8'); const originalStdoutListener = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout; const originalStdErrListener = (_b = options === null || options === void 0 ? void 0 : options.listeners) === null || _b === void 0 ? void 0 : _b.stderr; const stdErrListener = (data) => { stderr += stderrDecoder.write(data); if (originalStdErrListener) { originalStdErrListener(data); } }; const stdOutListener = (data) => { stdout += stdoutDecoder.write(data); if (originalStdoutListener) { originalStdoutListener(data); } }; const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener }); const exitCode = yield exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners })); //flush any remaining characters stdout += stdoutDecoder.end(); stderr += stderrDecoder.end(); return { exitCode, stdout, stderr }; }); }
Exec a command and get the output. Output will be streamed to the live console. Returns promise with the exit code and collected stdout and stderr @param commandLine command to execute (can include additional args). Must be correctly escaped. @param args optional arguments for tool. Escaping is handled by the lib. @param options optional exec options. See ExecOptions @returns Promise<ExecOutput> exit code, stdout, and stderr
getExecOutput
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
stdErrListener = (data) => { stderr += stderrDecoder.write(data); if (originalStdErrListener) { originalStdErrListener(data); } }
Exec a command and get the output. Output will be streamed to the live console. Returns promise with the exit code and collected stdout and stderr @param commandLine command to execute (can include additional args). Must be correctly escaped. @param args optional arguments for tool. Escaping is handled by the lib. @param options optional exec options. See ExecOptions @returns Promise<ExecOutput> exit code, stdout, and stderr
stdErrListener
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
stdErrListener = (data) => { stderr += stderrDecoder.write(data); if (originalStdErrListener) { originalStdErrListener(data); } }
Exec a command and get the output. Output will be streamed to the live console. Returns promise with the exit code and collected stdout and stderr @param commandLine command to execute (can include additional args). Must be correctly escaped. @param args optional arguments for tool. Escaping is handled by the lib. @param options optional exec options. See ExecOptions @returns Promise<ExecOutput> exit code, stdout, and stderr
stdErrListener
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
stdOutListener = (data) => { stdout += stdoutDecoder.write(data); if (originalStdoutListener) { originalStdoutListener(data); } }
Exec a command and get the output. Output will be streamed to the live console. Returns promise with the exit code and collected stdout and stderr @param commandLine command to execute (can include additional args). Must be correctly escaped. @param args optional arguments for tool. Escaping is handled by the lib. @param options optional exec options. See ExecOptions @returns Promise<ExecOutput> exit code, stdout, and stderr
stdOutListener
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
stdOutListener = (data) => { stdout += stdoutDecoder.write(data); if (originalStdoutListener) { originalStdoutListener(data); } }
Exec a command and get the output. Output will be streamed to the live console. Returns promise with the exit code and collected stdout and stderr @param commandLine command to execute (can include additional args). Must be correctly escaped. @param args optional arguments for tool. Escaping is handled by the lib. @param options optional exec options. See ExecOptions @returns Promise<ExecOutput> exit code, stdout, and stderr
stdOutListener
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
exec() { return __awaiter(this, void 0, void 0, function* () { // root the tool path if it is unrooted and contains relative pathing if (!ioUtil.isRooted(this.toolPath) && (this.toolPath.includes('/') || (IS_WINDOWS && this.toolPath.includes('\\')))) { // prefer options.cwd if it is specified, however options.cwd may also need to be rooted this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); } // if the tool is only a file name, then resolve it from the PATH // otherwise verify it exists (add extension on Windows if necessary) this.toolPath = yield io.which(this.toolPath, true); return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { this._debug(`exec tool: ${this.toolPath}`); this._debug('arguments:'); for (const arg of this.args) { this._debug(` ${arg}`); } const optionsNonNull = this._cloneExecOptions(this.options); if (!optionsNonNull.silent && optionsNonNull.outStream) { optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL); } const state = new ExecState(optionsNonNull, this.toolPath); state.on('debug', (message) => { this._debug(message); }); if (this.options.cwd && !(yield ioUtil.exists(this.options.cwd))) { return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`)); } const fileName = this._getSpawnFileName(); const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName)); let stdbuffer = ''; if (cp.stdout) { cp.stdout.on('data', (data) => { if (this.options.listeners && this.options.listeners.stdout) { this.options.listeners.stdout(data); } if (!optionsNonNull.silent && optionsNonNull.outStream) { optionsNonNull.outStream.write(data); } stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => { if (this.options.listeners && this.options.listeners.stdline) { this.options.listeners.stdline(line); } }); }); } let errbuffer = ''; if (cp.stderr) { cp.stderr.on('data', (data) => { state.processStderr = true; if (this.options.listeners && this.options.listeners.stderr) { this.options.listeners.stderr(data); } if (!optionsNonNull.silent && optionsNonNull.errStream && optionsNonNull.outStream) { const s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream; s.write(data); } errbuffer = this._processLineBuffer(data, errbuffer, (line) => { if (this.options.listeners && this.options.listeners.errline) { this.options.listeners.errline(line); } }); }); } cp.on('error', (err) => { state.processError = err.message; state.processExited = true; state.processClosed = true; state.CheckComplete(); }); cp.on('exit', (code) => { state.processExitCode = code; state.processExited = true; this._debug(`Exit code ${code} received from tool '${this.toolPath}'`); state.CheckComplete(); }); cp.on('close', (code) => { state.processExitCode = code; state.processExited = true; state.processClosed = true; this._debug(`STDIO streams have closed for tool '${this.toolPath}'`); state.CheckComplete(); }); state.on('done', (error, exitCode) => { if (stdbuffer.length > 0) { this.emit('stdline', stdbuffer); } if (errbuffer.length > 0) { this.emit('errline', errbuffer); } cp.removeAllListeners(); if (error) { reject(error); } else { resolve(exitCode); } }); if (this.options.input) { if (!cp.stdin) { throw new Error('child process missing stdin'); } cp.stdin.end(this.options.input); } })); }); }
Exec a tool. Output will be streamed to the live console. Returns promise with return code @param tool path to tool to exec @param options optional exec options. See ExecOptions @returns number
exec
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function argStringToArray(argString) { const args = []; let inQuotes = false; let escaped = false; let arg = ''; function append(c) { // we only escape double quotes. if (escaped && c !== '"') { arg += '\\'; } arg += c; escaped = false; } for (let i = 0; i < argString.length; i++) { const c = argString.charAt(i); if (c === '"') { if (!escaped) { inQuotes = !inQuotes; } else { append(c); } continue; } if (c === '\\' && escaped) { append(c); continue; } if (c === '\\' && inQuotes) { escaped = true; continue; } if (c === ' ' && !inQuotes) { if (arg.length > 0) { args.push(arg); arg = ''; } continue; } append(c); } if (arg.length > 0) { args.push(arg.trim()); } return args; }
Convert an arg string to an array of args. Handles escaping @param argString string of arguments @returns string[] array of arguments
argStringToArray
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function append(c) { // we only escape double quotes. if (escaped && c !== '"') { arg += '\\'; } arg += c; escaped = false; }
Convert an arg string to an array of args. Handles escaping @param argString string of arguments @returns string[] array of arguments
append
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor(options, toolPath) { super(); this.processClosed = false; // tracks whether the process has exited and stdio is closed this.processError = ''; this.processExitCode = 0; this.processExited = false; // tracks whether the process has exited this.processStderr = false; // tracks whether stderr was written to this.delay = 10000; // 10 seconds this.done = false; this.timeout = null; if (!toolPath) { throw new Error('toolPath must not be empty'); } this.options = options; this.toolPath = toolPath; if (options.delay) { this.delay = options.delay; } }
Convert an arg string to an array of args. Handles escaping @param argString string of arguments @returns string[] array of arguments
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
CheckComplete() { if (this.done) { return; } if (this.processClosed) { this._setResult(); } else if (this.processExited) { this.timeout = timers_1.setTimeout(ExecState.HandleTimeout, this.delay, this); } }
Convert an arg string to an array of args. Handles escaping @param argString string of arguments @returns string[] array of arguments
CheckComplete
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_debug(message) { this.emit('debug', message); }
Convert an arg string to an array of args. Handles escaping @param argString string of arguments @returns string[] array of arguments
_debug
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_setResult() { // determine whether there is an error let error; if (this.processExited) { if (this.processError) { error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`); } else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) { error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`); } else if (this.processStderr && this.options.failOnStdErr) { error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`); } } // clear the timeout if (this.timeout) { clearTimeout(this.timeout); this.timeout = null; } this.done = true; this.emit('done', error, this.processExitCode); }
Convert an arg string to an array of args. Handles escaping @param argString string of arguments @returns string[] array of arguments
_setResult
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
static HandleTimeout(state) { if (state.done) { return; } if (!state.processClosed && state.processExited) { const message = `The STDIO streams did not close within ${state.delay / 1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`; state._debug(message); } state._setResult(); }
Convert an arg string to an array of args. Handles escaping @param argString string of arguments @returns string[] array of arguments
HandleTimeout
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor() { var _a, _b, _c; this.payload = {}; if (process.env.GITHUB_EVENT_PATH) { if ((0, fs_1.existsSync)(process.env.GITHUB_EVENT_PATH)) { this.payload = JSON.parse((0, fs_1.readFileSync)(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' })); } else { const path = process.env.GITHUB_EVENT_PATH; process.stdout.write(`GITHUB_EVENT_PATH ${path} does not exist${os_1.EOL}`); } } this.eventName = process.env.GITHUB_EVENT_NAME; this.sha = process.env.GITHUB_SHA; this.ref = process.env.GITHUB_REF; this.workflow = process.env.GITHUB_WORKFLOW; this.action = process.env.GITHUB_ACTION; this.actor = process.env.GITHUB_ACTOR; this.job = process.env.GITHUB_JOB; this.runNumber = parseInt(process.env.GITHUB_RUN_NUMBER, 10); this.runId = parseInt(process.env.GITHUB_RUN_ID, 10); this.apiUrl = (_a = process.env.GITHUB_API_URL) !== null && _a !== void 0 ? _a : `https://api.github.com`; this.serverUrl = (_b = process.env.GITHUB_SERVER_URL) !== null && _b !== void 0 ? _b : `https://github.com`; this.graphqlUrl = (_c = process.env.GITHUB_GRAPHQL_URL) !== null && _c !== void 0 ? _c : `https://api.github.com/graphql`; }
Hydrate the context from the environment
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get issue() { const payload = this.payload; return Object.assign(Object.assign({}, this.repo), { number: (payload.issue || payload.pull_request || payload).number }); }
Hydrate the context from the environment
issue
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get repo() { if (process.env.GITHUB_REPOSITORY) { const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); return { owner, repo }; } if (this.payload.repository) { return { owner: this.payload.repository.owner.login, repo: this.payload.repository.name }; } throw new Error("context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'"); }
Hydrate the context from the environment
repo
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getOctokit(token, options, ...additionalPlugins) { const GitHubWithPlugins = utils_1.GitHub.plugin(...additionalPlugins); return new GitHubWithPlugins((0, utils_1.getOctokitOptions)(token, options)); }
Returns a hydrated octokit ready to use for GitHub Actions @param token the repo PAT or GITHUB_TOKEN @param options other options to set
getOctokit
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getOctokitOptions(token, options) { const opts = Object.assign({}, options || {}); // Shallow clone - don't mutate the object provided by the caller // Auth const auth = Utils.getAuthString(token, opts); if (auth) { opts.auth = auth; } return opts; }
Convience function to correctly format Octokit Options to pass into the constructor. @param token the repo PAT or GITHUB_TOKEN @param options other options to set
getOctokitOptions
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getProxyUrl(serverUrl) { const proxyUrl = pm.getProxyUrl(new URL(serverUrl)); return proxyUrl ? proxyUrl.href : ''; }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
getProxyUrl
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor(message, statusCode) { super(message); this.name = 'HttpClientError'; this.statusCode = statusCode; Object.setPrototypeOf(this, HttpClientError.prototype); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor(message) { this.message = message; }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
readBody() { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { let output = Buffer.alloc(0); this.message.on('data', (chunk) => { output = Buffer.concat([output, chunk]); }); this.message.on('end', () => { resolve(output.toString()); }); })); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
readBody
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
readBodyBuffer() { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { const chunks = []; this.message.on('data', (chunk) => { chunks.push(chunk); }); this.message.on('end', () => { resolve(Buffer.concat(chunks)); }); })); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
readBodyBuffer
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isHttps(requestUrl) { const parsedUrl = new URL(requestUrl); return parsedUrl.protocol === 'https:'; }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
isHttps
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor(userAgent, handlers, requestOptions) { this._ignoreSslError = false; this._allowRedirects = true; this._allowRedirectDowngrade = false; this._maxRedirects = 50; this._allowRetries = false; this._maxRetries = 1; this._keepAlive = false; this._disposed = false; this.userAgent = userAgent; this.handlers = handlers || []; this.requestOptions = requestOptions; if (requestOptions) { if (requestOptions.ignoreSslError != null) { this._ignoreSslError = requestOptions.ignoreSslError; } this._socketTimeout = requestOptions.socketTimeout; if (requestOptions.allowRedirects != null) { this._allowRedirects = requestOptions.allowRedirects; } if (requestOptions.allowRedirectDowngrade != null) { this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; } if (requestOptions.maxRedirects != null) { this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); } if (requestOptions.keepAlive != null) { this._keepAlive = requestOptions.keepAlive; } if (requestOptions.allowRetries != null) { this._allowRetries = requestOptions.allowRetries; } if (requestOptions.maxRetries != null) { this._maxRetries = requestOptions.maxRetries; } } }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
options(requestUrl, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
options
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get(requestUrl, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('GET', requestUrl, null, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
get
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
del(requestUrl, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('DELETE', requestUrl, null, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
del
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
post(requestUrl, data, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('POST', requestUrl, data, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
post
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
patch(requestUrl, data, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('PATCH', requestUrl, data, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
patch
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
put(requestUrl, data, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('PUT', requestUrl, data, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
put
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
head(requestUrl, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('HEAD', requestUrl, null, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
head
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
sendStream(verb, requestUrl, stream, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request(verb, requestUrl, stream, additionalHeaders); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
sendStream
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
getJson(requestUrl, additionalHeaders = {}) { return __awaiter(this, void 0, void 0, function* () { additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); const res = yield this.get(requestUrl, additionalHeaders); return this._processResponse(res, this.requestOptions); }); }
Gets a typed object from an endpoint Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
getJson
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
postJson(requestUrl, obj, additionalHeaders = {}) { return __awaiter(this, void 0, void 0, function* () { const data = JSON.stringify(obj, null, 2); additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); const res = yield this.post(requestUrl, data, additionalHeaders); return this._processResponse(res, this.requestOptions); }); }
Gets a typed object from an endpoint Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
postJson
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
putJson(requestUrl, obj, additionalHeaders = {}) { return __awaiter(this, void 0, void 0, function* () { const data = JSON.stringify(obj, null, 2); additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); const res = yield this.put(requestUrl, data, additionalHeaders); return this._processResponse(res, this.requestOptions); }); }
Gets a typed object from an endpoint Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
putJson
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
patchJson(requestUrl, obj, additionalHeaders = {}) { return __awaiter(this, void 0, void 0, function* () { const data = JSON.stringify(obj, null, 2); additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); const res = yield this.patch(requestUrl, data, additionalHeaders); return this._processResponse(res, this.requestOptions); }); }
Gets a typed object from an endpoint Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
patchJson
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
request(verb, requestUrl, data, headers) { return __awaiter(this, void 0, void 0, function* () { if (this._disposed) { throw new Error('Client has already been disposed.'); } const parsedUrl = new URL(requestUrl); let info = this._prepareRequest(verb, parsedUrl, headers); // Only perform retries on reads since writes may not be idempotent. const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) ? this._maxRetries + 1 : 1; let numTries = 0; let response; do { response = yield this.requestRaw(info, data); // Check if it's an authentication challenge if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) { let authenticationHandler; for (const handler of this.handlers) { if (handler.canHandleAuthentication(response)) { authenticationHandler = handler; break; } } if (authenticationHandler) { return authenticationHandler.handleAuthentication(this, info, data); } else { // We have received an unauthorized response but have no handlers to handle it. // Let the response return to the caller. return response; } } let redirectsRemaining = this._maxRedirects; while (response.message.statusCode && HttpRedirectCodes.includes(response.message.statusCode) && this._allowRedirects && redirectsRemaining > 0) { const redirectUrl = response.message.headers['location']; if (!redirectUrl) { // if there's no location to redirect to, we won't break; } const parsedRedirectUrl = new URL(redirectUrl); if (parsedUrl.protocol === 'https:' && parsedUrl.protocol !== parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) { throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); } // we need to finish reading the response before reassigning response // which will leak the open socket. yield response.readBody(); // strip authorization header if redirected to a different hostname if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { for (const header in headers) { // header names are case insensitive if (header.toLowerCase() === 'authorization') { delete headers[header]; } } } // let's make the request with the new redirectUrl info = this._prepareRequest(verb, parsedRedirectUrl, headers); response = yield this.requestRaw(info, data); redirectsRemaining--; } if (!response.message.statusCode || !HttpResponseRetryCodes.includes(response.message.statusCode)) { // If not a retry code, return immediately instead of retrying return response; } numTries += 1; if (numTries < maxTries) { yield response.readBody(); yield this._performExponentialBackoff(numTries); } } while (numTries < maxTries); return response; }); }
Makes a raw http request. All other methods such as get, post, patch, and request ultimately call this. Prefer get, del, post and patch
request
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
dispose() { if (this._agent) { this._agent.destroy(); } this._disposed = true; }
Needs to be called if keepAlive is set to true in request options.
dispose
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
requestRaw(info, data) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => { function callbackForResult(err, res) { if (err) { reject(err); } else if (!res) { // If `err` is not passed, then `res` must be passed. reject(new Error('Unknown error')); } else { resolve(res); } } this.requestRawWithCallback(info, data, callbackForResult); }); }); }
Raw request. @param info @param data
requestRaw
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function callbackForResult(err, res) { if (err) { reject(err); } else if (!res) { // If `err` is not passed, then `res` must be passed. reject(new Error('Unknown error')); } else { resolve(res); } }
Raw request. @param info @param data
callbackForResult
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
requestRawWithCallback(info, data, onResult) { if (typeof data === 'string') { if (!info.options.headers) { info.options.headers = {}; } info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); } let callbackCalled = false; function handleResult(err, res) { if (!callbackCalled) { callbackCalled = true; onResult(err, res); } } const req = info.httpModule.request(info.options, (msg) => { const res = new HttpClientResponse(msg); handleResult(undefined, res); }); let socket; req.on('socket', sock => { socket = sock; }); // If we ever get disconnected, we want the socket to timeout eventually req.setTimeout(this._socketTimeout || 3 * 60000, () => { if (socket) { socket.end(); } handleResult(new Error(`Request timeout: ${info.options.path}`)); }); req.on('error', function (err) { // err has statusCode property // res should have headers handleResult(err); }); if (data && typeof data === 'string') { req.write(data, 'utf8'); } if (data && typeof data !== 'string') { data.on('close', function () { req.end(); }); data.pipe(req); } else { req.end(); } }
Raw request with callback. @param info @param data @param onResult
requestRawWithCallback
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function handleResult(err, res) { if (!callbackCalled) { callbackCalled = true; onResult(err, res); } }
Raw request with callback. @param info @param data @param onResult
handleResult
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
getAgent(serverUrl) { const parsedUrl = new URL(serverUrl); return this._getAgent(parsedUrl); }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
getAgent
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
getAgentDispatcher(serverUrl) { const parsedUrl = new URL(serverUrl); const proxyUrl = pm.getProxyUrl(parsedUrl); const useProxy = proxyUrl && proxyUrl.hostname; if (!useProxy) { return; } return this._getProxyAgentDispatcher(parsedUrl, proxyUrl); }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
getAgentDispatcher
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_prepareRequest(method, requestUrl, headers) { const info = {}; info.parsedUrl = requestUrl; const usingSsl = info.parsedUrl.protocol === 'https:'; info.httpModule = usingSsl ? https : http; const defaultPort = usingSsl ? 443 : 80; info.options = {}; info.options.host = info.parsedUrl.hostname; info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort; info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); info.options.method = method; info.options.headers = this._mergeHeaders(headers); if (this.userAgent != null) { info.options.headers['user-agent'] = this.userAgent; } info.options.agent = this._getAgent(info.parsedUrl); // gives handlers an opportunity to participate if (this.handlers) { for (const handler of this.handlers) { handler.prepareRequest(info.options); } } return info; }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_prepareRequest
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_mergeHeaders(headers) { if (this.requestOptions && this.requestOptions.headers) { return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {})); } return lowercaseKeys(headers || {}); }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_mergeHeaders
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_getExistingOrDefaultHeader(additionalHeaders, header, _default) { let clientHeader; if (this.requestOptions && this.requestOptions.headers) { clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; } return additionalHeaders[header] || clientHeader || _default; }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_getExistingOrDefaultHeader
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_getAgent(parsedUrl) { let agent; const proxyUrl = pm.getProxyUrl(parsedUrl); const useProxy = proxyUrl && proxyUrl.hostname; if (this._keepAlive && useProxy) { agent = this._proxyAgent; } if (this._keepAlive && !useProxy) { agent = this._agent; } // if agent is already assigned use that agent. if (agent) { return agent; } const usingSsl = parsedUrl.protocol === 'https:'; let maxSockets = 100; if (this.requestOptions) { maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; } // This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis. if (proxyUrl && proxyUrl.hostname) { const agentOptions = { maxSockets, keepAlive: this._keepAlive, proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && { proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` })), { host: proxyUrl.hostname, port: proxyUrl.port }) }; let tunnelAgent; const overHttps = proxyUrl.protocol === 'https:'; if (usingSsl) { tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; } else { tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; } agent = tunnelAgent(agentOptions); this._proxyAgent = agent; } // if reusing agent across request and tunneling agent isn't assigned create a new agent if (this._keepAlive && !agent) { const options = { keepAlive: this._keepAlive, maxSockets }; agent = usingSsl ? new https.Agent(options) : new http.Agent(options); this._agent = agent; } // if not using private agent and tunnel agent isn't setup then use global agent if (!agent) { agent = usingSsl ? https.globalAgent : http.globalAgent; } if (usingSsl && this._ignoreSslError) { // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options // we have to cast it to any and change it directly agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false }); } return agent; }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_getAgent
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_getProxyAgentDispatcher(parsedUrl, proxyUrl) { let proxyAgent; if (this._keepAlive) { proxyAgent = this._proxyAgentDispatcher; } // if agent is already assigned use that agent. if (proxyAgent) { return proxyAgent; } const usingSsl = parsedUrl.protocol === 'https:'; proxyAgent = new undici_1.ProxyAgent(Object.assign({ uri: proxyUrl.href, pipelining: !this._keepAlive ? 0 : 1 }, ((proxyUrl.username || proxyUrl.password) && { token: `${proxyUrl.username}:${proxyUrl.password}` }))); this._proxyAgentDispatcher = proxyAgent; if (usingSsl && this._ignoreSslError) { // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options // we have to cast it to any and change it directly proxyAgent.options = Object.assign(proxyAgent.options.requestTls || {}, { rejectUnauthorized: false }); } return proxyAgent; }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_getProxyAgentDispatcher
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_performExponentialBackoff(retryNumber) { return __awaiter(this, void 0, void 0, function* () { retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); return new Promise(resolve => setTimeout(() => resolve(), ms)); }); }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_performExponentialBackoff
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_processResponse(res, options) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { const statusCode = res.message.statusCode || 0; const response = { statusCode, result: null, headers: {} }; // not found leads to null obj returned if (statusCode === HttpCodes.NotFound) { resolve(response); } // get the result from the body function dateTimeDeserializer(key, value) { if (typeof value === 'string') { const a = new Date(value); if (!isNaN(a.valueOf())) { return a; } } return value; } let obj; let contents; try { contents = yield res.readBody(); if (contents && contents.length > 0) { if (options && options.deserializeDates) { obj = JSON.parse(contents, dateTimeDeserializer); } else { obj = JSON.parse(contents); } response.result = obj; } response.headers = res.message.headers; } catch (err) { // Invalid resource (contents not json); leaving result obj null } // note that 3xx redirects are handled by the http layer. if (statusCode > 299) { let msg; // if exception/error in body, attempt to get better error if (obj && obj.message) { msg = obj.message; } else if (contents && contents.length > 0) { // it may be the case that the exception is in the body message as string msg = contents; } else { msg = `Failed request: (${statusCode})`; } const err = new HttpClientError(msg, statusCode); err.result = response.result; reject(err); } else { resolve(response); } })); }); }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_processResponse
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function dateTimeDeserializer(key, value) { if (typeof value === 'string') { const a = new Date(value); if (!isNaN(a.valueOf())) { return a; } } return value; }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
dateTimeDeserializer
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getProxyUrl(serverUrl) { const proxyUrl = pm.getProxyUrl(new URL(serverUrl)); return proxyUrl ? proxyUrl.href : ''; }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
getProxyUrl
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor(message, statusCode) { super(message); this.name = 'HttpClientError'; this.statusCode = statusCode; Object.setPrototypeOf(this, HttpClientError.prototype); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor(message) { this.message = message; }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
readBody() { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { let output = Buffer.alloc(0); this.message.on('data', (chunk) => { output = Buffer.concat([output, chunk]); }); this.message.on('end', () => { resolve(output.toString()); }); })); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
readBody
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
readBodyBuffer() { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { const chunks = []; this.message.on('data', (chunk) => { chunks.push(chunk); }); this.message.on('end', () => { resolve(Buffer.concat(chunks)); }); })); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
readBodyBuffer
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isHttps(requestUrl) { const parsedUrl = new URL(requestUrl); return parsedUrl.protocol === 'https:'; }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
isHttps
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor(userAgent, handlers, requestOptions) { this._ignoreSslError = false; this._allowRedirects = true; this._allowRedirectDowngrade = false; this._maxRedirects = 50; this._allowRetries = false; this._maxRetries = 1; this._keepAlive = false; this._disposed = false; this.userAgent = userAgent; this.handlers = handlers || []; this.requestOptions = requestOptions; if (requestOptions) { if (requestOptions.ignoreSslError != null) { this._ignoreSslError = requestOptions.ignoreSslError; } this._socketTimeout = requestOptions.socketTimeout; if (requestOptions.allowRedirects != null) { this._allowRedirects = requestOptions.allowRedirects; } if (requestOptions.allowRedirectDowngrade != null) { this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; } if (requestOptions.maxRedirects != null) { this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); } if (requestOptions.keepAlive != null) { this._keepAlive = requestOptions.keepAlive; } if (requestOptions.allowRetries != null) { this._allowRetries = requestOptions.allowRetries; } if (requestOptions.maxRetries != null) { this._maxRetries = requestOptions.maxRetries; } } }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
options(requestUrl, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
options
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get(requestUrl, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('GET', requestUrl, null, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
get
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
del(requestUrl, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('DELETE', requestUrl, null, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
del
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
post(requestUrl, data, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('POST', requestUrl, data, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
post
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
patch(requestUrl, data, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('PATCH', requestUrl, data, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
patch
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
put(requestUrl, data, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('PUT', requestUrl, data, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
put
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
head(requestUrl, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request('HEAD', requestUrl, null, additionalHeaders || {}); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
head
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
sendStream(verb, requestUrl, stream, additionalHeaders) { return __awaiter(this, void 0, void 0, function* () { return this.request(verb, requestUrl, stream, additionalHeaders); }); }
Returns the proxy URL, depending upon the supplied url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
sendStream
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
getJson(requestUrl, additionalHeaders = {}) { return __awaiter(this, void 0, void 0, function* () { additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); const res = yield this.get(requestUrl, additionalHeaders); return this._processResponse(res, this.requestOptions); }); }
Gets a typed object from an endpoint Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
getJson
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
postJson(requestUrl, obj, additionalHeaders = {}) { return __awaiter(this, void 0, void 0, function* () { const data = JSON.stringify(obj, null, 2); additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); const res = yield this.post(requestUrl, data, additionalHeaders); return this._processResponse(res, this.requestOptions); }); }
Gets a typed object from an endpoint Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
postJson
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
putJson(requestUrl, obj, additionalHeaders = {}) { return __awaiter(this, void 0, void 0, function* () { const data = JSON.stringify(obj, null, 2); additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); const res = yield this.put(requestUrl, data, additionalHeaders); return this._processResponse(res, this.requestOptions); }); }
Gets a typed object from an endpoint Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
putJson
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
patchJson(requestUrl, obj, additionalHeaders = {}) { return __awaiter(this, void 0, void 0, function* () { const data = JSON.stringify(obj, null, 2); additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); const res = yield this.patch(requestUrl, data, additionalHeaders); return this._processResponse(res, this.requestOptions); }); }
Gets a typed object from an endpoint Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
patchJson
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
request(verb, requestUrl, data, headers) { return __awaiter(this, void 0, void 0, function* () { if (this._disposed) { throw new Error('Client has already been disposed.'); } const parsedUrl = new URL(requestUrl); let info = this._prepareRequest(verb, parsedUrl, headers); // Only perform retries on reads since writes may not be idempotent. const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) ? this._maxRetries + 1 : 1; let numTries = 0; let response; do { response = yield this.requestRaw(info, data); // Check if it's an authentication challenge if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) { let authenticationHandler; for (const handler of this.handlers) { if (handler.canHandleAuthentication(response)) { authenticationHandler = handler; break; } } if (authenticationHandler) { return authenticationHandler.handleAuthentication(this, info, data); } else { // We have received an unauthorized response but have no handlers to handle it. // Let the response return to the caller. return response; } } let redirectsRemaining = this._maxRedirects; while (response.message.statusCode && HttpRedirectCodes.includes(response.message.statusCode) && this._allowRedirects && redirectsRemaining > 0) { const redirectUrl = response.message.headers['location']; if (!redirectUrl) { // if there's no location to redirect to, we won't break; } const parsedRedirectUrl = new URL(redirectUrl); if (parsedUrl.protocol === 'https:' && parsedUrl.protocol !== parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) { throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); } // we need to finish reading the response before reassigning response // which will leak the open socket. yield response.readBody(); // strip authorization header if redirected to a different hostname if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { for (const header in headers) { // header names are case insensitive if (header.toLowerCase() === 'authorization') { delete headers[header]; } } } // let's make the request with the new redirectUrl info = this._prepareRequest(verb, parsedRedirectUrl, headers); response = yield this.requestRaw(info, data); redirectsRemaining--; } if (!response.message.statusCode || !HttpResponseRetryCodes.includes(response.message.statusCode)) { // If not a retry code, return immediately instead of retrying return response; } numTries += 1; if (numTries < maxTries) { yield response.readBody(); yield this._performExponentialBackoff(numTries); } } while (numTries < maxTries); return response; }); }
Makes a raw http request. All other methods such as get, post, patch, and request ultimately call this. Prefer get, del, post and patch
request
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
dispose() { if (this._agent) { this._agent.destroy(); } this._disposed = true; }
Needs to be called if keepAlive is set to true in request options.
dispose
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
requestRaw(info, data) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => { function callbackForResult(err, res) { if (err) { reject(err); } else if (!res) { // If `err` is not passed, then `res` must be passed. reject(new Error('Unknown error')); } else { resolve(res); } } this.requestRawWithCallback(info, data, callbackForResult); }); }); }
Raw request. @param info @param data
requestRaw
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function callbackForResult(err, res) { if (err) { reject(err); } else if (!res) { // If `err` is not passed, then `res` must be passed. reject(new Error('Unknown error')); } else { resolve(res); } }
Raw request. @param info @param data
callbackForResult
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
requestRawWithCallback(info, data, onResult) { if (typeof data === 'string') { if (!info.options.headers) { info.options.headers = {}; } info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); } let callbackCalled = false; function handleResult(err, res) { if (!callbackCalled) { callbackCalled = true; onResult(err, res); } } const req = info.httpModule.request(info.options, (msg) => { const res = new HttpClientResponse(msg); handleResult(undefined, res); }); let socket; req.on('socket', sock => { socket = sock; }); // If we ever get disconnected, we want the socket to timeout eventually req.setTimeout(this._socketTimeout || 3 * 60000, () => { if (socket) { socket.end(); } handleResult(new Error(`Request timeout: ${info.options.path}`)); }); req.on('error', function (err) { // err has statusCode property // res should have headers handleResult(err); }); if (data && typeof data === 'string') { req.write(data, 'utf8'); } if (data && typeof data !== 'string') { data.on('close', function () { req.end(); }); data.pipe(req); } else { req.end(); } }
Raw request with callback. @param info @param data @param onResult
requestRawWithCallback
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function handleResult(err, res) { if (!callbackCalled) { callbackCalled = true; onResult(err, res); } }
Raw request with callback. @param info @param data @param onResult
handleResult
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
getAgent(serverUrl) { const parsedUrl = new URL(serverUrl); return this._getAgent(parsedUrl); }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
getAgent
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
getAgentDispatcher(serverUrl) { const parsedUrl = new URL(serverUrl); const proxyUrl = pm.getProxyUrl(parsedUrl); const useProxy = proxyUrl && proxyUrl.hostname; if (!useProxy) { return; } return this._getProxyAgentDispatcher(parsedUrl, proxyUrl); }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
getAgentDispatcher
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_prepareRequest(method, requestUrl, headers) { const info = {}; info.parsedUrl = requestUrl; const usingSsl = info.parsedUrl.protocol === 'https:'; info.httpModule = usingSsl ? https : http; const defaultPort = usingSsl ? 443 : 80; info.options = {}; info.options.host = info.parsedUrl.hostname; info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort; info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); info.options.method = method; info.options.headers = this._mergeHeaders(headers); if (this.userAgent != null) { info.options.headers['user-agent'] = this.userAgent; } info.options.agent = this._getAgent(info.parsedUrl); // gives handlers an opportunity to participate if (this.handlers) { for (const handler of this.handlers) { handler.prepareRequest(info.options); } } return info; }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_prepareRequest
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_mergeHeaders(headers) { if (this.requestOptions && this.requestOptions.headers) { return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {})); } return lowercaseKeys(headers || {}); }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_mergeHeaders
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_getExistingOrDefaultHeader(additionalHeaders, header, _default) { let clientHeader; if (this.requestOptions && this.requestOptions.headers) { clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; } return additionalHeaders[header] || clientHeader || _default; }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_getExistingOrDefaultHeader
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_getAgent(parsedUrl) { let agent; const proxyUrl = pm.getProxyUrl(parsedUrl); const useProxy = proxyUrl && proxyUrl.hostname; if (this._keepAlive && useProxy) { agent = this._proxyAgent; } if (!useProxy) { agent = this._agent; } // if agent is already assigned use that agent. if (agent) { return agent; } const usingSsl = parsedUrl.protocol === 'https:'; let maxSockets = 100; if (this.requestOptions) { maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; } // This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis. if (proxyUrl && proxyUrl.hostname) { const agentOptions = { maxSockets, keepAlive: this._keepAlive, proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && { proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` })), { host: proxyUrl.hostname, port: proxyUrl.port }) }; let tunnelAgent; const overHttps = proxyUrl.protocol === 'https:'; if (usingSsl) { tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; } else { tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; } agent = tunnelAgent(agentOptions); this._proxyAgent = agent; } // if tunneling agent isn't assigned create a new agent if (!agent) { const options = { keepAlive: this._keepAlive, maxSockets }; agent = usingSsl ? new https.Agent(options) : new http.Agent(options); this._agent = agent; } if (usingSsl && this._ignoreSslError) { // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options // we have to cast it to any and change it directly agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false }); } return agent; }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_getAgent
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_getProxyAgentDispatcher(parsedUrl, proxyUrl) { let proxyAgent; if (this._keepAlive) { proxyAgent = this._proxyAgentDispatcher; } // if agent is already assigned use that agent. if (proxyAgent) { return proxyAgent; } const usingSsl = parsedUrl.protocol === 'https:'; proxyAgent = new undici_1.ProxyAgent(Object.assign({ uri: proxyUrl.href, pipelining: !this._keepAlive ? 0 : 1 }, ((proxyUrl.username || proxyUrl.password) && { token: `Basic ${Buffer.from(`${proxyUrl.username}:${proxyUrl.password}`).toString('base64')}` }))); this._proxyAgentDispatcher = proxyAgent; if (usingSsl && this._ignoreSslError) { // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options // we have to cast it to any and change it directly proxyAgent.options = Object.assign(proxyAgent.options.requestTls || {}, { rejectUnauthorized: false }); } return proxyAgent; }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_getProxyAgentDispatcher
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_performExponentialBackoff(retryNumber) { return __awaiter(this, void 0, void 0, function* () { retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); return new Promise(resolve => setTimeout(() => resolve(), ms)); }); }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_performExponentialBackoff
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
_processResponse(res, options) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { const statusCode = res.message.statusCode || 0; const response = { statusCode, result: null, headers: {} }; // not found leads to null obj returned if (statusCode === HttpCodes.NotFound) { resolve(response); } // get the result from the body function dateTimeDeserializer(key, value) { if (typeof value === 'string') { const a = new Date(value); if (!isNaN(a.valueOf())) { return a; } } return value; } let obj; let contents; try { contents = yield res.readBody(); if (contents && contents.length > 0) { if (options && options.deserializeDates) { obj = JSON.parse(contents, dateTimeDeserializer); } else { obj = JSON.parse(contents); } response.result = obj; } response.headers = res.message.headers; } catch (err) { // Invalid resource (contents not json); leaving result obj null } // note that 3xx redirects are handled by the http layer. if (statusCode > 299) { let msg; // if exception/error in body, attempt to get better error if (obj && obj.message) { msg = obj.message; } else if (contents && contents.length > 0) { // it may be the case that the exception is in the body message as string msg = contents; } else { msg = `Failed request: (${statusCode})`; } const err = new HttpClientError(msg, statusCode); err.result = response.result; reject(err); } else { resolve(response); } })); }); }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
_processResponse
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function dateTimeDeserializer(key, value) { if (typeof value === 'string') { const a = new Date(value); if (!isNaN(a.valueOf())) { return a; } } return value; }
Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables. @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
dateTimeDeserializer
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isRooted(p) { p = normalizeSeparators(p); if (!p) { throw new Error('isRooted() parameter "p" cannot be empty'); } if (exports.IS_WINDOWS) { return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello ); // e.g. C: or C:\hello } return p.startsWith('/'); }
On OSX/Linux, true if path starts with '/'. On Windows, true for paths like: \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
isRooted
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function tryGetExecutablePath(filePath, extensions) { return __awaiter(this, void 0, void 0, function* () { let stats = undefined; try { // test file exists stats = yield exports.stat(filePath); } catch (err) { if (err.code !== 'ENOENT') { // eslint-disable-next-line no-console console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); } } if (stats && stats.isFile()) { if (exports.IS_WINDOWS) { // on Windows, test for valid extension const upperExt = path.extname(filePath).toUpperCase(); if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) { return filePath; } } else { if (isUnixExecutable(stats)) { return filePath; } } } // try each extension const originalFilePath = filePath; for (const extension of extensions) { filePath = originalFilePath + extension; stats = undefined; try { stats = yield exports.stat(filePath); } catch (err) { if (err.code !== 'ENOENT') { // eslint-disable-next-line no-console console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); } } if (stats && stats.isFile()) { if (exports.IS_WINDOWS) { // preserve the case of the actual file (since an extension was appended) try { const directory = path.dirname(filePath); const upperName = path.basename(filePath).toUpperCase(); for (const actualName of yield exports.readdir(directory)) { if (upperName === actualName.toUpperCase()) { filePath = path.join(directory, actualName); break; } } } catch (err) { // eslint-disable-next-line no-console console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); } return filePath; } else { if (isUnixExecutable(stats)) { return filePath; } } } } return ''; }); }
Best effort attempt to determine whether a file exists and is executable. @param filePath file path to check @param extensions additional file extensions to try @return if file exists and is executable, returns the file path. otherwise empty string.
tryGetExecutablePath
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function normalizeSeparators(p) { p = p || ''; if (exports.IS_WINDOWS) { // convert slashes on Windows p = p.replace(/\//g, '\\'); // remove redundant slashes return p.replace(/\\\\+/g, '\\'); } // remove redundant slashes return p.replace(/\/\/+/g, '/'); }
Best effort attempt to determine whether a file exists and is executable. @param filePath file path to check @param extensions additional file extensions to try @return if file exists and is executable, returns the file path. otherwise empty string.
normalizeSeparators
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isUnixExecutable(stats) { return ((stats.mode & 1) > 0 || ((stats.mode & 8) > 0 && stats.gid === process.getgid()) || ((stats.mode & 64) > 0 && stats.uid === process.getuid())); }
Best effort attempt to determine whether a file exists and is executable. @param filePath file path to check @param extensions additional file extensions to try @return if file exists and is executable, returns the file path. otherwise empty string.
isUnixExecutable
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getCmdPath() { var _a; return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`; }
Best effort attempt to determine whether a file exists and is executable. @param filePath file path to check @param extensions additional file extensions to try @return if file exists and is executable, returns the file path. otherwise empty string.
getCmdPath
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function cp(source, dest, options = {}) { return __awaiter(this, void 0, void 0, function* () { const { force, recursive, copySourceDirectory } = readCopyOptions(options); const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null; // Dest is an existing file, but not forcing if (destStat && destStat.isFile() && !force) { return; } // If dest is an existing directory, should copy inside. const newDest = destStat && destStat.isDirectory() && copySourceDirectory ? path.join(dest, path.basename(source)) : dest; if (!(yield ioUtil.exists(source))) { throw new Error(`no such file or directory: ${source}`); } const sourceStat = yield ioUtil.stat(source); if (sourceStat.isDirectory()) { if (!recursive) { throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`); } else { yield cpDirRecursive(source, newDest, 0, force); } } else { if (path.relative(source, newDest) === '') { // a file cannot be copied to itself throw new Error(`'${newDest}' and '${source}' are the same file`); } yield copyFile(source, newDest, force); } }); }
Copies a file or folder. Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js @param source source path @param dest destination path @param options optional. See CopyOptions.
cp
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function mv(source, dest, options = {}) { return __awaiter(this, void 0, void 0, function* () { if (yield ioUtil.exists(dest)) { let destExists = true; if (yield ioUtil.isDirectory(dest)) { // If dest is directory copy src into dest dest = path.join(dest, path.basename(source)); destExists = yield ioUtil.exists(dest); } if (destExists) { if (options.force == null || options.force) { yield rmRF(dest); } else { throw new Error('Destination already exists'); } } } yield mkdirP(path.dirname(dest)); yield ioUtil.rename(source, dest); }); }
Moves a path. @param source source path @param dest destination path @param options optional. See MoveOptions.
mv
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function rmRF(inputPath) { return __awaiter(this, void 0, void 0, function* () { if (ioUtil.IS_WINDOWS) { // Check for invalid characters // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file if (/[*"<>|]/.test(inputPath)) { throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows'); } } try { // note if path does not exist, error is silent yield ioUtil.rm(inputPath, { force: true, maxRetries: 3, recursive: true, retryDelay: 300 }); } catch (err) { throw new Error(`File was unable to be removed ${err}`); } }); }
Remove a path recursively with force @param inputPath path to remove
rmRF
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function mkdirP(fsPath) { return __awaiter(this, void 0, void 0, function* () { assert_1.ok(fsPath, 'a path argument must be provided'); yield ioUtil.mkdir(fsPath, { recursive: true }); }); }
Make a directory. Creates the full path with folders in between Will throw if it fails @param fsPath path to create @returns Promise<void>
mkdirP
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function which(tool, check) { return __awaiter(this, void 0, void 0, function* () { if (!tool) { throw new Error("parameter 'tool' is required"); } // recursive when check=true if (check) { const result = yield which(tool, false); if (!result) { if (ioUtil.IS_WINDOWS) { throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`); } else { throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`); } } return result; } const matches = yield findInPath(tool); if (matches && matches.length > 0) { return matches[0]; } return ''; }); }
Returns path of a tool had the tool actually been invoked. Resolves via paths. If you check and the tool does not exist, it will throw. @param tool name of the tool @param check whether to check if tool exists @returns Promise<string> path to tool
which
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT