chore: update @actions/core to v3 and migrate to ESM (#73)
This PR updates the `@actions/core` dependency from v2 to v3.0.0.
### Major Changes:
- **Dependency Update**: Updated `@actions/core` to `v3.0.0` in `package.json`.
- **ESM Migration**: Converted the entire project to ECMAScript Modules (ESM). This was necessary because `@actions/core` v3 is an ESM-only package and does not provide CommonJS exports.
- **`package.json` updates**: Added `"type": "module"` and updated the dependency version.
- **Code Refactor**:
- Converted `index.js` to use `import` and `export`.
- Updated the main execution check to use `import.meta.url` for ESM compatibility.
- Converted `__tests__/index.test.js` to use ESM imports for compatibility with the updated source code.
- **Production Build**: Re-generated the `dist/index.js` bundle using `ncc` to reflect the changes.
- **Node.js Version**: The project continues to use Node 20 (`node20` in `action.yaml`), which is fully compatible with these changes.
### Why these changes are needed:
- `@actions/core` v3 brings latest improvements and fixes from the GitHub Actions toolkit.
- Migrating to ESM is the modern standard for Node.js development and is required to consume ESM-only packages like the new `@actions/core` v3.
Verified with `npm test` and `npm run build`.
Reviewed-on: #73
This commit is contained in:
1 parent
cbbd0e64e8
commit
2be5b2a1bc
6 files changed
+46
-47
No files matched your search
@@ -1,13 +1,13 @@
|
||||
const {
|
||||
import {
|
||||
validateAuthentication,
|
||||
replacePlaceholders,
|
||||
readReplaceAndWriteFiles,
|
||||
readFilesIntoDict,
|
||||
} = require("../index");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const os = require("os");
|
||||
const { glob } = require("glob");
|
||||
} from "../index.js";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import { glob } from "glob";
|
||||
|
||||
describe("validateAuthentication", () => {
|
||||
it("should return null when only token is provided", () => {
|
||||
|
||||
Vendored
+6
-5
@@ -1,16 +1,17 @@
|
||||
(()=>{var __webpack_modules__={6136:(module,__unused_webpack_exports,__nccwpck_require__)=>{const{ScreepsAPI:ScreepsAPI}=__nccwpck_require__(9546);const core=__nccwpck_require__(7484);const fs=__nccwpck_require__(9896);const{glob:glob}=__nccwpck_require__(8941);const path=__nccwpck_require__(6928);function replacePlaceholders(i,A){const u=(new Date).toISOString();return i.replace(/{{gitHash}}/g,process.env.GITHUB_SHA).replace(/{{gitRef}}/g,process.env.GITHUB_REF).replace(/{{deployTime}}/g,u).replace(/{{hostname}}/g,A)}async function readReplaceAndWriteFiles(i,A,u){const p=A?path.join(A,i):i;const g=await glob(p);let E=g.map((i=>fs.promises.readFile(i,"utf8").then((A=>{A=replacePlaceholders(A,u);return fs.promises.writeFile(i,A)}))));await Promise.all(E);return g}async function readFilesIntoDict(i,A){const u=A?path.join(A,i):i;const p=await glob(u);let g={};let E=p.map((i=>fs.promises.readFile(i,"utf8").then((u=>{let p=i;if(A&&i.startsWith(A)){p=p.slice(A.length)}p=path.basename(p,path.extname(p));g[p]=u}))));await Promise.all(E);return g}function validateAuthentication(i,A,u){if(i){if(A||u){return"Token is defined along with username and/or password."}}else{if(!A&&!u){return"Neither token nor password and username are defined."}if(A&&!u){return"Username is defined but no password is provided."}if(!A&&u){return"Password is defined but no username is provided."}}return null}async function postCode(){const i=core.getInput("protocol")||"https";const A=core.getInput("hostname")||"screeps.com";const u=core.getInput("port")||"443";const p=core.getInput("path")||"/";const g=core.getInput("token")||undefined;const E=core.getInput("username")||undefined;const C=core.getInput("password")||undefined;const Q=core.getInput("source-prefix");const B=core.getInput("pattern")||"*.js";const I=core.getInput("branch")||"default";const y=core.getInput("git-replace")||null;if(y){await readReplaceAndWriteFiles(y,Q,A)}const w=await readFilesIntoDict(B,Q);core.info(`Trying to upload the following files to ${I}:`);Object.keys(w).forEach((i=>{core.info(`Key: ${i}`)}));const v={token:g,username:E,password:C,protocol:i,hostname:A,port:u,path:p};core.info("login_arguments:");core.info(JSON.stringify(v,null,2));const x=validateAuthentication(g,E,C);if(x){core.error(x);return}let k=new ScreepsAPI(v);if(g){const i=await k.code.set(I,w);core.info(JSON.stringify(i,null,2));console.log(`Code set successfully to ${I}`)}else{core.info(`Logging in as user ${E}`);await Promise.resolve().then((()=>k.auth(E,C,v))).then((()=>{k.code.set(I,w)})).then((()=>{console.log(`Code set successfully to ${I}`)})).catch((i=>{console.error("Error:",i)}))}}if(require.main===require.cache[eval("__filename")]){postCode()}module.exports={validateAuthentication:validateAuthentication,replacePlaceholders:replacePlaceholders,postCode:postCode,readReplaceAndWriteFiles:readReplaceAndWriteFiles,readFilesIntoDict:readFilesIntoDict}},4914:function(i,A,u){"use strict";var p=this&&this.__createBinding||(Object.create?function(i,A,u,p){if(p===undefined)p=u;var g=Object.getOwnPropertyDescriptor(A,u);if(!g||("get"in g?!A.__esModule:g.writable||g.configurable)){g={enumerable:true,get:function(){return A[u]}}}Object.defineProperty(i,p,g)}:function(i,A,u,p){if(p===undefined)p=u;i[p]=A[u]});var g=this&&this.__setModuleDefault||(Object.create?function(i,A){Object.defineProperty(i,"default",{enumerable:true,value:A})}:function(i,A){i["default"]=A});var E=this&&this.__importStar||function(){var ownKeys=function(i){ownKeys=Object.getOwnPropertyNames||function(i){var A=[];for(var u in i)if(Object.prototype.hasOwnProperty.call(i,u))A[A.length]=u;return A};return ownKeys(i)};return function(i){if(i&&i.__esModule)return i;var A={};if(i!=null)for(var u=ownKeys(i),E=0;E<u.length;E++)if(u[E]!=="default")p(A,i,u[E]);g(A,i);return A}}();Object.defineProperty(A,"__esModule",{value:true});A.issueCommand=issueCommand;A.issue=issue;const C=E(u(857));const Q=u(302);function issueCommand(i,A,u){const p=new Command(i,A,u);process.stdout.write(p.toString()+C.EOL)}function issue(i,A=""){issueCommand(i,{},A)}const B="::";class Command{constructor(i,A,u){if(!i){i="missing.command"}this.command=i;this.properties=A;this.message=u}toString(){let i=B+this.command;if(this.properties&&Object.keys(this.properties).length>0){i+=" ";let A=true;for(const u in this.properties){if(this.properties.hasOwnProperty(u)){const p=this.properties[u];if(p){if(A){A=false}else{i+=","}i+=`${u}=${escapeProperty(p)}`}}}}i+=`${B}${escapeData(this.message)}`;return i}}function escapeData(i){return(0,Q.toCommandValue)(i).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(i){return(0,Q.toCommandValue)(i).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},7484:function(i,A,u){"use strict";var p=this&&this.__createBinding||(Object.create?function(i,A,u,p){if(p===undefined)p=u;var g=Object.getOwnPropertyDescriptor(A,u);if(!g||("get"in g?!A.__esModule:gLine truncated
|
||||
import{createRequire as i}from"module";var A={1324:(i,A,p)=>{i.exports={parallel:p(3857),serial:p(1054),serialOrdered:p(3961)}},4818:i=>{i.exports=abort;function abort(i){Object.keys(i.jobs).forEach(clean.bind(i));i.jobs={}}function clean(i){if(typeof this.jobs[i]=="function"){this.jobs[i]()}}},8452:(i,A,p)=>{var g=p(9200);i.exports=async;function async(i){var A=false;g((function(){A=true}));return function async_callback(p,f){if(A){i(p,f)}else{g((function nextTick_callback(){i(p,f)}))}}}},9200:i=>{i.exports=defer;function defer(i){var A=typeof setImmediate=="function"?setImmediate:typeof process=="object"&&typeof process.nextTick=="function"?process.nextTick:null;if(A){A(i)}else{setTimeout(i,0)}}},4902:(i,A,p)=>{var g=p(8452),f=p(4818);i.exports=iterate;function iterate(i,A,p,g){var E=p["keyedList"]?p["keyedList"][p.index]:p.index;p.jobs[E]=runJob(A,E,i[E],(function(i,A){if(!(E in p.jobs)){return}delete p.jobs[E];if(i){f(p)}else{p.results[E]=A}g(i,p.results)}))}function runJob(i,A,p,f){var E;if(i.length==2){E=i(p,g(f))}else{E=i(p,A,g(f))}return E}},1721:i=>{i.exports=state;function state(i,A){var p=!Array.isArray(i),g={index:0,keyedList:p||A?Object.keys(i):null,jobs:{},results:p?{}:[],size:p?Object.keys(i).length:i.length};if(A){g.keyedList.sort(p?A:function(p,g){return A(i[p],i[g])})}return g}},3351:(i,A,p)=>{var g=p(4818),f=p(8452);i.exports=terminator;function terminator(i){if(!Object.keys(this.jobs).length){return}this.index=this.size;g(this);f(i)(null,this.results)}},3857:(i,A,p)=>{var g=p(4902),f=p(1721),E=p(3351);i.exports=parallel;function parallel(i,A,p){var C=f(i);while(C.index<(C["keyedList"]||i).length){g(i,A,C,(function(i,A){if(i){p(i,A);return}if(Object.keys(C.jobs).length===0){p(null,C.results);return}}));C.index++}return E.bind(C,p)}},1054:(i,A,p)=>{var g=p(3961);i.exports=serial;function serial(i,A,p){return g(i,A,null,p)}},3961:(i,A,p)=>{var g=p(4902),f=p(1721),E=p(3351);i.exports=serialOrdered;i.exports.ascending=ascending;i.exports.descending=descending;function serialOrdered(i,A,p,C){var Q=f(i,p);g(i,A,Q,(function iteratorHandler(p,f){if(p){C(p,f);return}Q.index++;if(Q.index<(Q["keyedList"]||i).length){g(i,A,Q,iteratorHandler);return}C(null,Q.results)}));return E.bind(Q,C)}function ascending(i,A){return i<A?-1:i>A?1:0}function descending(i,A){return-1*ascending(i,A)}},4922:(i,A,p)=>{i.exports=p(3732)},127:(i,A,p)=>{var g=p(9743);var f=p(5529);var E=p(3250);var C=p(4267);var Q=p(7777).T;var B=p(8611);var I=p(5692);var y=p(5665);var b=p(4852);var v=p(7016);var x=p(3106);var k=p(1428).version;var R=p(4491);var S=p(1914);var D=p(9862);var F=p(5896);var T=p(3566);var U=p(2203);var M=/https:?/;var L=F.protocols.map((function(i){return i+":"}));function dispatchBeforeRedirect(i){if(i.beforeRedirects.proxy){i.beforeRedirects.proxy(i)}if(i.beforeRedirects.config){i.beforeRedirects.config(i)}}function setProxy(i,A,p){var g=A;if(!g&&g!==false){var f=Q(p);if(f){g=v.parse(f);g.host=g.hostname}}if(g){if(g.auth){if(g.auth.username||g.auth.password){g.auth=(g.auth.username||"")+":"+(g.auth.password||"")}var E=Buffer.from(g.auth,"utf8").toString("base64");i.headers["Proxy-Authorization"]="Basic "+E}i.headers.host=i.hostname+(i.port?":"+i.port:"");i.hostname=g.host;i.host=g.host;i.port=g.port;i.path=p;if(g.protocol){i.protocol=g.protocol}}i.beforeRedirects.proxy=function beforeRedirect(i){setProxy(i,A,i.href)}}i.exports=function httpAdapter(i){return new Promise((function dispatchHttpRequest(A,p){var Q;function done(){if(i.cancelToken){i.cancelToken.unsubscribe(Q)}if(i.signal){i.signal.removeEventListener("abort",Q)}}var F=function resolve(i){done();A(i)};var _=false;var G=function reject(i){done();_=true;p(i)};var H=i.data;var Y=i.responseType;var P=i.responseEncoding;var J=i.method.toUpperCase();var V=E(i.baseURL,i.url);var j=v.parse(V);var z=j.protocol||L[0];if(z==="data:"){var Z;if(J!=="GET"){return f(F,G,{status:405,statusText:"method not allowed",headers:{},config:i})}try{Z=T(i.url,Y==="blob",{Blob:i.env&&i.env.Blob})}catch(A){throw S.from(A,S.ERR_BAD_REQUEST,i)}if(Y==="text"){Z=Z.toString(P);if(!P||P==="utf8"){H=g.stripBOM(Z)}}else if(Y==="stream"){Z=U.Readable.from(Z)}return f(F,G,{data:Z,status:200,statusText:"OK",headers:{},config:i})}if(L.indexOf(z)===-1){return G(new S("Unsupported protocol "+z,S.ERR_BAD_REQUEST,i))}var K=i.headers;var X={};Object.keys(K).forEach((function storeLowerName(i){X[i.toLowerCase()]=i}));if("user-agent"in X){if(!K[X["user-agent"]]){delete K[X["user-agent"]]}}else{K["User-Agent"]="axios/"+k}if(g.isFormData(H)&&g.isFunction(H.getHeaders)){Object.assign(K,H.getHeaders())}else if(H&&!g.isStream(H)){if(Buffer.isBuffer(H)){}else if(g.isArrayBuffer(H)){H=Buffer.from(new Uint8Array(H))}else if(g.isString(H)){H=Buffer.from(H,"utf-8")}else{return G(new S("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",S.ERR_BAD_REQUEST,i))}if(i.maxBodyLength>-1&&H.length>i.maxBodyLength){return G(new S("Request body larger than maxBodyLength limit",S.ERR_Line truncated
|
||||
/*!
|
||||
* mime-db
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
i.exports=u(1813)},4096:(i,A,u)=>{"use strict";
|
||||
i.exports=p(1813)},4096:(i,A,p)=>{
|
||||
/*!
|
||||
* mime-types
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/var p=u(9829);var g=u(6928).extname;var E=/^\s*([^;\s]*)(?:;|\s|$)/;var C=/^text\//i;A.charset=charset;A.charsets={lookup:charset};A.contentType=contentType;A.extension=extension;A.extensions=Object.create(null);A.lookup=lookup;A.types=Object.create(null);populateMaps(A.extensions,A.types);function charset(i){if(!i||typeof i!=="string"){return false}var A=E.exec(i);var u=A&&p[A[1].toLowerCase()];if(u&&u.charset){return u.charset}if(A&&C.test(A[1])){return"UTF-8"}return false}function contentType(i){if(!i||typeof i!=="string"){return false}var u=i.indexOf("/")===-1?A.lookup(i):i;if(!u){return false}if(u.indexOf("charset")===-1){var p=A.charset(u);if(p)u+="; charset="+p.toLowerCase()}return u}function extension(i){if(!i||typeof i!=="string"){return false}var u=E.exec(i);var p=u&&A.extensions[u[1].toLowerCase()];if(!p||!p.length){return false}return p[0]}function lookup(i){if(!i||typeof i!=="string"){return false}var u=g("x."+i).toLowerCase().substr(1);if(!u){return false}return A.types[u]||false}function populateMaps(i,A){var u=["nginx","apache",undefined,"iana"];Object.keys(p).forEach((function forEachMimeType(g){var E=p[g];var C=E.extensions;if(!C||!C.length){return}i[g]=C;for(var Q=0;Q<C.length;Q++){var B=C[Q];if(A[B]){var I=u.indexOf(p[A[B]].source);var y=u.indexOf(E.source);if(A[B]!=="application/octet-stream"&&(I>y||I===y&&A[B].substr(0,12)==="application/")){continue}}A[B]=g}}))}},744:i=>{var A=1e3;var u=A*60;var p=u*60;var g=p*24;var E=g*7;var C=g*365.25;i.exports=function(i,A){A=A||{};var u=typeof i;if(u==="string"&&i.length>0){return parse(i)}else if(u==="number"&&isFinite(i)){return A.long?fmtLong(i):fmtShort(i)}throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function parse(i){i=String(i);if(i.length>100){return}var Q=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!Q){return}var B=parseFloat(Q[1]);var I=(Q[2]||"ms").toLowerCase();switch(I){case"years":case"year":case"yrs":case"yr":case"y":return B*C;case"weeks":case"week":case"w":return B*E;case"days":case"day":case"d":return B*g;case"hours":case"hour":case"hrs":case"hr":case"h":return B*p;case"minutes":case"minute":case"mins":case"min":case"m":return B*u;case"seconds":case"second":case"secs":case"sec":case"s":return B*A;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return B;default:return undefined}}function fmtShort(i){var E=Math.abs(i);if(E>=g){return Math.round(i/g)+"d"}if(E>=p){return Math.round(i/p)+"h"}if(E>=u){return Math.round(i/u)+"m"}if(E>=A){return Math.round(i/A)+"s"}return i+"ms"}function fmtLong(i){var E=Math.abs(i);if(E>=g){return plural(i,E,g,"day")}if(E>=p){return plural(i,E,p,"hour")}if(E>=u){return plural(i,E,u,"minute")}if(E>=A){return plural(i,E,A,"second")}return i+" ms"}function plural(i,A,u,p){var g=A>=u*1.5;return Math.round(i/u)+" "+p+(g?"s":"")}},7777:(i,A,u)=>{"use strict";var p=u(7016).parse;var g={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};var E=String.prototype.endsWith||function(i){return i.length<=this.length&&this.indexOf(i,this.length-i.length)!==-1};function getProxyForUrl(i){var A=typeof i==="string"?p(i):i||{};var u=A.protocol;var E=A.host;var C=A.port;if(typeof E!=="string"||!E||typeof u!=="string"){return""}u=u.split(":",1)[0];E=E.replace(/:\d*$/,"");C=parseInt(C)||g[u]||0;if(!shouldProxy(E,C)){return""}var Q=getEnv("npm_config_"+u+"_proxy")||getEnv(u+"_proxy")||getEnv("npm_config_proxy")||getEnv("all_proxy");if(Q&&Q.indexOf("://")===-1){Q=u+"://"+Q}return Q}function shouldProxy(i,A){var u=(getEnv("npm_config_no_proxy")||getEnv("no_proxy")).toLowerCase();if(!u){return true}if(u==="*"){return false}return u.split(/[,\s]/).every((function(u){if(!u){return true}var p=u.match(/^(.+):(\d+)$/);var g=p?p[1]:u;var C=p?parseInt(p[2]):0;if(C&&C!==A){return true}if(!/^[.*]/.test(g)){return i!==g}if(g.charAt(0)==="*"){g=g.slice(1)}return!E.call(i,g)}))}function getEnv(i){return process.env[i.toLowerCase()]||process.env[i.toUpperCase()]||""}A.T=getProxyForUrl},9546:(i,A,u)=>{"use strict";Object.defineProperty(A,"__esModule",{value:true});const p=u(1354);const g=u(7016);const E=u(4434);const C=u(2830);const Q=u(3106);const B=u(4922);const I=u(9023);const y=u(9896);const w=u(9557);const v=u(6928);function _interopDefaultLegacy(i){return i&&typeof i==="object"&&"default"in i?i:{default:i}}const x=_interopDefaultLegacy(p);const k=_interopDefaultLegacy(g);const S=_interopDefaultLegacy(C);const D=_interopDefaultLegacy(Q);const N=_interopDefaultLegacy(B);const T=_interopDefaultLegacy(I);const M=_interopDefaultLegacy(y);const U=_interopDefaultLegacy(w);const L=_interopDefaultLegacy(v);const _=S["default"]("screepsapi:socket");const O={reconnect:true,resubscribe:true,keepAlive:true,maxRetries:10,maxRetryDelay:60*1e3};class Socket extends E.EventEmitter{constructor(i){super();this.api=i;this.opts=Object.assign({},O);this.on("error",(()=>{}));this.reset();this.oLine truncated
|
||||
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */;const escape=i=>i.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22");const normalizeLinefeeds=i=>i.replace(/\r?\n|\r/g,"\r\n");const p=[];const g=new Uint8Array([13,10]);y=0;let E=false;for(const[A,C]of i){if(typeof C==="string"){const i=O.encode(u+`; name="${escape(normalizeLinefeeds(A))}"`+`\r\n\r\n${normalizeLinefeeds(C)}\r\n`);p.push(i);y+=i.byteLength}else{const i=O.encode(`${u}; name="${escape(normalizeLinefeeds(A))}"`+(C.name?`; filename="${escape(C.name)}"`:"")+"\r\n"+`Content-Type: ${C.type||"application/octet-stream"}\r\n\r\n`);p.push(i,C,g);if(typeof C.size==="number"){y+=i.byteLength+C.size+g.byteLength}else{E=true}}}const C=O.encode(`--${A}--\r\n`);p.push(C);y+=C.byteLength;if(E){y=null}I=i;B=async function*(){for(const i of p){if(i.stream){yield*i.stream()}else{yield i}}};w=`multipart/form-data; boundary=${A}`}else if(E(i)){I=i;y=i.size;if(i.type){w=i.type}}else if(typeof i[Symbol.asyncIterator]==="function"){if(A){throw new TypeError("keepalive")}if(p.isDisturbed(i)||i.locked){throw new TypeError("Response body object should not be disturbed or locked")}u=i instanceof ReadableStream?i:g(i)}if(typeof I==="string"||p.isBuffer(I)){y=Buffer.byteLength(I)}if(B!=null){let A;u=new ReadableStream({async start(){A=B(i)[Symbol.asyncIterator]()},async pull(i){const{value:p,done:g}=await A.next();if(g){queueMicrotask((()=>{i.close();i.byobRequest?.respond(0)}))}else{if(!N(u)){const A=new Uint8Array(p);if(A.byteLength){i.enqueue(A)}}}return i.desiredSize>0},async cancel(i){await A.return()},type:"bytes"})}const v={stream:u,source:I,length:y};return[v,w]}function safelyExtractBody(i,A=false){if(i instanceof ReadableStream){D(!p.isDisturbed(i),"The body has already been consumed.");D(!i.locked,"The stream is locked.")}return extractBody(i,A)}function cloneBody(i,A){const[u,p]=A.stream.tee();A.stream=u;return{stream:p,length:A.length,source:A.source}}function throwIfAborted(i){if(i.aborted){throw new DOMException("The operation was aborted.","AbortError")}}function bodyMixinMethods(i){const A={blob(){return consumeBody(this,(i=>{let A=bodyMimeType(this);if(A===null){A=""}else if(A){A=U(A)}return new S([i],{type:A})}),i)},arrayBuffer(){return consumeBody(this,(i=>new Uint8Array(i).buffer),i)},text(){return consumeBody(this,w,i)},json(){return consumeBody(this,parseJSONFromBytes,i)},formData(){return consumeBody(this,(i=>{const A=bodyMimeType(this);if(A!==null){switch(A.essence){case"multipart/form-data":{const u=L(i,A);if(u==="failure"){throw new TypeError("Failed to parse body as FormData.")}const p=new v;p[x]=u;return p}case"application/x-www-form-urlencoded":{const A=new URLSearchParams(i.toString());const u=new v;for(const[i,p]of A){u.append(i,p)}return u}}}throw new TypeError('Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".')}),i)},bytes(){return consumeBody(this,(i=>new Uint8Array(i)),i)}};return A}function mixinBody(i){Object.assign(i.prototype,bodyMixinMethods(i))}async function consumeBody(i,A,u){k.brandCheck(i,u);if(bodyUnusable(i)){throw new TypeError("Body is unusable: Body has already been read")}throwIfAborted(i[x]);const p=B();const errorSteps=i=>p.reject(i);const successSteps=i=>{try{p.resolve(A(i))}catch(i){errorSteps(i)}};if(i[x].body==null){successSteps(Buffer.allocUnsafe(0));return p.promise}await I(i[x].body,successSteps,errorSteps);return p.promise}function bodyUnusable(i){const A=i[x].body;return A!=null&&(A.stream.locked||p.isDisturbed(A.stream))}function parseJSONFromBytes(i){return JSON.parse(w(i))}function bodyMimeType(i){const A=i[x].headersList;const u=y(A);if(u==="failure"){return null}return u}i.exports={extractBody:extractBody,safelyExtractBody:safelyExtractBody,cloneBody:cloneBody,mixinBody:mixinBody,streamRegistry:H,hasFinalizationRegistry:G,bodyUnusable:bodyUnusable}},4495:i=>{"use strict";const A=["GET","HEAD","POST"];const u=new Set(A);const p=[101,204,205,304];const g=[301,302,303,307,308];const E=new Set(g);const C=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"];const Q=new Set(C);const B=["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"];const I=new Set(B);const y=["follow","manual","error"];const w=["GET","HEAD","OPTIONS","TRACE"];const v=new Set(w);const x=["navigate","same-origin","no-cors","cors"];const k=["omit","same-origin","include"];const S=["default","no-store","reload","no-caLine truncated
|
||||
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */Q[C-4]=u[0];Q[C-3]=u[1];Q[C-2]=u[2];Q[C-1]=u[3];Q[1]=E;if(E===126){Q.writeUInt16BE(g,2)}else if(E===127){Q[2]=Q[3]=0;Q.writeUIntBE(g,4,6)}Q[1]|=128;for(let i=0;i<g;++i){Q[C+i]=A[i]^u[i&3]}return Q}}i.exports={WebsocketFrameSend:WebsocketFrameSend}},9469:(i,A,u)=>{"use strict";const{createInflateRaw:p,Z_DEFAULT_WINDOWBITS:g}=u(8522);const{isValidClientWindowBits:E}=u(8625);const C=Buffer.from([0,0,255,255]);const Q=Symbol("kBuffer");const B=Symbol("kLength");class PerMessageDeflate{#Z;#h={};constructor(i){this.#h.serverNoContextTakeover=i.has("server_no_context_takeover");this.#h.serverMaxWindowBits=i.get("server_max_window_bits")}decompress(i,A,u){if(!this.#Z){let i=g;if(this.#h.serverMaxWindowBits){if(!E(this.#h.serverMaxWindowBits)){u(new Error("Invalid server_max_window_bits"));return}i=Number.parseInt(this.#h.serverMaxWindowBits)}this.#Z=p({windowBits:i});this.#Z[Q]=[];this.#Z[B]=0;this.#Z.on("data",(i=>{this.#Z[Q].push(i);this.#Z[B]+=i.length}));this.#Z.on("error",(i=>{this.#Z=null;u(i)}))}this.#Z.write(i);if(A){this.#Z.write(C)}this.#Z.flush((()=>{const i=Buffer.concat(this.#Z[Q],this.#Z[B]);this.#Z[Q].length=0;this.#Z[B]=0;u(null,i)}))}}i.exports={PerMessageDeflate:PerMessageDeflate}},1652:(i,A,u)=>{"use strict";const{Writable:p}=u(7075);const g=u(4589);const{parserStates:E,opcodes:C,states:Q,emptyBuffer:B,sentCloseFrameState:I}=u(736);const{kReadyState:y,kSentClose:w,kResponse:v,kReceivedClose:x}=u(1216);const{channels:k}=u(2414);const{isValidStatusCode:S,isValidOpcode:D,failWebsocketConnection:N,websocketMessageReceived:T,utf8Decode:M,isControlFrame:U,isTextBinaryFrame:L,isContinuationFrame:_}=u(8625);const{WebsocketFrameSend:O}=u(3264);const{closeWebSocketConnection:G}=u(6897);const{PerMessageDeflate:H}=u(9469);class ByteParser extends p{#K=[];#X=0;#$=false;#Q=E.INFO;#ee={};#te=[];#se;constructor(i,A){super();this.ws=i;this.#se=A==null?new Map:A;if(this.#se.has("permessage-deflate")){this.#se.set("permessage-deflate",new H(A))}}_write(i,A,u){this.#K.push(i);this.#X+=i.length;this.#$=true;this.run(u)}run(i){while(this.#$){if(this.#Q===E.INFO){if(this.#X<2){return i()}const A=this.consume(2);const u=(A[0]&128)!==0;const p=A[0]&15;const g=(A[1]&128)===128;const Q=!u&&p!==C.CONTINUATION;const B=A[1]&127;const I=A[0]&64;const y=A[0]&32;const w=A[0]&16;if(!D(p)){N(this.ws,"Invalid opcode received");return i()}if(g){N(this.ws,"Frame cannot be masked");return i()}if(I!==0&&!this.#se.has("permessage-deflate")){N(this.ws,"Expected RSV1 to be clear.");return}if(y!==0||w!==0){N(this.ws,"RSV1, RSV2, RSV3 must be clear");return}if(Q&&!L(p)){N(this.ws,"Invalid frame type was fragmented.");return}if(L(p)&&this.#te.length>0){N(this.ws,"Expected continuation frame");return}if(this.#ee.fragmented&&Q){N(this.ws,"Fragmented frame exceeded 125 bytes.");return}if((B>125||Q)&&U(p)){N(this.ws,"Control frame either too large or fragmented");return}if(_(p)&&this.#te.length===0&&!this.#ee.compressed){N(this.ws,"Unexpected continuation frame");return}if(B<=125){this.#ee.payloadLength=B;this.#Q=E.READ_DATA}else if(B===126){this.#Q=E.PAYLOADLENGTH_16}else if(B===127){this.#Q=E.PAYLOADLENGTH_64}if(L(p)){this.#ee.binaryType=p;this.#ee.compressed=I!==0}this.#ee.opcode=p;this.#ee.masked=g;this.#ee.fin=u;this.#ee.fragmented=Q}else if(this.#Q===E.PAYLOADLENGTH_16){if(this.#X<2){return i()}const A=this.consume(2);this.#ee.payloadLength=A.readUInt16BE(0);this.#Q=E.READ_DATA}else if(this.#Q===E.PAYLOADLENGTH_64){if(this.#X<8){return i()}const A=this.consume(8);const u=A.readUInt32BE(0);if(u>2**31-1){N(this.ws,"Received payload length > 2^31 bytes.");return}const p=A.readUInt32BE(4);this.#ee.payloadLength=(u<<8)+p;this.#Q=E.READ_DATA}else if(this.#Q===E.READ_DATA){if(this.#X<this.#ee.payloadLength){return i()}const A=this.consume(this.#ee.payloadLength);if(U(this.#ee.opcode)){this.#$=this.parseControlFrame(A);this.#Q=E.INFO}else{if(!this.#ee.compressed){this.#te.push(A);if(!this.#ee.fragmented&&this.#ee.fin){const i=Buffer.concat(this.#te);T(this.ws,this.#ee.binaryType,i);this.#te.length=0}this.#Q=E.INFO}else{this.#se.get("permessage-deflate").decompress(A,this.#ee.fin,((A,u)=>{if(A){G(this.ws,1007,A.message,A.message.length);return}this.#te.push(u);if(!this.#ee.fin){this.#Q=E.INFO;this.#$=true;this.run(i);return}T(this.ws,this.#ee.binaryType,Buffer.concat(this.#te));this.#$=true;this.#Q=E.INFO;this.#te.length=0;this.run(i)}));this.#$=false;break}}}}}consume(i){if(i>this.#X){throw new Error("Called consume() before buffers satiated.")}else if(i===0){return B}if(this.#K[0].length===i){this.#X-=this.#K[0].length;return this.#K.shift()}const A=Buffer.allocUnsafe(i);let u=0;while(u!==i){const p=this.#K[0];const{length:g}=p;if(g+u===i){A.set(this.#K.shift(),u);break}else if(g+u>i){A.set(p.subarray(0,i-u),u);this.#K[0]=p.subarray(i-u);break}else{A.set(this.#K.shift(),u);u+=p.length}}this.#X-=i;return A}parseCloseBody(i){g(i.length!==1);let A;if(i.length>=2){A=i.readUInt16BE(0)}if(Line truncated
|
||||
*/
|
||||
var g=p(9829);var f=p(6928).extname;var E=/^\s*([^;\s]*)(?:;|\s|$)/;var C=/^text\//i;A.charset=charset;A.charsets={lookup:charset};A.contentType=contentType;A.extension=extension;A.extensions=Object.create(null);A.lookup=lookup;A.types=Object.create(null);populateMaps(A.extensions,A.types);function charset(i){if(!i||typeof i!=="string"){return false}var A=E.exec(i);var p=A&&g[A[1].toLowerCase()];if(p&&p.charset){return p.charset}if(A&&C.test(A[1])){return"UTF-8"}return false}function contentType(i){if(!i||typeof i!=="string"){return false}var p=i.indexOf("/")===-1?A.lookup(i):i;if(!p){return false}if(p.indexOf("charset")===-1){var g=A.charset(p);if(g)p+="; charset="+g.toLowerCase()}return p}function extension(i){if(!i||typeof i!=="string"){return false}var p=E.exec(i);var g=p&&A.extensions[p[1].toLowerCase()];if(!g||!g.length){return false}return g[0]}function lookup(i){if(!i||typeof i!=="string"){return false}var p=f("x."+i).toLowerCase().substr(1);if(!p){return false}return A.types[p]||false}function populateMaps(i,A){var p=["nginx","apache",undefined,"iana"];Object.keys(g).forEach((function forEachMimeType(f){var E=g[f];var C=E.extensions;if(!C||!C.length){return}i[f]=C;for(var Q=0;Q<C.length;Q++){var B=C[Q];if(A[B]){var I=p.indexOf(g[A[B]].source);var y=p.indexOf(E.source);if(A[B]!=="application/octet-stream"&&(I>y||I===y&&A[B].substr(0,12)==="application/")){continue}}A[B]=f}}))}},744:i=>{var A=1e3;var p=A*60;var g=p*60;var f=g*24;var E=f*7;var C=f*365.25;i.exports=function(i,A){A=A||{};var p=typeof i;if(p==="string"&&i.length>0){return parse(i)}else if(p==="number"&&isFinite(i)){return A.long?fmtLong(i):fmtShort(i)}throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function parse(i){i=String(i);if(i.length>100){return}var Q=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!Q){return}var B=parseFloat(Q[1]);var I=(Q[2]||"ms").toLowerCase();switch(I){case"years":case"year":case"yrs":case"yr":case"y":return B*C;case"weeks":case"week":case"w":return B*E;case"days":case"day":case"d":return B*f;case"hours":case"hour":case"hrs":case"hr":case"h":return B*g;case"minutes":case"minute":case"mins":case"min":case"m":return B*p;case"seconds":case"second":case"secs":case"sec":case"s":return B*A;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return B;default:return undefined}}function fmtShort(i){var E=Math.abs(i);if(E>=f){return Math.round(i/f)+"d"}if(E>=g){return Math.round(i/g)+"h"}if(E>=p){return Math.round(i/p)+"m"}if(E>=A){return Math.round(i/A)+"s"}return i+"ms"}function fmtLong(i){var E=Math.abs(i);if(E>=f){return plural(i,E,f,"day")}if(E>=g){return plural(i,E,g,"hour")}if(E>=p){return plural(i,E,p,"minute")}if(E>=A){return plural(i,E,A,"second")}return i+" ms"}function plural(i,A,p,g){var f=A>=p*1.5;return Math.round(i/p)+" "+g+(f?"s":"")}},7777:(i,A,p)=>{var g=p(7016).parse;var f={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};var E=String.prototype.endsWith||function(i){return i.length<=this.length&&this.indexOf(i,this.length-i.length)!==-1};function getProxyForUrl(i){var A=typeof i==="string"?g(i):i||{};var p=A.protocol;var E=A.host;var C=A.port;if(typeof E!=="string"||!E||typeof p!=="string"){return""}p=p.split(":",1)[0];E=E.replace(/:\d*$/,"");C=parseInt(C)||f[p]||0;if(!shouldProxy(E,C)){return""}var Q=getEnv("npm_config_"+p+"_proxy")||getEnv(p+"_proxy")||getEnv("npm_config_proxy")||getEnv("all_proxy");if(Q&&Q.indexOf("://")===-1){Q=p+"://"+Q}return Q}function shouldProxy(i,A){var p=(getEnv("npm_config_no_proxy")||getEnv("no_proxy")).toLowerCase();if(!p){return true}if(p==="*"){return false}return p.split(/[,\s]/).every((function(p){if(!p){return true}var g=p.match(/^(.+):(\d+)$/);var f=g?g[1]:p;var C=g?parseInt(g[2]):0;if(C&&C!==A){return true}if(!/^[.*]/.test(f)){return i!==f}if(f.charAt(0)==="*"){f=f.slice(1)}return!E.call(i,f)}))}function getEnv(i){return process.env[i.toLowerCase()]||process.env[i.toUpperCase()]||""}A.T=getProxyForUrl},9546:(i,A,p)=>{var g;g={value:true};const f=p(1354);const E=p(7016);const C=p(4434);const Q=p(2830);const B=p(3106);const I=p(4922);const y=p(9023);const b=p(9896);const v=p(9557);const x=p(6928);function _interopDefaultLegacy(i){return i&&typeof i==="object"&&"default"in i?i:{default:i}}const k=_interopDefaultLegacy(f);const R=_interopDefaultLegacy(E);const S=_interopDefaultLegacy(Q);const D=_interopDefaultLegacy(B);const F=_interopDefaultLegacy(I);const T=_interopDefaultLegacy(y);const U=_interopDefaultLegacy(b);const M=_interopDefaultLegacy(v);const L=_interopDefaultLegacy(x);const _=S["default"]("screepsapi:socket");const G={reconnect:true,resubscribe:true,keepAlive:true,maxRetries:10,maxRetryDelay:60*1e3};class Socket extends C.EventEmitter{constructor(i){super();this.api=i;this.opts=Object.assign({},G);this.on("error",(()=>{}));this.reset();this.on("auth",(i=>{if(i.data.status==="ok"){while(this.__queue.lLine truncated
|
||||
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */;const escape=i=>i.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22");const normalizeLinefeeds=i=>i.replace(/\r?\n|\r/g,"\r\n");const g=[];const f=new Uint8Array([13,10]);y=0;let E=false;for(const[A,C]of i){if(typeof C==="string"){const i=_.encode(p+`; name="${escape(normalizeLinefeeds(A))}"`+`\r\n\r\n${normalizeLinefeeds(C)}\r\n`);g.push(i);y+=i.byteLength}else{const i=_.encode(`${p}; name="${escape(normalizeLinefeeds(A))}"`+(C.name?`; filename="${escape(C.name)}"`:"")+"\r\n"+`Content-Type: ${C.type||"application/octet-stream"}\r\n\r\n`);g.push(i,C,f);if(typeof C.size==="number"){y+=i.byteLength+C.size+f.byteLength}else{E=true}}}const C=_.encode(`--${A}--\r\n`);g.push(C);y+=C.byteLength;if(E){y=null}I=i;B=async function*(){for(const i of g){if(i.stream){yield*i.stream()}else{yield i}}};b=`multipart/form-data; boundary=${A}`}else if(E(i)){I=i;y=i.size;if(i.type){b=i.type}}else if(typeof i[Symbol.asyncIterator]==="function"){if(A){throw new TypeError("keepalive")}if(g.isDisturbed(i)||i.locked){throw new TypeError("Response body object should not be disturbed or locked")}p=i instanceof ReadableStream?i:f(i)}if(typeof I==="string"||g.isBuffer(I)){y=Buffer.byteLength(I)}if(B!=null){let A;p=new ReadableStream({async start(){A=B(i)[Symbol.asyncIterator]()},async pull(i){const{value:g,done:f}=await A.next();if(f){queueMicrotask((()=>{i.close();i.byobRequest?.respond(0)}))}else{if(!D(p)){const A=new Uint8Array(g);if(A.byteLength){i.enqueue(A)}}}return i.desiredSize>0},async cancel(i){await A.return()},type:"bytes"})}const v={stream:p,source:I,length:y};return[v,b]}function safelyExtractBody(i,A=false){if(i instanceof ReadableStream){S(!g.isDisturbed(i),"The body has already been consumed.");S(!i.locked,"The stream is locked.")}return extractBody(i,A)}function cloneBody(i,A){const[p,g]=A.stream.tee();A.stream=p;return{stream:g,length:A.length,source:A.source}}function throwIfAborted(i){if(i.aborted){throw new DOMException("The operation was aborted.","AbortError")}}function bodyMixinMethods(i){const A={blob(){return consumeBody(this,(i=>{let A=bodyMimeType(this);if(A===null){A=""}else if(A){A=U(A)}return new R([i],{type:A})}),i)},arrayBuffer(){return consumeBody(this,(i=>new Uint8Array(i).buffer),i)},text(){return consumeBody(this,b,i)},json(){return consumeBody(this,parseJSONFromBytes,i)},formData(){return consumeBody(this,(i=>{const A=bodyMimeType(this);if(A!==null){switch(A.essence){case"multipart/form-data":{const p=M(i,A);if(p==="failure"){throw new TypeError("Failed to parse body as FormData.")}const g=new v;g[x]=p;return g}case"application/x-www-form-urlencoded":{const A=new URLSearchParams(i.toString());const p=new v;for(const[i,g]of A){p.append(i,g)}return p}}}throw new TypeError('Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".')}),i)},bytes(){return consumeBody(this,(i=>new Uint8Array(i)),i)}};return A}function mixinBody(i){Object.assign(i.prototype,bodyMixinMethods(i))}async function consumeBody(i,A,p){k.brandCheck(i,p);if(bodyUnusable(i)){throw new TypeError("Body is unusable: Body has already been read")}throwIfAborted(i[x]);const g=B();const errorSteps=i=>g.reject(i);const successSteps=i=>{try{g.resolve(A(i))}catch(i){errorSteps(i)}};if(i[x].body==null){successSteps(Buffer.allocUnsafe(0));return g.promise}await I(i[x].body,successSteps,errorSteps);return g.promise}function bodyUnusable(i){const A=i[x].body;return A!=null&&(A.stream.locked||g.isDisturbed(A.stream))}function parseJSONFromBytes(i){return JSON.parse(b(i))}function bodyMimeType(i){const A=i[x].headersList;const p=y(A);if(p==="failure"){return null}return p}i.exports={extractBody:extractBody,safelyExtractBody:safelyExtractBody,cloneBody:cloneBody,mixinBody:mixinBody,streamRegistry:H,hasFinalizationRegistry:G,bodyUnusable:bodyUnusable}},4495:i=>{const A=["GET","HEAD","POST"];const p=new Set(A);const g=[101,204,205,304];const f=[301,302,303,307,308];const E=new Set(f);const C=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"];const Q=new Set(C);const B=["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"];const I=new Set(B);const y=["follow","manual","error"];const b=["GET","HEAD","OPTIONS","TRACE"];const v=new Set(b);const x=["navigate","same-origin","no-cors","cors"];const k=["omit","same-origin","include"];const R=["default","no-store","reload","no-cache","force-cLine truncated
|
||||
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */Q[C-4]=p[0];Q[C-3]=p[1];Q[C-2]=p[2];Q[C-1]=p[3];Q[1]=E;if(E===126){Q.writeUInt16BE(f,2)}else if(E===127){Q[2]=Q[3]=0;Q.writeUIntBE(f,4,6)}Q[1]|=128;for(let i=0;i<f;++i){Q[C+i]=A[i]^p[i&3]}return Q}}i.exports={WebsocketFrameSend:WebsocketFrameSend}},9469:(i,A,p)=>{const{createInflateRaw:g,Z_DEFAULT_WINDOWBITS:f}=p(8522);const{isValidClientWindowBits:E}=p(8625);const C=Buffer.from([0,0,255,255]);const Q=Symbol("kBuffer");const B=Symbol("kLength");class PerMessageDeflate{#Z;#h={};constructor(i){this.#h.serverNoContextTakeover=i.has("server_no_context_takeover");this.#h.serverMaxWindowBits=i.get("server_max_window_bits")}decompress(i,A,p){if(!this.#Z){let i=f;if(this.#h.serverMaxWindowBits){if(!E(this.#h.serverMaxWindowBits)){p(new Error("Invalid server_max_window_bits"));return}i=Number.parseInt(this.#h.serverMaxWindowBits)}this.#Z=g({windowBits:i});this.#Z[Q]=[];this.#Z[B]=0;this.#Z.on("data",(i=>{this.#Z[Q].push(i);this.#Z[B]+=i.length}));this.#Z.on("error",(i=>{this.#Z=null;p(i)}))}this.#Z.write(i);if(A){this.#Z.write(C)}this.#Z.flush((()=>{const i=Buffer.concat(this.#Z[Q],this.#Z[B]);this.#Z[Q].length=0;this.#Z[B]=0;p(null,i)}))}}i.exports={PerMessageDeflate:PerMessageDeflate}},1652:(i,A,p)=>{const{Writable:g}=p(7075);const f=p(4589);const{parserStates:E,opcodes:C,states:Q,emptyBuffer:B,sentCloseFrameState:I}=p(736);const{kReadyState:y,kSentClose:b,kResponse:v,kReceivedClose:x}=p(1216);const{channels:k}=p(2414);const{isValidStatusCode:R,isValidOpcode:S,failWebsocketConnection:D,websocketMessageReceived:F,utf8Decode:T,isControlFrame:U,isTextBinaryFrame:M,isContinuationFrame:L}=p(8625);const{WebsocketFrameSend:_}=p(3264);const{closeWebSocketConnection:G}=p(6897);const{PerMessageDeflate:H}=p(9469);class ByteParser extends g{#K=[];#X=0;#$=false;#Q=E.INFO;#ee={};#te=[];#se;constructor(i,A){super();this.ws=i;this.#se=A==null?new Map:A;if(this.#se.has("permessage-deflate")){this.#se.set("permessage-deflate",new H(A))}}_write(i,A,p){this.#K.push(i);this.#X+=i.length;this.#$=true;this.run(p)}run(i){while(this.#$){if(this.#Q===E.INFO){if(this.#X<2){return i()}const A=this.consume(2);const p=(A[0]&128)!==0;const g=A[0]&15;const f=(A[1]&128)===128;const Q=!p&&g!==C.CONTINUATION;const B=A[1]&127;const I=A[0]&64;const y=A[0]&32;const b=A[0]&16;if(!S(g)){D(this.ws,"Invalid opcode received");return i()}if(f){D(this.ws,"Frame cannot be masked");return i()}if(I!==0&&!this.#se.has("permessage-deflate")){D(this.ws,"Expected RSV1 to be clear.");return}if(y!==0||b!==0){D(this.ws,"RSV1, RSV2, RSV3 must be clear");return}if(Q&&!M(g)){D(this.ws,"Invalid frame type was fragmented.");return}if(M(g)&&this.#te.length>0){D(this.ws,"Expected continuation frame");return}if(this.#ee.fragmented&&Q){D(this.ws,"Fragmented frame exceeded 125 bytes.");return}if((B>125||Q)&&U(g)){D(this.ws,"Control frame either too large or fragmented");return}if(L(g)&&this.#te.length===0&&!this.#ee.compressed){D(this.ws,"Unexpected continuation frame");return}if(B<=125){this.#ee.payloadLength=B;this.#Q=E.READ_DATA}else if(B===126){this.#Q=E.PAYLOADLENGTH_16}else if(B===127){this.#Q=E.PAYLOADLENGTH_64}if(M(g)){this.#ee.binaryType=g;this.#ee.compressed=I!==0}this.#ee.opcode=g;this.#ee.masked=f;this.#ee.fin=p;this.#ee.fragmented=Q}else if(this.#Q===E.PAYLOADLENGTH_16){if(this.#X<2){return i()}const A=this.consume(2);this.#ee.payloadLength=A.readUInt16BE(0);this.#Q=E.READ_DATA}else if(this.#Q===E.PAYLOADLENGTH_64){if(this.#X<8){return i()}const A=this.consume(8);const p=A.readUInt32BE(0);if(p>2**31-1){D(this.ws,"Received payload length > 2^31 bytes.");return}const g=A.readUInt32BE(4);this.#ee.payloadLength=(p<<8)+g;this.#Q=E.READ_DATA}else if(this.#Q===E.READ_DATA){if(this.#X<this.#ee.payloadLength){return i()}const A=this.consume(this.#ee.payloadLength);if(U(this.#ee.opcode)){this.#$=this.parseControlFrame(A);this.#Q=E.INFO}else{if(!this.#ee.compressed){this.#te.push(A);if(!this.#ee.fragmented&&this.#ee.fin){const i=Buffer.concat(this.#te);F(this.ws,this.#ee.binaryType,i);this.#te.length=0}this.#Q=E.INFO}else{this.#se.get("permessage-deflate").decompress(A,this.#ee.fin,((A,p)=>{if(A){G(this.ws,1007,A.message,A.message.length);return}this.#te.push(p);if(!this.#ee.fin){this.#Q=E.INFO;this.#$=true;this.run(i);return}F(this.ws,this.#ee.binaryType,Buffer.concat(this.#te));this.#$=true;this.#Q=E.INFO;this.#te.length=0;this.run(i)}));this.#$=false;break}}}}}consume(i){if(i>this.#X){throw new Error("Called consume() before buffers satiated.")}else if(i===0){return B}if(this.#K[0].length===i){this.#X-=this.#K[0].length;return this.#K.shift()}const A=Buffer.allocUnsafe(i);let p=0;while(p!==i){const g=this.#K[0];const{length:f}=g;if(f+p===i){A.set(this.#K.shift(),p);break}else if(f+p>i){A.set(g.subarray(0,i-p),p);this.#K[0]=g.subarray(i-p);break}else{A.set(this.#K.shift(),p);p+=g.length}}this.#X-=i;return A}parseCloseBody(i){f(i.length!==1);let A;if(i.length>=2){A=i.readUInt16BE(0)}if(A!==undefined&&!R(A)){retuLine truncated
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
const { ScreepsAPI } = require("screeps-api");
|
||||
const core = require("@actions/core");
|
||||
const fs = require("fs");
|
||||
const { glob } = require("glob");
|
||||
const path = require("path");
|
||||
import { ScreepsAPI } from "screeps-api";
|
||||
import * as core from "@actions/core";
|
||||
import fs from "fs";
|
||||
import { glob } from "glob";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
/**
|
||||
* Replaces specific placeholder strings within the provided content with corresponding dynamic values.
|
||||
@@ -17,7 +18,7 @@ const path = require("path");
|
||||
* @param {string} content - The string content in which placeholders are to be replaced.
|
||||
* @returns {string} The content with placeholders replaced by their respective dynamic values.
|
||||
*/
|
||||
function replacePlaceholders(content, hostname) {
|
||||
export function replacePlaceholders(content, hostname) {
|
||||
const deployTime = new Date().toISOString();
|
||||
return content
|
||||
.replace(/{{gitHash}}/g, process.env.GITHUB_SHA)
|
||||
@@ -37,7 +38,7 @@ function replacePlaceholders(content, hostname) {
|
||||
* @param {string} [prefix] - An optional directory prefix to prepend to the glob pattern. This allows searching within a specific directory.
|
||||
* @returns {Promise<string[]>} A promise that resolves with an array of file paths that were processed, or rejects with an error if the process fails.
|
||||
*/
|
||||
async function readReplaceAndWriteFiles(pattern, prefix, hostname) {
|
||||
export async function readReplaceAndWriteFiles(pattern, prefix, hostname) {
|
||||
const globPattern = prefix ? path.join(prefix, pattern) : pattern;
|
||||
const files = await glob(globPattern);
|
||||
|
||||
@@ -58,7 +59,7 @@ async function readReplaceAndWriteFiles(pattern, prefix, hostname) {
|
||||
* @param {string} prefix - Directory prefix for file paths.
|
||||
* @returns {Promise<Object>} - Promise resolving to a dictionary of file contents keyed by filenames.
|
||||
*/
|
||||
async function readFilesIntoDict(pattern, prefix) {
|
||||
export async function readFilesIntoDict(pattern, prefix) {
|
||||
// Prepend the prefix to the glob pattern
|
||||
const globPattern = prefix ? path.join(prefix, pattern) : pattern;
|
||||
const files = await glob(globPattern);
|
||||
@@ -88,7 +89,7 @@ async function readFilesIntoDict(pattern, prefix) {
|
||||
* @param {string} password - The password.
|
||||
* @returns {string|null} - Returns an error message if validation fails, otherwise null.
|
||||
*/
|
||||
function validateAuthentication(token, username, password) {
|
||||
export function validateAuthentication(token, username, password) {
|
||||
if (token) {
|
||||
if (username || password) {
|
||||
return "Token is defined along with username and/or password.";
|
||||
@@ -110,7 +111,7 @@ function validateAuthentication(token, username, password) {
|
||||
/**
|
||||
* Posts code to Screeps server.
|
||||
*/
|
||||
async function postCode() {
|
||||
export async function postCode() {
|
||||
const protocol = core.getInput("protocol") || "https";
|
||||
const hostname = core.getInput("hostname") || "screeps.com";
|
||||
const port = core.getInput("port") || "443";
|
||||
@@ -175,14 +176,7 @@ async function postCode() {
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
if (process.argv[1] === __filename) {
|
||||
postCode();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
validateAuthentication,
|
||||
replacePlaceholders,
|
||||
postCode,
|
||||
readReplaceAndWriteFiles,
|
||||
readFilesIntoDict,
|
||||
};
|
||||
Generated
+16
-16
@@ -8,7 +8,7 @@
|
||||
"name": "screeps-deploy-action",
|
||||
"version": "0.1.1",
|
||||
"dependencies": {
|
||||
"@actions/core": "^2.0.0",
|
||||
"@actions/core": "^3.0.0",
|
||||
"glob": "^13.0.0",
|
||||
"screeps-api": "^1.7.2"
|
||||
},
|
||||
@@ -19,28 +19,28 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-2.0.3.tgz",
|
||||
"integrity": "sha512-Od9Thc3T1mQJYddvVPM4QGiLUewdh+3txmDYHHxoNdkqysR1MbCT+rFOtNUxYAz+7+6RIsqipVahY2GJqGPyxA==",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-3.0.0.tgz",
|
||||
"integrity": "sha512-zYt6cz+ivnTmiT/ksRVriMBOiuoUpDCJJlZ5KPl2/FRdvwU3f7MPh9qftvbkXJThragzUZieit2nyHUyw53Seg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/exec": "^2.0.0",
|
||||
"@actions/http-client": "^3.0.2"
|
||||
"@actions/exec": "^3.0.0",
|
||||
"@actions/http-client": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/exec": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-2.0.0.tgz",
|
||||
"integrity": "sha512-k8ngrX2voJ/RIN6r9xB82NVqKpnMRtxDoiO+g3olkIUpQNqjArXrCQceduQZCQj3P3xm32pChRLqRrtXTlqhIw==",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-3.0.0.tgz",
|
||||
"integrity": "sha512-6xH/puSoNBXb72VPlZVm7vQ+svQpFyA96qdDBvhB8eNZOE8LtPf9L4oAsfzK/crCL8YZ+19fKYVnM63Sl+Xzlw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/io": "^2.0.0"
|
||||
"@actions/io": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/http-client": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-3.0.2.tgz",
|
||||
"integrity": "sha512-JP38FYYpyqvUsz+Igqlc/JG6YO9PaKuvqjM3iGvaLqFnJ7TFmcLyy2IDrY0bI0qCQug8E9K+elv5ZNfw62ZJzA==",
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-4.0.0.tgz",
|
||||
"integrity": "sha512-QuwPsgVMsD6qaPD57GLZi9sqzAZCtiJT8kVBCDpLtxhL5MydQ4gS+DrejtZZPdIYyB1e95uCK9Luyds7ybHI3g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tunnel": "^0.0.6",
|
||||
@@ -48,9 +48,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/io": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/io/-/io-2.0.0.tgz",
|
||||
"integrity": "sha512-Jv33IN09XLO+0HS79aaODsvIRyduiF7NY/F6LYeK5oeUmrsz7aFdRphQjFoESF4jS7lMauDOttKALcpapVDIAg==",
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@actions/io/-/io-3.0.2.tgz",
|
||||
"integrity": "sha512-nRBchcMM+QK1pdjO7/idu86rbJI5YHUKCvKs0KxnSYbVe3F51UfGxuZX4Qy/fWlp6l7gWFwIkrOzN+oUK03kfw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@babel/helper-string-parser": {
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@
|
||||
"name": "screeps-deploy-action",
|
||||
"version": "0.1.1",
|
||||
"description": "Deploys screeps code to the official game or an pirvate server.",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
@@ -9,7 +10,7 @@
|
||||
"build": "ncc build index.js -o dist -m --external utf-8-validate --external bufferutil"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^2.0.0",
|
||||
"@actions/core": "^3.0.0",
|
||||
"glob": "^13.0.0",
|
||||
"screeps-api": "^1.7.2"
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user