frgen 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";function t(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,c=[],u=!0,l=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(c.push(n.value),c.length!==r);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}function r(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function e(){e=function(){return r};var t,r={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,e){return t[r]=e}}function s(t,r,e,n){var o=r&&r.prototype instanceof m?r:m,a=Object.create(o.prototype),c=new I(n||[]);return i(a,"_invoke",{value:S(t,e,c)}),a}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=s;var p="suspendedStart",y="suspendedYield",v="executing",d="completed",g={};function m(){}function b(){}function w(){}var x={};f(x,c,(function(){return this}));var O=Object.getPrototypeOf,j=O&&O(O(k([])));j&&j!==n&&o.call(j,c)&&(x=j);var L=w.prototype=m.prototype=Object.create(x);function E(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function P(t,r){function e(n,i,a,c){var u=h(t[n],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==typeof f&&o.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new r((function(r,n){e(t,o,r,n)}))}return n=n?n.then(i,i):i()}})}function S(r,e,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var l=h(r,e,n);if("normal"===l.type){if(o=n.done?d:y,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=d,n.method="throw",n.arg=l.arg)}}}function _(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,_(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function A(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 T(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function k(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var n=-1,i=function e(){for(;++n<r.length;)if(o.call(r,n))return e.value=r[n],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof r+" is not iterable")}return b.prototype=w,i(L,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:b,configurable:!0}),b.displayName=f(w,l,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===b||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,l,"GeneratorFunction")),t.prototype=Object.create(L),t},r.awrap=function(t){return{__await:t}},E(P.prototype),f(P.prototype,u,(function(){return this})),r.AsyncIterator=P,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new P(s(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(L),f(L,l,"Generator"),f(L,c,(function(){return this})),f(L,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=k,I.prototype={constructor:I,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!r)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),l=o.call(a,"finallyLoc");if(u&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;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,g):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),g},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),T(e),g}},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;T(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:k(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),g}},r}function n(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function o(t){var r=n(t,"string");return"symbol"==typeof r?r:r+""}function i(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function a(t,r,e){return(r=o(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function c(t){if(Array.isArray(t))return t}function u(t,r){if(t){if("string"==typeof t)return l(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?l(t,r):void 0}}function l(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function f(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.arrayLikeToArray=l,exports.arrayWithHoles=c,exports.asyncToGenerator=function(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function c(t){i(a,n,o,c,u,"next",t)}function u(t){i(a,n,o,c,u,"throw",t)}c(void 0)}))}},exports.createForOfIteratorHelper=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=u(t))||r){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(c)throw i}}}},exports.defineProperty=a,exports.iterableToArrayLimit=t,exports.nonIterableRest=f,exports.objectSpread2=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(Object(n),!0).forEach((function(r){a(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))}))}return t},exports.regeneratorRuntime=e,exports.slicedToArray=function(r,e){return c(r)||t(r,e)||u(r,e)||f()},exports.toPrimitive=n,exports.toPropertyKey=o,exports.unsupportedIterableToArray=u;
|
|
2
|
+
"use strict";function t(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;c=!1}else for(;!(c=(n=i.call(e)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}function r(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function e(){e=function(){return r};var t,r={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},u=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,e){return t[r]=e}}function s(t,r,e,n){var o=r&&r.prototype instanceof g?r:g,a=Object.create(o.prototype),u=new I(n||[]);return i(a,"_invoke",{value:S(t,e,u)}),a}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=s;var p="suspendedStart",y="suspendedYield",v="executing",d="completed",m={};function g(){}function b(){}function w(){}var x={};f(x,u,(function(){return this}));var O=Object.getPrototypeOf,j=O&&O(O(k([])));j&&j!==n&&o.call(j,u)&&(x=j);var L=w.prototype=g.prototype=Object.create(x);function E(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function P(t,r){function e(n,i,a,u){var c=h(t[n],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&o.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,a,u)}),(function(t){e("throw",t,a,u)})):r.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return e("throw",t,a,u)}))}u(c.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new r((function(r,n){e(t,o,r,n)}))}return n=n?n.then(i,i):i()}})}function S(r,e,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=A(u,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var l=h(r,e,n);if("normal"===l.type){if(o=n.done?d:y,l.arg===m)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=d,n.method="throw",n.arg=l.arg)}}}function A(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,A(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function _(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 T(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function k(r){if(r||""===r){var e=r[u];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var n=-1,i=function e(){for(;++n<r.length;)if(o.call(r,n))return e.value=r[n],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof r+" is not iterable")}return b.prototype=w,i(L,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:b,configurable:!0}),b.displayName=f(w,l,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===b||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,l,"GeneratorFunction")),t.prototype=Object.create(L),t},r.awrap=function(t){return{__await:t}},E(P.prototype),f(P.prototype,c,(function(){return this})),r.AsyncIterator=P,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new P(s(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(L),f(L,l,"Generator"),f(L,u,(function(){return this})),f(L,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=k,I.prototype={constructor:I,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!r)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return u.type="throw",u.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=o.call(a,"catchLoc"),l=o.call(a,"finallyLoc");if(c&&l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;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,m):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),m},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),T(e),m}},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;T(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:k(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function n(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function o(t){var r=n(t,"string");return"symbol"==typeof r?r:r+""}function i(t,r,e,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}function a(t,r,e){return(r=o(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function u(t){if(Array.isArray(t))return t}function c(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function l(t,r){if(t){if("string"==typeof t)return f(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?f(t,r):void 0}}function f(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function s(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.arrayLikeToArray=f,exports.arrayWithHoles=u,exports.asyncToGenerator=function(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function u(t){i(a,n,o,u,c,"next",t)}function c(t){i(a,n,o,u,c,"throw",t)}u(void 0)}))}},exports.createForOfIteratorHelper=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=l(t))||r){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(u)throw i}}}},exports.defineProperty=a,exports.iterableToArray=c,exports.iterableToArrayLimit=t,exports.nonIterableRest=s,exports.objectSpread2=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(Object(n),!0).forEach((function(r){a(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))}))}return t},exports.regeneratorRuntime=e,exports.slicedToArray=function(r,e){return u(r)||t(r,e)||l(r,e)||s()},exports.toArray=function(t){return u(t)||c(t)||l(t)||s()},exports.toPrimitive=n,exports.toPropertyKey=o,exports.unsupportedIterableToArray=l;
|
package/lib/main.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),r=require("./utils.js"),
|
|
2
|
+
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),r=require("./utils.js"),t=require("./make_model.js"),a=require("./make_resource.js"),n=require("./make_controller.js"),s=require("./make_crud.js"),c=e.toArray(process.argv);c[0],c[1];var o=c[2],u=c[3],i=c[4],l=c.slice(5);o||(console.error("action undefined."),process.exit(1));var k="default",f="public";if(l.length>0){var p,x=e.createForOfIteratorHelper(l);try{for(x.s();!(p=x.n()).done;){var d=p.value,m=d.split("="),v=e.slicedToArray(m,2),b=(v[0],v[1]);d.includes("--schema")&&(f=b),d.includes("--path")&&(k=b)}}catch(e){x.e(e)}finally{x.f()}}(function(){var c=e.asyncToGenerator(e.regeneratorRuntime().mark((function c(){var l,p;return e.regeneratorRuntime().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,r.loadConfig();case 2:return l=c.sent,p=require("knex")(e.objectSpread2({},l)),c.prev=4,c.next=7,r.checkDatabaseConnection(p);case 7:if("make:model"!==o){c.next=12;break}return c.next=10,t(u,i,p,f);case 10:c.next=25;break;case 12:if("make:resource"!==o){c.next=17;break}return c.next=15,a(u,i,p,f);case 15:c.next=25;break;case 17:if("make:controller"!==o){c.next=22;break}return c.next=20,n(u,i,k,p,f);case 20:c.next=25;break;case 22:if("make:crud"!==o){c.next=25;break}return c.next=25,s(k,p,u);case 25:c.next=31;break;case 27:c.prev=27,c.t0=c.catch(4),console.log(c.t0),process.exit(1);case 31:return c.prev=31,p.destroy(),c.finish(31);case 34:case"end":return c.stop()}}),c,null,[[4,27,31,34]])})));return function(){return c.apply(this,arguments)}})()();
|
package/lib/make_controller.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),n=require("fs"),
|
|
2
|
+
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),n=require("fs"),t=require("path"),r=require("./utils.js");function a(e,n){var t=n.type,a=n.nullable,o=["yup"],c=["integer","bigint","smallint","tinyint","numeric","decimal","float"].includes(t),i=["varchar","text","string","char","character varying","uuid","date","datetime","timestamp","timestamp with time zone"].includes(t),s=["boolean"].includes(t);return c?o.push("number()"):i?o.push("string()"):s?o.push("boolean()"):o.push("mixed()"),a?o.push("optional()"):o.push("required()"),o.push("label('".concat(e.replaceAll("_"," "),"')")),"".concat(r.toCamelCase(e),":").concat(o.join("."))}var o=function(){var o=e.asyncToGenerator(e.regeneratorRuntime().mark((function o(c,i,s,l){var u,d,m,p,y,h,f,x,b,w,q,g=arguments;return e.regeneratorRuntime().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return u=g.length>4&&void 0!==g[4]?g[4]:"public",o.prev=1,c||(console.error("class name undefined"),process.exit(1)),i||(console.error("table name undefined"),process.exit(1)),d="".concat(c,".ts"),m=t.join(process.cwd(),"src","app","http","controller",d),s&&"default"!==s&&("/"!==s.charAt(s.length-1)&&(s+="/"),m=t.join(process.cwd(),"src",s,d)),p=c.replace(/Controller$/,""),o.next=10,l.select("table_name","column_name","column_default","is_nullable","data_type","character_maximum_length").from("information_schema.columns").whereRaw("table_catalog = current_database()").where("table_name",null!=i?i:p+"s").where("table_schema",u);case 10:y=o.sent,h=Object.fromEntries(y.map((function(e){return[e.column_name,{defaultValue:e.column_default,type:e.data_type,maxLength:e.character_maximum_length,nullable:"YES"===e.is_nullable}]}))),f="",x="",Object.keys(h).length&&(b=Object.entries(h).filter((function(n){var t=e.slicedToArray(n,1)[0];return!["created_at","updated_at","createdAt","updatedAt"].includes(t)})).map((function(n){var t=e.slicedToArray(n,2),o=t[0],c=t[1];return[r.toCamelCase(o),a(o,c)]})),x="\n const validated = await req.validation((yup) => yup.object({\n ".concat(b.map((function(n){var t=e.slicedToArray(n,2);return t[0],t[1]})).join(",\n"),"\n }));\n "),f="\n const validated = await req.validation((yup) => yup.object({\n ".concat(b.filter((function(n){return"id"!==e.slicedToArray(n,1)[0]})).map((function(n){var t=e.slicedToArray(n,2);return t[0],t[1]})).join(",\n"),"\n }));\n ")),w='\nimport NotFoundException from "@exception/NotFoundException";\nimport '.concat(p,' from "@model/').concat(p,'";\nimport ').concat(p,'Resource from "@resource/').concat(p,'Resource";\nimport express from "express";\n\nconst ').concat(c," = express.Router();\n\n").concat(c,'.get("/", async (req, res, next) => {\n try {\n const results = await ').concat(p,'.query().page(req.getQuery("page", 0), req.getQuery("perPage", 10));\n res.json(results);\n } catch (error) {\n next(error);\n }\n});\n\n').concat(c,'.get("/:id", async (req, res, next) => {\n try {\n const model = await ').concat(p,'.query().findById(req.params.id);\n if (!model) {\n throw new NotFoundException("').concat(p,'");\n }\n res.json(new ').concat(p,"Resource(model, true));\n } catch (error) {\n next(error);\n }\n});\n\n").concat(c,'.post("/", async (req, res, next) => {\n try {\n ').concat(f,"\n const model = await ").concat(p,".query().insertAndFetch(").concat(""===f?"req.body":"validated",");\n res.json(new ").concat(p,"Resource(model, true));\n } catch (error) {\n next(error);\n }\n});\n\n").concat(c,'.put("/", async (req, res, next) => {\n try {\n ').concat(x,"\n const model = await ").concat(p,".query().findById(").concat(""===x?"req.body.id":"validated.id",');\n if (!model) {\n throw new NotFoundException("').concat(p,'");\n }\n await model.$query().updateAndFetch(').concat(""===x?"req.body":"validated",");\n res.json(new ").concat(p,"Resource(model, true));\n } catch (error) {\n next(error);\n }\n});\n\n").concat(c,'.delete("/:id", async (req, res, next) => {\n try {\n const model = await ').concat(p,'.query().findById(+req.params.id);\n if (!model) {\n throw new NotFoundException("').concat(p,'");\n }\n await model.$query().delete();\n res.json(new ').concat(p,"Resource(model, true));\n } catch (error) {\n next(error);\n }\n});\n\nexport default ").concat(c,";\n"),q=t.dirname(m),n.existsSync(q)||n.mkdirSync(q,{recursive:!0}),n.writeFile(m,w,(function(e){e?console.error("Gagal membuat file:",e):console.log("File ".concat(d," berhasil dibuat di ").concat(m))})),o.next=24;break;case 21:o.prev=21,o.t0=o.catch(1),console.error("Gagal mendapatkan informasi kolom:",o.t0);case 24:return o.prev=24,o.finish(24);case 26:case"end":return o.stop()}}),o,null,[[1,21,24,26]])})));return function(e,n,t,r){return o.apply(this,arguments)}}();module.exports=o;
|
package/lib/make_crud.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),r=require("./make_controller.js"),t=require("./make_model.js"),a=require("./make_resource.js"),n=require("./utils.js"),s=function(){var s=e.asyncToGenerator(e.regeneratorRuntime().mark((function s(c,o){var i,u,
|
|
2
|
+
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),r=require("./make_controller.js"),t=require("./make_model.js"),a=require("./make_resource.js"),n=require("./utils.js"),s=function(){var s=e.asyncToGenerator(e.regeneratorRuntime().mark((function s(c,o){var i,l,u,m,p,f,v,h,_,b=arguments;return e.regeneratorRuntime().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return i=b.length>2&&void 0!==b[2]?b[2]:"public",s.prev=1,s.next=4,o.select("*").from("information_schema.tables").whereNotIn("table_schema",["information_schema","pg_catalog"]).whereNotIn("table_name",["migrations","migrations_lock"]).where("table_type","BASE TABLE");case 4:l=s.sent,u=e.createForOfIteratorHelper(l),s.prev=6,u.s();case 8:if((m=u.n()).done){s.next=22;break}return p=m.value,f=p.table_name,v=n.capitalize(n.toCamelCase(n.removePluralSuffix(f))),h="".concat(v,"Resource"),_="".concat(v,"Controller"),s.next=16,t(v,f,o,i);case 16:return s.next=18,a(h,f,o,i);case 18:return s.next=20,r(_,f,c,o,i);case 20:s.next=8;break;case 22:s.next=27;break;case 24:s.prev=24,s.t0=s.catch(6),u.e(s.t0);case 27:return s.prev=27,u.f(),s.finish(27);case 30:s.next=35;break;case 32:s.prev=32,s.t1=s.catch(1),console.log(s.t1);case 35:return s.prev=35,s.finish(35);case 37:case"end":return s.stop()}}),s,null,[[1,32,35,37],[6,24,27,30]])})));return function(e,r){return s.apply(this,arguments)}}();module.exports=s;
|
package/lib/make_model.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),n=require("fs"),a=require("path"),t=require("./utils.js");function r(e,n){return
|
|
2
|
+
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),n=require("fs"),a=require("path"),t=require("./utils.js");function r(e,n){return c.apply(this,arguments)}function c(){return(c=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(a,r){var c,o,i;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,r.select("tc.table_name","kcu.column_name","ccu.table_name as foreign_table_name","ccu.column_name as foreign_column_name").from("information_schema.table_constraints as tc").join("information_schema.key_column_usage as kcu","tc.constraint_name","kcu.constraint_name").join("information_schema.constraint_column_usage as ccu","ccu.constraint_name","tc.constraint_name").where("tc.constraint_type","FOREIGN KEY").andWhere("tc.table_name",a);case 3:return c=e.sent,e.next=6,r.select("tc.table_name","kcu.column_name","ccu.table_name as foreign_table_name","ccu.column_name as foreign_column_name").from("information_schema.table_constraints as tc").join("information_schema.key_column_usage as kcu","tc.constraint_name","kcu.constraint_name").join("information_schema.constraint_column_usage as ccu","ccu.constraint_name","tc.constraint_name").where("tc.constraint_type","FOREIGN KEY").andWhere("ccu.table_name",a);case 6:return o=e.sent,i={},c.forEach((function(e){var n=e.foreign_table_name;i[t.toCamelCase(t.removePluralSuffix(n))]={relation:"BelongsToOneRelation",relatedTable:e.foreign_table_name,foreignKey:e.column_name,localKey:e.foreign_column_name}})),o.forEach((function(e){var n=e.table_name;i[t.toCamelCase(t.removePluralSuffix(n))]={relation:"HasOneRelation",relatedTable:e.table_name,foreignKey:e.foreign_column_name,localKey:e.column_name},i[t.toCamelCase(n)]={relation:"HasManyRelation",relatedTable:e.table_name,foreignKey:e.foreign_column_name,localKey:e.column_name}})),e.abrupt("return",i);case 11:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function o(n){return Array.from(new Set(Object.entries(n).map((function(n){var a=e.slicedToArray(n,2);a[0];var r=a[1].relatedTable;return"import ".concat(t.capitalize(t.toCamelCase(t.removePluralSuffix(r)))," from './").concat(t.capitalize(t.toCamelCase(t.removePluralSuffix(r))),"';")})))).join("\n")}function i(n,a){var r=Object.entries(n).map((function(n){var r=e.slicedToArray(n,2),c=r[0],o=r[1],i=o.relation,l=o.relatedTable,s=o.foreignKey,m=o.localKey;return"\n ".concat(c,": {\n relation: Model.").concat(i,",\n modelClass: ").concat(t.capitalize(t.toCamelCase(t.removePluralSuffix(l))),",\n join: {\n ").concat("ManyToManyRelation"===i?"\n from: '".concat(m,"',\n through: {\n from: '").concat(s,"',\n to: '").concat(s,"'\n },\n to: '").concat(m,"'"):"\n from: '".concat(a,".").concat(s,"',\n to: '").concat(l,".").concat(m,"'"),"\n }\n }")})).join(",");return"\nstatic get relationMappings() {\nreturn {".concat(r,"\n};\n}")}var l=function(){var c=e.asyncToGenerator(e.regeneratorRuntime().mark((function c(l,s,m){var u,_,f,p,b,d,g,h,y,v,x,C,j=arguments;return e.regeneratorRuntime().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return u=j.length>3&&void 0!==j[3]?j[3]:"public",c.prev=1,l||(console.error("class name undefined"),process.exit(1)),s||(console.error("table name undefined"),process.exit(1)),_="".concat(l,".ts"),f=a.join(process.cwd(),"src","app","model",_),c.next=8,m.select("table_name","column_name","column_default","is_nullable","data_type","character_maximum_length").from("information_schema.columns").whereRaw("table_catalog = current_database()").where("table_name",null!=s?s:l.toLowerCase()+"s").where("table_schema",u);case 8:return p=c.sent,b=Object.fromEntries(p.map((function(e){return[e.column_name,{defaultValue:e.column_default,type:e.data_type,maxLength:e.character_maximum_length,nullable:"YES"===e.is_nullable}]}))),c.next=12,r(s,m,u);case 12:d=c.sent,g=Object.entries(b).map((function(n){var a,r=e.slicedToArray(n,2),c=r[0],o=r[1],i=t.toCamelCase(c),l=(a=o.type,["integer","bigint","smallint","tinyint","numeric","decimal","float"].includes(a)?"number":["varchar","text","string","char","character varying","uuid"].includes(a)?"string":["boolean"].includes(a)?"boolean":["date","datetime","timestamp","timestamp with time zone"].includes(a)?"Date":"any");return" public ".concat(i,": ").concat(l,";")})).join("\n"),h='\n static get tableName() {\n return "'.concat(l.toLowerCase(),'s";\n }\n '),s&&(h='\n static get tableName() {\n return "'.concat(s,'";\n }\n ')),y=d?o(d):"",v=d?i(d,s):"",x='\n import Model from "@lib/Model";\n import { snakeCaseMappers } from "objection";\n '.concat(y,"\n \n export default class ").concat(l," extends Model {\n \n ").concat(g,"\n \n ").concat(h,'\n \n static get idColumn() {\n return "id";\n }\n \n static get columnNameMappers() {\n return snakeCaseMappers();\n }\n \n ').concat(v,"\n }"),C=a.dirname(f),n.existsSync(C)||n.mkdirSync(C,{recursive:!0}),n.writeFile(f,x,(function(e){e?console.error("Gagal membuat file:",e):console.log("File ".concat(_," berhasil dibuat di ").concat(f))})),c.next=27;break;case 24:c.prev=24,c.t0=c.catch(1),console.error("Gagal mendapatkan informasi kolom:",c.t0);case 27:return c.prev=27,c.finish(27);case 29:case"end":return c.stop()}}),c,null,[[1,24,27,29]])})));return function(e,n,a){return c.apply(this,arguments)}}();module.exports=l;
|
package/lib/make_resource.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),r=require("fs"),n=require("path"),t=require("./utils.js"),
|
|
2
|
+
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),r=require("fs"),n=require("path"),t=require("./utils.js"),a=function(){var a=e.asyncToGenerator(e.regeneratorRuntime().mark((function a(c,o,l){var s,u,i,m,p,f,d,_,h=arguments;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=h.length>3&&void 0!==h[3]?h[3]:"public",e.prev=1,c||(console.error("class name undefined"),process.exit(1)),o||(console.error("table name undefined"),process.exit(1)),u="".concat(c.replace("Resource",""),"Resource.ts"),i=n.join(process.cwd(),"src","app","http","resource",u),e.next=8,l.select("table_name","column_name","column_default","is_nullable","data_type","character_maximum_length").from("information_schema.columns").whereRaw("table_catalog = current_database()").where("table_name",o).where("table_schema",s);case 8:m=e.sent,p=Object.fromEntries(m.map((function(e){return[e.column_name,{defaultValue:e.column_default,type:e.data_type,maxLength:e.character_maximum_length,nullable:"YES"===e.is_nullable}]}))),f=Object.keys(p).filter((function(e){return"created_at"!==e&&"updated_at"!==e})).map((function(e){return"".concat(t.toCamelCase(e),": this.").concat(t.toCamelCase(e))})).join(",\n"),d='\nimport Resource from "frexp/lib/Resource";\n\nexport default class '.concat(c," extends Resource {\n toArray() {\n return {\n").concat(f,"\n };\n }\n}"),_=n.dirname(i),r.existsSync(_)||r.mkdirSync(_,{recursive:!0}),r.writeFile(i,d,(function(e){e?console.error("Gagal membuat file:",e):console.log("File ".concat(u," berhasil dibuat di ").concat(i))})),e.next=20;break;case 17:e.prev=17,e.t0=e.catch(1),console.error("Gagal mendapatkan informasi kolom:",e.t0);case 20:return e.prev=20,e.finish(20);case 22:case"end":return e.stop()}}),a,null,[[1,17,20,22]])})));return function(e,r,n){return a.apply(this,arguments)}}();module.exports=a;
|