frgen 0.0.3 → 0.0.5

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"),n=require("./make_model.js"),t=require("./make_resource.js"),a=require("./make_controller.js"),s=require("./make_crud.js"),c=e.slicedToArray(process.argv,7);c[0],c[1];var o=c[2],u=c[3],i=c[4],l=c[5],k=c[6];o||(console.error("action undefined."),process.exit(1)),function(){var c=e.asyncToGenerator(e.regeneratorRuntime().mark((function c(){var x,p;return e.regeneratorRuntime().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,r.loadConfig();case 2:return x=c.sent,p=require("knex")(e.objectSpread2({},x)),c.prev=4,c.next=7,r.checkDatabaseConnection(p);case 7:if("make:model"!==o){c.next=12;break}return c.next=10,n(u,i,p,l);case 10:c.next=25;break;case 12:if("make:resource"!==o){c.next=17;break}return c.next=15,t(u,i,p,l);case 15:c.next=25;break;case 17:if("make:controller"!==o){c.next=22;break}return c.next=20,a(u,i,k,p,l);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)}}()();
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)}})()();
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
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;
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,g,q=arguments;return e.regeneratorRuntime().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return u=q.length>4&&void 0!==q[4]?q[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(').concat(p,"Resource.paginate(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"),g=t.dirname(m),n.existsSync(g)||n.mkdirSync(g,{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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frgen",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "helper generator",
5
5
  "main": "lib/",
6
6
  "types": "lib/index.d.ts",