@cyberskill/shared 2025.2.0 → 2025.2.1
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/commands.cjs +1 -1
- package/dist/commands.js +1 -1
- package/package.json +1 -1
package/dist/commands.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";function n(n,e,t,r,i,c,s){try{var o=n[c](s);var u=o.value}catch(n){t(n);return}if(o.done){e(u)}else{Promise.resolve(u).then(r,i)}}function e(e){return function(){var t=this,r=arguments;return new Promise(function(i,c){var s=e.apply(t,r);function o(e){n(s,i,c,o,u,"next",e)}function u(e){n(s,i,c,o,u,"throw",e)}o(undefined)})}}function t(n,e,t){if(e in n){Object.defineProperty(n,e,{value:t,enumerable:true,configurable:true,writable:true})}else{n[e]=t}return n}function r(n){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};var i=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){i=i.concat(Object.getOwnPropertySymbols(r).filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable}))}i.forEach(function(e){t(n,e,r[e])})}return n}function i(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);if(e){r=r.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})}t.push.apply(t,r)}return t}function c(n,e){e=e!=null?e:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(n,Object.getOwnPropertyDescriptors(e))}else{i(Object(e)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})}return n}function s(n){"@swc/helpers - typeof";return n&&typeof Symbol!=="undefined"&&n.constructor===Symbol?"symbol":typeof n}function o(n,e){var t,r,i,c,s={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return c={next:o(0),"throw":o(1),"return":o(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(e){return u([n,e])}}function u(c){if(t)throw new TypeError("Generator is already executing.");while(s)try{if(t=1,r&&(i=c[0]&2?r["return"]:c[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;if(r=0,i)c=[c[0]&2,i.value];switch(c[0]){case 0:case 1:i=c;break;case 4:s.label++;return{value:c[1],done:false};case 5:s.label++;r=c[1];c=[0];continue;case 7:c=s.ops.pop();s.trys.pop();continue;default:if(!(i=s.trys,i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){s=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){s.label=c[1];break}if(c[0]===6&&s.label<i[1]){s.label=i[1];i=c;break}if(i&&s.label<i[2]){s.label=i[2];s.ops.push(c);break}if(i[2])s.ops.pop();s.trys.pop();continue}c=e.call(n,s)}catch(n){c=[6,n];r=0}finally{t=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}}var u=Object.create;var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var d=function(n,e,t,r){var i=true,c=false,o=undefined;if(e&&(typeof e==="undefined"?"undefined":s(e))=="object"||typeof e=="function")try{var u=function(){var i=d.value;!h.call(n,i)&&i!==t&&a(n,i,{get:function(){return e[i]},enumerable:!(r=l(e,i))||r.enumerable})};for(var p=f(e)[Symbol.iterator](),d;!(i=(d=p.next()).done);i=true)u()}catch(n){c=true;o=n}finally{try{if(!i&&p.return!=null){p.return()}}finally{if(c){throw o}}}return n};var g=function(n,e,t){return t=n!=null?u(p(n)):{},d(e||!n||!n.__esModule?a(t,"default",{value:n,enumerable:!0}):t,n)};var y=function(){return(typeof document==="undefined"?"undefined":s(document))>"u"?new URL("file:".concat(__filename)).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href},m=y();var b=g(require("boxen"),1),_=g(require("chalk"),1),v=g(require("node-fetch"),1),w=require("child_process"),I=g(require("fs"),1),S=g(require("path"),1),O=g(require("process"),1),T=g(require("util"),1),P=g(require("ora"),1),j=require("yargs/helpers"),x=g(require("yargs/yargs"),1);var k=require("path"),N=require("url"),C=(0,N.fileURLToPath)(m),E=(0,k.dirname)(C);var R=_.default,D=R.blue,U=R.red,W=R.yellow,H=R.green,G=R.gray,M=R.white,F=R.bold,q=T.promisify(w.exec),A={FILE_EXTENSIONS:"**/*.{ts,tsx,js,jsx,json,css,scss,less}",INIT_CWD:O.default.env.INIT_CWD||O.default.cwd(),TSCONFIG_PATH:"".concat(O.default.env.INIT_CWD||O.default.cwd(),"/tsconfig.json"),HUSKY_PATH:"".concat(O.default.env.INIT_CWD||O.default.cwd(),"/.husky"),GIT_HOOK_PATH:"".concat(O.default.env.INIT_CWD||O.default.cwd(),"/.git/hooks"),GIT_COMMIT_MSG:"".concat(O.default.env.INIT_CWD||O.default.cwd(),"/.git/COMMIT_EDITMSG"),SIMPLE_GIT_HOOKS_PATH:"".concat(O.default.env.INIT_CWD||O.default.cwd(),"/.simple-git-hooks.json")},L=[];function K(n){return(0,P.default)({text:n,color:"cyan",spinner:"dots"})}function J(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";var t=new Date().toLocaleString();console.log("".concat(e," [").concat(t,"] ").concat(M(n)))}function Y(n,e){return $.apply(this,arguments)}function $(){$=e(function(n,e){var t,r,i,c,s,u,a,l,f;var p=arguments;return o(this,function(o){switch(o.label){case 0:t=p.length>2&&p[2]!==void 0?p[2]:z;J(e);r=new AbortController;O.default.on("SIGINT",function(){console.log("Terminating process..."),r.abort(),O.default.exit()});o.label=1;case 1:o.trys.push([1,3,,4]);return[4,q(n,{maxBuffer:0x6400000,signal:r.signal})];case 2:i=o.sent(),c=i.stdout,s=i.stderr;[c,s].forEach(function(n){return n&&t(n)});return[3,4];case 3:u=o.sent();a=u.stdout,l=u.stderr,f=u.message;[a,l].forEach(function(n){return n&&t(n)}),!l&&!a&&console.error("Command failed: ".concat(f));return[3,4];case 4:return[2]}})});return $.apply(this,arguments)}function B(n,e){return X.apply(this,arguments)}function X(){X=e(function(n,e){var t,r;return o(this,function(i){switch(i.label){case 0:t=K(n).start();i.label=1;case 1:i.trys.push([1,3,,4]);return[4,e()];case 2:i.sent(),L.length?O.default.exit(1):t.succeed("".concat(n," completed successfully!"));return[3,4];case 3:r=i.sent();throw t.fail("".concat(n," failed.")),r;case 4:return[2]}})});return X.apply(this,arguments)}function z(n){try{JSON.parse(n).forEach(function(n){var e=n.filePath,t=n.messages;t.forEach(function(n){var t=n.severity,r=n.line,i=n.column,c=n.ruleId,s=n.message;L.push({type:t===2?"error":"warning",file:e,position:"".concat(r,":").concat(i),rule:c,message:s})})})}catch(e){Q(n)}}function Q(n){var e=/^\s*(\d+):(\d+)\s+(error|warning)\s+(\S+)\s+(\S+)$/,t=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,r=/^✖\s+(.*?)\s+\[(.*?)\]$/,i=[],c="";n.split("\n").forEach(function(n){if(n.startsWith("/"))c=n.trim();else{var s=e.exec(n);if(s&&c)L.push({file:c,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()});else{var o=t.exec(n);if(o)L.push({file:o[1],position:"".concat(o[2],":").concat(o[3]),type:o[4],message:o[5].trim()});else{var u=r.exec(n);u?L.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):i.push(n.trim())}}}}),i.length>0&&(console.log(G("Unmatched lines:")),i.forEach(function(n){return console.info(n)}))}function V(n,e){var t=new Map([[U,"red"],[W,"yellow"],[H,"green"]]).get(e)||"green";return(0,b.default)(F(e(n)),{padding:1,margin:1,borderStyle:"arrow",borderColor:t})}function Z(n,e,t,r){n.length&&(n.forEach(function(n){var r=n.file,i=n.position,c=n.rule,s=n.message;console.log("".concat(e("".concat(t," File:"))," ").concat(D("".concat(r).concat(i?":".concat(i):"")))),c&&console.log(" ".concat(e("Rule:")," ").concat(e(c))),console.log(" ".concat(e("Message:")," ").concat(e(s)))}),console.log(V(F(e("".concat(t," Total ").concat(r,": ").concat(n.length))),e)),console.log(G("─".repeat(40))))}function nn(){var n=L.filter(function(n){return n.type==="error"}),e=L.filter(function(n){return n.type==="warning"});!n.length&&!e.length?console.log(V(F(H("✔ NO ISSUE FOUND!")),H)):(Z(e,W,"⚠","Warnings"),Z(n,U,"✖","Errors"))}function ne(){return nt.apply(this,arguments)}function nt(){nt=e(function(){var n;return o(this,function(e){switch(e.label){case 0:if(!I.existsSync(A.TSCONFIG_PATH))return[3,2];return[4,Y("npx tsc -p ".concat(A.TSCONFIG_PATH," --noEmit"),"TypeScript checking...")];case 1:n=e.sent();return[3,3];case 2:n=J("tsconfig.json file not found.","⚠️");e.label=3;case 3:n;return[2]}})});return nt.apply(this,arguments)}function nr(){return ni.apply(this,arguments)}function ni(){ni=e(function(){var n,e;var t=arguments;return o(this,function(r){switch(r.label){case 0:n=t.length>0&&t[0]!==void 0?t[0]:!1;e="npx eslint ".concat(A.INIT_CWD).concat(n?" --fix":" --format json");return[4,Y(e,"Eslint ".concat(n?"fixing":"checking","..."))];case 1:r.sent();return[2]}})});return ni.apply(this,arguments)}function nc(){return ns.apply(this,arguments)}function ns(){ns=e(function(){return o(this,function(n){switch(n.label){case 0:return[4,Y('npx lint-staged -- "*": "eslint --fix"',"Lint-staged processing...")];case 1:n.sent();return[2]}})});return ns.apply(this,arguments)}function no(){return nu.apply(this,arguments)}function nu(){nu=e(function(){return o(this,function(n){switch(n.label){case 0:J("Starting lint check for ".concat(A.INIT_CWD),"\uD83D\uDE80");return[4,B("Running lint checks...",/*#__PURE__*/e(function(){return o(this,function(n){switch(n.label){case 0:L.length=0;return[4,Promise.all([ne(),nr()])];case 1:n.sent(),nn();return[2]}})}))];case 1:n.sent();return[2]}})});return nu.apply(this,arguments)}function na(){return nl.apply(this,arguments)}function nl(){nl=e(function(){return o(this,function(n){switch(n.label){case 0:J("Starting lint and format fix for ".concat(A.INIT_CWD),"\uD83D\uDE80");return[4,B("Fixing issues...",/*#__PURE__*/e(function(){return o(this,function(n){switch(n.label){case 0:return[4,nr(!0)];case 1:n.sent();return[2]}})}))];case 1:n.sent();return[2]}})});return nl.apply(this,arguments)}function nf(){return np.apply(this,arguments)}function np(){np=e(function(){return o(this,function(n){switch(n.label){case 0:return[4,Y("npx @eslint/config-inspector","Lint inspect processing...")];case 1:n.sent();return[2]}})});return np.apply(this,arguments)}function nh(){return nd.apply(this,arguments)}function nd(){nd=e(function(){return o(this,function(n){switch(n.label){case 0:J("Starting lint-staged process for ".concat(O.default.env.INIT_CWD),"\uD83D\uDE80");return[4,B("Running lint-staged...",/*#__PURE__*/e(function(){return o(this,function(n){switch(n.label){case 0:L.length=0;return[4,Promise.all([ne(),nc()])];case 1:n.sent(),nn();return[2]}})}))];case 1:n.sent();return[2]}})});return nd.apply(this,arguments)}function ng(){return ny.apply(this,arguments)}function ny(){ny=e(function(){return o(this,function(n){switch(n.label){case 0:J("Starting commitlint process for ".concat(A.INIT_CWD),"\uD83D\uDE80");return[4,B("Running commitlint...",/*#__PURE__*/e(function(){var n,e;return o(this,function(t){switch(t.label){case 0:L.length=0;n=S.resolve(E,"./configs/commitlint/commitlint.base.js"),e="npx --no -- commitlint --edit ".concat(A.GIT_COMMIT_MSG," --config ").concat(n);return[4,Y(e,"Commitlint processing...")];case 1:t.sent(),nn();return[2]}})}))];case 1:n.sent();return[2]}})});return ny.apply(this,arguments)}function nm(){return nb.apply(this,arguments)}function nb(){nb=e(function(){var n;return o(this,function(e){switch(e.label){case 0:n=I.existsSync(A.HUSKY_PATH);if(!n)return[3,2];return[4,Y("npx rimraf ".concat(A.HUSKY_PATH," ").concat(A.GIT_HOOK_PATH," && git config core.hooksPath ").concat(A.GIT_HOOK_PATH),"Removing husky hooks...")];case 1:n=e.sent();e.label=2;case 2:n,I.writeFileSync(A.SIMPLE_GIT_HOOKS_PATH,JSON.stringify({"pre-commit":"npx --yes cyberskill lint-staged","commit-msg":"npx --yes cyberskill commitlint"},null,4));return[4,Y("npx simple-git-hooks","Setting up git hooks...")];case 3:e.sent(),I.unlinkSync(A.SIMPLE_GIT_HOOKS_PATH);return[2]}})});return nb.apply(this,arguments)}function n_(){return nv.apply(this,arguments)}function nv(){nv=e(function(){return o(this,function(n){switch(n.label){case 0:J("Starting setup process for ".concat(A.INIT_CWD),"\uD83D\uDE80");return[4,B("Setting up...",/*#__PURE__*/e(function(){var n,t,i,s,u,a,l,f,p;return o(this,function(h){switch(h.label){case 0:t="".concat(A.INIT_CWD,"/package.json"),i=/*#__PURE__*/function(){var n=e(function(){return o(this,function(n){switch(n.label){case 0:return[4,(0,v.default)("https://registry.npmjs.org/cyberskill/latest")];case 1:return[4,n.sent().json()];case 2:return[2,n.sent().version]}})});return function e(){return n.apply(this,arguments)}}(),s=/*#__PURE__*/function(){var n=e(function(){var n,e,t,r;return o(this,function(c){switch(c.label){case 0:return[4,i()];case 1:n=c.sent();try{e="".concat(A.INIT_CWD,"/node_modules/cyberskill/package.json"),t=JSON.parse(I.readFileSync(e,"utf-8")),r=t.version;return[2,r!==n]}catch(n){return[2,!0]}return[2]}})});return function e(){return n.apply(this,arguments)}}(),u=/*#__PURE__*/function(){var n=e(function(){var n,e;return o(this,function(s){switch(s.label){case 0:return[4,i()];case 1:n=s.sent(),e=JSON.parse(I.readFileSync(t,"utf-8"));e.dependencies=c(r({},e.dependencies),{cyberskill:n}),I.writeFileSync(t,JSON.stringify(e,null,2));return[4,Y("npm i -f","Installing all dependencies with updated cyberskill...")];case 2:s.sent();return[4,Y("npm run lint:fix","Fixing lint issues...")];case 3:s.sent();return[2]}})});return function e(){return n.apply(this,arguments)}}(),a=JSON.parse(I.readFileSync(t,"utf-8"));if(!(a.name==="cyberskill"))return[3,1];l=J("Cyberskill is the current project. No setup needed.","✅");return[3,7];case 1:p=!((n=a.dependencies)===null||n===void 0?void 0:n.cyberskill);if(p)return[3,3];return[4,s()];case 2:p=h.sent();h.label=3;case 3:if(!p)return[3,5];J("Cyberskill is missing or outdated. Updating...");return[4,u()];case 4:f=h.sent();return[3,6];case 5:f=J("Cyberskill is up to date","✅");h.label=6;case 6:l=f;h.label=7;case 7:l,nm();return[2]}})}))];case 1:n.sent();return[2]}})});return nv.apply(this,arguments)}function nw(){return nI.apply(this,arguments)}function nI(){nI=e(function(){return o(this,function(n){switch(n.label){case 0:J("Starting reset process for ".concat(A.INIT_CWD),"\uD83D\uDE80");return[4,B("Resetting...",/*#__PURE__*/e(function(){return o(this,function(n){switch(n.label){case 0:return[4,Y("npx rimraf ".concat(A.INIT_CWD,"/node_modules ").concat(A.INIT_CWD,"/package-lock.json"),"Cleaning node_modules and package-lock.json...")];case 1:n.sent();return[4,Y("npm i -f","Installing all dependencies...")];case 2:n.sent(),nm();return[2]}})}))];case 1:n.sent();return[2]}})});return nI.apply(this,arguments)}function nS(){return nO.apply(this,arguments)}function nO(){nO=e(function(){var n;return o(this,function(t){switch(t.label){case 0:n=S.resolve(E,"./configs/vitest/react/unit.js");J("Starting unit tests for ".concat(A.INIT_CWD),"\uD83D\uDE80");return[4,B("Running unit tests...",/*#__PURE__*/e(function(){return o(this,function(e){switch(e.label){case 0:return[4,Y("npx vitest --config ".concat(n),"Running unit tests...")];case 1:e.sent();return[2]}})}))];case 1:t.sent();return[2]}})});return nO.apply(this,arguments)}function nT(){return nP.apply(this,arguments)}function nP(){nP=e(function(){var n;return o(this,function(t){switch(t.label){case 0:n=S.resolve(E,"./configs/vitest/react/e2e.js");J("Starting e2e tests for ".concat(A.INIT_CWD),"\uD83D\uDE80");return[4,B("Running end-to-end tests...",/*#__PURE__*/e(function(){return o(this,function(e){switch(e.label){case 0:return[4,Y("npx vitest --config ".concat(n),"Running e2e tests...")];case 1:e.sent();return[2]}})}))];case 1:t.sent();return[2]}})});return nP.apply(this,arguments)}(0,x.default)((0,j.hideBin)(O.default.argv)).command("lint","Run linting checks",no).command("lint:fix","Fix linting and formatting issues",na).command("lint:inspect","Inspect linting rules",nf).command("lint-staged","Run lint-staged with given configuration",nh).command("commitlint","Run commitlint with given configuration",ng).command("setup","Run setup with given configuration",n_).command("reset","Reset dependencies and install",nw).command("test:unit","Run unit tests",nS).command("test:e2e","Run e2e tests",nT).help().parse();
|
|
2
|
+
"use strict";function n(n,t,e,r,i,c,s){try{var o=n[c](s);var u=o.value}catch(n){e(n);return}if(o.done){t(u)}else{Promise.resolve(u).then(r,i)}}function t(t){return function(){var e=this,r=arguments;return new Promise(function(i,c){var s=t.apply(e,r);function o(t){n(s,i,c,o,u,"next",t)}function u(t){n(s,i,c,o,u,"throw",t)}o(undefined)})}}function e(n,t,e){if(t in n){Object.defineProperty(n,t,{value:e,enumerable:true,configurable:true,writable:true})}else{n[t]=e}return n}function r(n){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var i=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){i=i.concat(Object.getOwnPropertySymbols(r).filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable}))}i.forEach(function(t){e(n,t,r[t])})}return n}function i(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);if(t){r=r.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})}e.push.apply(e,r)}return e}function c(n,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(n,Object.getOwnPropertyDescriptors(t))}else{i(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function s(n){"@swc/helpers - typeof";return n&&typeof Symbol!=="undefined"&&n.constructor===Symbol?"symbol":typeof n}function o(n,t){var e,r,i,c,s={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return c={next:o(0),"throw":o(1),"return":o(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(t){return u([n,t])}}function u(c){if(e)throw new TypeError("Generator is already executing.");while(s)try{if(e=1,r&&(i=c[0]&2?r["return"]:c[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;if(r=0,i)c=[c[0]&2,i.value];switch(c[0]){case 0:case 1:i=c;break;case 4:s.label++;return{value:c[1],done:false};case 5:s.label++;r=c[1];c=[0];continue;case 7:c=s.ops.pop();s.trys.pop();continue;default:if(!(i=s.trys,i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){s=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){s.label=c[1];break}if(c[0]===6&&s.label<i[1]){s.label=i[1];i=c;break}if(i&&s.label<i[2]){s.label=i[2];s.ops.push(c);break}if(i[2])s.ops.pop();s.trys.pop();continue}c=t.call(n,s)}catch(n){c=[6,n];r=0}finally{e=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}}var u=Object.create;var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var d=function(n,t,e,r){var i=true,c=false,o=undefined;if(t&&(typeof t==="undefined"?"undefined":s(t))=="object"||typeof t=="function")try{var u=function(){var i=d.value;!h.call(n,i)&&i!==e&&a(n,i,{get:function(){return t[i]},enumerable:!(r=l(t,i))||r.enumerable})};for(var p=f(t)[Symbol.iterator](),d;!(i=(d=p.next()).done);i=true)u()}catch(n){c=true;o=n}finally{try{if(!i&&p.return!=null){p.return()}}finally{if(c){throw o}}}return n};var g=function(n,t,e){return e=n!=null?u(p(n)):{},d(t||!n||!n.__esModule?a(e,"default",{value:n,enumerable:!0}):e,n)};var y=function(){return(typeof document==="undefined"?"undefined":s(document))>"u"?new URL("file:".concat(__filename)).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href},m=y();var _=g(require("boxen"),1),b=g(require("chalk"),1),v=g(require("node-fetch"),1),w=require("child_process"),I=g(require("fs"),1),S=g(require("path"),1),O=g(require("process"),1),P=g(require("util"),1),T=g(require("ora"),1),E=require("yargs/helpers"),N=g(require("yargs/yargs"),1);var j=require("path"),x=require("url"),C=(0,x.fileURLToPath)(m),k=(0,j.dirname)(C);var R=b.default,D=R.blue,A=R.red,U=R.yellow,W=R.green,G=R.gray,H=R.white,M=R.bold,F=P.promisify(w.exec),K={FILE_EXTENSIONS:"**/*.{ts,tsx,js,jsx,json,css,scss,less}",INIT_CWD:O.default.env.INIT_CWD||O.default.cwd(),TSCONFIG_PATH:"".concat(O.default.env.INIT_CWD||O.default.cwd(),"/tsconfig.json"),HUSKY_PATH:"".concat(O.default.env.INIT_CWD||O.default.cwd(),"/.husky"),GIT_HOOK_PATH:"".concat(O.default.env.INIT_CWD||O.default.cwd(),"/.git/hooks"),GIT_COMMIT_MSG:"".concat(O.default.env.INIT_CWD||O.default.cwd(),"/.git/COMMIT_EDITMSG"),SIMPLE_GIT_HOOKS_PATH:"".concat(O.default.env.INIT_CWD||O.default.cwd(),"/.simple-git-hooks.json"),PACKAGE_NAME:"@cyberskill/shared"},q=[];function L(n){return(0,T.default)({text:n,color:"cyan",spinner:"dots"})}function J(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";var e=new Date().toLocaleString();console.log("".concat(t," [").concat(e,"] ").concat(H(n)))}function Y(n,t){return $.apply(this,arguments)}function $(){$=t(function(n,t){var e,r,i,c,s,u,a,l,f;var p=arguments;return o(this,function(o){switch(o.label){case 0:e=p.length>2&&p[2]!==void 0?p[2]:z;J(t);r=new AbortController;O.default.on("SIGINT",function(){console.log("Terminating process..."),r.abort(),O.default.exit()});o.label=1;case 1:o.trys.push([1,3,,4]);return[4,F(n,{maxBuffer:0x6400000,signal:r.signal})];case 2:i=o.sent(),c=i.stdout,s=i.stderr;[c,s].forEach(function(n){return n&&e(n)});return[3,4];case 3:u=o.sent();a=u.stdout,l=u.stderr,f=u.message;[a,l].forEach(function(n){return n&&e(n)}),!l&&!a&&console.error("Command failed: ".concat(f));return[3,4];case 4:return[2]}})});return $.apply(this,arguments)}function B(n,t){return X.apply(this,arguments)}function X(){X=t(function(n,t){var e,r;return o(this,function(i){switch(i.label){case 0:e=L(n).start();i.label=1;case 1:i.trys.push([1,3,,4]);return[4,t()];case 2:i.sent(),q.length?O.default.exit(1):e.succeed("".concat(n," completed successfully!"));return[3,4];case 3:r=i.sent();throw e.fail("".concat(n," failed.")),r;case 4:return[2]}})});return X.apply(this,arguments)}function z(n){try{JSON.parse(n).forEach(function(n){var t=n.filePath,e=n.messages;e.forEach(function(n){var e=n.severity,r=n.line,i=n.column,c=n.ruleId,s=n.message;q.push({type:e===2?"error":"warning",file:t,position:"".concat(r,":").concat(i),rule:c,message:s})})})}catch(t){Q(n)}}function Q(n){var t=/^\s*(\d+):(\d+)\s+(error|warning)\s+(\S+)\s+(\S+)$/,e=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,r=/^✖\s+(.*?)\s+\[(.*?)\]$/,i=[],c="";n.split("\n").forEach(function(n){if(n.startsWith("/"))c=n.trim();else{var s=t.exec(n);if(s&&c)q.push({file:c,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()});else{var o=e.exec(n);if(o)q.push({file:o[1],position:"".concat(o[2],":").concat(o[3]),type:o[4],message:o[5].trim()});else{var u=r.exec(n);u?q.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):i.push(n.trim())}}}}),i.length>0&&(console.log(G("Unmatched lines:")),i.forEach(function(n){return console.info(n)}))}function V(n,t){var e=new Map([[A,"red"],[U,"yellow"],[W,"green"]]).get(t)||"green";return(0,_.default)(M(t(n)),{padding:1,margin:1,borderStyle:"arrow",borderColor:e})}function Z(n,t,e,r){n.length&&(n.forEach(function(n){var r=n.file,i=n.position,c=n.rule,s=n.message;console.log("".concat(t("".concat(e," File:"))," ").concat(D("".concat(r).concat(i?":".concat(i):"")))),c&&console.log(" ".concat(t("Rule:")," ").concat(t(c))),console.log(" ".concat(t("Message:")," ").concat(t(s)))}),console.log(V(M(t("".concat(e," Total ").concat(r,": ").concat(n.length))),t)),console.log(G("─".repeat(40))))}function nn(){var n=q.filter(function(n){return n.type==="error"}),t=q.filter(function(n){return n.type==="warning"});!n.length&&!t.length?console.log(V(M(W("✔ NO ISSUE FOUND!")),W)):(Z(t,U,"⚠","Warnings"),Z(n,A,"✖","Errors"))}function nt(){return ne.apply(this,arguments)}function ne(){ne=t(function(){var n;return o(this,function(t){switch(t.label){case 0:if(!I.existsSync(K.TSCONFIG_PATH))return[3,2];return[4,Y("npx tsc -p ".concat(K.TSCONFIG_PATH," --noEmit"),"TypeScript checking...")];case 1:n=t.sent();return[3,3];case 2:n=J("tsconfig.json file not found.","⚠️");t.label=3;case 3:n;return[2]}})});return ne.apply(this,arguments)}function nr(){return ni.apply(this,arguments)}function ni(){ni=t(function(){var n,t;var e=arguments;return o(this,function(r){switch(r.label){case 0:n=e.length>0&&e[0]!==void 0?e[0]:!1;t="npx eslint ".concat(K.INIT_CWD).concat(n?" --fix":" --format json");return[4,Y(t,"Eslint ".concat(n?"fixing":"checking","..."))];case 1:r.sent();return[2]}})});return ni.apply(this,arguments)}function nc(){return ns.apply(this,arguments)}function ns(){ns=t(function(){return o(this,function(n){switch(n.label){case 0:return[4,Y('npx lint-staged -- "*": "eslint --fix"',"Lint-staged processing...")];case 1:n.sent();return[2]}})});return ns.apply(this,arguments)}function no(){return nu.apply(this,arguments)}function nu(){nu=t(function(){return o(this,function(n){switch(n.label){case 0:J("Starting lint check for ".concat(K.INIT_CWD),"\uD83D\uDE80");return[4,B("Running lint checks...",/*#__PURE__*/t(function(){return o(this,function(n){switch(n.label){case 0:q.length=0;return[4,Promise.all([nt(),nr()])];case 1:n.sent(),nn();return[2]}})}))];case 1:n.sent();return[2]}})});return nu.apply(this,arguments)}function na(){return nl.apply(this,arguments)}function nl(){nl=t(function(){return o(this,function(n){switch(n.label){case 0:J("Starting lint and format fix for ".concat(K.INIT_CWD),"\uD83D\uDE80");return[4,B("Fixing issues...",/*#__PURE__*/t(function(){return o(this,function(n){switch(n.label){case 0:return[4,nr(!0)];case 1:n.sent();return[2]}})}))];case 1:n.sent();return[2]}})});return nl.apply(this,arguments)}function nf(){return np.apply(this,arguments)}function np(){np=t(function(){return o(this,function(n){switch(n.label){case 0:return[4,Y("npx @eslint/config-inspector","Lint inspect processing...")];case 1:n.sent();return[2]}})});return np.apply(this,arguments)}function nh(){return nd.apply(this,arguments)}function nd(){nd=t(function(){return o(this,function(n){switch(n.label){case 0:J("Starting lint-staged process for ".concat(O.default.env.INIT_CWD),"\uD83D\uDE80");return[4,B("Running lint-staged...",/*#__PURE__*/t(function(){return o(this,function(n){switch(n.label){case 0:q.length=0;return[4,Promise.all([nt(),nc()])];case 1:n.sent(),nn();return[2]}})}))];case 1:n.sent();return[2]}})});return nd.apply(this,arguments)}function ng(){return ny.apply(this,arguments)}function ny(){ny=t(function(){return o(this,function(n){switch(n.label){case 0:J("Starting commitlint process for ".concat(K.INIT_CWD),"\uD83D\uDE80");return[4,B("Running commitlint...",/*#__PURE__*/t(function(){var n,t;return o(this,function(e){switch(e.label){case 0:q.length=0;n=S.resolve(k,"./configs/commitlint/commitlint.base.js"),t="npx --no -- commitlint --edit ".concat(K.GIT_COMMIT_MSG," --config ").concat(n);return[4,Y(t,"Commitlint processing...")];case 1:e.sent(),nn();return[2]}})}))];case 1:n.sent();return[2]}})});return ny.apply(this,arguments)}function nm(){return n_.apply(this,arguments)}function n_(){n_=t(function(){var n;return o(this,function(t){switch(t.label){case 0:n=I.existsSync(K.HUSKY_PATH);if(!n)return[3,2];return[4,Y("npx rimraf ".concat(K.HUSKY_PATH," ").concat(K.GIT_HOOK_PATH," && git config core.hooksPath ").concat(K.GIT_HOOK_PATH),"Removing husky hooks...")];case 1:n=t.sent();t.label=2;case 2:n,I.writeFileSync(K.SIMPLE_GIT_HOOKS_PATH,JSON.stringify({"pre-commit":"npx --yes cyberskill lint-staged","commit-msg":"npx --yes cyberskill commitlint"},null,4));return[4,Y("npx simple-git-hooks","Setting up git hooks...")];case 3:t.sent(),I.unlinkSync(K.SIMPLE_GIT_HOOKS_PATH);return[2]}})});return n_.apply(this,arguments)}function nb(){return nv.apply(this,arguments)}function nv(){nv=t(function(){return o(this,function(n){switch(n.label){case 0:J("Starting setup process for ".concat(K.INIT_CWD),"\uD83D\uDE80");return[4,B("Setting up...",/*#__PURE__*/t(function(){var n,i,s,u,a,l,f,p,h;return o(this,function(d){switch(d.label){case 0:i="".concat(K.INIT_CWD,"/package.json"),s=/*#__PURE__*/function(){var n=t(function(){return o(this,function(n){switch(n.label){case 0:return[4,(0,v.default)("https://registry.npmjs.org/".concat(K.PACKAGE_NAME,"/latest"))];case 1:return[4,n.sent().json()];case 2:return[2,n.sent().version]}})});return function t(){return n.apply(this,arguments)}}(),u=/*#__PURE__*/function(){var n=t(function(){var n,t,e,r;return o(this,function(i){switch(i.label){case 0:return[4,s()];case 1:n=i.sent();try{t="".concat(K.INIT_CWD,"/node_modules/").concat(K.PACKAGE_NAME,"/package.json"),e=JSON.parse(I.readFileSync(t,"utf-8")),r=e.version;return[2,r!==n]}catch(n){return[2,!0]}return[2]}})});return function t(){return n.apply(this,arguments)}}(),a=/*#__PURE__*/function(){var n=t(function(){var n,t;return o(this,function(o){switch(o.label){case 0:return[4,s()];case 1:n=o.sent(),t=JSON.parse(I.readFileSync(i,"utf-8"));t.dependencies=c(r({},t.dependencies),e({},K.PACKAGE_NAME,n)),I.writeFileSync(i,JSON.stringify(t,null,2));return[4,Y("npm i -f","Installing all dependencies with updated cyberskill...")];case 2:o.sent();return[4,Y("npm run lint:fix","Fixing lint issues...")];case 3:o.sent();return[2]}})});return function t(){return n.apply(this,arguments)}}(),l=JSON.parse(I.readFileSync(i,"utf-8"));if(!(l.name===K.PACKAGE_NAME))return[3,1];f=J("Cyberskill is the current project. No setup needed.","✅");return[3,7];case 1:h=!((n=l.dependencies)===null||n===void 0?void 0:n.cyberskill);if(h)return[3,3];return[4,u()];case 2:h=d.sent();d.label=3;case 3:if(!h)return[3,5];J("Cyberskill is missing or outdated. Updating...");return[4,a()];case 4:p=d.sent();return[3,6];case 5:p=J("Cyberskill is up to date","✅");d.label=6;case 6:f=p;d.label=7;case 7:f,nm();return[2]}})}))];case 1:n.sent();return[2]}})});return nv.apply(this,arguments)}function nw(){return nI.apply(this,arguments)}function nI(){nI=t(function(){return o(this,function(n){switch(n.label){case 0:J("Starting reset process for ".concat(K.INIT_CWD),"\uD83D\uDE80");return[4,B("Resetting...",/*#__PURE__*/t(function(){return o(this,function(n){switch(n.label){case 0:return[4,Y("npx rimraf ".concat(K.INIT_CWD,"/node_modules ").concat(K.INIT_CWD,"/package-lock.json"),"Cleaning node_modules and package-lock.json...")];case 1:n.sent();return[4,Y("npm i -f","Installing all dependencies...")];case 2:n.sent(),nm();return[2]}})}))];case 1:n.sent();return[2]}})});return nI.apply(this,arguments)}function nS(){return nO.apply(this,arguments)}function nO(){nO=t(function(){var n;return o(this,function(e){switch(e.label){case 0:n=S.resolve(k,"./configs/vitest/react/unit.js");J("Starting unit tests for ".concat(K.INIT_CWD),"\uD83D\uDE80");return[4,B("Running unit tests...",/*#__PURE__*/t(function(){return o(this,function(t){switch(t.label){case 0:return[4,Y("npx vitest --config ".concat(n),"Running unit tests...")];case 1:t.sent();return[2]}})}))];case 1:e.sent();return[2]}})});return nO.apply(this,arguments)}function nP(){return nT.apply(this,arguments)}function nT(){nT=t(function(){var n;return o(this,function(e){switch(e.label){case 0:n=S.resolve(k,"./configs/vitest/react/e2e.js");J("Starting e2e tests for ".concat(K.INIT_CWD),"\uD83D\uDE80");return[4,B("Running end-to-end tests...",/*#__PURE__*/t(function(){return o(this,function(t){switch(t.label){case 0:return[4,Y("npx vitest --config ".concat(n),"Running e2e tests...")];case 1:t.sent();return[2]}})}))];case 1:e.sent();return[2]}})});return nT.apply(this,arguments)}(0,N.default)((0,E.hideBin)(O.default.argv)).command("lint","Run linting checks",no).command("lint:fix","Fix linting and formatting issues",na).command("lint:inspect","Inspect linting rules",nf).command("lint-staged","Run lint-staged with given configuration",nh).command("commitlint","Run commitlint with given configuration",ng).command("setup","Run setup with given configuration",nb).command("reset","Reset dependencies and install",nw).command("test:unit","Run unit tests",nS).command("test:e2e","Run e2e tests",nP).help().parse();
|
package/dist/commands.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
function n(n,t,e,r,i,c,s){try{var o=n[c](s);var a=o.value}catch(n){e(n);return}if(o.done){t(a)}else{Promise.resolve(a).then(r,i)}}function t(t){return function(){var e=this,r=arguments;return new Promise(function(i,c){var s=t.apply(e,r);function o(t){n(s,i,c,o,a,"next",t)}function a(t){n(s,i,c,o,a,"throw",t)}o(undefined)})}}function e(n,t,e){if(t in n){Object.defineProperty(n,t,{value:e,enumerable:true,configurable:true,writable:true})}else{n[t]=e}return n}function r(n){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var i=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){i=i.concat(Object.getOwnPropertySymbols(r).filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable}))}i.forEach(function(t){e(n,t,r[t])})}return n}function i(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);if(t){r=r.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})}e.push.apply(e,r)}return e}function c(n,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(n,Object.getOwnPropertyDescriptors(t))}else{i(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function s(n,t){var e,r,i,c,s={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return c={next:o(0),"throw":o(1),"return":o(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(t){return a([n,t])}}function a(c){if(e)throw new TypeError("Generator is already executing.");while(s)try{if(e=1,r&&(i=c[0]&2?r["return"]:c[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;if(r=0,i)c=[c[0]&2,i.value];switch(c[0]){case 0:case 1:i=c;break;case 4:s.label++;return{value:c[1],done:false};case 5:s.label++;r=c[1];c=[0];continue;case 7:c=s.ops.pop();s.trys.pop();continue;default:if(!(i=s.trys,i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){s=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){s.label=c[1];break}if(c[0]===6&&s.label<i[1]){s.label=i[1];i=c;break}if(i&&s.label<i[2]){s.label=i[2];s.ops.push(c);break}if(i[2])s.ops.pop();s.trys.pop();continue}c=t.call(n,s)}catch(n){c=[6,n];r=0}finally{e=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}}import o from"boxen";import a from"chalk";import u from"node-fetch";import{exec as l}from"node:child_process";import*as f from"node:fs";import*as p from"node:path";import h from"node:process";import*as g from"node:util";import m from"ora";import{hideBin as y}from"yargs/helpers";import d from"yargs/yargs";import{dirname as _}from"node:path";import{fileURLToPath as b}from"node:url";var v=b(import.meta.url),w=_(v);var I=a.blue,S=a.red,T=a.yellow,O=a.green,P=a.gray,x=a.white,k=a.bold,N=g.promisify(l),C={FILE_EXTENSIONS:"**/*.{ts,tsx,js,jsx,json,css,scss,less}",INIT_CWD:h.env.INIT_CWD||h.cwd(),TSCONFIG_PATH:"".concat(h.env.INIT_CWD||h.cwd(),"/tsconfig.json"),HUSKY_PATH:"".concat(h.env.INIT_CWD||h.cwd(),"/.husky"),GIT_HOOK_PATH:"".concat(h.env.INIT_CWD||h.cwd(),"/.git/hooks"),GIT_COMMIT_MSG:"".concat(h.env.INIT_CWD||h.cwd(),"/.git/COMMIT_EDITMSG"),SIMPLE_GIT_HOOKS_PATH:"".concat(h.env.INIT_CWD||h.cwd(),"/.simple-git-hooks.json")},j=[];function E(n){return m({text:n,color:"cyan",spinner:"dots"})}function R(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";var e=new Date().toLocaleString();console.log("".concat(t," [").concat(e,"] ").concat(x(n)))}function D(n,t){return W.apply(this,arguments)}function W(){W=t(function(n,t){var e,r,i,c,o,a,u,l,f;var p=arguments;return s(this,function(s){switch(s.label){case 0:e=p.length>2&&p[2]!==void 0?p[2]:G;R(t);r=new AbortController;h.on("SIGINT",function(){console.log("Terminating process..."),r.abort(),h.exit()});s.label=1;case 1:s.trys.push([1,3,,4]);return[4,N(n,{maxBuffer:0x6400000,signal:r.signal})];case 2:i=s.sent(),c=i.stdout,o=i.stderr;[c,o].forEach(function(n){return n&&e(n)});return[3,4];case 3:a=s.sent();u=a.stdout,l=a.stderr,f=a.message;[u,l].forEach(function(n){return n&&e(n)}),!l&&!u&&console.error("Command failed: ".concat(f));return[3,4];case 4:return[2]}})});return W.apply(this,arguments)}function H(n,t){return U.apply(this,arguments)}function U(){U=t(function(n,t){var e,r;return s(this,function(i){switch(i.label){case 0:e=E(n).start();i.label=1;case 1:i.trys.push([1,3,,4]);return[4,t()];case 2:i.sent(),j.length?h.exit(1):e.succeed("".concat(n," completed successfully!"));return[3,4];case 3:r=i.sent();throw e.fail("".concat(n," failed.")),r;case 4:return[2]}})});return U.apply(this,arguments)}function G(n){try{JSON.parse(n).forEach(function(n){var t=n.filePath,e=n.messages;e.forEach(function(n){var e=n.severity,r=n.line,i=n.column,c=n.ruleId,s=n.message;j.push({type:e===2?"error":"warning",file:t,position:"".concat(r,":").concat(i),rule:c,message:s})})})}catch(t){F(n)}}function F(n){var t=/^\s*(\d+):(\d+)\s+(error|warning)\s+(\S+)\s+(\S+)$/,e=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,r=/^✖\s+(.*?)\s+\[(.*?)\]$/,i=[],c="";n.split("\n").forEach(function(n){if(n.startsWith("/"))c=n.trim();else{var s=t.exec(n);if(s&&c)j.push({file:c,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()});else{var o=e.exec(n);if(o)j.push({file:o[1],position:"".concat(o[2],":").concat(o[3]),type:o[4],message:o[5].trim()});else{var a=r.exec(n);a?j.push({file:"commitlint",type:"error",message:a[1].trim(),rule:a[2].trim()}):i.push(n.trim())}}}}),i.length>0&&(console.log(P("Unmatched lines:")),i.forEach(function(n){return console.info(n)}))}function M(n,t){var e=new Map([[S,"red"],[T,"yellow"],[O,"green"]]).get(t)||"green";return o(k(t(n)),{padding:1,margin:1,borderStyle:"arrow",borderColor:e})}function A(n,t,e,r){n.length&&(n.forEach(function(n){var r=n.file,i=n.position,c=n.rule,s=n.message;console.log("".concat(t("".concat(e," File:"))," ").concat(I("".concat(r).concat(i?":".concat(i):"")))),c&&console.log(" ".concat(t("Rule:")," ").concat(t(c))),console.log(" ".concat(t("Message:")," ").concat(t(s)))}),console.log(M(k(t("".concat(e," Total ").concat(r,": ").concat(n.length))),t)),console.log(P("─".repeat(40))))}function K(){var n=j.filter(function(n){return n.type==="error"}),t=j.filter(function(n){return n.type==="warning"});!n.length&&!t.length?console.log(M(k(O("✔ NO ISSUE FOUND!")),O)):(A(t,T,"⚠","Warnings"),A(n,S,"✖","Errors"))}function L(){return J.apply(this,arguments)}function J(){J=t(function(){var n;return s(this,function(t){switch(t.label){case 0:if(!f.existsSync(C.TSCONFIG_PATH))return[3,2];return[4,D("npx tsc -p ".concat(C.TSCONFIG_PATH," --noEmit"),"TypeScript checking...")];case 1:n=t.sent();return[3,3];case 2:n=R("tsconfig.json file not found.","⚠️");t.label=3;case 3:n;return[2]}})});return J.apply(this,arguments)}function Y(){return $.apply(this,arguments)}function $(){$=t(function(){var n,t;var e=arguments;return s(this,function(r){switch(r.label){case 0:n=e.length>0&&e[0]!==void 0?e[0]:!1;t="npx eslint ".concat(C.INIT_CWD).concat(n?" --fix":" --format json");return[4,D(t,"Eslint ".concat(n?"fixing":"checking","..."))];case 1:r.sent();return[2]}})});return $.apply(this,arguments)}function B(){return X.apply(this,arguments)}function X(){X=t(function(){return s(this,function(n){switch(n.label){case 0:return[4,D('npx lint-staged -- "*": "eslint --fix"',"Lint-staged processing...")];case 1:n.sent();return[2]}})});return X.apply(this,arguments)}function q(){return z.apply(this,arguments)}function z(){z=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting lint check for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,H("Running lint checks...",/*#__PURE__*/t(function(){return s(this,function(n){switch(n.label){case 0:j.length=0;return[4,Promise.all([L(),Y()])];case 1:n.sent(),K();return[2]}})}))];case 1:n.sent();return[2]}})});return z.apply(this,arguments)}function Q(){return V.apply(this,arguments)}function V(){V=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting lint and format fix for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,H("Fixing issues...",/*#__PURE__*/t(function(){return s(this,function(n){switch(n.label){case 0:return[4,Y(!0)];case 1:n.sent();return[2]}})}))];case 1:n.sent();return[2]}})});return V.apply(this,arguments)}function Z(){return nn.apply(this,arguments)}function nn(){nn=t(function(){return s(this,function(n){switch(n.label){case 0:return[4,D("npx @eslint/config-inspector","Lint inspect processing...")];case 1:n.sent();return[2]}})});return nn.apply(this,arguments)}function nt(){return ne.apply(this,arguments)}function ne(){ne=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting lint-staged process for ".concat(h.env.INIT_CWD),"\uD83D\uDE80");return[4,H("Running lint-staged...",/*#__PURE__*/t(function(){return s(this,function(n){switch(n.label){case 0:j.length=0;return[4,Promise.all([L(),B()])];case 1:n.sent(),K();return[2]}})}))];case 1:n.sent();return[2]}})});return ne.apply(this,arguments)}function nr(){return ni.apply(this,arguments)}function ni(){ni=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting commitlint process for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,H("Running commitlint...",/*#__PURE__*/t(function(){var n,t;return s(this,function(e){switch(e.label){case 0:j.length=0;n=p.resolve(w,"./configs/commitlint/commitlint.base.js"),t="npx --no -- commitlint --edit ".concat(C.GIT_COMMIT_MSG," --config ").concat(n);return[4,D(t,"Commitlint processing...")];case 1:e.sent(),K();return[2]}})}))];case 1:n.sent();return[2]}})});return ni.apply(this,arguments)}function nc(){return ns.apply(this,arguments)}function ns(){ns=t(function(){var n;return s(this,function(t){switch(t.label){case 0:n=f.existsSync(C.HUSKY_PATH);if(!n)return[3,2];return[4,D("npx rimraf ".concat(C.HUSKY_PATH," ").concat(C.GIT_HOOK_PATH," && git config core.hooksPath ").concat(C.GIT_HOOK_PATH),"Removing husky hooks...")];case 1:n=t.sent();t.label=2;case 2:n,f.writeFileSync(C.SIMPLE_GIT_HOOKS_PATH,JSON.stringify({"pre-commit":"npx --yes cyberskill lint-staged","commit-msg":"npx --yes cyberskill commitlint"},null,4));return[4,D("npx simple-git-hooks","Setting up git hooks...")];case 3:t.sent(),f.unlinkSync(C.SIMPLE_GIT_HOOKS_PATH);return[2]}})});return ns.apply(this,arguments)}function no(){return na.apply(this,arguments)}function na(){na=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting setup process for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,H("Setting up...",/*#__PURE__*/t(function(){var n,e,i,o,a,l,p,h,g;return s(this,function(m){switch(m.label){case 0:e="".concat(C.INIT_CWD,"/package.json"),i=/*#__PURE__*/function(){var n=t(function(){return s(this,function(n){switch(n.label){case 0:return[4,u("https://registry.npmjs.org/cyberskill/latest")];case 1:return[4,n.sent().json()];case 2:return[2,n.sent().version]}})});return function t(){return n.apply(this,arguments)}}(),o=/*#__PURE__*/function(){var n=t(function(){var n,t,e,r;return s(this,function(c){switch(c.label){case 0:return[4,i()];case 1:n=c.sent();try{t="".concat(C.INIT_CWD,"/node_modules/cyberskill/package.json"),e=JSON.parse(f.readFileSync(t,"utf-8")),r=e.version;return[2,r!==n]}catch(n){return[2,!0]}return[2]}})});return function t(){return n.apply(this,arguments)}}(),a=/*#__PURE__*/function(){var n=t(function(){var n,t;return s(this,function(s){switch(s.label){case 0:return[4,i()];case 1:n=s.sent(),t=JSON.parse(f.readFileSync(e,"utf-8"));t.dependencies=c(r({},t.dependencies),{cyberskill:n}),f.writeFileSync(e,JSON.stringify(t,null,2));return[4,D("npm i -f","Installing all dependencies with updated cyberskill...")];case 2:s.sent();return[4,D("npm run lint:fix","Fixing lint issues...")];case 3:s.sent();return[2]}})});return function t(){return n.apply(this,arguments)}}(),l=JSON.parse(f.readFileSync(e,"utf-8"));if(!(l.name==="cyberskill"))return[3,1];p=R("Cyberskill is the current project. No setup needed.","✅");return[3,7];case 1:g=!((n=l.dependencies)===null||n===void 0?void 0:n.cyberskill);if(g)return[3,3];return[4,o()];case 2:g=m.sent();m.label=3;case 3:if(!g)return[3,5];R("Cyberskill is missing or outdated. Updating...");return[4,a()];case 4:h=m.sent();return[3,6];case 5:h=R("Cyberskill is up to date","✅");m.label=6;case 6:p=h;m.label=7;case 7:p,nc();return[2]}})}))];case 1:n.sent();return[2]}})});return na.apply(this,arguments)}function nu(){return nl.apply(this,arguments)}function nl(){nl=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting reset process for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,H("Resetting...",/*#__PURE__*/t(function(){return s(this,function(n){switch(n.label){case 0:return[4,D("npx rimraf ".concat(C.INIT_CWD,"/node_modules ").concat(C.INIT_CWD,"/package-lock.json"),"Cleaning node_modules and package-lock.json...")];case 1:n.sent();return[4,D("npm i -f","Installing all dependencies...")];case 2:n.sent(),nc();return[2]}})}))];case 1:n.sent();return[2]}})});return nl.apply(this,arguments)}function nf(){return np.apply(this,arguments)}function np(){np=t(function(){var n;return s(this,function(e){switch(e.label){case 0:n=p.resolve(w,"./configs/vitest/react/unit.js");R("Starting unit tests for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,H("Running unit tests...",/*#__PURE__*/t(function(){return s(this,function(t){switch(t.label){case 0:return[4,D("npx vitest --config ".concat(n),"Running unit tests...")];case 1:t.sent();return[2]}})}))];case 1:e.sent();return[2]}})});return np.apply(this,arguments)}function nh(){return ng.apply(this,arguments)}function ng(){ng=t(function(){var n;return s(this,function(e){switch(e.label){case 0:n=p.resolve(w,"./configs/vitest/react/e2e.js");R("Starting e2e tests for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,H("Running end-to-end tests...",/*#__PURE__*/t(function(){return s(this,function(t){switch(t.label){case 0:return[4,D("npx vitest --config ".concat(n),"Running e2e tests...")];case 1:t.sent();return[2]}})}))];case 1:e.sent();return[2]}})});return ng.apply(this,arguments)}d(y(h.argv)).command("lint","Run linting checks",q).command("lint:fix","Fix linting and formatting issues",Q).command("lint:inspect","Inspect linting rules",Z).command("lint-staged","Run lint-staged with given configuration",nt).command("commitlint","Run commitlint with given configuration",nr).command("setup","Run setup with given configuration",no).command("reset","Reset dependencies and install",nu).command("test:unit","Run unit tests",nf).command("test:e2e","Run e2e tests",nh).help().parse();
|
|
2
|
+
function n(n,t,e,r,i,c,s){try{var o=n[c](s);var a=o.value}catch(n){e(n);return}if(o.done){t(a)}else{Promise.resolve(a).then(r,i)}}function t(t){return function(){var e=this,r=arguments;return new Promise(function(i,c){var s=t.apply(e,r);function o(t){n(s,i,c,o,a,"next",t)}function a(t){n(s,i,c,o,a,"throw",t)}o(undefined)})}}function e(n,t,e){if(t in n){Object.defineProperty(n,t,{value:e,enumerable:true,configurable:true,writable:true})}else{n[t]=e}return n}function r(n){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var i=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){i=i.concat(Object.getOwnPropertySymbols(r).filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable}))}i.forEach(function(t){e(n,t,r[t])})}return n}function i(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);if(t){r=r.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})}e.push.apply(e,r)}return e}function c(n,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(n,Object.getOwnPropertyDescriptors(t))}else{i(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function s(n,t){var e,r,i,c,s={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return c={next:o(0),"throw":o(1),"return":o(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(t){return a([n,t])}}function a(c){if(e)throw new TypeError("Generator is already executing.");while(s)try{if(e=1,r&&(i=c[0]&2?r["return"]:c[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;if(r=0,i)c=[c[0]&2,i.value];switch(c[0]){case 0:case 1:i=c;break;case 4:s.label++;return{value:c[1],done:false};case 5:s.label++;r=c[1];c=[0];continue;case 7:c=s.ops.pop();s.trys.pop();continue;default:if(!(i=s.trys,i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){s=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){s.label=c[1];break}if(c[0]===6&&s.label<i[1]){s.label=i[1];i=c;break}if(i&&s.label<i[2]){s.label=i[2];s.ops.push(c);break}if(i[2])s.ops.pop();s.trys.pop();continue}c=t.call(n,s)}catch(n){c=[6,n];r=0}finally{e=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}}import o from"boxen";import a from"chalk";import u from"node-fetch";import{exec as l}from"node:child_process";import*as f from"node:fs";import*as p from"node:path";import h from"node:process";import*as g from"node:util";import m from"ora";import{hideBin as d}from"yargs/helpers";import y from"yargs/yargs";import{dirname as _}from"node:path";import{fileURLToPath as b}from"node:url";var v=b(import.meta.url),w=_(v);var I=a.blue,S=a.red,T=a.yellow,O=a.green,P=a.gray,E=a.white,N=a.bold,x=g.promisify(l),C={FILE_EXTENSIONS:"**/*.{ts,tsx,js,jsx,json,css,scss,less}",INIT_CWD:h.env.INIT_CWD||h.cwd(),TSCONFIG_PATH:"".concat(h.env.INIT_CWD||h.cwd(),"/tsconfig.json"),HUSKY_PATH:"".concat(h.env.INIT_CWD||h.cwd(),"/.husky"),GIT_HOOK_PATH:"".concat(h.env.INIT_CWD||h.cwd(),"/.git/hooks"),GIT_COMMIT_MSG:"".concat(h.env.INIT_CWD||h.cwd(),"/.git/COMMIT_EDITMSG"),SIMPLE_GIT_HOOKS_PATH:"".concat(h.env.INIT_CWD||h.cwd(),"/.simple-git-hooks.json"),PACKAGE_NAME:"@cyberskill/shared"},k=[];function j(n){return m({text:n,color:"cyan",spinner:"dots"})}function R(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";var e=new Date().toLocaleString();console.log("".concat(t," [").concat(e,"] ").concat(E(n)))}function A(n,t){return D.apply(this,arguments)}function D(){D=t(function(n,t){var e,r,i,c,o,a,u,l,f;var p=arguments;return s(this,function(s){switch(s.label){case 0:e=p.length>2&&p[2]!==void 0?p[2]:H;R(t);r=new AbortController;h.on("SIGINT",function(){console.log("Terminating process..."),r.abort(),h.exit()});s.label=1;case 1:s.trys.push([1,3,,4]);return[4,x(n,{maxBuffer:0x6400000,signal:r.signal})];case 2:i=s.sent(),c=i.stdout,o=i.stderr;[c,o].forEach(function(n){return n&&e(n)});return[3,4];case 3:a=s.sent();u=a.stdout,l=a.stderr,f=a.message;[u,l].forEach(function(n){return n&&e(n)}),!l&&!u&&console.error("Command failed: ".concat(f));return[3,4];case 4:return[2]}})});return D.apply(this,arguments)}function W(n,t){return G.apply(this,arguments)}function G(){G=t(function(n,t){var e,r;return s(this,function(i){switch(i.label){case 0:e=j(n).start();i.label=1;case 1:i.trys.push([1,3,,4]);return[4,t()];case 2:i.sent(),k.length?h.exit(1):e.succeed("".concat(n," completed successfully!"));return[3,4];case 3:r=i.sent();throw e.fail("".concat(n," failed.")),r;case 4:return[2]}})});return G.apply(this,arguments)}function H(n){try{JSON.parse(n).forEach(function(n){var t=n.filePath,e=n.messages;e.forEach(function(n){var e=n.severity,r=n.line,i=n.column,c=n.ruleId,s=n.message;k.push({type:e===2?"error":"warning",file:t,position:"".concat(r,":").concat(i),rule:c,message:s})})})}catch(t){M(n)}}function M(n){var t=/^\s*(\d+):(\d+)\s+(error|warning)\s+(\S+)\s+(\S+)$/,e=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,r=/^✖\s+(.*?)\s+\[(.*?)\]$/,i=[],c="";n.split("\n").forEach(function(n){if(n.startsWith("/"))c=n.trim();else{var s=t.exec(n);if(s&&c)k.push({file:c,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()});else{var o=e.exec(n);if(o)k.push({file:o[1],position:"".concat(o[2],":").concat(o[3]),type:o[4],message:o[5].trim()});else{var a=r.exec(n);a?k.push({file:"commitlint",type:"error",message:a[1].trim(),rule:a[2].trim()}):i.push(n.trim())}}}}),i.length>0&&(console.log(P("Unmatched lines:")),i.forEach(function(n){return console.info(n)}))}function U(n,t){var e=new Map([[S,"red"],[T,"yellow"],[O,"green"]]).get(t)||"green";return o(N(t(n)),{padding:1,margin:1,borderStyle:"arrow",borderColor:e})}function F(n,t,e,r){n.length&&(n.forEach(function(n){var r=n.file,i=n.position,c=n.rule,s=n.message;console.log("".concat(t("".concat(e," File:"))," ").concat(I("".concat(r).concat(i?":".concat(i):"")))),c&&console.log(" ".concat(t("Rule:")," ").concat(t(c))),console.log(" ".concat(t("Message:")," ").concat(t(s)))}),console.log(U(N(t("".concat(e," Total ").concat(r,": ").concat(n.length))),t)),console.log(P("─".repeat(40))))}function K(){var n=k.filter(function(n){return n.type==="error"}),t=k.filter(function(n){return n.type==="warning"});!n.length&&!t.length?console.log(U(N(O("✔ NO ISSUE FOUND!")),O)):(F(t,T,"⚠","Warnings"),F(n,S,"✖","Errors"))}function L(){return J.apply(this,arguments)}function J(){J=t(function(){var n;return s(this,function(t){switch(t.label){case 0:if(!f.existsSync(C.TSCONFIG_PATH))return[3,2];return[4,A("npx tsc -p ".concat(C.TSCONFIG_PATH," --noEmit"),"TypeScript checking...")];case 1:n=t.sent();return[3,3];case 2:n=R("tsconfig.json file not found.","⚠️");t.label=3;case 3:n;return[2]}})});return J.apply(this,arguments)}function Y(){return $.apply(this,arguments)}function $(){$=t(function(){var n,t;var e=arguments;return s(this,function(r){switch(r.label){case 0:n=e.length>0&&e[0]!==void 0?e[0]:!1;t="npx eslint ".concat(C.INIT_CWD).concat(n?" --fix":" --format json");return[4,A(t,"Eslint ".concat(n?"fixing":"checking","..."))];case 1:r.sent();return[2]}})});return $.apply(this,arguments)}function B(){return X.apply(this,arguments)}function X(){X=t(function(){return s(this,function(n){switch(n.label){case 0:return[4,A('npx lint-staged -- "*": "eslint --fix"',"Lint-staged processing...")];case 1:n.sent();return[2]}})});return X.apply(this,arguments)}function q(){return z.apply(this,arguments)}function z(){z=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting lint check for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,W("Running lint checks...",/*#__PURE__*/t(function(){return s(this,function(n){switch(n.label){case 0:k.length=0;return[4,Promise.all([L(),Y()])];case 1:n.sent(),K();return[2]}})}))];case 1:n.sent();return[2]}})});return z.apply(this,arguments)}function Q(){return V.apply(this,arguments)}function V(){V=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting lint and format fix for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,W("Fixing issues...",/*#__PURE__*/t(function(){return s(this,function(n){switch(n.label){case 0:return[4,Y(!0)];case 1:n.sent();return[2]}})}))];case 1:n.sent();return[2]}})});return V.apply(this,arguments)}function Z(){return nn.apply(this,arguments)}function nn(){nn=t(function(){return s(this,function(n){switch(n.label){case 0:return[4,A("npx @eslint/config-inspector","Lint inspect processing...")];case 1:n.sent();return[2]}})});return nn.apply(this,arguments)}function nt(){return ne.apply(this,arguments)}function ne(){ne=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting lint-staged process for ".concat(h.env.INIT_CWD),"\uD83D\uDE80");return[4,W("Running lint-staged...",/*#__PURE__*/t(function(){return s(this,function(n){switch(n.label){case 0:k.length=0;return[4,Promise.all([L(),B()])];case 1:n.sent(),K();return[2]}})}))];case 1:n.sent();return[2]}})});return ne.apply(this,arguments)}function nr(){return ni.apply(this,arguments)}function ni(){ni=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting commitlint process for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,W("Running commitlint...",/*#__PURE__*/t(function(){var n,t;return s(this,function(e){switch(e.label){case 0:k.length=0;n=p.resolve(w,"./configs/commitlint/commitlint.base.js"),t="npx --no -- commitlint --edit ".concat(C.GIT_COMMIT_MSG," --config ").concat(n);return[4,A(t,"Commitlint processing...")];case 1:e.sent(),K();return[2]}})}))];case 1:n.sent();return[2]}})});return ni.apply(this,arguments)}function nc(){return ns.apply(this,arguments)}function ns(){ns=t(function(){var n;return s(this,function(t){switch(t.label){case 0:n=f.existsSync(C.HUSKY_PATH);if(!n)return[3,2];return[4,A("npx rimraf ".concat(C.HUSKY_PATH," ").concat(C.GIT_HOOK_PATH," && git config core.hooksPath ").concat(C.GIT_HOOK_PATH),"Removing husky hooks...")];case 1:n=t.sent();t.label=2;case 2:n,f.writeFileSync(C.SIMPLE_GIT_HOOKS_PATH,JSON.stringify({"pre-commit":"npx --yes cyberskill lint-staged","commit-msg":"npx --yes cyberskill commitlint"},null,4));return[4,A("npx simple-git-hooks","Setting up git hooks...")];case 3:t.sent(),f.unlinkSync(C.SIMPLE_GIT_HOOKS_PATH);return[2]}})});return ns.apply(this,arguments)}function no(){return na.apply(this,arguments)}function na(){na=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting setup process for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,W("Setting up...",/*#__PURE__*/t(function(){var n,i,o,a,l,p,h,g,m;return s(this,function(d){switch(d.label){case 0:i="".concat(C.INIT_CWD,"/package.json"),o=/*#__PURE__*/function(){var n=t(function(){return s(this,function(n){switch(n.label){case 0:return[4,u("https://registry.npmjs.org/".concat(C.PACKAGE_NAME,"/latest"))];case 1:return[4,n.sent().json()];case 2:return[2,n.sent().version]}})});return function t(){return n.apply(this,arguments)}}(),a=/*#__PURE__*/function(){var n=t(function(){var n,t,e,r;return s(this,function(i){switch(i.label){case 0:return[4,o()];case 1:n=i.sent();try{t="".concat(C.INIT_CWD,"/node_modules/").concat(C.PACKAGE_NAME,"/package.json"),e=JSON.parse(f.readFileSync(t,"utf-8")),r=e.version;return[2,r!==n]}catch(n){return[2,!0]}return[2]}})});return function t(){return n.apply(this,arguments)}}(),l=/*#__PURE__*/function(){var n=t(function(){var n,t;return s(this,function(s){switch(s.label){case 0:return[4,o()];case 1:n=s.sent(),t=JSON.parse(f.readFileSync(i,"utf-8"));t.dependencies=c(r({},t.dependencies),e({},C.PACKAGE_NAME,n)),f.writeFileSync(i,JSON.stringify(t,null,2));return[4,A("npm i -f","Installing all dependencies with updated cyberskill...")];case 2:s.sent();return[4,A("npm run lint:fix","Fixing lint issues...")];case 3:s.sent();return[2]}})});return function t(){return n.apply(this,arguments)}}(),p=JSON.parse(f.readFileSync(i,"utf-8"));if(!(p.name===C.PACKAGE_NAME))return[3,1];h=R("Cyberskill is the current project. No setup needed.","✅");return[3,7];case 1:m=!((n=p.dependencies)===null||n===void 0?void 0:n.cyberskill);if(m)return[3,3];return[4,a()];case 2:m=d.sent();d.label=3;case 3:if(!m)return[3,5];R("Cyberskill is missing or outdated. Updating...");return[4,l()];case 4:g=d.sent();return[3,6];case 5:g=R("Cyberskill is up to date","✅");d.label=6;case 6:h=g;d.label=7;case 7:h,nc();return[2]}})}))];case 1:n.sent();return[2]}})});return na.apply(this,arguments)}function nu(){return nl.apply(this,arguments)}function nl(){nl=t(function(){return s(this,function(n){switch(n.label){case 0:R("Starting reset process for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,W("Resetting...",/*#__PURE__*/t(function(){return s(this,function(n){switch(n.label){case 0:return[4,A("npx rimraf ".concat(C.INIT_CWD,"/node_modules ").concat(C.INIT_CWD,"/package-lock.json"),"Cleaning node_modules and package-lock.json...")];case 1:n.sent();return[4,A("npm i -f","Installing all dependencies...")];case 2:n.sent(),nc();return[2]}})}))];case 1:n.sent();return[2]}})});return nl.apply(this,arguments)}function nf(){return np.apply(this,arguments)}function np(){np=t(function(){var n;return s(this,function(e){switch(e.label){case 0:n=p.resolve(w,"./configs/vitest/react/unit.js");R("Starting unit tests for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,W("Running unit tests...",/*#__PURE__*/t(function(){return s(this,function(t){switch(t.label){case 0:return[4,A("npx vitest --config ".concat(n),"Running unit tests...")];case 1:t.sent();return[2]}})}))];case 1:e.sent();return[2]}})});return np.apply(this,arguments)}function nh(){return ng.apply(this,arguments)}function ng(){ng=t(function(){var n;return s(this,function(e){switch(e.label){case 0:n=p.resolve(w,"./configs/vitest/react/e2e.js");R("Starting e2e tests for ".concat(C.INIT_CWD),"\uD83D\uDE80");return[4,W("Running end-to-end tests...",/*#__PURE__*/t(function(){return s(this,function(t){switch(t.label){case 0:return[4,A("npx vitest --config ".concat(n),"Running e2e tests...")];case 1:t.sent();return[2]}})}))];case 1:e.sent();return[2]}})});return ng.apply(this,arguments)}y(d(h.argv)).command("lint","Run linting checks",q).command("lint:fix","Fix linting and formatting issues",Q).command("lint:inspect","Inspect linting rules",Z).command("lint-staged","Run lint-staged with given configuration",nt).command("commitlint","Run commitlint with given configuration",nr).command("setup","Run setup with given configuration",no).command("reset","Reset dependencies and install",nu).command("test:unit","Run unit tests",nf).command("test:e2e","Run e2e tests",nh).help().parse();
|