From 2d20c717ab6cea009607056465a16c80a7ce26f6 Mon Sep 17 00:00:00 2001 From: LittleC Date: Sun, 1 May 2022 19:42:30 +0800 Subject: [PATCH] :bug: not required --- index.js | 2 +- src/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 3dd7ae7..951053f 100644 --- a/index.js +++ b/index.js @@ -155,7 +155,7 @@ Error Stack: %s`,Date(),process.pid,this.constructor.name,__filename,t.name,t.message,t.stack);var e=[];for(var r in t)r==="name"||r==="message"||e.push(B7.format(" %s: %j",r,t[r]));e.length&&console.error(`Error Additions: %s`,e.join(` `)),console.error()}}});var O7=P((Iae,I7)=>{var T7=k7(),oZ=require("util"),uZ=Hg(),cZ=oi(),lZ=Qp().ip(),fZ="roundRobin",hZ="masterSlave";I7.exports=function(t){function e(s){if(!(this instanceof e))return new e(s);if(!s||!Array.isArray(s.cluster))throw new Error("require options.cluster to be an array");T7.call(this),this.clients=[],this.availables={};for(let o=0;o{r[s]=async function(...a){let o=this.chooseAvailable(),u;try{return await o[s](...a)}catch(l){if(l.status&&l.status>=200&&l.status<500)throw l;u=l}for(let l=0;l=200&&g.status<500)throw g;u=g}}throw u.message+=" (all clients are down)",u}}),n.forEach(s=>{r[s]=async function(...a){return(await Promise.all(this.clients.map(u=>u[s](...a))))[0]}}),r.signatureUrl=function(...a){return this.chooseAvailable().signatureUrl(...a)},r.getObjectUrl=function(...a){return this.chooseAvailable().getObjectUrl(...a)},r._init=function(){let a=this;(async()=>{await a._checkAvailable(a._ignoreStatusFile),a.ready(!0)})().catch(o=>{a.emit("error",o)})},r._checkAvailable=async function(a){let o=`._ali-oss/check.status.${lZ}.txt`;if(a||await this.put(o,Buffer.from(`check available started at ${Date()}`)),this._checkAvailableLock)return;this._checkAvailableLock=!0;let u=[];for(let l=0;l0){let l=new Error(`${u.length} data node down, please check status file: ${u.join(", ")}`);l.name="CheckAvailableError",this.emit("error",l)}},r._checkStatus=async function(a,o){let u=!0;try{await a.head(o)}catch(l){(!l.status||l.status>=500||l.status<200)&&(u=!1)}return u},r.chooseAvailable=function(){if(this.schedule===hZ){if(this.masterOnly)return this.clients[0];for(let o=0;o0;){let o=this._nextRRIndex();if(this.availables[o])return this.clients[o];a--}return this.clients[0]},r._nextRRIndex=function(){let a=this.index++;return this.index>=this.clients.length&&(this.index=0),a},r._error=function(a){if(a)throw a},r._createCallback=function(a,o,u){return()=>{u=u||this._error,o.call(a).then(()=>{u()},u)}},r._deferInterval=function(a,o,u){return setInterval(this._createCallback(this,a,u),o)},r.close=function(){clearInterval(this._timerId),this._timerId=null},e}});var N7=P((Oae,P7)=>{var Gg=$s()("ali-oss:sts"),pZ=require("crypto"),dZ=require("querystring"),mZ=oi(),yZ=Gc(),gZ=Is(),vZ=Qs(),EZ=ng(),AZ=new yZ;function Vh(t){if(!(this instanceof Vh))return new Vh(t);if(!t||!t.accessKeyId||!t.accessKeySecret)throw new Error("require accessKeyId, accessKeySecret");this.options={endpoint:t.endpoint||"https://sts.aliyuncs.com",format:"JSON",apiVersion:"2015-04-01",sigMethod:"HMAC-SHA1",sigVersion:"1.0",timeout:"60s"},mZ(t).to(this.options),this.options.urllib?this.urllib=this.options.urllib:(this.urllib=EZ,this.agent=this.options.agent||AZ)}P7.exports=Vh;var zh=Vh.prototype;zh.assumeRole=async function(e,r,i,n,s){let a=this.options,o={Action:"AssumeRole",RoleArn:e,RoleSessionName:n||"app",DurationSeconds:i||3600,Format:a.format,Version:a.apiVersion,AccessKeyId:a.accessKeyId,SignatureMethod:a.sigMethod,SignatureVersion:a.sigVersion,SignatureNonce:Math.random(),Timestamp:new Date().toISOString()};if(r){let d;if(gZ.string(r))try{d=JSON.stringify(JSON.parse(r))}catch(c){throw new Error(`Policy string is not a valid JSON: ${c.message}`)}else d=JSON.stringify(r);o.Policy=d}let u=this._getSignature("POST",o,a.accessKeySecret);o.Signature=u;let l=a.endpoint,h={agent:this.agent,timeout:vZ(s&&s.timeout||a.timeout),method:"POST",content:dZ.stringify(o),headers:{"Content-Type":"application/x-www-form-urlencoded"},ctx:s&&s.ctx},g=await this.urllib.request(l,h);if(Gg("response %s %s, got %s, headers: %j",h.method,l,g.status,g.headers),Math.floor(g.status/100)!==2){let d=await this._requestError(g);throw d.params=h,d}return g.data=JSON.parse(g.data),{res:g.res,credentials:g.data.Credentials}};zh._requestError=async function(e){let r=new Error;r.status=e.status;try{let i=await JSON.parse(e.data)||{};r.code=i.Code,r.message=`${i.Code}: ${i.Message}`,r.requestId=i.RequestId}catch{r.message=`UnknownError: ${String(e.data)}`}return r};zh._getSignature=function(e,r,i){let n=this,s=Object.keys(r).sort().map(u=>`${n._escape(u)}=${n._escape(r[u])}`).join("&"),a=`${e.toUpperCase()}&${this._escape("/")}&${this._escape(s)}`;Gg("string to sign: %s",a);let o=pZ.createHmac("sha1",`${i}&`);return o=o.update(a).digest("base64"),Gg("signature: %s",o),o};zh._escape=function(e){return encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")}});var U7=P((Pae,j7)=>{var oc=$s()("ali-oss"),DZ=UE(),CZ=lD(),FZ=Gc(),bZ=Gc().HttpsAgent,Pi=Zs(),xZ=xD(),wZ=zn(),SZ=ng(),BZ=d6(),R7=y6(),Xg=_h(),_Z=B6(),{createRequest:kZ}=(N6(),ge(P6)),{encoder:TZ}=(lg(),ge(cg)),{getReqUrl:IZ}=(mg(),ge(dg)),{setSTSToken:OZ}=(vg(),ge(gg)),{retry:PZ}=(Oh(),ge(Ih)),{isFunction:NZ}=(Ag(),ge(Eg)),M7=new FZ,q7=new bZ;function gi(t,e){if(!(this instanceof gi))return new gi(t,e);t&&t.inited?this.options=t:this.options=gi.initOptions(t),this.options.urllib?this.urllib=this.options.urllib:(this.urllib=SZ,this.options.maxSockets&&(M7.maxSockets=this.options.maxSockets,q7.maxSockets=this.options.maxSockets),this.agent=this.options.agent||M7,this.httpsAgent=this.options.httpsAgent||q7),this.ctx=e,this.userAgent=this._getUserAgent(),this.stsTokenFreshTime=new Date}j7.exports=gi;gi.initOptions=function(e){return _Z(e)};var _t=gi.prototype;Pi(_t,I9());Pi(_t,M9());Pi(_t,z9());Pi(_t,n7());Pi(_t,a7());Pi(_t,h7());Pi(_t,y7());Pi(_t,E7());Pi(_t,D7());Pi(_t,F7());gi.ImageClient=x7()(gi);gi.ClusterClient=O7()(gi);gi.STS=N7();_t.signature=function(e){return oc("authorization stringToSign: %s",e),Xg.computeSignature(this.options.accessKeySecret,e,this.options.headerEncoding)};_t._getReqUrl=IZ;_t.authorization=function(e,r,i,n){let s=Xg.buildCanonicalString(e.toUpperCase(),r,{headers:n,parameters:i});return Xg.authorization(this.options.accessKeyId,this.options.accessKeySecret,s,this.options.headerEncoding)};_t.request=async function(t){return this.options.retryMax?await PZ(L7.bind(this),this.options.retryMax,{errorHandler:e=>!!(i=>{if(t.stream)return!1;let n=[-1,-2].includes(i.status),s=this.options.requestErrorRetryHandle||(()=>!0);return n&&s(i)})(e)})(t):await L7.call(this,t)};async function L7(t){this.options.stsToken&&NZ(this.options.refreshSTSToken)&&await OZ.call(this);let e=kZ.call(this,t),r,i;try{r=await this.urllib.request(e.url,e.params),oc("response %s %s, got %s, headers: %j",t.method,e.url,r.status,r.headers)}catch(s){i=s}let n;if(r&&t.successStatuses&&t.successStatuses.indexOf(r.status)===-1?(n=await this.requestError(r),n.params=t):i&&(n=await this.requestError(i)),n)throw t.customResponse&&r&&r.res&&await DZ(r.res),n.name==="ResponseTimeoutError"&&(n.message=`${n.message.split(",")[0]}, please increase the timeout or use multipartDownload.`),n;return t.xmlResponse&&(r.data=await this.parseXML(r.data)),r}_t._getResource=function(e){let r="/";return e.bucket&&(r+=`${e.bucket}/`),e.object&&(r+=TZ(e.object,this.options.headerEncoding)),r};_t._escape=function(e){return wZ.encodeURIComponent(e).replace(/%2F/g,"/")};_t._getUserAgent=function(){let r=`aliyun-sdk-${process&&process.browser?"js":"nodejs"}/${BZ.version}`,i=xZ.description;return!i&&process&&(i=`Node.js ${process.version.slice(1)} on ${process.platform} ${process.arch}`),this._checkUserAgent(`${r} ${i}`)};_t._checkUserAgent=function(e){return e.replace(/\u03b1/,"alpha").replace(/\u03b2/,"beta")};_t.checkBrowserAndVersion=function(e,r){return R7.name===e&&R7.version.split(".")[0]===r};_t.parseXML=function(e){return new Promise((r,i)=>{Buffer.isBuffer(e)&&(e=e.toString()),CZ.parseString(e,{explicitRoot:!1,explicitArray:!1},(n,s)=>{n?i(n):r(s)})})};_t.requestError=async function(e){let r=null;if(e.name==="ResponseTimeoutError")r=new Error(e.message),r.name=e.name;else if(!e.data||!e.data.length)e.status===-1||e.status===-2?(r=new Error(e.message),r.name=e.name,r.status=e.status,r.code=e.name):(e.status===404?(r=new Error("Object not exists"),r.name="NoSuchKeyError",r.status=404,r.code="NoSuchKey"):e.status===412?(r=new Error("Pre condition failed"),r.name="PreconditionFailedError",r.status=412,r.code="PreconditionFailed"):(r=new Error(`Unknow error, status: ${e.status}`),r.name="UnknowError",r.status=e.status),r.requestId=e.headers["x-oss-request-id"],r.host="");else{let i=String(e.data);oc("request response error data: %s",i);let n;try{n=await this.parseXML(i)||{}}catch(a){return oc(i),a.message+=` -raw xml: ${i}`,a.status=e.status,a.requestId=e.headers["x-oss-request-id"],a}let s=n.Message||`unknow request error, status: ${e.status}`;n.Condition&&(s+=` (condition: ${n.Condition})`),r=new Error(s),r.name=n.Code?`${n.Code}Error`:"UnknowError",r.status=e.status,r.code=n.Code,r.requestId=n.RequestId,r.hostId=n.HostId}return oc("generate error %j",r),r};_t.setSLDEnabled=function(e){return this.options.sldEnable=!!e,this}});var mo=en(Qh()),V7=en(D0()),z7=en(U7()),Wg=require("path");(async()=>{let t=new z7.default({accessKeyId:mo.default.getInput("KEY_ID"),accessKeySecret:mo.default.getInput("KEY_SECRET"),bucket:mo.default.getInput("BUCKET"),endpoint:"oss-accelerate.aliyuncs.com"}),e=(0,Wg.resolve)(mo.default.getInput("LOCAL_PATH")),r=V7.default.sync(`${e}/**/*.*`).map(i=>i.substr(e.length));for(let i of r){let n=mo.default.getInput("REMOTE_PREFIX")+i;await t.put(n,(0,Wg.resolve)(e,i)),console.log(i)}console.log("done")})(); +raw xml: ${i}`,a.status=e.status,a.requestId=e.headers["x-oss-request-id"],a}let s=n.Message||`unknow request error, status: ${e.status}`;n.Condition&&(s+=` (condition: ${n.Condition})`),r=new Error(s),r.name=n.Code?`${n.Code}Error`:"UnknowError",r.status=e.status,r.code=n.Code,r.requestId=n.RequestId,r.hostId=n.HostId}return oc("generate error %j",r),r};_t.setSLDEnabled=function(e){return this.options.sldEnable=!!e,this}});var mo=en(Qh()),V7=en(D0()),z7=en(U7()),Wg=require("path");(async()=>{let t=new z7.default({accessKeyId:mo.default.getInput("KEY_ID"),accessKeySecret:mo.default.getInput("KEY_SECRET"),bucket:mo.default.getInput("BUCKET"),endpoint:"oss-accelerate.aliyuncs.com"}),e=(0,Wg.resolve)(mo.default.getInput("LOCAL_PATH")),r=V7.default.sync(`${e}/**/*.*`).map(i=>i.substr(e.length));for(let i of r){let n=(mo.default.getInput("REMOTE_PREFIX")||"")+i;await t.put(n,(0,Wg.resolve)(e,i)),console.log(i)}console.log("done")})(); /*! * Bowser - a browser detector * https://github.com/ded/bowser diff --git a/src/index.ts b/src/index.ts index c8efbf0..fbecf32 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,7 @@ import { resolve } from 'path' const prefix = resolve(core.getInput('LOCAL_PATH')) let tasks = glob.sync(`${prefix}/**/*.*`).map(v => v.substr(prefix.length)) for (let task of tasks) { - const remoteName = core.getInput('REMOTE_PREFIX') + task + const remoteName = (core.getInput('REMOTE_PREFIX') || "") + task await store.put(remoteName, resolve(prefix, task)) console.log(task) }