meocord 1.0.10 → 1.0.12
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.
- package/dist/bin/generator.js +2 -2
- package/dist/bin/meocord.js +6 -6
- package/dist/core/meocord.app.js +2 -2
- package/dist/decorator/app.decorator.d.ts +1 -1
- package/dist/decorator/app.decorator.js +1 -1
- package/dist/decorator/guard.decorator.js +2 -2
- package/dist/util/common.util.js +2 -2
- package/dist/util/meocord-cli.util.js +2 -2
- package/dist/util/meocord-config-loader.util.js +3 -3
- package/package.json +39 -37
- package/webpack.config.js +17 -6
package/dist/bin/generator.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function
|
|
1
|
+
function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _regenerator(){function i(a,d,f,g){var h=d&&d.prototype instanceof Generator?d:Generator,c=Object.create(h.prototype);return _regeneratorDefine2(c,"_invoke",function(a,g,h){function d(a,c){for(m=a,q=c,e=0;!v&&s&&!f&&e<t.length;e++){var f,g=t[e],h=p.p,k=g[2];3<a?(f=k===c)&&(q=g[(m=g[4])?5:(m=3,3)],g[4]=g[5]=b):g[0]<=h&&((f=2>a&&h<g[1])?(m=0,p.v=c,p.n=g[1]):h<k&&(f=3>a||g[0]>c||c>k)&&(g[4]=a,g[5]=c,p.n=k,m=0))}if(f||1<a)return j;throw v=!0,c}var k,m,q,s=0,t=h||[],v=!1,p={p:0,n:0,v:b,a:d,f:d.bind(b,4),d:function d(a,c){return k=a,m=0,q=b,p.n=c,j}};return function(c,f,h){if(1<s)throw TypeError("Generator is already running");for(v&&1===f&&d(f,h),m=f,q=h;(e=2>m?b:q)||!v;){k||(m?3>m?(1<m&&(p.n=-1),d(m,q)):p.n=q:p.v=q);try{if(s=2,k){if(m||(c="next"),e=k[c]){if(!(e=e.call(k,q)))throw TypeError("iterator result is not an object");if(!e.done)return e;q=e.value,2>m&&(m=0)}else 1===m&&(e=k["return"])&&e.call(k),2>m&&(q=TypeError("The iterator does not provide a '"+c+"' method"),m=1);k=b}else if((e=(v=0>p.n)?q:a.call(g,p))!==j)break}catch(a){k=b,m=1,q=a}finally{s=1}}return{value:e,done:v}}}(a,f,g),!0),c}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function f(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(a,h,"GeneratorFunction")),a.prototype=Object.create(c),a}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var b,e,d="function"==typeof Symbol?Symbol:{},g=d.iterator||"@@iterator",h=d.toStringTag||"@@toStringTag",j={};e=Object.getPrototypeOf;var a=[][g]?e(e([][g]())):(_regeneratorDefine2(e={},g,function(){return this}),e),c=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(a);return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(c,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,h,"GeneratorFunction"),_regeneratorDefine2(c),_regeneratorDefine2(c,h,"Generator"),_regeneratorDefine2(c,g,function(){return this}),_regeneratorDefine2(c,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(a,b,c,d){var f=Object.defineProperty;try{f({},"",{})}catch(a){f=0}_regeneratorDefine2=function _regeneratorDefine(a,b,c,d){function o(b,c){_regeneratorDefine2(a,b,function(a){return this._invoke(b,c,a)})}b?f?f(a,b,{value:c,enumerable:!d,configurable:!d,writable:!d}):a[b]=c:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(a,b,c,d)}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
|
|
2
2
|
* MeoCord Framework
|
|
3
3
|
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
4
|
*
|
|
@@ -14,4 +14,4 @@ function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
14
14
|
*
|
|
15
15
|
* You should have received a copy of the GNU General Public License
|
|
16
16
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/import{Argument}from"commander";import{ControllerGeneratorHelper}from"./helper/controller-generator.helper.js";import{Logger}from"../common/index.js";import{ServiceGeneratorHelper}from"./helper/service-generator.helper.js";import{GuardGeneratorHelper}from"./helper/guard-generator.helper.js";import wait from"../util/wait.util.js";export var GeneratorCLI=/*#__PURE__*/function(){function GeneratorCLI(a){_classCallCheck(this,GeneratorCLI),this.appName=a,this.logger=new Logger(this.appName),this.controllerGeneratorHelper=new ControllerGeneratorHelper,this.serviceGeneratorHelper=new ServiceGeneratorHelper(this.appName),this.guardGeneratorHelper=new GuardGeneratorHelper(this.appName)}return _createClass(GeneratorCLI,[{key:"register",value:function register(a){var b=this,c=a.command("generate").alias("g").description("Generate components");return c.command("controller").alias("co").description("Generate a controller component").addArgument(new Argument("<type>","Type of the controller (e.g., button, context-menu, etc.)").choices(["button","context-menu","message","modal-submit","reaction","select-menu","slash"])).addArgument(new Argument("<name>","Name of the controller")).action(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/
|
|
17
|
+
*/import{Argument}from"commander";import{ControllerGeneratorHelper}from"./helper/controller-generator.helper.js";import{Logger}from"../common/index.js";import{ServiceGeneratorHelper}from"./helper/service-generator.helper.js";import{GuardGeneratorHelper}from"./helper/guard-generator.helper.js";import wait from"../util/wait.util.js";export var GeneratorCLI=/*#__PURE__*/function(){function GeneratorCLI(a){_classCallCheck(this,GeneratorCLI),this.appName=a,this.logger=new Logger(this.appName),this.controllerGeneratorHelper=new ControllerGeneratorHelper,this.serviceGeneratorHelper=new ServiceGeneratorHelper(this.appName),this.guardGeneratorHelper=new GuardGeneratorHelper(this.appName)}return _createClass(GeneratorCLI,[{key:"register",value:function register(a){var b=this,c=a.command("generate").alias("g").description("Generate components");return c.command("controller").alias("co").description("Generate a controller component").addArgument(new Argument("<type>","Type of the controller (e.g., button, context-menu, etc.)").choices(["button","context-menu","message","modal-submit","reaction","select-menu","slash"])).addArgument(new Argument("<name>","Name of the controller")).action(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(a,c){return _regenerator().w(function(d){for(;1;)switch(d.n){case 0:return d.n=1,b.handleGenerateComponent({component:"controller",type:a,name:c});case 1:return d.a(2)}},_callee)}));return function(b,c){return a.apply(this,arguments)}}()),c.command("service").alias("s").addArgument(new Argument("<name>","Name of the service.")).description("Generate a service component").action(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(a){return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:return c.n=1,b.handleGenerateComponent({component:"service",name:a});case 1:return c.a(2)}},_callee2)}));return function(b){return a.apply(this,arguments)}}()),c.command("guard").alias("gu").addArgument(new Argument("<name>","Name of the guard.")).description("Generate a guard component").action(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(a){return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:return c.n=1,b.handleGenerateComponent({component:"guard",name:a});case 1:return c.a(2)}},_callee3)}));return function(b){return a.apply(this,arguments)}}()),a}},{key:"handleGenerateComponent",value:function(){function handleGenerateComponent(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(a){var b,c,d,e;return _regenerator().w(function(f){for(;1;)switch(f.n){case 0:if(b=a.component,c=a.name,d=a.type,c){f.n=2;break}return this.logger.error("Name is required"),f.n=1,wait(100);case 1:process.exit(1);case 2:e=b,f.n="controller"===e?3:"service"===e?7:"guard"===e?8:9;break;case 3:if(d){f.n=5;break}return this.logger.error("Type is required for controllers"),f.n=4,wait(100);case 4:process.exit(1);case 5:return f.n=6,this.handleGenerateController({name:c,type:d});case 6:return f.a(3,11);case 7:return this.serviceGeneratorHelper.generateService(c),f.a(3,11);case 8:return this.guardGeneratorHelper.generateGuard(c),f.a(3,11);case 9:return this.logger.error("Unsupported component type: ".concat(b)),f.n=10,wait(100);case 10:process.exit(1);case 11:return f.a(2)}},_callee4,this)}));return handleGenerateComponent}()},{key:"handleGenerateController",value:function(){function handleGenerateController(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(a){var b;return _regenerator().w(function(c){for(;1;)switch(c.p=c.n){case 0:c.p=0,this.controllerGeneratorHelper.generateController({controllerName:a.name},a.type),c.n=3;break;case 1:return c.p=1,b=c.v,this.logger.error("Error generating controller: ".concat(b instanceof Error?b.message:b+"")),c.n=2,wait(100);case 2:process.exit(1);case 3:return c.a(2)}},_callee5,this,[[0,1]])}));return handleGenerateController}()}])}();
|
package/dist/bin/meocord.js
CHANGED
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
*
|
|
16
16
|
* You should have received a copy of the GNU General Public License
|
|
17
17
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
-
*/function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function _iterableToArrayLimit(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function define(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function wrap(b,d,e,f){var g=d&&d.prototype instanceof Generator?d:Generator,i=Object.create(g.prototype),a=new Context(f||[]);return h(i,"_invoke",{value:makeInvokeMethod(b,e,a)}),i}function tryCatch(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function defineIteratorMethods(a){["next","throw","return"].forEach(function(b){define(a,b,function(a){return this._invoke(b,a)})})}function AsyncIterator(b,d){function invoke(e,f,g,i){var a=tryCatch(b[e],b,f);if("throw"!==a.type){var c=a.arg,k=c.value;return k&&"object"==_typeof(k)&&j.call(k,"__await")?d.resolve(k.__await).then(function(a){invoke("next",a,g,i)},function(a){invoke("throw",a,g,i)}):d.resolve(k).then(function(a){c.value=a,g(c)},function(a){return invoke("throw",a,g,i)})}i(a.arg)}var a;h(this,"_invoke",{value:function value(b,c){function callInvokeWithMethodAndArg(){return new d(function(a,d){invoke(b,c,a,d)})}return a=a?a.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}})}function makeInvokeMethod(a,d,e){var f="suspendedStart";return function(g,h){if(f==="executing")throw Error("Generator is already running");if("completed"===f){if("throw"===g)throw h;return{value:b,done:!0}}for(e.method=g,e.arg=h;;){var i=e.delegate;if(i){var j=maybeInvokeDelegate(i,e);if(j){if(j===m)continue;return j}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===f)throw f="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);f="executing";var k=tryCatch(a,d,e);if("normal"===k.type){if(f=e.done?"completed":"suspendedYield",k.arg===m)continue;return{value:k.arg,done:e.done}}"throw"===k.type&&(f="completed",e.method="throw",e.arg=k.arg)}}}function maybeInvokeDelegate(c,d){var e=d.method,f=c.iterator[e];if(f===b)return d.delegate=null,"throw"===e&&c.iterator["return"]&&(d.method="return",d.arg=b,maybeInvokeDelegate(c,d),"throw"===d.method)||"return"!==e&&(d.method="throw",d.arg=new TypeError("The iterator does not provide a '"+e+"' method")),m;var g=tryCatch(f,c.iterator,d.arg);if("throw"===g.type)return d.method="throw",d.arg=g.arg,d.delegate=null,m;var h=g.arg;return h?h.done?(d[c.resultName]=h.value,d.next=c.nextLoc,"return"!==d.method&&(d.method="next",d.arg=b),d.delegate=null,m):h:(d.method="throw",d.arg=new TypeError("iterator result is not an object"),d.delegate=null,m)}function pushTryEntry(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function resetTryEntry(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function Context(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(pushTryEntry,this),this.reset(!0)}function values(a){if(a||""===a){var c=a[l];if(c)return c.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var d=-1,e=function next(){for(;++d<a.length;)if(j.call(a,d))return next.value=a[d],next.done=!1,next;return next.value=b,next.done=!0,next};return e.next=e}}throw new TypeError(_typeof(a)+" is not iterable")}_regeneratorRuntime=function _regeneratorRuntime(){return f};var b,f={},e=Object.prototype,j=e.hasOwnProperty,h=Object.defineProperty||function(a,b,c){a[b]=c.value},k="function"==typeof Symbol?Symbol:{},l=k.iterator||"@@iterator",a=k.asyncIterator||"@@asyncIterator",c=k.toStringTag||"@@toStringTag";try{define({},"")}catch(a){define=function define(a,b,c){return a[b]=c}}f.wrap=wrap;var m={},i={};define(i,l,function(){return this});var n=Object.getPrototypeOf,d=n&&n(n(values([])));d&&d!==e&&j.call(d,l)&&(i=d);var o=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(i);return GeneratorFunction.prototype=GeneratorFunctionPrototype,h(o,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),h(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,c,"GeneratorFunction"),f.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===GeneratorFunction||"GeneratorFunction"===(b.displayName||b.name))},f.mark=function(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,define(a,c,"GeneratorFunction")),a.prototype=Object.create(o),a},f.awrap=function(a){return{__await:a}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,a,function(){return this}),f.AsyncIterator=AsyncIterator,f.async=function(b,c,d,e,g){void 0===g&&(g=Promise);var h=new AsyncIterator(wrap(b,c,d,e),g);return f.isGeneratorFunction(c)?h:h.next().then(function(a){return a.done?a.value:h.next()})},defineIteratorMethods(o),define(o,c,"Generator"),define(o,l,function(){return this}),define(o,"toString",function(){return"[object Generator]"}),f.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function next(){for(;c.length;){var a=c.pop();if(a in b)return next.value=a,next.done=!1,next}return next.done=!0,next}},f.values=values,Context.prototype={constructor:Context,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=b,this.done=!1,this.delegate=null,this.method="next",this.arg=b,this.tryEntries.forEach(resetTryEntry),!a)for(var c in this)"t"===c.charAt(0)&&j.call(this,c)&&!isNaN(+c.slice(1))&&(this[c]=b)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(d){function handle(a,c){return h.type="throw",h.arg=d,e.next=a,c&&(e.method="next",e.arg=b),!!c}if(this.done)throw d;for(var e=this,f=this.tryEntries.length-1;0<=f;--f){var g=this.tryEntries[f],h=g.completion;if("root"===g.tryLoc)return handle("end");if(g.tryLoc<=this.prev){var k=j.call(g,"catchLoc"),l=j.call(g,"finallyLoc");if(k&&l){if(this.prev<g.catchLoc)return handle(g.catchLoc,!0);if(this.prev<g.finallyLoc)return handle(g.finallyLoc)}else if(!k){if(!l)throw Error("try statement without catch or finally");if(this.prev<g.finallyLoc)return handle(g.finallyLoc)}else if(this.prev<g.catchLoc)return handle(g.catchLoc,!0)}}},abrupt:function abrupt(b,c){for(var d,e=this.tryEntries.length-1;0<=e;--e)if(d=this.tryEntries[e],d.tryLoc<=this.prev&&j.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var f=d;break}f&&("break"===b||"continue"===b)&&f.tryLoc<=c&&c<=f.finallyLoc&&(f=null);var g=f?f.completion:{};return g.type=b,g.arg=c,f?(this.method="next",this.next=f.finallyLoc,m):this.complete(g)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),m},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),resetTryEntry(b),m},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var f=d.arg;resetTryEntry(b)}return f}throw Error("illegal catch attempt")},delegateYield:function delegateYield(a,c,d){return this.delegate={iterator:values(a),resultName:c,nextLoc:d},"next"===this.method&&(this.arg=b),m}},f}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import path from"path";import webpack from"webpack";import{Logger}from"../common/index.js";import{spawn}from"node:child_process";import{capitalize}from"lodash-es";import wait from"../util/wait.util.js";import{GeneratorCLI}from"./generator.js";import*as fs from"node:fs";import{compileAndValidateConfig,setEnvironment}from"../util/common.util.js";import{Command}from"commander";import{compileMeoCordConfig}from"../util/meocord-config-loader.util.js";import{simpleGit}from"simple-git";import chalk from"chalk";import{execSync}from"child_process";import{configureCommandHelp,ensureReady}from"../util/meocord-cli.util.js";import packageJson from"../../package.json"with{type:"json"};import{fileURLToPath}from"url";var __filename=fileURLToPath(import.meta.url),__dirname=path.dirname(__filename),MeoCordCLI=/*#__PURE__*/function(){function MeoCordCLI(){_classCallCheck(this,MeoCordCLI),_defineProperty(this,"appName","MeoCord"),_defineProperty(this,"logger",new Logger(this.appName)),_defineProperty(this,"projectRoot",process.cwd()),_defineProperty(this,"mainJSPath",path.join(this.projectRoot,"dist","main.js")),_defineProperty(this,"webpackConfigPath",path.resolve(__dirname,"..","..","webpack.config.js")),_defineProperty(this,"generatorCLI",new GeneratorCLI(this.appName)),_defineProperty(this,"version",packageJson.version)}return _createClass(MeoCordCLI,[{key:"run",value:(/**
|
|
18
|
+
*/function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function _iterableToArrayLimit(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _regenerator(){function i(a,d,f,g){var h=d&&d.prototype instanceof Generator?d:Generator,c=Object.create(h.prototype);return _regeneratorDefine2(c,"_invoke",function(a,g,h){function d(a,c){for(m=a,q=c,e=0;!v&&s&&!f&&e<t.length;e++){var f,g=t[e],h=p.p,k=g[2];3<a?(f=k===c)&&(q=g[(m=g[4])?5:(m=3,3)],g[4]=g[5]=b):g[0]<=h&&((f=2>a&&h<g[1])?(m=0,p.v=c,p.n=g[1]):h<k&&(f=3>a||g[0]>c||c>k)&&(g[4]=a,g[5]=c,p.n=k,m=0))}if(f||1<a)return j;throw v=!0,c}var k,m,q,s=0,t=h||[],v=!1,p={p:0,n:0,v:b,a:d,f:d.bind(b,4),d:function d(a,c){return k=a,m=0,q=b,p.n=c,j}};return function(c,f,h){if(1<s)throw TypeError("Generator is already running");for(v&&1===f&&d(f,h),m=f,q=h;(e=2>m?b:q)||!v;){k||(m?3>m?(1<m&&(p.n=-1),d(m,q)):p.n=q:p.v=q);try{if(s=2,k){if(m||(c="next"),e=k[c]){if(!(e=e.call(k,q)))throw TypeError("iterator result is not an object");if(!e.done)return e;q=e.value,2>m&&(m=0)}else 1===m&&(e=k["return"])&&e.call(k),2>m&&(q=TypeError("The iterator does not provide a '"+c+"' method"),m=1);k=b}else if((e=(v=0>p.n)?q:a.call(g,p))!==j)break}catch(a){k=b,m=1,q=a}finally{s=1}}return{value:e,done:v}}}(a,f,g),!0),c}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function f(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(a,h,"GeneratorFunction")),a.prototype=Object.create(c),a}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var b,e,d="function"==typeof Symbol?Symbol:{},g=d.iterator||"@@iterator",h=d.toStringTag||"@@toStringTag",j={};e=Object.getPrototypeOf;var a=[][g]?e(e([][g]())):(_regeneratorDefine2(e={},g,function(){return this}),e),c=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(a);return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(c,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,h,"GeneratorFunction"),_regeneratorDefine2(c),_regeneratorDefine2(c,h,"Generator"),_regeneratorDefine2(c,g,function(){return this}),_regeneratorDefine2(c,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(a,b,c,d){var f=Object.defineProperty;try{f({},"",{})}catch(a){f=0}_regeneratorDefine2=function _regeneratorDefine(a,b,c,d){function o(b,c){_regeneratorDefine2(a,b,function(a){return this._invoke(b,c,a)})}b?f?f(a,b,{value:c,enumerable:!d,configurable:!d,writable:!d}):a[b]=c:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(a,b,c,d)}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import path from"path";import webpack from"webpack";import{Logger}from"../common/index.js";import{spawn}from"node:child_process";import{capitalize}from"lodash-es";import wait from"../util/wait.util.js";import{GeneratorCLI}from"./generator.js";import*as fs from"node:fs";import{compileAndValidateConfig,setEnvironment}from"../util/common.util.js";import{Command}from"commander";import{compileMeoCordConfig}from"../util/meocord-config-loader.util.js";import{simpleGit}from"simple-git";import chalk from"chalk";import{execSync}from"child_process";import{configureCommandHelp,ensureReady}from"../util/meocord-cli.util.js";import packageJson from"../../package.json"with{type:"json"};import{fileURLToPath}from"url";var __filename=fileURLToPath(import.meta.url),__dirname=path.dirname(__filename),MeoCordCLI=/*#__PURE__*/function(){function MeoCordCLI(){_classCallCheck(this,MeoCordCLI),_defineProperty(this,"appName","MeoCord"),_defineProperty(this,"logger",new Logger(this.appName)),_defineProperty(this,"projectRoot",process.cwd()),_defineProperty(this,"mainJSPath",path.join(this.projectRoot,"dist","main.js")),_defineProperty(this,"webpackConfigPath",path.resolve(__dirname,"..","..","webpack.config.js")),_defineProperty(this,"generatorCLI",new GeneratorCLI(this.appName)),_defineProperty(this,"version",packageJson.version)}return _createClass(MeoCordCLI,[{key:"run",value:(/**
|
|
19
19
|
* Configures and runs the MeoCord CLI.
|
|
20
|
-
*/function(){function run(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/
|
|
20
|
+
*/function(){function run(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(){var a,b=this;return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:a=new Command,a.name(this.appName.toLowerCase()).description("CLI for managing the ".concat(this.appName," application")).version(this.version),a.command("show").description("Display information").option("-w, --warranty","Display warranty disclaimer").option("-c, --license","Display licensing conditions and usage rights").action(function(b){if(!b.warranty&&!b.license){var c;null===(c=a.commands.find(function(a){return"show"===a.name()}))||void 0===c||c.outputHelp(),process.exit(1)}b.warranty&&console.log("\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\nThe authors of this software are not responsible for damages caused\nby the usage, misuse, or inability to use the software.\n\nSee the GNU General Public License for full details:\n<https://www.gnu.org/licenses/>.\n "),b.license&&console.log("\nThis program is free software: you can redistribute it and/or\nmodify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation, either version 3 of\nthe License, or (at your option) any later version.\n\nKey conditions of the GNU GPL v3:\n- You can use this software for personal, academic, or commercial purposes.\n- If you distribute modified versions, you must share the source code under the same GPL v3 license.\n- The original copyright must be retained.\n\nFor full license details, refer to:\n<https://www.gnu.org/licenses/gpl-3.0.txt>\n ")}),a.command("create <app-name>").description("Create a new MeoCord application").action(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(a){return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:return c.n=1,b.createApp(a);case 1:return c.a(2,c.v)}},_callee)}));return function(b){return a.apply(this,arguments)}}()),a.command("build").description("Build the application").option("-d, --dev","Build in development mode").option("-p, --prod","Build in production mode").action(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(a){var c;return _regenerator().w(function(d){for(;1;)switch(d.n){case 0:return d.n=1,ensureReady();case 1:return c=a.prod?"production":"development",setEnvironment(c),d.n=2,compileAndValidateConfig();case 2:return d.n=3,b.build(c);case 3:return d.a(2)}},_callee2)}));return function(b){return a.apply(this,arguments)}}()),a.command("start").description("Start the application").option("-b, --build","Pre-build before starting").option("-d, --dev","Start in development mode").option("-p, --prod","Start in production mode").action(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(a){var c;return _regenerator().w(function(d){for(;1;)switch(d.n){case 0:return d.n=1,ensureReady();case 1:if(c=a.prod?"production":"development",setEnvironment(c),!(a.build||a.dev)){d.n=2;break}return d.n=2,compileAndValidateConfig();case 2:if(!a.build){d.n=3;break}return d.n=3,b.build(c);case 3:if(!a.prod){d.n=5;break}return d.n=4,b.startProd();case 4:d.n=6;break;case 5:return d.n=6,b.startDev();case 6:return d.a(2)}},_callee3)}));return function(b){return a.apply(this,arguments)}}()),a=this.generatorCLI.register(a),configureCommandHelp(a),a.showHelpAfterError().parse(process.argv);case 1:return c.a(2)}},_callee4,this)}));return run}())},{key:"createApp",value:function(){function createApp(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return _regenerator().w(function(r){for(;1;)switch(r.p=r.n){case 0:if(b=a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),c=path.resolve(process.cwd(),b),d="https://github.com/l7aromeo/meocord-template.git",console.info(chalk.blueBright("\uD83D\uDE80 Creating a new MeoCord app: ".concat(chalk.bold(b)))),r.p=1,!fs.existsSync(c)){r.n=3;break}return console.error(chalk.red("\u274C Directory \"".concat(chalk.bold(b),"\" already exists."))),r.n=2,wait(100);case 2:process.exit(1);case 3:if(e="22.14.0",f=process.version.slice(1).split(".").map(Number),g=_slicedToArray(f,3),h=g[0],i=g[1],j=g[2],k=e.split(".").map(Number),l=_slicedToArray(k,3),m=l[0],n=l[1],o=l[2],!(h<m||h===m&&i<n||h===m&&i===n&&j<o)){r.n=5;break}return console.error(chalk.red("\u274C Node.js v".concat(e," or higher is required. Current version: v").concat(process.version,"."))),r.n=4,wait(100);case 4:process.exit(1);case 5:return console.info(chalk.blueBright("\uD83D\uDCE6 Fetching template...")),r.n=6,simpleGit().clone(d,c);case 6:return console.log(chalk.green("\u2714 App successfully created at: ".concat(chalk.bold(c)))),fs.rmSync(path.join(c,".git"),{recursive:!0,force:!0}),console.info(chalk.blueBright("\uD83D\uDD27 Initializing Git repository...")),p=simpleGit(c),r.n=7,p.init();case 7:return r.n=8,p.add("./*");case 8:return r.n=9,p.commit("Initial commit");case 9:console.log(chalk.green("\u2714 Git repository initialized.")),console.info(chalk.blueBright("\uD83D\uDCE6 Installing dependencies...")),execSync("cd ".concat(b," && corepack enable && yarn install"),{stdio:"inherit"}),console.log(chalk.green("\u2714 Dependencies installed successfully.")),console.log(chalk.greenBright("\uD83C\uDF89 MeoCord app \"".concat(chalk.bold(b),"\" is ready!"))),r.n=12;break;case 10:return r.p=10,q=r.v,console.error(chalk.red("\u274C Failed to create app: ".concat(q instanceof Error?q.message:q+""))),r.n=11,wait(100);case 11:process.exit(1);case 12:return r.a(2)}},_callee5,null,[[1,10]])}));return createApp}()/**
|
|
21
21
|
* Builds the MeoCord application in the specified mode.
|
|
22
22
|
*
|
|
23
23
|
* @param mode - The build mode ('production' or 'development').
|
|
24
|
-
*/},{key:"build",value:(function(){function build(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/
|
|
24
|
+
*/},{key:"build",value:(function(){function build(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(a){var b,c,d,e=this;return _regenerator().w(function(f){for(;1;)switch(f.p=f.n){case 0:return f.p=0,this.clearConsole(),this.logger.info("Building ".concat(a," version...")),f.n=1,import(this.webpackConfigPath);case 1:return b=f.v["default"],c=webpack(_objectSpread(_objectSpread({},b),{},{mode:a})),f.n=2,new Promise(function(b,d){return c?void c.run(function(f,g){return f?(e.logger.error("Build encountered an error: ".concat(f.message)),d("Build encountered an error: ".concat(f.message))):void(null!==g&&void 0!==g&&g.hasErrors()?e.logger.error("Build failed due to errors in the compilation process:",g.compilation.errors):e.logger.info("".concat(capitalize(a)," build completed successfully.")),c.close(function(a){return a?(e.logger.error("Error occurred while closing the compiler: ".concat(a.message)),d("Error occurred while closing the compiler: ".concat(a.message))):void b()}))}):(e.logger.error("Failed to create webpack compiler instance."),d("Failed to create webpack compiler instance."))});case 2:f.n=5;break;case 3:return f.p=3,d=f.v,this.logger.error("Build process failed: ".concat(d.message)),f.n=4,wait(100);case 4:process.exit(1);case 5:return f.a(2)}},_callee6,this,[[0,3]])}));return build}()/**
|
|
25
25
|
* Starts the MeoCord application in development mode with live updates.
|
|
26
|
-
*/)},{key:"startDev",value:(function(){function startDev(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/
|
|
26
|
+
*/)},{key:"startDev",value:(function(){function startDev(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(){var a,b,c,d,e,f,g,h,i=this;return _regenerator().w(function(j){for(;1;)switch(j.p=j.n){case 0:return j.p=0,this.clearConsole(),this.logger.log("Starting watch mode..."),j.n=1,import(this.webpackConfigPath);case 1:if(a=j.v["default"],b=webpack(_objectSpread(_objectSpread({},a),{},{mode:"development"})),b){j.n=3;break}return this.logger.error("Failed to create webpack compiler instance."),j.n=2,wait(100);case 2:process.exit(1);case 3:c=null,d=!1,e=function watch(){return b.watch({},function(a,b){return a?void i.logger.error("Webpack Error: ".concat(a.message)):void(null!==b&&void 0!==b&&b.hasErrors()?i.logger.error("Build failed due to errors in the compilation process:",b.compilation.errors):(c&&(c.kill(),c=null),c=spawn("npx -y nodemon",["-q",i.mainJSPath],{shell:!0,cwd:i.projectRoot,stdio:"inherit"}),d=!0))})},e(),g=fs.watch(path.resolve(process.cwd(),"meocord.config.ts"),function(){clearTimeout(f),f=setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(){return _regenerator().w(function(a){for(;1;)switch(a.n){case 0:if(!(d&&c)){a.n=3;break}return d=!1,i.logger.log("MeoCord config change detected, recompiling config..."),c&&!c.killed&&(c.kill(),c=null),a.n=1,new Promise(function(a){return b.close(a)});case 1:return a.n=2,compileMeoCordConfig();case 2:e();case 3:return a.a(2)}},_callee7)})),300)}),process.on("SIGINT",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(){return _regenerator().w(function(a){for(;1;)switch(a.n){case 0:return a.n=1,wait(1e3);case 1:return c&&!c.killed&&c.kill(),a.n=2,new Promise(function(a){return b.close(a)});case 2:return g.close(),a.n=3,wait(100);case 3:process.exit(0);case 4:return a.a(2)}},_callee8)}))),j.n=5;break;case 4:j.p=4,h=j.v,this.logger.error("Failed to start: ".concat(h.message));case 5:return j.a(2)}},_callee9,this,[[0,4]])}));return startDev}()/**
|
|
27
27
|
* Starts the MeoCord application in production mode.
|
|
28
|
-
*/)},{key:"startProd",value:(function(){function startProd(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/
|
|
28
|
+
*/)},{key:"startProd",value:(function(){function startProd(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(){var a,b;return _regenerator().w(function(c){for(;1;)switch(c.p=c.n){case 0:if(c.p=0,fs.existsSync(this.mainJSPath)){c.n=2;break}return this.logger.error("Main entry file (main.js) not found! You might need to build before running in production mode."),c.n=1,wait(100);case 1:process.exit(1);case 2:this.clearConsole(),this.logger.log("Starting..."),a=spawn("node ".concat(this.mainJSPath),{shell:!0,cwd:this.projectRoot,stdio:"inherit"}).on("spawn",this.clearConsole),process.on("SIGINT",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(){return _regenerator().w(function(b){for(;1;)switch(b.n){case 0:return b.n=1,wait(1e3);case 1:return a&&!a.killed&&a.kill(),b.n=2,wait(100);case 2:process.exit(0);case 3:return b.a(2)}},_callee0)}))),c.n=5;break;case 3:return c.p=3,b=c.v,this.logger.error("Failed to start:",b instanceof Error?b.message:b+""),c.n=4,wait(100);case 4:process.exit(1);case 5:return c.a(2)}},_callee1,this,[[0,3]])}));return startProd}()/**
|
|
29
29
|
* Clears the console on all platforms.
|
|
30
30
|
*/)},{key:"clearConsole",value:function clearConsole(){process.stdout.write("\x1B[3J\x1B[2J\x1B[H")}}])}(),cli=new MeoCordCLI;/**
|
|
31
31
|
* A Command Line Interface (CLI) for managing the MeoCord application.
|
|
32
32
|
*/// Create an instance of the CLI and run it
|
|
33
|
-
cli.run()["catch"](/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/
|
|
33
|
+
cli.run()["catch"](/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(a){return _regenerator().w(function(b){for(;1;)switch(b.n){case 0:return cli.logger.error("Failed to initialize CLI:",(null===a||void 0===a?void 0:a.message)||a),b.n=1,wait(100);case 1:process.exit(1);case 2:return b.a(2)}},_callee10)}));return function(b){return a.apply(this,arguments)}}());
|
package/dist/core/meocord.app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(b,c){var d="undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(!d){if(Array.isArray(b)||(d=_unsupportedIterableToArray(b))||c&&b&&"number"==typeof b.length){d&&(b=d);var e=0,f=function F(){};return{s:f,n:function n(){return e>=b.length?{done:!0}:{done:!1,value:b[e++]}},e:function e(a){throw a},f:f}}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 g,h=!0,i=!1;return{s:function s(){d=d.call(b)},n:function n(){var a=d.next();return h=a.done,a},e:function e(a){i=!0,g=a},f:function f(){try{h||null==d["return"]||d["return"]()}finally{if(i)throw g}}}}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function define(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function wrap(b,d,e,f){var g=d&&d.prototype instanceof Generator?d:Generator,i=Object.create(g.prototype),a=new Context(f||[]);return h(i,"_invoke",{value:makeInvokeMethod(b,e,a)}),i}function tryCatch(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function defineIteratorMethods(a){["next","throw","return"].forEach(function(b){define(a,b,function(a){return this._invoke(b,a)})})}function AsyncIterator(b,d){function invoke(e,f,g,i){var a=tryCatch(b[e],b,f);if("throw"!==a.type){var c=a.arg,k=c.value;return k&&"object"==_typeof(k)&&j.call(k,"__await")?d.resolve(k.__await).then(function(a){invoke("next",a,g,i)},function(a){invoke("throw",a,g,i)}):d.resolve(k).then(function(a){c.value=a,g(c)},function(a){return invoke("throw",a,g,i)})}i(a.arg)}var a;h(this,"_invoke",{value:function value(b,c){function callInvokeWithMethodAndArg(){return new d(function(a,d){invoke(b,c,a,d)})}return a=a?a.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}})}function makeInvokeMethod(a,d,e){var f="suspendedStart";return function(g,h){if(f==="executing")throw Error("Generator is already running");if("completed"===f){if("throw"===g)throw h;return{value:b,done:!0}}for(e.method=g,e.arg=h;;){var i=e.delegate;if(i){var j=maybeInvokeDelegate(i,e);if(j){if(j===m)continue;return j}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===f)throw f="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);f="executing";var k=tryCatch(a,d,e);if("normal"===k.type){if(f=e.done?"completed":"suspendedYield",k.arg===m)continue;return{value:k.arg,done:e.done}}"throw"===k.type&&(f="completed",e.method="throw",e.arg=k.arg)}}}function maybeInvokeDelegate(c,d){var e=d.method,f=c.iterator[e];if(f===b)return d.delegate=null,"throw"===e&&c.iterator["return"]&&(d.method="return",d.arg=b,maybeInvokeDelegate(c,d),"throw"===d.method)||"return"!==e&&(d.method="throw",d.arg=new TypeError("The iterator does not provide a '"+e+"' method")),m;var g=tryCatch(f,c.iterator,d.arg);if("throw"===g.type)return d.method="throw",d.arg=g.arg,d.delegate=null,m;var h=g.arg;return h?h.done?(d[c.resultName]=h.value,d.next=c.nextLoc,"return"!==d.method&&(d.method="next",d.arg=b),d.delegate=null,m):h:(d.method="throw",d.arg=new TypeError("iterator result is not an object"),d.delegate=null,m)}function pushTryEntry(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function resetTryEntry(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function Context(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(pushTryEntry,this),this.reset(!0)}function values(a){if(a||""===a){var c=a[l];if(c)return c.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var d=-1,e=function next(){for(;++d<a.length;)if(j.call(a,d))return next.value=a[d],next.done=!1,next;return next.value=b,next.done=!0,next};return e.next=e}}throw new TypeError(_typeof(a)+" is not iterable")}_regeneratorRuntime=function _regeneratorRuntime(){return f};var b,f={},e=Object.prototype,j=e.hasOwnProperty,h=Object.defineProperty||function(a,b,c){a[b]=c.value},k="function"==typeof Symbol?Symbol:{},l=k.iterator||"@@iterator",a=k.asyncIterator||"@@asyncIterator",c=k.toStringTag||"@@toStringTag";try{define({},"")}catch(a){define=function define(a,b,c){return a[b]=c}}f.wrap=wrap;var m={},i={};define(i,l,function(){return this});var n=Object.getPrototypeOf,d=n&&n(n(values([])));d&&d!==e&&j.call(d,l)&&(i=d);var o=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(i);return GeneratorFunction.prototype=GeneratorFunctionPrototype,h(o,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),h(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,c,"GeneratorFunction"),f.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===GeneratorFunction||"GeneratorFunction"===(b.displayName||b.name))},f.mark=function(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,define(a,c,"GeneratorFunction")),a.prototype=Object.create(o),a},f.awrap=function(a){return{__await:a}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,a,function(){return this}),f.AsyncIterator=AsyncIterator,f.async=function(b,c,d,e,g){void 0===g&&(g=Promise);var h=new AsyncIterator(wrap(b,c,d,e),g);return f.isGeneratorFunction(c)?h:h.next().then(function(a){return a.done?a.value:h.next()})},defineIteratorMethods(o),define(o,c,"Generator"),define(o,l,function(){return this}),define(o,"toString",function(){return"[object Generator]"}),f.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function next(){for(;c.length;){var a=c.pop();if(a in b)return next.value=a,next.done=!1,next}return next.done=!0,next}},f.values=values,Context.prototype={constructor:Context,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=b,this.done=!1,this.delegate=null,this.method="next",this.arg=b,this.tryEntries.forEach(resetTryEntry),!a)for(var c in this)"t"===c.charAt(0)&&j.call(this,c)&&!isNaN(+c.slice(1))&&(this[c]=b)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(d){function handle(a,c){return h.type="throw",h.arg=d,e.next=a,c&&(e.method="next",e.arg=b),!!c}if(this.done)throw d;for(var e=this,f=this.tryEntries.length-1;0<=f;--f){var g=this.tryEntries[f],h=g.completion;if("root"===g.tryLoc)return handle("end");if(g.tryLoc<=this.prev){var k=j.call(g,"catchLoc"),l=j.call(g,"finallyLoc");if(k&&l){if(this.prev<g.catchLoc)return handle(g.catchLoc,!0);if(this.prev<g.finallyLoc)return handle(g.finallyLoc)}else if(!k){if(!l)throw Error("try statement without catch or finally");if(this.prev<g.finallyLoc)return handle(g.finallyLoc)}else if(this.prev<g.catchLoc)return handle(g.catchLoc,!0)}}},abrupt:function abrupt(b,c){for(var d,e=this.tryEntries.length-1;0<=e;--e)if(d=this.tryEntries[e],d.tryLoc<=this.prev&&j.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var f=d;break}f&&("break"===b||"continue"===b)&&f.tryLoc<=c&&c<=f.finallyLoc&&(f=null);var g=f?f.completion:{};return g.type=b,g.arg=c,f?(this.method="next",this.next=f.finallyLoc,m):this.complete(g)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),m},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),resetTryEntry(b),m},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var f=d.arg;resetTryEntry(b)}return f}throw Error("illegal catch attempt")},delegateYield:function delegateYield(a,c,d){return this.delegate={iterator:values(a),resultName:c,nextLoc:d},"next"===this.method&&(this.arg=b),m}},f}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
|
|
1
|
+
function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _regeneratorValues(a){if(null!=a){var b=a["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],c=0;if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length))return{next:function next(){return a&&c>=a.length&&(a=void 0),{value:a&&a[c++],done:!a}}}}throw new TypeError(_typeof(a)+" is not iterable")}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _regeneratorKeys(a){var b=Object(a),c=[];for(var d in b)c.unshift(d);return function e(){for(;c.length;)if((d=c.pop())in b)return e.value=d,e.done=!1,e;return e.done=!0,e}}function _createForOfIteratorHelper(b,c){var d="undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(!d){if(Array.isArray(b)||(d=_unsupportedIterableToArray(b))||c&&b&&"number"==typeof b.length){d&&(b=d);var e=0,f=function F(){};return{s:f,n:function n(){return e>=b.length?{done:!0}:{done:!1,value:b[e++]}},e:function e(a){throw a},f:f}}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 g,h=!0,i=!1;return{s:function s(){d=d.call(b)},n:function n(){var a=d.next();return h=a.done,a},e:function e(a){i=!0,g=a},f:function f(){try{h||null==d["return"]||d["return"]()}finally{if(i)throw g}}}}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function _regenerator(){function i(a,d,f,g){var h=d&&d.prototype instanceof Generator?d:Generator,c=Object.create(h.prototype);return _regeneratorDefine2(c,"_invoke",function(a,g,h){function d(a,c){for(m=a,q=c,e=0;!v&&s&&!f&&e<t.length;e++){var f,g=t[e],h=p.p,k=g[2];3<a?(f=k===c)&&(q=g[(m=g[4])?5:(m=3,3)],g[4]=g[5]=b):g[0]<=h&&((f=2>a&&h<g[1])?(m=0,p.v=c,p.n=g[1]):h<k&&(f=3>a||g[0]>c||c>k)&&(g[4]=a,g[5]=c,p.n=k,m=0))}if(f||1<a)return j;throw v=!0,c}var k,m,q,s=0,t=h||[],v=!1,p={p:0,n:0,v:b,a:d,f:d.bind(b,4),d:function d(a,c){return k=a,m=0,q=b,p.n=c,j}};return function(c,f,h){if(1<s)throw TypeError("Generator is already running");for(v&&1===f&&d(f,h),m=f,q=h;(e=2>m?b:q)||!v;){k||(m?3>m?(1<m&&(p.n=-1),d(m,q)):p.n=q:p.v=q);try{if(s=2,k){if(m||(c="next"),e=k[c]){if(!(e=e.call(k,q)))throw TypeError("iterator result is not an object");if(!e.done)return e;q=e.value,2>m&&(m=0)}else 1===m&&(e=k["return"])&&e.call(k),2>m&&(q=TypeError("The iterator does not provide a '"+c+"' method"),m=1);k=b}else if((e=(v=0>p.n)?q:a.call(g,p))!==j)break}catch(a){k=b,m=1,q=a}finally{s=1}}return{value:e,done:v}}}(a,f,g),!0),c}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function f(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(a,h,"GeneratorFunction")),a.prototype=Object.create(c),a}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var b,e,d="function"==typeof Symbol?Symbol:{},g=d.iterator||"@@iterator",h=d.toStringTag||"@@toStringTag",j={};e=Object.getPrototypeOf;var a=[][g]?e(e([][g]())):(_regeneratorDefine2(e={},g,function(){return this}),e),c=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(a);return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(c,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,h,"GeneratorFunction"),_regeneratorDefine2(c),_regeneratorDefine2(c,h,"Generator"),_regeneratorDefine2(c,g,function(){return this}),_regeneratorDefine2(c,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(a,b,c,d){var f=Object.defineProperty;try{f({},"",{})}catch(a){f=0}_regeneratorDefine2=function _regeneratorDefine(a,b,c,d){function o(b,c){_regeneratorDefine2(a,b,function(a){return this._invoke(b,c,a)})}b?f?f(a,b,{value:c,enumerable:!d,configurable:!d,writable:!d}):a[b]=c:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(a,b,c,d)}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
|
|
2
2
|
* MeoCord Framework
|
|
3
3
|
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
4
|
*
|
|
@@ -14,4 +14,4 @@ function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
14
14
|
*
|
|
15
15
|
* You should have received a copy of the GNU General Public License
|
|
16
16
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/import{MessageFlagsBitField,SlashCommandBuilder}from"discord.js";import{Logger}from"../common/index.js";import{getCommandMap,getMessageHandlers,getReactionHandlers,mainContainer}from"../decorator/index.js";import{sample}from"lodash-es";import{EmbedUtil}from"../util/index.js";import wait from"../util/wait.util.js";import{CommandType}from"../enum/index.js";import{ReactionHandlerAction}from"../enum/controller.enum.js";export var MeoCordApp=/*#__PURE__*/function(){function MeoCordApp(a,b,c,d){var e=this;_classCallCheck(this,MeoCordApp),_defineProperty(this,"logger",new Logger(MeoCordApp.name)),_defineProperty(this,"isShuttingDown",!1),_defineProperty(this,"controllerInstancesCache",new Map),this.controllers=a,this.discordClient=b,this.discordToken=c,this.activities=d,this.bot=this.discordClient,process.on("SIGINT",function(){return e.gracefulShutdown()}),process.on("SIGTERM",function(){return e.gracefulShutdown()})}return _createClass(MeoCordApp,[{key:"start",value:function(){function start(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(){var a=this;return _regeneratorRuntime().wrap(function _callee6$(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,this.logger.log("Starting bot..."),this.bot.on("ready",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(b){for(;1;)switch(b.prev=b.next){case 0:return setInterval(function(){var b;null===(b=a.bot.user)||void 0===b||b.setActivity(sample(a.activities))},1e4),b.next=3,a.registerCommands();case 3:case"end":return b.stop()}},_callee)}))),this.bot.on("interactionCreate",/*#__PURE__*/function(){var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(b){return _regeneratorRuntime().wrap(function _callee2$(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,a.handleInteraction(b);case 2:case"end":return c.stop()}},_callee2)}));return function(a){return b.apply(this,arguments)}}()),this.bot.on("messageCreate",/*#__PURE__*/function(){var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(b){return _regeneratorRuntime().wrap(function _callee3$(c){for(;1;)switch(c.prev=c.next){case 0:return c.next=2,a.handleMessage(b);case 2:case"end":return c.stop()}},_callee3)}));return function(a){return b.apply(this,arguments)}}()),this.bot.on("messageReactionAdd",/*#__PURE__*/function(){var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(b,c){return _regeneratorRuntime().wrap(function _callee4$(d){for(;1;)switch(d.prev=d.next){case 0:return d.next=2,a.handleReaction(b,{user:c,action:ReactionHandlerAction.ADD});case 2:case"end":return d.stop()}},_callee4)}));return function(a,c){return b.apply(this,arguments)}}()),this.bot.on("messageReactionRemove",/*#__PURE__*/function(){var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(b,c){return _regeneratorRuntime().wrap(function _callee5$(d){for(;1;)switch(d.prev=d.next){case 0:return d.next=2,a.handleReaction(b,{user:c,action:ReactionHandlerAction.REMOVE});case 2:case"end":return d.stop()}},_callee5)}));return function(a,c){return b.apply(this,arguments)}}()),b.next=9,this.bot.login(this.discordToken);case 9:this.logger.log("Bot is online!"),b.next=15;break;case 12:b.prev=12,b.t0=b["catch"](0),this.logger.error("Error during bot startup:",b.t0);case 15:case"end":return b.stop()}},_callee6,this,[[0,12]])}));return start}()},{key:"registerCommands",value:function(){function registerCommands(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(){var a,b,c,d,e,f,g,h,i,j,k,l;return _regeneratorRuntime().wrap(function _callee7$(m){for(;1;)switch(m.prev=m.next){case 0:a=[],b=_createForOfIteratorHelper(this.controllers),m.prev=2,b.s();case 4:if((c=b.n()).done){m.next=19;break}d=c.value,e=getCommandMap(d),m.t0=_regeneratorRuntime().keys(e);case 8:if((m.t1=m.t0()).done){m.next=17;break}if(f=m.t1.value,g=e[f],Array.isArray(g)){m.next=13;break}return m.abrupt("continue",8);case 13:h=_createForOfIteratorHelper(g);try{for(h.s();!(i=h.n()).done;)j=i.value,k=j.builder,l=j.type,l in CommandType&&k&&a.push(k)}catch(a){h.e(a)}finally{h.f()}m.next=8;break;case 17:m.next=4;break;case 19:m.next=24;break;case 21:m.prev=21,m.t2=m["catch"](2),b.e(m.t2);case 24:return m.prev=24,b.f(),m.finish(24);case 27:if(m.prev=27,!this.bot.application){m.next=32;break}return m.next=31,this.bot.application.commands.set(a);case 31:this.logger.log("Registered ".concat(a.length," bot commands:"),a.map(function(a){if(a instanceof SlashCommandBuilder&&a.options.length){var b;return{name:a.name,subCommands:null===(b=a.toJSON().options)||void 0===b?void 0:b.map(function(a){return a.name})}}return{name:a.name}}));case 32:m.next=37;break;case 34:m.prev=34,m.t3=m["catch"](27),this.logger.error("Error during command registration:",m.t3);case 37:case"end":return m.stop()}},_callee7,this,[[2,21,24,27],[27,34]])}));return registerCommands}()},{key:"handleInteraction",value:function(){function handleInteraction(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(a){var b,c,d,e,f,g=this;return _regeneratorRuntime().wrap(function _callee8$(h){for(;1;)switch(h.prev=h.next){case 0:b=_createForOfIteratorHelper(this.controllers),h.prev=1,d=/*#__PURE__*/_regeneratorRuntime().mark(function _loop(){var b,d,e,f,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function _loop$(o){for(;1;)switch(o.prev=o.next){case 0:if(b=c.value,d=g.controllerInstancesCache.get(b),d||(d=mainContainer.get(b.constructor),g.controllerInstancesCache.set(b,d)),e=getCommandMap(d),e){o.next=6;break}return o.abrupt("return",0);case 6:if(f=void 0,h=void 0,a.isChatInputCommand()||a.isContextMenuCommand()?(h=a.commandName,f=e[h]):(a.isButton()||a.isStringSelectMenu()||a.isModalSubmit())&&(h=a.customId,i=Object.entries(e).find(function(b){var c=_slicedToArray(b,2),d=c[0],e=c[1];return!!Array.isArray(e)&&e.some(function(b){if(!b.regex||!h)return!1;var c=b.regex.exec(h);return null!==c&&void 0!==c&&c.groups?(a.dynamicParams=c.groups,!0):h===d})}),i&&(f=i[1])),!(f&&0<f.length)){o.next=34;break}if(j=f[0],k=j.methodName,l=j.type,o.prev=12,!(l===CommandType.SLASH&&a.isChatInputCommand()||l===CommandType.BUTTON&&a.isButton()||l===CommandType.SELECT_MENU&&a.isStringSelectMenu()||l===CommandType.CONTEXT_MENU&&a.isUserContextMenuCommand()||l===CommandType.CONTEXT_MENU&&a.isMessageContextMenuCommand()||l===CommandType.MODAL_SUBMIT&&a.isModalSubmit())){o.next=22;break}return g.logger.log("[INTERACTION]","[".concat(CommandType[l],"]"),"[".concat(k,"]")),m={},a.isChatInputCommand()&&a.options?m=a.options.data.reduce(function(a,b){return a[b.name]=b.value,a},{}):(a.isButton()||a.isStringSelectMenu())&&(m=a.dynamicParams||{}),o.next=19,d[k](a,m);case 19:return o.abrupt("return",{v:void 0});case 22:g.logger.debug(l,k,CommandType.BUTTON,a.isButton()),g.logger.warn("Interaction type mismatch for command \"".concat(h,"\". Interaction type: ").concat(a.type,"."));case 24:o.next=33;break;case 26:if(o.prev=26,o.t0=o["catch"](12),g.logger.error("Error executing command \"".concat(h,"\":"),o.t0),!a.isRepliable()){o.next=33;break}return n=EmbedUtil.createErrorEmbed("An error occurred while executing the command."),o.next=33,a.reply({embeds:[n],flags:MessageFlagsBitField.Flags.Ephemeral});case 33:return o.abrupt("return",{v:void 0});case 34:case"end":return o.stop()}},_loop,null,[[12,26]])}),b.s();case 4:if((c=b.n()).done){h.next=13;break}return h.delegateYield(d(),"t0",6);case 6:if(e=h.t0,0!==e){h.next=9;break}return h.abrupt("continue",11);case 9:if(!e){h.next=11;break}return h.abrupt("return",e.v);case 11:h.next=4;break;case 13:h.next=18;break;case 15:h.prev=15,h.t1=h["catch"](1),b.e(h.t1);case 18:return h.prev=18,b.f(),h.finish(18);case 21:if(!a.isRepliable()){h.next=25;break}return f=EmbedUtil.createErrorEmbed("Command not found!"),h.next=25,a.reply({embeds:[f],flags:MessageFlagsBitField.Flags.Ephemeral});case 25:case"end":return h.stop()}},_callee8,this,[[1,15,18,21]])}));return handleInteraction}()},{key:"handleMessage",value:function(){function handleMessage(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o;return _regeneratorRuntime().wrap(function _callee9$(p){for(;1;)switch(p.prev=p.next){case 0:if(!a.author.bot&&null!==(b=a.content)&&void 0!==b&&b.trim()){p.next=2;break}return p.abrupt("return");case 2:c=a.content.trim(),d=this.controllers.filter(function(a){var b=getMessageHandlers(a);return b.some(function(a){return!a.keyword||a.keyword===c})}),e=_createForOfIteratorHelper(d),p.prev=5,e.s();case 7:if((f=e.n()).done){p.next=40;break}g=f.value,h=this.controllerInstancesCache.get(g.constructor),h||(i=Reflect.getMetadata("inversify:container",g.constructor),h=i.get(g.constructor,{autobind:!0}),this.controllerInstancesCache.set(g.constructor,h)),j=getMessageHandlers(g),j=j.sort(function(c,a){return c.keyword&&!a.keyword?-1:!c.keyword&&a.keyword?1:0}),k=_createForOfIteratorHelper(j),p.prev=14,k.s();case 16:if((l=k.n()).done){p.next=30;break}if(m=l.value,n=m.keyword,o=m.method,n&&n!==c){p.next=28;break}return p.prev=20,p.next=23,h[o](a);case 23:p.next=28;break;case 25:p.prev=25,p.t0=p["catch"](20),this.logger.error("Error handling message \"".concat(c,"\" for method \"").concat(o,"\":"),p.t0);case 28:p.next=16;break;case 30:p.next=35;break;case 32:p.prev=32,p.t1=p["catch"](14),k.e(p.t1);case 35:return p.prev=35,k.f(),p.finish(35);case 38:p.next=7;break;case 40:p.next=45;break;case 42:p.prev=42,p.t2=p["catch"](5),e.e(p.t2);case 45:return p.prev=45,e.f(),p.finish(45);case 48:case"end":return p.stop()}},_callee9,this,[[5,42,45,48],[14,32,35,38],[20,25]])}));return handleMessage}()},{key:"handleReaction",value:function(){function handleReaction(b,c){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;return _regeneratorRuntime().wrap(function _callee10$(q){for(;1;)switch(q.prev=q.next){case 0:return c=b.user,d=b.action,q.next=3,a.message.fetch();case 3:e=this.controllers.filter(function(b){var c=getReactionHandlers(b);return c.some(function(b){return!b.emoji||b.emoji===a.emoji.name})}),f=_createForOfIteratorHelper(e),q.prev=5,f.s();case 7:if((g=f.n()).done){q.next=40;break}h=g.value,i=this.controllerInstancesCache.get(h.constructor),i||(j=Reflect.getMetadata("inversify:container",h.constructor),i=j.get(h.constructor,{autobind:!0}),this.controllerInstancesCache.set(h.constructor,i)),k=getReactionHandlers(h),k=k.sort(function(c,a){return c.emoji&&!a.emoji?-1:!c.emoji&&a.emoji?1:0}),l=_createForOfIteratorHelper(k),q.prev=14,l.s();case 16:if((m=l.n()).done){q.next=30;break}if(n=m.value,o=n.emoji,p=n.method,o&&o!==a.emoji.name){q.next=28;break}return q.prev=20,q.next=23,i[p](a,{user:c,action:d});case 23:q.next=28;break;case 25:q.prev=25,q.t0=q["catch"](20),this.logger.error("Error handling reaction \"".concat(a.emoji.name,"\" for method \"").concat(p,"\":"),q.t0);case 28:q.next=16;break;case 30:q.next=35;break;case 32:q.prev=32,q.t1=q["catch"](14),l.e(q.t1);case 35:return q.prev=35,l.f(),q.finish(35);case 38:q.next=7;break;case 40:q.next=45;break;case 42:q.prev=42,q.t2=q["catch"](5),f.e(q.t2);case 45:return q.prev=45,f.f(),q.finish(45);case 48:case"end":return q.stop()}},_callee10,this,[[5,42,45,48],[14,32,35,38],[20,25]])}));return handleReaction}()},{key:"gracefulShutdown",value:function(){function gracefulShutdown(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(){return _regeneratorRuntime().wrap(function _callee11$(a){for(;1;)switch(a.prev=a.next){case 0:if(!this.bot||this.isShuttingDown){a.next=19;break}return a.prev=1,this.isShuttingDown=!0,this.logger.log("Shutting down bot..."),this.bot.removeAllListeners(),a.next=7,this.bot.destroy();case 7:return this.logger.log("Bot has shut down"),a.next=10,wait(100);case 10:process.exit(0),a.next=19;break;case 13:return a.prev=13,a.t0=a["catch"](1),this.logger.error("Error during shutdown:",a.t0),a.next=18,wait(100);case 18:process.exit(0);case 19:case"end":return a.stop()}},_callee11,this,[[1,13]])}));return gracefulShutdown}()}])}();
|
|
17
|
+
*/import{MessageFlagsBitField,SlashCommandBuilder}from"discord.js";import{Logger}from"../common/index.js";import{getCommandMap,getMessageHandlers,getReactionHandlers,mainContainer}from"../decorator/index.js";import{sample}from"lodash-es";import{EmbedUtil}from"../util/index.js";import wait from"../util/wait.util.js";import{CommandType}from"../enum/index.js";import{ReactionHandlerAction}from"../enum/controller.enum.js";export var MeoCordApp=/*#__PURE__*/function(){function MeoCordApp(a,b,c,d){var e=this;_classCallCheck(this,MeoCordApp),_defineProperty(this,"logger",new Logger(MeoCordApp.name)),_defineProperty(this,"isShuttingDown",!1),_defineProperty(this,"controllerInstancesCache",new Map),this.controllers=a,this.discordClient=b,this.discordToken=c,this.activities=d,this.bot=this.discordClient,process.on("SIGINT",function(){return e.gracefulShutdown()}),process.on("SIGTERM",function(){return e.gracefulShutdown()})}return _createClass(MeoCordApp,[{key:"start",value:function(){function start(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(){var a,b=this;return _regenerator().w(function(c){for(;1;)switch(c.p=c.n){case 0:return c.p=0,this.logger.log("Starting bot..."),this.bot.on("clientReady",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(){return _regenerator().w(function(a){for(;1;)switch(a.n){case 0:return setInterval(function(){var a;null===(a=b.bot.user)||void 0===a||a.setActivity(sample(b.activities))},1e4),a.n=1,b.registerCommands();case 1:return a.a(2)}},_callee)}))),this.bot.on("interactionCreate",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(a){return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:return c.n=1,b.handleInteraction(a);case 1:return c.a(2)}},_callee2)}));return function(b){return a.apply(this,arguments)}}()),this.bot.on("messageCreate",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(a){return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:return c.n=1,b.handleMessage(a);case 1:return c.a(2)}},_callee3)}));return function(b){return a.apply(this,arguments)}}()),this.bot.on("messageReactionAdd",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(a,c){return _regenerator().w(function(d){for(;1;)switch(d.n){case 0:return d.n=1,b.handleReaction(a,{user:c,action:ReactionHandlerAction.ADD});case 1:return d.a(2)}},_callee4)}));return function(b,c){return a.apply(this,arguments)}}()),this.bot.on("messageReactionRemove",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(a,c){return _regenerator().w(function(d){for(;1;)switch(d.n){case 0:return d.n=1,b.handleReaction(a,{user:c,action:ReactionHandlerAction.REMOVE});case 1:return d.a(2)}},_callee5)}));return function(b,c){return a.apply(this,arguments)}}()),c.n=1,this.bot.login(this.discordToken);case 1:this.logger.log("Bot is online!"),c.n=3;break;case 2:c.p=2,a=c.v,this.logger.error("Error during bot startup:",a);case 3:return c.a(2)}},_callee6,this,[[0,2]])}));return start}()},{key:"registerCommands",value:function(){function registerCommands(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;return _regenerator().w(function(q){for(;1;)switch(q.p=q.n){case 0:a=[],b=_createForOfIteratorHelper(this.controllers),q.p=1,b.s();case 2:if((c=b.n()).done){q.n=6;break}d=c.value,e=getCommandMap(d),m=_regeneratorKeys(e);case 3:if((n=m()).done){q.n=5;break}if(f=n.value,g=e[f],Array.isArray(g)){q.n=4;break}return q.a(3,3);case 4:h=_createForOfIteratorHelper(g);try{for(h.s();!(i=h.n()).done;)j=i.value,k=j.builder,l=j.type,l in CommandType&&k&&a.push(k)}catch(a){h.e(a)}finally{h.f()}q.n=3;break;case 5:q.n=2;break;case 6:q.n=8;break;case 7:q.p=7,o=q.v,b.e(o);case 8:return q.p=8,b.f(),q.f(8);case 9:if(q.p=9,!this.bot.application){q.n=11;break}return q.n=10,this.bot.application.commands.set(a);case 10:this.logger.log("Registered ".concat(a.length," bot commands:"),a.map(function(a){if(a instanceof SlashCommandBuilder&&a.options.length){var b;return{name:a.name,subCommands:null===(b=a.toJSON().options)||void 0===b?void 0:b.map(function(a){return a.name})}}return{name:a.name}}));case 11:q.n=13;break;case 12:q.p=12,p=q.v,this.logger.error("Error during command registration:",p);case 13:return q.a(2)}},_callee7,this,[[9,12],[1,7,8,9]])}));return registerCommands}()},{key:"handleInteraction",value:function(){function handleInteraction(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(a){var b,c,d,e,f,g,h=this;return _regenerator().w(function(i){for(;1;)switch(i.p=i.n){case 0:b=_createForOfIteratorHelper(this.controllers),i.p=1,d=/*#__PURE__*/_regenerator().m(function _loop(){var b,d,e,f,g,i,j,k,l,m,n,o;return _regenerator().w(function(p){for(;1;)switch(p.p=p.n){case 0:if(b=c.value,d=h.controllerInstancesCache.get(b),d||(d=mainContainer.get(b.constructor),h.controllerInstancesCache.set(b,d)),e=getCommandMap(d),e){p.n=1;break}return p.a(2,0);case 1:if(f=void 0,g=void 0,a.isChatInputCommand()||a.isContextMenuCommand()?(g=a.commandName,f=e[g]):(a.isButton()||a.isStringSelectMenu()||a.isModalSubmit())&&(g=a.customId,i=Object.entries(e).find(function(b){var c=_slicedToArray(b,2),d=c[0],e=c[1];return!!Array.isArray(e)&&e.some(function(b){if(!b.regex||!g)return!1;var c=b.regex.exec(g);return null!==c&&void 0!==c&&c.groups?(a.dynamicParams=c.groups,!0):g===d})}),i&&(f=i[1])),!(f&&0<f.length)){p.n=8;break}if(j=f[0],k=j.methodName,l=j.type,p.p=2,!(l===CommandType.SLASH&&a.isChatInputCommand()||l===CommandType.BUTTON&&a.isButton()||l===CommandType.SELECT_MENU&&a.isStringSelectMenu()||l===CommandType.CONTEXT_MENU&&a.isUserContextMenuCommand()||l===CommandType.CONTEXT_MENU&&a.isMessageContextMenuCommand()||l===CommandType.MODAL_SUBMIT&&a.isModalSubmit())){p.n=4;break}return h.logger.log("[INTERACTION]","[".concat(CommandType[l],"]"),"[".concat(k,"]")),m={},a.isChatInputCommand()&&a.options?m=a.options.data.reduce(function(a,b){return a[b.name]=b.value,a},{}):(a.isButton()||a.isStringSelectMenu())&&(m=a.dynamicParams||{}),p.n=3,d[k](a,m);case 3:return p.a(2,{v:void 0});case 4:h.logger.debug(l,k,CommandType.BUTTON,a.isButton()),h.logger.warn("Interaction type mismatch for command \"".concat(g,"\". Interaction type: ").concat(a.type,"."));case 5:p.n=7;break;case 6:if(p.p=6,o=p.v,h.logger.error("Error executing command \"".concat(g,"\":"),o),!a.isRepliable()){p.n=7;break}return n=EmbedUtil.createErrorEmbed("An error occurred while executing the command."),p.n=7,a.reply({embeds:[n],flags:MessageFlagsBitField.Flags.Ephemeral});case 7:return p.a(2,{v:void 0});case 8:return p.a(2)}},_loop,null,[[2,6]])}),b.s();case 2:if((c=b.n()).done){i.n=6;break}return i.d(_regeneratorValues(d()),3);case 3:if(e=i.v,0!==e){i.n=4;break}return i.a(3,5);case 4:if(!e){i.n=5;break}return i.a(2,e.v);case 5:i.n=2;break;case 6:i.n=8;break;case 7:i.p=7,g=i.v,b.e(g);case 8:return i.p=8,b.f(),i.f(8);case 9:if(!a.isRepliable()){i.n=10;break}return f=EmbedUtil.createErrorEmbed("Command not found!"),i.n=10,a.reply({embeds:[f],flags:MessageFlagsBitField.Flags.Ephemeral});case 10:return i.a(2)}},_callee8,this,[[1,7,8,9]])}));return handleInteraction}()},{key:"handleMessage",value:function(){function handleMessage(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;return _regenerator().w(function(s){for(;1;)switch(s.p=s.n){case 0:if(!a.author.bot&&null!==(b=a.content)&&void 0!==b&&b.trim()){s.n=1;break}return s.a(2);case 1:c=a.content.trim(),d=this.controllers.filter(function(a){var b=getMessageHandlers(a);return b.some(function(a){return!a.keyword||a.keyword===c})}),e=_createForOfIteratorHelper(d),s.p=2,e.s();case 3:if((f=e.n()).done){s.n=14;break}g=f.value,h=this.controllerInstancesCache.get(g.constructor),h||(i=Reflect.getMetadata("inversify:container",g.constructor),h=i.get(g.constructor,{autobind:!0}),this.controllerInstancesCache.set(g.constructor,h)),j=getMessageHandlers(g),j=j.sort(function(c,a){return c.keyword&&!a.keyword?-1:!c.keyword&&a.keyword?1:0}),k=_createForOfIteratorHelper(j),s.p=4,k.s();case 5:if((l=k.n()).done){s.n=10;break}if(m=l.value,n=m.keyword,o=m.method,n&&n!==c){s.n=9;break}return s.p=6,s.n=7,h[o](a);case 7:s.n=9;break;case 8:s.p=8,p=s.v,this.logger.error("Error handling message \"".concat(c,"\" for method \"").concat(o,"\":"),p);case 9:s.n=5;break;case 10:s.n=12;break;case 11:s.p=11,q=s.v,k.e(q);case 12:return s.p=12,k.f(),s.f(12);case 13:s.n=3;break;case 14:s.n=16;break;case 15:s.p=15,r=s.v,e.e(r);case 16:return s.p=16,e.f(),s.f(16);case 17:return s.a(2)}},_callee9,this,[[6,8],[4,11,12,13],[2,15,16,17]])}));return handleMessage}()},{key:"handleReaction",value:function(){function handleReaction(b,c){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;return _regenerator().w(function(t){for(;1;)switch(t.p=t.n){case 0:return c=b.user,d=b.action,t.n=1,a.message.fetch();case 1:e=this.controllers.filter(function(b){var c=getReactionHandlers(b);return c.some(function(b){return!b.emoji||b.emoji===a.emoji.name})}),f=_createForOfIteratorHelper(e),t.p=2,f.s();case 3:if((g=f.n()).done){t.n=14;break}h=g.value,i=this.controllerInstancesCache.get(h.constructor),i||(j=Reflect.getMetadata("inversify:container",h.constructor),i=j.get(h.constructor,{autobind:!0}),this.controllerInstancesCache.set(h.constructor,i)),k=getReactionHandlers(h),k=k.sort(function(c,a){return c.emoji&&!a.emoji?-1:!c.emoji&&a.emoji?1:0}),l=_createForOfIteratorHelper(k),t.p=4,l.s();case 5:if((m=l.n()).done){t.n=10;break}if(n=m.value,o=n.emoji,p=n.method,o&&o!==a.emoji.name){t.n=9;break}return t.p=6,t.n=7,i[p](a,{user:c,action:d});case 7:t.n=9;break;case 8:t.p=8,q=t.v,this.logger.error("Error handling reaction \"".concat(a.emoji.name,"\" for method \"").concat(p,"\":"),q);case 9:t.n=5;break;case 10:t.n=12;break;case 11:t.p=11,r=t.v,l.e(r);case 12:return t.p=12,l.f(),t.f(12);case 13:t.n=3;break;case 14:t.n=16;break;case 15:t.p=15,s=t.v,f.e(s);case 16:return t.p=16,f.f(),t.f(16);case 17:return t.a(2)}},_callee0,this,[[6,8],[4,11,12,13],[2,15,16,17]])}));return handleReaction}()},{key:"gracefulShutdown",value:function(){function gracefulShutdown(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(){var a;return _regenerator().w(function(b){for(;1;)switch(b.p=b.n){case 0:if(!this.bot||this.isShuttingDown){b.n=6;break}return b.p=1,this.isShuttingDown=!0,this.logger.log("Shutting down bot..."),this.bot.removeAllListeners(),b.n=2,this.bot.destroy();case 2:return this.logger.log("Bot has shut down"),b.n=3,wait(100);case 3:process.exit(0),b.n=6;break;case 4:return b.p=4,a=b.v,this.logger.error("Error during shutdown:",a),b.n=5,wait(100);case 5:process.exit(0);case 6:return b.a(2)}},_callee1,this,[[1,4]])}));return gracefulShutdown}()}])}();
|
|
@@ -26,7 +26,7 @@ export declare const mainContainer: Container;
|
|
|
26
26
|
* @param {Object} options - The decorator options.
|
|
27
27
|
* @param {ServiceIdentifier[]} options.controllers - The list of controllers to be registered.
|
|
28
28
|
* @param {ClientOptions} options.clientOptions - The Discord client options for initializing the bot.
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {ActivityOptions[]} [options.activities] - Optional activities for the bot.
|
|
30
30
|
* @param {ServiceIdentifier[]} [options.services] - Optional services to be registered.
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
@@ -31,7 +31,7 @@ function _construct(a,b,c){if(_isNativeReflectConstruct())return Reflect.constru
|
|
|
31
31
|
* @param {Object} options - The decorator options.
|
|
32
32
|
* @param {ServiceIdentifier[]} options.controllers - The list of controllers to be registered.
|
|
33
33
|
* @param {ClientOptions} options.clientOptions - The Discord client options for initializing the bot.
|
|
34
|
-
* @param {
|
|
34
|
+
* @param {ActivityOptions[]} [options.activities] - Optional activities for the bot.
|
|
35
35
|
* @param {ServiceIdentifier[]} [options.services] - Optional services to be registered.
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _regenerator(){function i(a,d,f,g){var h=d&&d.prototype instanceof Generator?d:Generator,c=Object.create(h.prototype);return _regeneratorDefine2(c,"_invoke",function(a,g,h){function d(a,c){for(m=a,q=c,e=0;!v&&s&&!f&&e<t.length;e++){var f,g=t[e],h=p.p,k=g[2];3<a?(f=k===c)&&(q=g[(m=g[4])?5:(m=3,3)],g[4]=g[5]=b):g[0]<=h&&((f=2>a&&h<g[1])?(m=0,p.v=c,p.n=g[1]):h<k&&(f=3>a||g[0]>c||c>k)&&(g[4]=a,g[5]=c,p.n=k,m=0))}if(f||1<a)return j;throw v=!0,c}var k,m,q,s=0,t=h||[],v=!1,p={p:0,n:0,v:b,a:d,f:d.bind(b,4),d:function d(a,c){return k=a,m=0,q=b,p.n=c,j}};return function(c,f,h){if(1<s)throw TypeError("Generator is already running");for(v&&1===f&&d(f,h),m=f,q=h;(e=2>m?b:q)||!v;){k||(m?3>m?(1<m&&(p.n=-1),d(m,q)):p.n=q:p.v=q);try{if(s=2,k){if(m||(c="next"),e=k[c]){if(!(e=e.call(k,q)))throw TypeError("iterator result is not an object");if(!e.done)return e;q=e.value,2>m&&(m=0)}else 1===m&&(e=k["return"])&&e.call(k),2>m&&(q=TypeError("The iterator does not provide a '"+c+"' method"),m=1);k=b}else if((e=(v=0>p.n)?q:a.call(g,p))!==j)break}catch(a){k=b,m=1,q=a}finally{s=1}}return{value:e,done:v}}}(a,f,g),!0),c}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function f(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(a,h,"GeneratorFunction")),a.prototype=Object.create(c),a}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var b,e,d="function"==typeof Symbol?Symbol:{},g=d.iterator||"@@iterator",h=d.toStringTag||"@@toStringTag",j={};e=Object.getPrototypeOf;var a=[][g]?e(e([][g]())):(_regeneratorDefine2(e={},g,function(){return this}),e),c=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(a);return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(c,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,h,"GeneratorFunction"),_regeneratorDefine2(c),_regeneratorDefine2(c,h,"Generator"),_regeneratorDefine2(c,g,function(){return this}),_regeneratorDefine2(c,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(a,b,c,d){var f=Object.defineProperty;try{f({},"",{})}catch(a){f=0}_regeneratorDefine2=function _regeneratorDefine(a,b,c,d){function o(b,c){_regeneratorDefine2(a,b,function(a){return this._invoke(b,c,a)})}b?f?f(a,b,{value:c,enumerable:!d,configurable:!d,writable:!d}):a[b]=c:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(a,b,c,d)}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}/**
|
|
2
2
|
* MeoCord Framework
|
|
3
3
|
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
4
|
*
|
|
@@ -78,4 +78,4 @@ var b=Reflect.getMetadata("design:paramtypes",a)||[];b.forEach(function(a){mainC
|
|
|
78
78
|
* ```
|
|
79
79
|
*/export function UseGuard(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return function(a,c,d){var e=d.value;// TypeScript: Enforce that the first argument is an Interaction
|
|
80
80
|
// Store guard metadata for later access (if needed)
|
|
81
|
-
d.value=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
81
|
+
d.value=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(){var a,d,f,g,h,i,j,k,l,m,n,o=arguments;return _regenerator().w(function(p){for(;1;)switch(p.n){case 0:for(a=o.length,d=Array(a),f=0;f<a;f++)d[f]=o[f];if(d[0]instanceof BaseInteraction){p.n=1;break}throw new Error("The first argument of ".concat(c+""," must be an instance of Interaction."));case 1:g=0,h=b;case 2:if(!(g<h.length)){p.n=6;break}if(j=h[g],k=void 0,isGuardWithParams(j)?(l=j.provide,m=j.params,k=mainContainer.get(l,{autobind:!0}),Object.assign(k,m)):k=mainContainer.get(j,{autobind:!0}),k.canActivate){p.n=3;break}throw new Error("Guard ".concat(j.constructor.name," applied to ").concat(c+""," does not have a valid canActivate method."));case 3:return p.n=4,(i=k).canActivate.apply(i,d);case 4:if(n=p.v,n){p.n=5;break}return p.a(2);case 5:g++,p.n=2;break;case 6:return p.a(2,e.apply(this,d))}},_callee,this)})),Reflect.defineMetadata("guards",b,a,c)}}
|
package/dist/util/common.util.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _regenerator(){function i(a,d,f,g){var h=d&&d.prototype instanceof Generator?d:Generator,c=Object.create(h.prototype);return _regeneratorDefine2(c,"_invoke",function(a,g,h){function d(a,c){for(m=a,q=c,e=0;!v&&s&&!f&&e<t.length;e++){var f,g=t[e],h=p.p,k=g[2];3<a?(f=k===c)&&(q=g[(m=g[4])?5:(m=3,3)],g[4]=g[5]=b):g[0]<=h&&((f=2>a&&h<g[1])?(m=0,p.v=c,p.n=g[1]):h<k&&(f=3>a||g[0]>c||c>k)&&(g[4]=a,g[5]=c,p.n=k,m=0))}if(f||1<a)return j;throw v=!0,c}var k,m,q,s=0,t=h||[],v=!1,p={p:0,n:0,v:b,a:d,f:d.bind(b,4),d:function d(a,c){return k=a,m=0,q=b,p.n=c,j}};return function(c,f,h){if(1<s)throw TypeError("Generator is already running");for(v&&1===f&&d(f,h),m=f,q=h;(e=2>m?b:q)||!v;){k||(m?3>m?(1<m&&(p.n=-1),d(m,q)):p.n=q:p.v=q);try{if(s=2,k){if(m||(c="next"),e=k[c]){if(!(e=e.call(k,q)))throw TypeError("iterator result is not an object");if(!e.done)return e;q=e.value,2>m&&(m=0)}else 1===m&&(e=k["return"])&&e.call(k),2>m&&(q=TypeError("The iterator does not provide a '"+c+"' method"),m=1);k=b}else if((e=(v=0>p.n)?q:a.call(g,p))!==j)break}catch(a){k=b,m=1,q=a}finally{s=1}}return{value:e,done:v}}}(a,f,g),!0),c}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function f(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(a,h,"GeneratorFunction")),a.prototype=Object.create(c),a}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var b,e,d="function"==typeof Symbol?Symbol:{},g=d.iterator||"@@iterator",h=d.toStringTag||"@@toStringTag",j={};e=Object.getPrototypeOf;var a=[][g]?e(e([][g]())):(_regeneratorDefine2(e={},g,function(){return this}),e),c=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(a);return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(c,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,h,"GeneratorFunction"),_regeneratorDefine2(c),_regeneratorDefine2(c,h,"Generator"),_regeneratorDefine2(c,g,function(){return this}),_regeneratorDefine2(c,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(a,b,c,d){var f=Object.defineProperty;try{f({},"",{})}catch(a){f=0}_regeneratorDefine2=function _regeneratorDefine(a,b,c,d){function o(b,c){_regeneratorDefine2(a,b,function(a){return this._invoke(b,c,a)})}b?f?f(a,b,{value:c,enumerable:!d,configurable:!d,writable:!d}):a[b]=c:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(a,b,c,d)}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}/**
|
|
2
2
|
* MeoCord Framework
|
|
3
3
|
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
4
|
*
|
|
@@ -35,4 +35,4 @@ c=path.join(c,"..")}throw new Error("Module ".concat(a," not found in node_modul
|
|
|
35
35
|
* Assigns the provided mode to `process.env.NODE_ENV` if it hasn't been set already.
|
|
36
36
|
*
|
|
37
37
|
* @param {'production' | 'development'} mode - The desired environment mode.
|
|
38
|
-
*/function _compileAndValidateConfig(){return _compileAndValidateConfig=_asyncToGenerator(/*#__PURE__*/
|
|
38
|
+
*/function _compileAndValidateConfig(){return _compileAndValidateConfig=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(){var a,b;return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:if(a=path.resolve(process.cwd(),"meocord.config.ts"),fs.existsSync(a)){c.n=2;break}return console.error(chalk.red("Configuration file \"meocord.config.ts\" is missing!")),c.n=1,wait(100);case 1:process.exit(1);case 2:return c.n=3,compileMeoCordConfig();case 3:if(b=loadMeoCordConfig(),null!==b&&void 0!==b&&b.discordToken){c.n=5;break}return console.error(chalk.red("Discord token is missing!")),c.n=4,wait(100);case 4:process.exit(1);case 5:return c.a(2)}},_callee)})),_compileAndValidateConfig.apply(this,arguments)}export function setEnvironment(a){process.env.NODE_ENV||(process.env.NODE_ENV=a)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _regenerator(){function i(a,d,f,g){var h=d&&d.prototype instanceof Generator?d:Generator,c=Object.create(h.prototype);return _regeneratorDefine2(c,"_invoke",function(a,g,h){function d(a,c){for(m=a,q=c,e=0;!v&&s&&!f&&e<t.length;e++){var f,g=t[e],h=p.p,k=g[2];3<a?(f=k===c)&&(q=g[(m=g[4])?5:(m=3,3)],g[4]=g[5]=b):g[0]<=h&&((f=2>a&&h<g[1])?(m=0,p.v=c,p.n=g[1]):h<k&&(f=3>a||g[0]>c||c>k)&&(g[4]=a,g[5]=c,p.n=k,m=0))}if(f||1<a)return j;throw v=!0,c}var k,m,q,s=0,t=h||[],v=!1,p={p:0,n:0,v:b,a:d,f:d.bind(b,4),d:function d(a,c){return k=a,m=0,q=b,p.n=c,j}};return function(c,f,h){if(1<s)throw TypeError("Generator is already running");for(v&&1===f&&d(f,h),m=f,q=h;(e=2>m?b:q)||!v;){k||(m?3>m?(1<m&&(p.n=-1),d(m,q)):p.n=q:p.v=q);try{if(s=2,k){if(m||(c="next"),e=k[c]){if(!(e=e.call(k,q)))throw TypeError("iterator result is not an object");if(!e.done)return e;q=e.value,2>m&&(m=0)}else 1===m&&(e=k["return"])&&e.call(k),2>m&&(q=TypeError("The iterator does not provide a '"+c+"' method"),m=1);k=b}else if((e=(v=0>p.n)?q:a.call(g,p))!==j)break}catch(a){k=b,m=1,q=a}finally{s=1}}return{value:e,done:v}}}(a,f,g),!0),c}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function f(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(a,h,"GeneratorFunction")),a.prototype=Object.create(c),a}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var b,e,d="function"==typeof Symbol?Symbol:{},g=d.iterator||"@@iterator",h=d.toStringTag||"@@toStringTag",j={};e=Object.getPrototypeOf;var a=[][g]?e(e([][g]())):(_regeneratorDefine2(e={},g,function(){return this}),e),c=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(a);return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(c,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,h,"GeneratorFunction"),_regeneratorDefine2(c),_regeneratorDefine2(c,h,"Generator"),_regeneratorDefine2(c,g,function(){return this}),_regeneratorDefine2(c,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(a,b,c,d){var f=Object.defineProperty;try{f({},"",{})}catch(a){f=0}_regeneratorDefine2=function _regeneratorDefine(a,b,c,d){function o(b,c){_regeneratorDefine2(a,b,function(a){return this._invoke(b,c,a)})}b?f?f(a,b,{value:c,enumerable:!d,configurable:!d,writable:!d}):a[b]=c:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(a,b,c,d)}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}/**
|
|
2
2
|
* MeoCord Framework
|
|
3
3
|
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
4
|
*
|
|
@@ -47,4 +47,4 @@ function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
47
47
|
* Ensures that the script is being run from the root directory of the project.
|
|
48
48
|
* Validates the existence of required files, dependencies, and configuration.
|
|
49
49
|
* If validation fails, it logs an error message and terminates the process.
|
|
50
|
-
*/export function ensureReady(){return _ensureReady.apply(this,arguments)}function _ensureReady(){return _ensureReady=_asyncToGenerator(/*#__PURE__*/
|
|
50
|
+
*/export function ensureReady(){return _ensureReady.apply(this,arguments)}function _ensureReady(){return _ensureReady=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(){var a,b,c,d,e,f,g,h;return _regenerator().w(function(i){for(;1;)switch(i.p=i.n){case 0:if(a=findModulePackageDir("meocord"),b=path.resolve(process.cwd(),"package.json"),i.p=1,fs.existsSync(b)){i.n=2;break}throw new Error("package.json not found. This script must be run from the root directory of the project.");case 2:if(a){i.n=3;break}throw new Error("Cannot locate the \"MeoCord\" package directory.");case 3:if(c=JSON.parse(fs.readFileSync(b,"utf-8")),d=c.dependencies,e=path.join(a,"package.json"),f=JSON.parse(fs.readFileSync(e,"utf-8")),g=f.name,null!==d&&void 0!==d&&d[g]){i.n=4;break}throw new Error("The package.json does not list \"MeoCord\" as a dependency. Ensure you are in the root directory.");case 4:i.n=7;break;case 5:return i.p=5,h=i.v,console.error(chalk.red(h instanceof Error?h.message:"An unknown error occurred during validation.")),i.n=6,wait(100);case 6:process.exit(1);case 7:return i.a(2)}},_callee,null,[[1,5]])})),_ensureReady.apply(this,arguments)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _regenerator(){function i(a,d,f,g){var h=d&&d.prototype instanceof Generator?d:Generator,c=Object.create(h.prototype);return _regeneratorDefine2(c,"_invoke",function(a,g,h){function d(a,c){for(m=a,q=c,e=0;!v&&s&&!f&&e<t.length;e++){var f,g=t[e],h=p.p,k=g[2];3<a?(f=k===c)&&(q=g[(m=g[4])?5:(m=3,3)],g[4]=g[5]=b):g[0]<=h&&((f=2>a&&h<g[1])?(m=0,p.v=c,p.n=g[1]):h<k&&(f=3>a||g[0]>c||c>k)&&(g[4]=a,g[5]=c,p.n=k,m=0))}if(f||1<a)return j;throw v=!0,c}var k,m,q,s=0,t=h||[],v=!1,p={p:0,n:0,v:b,a:d,f:d.bind(b,4),d:function d(a,c){return k=a,m=0,q=b,p.n=c,j}};return function(c,f,h){if(1<s)throw TypeError("Generator is already running");for(v&&1===f&&d(f,h),m=f,q=h;(e=2>m?b:q)||!v;){k||(m?3>m?(1<m&&(p.n=-1),d(m,q)):p.n=q:p.v=q);try{if(s=2,k){if(m||(c="next"),e=k[c]){if(!(e=e.call(k,q)))throw TypeError("iterator result is not an object");if(!e.done)return e;q=e.value,2>m&&(m=0)}else 1===m&&(e=k["return"])&&e.call(k),2>m&&(q=TypeError("The iterator does not provide a '"+c+"' method"),m=1);k=b}else if((e=(v=0>p.n)?q:a.call(g,p))!==j)break}catch(a){k=b,m=1,q=a}finally{s=1}}return{value:e,done:v}}}(a,f,g),!0),c}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function f(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(a,h,"GeneratorFunction")),a.prototype=Object.create(c),a}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var b,e,d="function"==typeof Symbol?Symbol:{},g=d.iterator||"@@iterator",h=d.toStringTag||"@@toStringTag",j={};e=Object.getPrototypeOf;var a=[][g]?e(e([][g]())):(_regeneratorDefine2(e={},g,function(){return this}),e),c=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(a);return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(c,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,h,"GeneratorFunction"),_regeneratorDefine2(c),_regeneratorDefine2(c,h,"Generator"),_regeneratorDefine2(c,g,function(){return this}),_regeneratorDefine2(c,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(a,b,c,d){var f=Object.defineProperty;try{f({},"",{})}catch(a){f=0}_regeneratorDefine2=function _regeneratorDefine(a,b,c,d){function o(b,c){_regeneratorDefine2(a,b,function(a){return this._invoke(b,c,a)})}b?f?f(a,b,{value:c,enumerable:!d,configurable:!d,writable:!d}):a[b]=c:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(a,b,c,d)}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}/**
|
|
2
2
|
* MeoCord Framework
|
|
3
3
|
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
|
|
4
4
|
*
|
|
@@ -14,7 +14,7 @@ function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright
|
|
|
14
14
|
*
|
|
15
15
|
* You should have received a copy of the GNU General Public License
|
|
16
16
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/import webpack from"webpack";import
|
|
17
|
+
*/import webpack from"webpack";import{TsconfigPathsPlugin}from"tsconfig-paths-webpack-plugin";import path from"path";import{createRequire}from"module";import{existsSync,mkdirSync,readFileSync,rmSync,writeFileSync}from"fs";import{findModulePackageDir}from"./common.util.js";import{fixJSON}from"./json.util.js";import nodeExternals from"webpack-node-externals";var require=createRequire(import.meta.url),TEMP_OUTPUT_DIR=path.resolve(process.cwd(),"dist",".meocord-temp"),_removeUndefinedKeys=function removeUndefinedKeys(a){Object.keys(a).forEach(function(b){a[b]===void 0?delete a[b]:"object"===_typeof(a[b])&&null!==a[b]&&_removeUndefinedKeys(a[b])})},createBuildTsConfig=function createBuildTsConfig(a){var b;return{compilerOptions:{tsBuildInfoFile:null,strict:!0,module:"NodeNext",target:"ESNext",moduleResolution:"NodeNext",esModuleInterop:!0,resolveJsonModule:!0,allowSyntheticDefaultImports:!0,sourceMap:!1,baseUrl:".",rootDir:".",outDir:TEMP_OUTPUT_DIR,paths:null===a||void 0===a||null===(b=a.compilerOptions)||void 0===b?void 0:b.paths,skipLibCheck:!0,noImplicitAny:!1,forceConsistentCasingInFileNames:!0},include:["meocord.config.ts"]}},createWebpackConfig=function createWebpackConfig(a){return{mode:"production"===process.env.NODE_ENV?"production":"development",entry:"meocord.config.ts",target:"node",externals:[nodeExternals({importType:"module"})],experiments:{outputModule:!0},module:{rules:[{test:/\.ts$/,use:{loader:"swc-loader",options:{jsc:{parser:{syntax:"typescript",tsx:!1,decorators:!0},transform:{decoratorMetadata:!0,legacyDecorator:!0}}}},exclude:/node_modules/}]},resolve:{plugins:[new TsconfigPathsPlugin({configFile:a})],extensions:[".ts",".js"]},output:{filename:"meocord.config.js",path:TEMP_OUTPUT_DIR,publicPath:TEMP_OUTPUT_DIR,library:{type:"module"}}}};/**
|
|
18
18
|
* Recursively removes undefined keys from an object
|
|
19
19
|
*//**
|
|
20
20
|
* Creates the build TypeScript configuration
|
|
@@ -30,4 +30,4 @@ function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright
|
|
|
30
30
|
* and returns it as a JavaScript object.
|
|
31
31
|
*
|
|
32
32
|
* @returns {MeoCordConfig | undefined} The loaded configuration object, or undefined if loading fails.
|
|
33
|
-
*/function _compileMeoCordConfig(){return _compileMeoCordConfig=_asyncToGenerator(/*#__PURE__*/
|
|
33
|
+
*/function _compileMeoCordConfig(){return _compileMeoCordConfig=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(){var a,b,c,d,e,f,g,h;return _regenerator().w(function(i){for(;1;)switch(i.p=i.n){case 0:if(a=findModulePackageDir("meocord"),a){i.n=1;break}return i.a(2,!1);case 1:if(b=path.resolve(process.cwd(),"tsconfig.build.json"),c=path.resolve(process.cwd(),"tsconfig.json"),existsSync(c)){i.n=2;break}throw new Error("tsconfig.json not found in: ".concat(process.cwd()));case 2:if(d=JSON.parse(fixJSON(readFileSync(c,"utf-8"))),e=createBuildTsConfig(d),_removeUndefinedKeys(e),writeFileSync(b,fixJSON(JSON.stringify(e))),existsSync(b)){i.n=3;break}return console.error("[MeoCord] tsconfig.build.json file not found: ".concat(b)),i.a(2,!1);case 3:return existsSync(TEMP_OUTPUT_DIR)||mkdirSync(TEMP_OUTPUT_DIR,{recursive:!0}),f=createWebpackConfig(b),g=webpack(f),i.p=4,i.n=5,new Promise(function(a,b){return g?void g.run(function(c,d){return c?(console.error("Build encountered an error: ".concat(c.message)),b("Build encountered an error: ".concat(c.message))):null!==d&&void 0!==d&&d.hasErrors()?(console.error("Build failed due to errors in the compilation process:",d.compilation.errors),b("Build encountered an error: ".concat(d.compilation.errors))):void g.close(function(c){return c?(console.error("Error occurred while closing the compiler: ".concat(c.message)),b("Error occurred while closing the compiler: ".concat(c.message))):void a(!0)})}):(console.error("[MeoCord] Failed to create webpack compiler instance."),b("Failed to create webpack compiler instance."))});case 5:return i.a(2,i.v);case 6:return i.p=6,h=i.v,h instanceof Error?console.error("[MeoCord] Failed to transpile config: ".concat(h.message)):console.error("[MeoCord] Failed to transpile config: Unknown error"),i.a(2,!1);case 7:return i.p=7,rmSync(b,{force:!0}),i.f(7);case 8:return i.a(2)}},_callee,null,[[4,6,7,8]])})),_compileMeoCordConfig.apply(this,arguments)}export function loadMeoCordConfig(){var a=findModulePackageDir("meocord");if(a){var b=path.join(TEMP_OUTPUT_DIR,"meocord.config.js");if(existsSync(b))try{return require(b)["default"]}catch(a){return void(a instanceof Error?console.error("[MeoCord] Failed to load config: ".concat(a.message)):console.error("[MeoCord] Failed to load config: Unknown error"))}}}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meocord",
|
|
3
3
|
"description": "MeoCord is a lightweight and modular framework for building scalable Discord bots using TypeScript and Discord.js. It simplifies bot development with an extensible architecture, TypeScript-first approach, and powerful CLI tools.",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"packageManager": "yarn@4.
|
|
4
|
+
"version": "1.0.12",
|
|
5
|
+
"packageManager": "yarn@4.10.3",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rm -rf ./dist && babel src --out-dir dist --extensions \".ts,.js\" && tsc && tsc-alias && copyfiles -u 1 \"src/**/*.template\" dist",
|
|
@@ -57,54 +57,56 @@
|
|
|
57
57
|
"AUTHOR.md",
|
|
58
58
|
"README.md"
|
|
59
59
|
],
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@swc/core": "1.13.5",
|
|
62
|
+
"chalk": "^5.6.2",
|
|
63
|
+
"cli-table3": "^0.6.5",
|
|
64
|
+
"commander": "^14.0.2",
|
|
65
|
+
"dayjs": "^1.11.18",
|
|
66
|
+
"discord.js": "^14.24.0",
|
|
67
|
+
"dotenv": "^17.2.3",
|
|
68
|
+
"esbuild-plugin-tsc": "^0.5.0",
|
|
69
|
+
"inversify": "^7.10.3",
|
|
70
|
+
"lodash-es": "^4.17.21",
|
|
71
|
+
"nodemon": "^3.1.10",
|
|
72
|
+
"reflect-metadata": "^0.2.2",
|
|
73
|
+
"simple-git": "^3.28.0",
|
|
74
|
+
"swc-loader": "^0.2.6",
|
|
75
|
+
"terser-webpack-plugin": "^5.3.14",
|
|
76
|
+
"tsconfig-paths-webpack-plugin": "^4.2.0",
|
|
77
|
+
"webpack": "^5.102.1",
|
|
78
|
+
"webpack-node-externals": "^3.0.0"
|
|
79
|
+
},
|
|
60
80
|
"devDependencies": {
|
|
61
|
-
"@babel/cli": "^7.
|
|
62
|
-
"@babel/core": "^7.
|
|
63
|
-
"@babel/preset-env": "^7.
|
|
64
|
-
"@babel/preset-typescript": "^7.
|
|
65
|
-
"@eslint/js": "^9.
|
|
81
|
+
"@babel/cli": "^7.28.3",
|
|
82
|
+
"@babel/core": "^7.28.5",
|
|
83
|
+
"@babel/preset-env": "^7.28.5",
|
|
84
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
85
|
+
"@eslint/js": "^9.38.0",
|
|
66
86
|
"@types/copyfiles": "^2.4.4",
|
|
67
87
|
"@types/lodash-es": "^4.17.12",
|
|
68
88
|
"@types/webpack-node-externals": "^3.0.4",
|
|
69
|
-
"@typescript-eslint/parser": "^8.
|
|
89
|
+
"@typescript-eslint/parser": "^8.46.2",
|
|
70
90
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
71
91
|
"babel-preset-minify": "^0.5.2",
|
|
72
92
|
"copyfiles": "^2.4.1",
|
|
73
|
-
"eslint": "^9.
|
|
74
|
-
"eslint-config-prettier": "^10.1.
|
|
75
|
-
"eslint-plugin-headers": "^1.
|
|
76
|
-
"eslint-plugin-import": "^2.
|
|
77
|
-
"eslint-plugin-prettier": "^5.
|
|
78
|
-
"eslint-plugin-unused-imports": "^4.
|
|
79
|
-
"globals": "^16.
|
|
93
|
+
"eslint": "^9.38.0",
|
|
94
|
+
"eslint-config-prettier": "^10.1.8",
|
|
95
|
+
"eslint-plugin-headers": "^1.3.3",
|
|
96
|
+
"eslint-plugin-import": "^2.32.0",
|
|
97
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
98
|
+
"eslint-plugin-unused-imports": "^4.3.0",
|
|
99
|
+
"globals": "^16.4.0",
|
|
80
100
|
"husky": "^9.1.7",
|
|
81
|
-
"prettier": "^3.
|
|
82
|
-
"tsc-alias": "^1.8.
|
|
83
|
-
"typescript": "^5.
|
|
84
|
-
"typescript-eslint": "^8.
|
|
101
|
+
"prettier": "^3.6.2",
|
|
102
|
+
"tsc-alias": "^1.8.16",
|
|
103
|
+
"typescript": "^5.9.3",
|
|
104
|
+
"typescript-eslint": "^8.46.2"
|
|
85
105
|
},
|
|
86
106
|
"peerDependencies": {
|
|
87
107
|
"discord.js": "^14.17.3",
|
|
88
108
|
"dotenv": "^16.4.7"
|
|
89
109
|
},
|
|
90
|
-
"dependencies": {
|
|
91
|
-
"chalk": "^5.4.1",
|
|
92
|
-
"cli-table3": "^0.6.5",
|
|
93
|
-
"commander": "^13.1.0",
|
|
94
|
-
"dayjs": "^1.11.13",
|
|
95
|
-
"discord.js": "^14.18.0",
|
|
96
|
-
"dotenv": "^16.4.7",
|
|
97
|
-
"inversify": "^7.1.0",
|
|
98
|
-
"lodash-es": "^4.17.21",
|
|
99
|
-
"nodemon": "^3.1.9",
|
|
100
|
-
"reflect-metadata": "^0.2.2",
|
|
101
|
-
"simple-git": "^3.27.0",
|
|
102
|
-
"terser-webpack-plugin": "^5.3.14",
|
|
103
|
-
"ts-loader": "^9.5.2",
|
|
104
|
-
"tsconfig-paths-webpack-plugin": "^4.2.0",
|
|
105
|
-
"webpack": "^5.98.0",
|
|
106
|
-
"webpack-node-externals": "^3.0.0"
|
|
107
|
-
},
|
|
108
110
|
"_moduleAliases": {
|
|
109
111
|
"@src": "./dist"
|
|
110
112
|
},
|
package/webpack.config.js
CHANGED
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import path from 'path'
|
|
20
|
-
import NodeExternals from 'webpack-node-externals'
|
|
21
20
|
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
|
|
22
21
|
import TerserPlugin from 'terser-webpack-plugin'
|
|
23
22
|
import { loadMeoCordConfig } from './dist/util/meocord-config-loader.util.js'
|
|
24
23
|
import { prepareModifiedTsConfig } from './dist/util/tsconfig.util.js'
|
|
24
|
+
import nodeExternals from 'webpack-node-externals'
|
|
25
25
|
|
|
26
26
|
const CWD = process.cwd()
|
|
27
27
|
const IS_PRODUCTION = process.env.NODE_ENV === 'production'
|
|
@@ -34,10 +34,21 @@ const tsConfigPath = prepareModifiedTsConfig()
|
|
|
34
34
|
const baseRules = [
|
|
35
35
|
{
|
|
36
36
|
test: /\.ts$/,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
use: {
|
|
38
|
+
loader: 'swc-loader',
|
|
39
|
+
options: {
|
|
40
|
+
jsc: {
|
|
41
|
+
parser: {
|
|
42
|
+
syntax: 'typescript',
|
|
43
|
+
tsx: false,
|
|
44
|
+
decorators: true,
|
|
45
|
+
},
|
|
46
|
+
transform: {
|
|
47
|
+
decoratorMetadata: true,
|
|
48
|
+
legacyDecorator: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
41
52
|
},
|
|
42
53
|
exclude: /node_modules/,
|
|
43
54
|
},
|
|
@@ -56,7 +67,7 @@ const createWebpackConfig = (overrides = {}) => {
|
|
|
56
67
|
mode: overrides.mode ?? (IS_PRODUCTION ? 'production' : 'development'),
|
|
57
68
|
entry: overrides.entry ?? path.resolve(SRC_DIR, 'main.ts'),
|
|
58
69
|
target: 'node',
|
|
59
|
-
externals: mergeUnique([
|
|
70
|
+
externals: mergeUnique([nodeExternals({ importType: 'module' })], overrides.externals),
|
|
60
71
|
module: {
|
|
61
72
|
...overrides.module,
|
|
62
73
|
rules: mergeUnique(baseRules, overrides.module?.rules),
|