feat(output): print output parameters (#458)

*  print output parameters

* 📝 add output table

* ⚗️ try output parameters

* ⚗️ stringify output

* ⚗️ try test output

* 🔥 remove test output

* 💚 build and lint code

* 🔥 remove output test

* 🔒 fix vulnerabilities

* 🎨 renaming staled variables

* 🎨 build code

* 📝 update contributing commands
This commit is contained in:
Falk Puschner 2021-06-03 15:18:48 +02:00 committed by GitHub
parent 1648064648
commit 3e6d35b685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1924 additions and 1932 deletions

View File

@ -19,7 +19,10 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: ./
id: stale
with:
stale-issue-message: 'This issue is stale'
stale-pr-message: 'This PR is stale'
debug-only: true
- name: print outputs
run: echo ${{ join(steps.stale.outputs.*, ',') }}

View File

@ -21,19 +21,19 @@ $ npm test
Run the tests and display only the first failing tests :heavy_check_mark:
```bash
$ npm test:only-errors
$ npm run test:only-errors
```
Run the tests with the watch mode :heavy_check_mark:
```bash
$ npm test:watch
$ npm run test:watch
```
Run the linter and fix (almost) every issue for you :heavy_check_mark:
```bash
$ npm lint:all:fix
$ npm run lint:all:fix
```
# Before creating a PR
@ -43,7 +43,7 @@ $ npm lint:all:fix
Build, lint, package and test everything.
```bash
$ npm all
$ npm run all
```
# Release

View File

@ -10,7 +10,7 @@ The default configuration will:
## All options
### List of options
### List of input options
Every argument is optional.
@ -61,6 +61,13 @@ Every argument is optional.
| [exempt-all-pr-assignees](#exempt-all-pr-assignees) | Override [exempt-all-assignees](#exempt-all-assignees) for PRs only | |
| [enable-statistics](#enable-statistics) | Display statistics in the logs | `true` |
### List of output options
| Output | Description |
| ----------------- | -------------------------------------------- |
| staled-issues-prs | List of all staled issues and pull requests. |
| closed-issues-prs | List of all closed issues and pull requests. |
### Detailed options
#### repo-token

View File

@ -168,6 +168,11 @@ inputs:
description: 'Display some statistics at the end regarding the stale workflow (only when the logs are enabled).'
default: 'true'
required: false
outputs:
closed-issues-prs:
description: 'List of all closed issues and pull requests.'
staled-issues-prs:
description: 'List of all staled issues and pull requests.'
runs:
using: 'node12'
main: 'dist/index.js'

119
dist/index.js vendored
View File

@ -1847,7 +1847,9 @@ function _run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const args = _getAndValidateArgs();
yield new issues_processor_1.IssuesProcessor(args).processIssues();
const issueProcessor = new issues_processor_1.IssuesProcessor(args);
yield issueProcessor.processIssues();
yield processOutput(issueProcessor.closedIssues, issueProcessor.staleIssues);
}
catch (error) {
core.error(error);
@ -1927,6 +1929,12 @@ function _getAndValidateArgs() {
}
return args;
}
function processOutput(staledIssues, closedIssues) {
return __awaiter(this, void 0, void 0, function* () {
core.setOutput('staled-issues-prs', JSON.stringify(staledIssues));
core.setOutput('closed-issues-prs', JSON.stringify(closedIssues));
});
}
function _toOptionalBoolean(argumentName) {
const argument = core.getInput(argumentName);
if (argument === 'true') {
@ -5661,16 +5669,13 @@ ansiEscapes.iTerm = {
/***/ }),
/***/ 2068:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
__nccwpck_require__.r(__webpack_exports__);
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
/* harmony export */ });
const ANSI_BACKGROUND_OFFSET = 10;
/* module decorator */ module = __nccwpck_require__.nmd(module);
const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
const ANSI_BACKGROUND_OFFSET = 10;
const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
@ -5765,10 +5770,8 @@ function assembleStyles() {
styles.color.close = '\u001B[39m';
styles.bgColor.close = '\u001B[49m';
styles.color.ansi = wrapAnsi16();
styles.color.ansi256 = wrapAnsi256();
styles.color.ansi16m = wrapAnsi16m();
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
@ -5823,67 +5826,17 @@ function assembleStyles() {
hexToAnsi256: {
value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
enumerable: false
},
ansi256ToAnsi: {
value: code => {
if (code < 8) {
return 30 + code;
}
if (code < 16) {
return 90 + (code - 8);
}
let red;
let green;
let blue;
if (code >= 232) {
red = (((code - 232) * 10) + 8) / 255;
green = red;
blue = red;
} else {
code -= 16;
const remainder = code % 36;
red = Math.floor(code / 36) / 5;
green = Math.floor(remainder / 6) / 5;
blue = (remainder % 6) / 5;
}
const value = Math.max(red, green, blue) * 2;
if (value === 0) {
return 30;
}
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
if (value === 2) {
result += 60;
}
return result;
},
enumerable: false
},
rgbToAnsi: {
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
enumerable: false
},
hexToAnsi: {
value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
enumerable: false
}
});
return styles;
}
const ansiStyles = assembleStyles();
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ansiStyles);
// Make the export immutable
Object.defineProperty(module, 'exports', {
enumerable: true,
get: assembleStyles
});
/***/ }),
@ -8874,8 +8827,8 @@ module.exports = require("zlib");;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ id: moduleId,
/******/ loaded: false,
/******/ exports: {}
/******/ };
/******/
@ -8888,36 +8841,20 @@ module.exports = require("zlib");;
/******/ if(threw) delete __webpack_module_cache__[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ /* webpack/runtime/node module decorator */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __nccwpck_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __nccwpck_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __nccwpck_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ __nccwpck_require__.nmd = (module) => {
/******/ module.paths = [];
/******/ if (!module.children) module.children = [];
/******/ return module;
/******/ };
/******/ })();
/******/

35
package-lock.json generated
View File

@ -7026,8 +7026,7 @@
},
"ws": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.0.tgz",
"integrity": "sha512-kyFwXuV/5ymf+IXhS6f0+eAFvydbaBW3zjpT6hUdAh/hbVjTIB5EHBGi0bPoCLSK2wcuz3BrEkB9LrYv1Nm4NQ==",
"resolved": "",
"dev": true
},
"yargs": {
@ -10292,6 +10291,32 @@
"yargs": "^16.0.0"
},
"dependencies": {
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
},
"dependencies": {
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dev": true,
"requires": {
"color-name": "1.1.3"
}
},
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
}
}
},
"chalk": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
@ -11245,9 +11270,9 @@
}
},
"ws": {
"version": "7.4.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
"integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA==",
"version": "7.4.6",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
"integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
"dev": true
},
"xml-name-validator": {

View File

@ -2,12 +2,19 @@ import * as core from '@actions/core';
import {IssuesProcessor} from './classes/issues-processor';
import {isValidDate} from './functions/dates/is-valid-date';
import {IIssuesProcessorOptions} from './interfaces/issues-processor-options';
import {Issue} from './classes/issue';
async function _run(): Promise<void> {
try {
const args = _getAndValidateArgs();
await new IssuesProcessor(args).processIssues();
const issueProcessor: IssuesProcessor = new IssuesProcessor(args);
await issueProcessor.processIssues();
await processOutput(
issueProcessor.closedIssues,
issueProcessor.staleIssues
);
} catch (error) {
core.error(error);
core.setFailed(error.message);
@ -103,6 +110,14 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
return args;
}
async function processOutput(
staledIssues: Issue[],
closedIssues: Issue[]
): Promise<void> {
core.setOutput('staled-issues-prs', JSON.stringify(staledIssues));
core.setOutput('closed-issues-prs', JSON.stringify(closedIssues));
}
function _toOptionalBoolean(
argumentName: Readonly<string>
): boolean | undefined {