@@ -353,7 +353,6 @@ const file_command_1 = __nccwpck_require__(717);
353
353
const utils_1 = __nccwpck_require__(5278);
354
354
const os = __importStar(__nccwpck_require__(2037));
355
355
const path = __importStar(__nccwpck_require__(1017));
356
- const uuid_1 = __nccwpck_require__(5840);
357
356
const oidc_utils_1 = __nccwpck_require__(8041);
358
357
/**
359
358
* The code to exit an action
@@ -383,20 +382,9 @@ function exportVariable(name, val) {
383
382
process.env[name] = convertedVal;
384
383
const filePath = process.env['GITHUB_ENV'] || '';
385
384
if (filePath) {
386
- const delimiter = `ghadelimiter_${uuid_1.v4()}`;
387
- // 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.
388
- if (name.includes(delimiter)) {
389
- throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
390
- }
391
- if (convertedVal.includes(delimiter)) {
392
- throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
393
- }
394
- const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
395
- file_command_1.issueCommand('ENV', commandValue);
396
- }
397
- else {
398
- command_1.issueCommand('set-env', { name }, convertedVal);
385
+ return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
399
386
}
387
+ command_1.issueCommand('set-env', { name }, convertedVal);
400
388
}
401
389
exports.exportVariable = exportVariable;
402
390
/**
@@ -414,7 +402,7 @@ exports.setSecret = setSecret;
414
402
function addPath(inputPath) {
415
403
const filePath = process.env['GITHUB_PATH'] || '';
416
404
if (filePath) {
417
- file_command_1.issueCommand ('PATH', inputPath);
405
+ file_command_1.issueFileCommand ('PATH', inputPath);
418
406
}
419
407
else {
420
408
command_1.issueCommand('add-path', {}, inputPath);
@@ -454,7 +442,10 @@ function getMultilineInput(name, options) {
454
442
const inputs = getInput(name, options)
455
443
.split('\n')
456
444
.filter(x => x !== '');
457
- return inputs;
445
+ if (options && options.trimWhitespace === false) {
446
+ return inputs;
447
+ }
448
+ return inputs.map(input => input.trim());
458
449
}
459
450
exports.getMultilineInput = getMultilineInput;
460
451
/**
@@ -487,8 +478,12 @@ exports.getBooleanInput = getBooleanInput;
487
478
*/
488
479
// eslint-disable-next-line @typescript-eslint/no-explicit-any
489
480
function setOutput(name, value) {
481
+ const filePath = process.env['GITHUB_OUTPUT'] || '';
482
+ if (filePath) {
483
+ return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
484
+ }
490
485
process.stdout.write(os.EOL);
491
- command_1.issueCommand('set-output', { name }, value);
486
+ command_1.issueCommand('set-output', { name }, utils_1.toCommandValue( value) );
492
487
}
493
488
exports.setOutput = setOutput;
494
489
/**
@@ -617,7 +612,11 @@ exports.group = group;
617
612
*/
618
613
// eslint-disable-next-line @typescript-eslint/no-explicit-any
619
614
function saveState(name, value) {
620
- command_1.issueCommand('save-state', { name }, value);
615
+ const filePath = process.env['GITHUB_STATE'] || '';
616
+ if (filePath) {
617
+ return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
618
+ }
619
+ command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
621
620
}
622
621
exports.saveState = saveState;
623
622
/**
@@ -683,13 +682,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
683
682
return result;
684
683
};
685
684
Object.defineProperty(exports, "__esModule", ({ value: true }));
686
- exports.issueCommand = void 0;
685
+ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
687
686
// We use any as a valid input type
688
687
/* eslint-disable @typescript-eslint/no-explicit-any */
689
688
const fs = __importStar(__nccwpck_require__(7147));
690
689
const os = __importStar(__nccwpck_require__(2037));
690
+ const uuid_1 = __nccwpck_require__(5840);
691
691
const utils_1 = __nccwpck_require__(5278);
692
- function issueCommand (command, message) {
692
+ function issueFileCommand (command, message) {
693
693
const filePath = process.env[`GITHUB_${command}`];
694
694
if (!filePath) {
695
695
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -701,7 +701,22 @@ function issueCommand(command, message) {
701
701
encoding: 'utf8'
702
702
});
703
703
}
704
- exports.issueCommand = issueCommand;
704
+ exports.issueFileCommand = issueFileCommand;
705
+ function prepareKeyValueMessage(key, value) {
706
+ const delimiter = `ghadelimiter_${uuid_1.v4()}`;
707
+ const convertedValue = utils_1.toCommandValue(value);
708
+ // These should realistically never happen, but just in case someone finds a
709
+ // way to exploit uuid generation let's not allow keys or values that contain
710
+ // the delimiter.
711
+ if (key.includes(delimiter)) {
712
+ throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
713
+ }
714
+ if (convertedValue.includes(delimiter)) {
715
+ throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
716
+ }
717
+ return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
718
+ }
719
+ exports.prepareKeyValueMessage = prepareKeyValueMessage;
705
720
//# sourceMappingURL=file-command.js.map
706
721
707
722
/***/ }),
@@ -2023,8 +2038,9 @@ exports.context = new Context.Context();
2023
2038
* @param token the repo PAT or GITHUB_TOKEN
2024
2039
* @param options other options to set
2025
2040
*/
2026
- function getOctokit(token, options) {
2027
- return new utils_1.GitHub(utils_1.getOctokitOptions(token, options));
2041
+ function getOctokit(token, options, ...additionalPlugins) {
2042
+ const GitHubWithPlugins = utils_1.GitHub.plugin(...additionalPlugins);
2043
+ return new GitHubWithPlugins(utils_1.getOctokitOptions(token, options));
2028
2044
}
2029
2045
exports.getOctokit = getOctokit;
2030
2046
//# sourceMappingURL=github.js.map
@@ -2106,7 +2122,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
2106
2122
return result;
2107
2123
};
2108
2124
Object.defineProperty(exports, "__esModule", ({ value: true }));
2109
- exports.getOctokitOptions = exports.GitHub = exports.context = void 0;
2125
+ exports.getOctokitOptions = exports.GitHub = exports.defaults = exports. context = void 0;
2110
2126
const Context = __importStar(__nccwpck_require__(4087));
2111
2127
const Utils = __importStar(__nccwpck_require__(7914));
2112
2128
// octokit + plugins
@@ -2115,13 +2131,13 @@ const plugin_rest_endpoint_methods_1 = __nccwpck_require__(3044);
2115
2131
const plugin_paginate_rest_1 = __nccwpck_require__(4193);
2116
2132
exports.context = new Context.Context();
2117
2133
const baseUrl = Utils.getApiBaseUrl();
2118
- const defaults = {
2134
+ exports. defaults = {
2119
2135
baseUrl,
2120
2136
request: {
2121
2137
agent: Utils.getProxyAgent(baseUrl)
2122
2138
}
2123
2139
};
2124
- exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(defaults);
2140
+ exports.GitHub = core_1.Octokit.plugin(plugin_rest_endpoint_methods_1.restEndpointMethods, plugin_paginate_rest_1.paginateRest).defaults(exports. defaults);
2125
2141
/**
2126
2142
* Convience function to correctly format Octokit Options to pass into the constructor.
2127
2143
*
@@ -2945,11 +2961,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
2945
2961
};
2946
2962
var _a;
2947
2963
Object.defineProperty(exports, "__esModule", ({ value: true }));
2948
- exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
2964
+ exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.READONLY = exports.UV_FS_O_EXLOCK = exports. IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports. rename = exports.readlink = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
2949
2965
const fs = __importStar(__nccwpck_require__(7147));
2950
2966
const path = __importStar(__nccwpck_require__(1017));
2951
- _a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
2967
+ _a = fs.promises
2968
+ // export const {open} = 'fs'
2969
+ , exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
2970
+ // export const {open} = 'fs'
2952
2971
exports.IS_WINDOWS = process.platform === 'win32';
2972
+ // See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
2973
+ exports.UV_FS_O_EXLOCK = 0x10000000;
2974
+ exports.READONLY = fs.constants.O_RDONLY;
2953
2975
function exists(fsPath) {
2954
2976
return __awaiter(this, void 0, void 0, function* () {
2955
2977
try {
@@ -3130,12 +3152,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
3130
3152
Object.defineProperty(exports, "__esModule", ({ value: true }));
3131
3153
exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
3132
3154
const assert_1 = __nccwpck_require__(9491);
3133
- const childProcess = __importStar(__nccwpck_require__(2081));
3134
3155
const path = __importStar(__nccwpck_require__(1017));
3135
- const util_1 = __nccwpck_require__(3837);
3136
3156
const ioUtil = __importStar(__nccwpck_require__(1962));
3137
- const exec = util_1.promisify(childProcess.exec);
3138
- const execFile = util_1.promisify(childProcess.execFile);
3139
3157
/**
3140
3158
* Copies a file or folder.
3141
3159
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
@@ -3216,61 +3234,23 @@ exports.mv = mv;
3216
3234
function rmRF(inputPath) {
3217
3235
return __awaiter(this, void 0, void 0, function* () {
3218
3236
if (ioUtil.IS_WINDOWS) {
3219
- // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
3220
- // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
3221
3237
// Check for invalid characters
3222
3238
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
3223
3239
if (/[*"<>|]/.test(inputPath)) {
3224
3240
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
3225
3241
}
3226
- try {
3227
- const cmdPath = ioUtil.getCmdPath();
3228
- if (yield ioUtil.isDirectory(inputPath, true)) {
3229
- yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
3230
- env: { inputPath }
3231
- });
3232
- }
3233
- else {
3234
- yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
3235
- env: { inputPath }
3236
- });
3237
- }
3238
- }
3239
- catch (err) {
3240
- // if you try to delete a file that doesn't exist, desired result is achieved
3241
- // other errors are valid
3242
- if (err.code !== 'ENOENT')
3243
- throw err;
3244
- }
3245
- // Shelling out fails to remove a symlink folder with missing source, this unlink catches that
3246
- try {
3247
- yield ioUtil.unlink(inputPath);
3248
- }
3249
- catch (err) {
3250
- // if you try to delete a file that doesn't exist, desired result is achieved
3251
- // other errors are valid
3252
- if (err.code !== 'ENOENT')
3253
- throw err;
3254
- }
3255
3242
}
3256
- else {
3257
- let isDir = false;
3258
- try {
3259
- isDir = yield ioUtil.isDirectory(inputPath);
3260
- }
3261
- catch (err) {
3262
- // if you try to delete a file that doesn't exist, desired result is achieved
3263
- // other errors are valid
3264
- if (err.code !== 'ENOENT')
3265
- throw err;
3266
- return;
3267
- }
3268
- if (isDir) {
3269
- yield execFile(`rm`, [`-rf`, `${inputPath}`]);
3270
- }
3271
- else {
3272
- yield ioUtil.unlink(inputPath);
3273
- }
3243
+ try {
3244
+ // note if path does not exist, error is silent
3245
+ yield ioUtil.rm(inputPath, {
3246
+ force: true,
3247
+ maxRetries: 3,
3248
+ recursive: true,
3249
+ retryDelay: 300
3250
+ });
3251
+ }
3252
+ catch (err) {
3253
+ throw new Error(`File was unable to be removed ${err}`);
3274
3254
}
3275
3255
});
3276
3256
}
0 commit comments