From 78eac15b6bc04c8171ca6c18ed73c4cfe62c336e Mon Sep 17 00:00:00 2001 From: Matteo Casonato Date: Tue, 24 Jan 2023 16:10:04 +0100 Subject: [PATCH] Update action - refactor - add `total_milestones` - remove `total_cost_btc` - changed @zeit/ncc (deprecated) to @vercel/ncc --- action.yml | 4 +- dist/index.js | 379 ++++++++++++++++++++++++---------------------- index.js | 66 +++++--- package-lock.json | 19 ++- package.json | 2 +- 5 files changed, 251 insertions(+), 219 deletions(-) diff --git a/action.yml b/action.yml index a3ba6fb..d8e944d 100644 --- a/action.yml +++ b/action.yml @@ -18,10 +18,10 @@ outputs: description: 'Project name' address: description: 'Registered address of legal entity' - total_cost_btc: - description: 'Total cost, BTC' total_cost_dai: description: 'Total cost, DAI' + total_milestones: + description: 'Total number of milestones' runs: using: 'node12' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 1882550..1eeb235 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,171 +1,10 @@ -module.exports = -/******/ (function(modules, runtime) { // webpackBootstrap +/******/ (() => { // webpackBootstrap /******/ "use strict"; -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ __webpack_require__.ab = __dirname + "/"; -/******/ -/******/ // the startup function -/******/ function startup() { -/******/ // Load entry module and return exports -/******/ return __webpack_require__(104); -/******/ }; -/******/ -/******/ // run startup -/******/ return startup(); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ 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: -/***/ (function(module) { - -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 - -/***/ }), - -/***/ 104: -/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) { - -"use strict"; - - -const core = __webpack_require__(470) -const { promises: fs } = __webpack_require__(747) - -const main = async () => { - const path = core.getInput('path') - const content = await fs.readFile(path, 'utf8') - - const regexList = [ - /(?<=\*\*Team Name:\*\* ).*/g, - /(?<=^# ).*/g, - /(?<=\*\*Contact Name:\*\* ).*/g, - /(?<=\*\*Contact Email:\*\* ).*/g, - /(?<=\*\*Total Costs:\*\* ).*(?= BTC)/gi, - /(?<=\*\*Total Costs:\*\* ).*(?=( DAI)|( USD))/gi, - /(?<=\*\*Registered Address:\*\* ).*/g, - /(?<=\*\*((Level)|(\[Level\]\(https:\/\/github.com\/w3f\/Grants-Program\/tree\/master#level_slider-levels\))):\*\*.*)\d+/g - ] - - const outputs = [ - 'team_name', - 'project_name', - 'contact_name', - 'contact_email', - 'total_cost_btc', - 'total_cost_dai', - 'address', - 'level' - ] - - regexList.map(function (reg, i) { - try { - const result = content.match(reg)[0] - core.setOutput(outputs[i], result) - } catch { - core.warning(`Match not found for: ${outputs[i]}`) - } - }) -} - -main().catch(err => core.setFailed(err.message)) - - -/***/ }), +/******/ var __webpack_modules__ = ({ -/***/ 431: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/***/ 351: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { -"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; @@ -174,9 +13,9 @@ var __importStar = (this && this.__importStar) || function (mod) { result["default"] = mod; return result; }; -Object.defineProperty(exports, "__esModule", { value: true }); -const os = __importStar(__webpack_require__(87)); -const utils_1 = __webpack_require__(82); +Object.defineProperty(exports, "__esModule", ({ value: true })); +const os = __importStar(__nccwpck_require__(37)); +const utils_1 = __nccwpck_require__(278); /** * Commands * @@ -248,10 +87,9 @@ function escapeProperty(s) { /***/ }), -/***/ 470: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/***/ 186: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { -"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } @@ -269,12 +107,12 @@ var __importStar = (this && this.__importStar) || function (mod) { result["default"] = mod; return result; }; -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)); +Object.defineProperty(exports, "__esModule", ({ value: true })); +const command_1 = __nccwpck_require__(351); +const file_command_1 = __nccwpck_require__(717); +const utils_1 = __nccwpck_require__(278); +const os = __importStar(__nccwpck_require__(37)); +const path = __importStar(__nccwpck_require__(17)); /** * The code to exit an action */ @@ -493,18 +331,193 @@ exports.getState = getState; /***/ }), -/***/ 622: -/***/ (function(module) { +/***/ 717: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { -module.exports = require("path"); + +// 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(__nccwpck_require__(147)); +const os = __importStar(__nccwpck_require__(37)); +const utils_1 = __nccwpck_require__(278); +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 + +/***/ }), + +/***/ 278: +/***/ ((__unused_webpack_module, exports) => { + + +// 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 /***/ }), -/***/ 747: -/***/ (function(module) { +/***/ 147: +/***/ ((module) => { module.exports = require("fs"); +/***/ }), + +/***/ 37: +/***/ ((module) => { + +module.exports = require("os"); + +/***/ }), + +/***/ 17: +/***/ ((module) => { + +module.exports = require("path"); + /***/ }) -/******/ }); \ No newline at end of file +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __nccwpck_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ var threw = true; +/******/ try { +/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__); +/******/ threw = false; +/******/ } finally { +/******/ if(threw) delete __webpack_module_cache__[moduleId]; +/******/ } +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat */ +/******/ +/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { + + +const core = __nccwpck_require__(186) +const { promises: fs } = __nccwpck_require__(147) + +const main = async () => { + const path = core.getInput('path') + const content = await fs.readFile(path, 'utf8') + + const regexList = [ + { + name: 'team_name', + regex: /(?<=\*\*Team Name:\*\* ).*/g, + }, + { + name: 'project_name', + regex: /(?<=^# ).*/g, + }, + { + name: 'contact_name', + regex: /(?<=\*\*Contact Name:\*\* ).*/g, + }, + { + name: 'contact_email', + regex: /(?<=\*\*Contact Email:\*\* ).*/g, + }, + { + name: 'total_cost_dai', + regex: /(?<=\*\*Total Costs:\*\* ).*(?=( DAI)|( USD))/gi, + }, + { + name: 'address', + regex: /(?<=\*\*Registered Address:\*\* ).*/g, + }, + { + name: 'level', + regex: /(?<=\*\*((Level)|(\[Level\]\(https:\/\/github.com\/w3f\/Grants-Program\/tree\/master#level_slider-levels\))):\*\*.*)\d+/g, + }, + { + name: 'total_milestones', + regex: /(?<=^(.*)?\# (.* )?Milestone ).*/gm, + }, + ] + + regexList.map(function (reg) { + try { + switch (reg.name) { + case 'total_milestones': + const milestones = content.match(reg.regex) + core.setOutput(reg.name, milestones.length) + break + default: + const result = content.match(reg.regex)[0] + core.setOutput(reg.name, result) + } + } catch { + core.warning(`Match not found for: ${reg.name}`) + } + }) +} + +main().catch(err => core.setFailed(err.message)) + +})(); + +module.exports = __webpack_exports__; +/******/ })() +; \ No newline at end of file diff --git a/index.js b/index.js index 580d867..1c41328 100644 --- a/index.js +++ b/index.js @@ -8,33 +8,53 @@ const main = async () => { const content = await fs.readFile(path, 'utf8') const regexList = [ - /(?<=\*\*Team Name:\*\* ).*/g, - /(?<=^# ).*/g, - /(?<=\*\*Contact Name:\*\* ).*/g, - /(?<=\*\*Contact Email:\*\* ).*/g, - /(?<=\*\*Total Costs:\*\* ).*(?= BTC)/gi, - /(?<=\*\*Total Costs:\*\* ).*(?=( DAI)|( USD))/gi, - /(?<=\*\*Registered Address:\*\* ).*/g, - /(?<=\*\*((Level)|(\[Level\]\(https:\/\/github.com\/w3f\/Grants-Program\/tree\/master#level_slider-levels\))):\*\*.*)\d+/g + { + name: 'team_name', + regex: /(?<=\*\*Team Name:\*\* ).*/g, + }, + { + name: 'project_name', + regex: /(?<=^# ).*/g, + }, + { + name: 'contact_name', + regex: /(?<=\*\*Contact Name:\*\* ).*/g, + }, + { + name: 'contact_email', + regex: /(?<=\*\*Contact Email:\*\* ).*/g, + }, + { + name: 'total_cost_dai', + regex: /(?<=\*\*Total Costs:\*\* ).*(?=( DAI)|( USD))/gi, + }, + { + name: 'address', + regex: /(?<=\*\*Registered Address:\*\* ).*/g, + }, + { + name: 'level', + regex: /(?<=\*\*((Level)|(\[Level\]\(https:\/\/github.com\/w3f\/Grants-Program\/tree\/master#level_slider-levels\))):\*\*.*)\d+/g, + }, + { + name: 'total_milestones', + regex: /(?<=^(.*)?\# (.* )?Milestone ).*/gm, + }, ] - const outputs = [ - 'team_name', - 'project_name', - 'contact_name', - 'contact_email', - 'total_cost_btc', - 'total_cost_dai', - 'address', - 'level' - ] - - regexList.map(function (reg, i) { + regexList.map(function (reg) { try { - const result = content.match(reg)[0] - core.setOutput(outputs[i], result) + switch (reg.name) { + case 'total_milestones': + const milestones = content.match(reg.regex) + core.setOutput(reg.name, milestones.length) + break + default: + const result = content.match(reg.regex)[0] + core.setOutput(reg.name, result) + } } catch { - core.warning(`Match not found for: ${outputs[i]}`) + core.warning(`Match not found for: ${reg.name}`) } }) } diff --git a/package-lock.json b/package-lock.json index 1e7cd57..2f2cffe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@actions/core": "^1.2.6" }, "devDependencies": { - "@zeit/ncc": "^0.20.5", + "@vercel/ncc": "^0.36.0", "np": "^5.1.3", "prettier-standard": "^15.0.1", "standard": "^14.3.1" @@ -232,11 +232,10 @@ "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "dev": true }, - "node_modules/@zeit/ncc": { - "version": "0.20.5", - "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.20.5.tgz", - "integrity": "sha512-XU6uzwvv95DqxciQx+aOLhbyBx/13ky+RK1y88Age9Du3BlA4mMPCy13BGjayOrrumOzlq1XV3SD/BWiZENXlw==", - "deprecated": "@zeit/ncc is no longer maintained. Please use @vercel/ncc instead.", + "node_modules/@vercel/ncc": { + "version": "0.36.0", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.0.tgz", + "integrity": "sha512-/ZTUJ/ZkRt694k7KJNimgmHjtQcRuVwsST2Z6XfYveQIuBbHR+EqkTc1jfgPkQmMyk/vtpxo3nVxe8CNuau86A==", "dev": true, "bin": { "ncc": "dist/ncc/cli.js" @@ -7284,10 +7283,10 @@ "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "dev": true }, - "@zeit/ncc": { - "version": "0.20.5", - "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.20.5.tgz", - "integrity": "sha512-XU6uzwvv95DqxciQx+aOLhbyBx/13ky+RK1y88Age9Du3BlA4mMPCy13BGjayOrrumOzlq1XV3SD/BWiZENXlw==", + "@vercel/ncc": { + "version": "0.36.0", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.0.tgz", + "integrity": "sha512-/ZTUJ/ZkRt694k7KJNimgmHjtQcRuVwsST2Z6XfYveQIuBbHR+EqkTc1jfgPkQmMyk/vtpxo3nVxe8CNuau86A==", "dev": true }, "acorn": { diff --git a/package.json b/package.json index 37cd144..a56a11a 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@actions/core": "^1.2.6" }, "devDependencies": { - "@zeit/ncc": "^0.20.5", + "@vercel/ncc": "^0.36.0", "np": "^5.1.3", "prettier-standard": "^15.0.1", "standard": "^14.3.1"