@bring-it/sftp
Version:
SFTP deployment tool for frontend
1 lines • 13.3 kB
JavaScript
export const __webpack_id__=154;export const __webpack_ids__=[154];export const __webpack_modules__={154:(t,r,e)=>{e.d(r,{upload:()=>S});var o=e(5605);class n extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const i=t=>void 0===globalThis.DOMException?new n(t):new DOMException(t),s=t=>{const r=void 0===t.reason?i("This operation was aborted."):t.reason;return r instanceof Error?r:i(r)},a=Symbol("skip");var u=e(9627);const c=Object.prototype.toString,f=t=>"[object Error]"===c.call(t),p=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Load failed","Network request failed","fetch failed","terminated"]);class l extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,({message:t}=t)):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}}const m=(t,r,e)=>{const o=e.retries-(r-1);return t.attemptNumber=r,t.retriesLeft=o,t};class h extends Error{constructor(t){super(t),this.name="TimeoutError"}}class v extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const y=t=>void 0===globalThis.DOMException?new v(t):new DOMException(t),d=t=>{const r=void 0===t.reason?y("This operation was aborted."):t.reason;return r instanceof Error?r:y(r)};function g(t){return async function(t,r){return new Promise((e,o)=>{r={...r},r.onFailedAttempt??=()=>{},r.shouldRetry??=()=>!0,r.retries??=10;const n=u.operation(r),i=()=>{n.stop(),o(r.signal?.reason)};r.signal&&!r.signal.aborted&&r.signal.addEventListener("abort",i,{once:!0});const s=()=>{r.signal?.removeEventListener("abort",i),n.stop()};n.attempt(async i=>{try{const r=await t(i);s(),e(r)}catch(t){try{if(!(t instanceof Error))throw new TypeError(`Non-error was thrown: "${t}". You should only throw errors.`);if(t instanceof l)throw t.originalError;if(t instanceof TypeError&&!function(t){return!(!t||!f(t)||"TypeError"!==t.name||"string"!=typeof t.message)&&("Load failed"===t.message?void 0===t.stack:p.has(t.message))}(t))throw t;if(m(t,i,r),await r.shouldRetry(t)||(n.stop(),o(t)),await r.onFailedAttempt(t),!n.retry(t))throw n.mainError()}catch(t){m(t,i,r),s(),o(t)}}})})}(t,{retries:5,async onFailedAttempt(t){if("Permission denied"===t.message)throw new l(t.message);await new Promise(t=>{setTimeout(t,3e3)})}})}function _({groups:t,action:r,onOkay:e,onFail:o}){function n(t){return function(t){return g(()=>function(t,r){const{milliseconds:e,fallback:o,message:n,customTimers:i={setTimeout,clearTimeout}}=r;let s,a;const u=new Promise((u,c)=>{if("number"!=typeof e||1!==Math.sign(e))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(r.signal){const{signal:t}=r;t.aborted&&c(d(t)),a=()=>{c(d(t))},t.addEventListener("abort",a,{once:!0})}if(e===Number.POSITIVE_INFINITY)return void t.then(u,c);const f=new h;s=i.setTimeout.call(void 0,()=>{if(o)try{u(o())}catch(t){c(t)}else"function"==typeof t.cancel&&t.cancel(),!1===n?u():n instanceof Error?c(n):(f.message=n??`Promise timed out after ${e} milliseconds`,c(f))},e),(async()=>{try{u(await t)}catch(t){c(t)}})()}).finally(()=>{u.clear(),a&&r.signal&&r.signal.removeEventListener("abort",a)});return u.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},u}(t,{message:"timeout...",milliseconds:1e4}))}(r(t)).then(()=>{e(t)},r=>{throw o(t),r})}function i(t){return async function(t,r){return async function(t,r,{concurrency:e=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:n}={}){return new Promise((i,u)=>{if(void 0===t[Symbol.iterator]&&void 0===t[Symbol.asyncIterator])throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`);if("function"!=typeof r)throw new TypeError("Mapper function is required");if(!Number.isSafeInteger(e)&&e!==Number.POSITIVE_INFINITY||!(e>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${e}\` (${typeof e})`);const c=[],f=[],p=new Map;let l=!1,m=!1,h=!1,v=0,y=0;const d=void 0===t[Symbol.iterator]?t[Symbol.asyncIterator]():t[Symbol.iterator](),g=t=>{l=!0,m=!0,u(t)};n&&(n.aborted&&g(s(n)),n.addEventListener("abort",()=>{g(s(n))}));const _=async()=>{if(m)return;const t=await d.next(),e=y;if(y++,t.done){if(h=!0,0===v&&!m){if(!o&&f.length>0)return void g(new AggregateError(f));if(m=!0,0===p.size)return void i(c);const t=[];for(const[r,e]of c.entries())p.get(r)!==a&&t.push(e);i(t)}}else v++,(async()=>{try{const o=await t.value;if(m)return;const n=await r(o,e);n===a&&p.set(e,n),c[e]=n,v--,await _()}catch(t){if(o)g(t);else{f.push(t),v--;try{await _()}catch(t){g(t)}}}})()};(async()=>{for(let t=0;t<e;t++){try{await _()}catch(t){g(t);break}if(h||l)break}})()})}(t,t=>t(),r)}(t.map(t=>()=>n(t)),{concurrency:5})}return async function(t){for(const r of t)if("function"!=typeof r)throw new TypeError(`Expected task to be a \`Function\`, received \`${typeof r}\``);const r=[];for(const e of t)r.push(await e());return r}(t.map(t=>()=>i(t)))}var w=e(6760),T=e(9790),b=e(8373),x=e(6149),E=e(5246),I=e(9969);const O=[[".svgz",".svg"],[".css"],[".js",".mjs",".cjs"],[".xhtml",".html",".htm"],[".xml",".json",".yml",".yaml"]];async function S(t,r){const e=await function({CWD:t,path:r,include:e,exclude:o}){return(0,b.globby)(e.split(","),{cwd:t,ignore:[...T.Xe,...o.split(",")],onlyFiles:!0,dot:!0}).then(t=>function(t){return E(Object.entries(x(t,t=>{const{ext:r}=(0,w.parse)(t),e=O.findIndex(t=>t.includes(r));return-1===e?"":e})),([t])=>t).map(([t,r])=>r)}(t)).then(e=>e.map(e=>e.map(e=>({name:(0,I.A)(e),local:(0,I.A)((0,w.join)(t,e)),remote:(0,I.A)((0,w.join)(r,e))}))))}(r),n=await t.requestSFTP();return _({groups:e,action:r=>t.putFile(r.local,r.remote,n),onOkay(t){o.v.okay(t.name)},onFail(t){o.v.fail(t.name)}})}},830:(t,r,e)=>{var o=e(7702),n=e(8678)(o);t.exports=n},853:(t,r,e)=>{var o=e(6971);r.operation=function(t){var e=r.timeouts(t);return new o(e,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})},r.timeouts=function(t){if(t instanceof Array)return[].concat(t);var r={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var e in t)r[e]=t[e];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],n=0;n<r.retries;n++)o.push(this.createTimeout(n,r));return t&&t.forever&&!o.length&&o.push(this.createTimeout(n,r)),o.sort(function(t,r){return t-r}),o},r.createTimeout=function(t,r){var e=r.randomize?Math.random()+1:1,o=Math.round(e*Math.max(r.minTimeout,1)*Math.pow(r.factor,t));return Math.min(o,r.maxTimeout)},r.wrap=function(t,e,o){if(e instanceof Array&&(o=e,e=null),!o)for(var n in o=[],t)"function"==typeof t[n]&&o.push(n);for(var i=0;i<o.length;i++){var s=o[i],a=t[s];t[s]=function(o){var n=r.operation(e),i=Array.prototype.slice.call(arguments,1),s=i.pop();i.push(function(t){n.retry(t)||(t&&(arguments[0]=n.mainError()),s.apply(this,arguments))}),n.attempt(function(){o.apply(t,i)})}.bind(t,a),t[s].options=e}}},1141:(t,r,e)=>{var o=e(975);t.exports=function(t,r){if(t!==r){var e=void 0!==t,n=null===t,i=t==t,s=o(t),a=void 0!==r,u=null===r,c=r==r,f=o(r);if(!u&&!f&&!s&&t>r||s&&a&&c&&!u&&!f||n&&a&&c||!e&&c||!i)return 1;if(!n&&!s&&!f&&t<r||f&&e&&i&&!n&&!s||u&&e&&i||!a&&i||!c)return-1}return 0}},1824:t=>{var r=Date.now;t.exports=function(t){var e=0,o=0;return function(){var n=r(),i=16-(n-o);if(o=n,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}},2110:(t,r,e)=>{var o=e(830);t.exports=function(t,r,e,n){return o(t,function(t,o,i){r(n,t,e(t),i)}),n}},2202:(t,r,e)=>{var o=e(2525),n=e(3542);t.exports=function t(r,e,i,s,a){var u=-1,c=r.length;for(i||(i=n),a||(a=[]);++u<c;){var f=r[u];e>0&&i(f)?e>1?t(f,e-1,i,s,a):o(a,f):s||(a[a.length]=f)}return a}},2863:(t,r,e)=>{var o=e(8152),n=e(2110),i=e(4506),s=e(5874);t.exports=function(t,r){return function(e,a){var u=s(e)?o:n,c=r?r():{};return u(e,t,i(a,2),c)}}},3232:(t,r,e)=>{var o=e(3431),n=e(1824)(o);t.exports=n},3431:(t,r,e)=>{var o=e(8295),n=e(4856),i=e(9169),s=n?function(t,r){return n(t,"toString",{configurable:!0,enumerable:!1,value:o(r),writable:!0})}:i;t.exports=s},3542:(t,r,e)=>{var o=e(9006),n=e(79),i=e(5874),s=o?o.isConcatSpreadable:void 0;t.exports=function(t){return i(t)||n(t)||!!(s&&t&&t[s])}},3600:t=>{t.exports=function(t){return function(r,e,o){for(var n=-1,i=Object(r),s=o(r),a=s.length;a--;){var u=s[t?a:++n];if(!1===e(i[u],u,i))break}return r}}},4733:(t,r,e)=>{var o=e(830),n=e(3069);t.exports=function(t,r){var e=-1,i=n(t)?Array(t.length):[];return o(t,function(t,o,n){i[++e]=r(t,o,n)}),i}},5246:(t,r,e)=>{var o=e(2202),n=e(9586),i=e(6965),s=e(8819),a=i(function(t,r){if(null==t)return[];var e=r.length;return e>1&&s(t,r[0],r[1])?r=[]:e>2&&s(r[0],r[1],r[2])&&(r=[r[0]]),n(t,o(r,1),[])});t.exports=a},5390:(t,r,e)=>{var o=e(7156),n=Math.max;t.exports=function(t,r,e){return r=n(void 0===r?t.length-1:r,0),function(){for(var i=arguments,s=-1,a=n(i.length-r,0),u=Array(a);++s<a;)u[s]=i[r+s];s=-1;for(var c=Array(r+1);++s<r;)c[s]=i[s];return c[r]=e(u),o(t,this,c)}}},6149:(t,r,e)=>{var o=e(3077),n=e(2863),i=Object.prototype.hasOwnProperty,s=n(function(t,r,e){i.call(t,e)?t[e].push(r):o(t,e,[r])});t.exports=s},6395:(t,r,e)=>{var o=e(1141);t.exports=function(t,r,e){for(var n=-1,i=t.criteria,s=r.criteria,a=i.length,u=e.length;++n<a;){var c=o(i[n],s[n]);if(c)return n>=u?c:c*("desc"==e[n]?-1:1)}return t.index-r.index}},6965:(t,r,e)=>{var o=e(9169),n=e(5390),i=e(3232);t.exports=function(t,r){return i(n(t,r,o),t+"")}},6971:t=>{function r(t,r){"boolean"==typeof r&&(r={forever:r}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=r||{},this._maxRetryTime=r&&r.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=r,r.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},r.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},r.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var r=(new Date).getTime();if(t&&r-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var e=this._timeouts.shift();if(void 0===e){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),e=this._cachedTimeouts.slice(-1)}var o=this;return this._timer=setTimeout(function(){o._attempts++,o._operationTimeoutCb&&(o._timeout=setTimeout(function(){o._operationTimeoutCb(o._attempts)},o._operationTimeout),o._options.unref&&o._timeout.unref()),o._fn(o._attempts)},e),this._options.unref&&this._timer.unref(),!0},r.prototype.attempt=function(t,r){this._fn=t,r&&(r.timeout&&(this._operationTimeout=r.timeout),r.cb&&(this._operationTimeoutCb=r.cb));var e=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){e._operationTimeoutCb()},e._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},r.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)},r.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)},r.prototype.start=r.prototype.try,r.prototype.errors=function(){return this._errors},r.prototype.attempts=function(){return this._attempts},r.prototype.mainError=function(){if(0===this._errors.length)return null;for(var t={},r=null,e=0,o=0;o<this._errors.length;o++){var n=this._errors[o],i=n.message,s=(t[i]||0)+1;t[i]=s,s>=e&&(r=n,e=s)}return r}},7070:t=>{t.exports=function(t,r){var e=t.length;for(t.sort(r);e--;)t[e]=t[e].value;return t}},7156:t=>{t.exports=function(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}},7702:(t,r,e)=>{var o=e(9128),n=e(3511);t.exports=function(t,r){return t&&o(t,r,n)}},8152:t=>{t.exports=function(t,r,e,o){for(var n=-1,i=null==t?0:t.length;++n<i;){var s=t[n];r(o,s,e(s),t)}return o}},8295:t=>{t.exports=function(t){return function(){return t}}},8678:(t,r,e)=>{var o=e(3069);t.exports=function(t,r){return function(e,n){if(null==e)return e;if(!o(e))return t(e,n);for(var i=e.length,s=r?i:-1,a=Object(e);(r?s--:++s<i)&&!1!==n(a[s],s,a););return e}}},8819:(t,r,e)=>{var o=e(5097),n=e(3069),i=e(1908),s=e(9400);t.exports=function(t,r,e){if(!s(e))return!1;var a=typeof r;return!!("number"==a?n(e)&&i(r,e.length):"string"==a&&r in e)&&o(e[r],t)}},9128:(t,r,e)=>{var o=e(3600)();t.exports=o},9586:(t,r,e)=>{var o=e(2275),n=e(1855),i=e(4506),s=e(4733),a=e(7070),u=e(8232),c=e(6395),f=e(9169),p=e(5874);t.exports=function(t,r,e){r=r.length?o(r,function(t){return p(t)?function(r){return n(r,1===t.length?t[0]:t)}:t}):[f];var l=-1;r=o(r,u(i));var m=s(t,function(t,e,n){return{criteria:o(r,function(r){return r(t)}),index:++l,value:t}});return a(m,function(t,r){return c(t,r,e)})}},9627:(t,r,e)=>{t.exports=e(853)}};