3 lines
11 KiB
JavaScript
3 lines
11 KiB
JavaScript
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var r,e,n,o=t(require("axios")),i=t(require("camelcase-keys")),a=require("luxon"),u=t(require("ramda")),s=t(require("pino"));function c(t,r,e,n,o,i,a){try{var u=t[i](a),s=u.value}catch(t){return void e(t)}u.done?r(s):Promise.resolve(s).then(n,o)}function p(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var i=t.apply(r,e);function a(t){c(i,n,o,a,u,"next",t)}function u(t){c(i,n,o,a,u,"throw",t)}a(void 0)}))}}(r=exports.Architecture||(exports.Architecture={})).i386="386",r.amd64="amd64",r.arm="arm",r.arm64="arm64",r.mips="mips",r.mips64="mips64",r.mips64le="mips64le",r.mipsle="mipsle",r.ppc64="ppc64",r.ppc64le="ppc64le",r.s390x="s390x",r.wasm="wasm",function(t){t.aix="aix",t.android="android",t.darwin="darwin",t.dragonfly="dragonfly",t.freebsd="freebsd",t.illumos="illumos",t.js="js",t.linux="linux",t.netbsd="netbsd",t.openbsd="openbsd",t.plan9="plan9",t.solaris="solaris",t.windows="windows"}(e||(e={})),(n=exports.ManifestMediaType||(exports.ManifestMediaType={})).Manifest="application/vnd.docker.distribution.manifest.v2+json",n.ManifestList="application/vnd.docker.distribution.manifest.list.v2+json";var f,l=(function(t){var r=function(t){var r=Object.prototype,e=r.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{u({},"")}catch(t){u=function(t,r,e){return t[r]=e}}function s(t,r,e,n){var o=Object.create((r&&r.prototype instanceof f?r:f).prototype),i=new L(n||[]);return o._invoke=function(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var u=w(a,e);if(u){if(u===p)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var s=c(t,r,e);if("normal"===s.type){if(n=e.done?"completed":"suspendedYield",s.arg===p)continue;return{value:s.arg,done:e.done}}"throw"===s.type&&(n="completed",e.method="throw",e.arg=s.arg)}}}(t,e,i),o}function c(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var p={};function f(){}function l(){}function h(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==r&&e.call(y,o)&&(d=y);var m=h.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(r){u(t,r,(function(t){return this._invoke(r,t)}))}))}function x(t,r){var n;this._invoke=function(o,i){function a(){return new r((function(n,a){!function n(o,i,a,u){var s=c(t[o],t,i);if("throw"!==s.type){var p=s.arg,f=p.value;return f&&"object"==typeof f&&e.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):r.resolve(f).then((function(t){p.value=t,a(p)}),(function(t){return n("throw",t,a,u)}))}u(s.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,r){var e=t.iterator[r.method];if(void 0===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,w(t,r),"throw"===r.method))return p;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=c(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,p;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,p):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,p)}function b(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function k(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function E(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function r(){for(;++n<t.length;)if(e.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return i.next=i}}return{next:_}}function _(){return{value:void 0,done:!0}}return l.prototype=m.constructor=h,h.constructor=l,l.displayName=u(h,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===l||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,u(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(x.prototype),x.prototype[i]=function(){return this},t.AsyncIterator=x,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new x(s(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),u(m,a,"Generator"),m[o]=function(){return this},m.toString=function(){return"[object Generator]"},t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=E,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var r in this)"t"===r.charAt(0)&&e.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e,n){return a.type="throw",a.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=e.call(i,"catchLoc"),s=e.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&e.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),p},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),k(e),p}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;k(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:E(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),p}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}}(f={exports:{}}),f.exports),h=s({base:null,useLevelLabels:!0}),d=function(t){var r=t.repo;return"https://registry-1.docker.io/v2/"+r.user+"/"+r.name+"/manifests/latest"},v=function(t){return"https://hub.docker.com/v2/repositories/"+t},y=function(){var t=p(l.mark((function t(r){var e,n,i;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.name,n=r.user,t.next=3,o.get("https://auth.docker.io/token",{params:{scope:"repository:"+n+"/"+e+":pull",service:"registry.docker.io"}});case 3:if(i=u.path(["data","token"],t.sent)){t.next=7;break}throw new Error("Unable to retrieve auth token from registry.");case 7:return t.abrupt("return",i);case 8:case"end":return t.stop()}}),t)})));return function(r){return t.apply(this,arguments)}}(),m=function(t,r){if(!t||u.isEmpty(t))return[];var e=i(t);return u.isNil(r)?e:e.filter((function(t){return a.DateTime.fromISO(t.lastUpdated)<r}))},g=function(){var t=p(l.mark((function t(r){var e,n,a,s;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.name,n=r.user,t.next=3,o.request({url:"https://hub.docker.com/v2/repositories/"+n+"/"+e+"/"});case 3:if(s=u.prop("data",a=t.sent),200===a.status&&s&&!u.isEmpty(s)){t.next=7;break}return t.abrupt("return");case 7:return t.abrupt("return",i(s));case 8:case"end":return t.stop()}}),t)})));return function(r){return t.apply(this,arguments)}}(),x=function(){var t=p(l.mark((function t(r){var e,n,i,a,s,c;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=r.lastUpdatedSince,a=r.user,!((i=void 0===(n=r.numRepos)?100:n)>100)){t.next=3;break}throw new RangeError("Number of repos to query cannot exceed 100.");case 3:return s=v(a),t.next=6,o.get(s,{params:{page:1,page_size:i}});case 6:return c=u.path(["data","results"],t.sent),t.abrupt("return",m(c,e));case 9:case"end":return t.stop()}}),t)})));return function(r){return t.apply(this,arguments)}}(),w=function(){var t=p(l.mark((function t(r){var e,n,a;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=v(r.user),n=e+"/"+r.name+"/tags?page_size=100",t.next=4,o.get(n);case 4:if((a=u.path(["data","results"],t.sent))&&!u.isEmpty(a)){t.next=8;break}return t.abrupt("return");case 8:return t.abrupt("return",i(a));case 9:case"end":return t.stop()}}),t)})));return function(r){return t.apply(this,arguments)}}(),b=function(){var t=p(l.mark((function t(r){var e,n,i;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y(r);case 2:return e=t.sent,n=d({repo:r}),t.next=6,o.get(n,{headers:{Accept:"application/vnd.docker.distribution.manifest.list.v2+json",Authorization:"Bearer "+e}});case 6:if(1!==(i=t.sent).data.schemaVersion){t.next=10;break}return h.info("Schema version 1 is unsupported.",r.name),t.abrupt("return");case 10:return t.abrupt("return",u.path(["data"],i));case 11:case"end":return t.stop()}}),t)})));return function(r){return t.apply(this,arguments)}}();exports.DOCKER_HUB_API_AUTH_URL="https://auth.docker.io/token",exports.DOCKER_HUB_API_ROOT="https://hub.docker.com/v2/",exports.extractRepositoryDetails=m,exports.fetchDockerHubToken=y,exports.fetchManifestList=b,exports.queryRepo=g,exports.queryTags=w,exports.queryTopRepos=x;
|
|
//# sourceMappingURL=docker-hub-utils.cjs.production.min.js.map
|