From 8ebe3fc9ae5e0754e5764cc620e308b858faf95e Mon Sep 17 00:00:00 2001 From: Ben Miner Date: Tue, 25 Jun 2024 12:36:45 -0500 Subject: [PATCH] update node to v20 --- action.yml | 2 +- index.js | 230 +++++++++++++++++++++++----------------------- package-lock.json | 36 ++++++-- package.json | 6 +- 4 files changed, 146 insertions(+), 128 deletions(-) diff --git a/action.yml b/action.yml index 61e3f56..73ef18c 100644 --- a/action.yml +++ b/action.yml @@ -30,5 +30,5 @@ inputs: required: false default: "2" runs: - using: "node16" + using: "node20" main: "index.js" diff --git a/index.js b/index.js index 7df67c8..beae784 100644 --- a/index.js +++ b/index.js @@ -21112,8 +21112,8 @@ var __publicField2 = (obj, key, value) => { return value; }; var Shell = class { + process; constructor(env_passthrough = ["PATH"]) { - __publicField(this, "process"); const env2 = { PS1: "" }; env_passthrough.forEach((key) => { env2[key] = process.env[key]; @@ -21150,6 +21150,21 @@ var trimFinalNewline = (input) => { return input; }; var Command = class { + shell; + cmd; + cwd; + interactive; + exec; + runningState; + pipe_logs; + exit_expected; + retCode; + promiseResolve; + promiseReject; + promise; + timer; + stdout; + stderr; constructor({ cwd, shell, @@ -21158,73 +21173,74 @@ var Command = class { pipe_logs = false, exit_expected = false }) { - __publicField(this, "shell"); - __publicField(this, "cmd"); - __publicField(this, "cwd"); - __publicField(this, "interactive"); - __publicField(this, "exec"); - __publicField(this, "runningState"); - __publicField(this, "pipe_logs"); - __publicField(this, "exit_expected"); - __publicField(this, "retCode"); - __publicField(this, "promiseResolve"); - __publicField(this, "promiseReject"); - __publicField(this, "promise"); - __publicField(this, "timer"); - __publicField(this, "stdout"); - __publicField(this, "stderr"); - __publicField(this, "handleStdoutData", (data) => { - const lines = trimFinalNewline(data).split(/\r?\n/); - for (let i = 0; i < lines.length; i++) { - const line = lines[i]; - const match = line.match(/__END_OF_COMMAND_\[(\d+)\]__/); - if (match) { - this.retCode = parseInt(match[1]); - setImmediate(this.finish); - return; - } else { - if (this.pipe_logs) - process.stdout.write(line + "\n"); - this.stdout += line + "\n"; - } - if (this.interactive) { - this.interactive(line, this.handleStdinData); - } + this.shell = shell; + this.cmd = cmd; + this.cwd = cwd; + this.interactive = interactive; + this.exit_expected = exit_expected; + this.exec = `cd "${cwd}" && +${this.cmd};echo __END_OF_COMMAND_[$?]__ +`; + this.shell.process.on("exit", this.finish); + this.shell.getStdout().on("data", this.handleStdoutData); + this.shell.getStderr().on("data", this.handleStderrData); + this.runningState = 0; + this.pipe_logs = pipe_logs; + this.stdout = ""; + this.stderr = ""; + } + handleStdoutData = (data) => { + const lines = trimFinalNewline(data).split(/\r?\n/); + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; + const match = line.match(/__END_OF_COMMAND_\[(\d+)\]__/); + if (match) { + this.retCode = parseInt(match[1]); + setImmediate(this.finish); + return; + } else { + if (this.pipe_logs) + process.stdout.write(line + "\n"); + this.stdout += line + "\n"; } - }); - __publicField(this, "handleStderrData", (data) => { - if (this.pipe_logs) - process.stderr.write(data); - this.stderr += data; - }); - __publicField(this, "handleStdinData", (data) => { - this.shell.getStdin().write(`${data} + if (this.interactive) { + this.interactive(line, this.handleStdinData); + } + } + }; + handleStderrData = (data) => { + if (this.pipe_logs) + process.stderr.write(data); + this.stderr += data; + }; + handleStdinData = (data) => { + this.shell.getStdin().write(`${data} `); + }; + run = () => { + let promiseResolve, promiseReject; + const promise = new Promise((resolve, reject) => { + promiseResolve = resolve; + promiseReject = reject; }); - __publicField(this, "run", () => { - let promiseResolve, promiseReject; - const promise = new Promise((resolve, reject) => { - promiseResolve = resolve; - promiseReject = reject; - }); - this.promiseResolve = promiseResolve; - this.promiseReject = promiseReject; - this.promise = promise; - this.runningState = 1; - this.shell.getStdin().write(this.exec); - this.timer = setTimeout(() => { - if (this.runningState !== 2) { - const obj = { - retCode: -1, - cmd: this.cmd, - stdout: this.stdout, - stderr: this.stderr - }; - this.promiseReject(obj); - } - }, 864e5); - return promise.then(() => this, (e) => { - this.log(` + this.promiseResolve = promiseResolve; + this.promiseReject = promiseReject; + this.promise = promise; + this.runningState = 1; + this.shell.getStdin().write(this.exec); + this.timer = setTimeout(() => { + if (this.runningState !== 2) { + const obj = { + retCode: -1, + cmd: this.cmd, + stdout: this.stdout, + stderr: this.stderr + }; + this.promiseReject(obj); + } + }, 864e5); + return promise.then(() => this, (e) => { + this.log(` SHELLAC COMMAND FAILED! Executing: ${this.cmd} in ${this.cwd} @@ -21232,65 +21248,49 @@ Executing: ${this.cmd} in ${this.cwd} STDOUT: `); - this.log(`${this.stdout} + this.log(`${this.stdout} `); - this.log(`STDERR: + this.log(`STDERR: ${this.stderr} `); - this.shell.exit(); - throw e; - }); + this.shell.exit(); + throw e; }); - __publicField(this, "finish", () => { - this.runningState = 2; - clearTimeout(this.timer); - this.shell.getStdout().removeListener("data", this.handleStdoutData); - this.shell.getStderr().removeListener("data", this.handleStderrData); - const obj = { - retCode: this.retCode, - cmd: this.cmd, - stdout: this.stdout, - stderr: this.stderr - }; - const matching_exit_code = this.retCode === this.exit_expected; - if (!matching_exit_code) { - if (this.exit_expected === true) { - if (this.retCode === 0) { - this.log("NO EXIT WHEN EXPECTED"); - return this.promiseReject(obj); - } - } else if (this.exit_expected === false) { - if (this.retCode !== 0) { - this.log("EXIT WHEN NOT EXPECTED"); - return this.promiseReject(obj); - } - } else { - this.log(`EXIT CODE DIDN'T MATCH`); + }; + finish = () => { + this.runningState = 2; + clearTimeout(this.timer); + this.shell.getStdout().removeListener("data", this.handleStdoutData); + this.shell.getStderr().removeListener("data", this.handleStderrData); + const obj = { + retCode: this.retCode, + cmd: this.cmd, + stdout: this.stdout, + stderr: this.stderr + }; + const matching_exit_code = this.retCode === this.exit_expected; + if (!matching_exit_code) { + if (this.exit_expected === true) { + if (this.retCode === 0) { + this.log("NO EXIT WHEN EXPECTED"); + return this.promiseReject(obj); + } + } else if (this.exit_expected === false) { + if (this.retCode !== 0) { + this.log("EXIT WHEN NOT EXPECTED"); return this.promiseReject(obj); } + } else { + this.log(`EXIT CODE DIDN'T MATCH`); + return this.promiseReject(obj); } - return this.promiseResolve(obj); - }); - __publicField(this, "log", Shell.logger); - this.shell = shell; - this.cmd = cmd; - this.cwd = cwd; - this.interactive = interactive; - this.exit_expected = exit_expected; - this.exec = `cd "${cwd}" && -${this.cmd};echo __END_OF_COMMAND_[$?]__ -`; - this.shell.process.on("exit", this.finish); - this.shell.getStdout().on("data", this.handleStdoutData); - this.shell.getStderr().on("data", this.handleStderrData); - this.runningState = 0; - this.pipe_logs = pipe_logs; - this.stdout = ""; - this.stderr = ""; - } + } + return this.promiseResolve(obj); + }; + log = Shell.logger; }; async function IfStatement(chunk, context2) { const { interps, last_cmd } = context2; @@ -22060,7 +22060,7 @@ var src_default = shellac; // src/index.ts var import_undici = __toESM(require_undici()); var import_process = require("process"); -var import_node_path = __toESM(require("path")); +var import_node_path = __toESM(require("node:path")); try { const apiToken = (0, import_core.getInput)("apiToken", { required: true }); const accountId = (0, import_core.getInput)("accountId", { required: true }); diff --git a/package-lock.json b/package-lock.json index 92bab55..f8327a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "undici": "^5.11.0" }, "devDependencies": { - "@types/node": "^18.11.3", + "@types/node": "^20.14.8", "esbuild": "^0.15.12", "husky": "^8.0.1", "prettier": "^2.8.1", @@ -214,10 +214,13 @@ } }, "node_modules/@types/node": { - "version": "18.11.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz", - "integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A==", - "dev": true + "version": "20.14.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.8.tgz", + "integrity": "sha512-DO+2/jZinXfROG7j7WKFn/3C6nFwxy2lLpgLjEXJz+0XKphZlTLJ14mo8Vfg8X5BWN6XjyESXq+LcYdT7tR3bA==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/before-after-hook": { "version": "2.2.3", @@ -773,6 +776,12 @@ "node": ">=12.18" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "node_modules/universal-user-agent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", @@ -969,10 +978,13 @@ } }, "@types/node": { - "version": "18.11.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz", - "integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A==", - "dev": true + "version": "20.14.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.8.tgz", + "integrity": "sha512-DO+2/jZinXfROG7j7WKFn/3C6nFwxy2lLpgLjEXJz+0XKphZlTLJ14mo8Vfg8X5BWN6XjyESXq+LcYdT7tR3bA==", + "dev": true, + "requires": { + "undici-types": "~5.26.4" + } }, "before-after-hook": { "version": "2.2.3", @@ -1279,6 +1291,12 @@ "busboy": "^1.6.0" } }, + "undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "universal-user-agent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", diff --git a/package.json b/package.json index 6c86547..1e1153d 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "pages-action", - "version": "1.5.0", + "version": "1.6.0", "description": "Publish to Cloudflare Pages", "main": "index.js", "scripts": { - "build": "npx esbuild src/index.ts --bundle --platform=node --target=es2021 --outfile=index.js", + "build": "npx esbuild src/index.ts --bundle --platform=node --target=node20 --outfile=index.js", "prepare": "husky install", "prettify": "prettier . --write --ignore-unknown" }, @@ -29,7 +29,7 @@ "undici": "^5.11.0" }, "devDependencies": { - "@types/node": "^18.11.3", + "@types/node": "^20.14.8", "esbuild": "^0.15.12", "husky": "^8.0.1", "prettier": "^2.8.1",