From 6e67af9be59a5e955cae1701b76ae55a6dfc2686 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Wed, 16 Dec 2020 15:07:55 +0300 Subject: [PATCH 1/5] added 'Scripts' folder to PATH on Windows --- src/find-python.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/find-python.ts b/src/find-python.ts index 6702430c5..6cc21d484 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -66,6 +66,10 @@ function usePyPy( core.addPath(installDir); core.addPath(_binDir); + // Starting from PyPy 7.3.1, the folder that is used for pip and anything that pip installs should be "Scripts" on Windows. + if (IS_WINDOWS) { + core.addPath(path.join(installDir, 'Scripts')); + } const impl = 'pypy' + majorVersion.toString(); core.setOutput('python-version', impl); From 52b59a2c40ad337d8982b5377f54e92b16d310fb Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Thu, 17 Dec 2020 16:35:01 +0300 Subject: [PATCH 2/5] add release code --- dist/index.js | 120 +++++++------------------------------------------- 1 file changed, 16 insertions(+), 104 deletions(-) diff --git a/dist/index.js b/dist/index.js index 41cfa78b7..10d8a4595 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1369,32 +1369,6 @@ class SemVer { module.exports = SemVer -/***/ }), - -/***/ 82: -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -// We use any as a valid input type -/* eslint-disable @typescript-eslint/no-explicit-any */ -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Sanitizes an input into a string so it can be passed into issueCommand safely - * @param input input to sanitize into a string - */ -function toCommandValue(input) { - if (input === null || input === undefined) { - return ''; - } - else if (typeof input === 'string' || input instanceof String) { - return input; - } - return JSON.stringify(input); -} -exports.toCommandValue = toCommandValue; -//# sourceMappingURL=utils.js.map - /***/ }), /***/ 87: @@ -1404,42 +1378,6 @@ module.exports = require("os"); /***/ }), -/***/ 102: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -// For internal use, subject to change. -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// We use any as a valid input type -/* eslint-disable @typescript-eslint/no-explicit-any */ -const fs = __importStar(__webpack_require__(747)); -const os = __importStar(__webpack_require__(87)); -const utils_1 = __webpack_require__(82); -function issueCommand(command, message) { - const filePath = process.env[`GITHUB_${command}`]; - if (!filePath) { - throw new Error(`Unable to find environment variable for file command ${command}`); - } - if (!fs.existsSync(filePath)) { - throw new Error(`Missing file at path: ${filePath}`); - } - fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { - encoding: 'utf8' - }); -} -exports.issueCommand = issueCommand; -//# sourceMappingURL=file-command.js.map - -/***/ }), - /***/ 120: /***/ (function(module, __unusedexports, __webpack_require__) { @@ -2611,7 +2549,6 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const os = __importStar(__webpack_require__(87)); -const utils_1 = __webpack_require__(82); /** * Commands * @@ -2666,13 +2603,13 @@ class Command { } } function escapeData(s) { - return utils_1.toCommandValue(s) + return (s || '') .replace(/%/g, '%25') .replace(/\r/g, '%0D') .replace(/\n/g, '%0A'); } function escapeProperty(s) { - return utils_1.toCommandValue(s) + return (s || '') .replace(/%/g, '%25') .replace(/\r/g, '%0D') .replace(/\n/g, '%0A') @@ -2793,8 +2730,6 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = __webpack_require__(431); -const file_command_1 = __webpack_require__(102); -const utils_1 = __webpack_require__(82); const os = __importStar(__webpack_require__(87)); const path = __importStar(__webpack_require__(622)); /** @@ -2817,21 +2752,11 @@ var ExitCode; /** * Sets env variable for this action and future actions in the job * @param name the name of the variable to set - * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify + * @param val the value of the variable */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any function exportVariable(name, val) { - const convertedVal = utils_1.toCommandValue(val); - process.env[name] = convertedVal; - const filePath = process.env['GITHUB_ENV'] || ''; - if (filePath) { - const delimiter = '_GitHubActionsFileCommandDelimeter_'; - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); - } + process.env[name] = val; + command_1.issueCommand('set-env', { name }, val); } exports.exportVariable = exportVariable; /** @@ -2847,13 +2772,7 @@ exports.setSecret = setSecret; * @param inputPath */ function addPath(inputPath) { - const filePath = process.env['GITHUB_PATH'] || ''; - if (filePath) { - file_command_1.issueCommand('PATH', inputPath); - } - else { - command_1.issueCommand('add-path', {}, inputPath); - } + command_1.issueCommand('add-path', {}, inputPath); process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; } exports.addPath = addPath; @@ -2876,22 +2795,12 @@ exports.getInput = getInput; * Sets the value of an output. * * @param name name of the output to set - * @param value value to store. Non-string values will be converted to a string via JSON.stringify + * @param value value to store */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { command_1.issueCommand('set-output', { name }, value); } exports.setOutput = setOutput; -/** - * Enables or disables the echoing of commands into stdout for the rest of the step. - * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. - * - */ -function setCommandEcho(enabled) { - command_1.issue('echo', enabled ? 'on' : 'off'); -} -exports.setCommandEcho = setCommandEcho; //----------------------------------------------------------------------- // Results //----------------------------------------------------------------------- @@ -2925,18 +2834,18 @@ function debug(message) { exports.debug = debug; /** * Adds an error issue - * @param message error issue message. Errors will be converted to string via toString() + * @param message error issue message */ function error(message) { - command_1.issue('error', message instanceof Error ? message.toString() : message); + command_1.issue('error', message); } exports.error = error; /** * Adds an warning issue - * @param message warning issue message. Errors will be converted to string via toString() + * @param message warning issue message */ function warning(message) { - command_1.issue('warning', message instanceof Error ? message.toString() : message); + command_1.issue('warning', message); } exports.warning = warning; /** @@ -2994,9 +2903,8 @@ exports.group = group; * Saves state for current action, the state can only be retrieved by this action's post job execution. * * @param name name of the state to store - * @param value value to store. Non-string values will be converted to a string via JSON.stringify + * @param value value to store */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { command_1.issueCommand('save-state', { name }, value); } @@ -6738,6 +6646,10 @@ function usePyPy(majorVersion, architecture) { core.exportVariable('pythonLocation', pythonLocation); core.addPath(installDir); core.addPath(_binDir); + // Starting from PyPy 7.3.1, the folder that is used for pip and anything that pip installs should be "Scripts" on Windows. + if (IS_WINDOWS) { + core.addPath(path.join(installDir, 'Scripts')); + } const impl = 'pypy' + majorVersion.toString(); core.setOutput('python-version', impl); return { impl: impl, version: versionFromPath(installDir) }; From 09aeb67db1edc8cec6a5f81d07430364aa41b877 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Thu, 17 Dec 2020 17:29:03 +0300 Subject: [PATCH 3/5] update index.js --- dist/index.js | 4 ++-- src/find-python.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 10d8a4595..66d1fdee6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6646,9 +6646,9 @@ function usePyPy(majorVersion, architecture) { core.exportVariable('pythonLocation', pythonLocation); core.addPath(installDir); core.addPath(_binDir); - // Starting from PyPy 7.3.1, the folder that is used for pip and anything that pip installs should be "Scripts" on Windows. if (IS_WINDOWS) { - core.addPath(path.join(installDir, 'Scripts')); + const scriptDir = path.join(installDir, 'Scripts'); + core.addPath(scriptDir); } const impl = 'pypy' + majorVersion.toString(); core.setOutput('python-version', impl); diff --git a/src/find-python.ts b/src/find-python.ts index 6cc21d484..3e54712a0 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -71,6 +71,11 @@ function usePyPy( core.addPath(path.join(installDir, 'Scripts')); } + if (IS_WINDOWS) { + const scriptDir = path.join(installDir, 'Scripts'); + core.addPath(scriptDir); + } + const impl = 'pypy' + majorVersion.toString(); core.setOutput('python-version', impl); From dcd7128984c3fdcccbe690ce9ad189838566c054 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 17 Dec 2020 17:38:56 +0300 Subject: [PATCH 4/5] rebuild index.js --- dist/index.js | 120 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 108 insertions(+), 12 deletions(-) diff --git a/dist/index.js b/dist/index.js index 66d1fdee6..bb7e8bdc8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1369,6 +1369,32 @@ class SemVer { module.exports = SemVer +/***/ }), + +/***/ 82: +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +// We use any as a valid input type +/* eslint-disable @typescript-eslint/no-explicit-any */ +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Sanitizes an input into a string so it can be passed into issueCommand safely + * @param input input to sanitize into a string + */ +function toCommandValue(input) { + if (input === null || input === undefined) { + return ''; + } + else if (typeof input === 'string' || input instanceof String) { + return input; + } + return JSON.stringify(input); +} +exports.toCommandValue = toCommandValue; +//# sourceMappingURL=utils.js.map + /***/ }), /***/ 87: @@ -1378,6 +1404,42 @@ module.exports = require("os"); /***/ }), +/***/ 102: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +// For internal use, subject to change. +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// We use any as a valid input type +/* eslint-disable @typescript-eslint/no-explicit-any */ +const fs = __importStar(__webpack_require__(747)); +const os = __importStar(__webpack_require__(87)); +const utils_1 = __webpack_require__(82); +function issueCommand(command, message) { + const filePath = process.env[`GITHUB_${command}`]; + if (!filePath) { + throw new Error(`Unable to find environment variable for file command ${command}`); + } + if (!fs.existsSync(filePath)) { + throw new Error(`Missing file at path: ${filePath}`); + } + fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { + encoding: 'utf8' + }); +} +exports.issueCommand = issueCommand; +//# sourceMappingURL=file-command.js.map + +/***/ }), + /***/ 120: /***/ (function(module, __unusedexports, __webpack_require__) { @@ -2549,6 +2611,7 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const os = __importStar(__webpack_require__(87)); +const utils_1 = __webpack_require__(82); /** * Commands * @@ -2603,13 +2666,13 @@ class Command { } } function escapeData(s) { - return (s || '') + return utils_1.toCommandValue(s) .replace(/%/g, '%25') .replace(/\r/g, '%0D') .replace(/\n/g, '%0A'); } function escapeProperty(s) { - return (s || '') + return utils_1.toCommandValue(s) .replace(/%/g, '%25') .replace(/\r/g, '%0D') .replace(/\n/g, '%0A') @@ -2730,6 +2793,8 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = __webpack_require__(431); +const file_command_1 = __webpack_require__(102); +const utils_1 = __webpack_require__(82); const os = __importStar(__webpack_require__(87)); const path = __importStar(__webpack_require__(622)); /** @@ -2752,11 +2817,21 @@ var ExitCode; /** * Sets env variable for this action and future actions in the job * @param name the name of the variable to set - * @param val the value of the variable + * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any function exportVariable(name, val) { - process.env[name] = val; - command_1.issueCommand('set-env', { name }, val); + const convertedVal = utils_1.toCommandValue(val); + process.env[name] = convertedVal; + const filePath = process.env['GITHUB_ENV'] || ''; + if (filePath) { + const delimiter = '_GitHubActionsFileCommandDelimeter_'; + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; + file_command_1.issueCommand('ENV', commandValue); + } + else { + command_1.issueCommand('set-env', { name }, convertedVal); + } } exports.exportVariable = exportVariable; /** @@ -2772,7 +2847,13 @@ exports.setSecret = setSecret; * @param inputPath */ function addPath(inputPath) { - command_1.issueCommand('add-path', {}, inputPath); + const filePath = process.env['GITHUB_PATH'] || ''; + if (filePath) { + file_command_1.issueCommand('PATH', inputPath); + } + else { + command_1.issueCommand('add-path', {}, inputPath); + } process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; } exports.addPath = addPath; @@ -2795,12 +2876,22 @@ exports.getInput = getInput; * Sets the value of an output. * * @param name name of the output to set - * @param value value to store + * @param value value to store. Non-string values will be converted to a string via JSON.stringify */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { command_1.issueCommand('set-output', { name }, value); } exports.setOutput = setOutput; +/** + * Enables or disables the echoing of commands into stdout for the rest of the step. + * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. + * + */ +function setCommandEcho(enabled) { + command_1.issue('echo', enabled ? 'on' : 'off'); +} +exports.setCommandEcho = setCommandEcho; //----------------------------------------------------------------------- // Results //----------------------------------------------------------------------- @@ -2834,18 +2925,18 @@ function debug(message) { exports.debug = debug; /** * Adds an error issue - * @param message error issue message + * @param message error issue message. Errors will be converted to string via toString() */ function error(message) { - command_1.issue('error', message); + command_1.issue('error', message instanceof Error ? message.toString() : message); } exports.error = error; /** * Adds an warning issue - * @param message warning issue message + * @param message warning issue message. Errors will be converted to string via toString() */ function warning(message) { - command_1.issue('warning', message); + command_1.issue('warning', message instanceof Error ? message.toString() : message); } exports.warning = warning; /** @@ -2903,8 +2994,9 @@ exports.group = group; * Saves state for current action, the state can only be retrieved by this action's post job execution. * * @param name name of the state to store - * @param value value to store + * @param value value to store. Non-string values will be converted to a string via JSON.stringify */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { command_1.issueCommand('save-state', { name }, value); } @@ -6646,6 +6738,10 @@ function usePyPy(majorVersion, architecture) { core.exportVariable('pythonLocation', pythonLocation); core.addPath(installDir); core.addPath(_binDir); + // Starting from PyPy 7.3.1, the folder that is used for pip and anything that pip installs should be "Scripts" on Windows. + if (IS_WINDOWS) { + core.addPath(path.join(installDir, 'Scripts')); + } if (IS_WINDOWS) { const scriptDir = path.join(installDir, 'Scripts'); core.addPath(scriptDir); From bedb244a49bd679c8bcf9660e08b4b5cc99a135c Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 17 Dec 2020 17:49:30 +0300 Subject: [PATCH 5/5] remove duplicate block --- dist/index.js | 4 ---- src/find-python.ts | 5 ----- 2 files changed, 9 deletions(-) diff --git a/dist/index.js b/dist/index.js index bb7e8bdc8..5362e846b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6742,10 +6742,6 @@ function usePyPy(majorVersion, architecture) { if (IS_WINDOWS) { core.addPath(path.join(installDir, 'Scripts')); } - if (IS_WINDOWS) { - const scriptDir = path.join(installDir, 'Scripts'); - core.addPath(scriptDir); - } const impl = 'pypy' + majorVersion.toString(); core.setOutput('python-version', impl); return { impl: impl, version: versionFromPath(installDir) }; diff --git a/src/find-python.ts b/src/find-python.ts index 3e54712a0..6cc21d484 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -71,11 +71,6 @@ function usePyPy( core.addPath(path.join(installDir, 'Scripts')); } - if (IS_WINDOWS) { - const scriptDir = path.join(installDir, 'Scripts'); - core.addPath(scriptDir); - } - const impl = 'pypy' + majorVersion.toString(); core.setOutput('python-version', impl);