Skip to content

Commit 1852a6a

Browse files
author
github-actions
committed
[actions] Build of 7fb374c
1 parent 47c2c74 commit 1852a6a

2 files changed

Lines changed: 175 additions & 66 deletions

File tree

typescript/dist/index.js

Lines changed: 174 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,6 @@ const file_command_1 = __nccwpck_require__(717);
675675
const utils_1 = __nccwpck_require__(5278);
676676
const os = __importStar(__nccwpck_require__(2037));
677677
const path = __importStar(__nccwpck_require__(1017));
678-
const uuid_1 = __nccwpck_require__(5840);
679678
const oidc_utils_1 = __nccwpck_require__(8041);
680679
/**
681680
* The code to exit an action
@@ -705,20 +704,9 @@ function exportVariable(name, val) {
705704
process.env[name] = convertedVal;
706705
const filePath = process.env['GITHUB_ENV'] || '';
707706
if (filePath) {
708-
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
709-
// These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
710-
if (name.includes(delimiter)) {
711-
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
712-
}
713-
if (convertedVal.includes(delimiter)) {
714-
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
715-
}
716-
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
717-
file_command_1.issueCommand('ENV', commandValue);
718-
}
719-
else {
720-
command_1.issueCommand('set-env', { name }, convertedVal);
707+
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
721708
}
709+
command_1.issueCommand('set-env', { name }, convertedVal);
722710
}
723711
exports.exportVariable = exportVariable;
724712
/**
@@ -736,7 +724,7 @@ exports.setSecret = setSecret;
736724
function addPath(inputPath) {
737725
const filePath = process.env['GITHUB_PATH'] || '';
738726
if (filePath) {
739-
file_command_1.issueCommand('PATH', inputPath);
727+
file_command_1.issueFileCommand('PATH', inputPath);
740728
}
741729
else {
742730
command_1.issueCommand('add-path', {}, inputPath);
@@ -776,7 +764,10 @@ function getMultilineInput(name, options) {
776764
const inputs = getInput(name, options)
777765
.split('\n')
778766
.filter(x => x !== '');
779-
return inputs;
767+
if (options && options.trimWhitespace === false) {
768+
return inputs;
769+
}
770+
return inputs.map(input => input.trim());
780771
}
781772
exports.getMultilineInput = getMultilineInput;
782773
/**
@@ -809,8 +800,12 @@ exports.getBooleanInput = getBooleanInput;
809800
*/
810801
// eslint-disable-next-line @typescript-eslint/no-explicit-any
811802
function setOutput(name, value) {
803+
const filePath = process.env['GITHUB_OUTPUT'] || '';
804+
if (filePath) {
805+
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
806+
}
812807
process.stdout.write(os.EOL);
813-
command_1.issueCommand('set-output', { name }, value);
808+
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
814809
}
815810
exports.setOutput = setOutput;
816811
/**
@@ -939,7 +934,11 @@ exports.group = group;
939934
*/
940935
// eslint-disable-next-line @typescript-eslint/no-explicit-any
941936
function saveState(name, value) {
942-
command_1.issueCommand('save-state', { name }, value);
937+
const filePath = process.env['GITHUB_STATE'] || '';
938+
if (filePath) {
939+
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
940+
}
941+
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
943942
}
944943
exports.saveState = saveState;
945944
/**
@@ -1005,13 +1004,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
10051004
return result;
10061005
};
10071006
Object.defineProperty(exports, "__esModule", ({ value: true }));
1008-
exports.issueCommand = void 0;
1007+
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
10091008
// We use any as a valid input type
10101009
/* eslint-disable @typescript-eslint/no-explicit-any */
10111010
const fs = __importStar(__nccwpck_require__(7147));
10121011
const os = __importStar(__nccwpck_require__(2037));
1012+
const uuid_1 = __nccwpck_require__(5840);
10131013
const utils_1 = __nccwpck_require__(5278);
1014-
function issueCommand(command, message) {
1014+
function issueFileCommand(command, message) {
10151015
const filePath = process.env[`GITHUB_${command}`];
10161016
if (!filePath) {
10171017
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -1023,7 +1023,22 @@ function issueCommand(command, message) {
10231023
encoding: 'utf8'
10241024
});
10251025
}
1026-
exports.issueCommand = issueCommand;
1026+
exports.issueFileCommand = issueFileCommand;
1027+
function prepareKeyValueMessage(key, value) {
1028+
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
1029+
const convertedValue = utils_1.toCommandValue(value);
1030+
// These should realistically never happen, but just in case someone finds a
1031+
// way to exploit uuid generation let's not allow keys or values that contain
1032+
// the delimiter.
1033+
if (key.includes(delimiter)) {
1034+
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
1035+
}
1036+
if (convertedValue.includes(delimiter)) {
1037+
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
1038+
}
1039+
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
1040+
}
1041+
exports.prepareKeyValueMessage = prepareKeyValueMessage;
10271042
//# sourceMappingURL=file-command.js.map
10281043

10291044
/***/ }),
@@ -1694,7 +1709,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
16941709
return result;
16951710
};
16961711
Object.defineProperty(exports, "__esModule", ({ value: true }));
1697-
exports.getOctokitOptions = exports.GitHub = exports.context = void 0;
1712+
exports.getOctokitOptions = exports.GitHub = exports.defaults = exports.context = void 0;
16981713
const Context = __importStar(__nccwpck_require__(4087));
16991714
const Utils = __importStar(__nccwpck_require__(7914));
17001715
// octokit + plugins
@@ -1703,13 +1718,13 @@ const plugin_rest_endpoint_methods_1 = __nccwpck_require__(3044);
17031718
const plugin_paginate_rest_1 = __nccwpck_require__(4193);
17041719
exports.context = new Context.Context();
17051720
const baseUrl = Utils.getApiBaseUrl();
1706-
const defaults = {
1721+
exports.defaults = {
17071722
baseUrl,
17081723
request: {
17091724
agent: Utils.getProxyAgent(baseUrl)
17101725
}
17111726
};
1712-
exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(defaults);
1727+
exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(exports.defaults);
17131728
/**
17141729
* Convience function to correctly format Octokit Options to pass into the constructor.
17151730
*
@@ -4867,63 +4882,67 @@ exports.request = request;
48674882
/***/ 3682:
48684883
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
48694884

4870-
var register = __nccwpck_require__(4670)
4871-
var addHook = __nccwpck_require__(5549)
4872-
var removeHook = __nccwpck_require__(6819)
4885+
var register = __nccwpck_require__(4670);
4886+
var addHook = __nccwpck_require__(5549);
4887+
var removeHook = __nccwpck_require__(6819);
48734888

48744889
// bind with array of arguments: https://stackoverflow.com/a/21792913
4875-
var bind = Function.bind
4876-
var bindable = bind.bind(bind)
4877-
4878-
function bindApi (hook, state, name) {
4879-
var removeHookRef = bindable(removeHook, null).apply(null, name ? [state, name] : [state])
4880-
hook.api = { remove: removeHookRef }
4881-
hook.remove = removeHookRef
4882-
4883-
;['before', 'error', 'after', 'wrap'].forEach(function (kind) {
4884-
var args = name ? [state, kind, name] : [state, kind]
4885-
hook[kind] = hook.api[kind] = bindable(addHook, null).apply(null, args)
4886-
})
4890+
var bind = Function.bind;
4891+
var bindable = bind.bind(bind);
4892+
4893+
function bindApi(hook, state, name) {
4894+
var removeHookRef = bindable(removeHook, null).apply(
4895+
null,
4896+
name ? [state, name] : [state]
4897+
);
4898+
hook.api = { remove: removeHookRef };
4899+
hook.remove = removeHookRef;
4900+
["before", "error", "after", "wrap"].forEach(function (kind) {
4901+
var args = name ? [state, kind, name] : [state, kind];
4902+
hook[kind] = hook.api[kind] = bindable(addHook, null).apply(null, args);
4903+
});
48874904
}
48884905

4889-
function HookSingular () {
4890-
var singularHookName = 'h'
4906+
function HookSingular() {
4907+
var singularHookName = "h";
48914908
var singularHookState = {
4892-
registry: {}
4893-
}
4894-
var singularHook = register.bind(null, singularHookState, singularHookName)
4895-
bindApi(singularHook, singularHookState, singularHookName)
4896-
return singularHook
4909+
registry: {},
4910+
};
4911+
var singularHook = register.bind(null, singularHookState, singularHookName);
4912+
bindApi(singularHook, singularHookState, singularHookName);
4913+
return singularHook;
48974914
}
48984915

4899-
function HookCollection () {
4916+
function HookCollection() {
49004917
var state = {
4901-
registry: {}
4902-
}
4918+
registry: {},
4919+
};
49034920

4904-
var hook = register.bind(null, state)
4905-
bindApi(hook, state)
4921+
var hook = register.bind(null, state);
4922+
bindApi(hook, state);
49064923

4907-
return hook
4924+
return hook;
49084925
}
49094926

4910-
var collectionHookDeprecationMessageDisplayed = false
4911-
function Hook () {
4927+
var collectionHookDeprecationMessageDisplayed = false;
4928+
function Hook() {
49124929
if (!collectionHookDeprecationMessageDisplayed) {
4913-
console.warn('[before-after-hook]: "Hook()" repurposing warning, use "Hook.Collection()". Read more: https://git.io/upgrade-before-after-hook-to-1.4')
4914-
collectionHookDeprecationMessageDisplayed = true
4930+
console.warn(
4931+
'[before-after-hook]: "Hook()" repurposing warning, use "Hook.Collection()". Read more: https://git.io/upgrade-before-after-hook-to-1.4'
4932+
);
4933+
collectionHookDeprecationMessageDisplayed = true;
49154934
}
4916-
return HookCollection()
4935+
return HookCollection();
49174936
}
49184937

4919-
Hook.Singular = HookSingular.bind()
4920-
Hook.Collection = HookCollection.bind()
4938+
Hook.Singular = HookSingular.bind();
4939+
Hook.Collection = HookCollection.bind();
49214940

4922-
module.exports = Hook
4941+
module.exports = Hook;
49234942
// expose constructors as a named property for TypeScript
4924-
module.exports.Hook = Hook
4925-
module.exports.Singular = Hook.Singular
4926-
module.exports.Collection = Hook.Collection
4943+
module.exports.Hook = Hook;
4944+
module.exports.Singular = Hook.Singular;
4945+
module.exports.Collection = Hook.Collection;
49274946

49284947

49294948
/***/ }),
@@ -6538,6 +6557,20 @@ const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original)
65386557
return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
65396558
};
65406559

6560+
/**
6561+
* isSameProtocol reports whether the two provided URLs use the same protocol.
6562+
*
6563+
* Both domains must already be in canonical form.
6564+
* @param {string|URL} original
6565+
* @param {string|URL} destination
6566+
*/
6567+
const isSameProtocol = function isSameProtocol(destination, original) {
6568+
const orig = new URL$1(original).protocol;
6569+
const dest = new URL$1(destination).protocol;
6570+
6571+
return orig === dest;
6572+
};
6573+
65416574
/**
65426575
* Fetch function
65436576
*
@@ -6569,7 +6602,7 @@ function fetch(url, opts) {
65696602
let error = new AbortError('The user aborted a request.');
65706603
reject(error);
65716604
if (request.body && request.body instanceof Stream.Readable) {
6572-
request.body.destroy(error);
6605+
destroyStream(request.body, error);
65736606
}
65746607
if (!response || !response.body) return;
65756608
response.body.emit('error', error);
@@ -6610,9 +6643,43 @@ function fetch(url, opts) {
66106643

66116644
req.on('error', function (err) {
66126645
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
6646+
6647+
if (response && response.body) {
6648+
destroyStream(response.body, err);
6649+
}
6650+
66136651
finalize();
66146652
});
66156653

6654+
fixResponseChunkedTransferBadEnding(req, function (err) {
6655+
if (signal && signal.aborted) {
6656+
return;
6657+
}
6658+
6659+
if (response && response.body) {
6660+
destroyStream(response.body, err);
6661+
}
6662+
});
6663+
6664+
/* c8 ignore next 18 */
6665+
if (parseInt(process.version.substring(1)) < 14) {
6666+
// Before Node.js 14, pipeline() does not fully support async iterators and does not always
6667+
// properly handle when the socket close/end events are out of order.
6668+
req.on('socket', function (s) {
6669+
s.addListener('close', function (hadError) {
6670+
// if a data listener is still present we didn't end cleanly
6671+
const hasDataListener = s.listenerCount('data') > 0;
6672+
6673+
// if end happened before close but the socket didn't emit an error, do it now
6674+
if (response && hasDataListener && !hadError && !(signal && signal.aborted)) {
6675+
const err = new Error('Premature close');
6676+
err.code = 'ERR_STREAM_PREMATURE_CLOSE';
6677+
response.body.emit('error', err);
6678+
}
6679+
});
6680+
});
6681+
}
6682+
66166683
req.on('response', function (res) {
66176684
clearTimeout(reqTimeout);
66186685

@@ -6684,7 +6751,7 @@ function fetch(url, opts) {
66846751
size: request.size
66856752
};
66866753

6687-
if (!isDomainOrSubdomain(request.url, locationURL)) {
6754+
if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
66886755
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
66896756
requestOpts.headers.delete(name);
66906757
}
@@ -6777,6 +6844,13 @@ function fetch(url, opts) {
67776844
response = new Response(body, response_options);
67786845
resolve(response);
67796846
});
6847+
raw.on('end', function () {
6848+
// some old IIS servers return zero-length OK deflate responses, so 'data' is never emitted.
6849+
if (!response) {
6850+
response = new Response(body, response_options);
6851+
resolve(response);
6852+
}
6853+
});
67806854
return;
67816855
}
67826856

@@ -6796,6 +6870,41 @@ function fetch(url, opts) {
67966870
writeToStream(req, request);
67976871
});
67986872
}
6873+
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
6874+
let socket;
6875+
6876+
request.on('socket', function (s) {
6877+
socket = s;
6878+
});
6879+
6880+
request.on('response', function (response) {
6881+
const headers = response.headers;
6882+
6883+
if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) {
6884+
response.once('close', function (hadError) {
6885+
// if a data listener is still present we didn't end cleanly
6886+
const hasDataListener = socket.listenerCount('data') > 0;
6887+
6888+
if (hasDataListener && !hadError) {
6889+
const err = new Error('Premature close');
6890+
err.code = 'ERR_STREAM_PREMATURE_CLOSE';
6891+
errorCallback(err);
6892+
}
6893+
});
6894+
}
6895+
});
6896+
}
6897+
6898+
function destroyStream(stream, err) {
6899+
if (stream.destroy) {
6900+
stream.destroy(err);
6901+
} else {
6902+
// node < 8
6903+
stream.emit('error', err);
6904+
stream.end();
6905+
}
6906+
}
6907+
67996908
/**
68006909
* Redirect code matching
68016910
*

typescript/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)