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:
parent
1648064648
commit
3e6d35b685
|
@ -19,7 +19,10 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: ./
|
- uses: ./
|
||||||
|
id: stale
|
||||||
with:
|
with:
|
||||||
stale-issue-message: 'This issue is stale'
|
stale-issue-message: 'This issue is stale'
|
||||||
stale-pr-message: 'This PR is stale'
|
stale-pr-message: 'This PR is stale'
|
||||||
debug-only: true
|
debug-only: true
|
||||||
|
- name: print outputs
|
||||||
|
run: echo ${{ join(steps.stale.outputs.*, ',') }}
|
||||||
|
|
|
@ -21,19 +21,19 @@ $ npm test
|
||||||
Run the tests and display only the first failing tests :heavy_check_mark:
|
Run the tests and display only the first failing tests :heavy_check_mark:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm test:only-errors
|
$ npm run test:only-errors
|
||||||
```
|
```
|
||||||
|
|
||||||
Run the tests with the watch mode :heavy_check_mark:
|
Run the tests with the watch mode :heavy_check_mark:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm test:watch
|
$ npm run test:watch
|
||||||
```
|
```
|
||||||
|
|
||||||
Run the linter and fix (almost) every issue for you :heavy_check_mark:
|
Run the linter and fix (almost) every issue for you :heavy_check_mark:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm lint:all:fix
|
$ npm run lint:all:fix
|
||||||
```
|
```
|
||||||
|
|
||||||
# Before creating a PR
|
# Before creating a PR
|
||||||
|
@ -43,7 +43,7 @@ $ npm lint:all:fix
|
||||||
Build, lint, package and test everything.
|
Build, lint, package and test everything.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm all
|
$ npm run all
|
||||||
```
|
```
|
||||||
|
|
||||||
# Release
|
# Release
|
||||||
|
|
|
@ -10,7 +10,7 @@ The default configuration will:
|
||||||
|
|
||||||
## All options
|
## All options
|
||||||
|
|
||||||
### List of options
|
### List of input options
|
||||||
|
|
||||||
Every argument is optional.
|
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 | |
|
| [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` |
|
| [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
|
### Detailed options
|
||||||
|
|
||||||
#### repo-token
|
#### repo-token
|
||||||
|
|
|
@ -168,6 +168,11 @@ inputs:
|
||||||
description: 'Display some statistics at the end regarding the stale workflow (only when the logs are enabled).'
|
description: 'Display some statistics at the end regarding the stale workflow (only when the logs are enabled).'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
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:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
|
@ -1847,7 +1847,9 @@ function _run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const args = _getAndValidateArgs();
|
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) {
|
catch (error) {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
|
@ -1927,6 +1929,12 @@ function _getAndValidateArgs() {
|
||||||
}
|
}
|
||||||
return args;
|
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) {
|
function _toOptionalBoolean(argumentName) {
|
||||||
const argument = core.getInput(argumentName);
|
const argument = core.getInput(argumentName);
|
||||||
if (argument === 'true') {
|
if (argument === 'true') {
|
||||||
|
@ -5661,16 +5669,13 @@ ansiEscapes.iTerm = {
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 2068:
|
/***/ 2068:
|
||||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
__nccwpck_require__.r(__webpack_exports__);
|
/* module decorator */ module = __nccwpck_require__.nmd(module);
|
||||||
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
||||||
/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__
|
|
||||||
/* harmony export */ });
|
|
||||||
const ANSI_BACKGROUND_OFFSET = 10;
|
|
||||||
|
|
||||||
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`;
|
const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
||||||
|
|
||||||
|
@ -5765,10 +5770,8 @@ function assembleStyles() {
|
||||||
styles.color.close = '\u001B[39m';
|
styles.color.close = '\u001B[39m';
|
||||||
styles.bgColor.close = '\u001B[49m';
|
styles.bgColor.close = '\u001B[49m';
|
||||||
|
|
||||||
styles.color.ansi = wrapAnsi16();
|
|
||||||
styles.color.ansi256 = wrapAnsi256();
|
styles.color.ansi256 = wrapAnsi256();
|
||||||
styles.color.ansi16m = wrapAnsi16m();
|
styles.color.ansi16m = wrapAnsi16m();
|
||||||
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
||||||
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
||||||
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
||||||
|
|
||||||
|
@ -5823,67 +5826,17 @@ function assembleStyles() {
|
||||||
hexToAnsi256: {
|
hexToAnsi256: {
|
||||||
value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
||||||
enumerable: false
|
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;
|
return styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ansiStyles = assembleStyles();
|
// Make the export immutable
|
||||||
|
Object.defineProperty(module, 'exports', {
|
||||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ansiStyles);
|
enumerable: true,
|
||||||
|
get: assembleStyles
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
@ -8874,8 +8827,8 @@ module.exports = require("zlib");;
|
||||||
/******/ }
|
/******/ }
|
||||||
/******/ // Create a new module (and put it into the cache)
|
/******/ // Create a new module (and put it into the cache)
|
||||||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||||
/******/ // no module.id needed
|
/******/ id: moduleId,
|
||||||
/******/ // no module.loaded needed
|
/******/ loaded: false,
|
||||||
/******/ exports: {}
|
/******/ exports: {}
|
||||||
/******/ };
|
/******/ };
|
||||||
/******/
|
/******/
|
||||||
|
@ -8888,36 +8841,20 @@ module.exports = require("zlib");;
|
||||||
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
||||||
/******/ }
|
/******/ }
|
||||||
/******/
|
/******/
|
||||||
|
/******/ // Flag the module as loaded
|
||||||
|
/******/ module.loaded = true;
|
||||||
|
/******/
|
||||||
/******/ // Return the exports of the module
|
/******/ // Return the exports of the module
|
||||||
/******/ return module.exports;
|
/******/ return module.exports;
|
||||||
/******/ }
|
/******/ }
|
||||||
/******/
|
/******/
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/******/ /* webpack/runtime/define property getters */
|
/******/ /* webpack/runtime/node module decorator */
|
||||||
/******/ (() => {
|
/******/ (() => {
|
||||||
/******/ // define getter functions for harmony exports
|
/******/ __nccwpck_require__.nmd = (module) => {
|
||||||
/******/ __nccwpck_require__.d = (exports, definition) => {
|
/******/ module.paths = [];
|
||||||
/******/ for(var key in definition) {
|
/******/ if (!module.children) module.children = [];
|
||||||
/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) {
|
/******/ return module;
|
||||||
/******/ 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 });
|
|
||||||
/******/ };
|
/******/ };
|
||||||
/******/ })();
|
/******/ })();
|
||||||
/******/
|
/******/
|
||||||
|
|
|
@ -7026,8 +7026,7 @@
|
||||||
},
|
},
|
||||||
"ws": {
|
"ws": {
|
||||||
"version": "7.4.0",
|
"version": "7.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.0.tgz",
|
"resolved": "",
|
||||||
"integrity": "sha512-kyFwXuV/5ymf+IXhS6f0+eAFvydbaBW3zjpT6hUdAh/hbVjTIB5EHBGi0bPoCLSK2wcuz3BrEkB9LrYv1Nm4NQ==",
|
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"yargs": {
|
"yargs": {
|
||||||
|
@ -10292,6 +10291,32 @@
|
||||||
"yargs": "^16.0.0"
|
"yargs": "^16.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"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": {
|
"chalk": {
|
||||||
"version": "2.4.2",
|
"version": "2.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
|
||||||
|
@ -11245,9 +11270,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ws": {
|
"ws": {
|
||||||
"version": "7.4.2",
|
"version": "7.4.6",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
|
||||||
"integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA==",
|
"integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"xml-name-validator": {
|
"xml-name-validator": {
|
||||||
|
|
17
src/main.ts
17
src/main.ts
|
@ -2,12 +2,19 @@ import * as core from '@actions/core';
|
||||||
import {IssuesProcessor} from './classes/issues-processor';
|
import {IssuesProcessor} from './classes/issues-processor';
|
||||||
import {isValidDate} from './functions/dates/is-valid-date';
|
import {isValidDate} from './functions/dates/is-valid-date';
|
||||||
import {IIssuesProcessorOptions} from './interfaces/issues-processor-options';
|
import {IIssuesProcessorOptions} from './interfaces/issues-processor-options';
|
||||||
|
import {Issue} from './classes/issue';
|
||||||
|
|
||||||
async function _run(): Promise<void> {
|
async function _run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const args = _getAndValidateArgs();
|
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) {
|
} catch (error) {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
@ -103,6 +110,14 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
|
||||||
return args;
|
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(
|
function _toOptionalBoolean(
|
||||||
argumentName: Readonly<string>
|
argumentName: Readonly<string>
|
||||||
): boolean | undefined {
|
): boolean | undefined {
|
||||||
|
|
Loading…
Reference in New Issue