|
| 1 | +"use strict"; |
| 2 | +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
| 3 | + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
| 4 | + return new (P || (P = Promise))(function (resolve, reject) { |
| 5 | + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
| 6 | + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
| 7 | + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
| 8 | + step((generator = generator.apply(thisArg, _arguments || [])).next()); |
| 9 | + }); |
| 10 | +}; |
| 11 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 12 | +exports.getSponsors = exports.generateFile = void 0; |
| 13 | +const core_1 = require("@actions/core"); |
| 14 | +const constants_1 = require("./constants"); |
| 15 | +const template_1 = require("./template"); |
| 16 | +Object.defineProperty(exports, "generateFile", { enumerable: true, get: function () { return template_1.generateFile; } }); |
| 17 | +Object.defineProperty(exports, "getSponsors", { enumerable: true, get: function () { return template_1.getSponsors; } }); |
| 18 | +const util_1 = require("./util"); |
| 19 | +/** Initializes and runs the action. |
| 20 | + * |
| 21 | + * @param {ActionInterface} configuration - The configuration object. |
| 22 | + */ |
| 23 | +function run(configuration) { |
| 24 | + return __awaiter(this, void 0, void 0, function* () { |
| 25 | + let status = constants_1.Status.RUNNING; |
| 26 | + const settings = Object.assign({}, configuration); |
| 27 | + try { |
| 28 | + (0, core_1.info)(` |
| 29 | +
|
| 30 | + ██████╗ ██╗████████╗██╗ ██╗██╗ ██╗██████╗ |
| 31 | + ██╔════╝ ██║╚══██╔══╝██║ ██║██║ ██║██╔══██╗ |
| 32 | + ██║ ███╗██║ ██║ ███████║██║ ██║██████╔╝ |
| 33 | + ██║ ██║██║ ██║ ██╔══██║██║ ██║██╔══██╗ |
| 34 | + ╚██████╔╝██║ ██║ ██║ ██║╚██████╔╝██████╔╝ |
| 35 | + ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ |
| 36 | + |
| 37 | + ███████╗██████╗ ██████╗ ███╗ ██╗███████╗ ██████╗ ██████╗ ███████╗ |
| 38 | + ██╔════╝██╔══██╗██╔═══██╗████╗ ██║██╔════╝██╔═══██╗██╔══██╗██╔════╝ |
| 39 | + ███████╗██████╔╝██║ ██║██╔██╗ ██║███████╗██║ ██║██████╔╝███████╗ |
| 40 | + ╚════██║██╔═══╝ ██║ ██║██║╚██╗██║╚════██║██║ ██║██╔══██╗╚════██║ |
| 41 | + ███████║██║ ╚██████╔╝██║ ╚████║███████║╚██████╔╝██║ ██║███████║ |
| 42 | + ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ |
| 43 | + |
| 44 | + ██████╗ ███████╗ █████╗ ██████╗ ███╗ ███╗███████╗ |
| 45 | + ██╔══██╗██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝ |
| 46 | + ██████╔╝█████╗ ███████║██║ ██║██╔████╔██║█████╗ |
| 47 | + ██╔══██╗██╔══╝ ██╔══██║██║ ██║██║╚██╔╝██║██╔══╝ |
| 48 | + ██║ ██║███████╗██║ ██║██████╔╝██║ ╚═╝ ██║███████╗ |
| 49 | + ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚══════╝ |
| 50 | + |
| 51 | + █████╗ ██████╗████████╗██╗ ██████╗ ███╗ ██╗ |
| 52 | + ██╔══██╗██╔════╝╚══██╔══╝██║██╔═══██╗████╗ ██║ |
| 53 | + ███████║██║ ██║ ██║██║ ██║██╔██╗ ██║ |
| 54 | + ██╔══██║██║ ██║ ██║██║ ██║██║╚██╗██║ |
| 55 | + ██║ ██║╚██████╗ ██║ ██║╚██████╔╝██║ ╚████║ |
| 56 | + ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ |
| 57 | + |
| 58 | + 🚀 Getting Started Guide: https://github.com/JamesIves/github-sponsors-readme-action |
| 59 | + ❓ Discussions / Q&A: https://github.com/JamesIves/github-sponsors-readme-action/discussions |
| 60 | + 🔧 Report a Bug: https://github.com/JamesIves/github-sponsors-readme-action/issues |
| 61 | +
|
| 62 | + 📣 Maintained by James Ives: https://jamesiv.es |
| 63 | + 💖 Support: https://github.com/sponsors/JamesIves`); |
| 64 | + (0, core_1.info)('Checking configuration and initializing… 🚚'); |
| 65 | + (0, util_1.checkParameters)(settings); |
| 66 | + const response = yield (0, template_1.getSponsors)(settings); |
| 67 | + status = yield (0, template_1.generateFile)(response, settings); |
| 68 | + } |
| 69 | + catch (error) { |
| 70 | + status = constants_1.Status.FAILED; |
| 71 | + (0, core_1.setFailed)((0, util_1.extractErrorMessage)(error)); |
| 72 | + } |
| 73 | + finally { |
| 74 | + (0, core_1.info)(`${status === constants_1.Status.FAILED |
| 75 | + ? 'There was an error generating sponsors. ❌' |
| 76 | + : status === constants_1.Status.SUCCESS |
| 77 | + ? 'The data was successfully retrieved and saved! ✅ 💖' |
| 78 | + : `Unable to locate markers in your file, ensure you have a starting and closing tag in your README file. Please check the documentation and try again. ⚠️`}`); |
| 79 | + (0, core_1.exportVariable)('sponsorshipStatus', status); |
| 80 | + (0, core_1.setOutput)('sponsorshipStatus', status); |
| 81 | + } |
| 82 | + return status; |
| 83 | + }); |
| 84 | +} |
| 85 | +exports.default = run; |
0 commit comments