update node to v20

pull/132/head
Ben Miner 1 year ago
parent aeb0d936a7
commit 8ebe3fc9ae

@ -30,5 +30,5 @@ inputs:
required: false required: false
default: "2" default: "2"
runs: runs:
using: "node16" using: "node20"
main: "index.js" main: "index.js"

@ -21112,8 +21112,8 @@ var __publicField2 = (obj, key, value) => {
return value; return value;
}; };
var Shell = class { var Shell = class {
process;
constructor(env_passthrough = ["PATH"]) { constructor(env_passthrough = ["PATH"]) {
__publicField(this, "process");
const env2 = { PS1: "" }; const env2 = { PS1: "" };
env_passthrough.forEach((key) => { env_passthrough.forEach((key) => {
env2[key] = process.env[key]; env2[key] = process.env[key];
@ -21150,6 +21150,21 @@ var trimFinalNewline = (input) => {
return input; return input;
}; };
var Command = class { var Command = class {
shell;
cmd;
cwd;
interactive;
exec;
runningState;
pipe_logs;
exit_expected;
retCode;
promiseResolve;
promiseReject;
promise;
timer;
stdout;
stderr;
constructor({ constructor({
cwd, cwd,
shell, shell,
@ -21158,73 +21173,74 @@ var Command = class {
pipe_logs = false, pipe_logs = false,
exit_expected = false exit_expected = false
}) { }) {
__publicField(this, "shell"); this.shell = shell;
__publicField(this, "cmd"); this.cmd = cmd;
__publicField(this, "cwd"); this.cwd = cwd;
__publicField(this, "interactive"); this.interactive = interactive;
__publicField(this, "exec"); this.exit_expected = exit_expected;
__publicField(this, "runningState"); this.exec = `cd "${cwd}" &&
__publicField(this, "pipe_logs"); ${this.cmd};echo __END_OF_COMMAND_[$?]__
__publicField(this, "exit_expected"); `;
__publicField(this, "retCode"); this.shell.process.on("exit", this.finish);
__publicField(this, "promiseResolve"); this.shell.getStdout().on("data", this.handleStdoutData);
__publicField(this, "promiseReject"); this.shell.getStderr().on("data", this.handleStderrData);
__publicField(this, "promise"); this.runningState = 0;
__publicField(this, "timer"); this.pipe_logs = pipe_logs;
__publicField(this, "stdout"); this.stdout = "";
__publicField(this, "stderr"); this.stderr = "";
__publicField(this, "handleStdoutData", (data) => { }
const lines = trimFinalNewline(data).split(/\r?\n/); handleStdoutData = (data) => {
for (let i = 0; i < lines.length; i++) { const lines = trimFinalNewline(data).split(/\r?\n/);
const line = lines[i]; for (let i = 0; i < lines.length; i++) {
const match = line.match(/__END_OF_COMMAND_\[(\d+)\]__/); const line = lines[i];
if (match) { const match = line.match(/__END_OF_COMMAND_\[(\d+)\]__/);
this.retCode = parseInt(match[1]); if (match) {
setImmediate(this.finish); this.retCode = parseInt(match[1]);
return; setImmediate(this.finish);
} else { return;
if (this.pipe_logs) } else {
process.stdout.write(line + "\n"); if (this.pipe_logs)
this.stdout += line + "\n"; process.stdout.write(line + "\n");
} this.stdout += line + "\n";
if (this.interactive) {
this.interactive(line, this.handleStdinData);
}
} }
}); if (this.interactive) {
__publicField(this, "handleStderrData", (data) => { this.interactive(line, this.handleStdinData);
if (this.pipe_logs) }
process.stderr.write(data); }
this.stderr += data; };
}); handleStderrData = (data) => {
__publicField(this, "handleStdinData", (data) => { if (this.pipe_logs)
this.shell.getStdin().write(`${data} 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", () => { this.promiseResolve = promiseResolve;
let promiseResolve, promiseReject; this.promiseReject = promiseReject;
const promise = new Promise((resolve, reject) => { this.promise = promise;
promiseResolve = resolve; this.runningState = 1;
promiseReject = reject; this.shell.getStdin().write(this.exec);
}); this.timer = setTimeout(() => {
this.promiseResolve = promiseResolve; if (this.runningState !== 2) {
this.promiseReject = promiseReject; const obj = {
this.promise = promise; retCode: -1,
this.runningState = 1; cmd: this.cmd,
this.shell.getStdin().write(this.exec); stdout: this.stdout,
this.timer = setTimeout(() => { stderr: this.stderr
if (this.runningState !== 2) { };
const obj = { this.promiseReject(obj);
retCode: -1, }
cmd: this.cmd, }, 864e5);
stdout: this.stdout, return promise.then(() => this, (e) => {
stderr: this.stderr this.log(`
};
this.promiseReject(obj);
}
}, 864e5);
return promise.then(() => this, (e) => {
this.log(`
SHELLAC COMMAND FAILED! SHELLAC COMMAND FAILED!
Executing: ${this.cmd} in ${this.cwd} Executing: ${this.cmd} in ${this.cwd}
@ -21232,65 +21248,49 @@ Executing: ${this.cmd} in ${this.cwd}
STDOUT: STDOUT:
`); `);
this.log(`${this.stdout} this.log(`${this.stdout}
`); `);
this.log(`STDERR: this.log(`STDERR:
${this.stderr} ${this.stderr}
`); `);
this.shell.exit(); this.shell.exit();
throw e; throw e;
});
}); });
__publicField(this, "finish", () => { };
this.runningState = 2; finish = () => {
clearTimeout(this.timer); this.runningState = 2;
this.shell.getStdout().removeListener("data", this.handleStdoutData); clearTimeout(this.timer);
this.shell.getStderr().removeListener("data", this.handleStderrData); this.shell.getStdout().removeListener("data", this.handleStdoutData);
const obj = { this.shell.getStderr().removeListener("data", this.handleStderrData);
retCode: this.retCode, const obj = {
cmd: this.cmd, retCode: this.retCode,
stdout: this.stdout, cmd: this.cmd,
stderr: this.stderr stdout: this.stdout,
}; stderr: this.stderr
const matching_exit_code = this.retCode === this.exit_expected; };
if (!matching_exit_code) { const matching_exit_code = this.retCode === this.exit_expected;
if (this.exit_expected === true) { if (!matching_exit_code) {
if (this.retCode === 0) { if (this.exit_expected === true) {
this.log("NO EXIT WHEN EXPECTED"); if (this.retCode === 0) {
return this.promiseReject(obj); this.log("NO EXIT WHEN EXPECTED");
} return this.promiseReject(obj);
} else if (this.exit_expected === false) { }
if (this.retCode !== 0) { } else if (this.exit_expected === false) {
this.log("EXIT WHEN NOT EXPECTED"); if (this.retCode !== 0) {
return this.promiseReject(obj); this.log("EXIT WHEN NOT EXPECTED");
}
} else {
this.log(`EXIT CODE DIDN'T MATCH`);
return this.promiseReject(obj); return this.promiseReject(obj);
} }
} else {
this.log(`EXIT CODE DIDN'T MATCH`);
return this.promiseReject(obj);
} }
return this.promiseResolve(obj); }
}); return this.promiseResolve(obj);
__publicField(this, "log", Shell.logger); };
this.shell = shell; log = Shell.logger;
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 = "";
}
}; };
async function IfStatement(chunk, context2) { async function IfStatement(chunk, context2) {
const { interps, last_cmd } = context2; const { interps, last_cmd } = context2;
@ -22060,7 +22060,7 @@ var src_default = shellac;
// src/index.ts // src/index.ts
var import_undici = __toESM(require_undici()); var import_undici = __toESM(require_undici());
var import_process = require("process"); var import_process = require("process");
var import_node_path = __toESM(require("path")); var import_node_path = __toESM(require("node:path"));
try { try {
const apiToken = (0, import_core.getInput)("apiToken", { required: true }); const apiToken = (0, import_core.getInput)("apiToken", { required: true });
const accountId = (0, import_core.getInput)("accountId", { required: true }); const accountId = (0, import_core.getInput)("accountId", { required: true });

36
package-lock.json generated

@ -16,7 +16,7 @@
"undici": "^5.11.0" "undici": "^5.11.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^18.11.3", "@types/node": "^20.14.8",
"esbuild": "^0.15.12", "esbuild": "^0.15.12",
"husky": "^8.0.1", "husky": "^8.0.1",
"prettier": "^2.8.1", "prettier": "^2.8.1",
@ -214,10 +214,13 @@
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.11.3", "version": "20.14.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.8.tgz",
"integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A==", "integrity": "sha512-DO+2/jZinXfROG7j7WKFn/3C6nFwxy2lLpgLjEXJz+0XKphZlTLJ14mo8Vfg8X5BWN6XjyESXq+LcYdT7tR3bA==",
"dev": true "dev": true,
"dependencies": {
"undici-types": "~5.26.4"
}
}, },
"node_modules/before-after-hook": { "node_modules/before-after-hook": {
"version": "2.2.3", "version": "2.2.3",
@ -773,6 +776,12 @@
"node": ">=12.18" "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": { "node_modules/universal-user-agent": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
@ -969,10 +978,13 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "18.11.3", "version": "20.14.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.3.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.8.tgz",
"integrity": "sha512-fNjDQzzOsZeKZu5NATgXUPsaFaTxeRgFXoosrHivTl8RGeV733OLawXsGfEk9a8/tySyZUyiZ6E8LcjPFZ2y1A==", "integrity": "sha512-DO+2/jZinXfROG7j7WKFn/3C6nFwxy2lLpgLjEXJz+0XKphZlTLJ14mo8Vfg8X5BWN6XjyESXq+LcYdT7tR3bA==",
"dev": true "dev": true,
"requires": {
"undici-types": "~5.26.4"
}
}, },
"before-after-hook": { "before-after-hook": {
"version": "2.2.3", "version": "2.2.3",
@ -1279,6 +1291,12 @@
"busboy": "^1.6.0" "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": { "universal-user-agent": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",

@ -1,10 +1,10 @@
{ {
"name": "pages-action", "name": "pages-action",
"version": "1.5.0", "version": "1.6.0",
"description": "Publish to Cloudflare Pages", "description": "Publish to Cloudflare Pages",
"main": "index.js", "main": "index.js",
"scripts": { "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", "prepare": "husky install",
"prettify": "prettier . --write --ignore-unknown" "prettify": "prettier . --write --ignore-unknown"
}, },
@ -29,7 +29,7 @@
"undici": "^5.11.0" "undici": "^5.11.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^18.11.3", "@types/node": "^20.14.8",
"esbuild": "^0.15.12", "esbuild": "^0.15.12",
"husky": "^8.0.1", "husky": "^8.0.1",
"prettier": "^2.8.1", "prettier": "^2.8.1",

Loading…
Cancel
Save