From d57c009faa022ad9a38dc1ef3720b0571ddc4f7f Mon Sep 17 00:00:00 2001 From: Gabriel Rufino Date: Mon, 24 Feb 2025 09:26:24 -0300 Subject: [PATCH 1/3] chore: fix packmages --- package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 798f95b..74ae1bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -113,12 +113,12 @@ } }, "node_modules/@octokit/graphql": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.1.0.tgz", - "integrity": "sha512-r+oZUH7aMFui1ypZnAvZmn0KSqAUgE1/tUXIWaqUCa1758ts/Jio84GZuzsvUkme98kv0WFY8//n0J1Z+vsIsQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.1.1.tgz", + "integrity": "sha512-3mkDltSfcDUoa176nlGoA32RGjeWjl3K7F/BwHwRMJUW/IteSa4bnSV8p2ThNkcIcZU2umkZWxwETSSCJf2Q7g==", "license": "MIT", "dependencies": { - "@octokit/request": "^8.3.0", + "@octokit/request": "^8.4.1", "@octokit/types": "^13.0.0", "universal-user-agent": "^6.0.0" }, From 28445fd0d7606f02bd508b2fddda7c49bc4f3289 Mon Sep 17 00:00:00 2001 From: Gabriel Rufino Date: Mon, 24 Feb 2025 09:30:47 -0300 Subject: [PATCH 2/3] refactor: using typescript --- dist/index.js | 83 +++++++++++++++++++++++++++++--------- package-lock.json | 17 +++++++- package.json | 5 ++- src/{index.js => index.ts} | 4 +- tsconfig.json | 6 +++ 5 files changed, 92 insertions(+), 23 deletions(-) rename src/{index.js => index.ts} (81%) create mode 100644 tsconfig.json diff --git a/dist/index.js b/dist/index.js index b99f488..137232e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4110,18 +4110,18 @@ var __copyProps = (to, from, except, desc) => { var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // pkg/dist-src/index.js -var dist_src_exports = {}; -__export(dist_src_exports, { +var index_exports = {}; +__export(index_exports, { GraphqlResponseError: () => GraphqlResponseError, graphql: () => graphql2, withCustomRequest: () => withCustomRequest }); -module.exports = __toCommonJS(dist_src_exports); +module.exports = __toCommonJS(index_exports); var import_request3 = __nccwpck_require__(8636); var import_universal_user_agent = __nccwpck_require__(3843); // pkg/dist-src/version.js -var VERSION = "7.1.0"; +var VERSION = "7.1.1"; // pkg/dist-src/with-defaults.js var import_request2 = __nccwpck_require__(8636); @@ -4169,8 +4169,7 @@ function graphql(request2, query, options) { ); } for (const key in options) { - if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key)) - continue; + if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key)) continue; return Promise.reject( new Error( `[@octokit/graphql] "${key}" cannot be used as variable name` @@ -31821,28 +31820,76 @@ module.exports = parseParams /******/ } /******/ /************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __nccwpck_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __nccwpck_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // 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 }); +/******/ }; +/******/ })(); +/******/ /******/ /* webpack/runtime/compat */ /******/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; /******/ /************************************************************************/ var __webpack_exports__ = {}; -const core = __nccwpck_require__(7484); -const github = __nccwpck_require__(3228); +// This entry need to be wrapped in an IIFE because it need to be in strict mode. +(() => { +"use strict"; +__nccwpck_require__.r(__webpack_exports__); +/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(7484); +/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(_actions_core__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(3228); +/* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(_actions_github__WEBPACK_IMPORTED_MODULE_1__); -try { - const nameToGreet = core.getInput('who-to-greet'); - console.log(`Hello, ${nameToGreet}!`); - const time = (new Date()).toTimeString(); - core.setOutput("time", time); - - const payload = JSON.stringify(github.context.payload, undefined, 2) - console.log(`The event payload: ${payload}`); -} catch (error) { - core.setFailed(error.message); +try { + const nameToGreet = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput('who-to-greet'); + console.log(`Hello, ${nameToGreet}!`); + const time = (new Date()).toTimeString(); + _actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput('time', time); + const payload = JSON.stringify(_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.payload, undefined, 2); + console.log(`The event payload: ${payload}`); +} +catch (error) { + _actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed(error.message); } +})(); + module.exports = __webpack_exports__; /******/ })() ; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 74ae1bb..398c2e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,8 @@ "@actions/github": "^6.0.0" }, "devDependencies": { - "@vercel/ncc": "^0.38.3" + "@vercel/ncc": "^0.38.3", + "typescript": "^5.7.3" } }, "node_modules/@actions/core": { @@ -270,6 +271,20 @@ "node": ">=0.6.11 <=0.7.0 || >=0.7.3" } }, + "node_modules/typescript": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/undici": { "version": "5.28.5", "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz", diff --git a/package.json b/package.json index 307128b..93f3a34 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "dist/index.js", "scripts": { - "build": "ncc build src/index.js -o dist" + "build": "ncc build src/index.ts -o dist" }, "repository": { "type": "git", @@ -21,6 +21,7 @@ "@actions/github": "^6.0.0" }, "devDependencies": { - "@vercel/ncc": "^0.38.3" + "@vercel/ncc": "^0.38.3", + "typescript": "^5.7.3" } } diff --git a/src/index.js b/src/index.ts similarity index 81% rename from src/index.js rename to src/index.ts index ca9c279..444a8a4 100644 --- a/src/index.js +++ b/src/index.ts @@ -1,5 +1,5 @@ -const core = require('@actions/core'); -const github = require('@actions/github'); +import * as core from '@actions/core' +import * as github from '@actions/github' try { const nameToGreet = core.getInput('who-to-greet'); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..57dce1f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "target": "es2015", + "moduleResolution": "node" + } +} From 443110f698f1eb5d0ffba3f1223a02a6fb2631ee Mon Sep 17 00:00:00 2001 From: Gabriel Rufino Date: Mon, 24 Feb 2025 09:32:17 -0300 Subject: [PATCH 3/3] chore: change project name --- README.md | 4 ++-- package-lock.json | 4 ++-- package.json | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e5f962c..ed71da3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# JavaScript Action +# Node Template -Template for JavaScript Actions +Template for Node Actions diff --git a/package-lock.json b/package-lock.json index 398c2e2..0281412 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@actalog/javascript-action", + "name": "@actalog/node-template", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@actalog/javascript-action", + "name": "@actalog/node-template", "version": "1.0.0", "license": "UNLICENSED", "dependencies": { diff --git a/package.json b/package.json index 93f3a34..79dd05b 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@actalog/javascript-action", + "name": "@actalog/node-template", "version": "1.0.0", "description": "", "main": "dist/index.js", @@ -8,14 +8,14 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/actalog/javascript-action-template.git" + "url": "git+https://github.com/actalog/node-template.git" }, "author": "Gabriel Rufino ", "license": "UNLICENSED", "bugs": { - "url": "https://github.com/actalog/javascript-action-template/issues" + "url": "https://github.com/actalog/node-template/issues" }, - "homepage": "https://github.com/actalog/javascript-action-template#readme", + "homepage": "https://github.com/actalog/node-template#readme", "dependencies": { "@actions/core": "^1.11.1", "@actions/github": "^6.0.0"