@cyberskill/shared 1.145.0 → 1.146.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(t){if(Array.isArray(t))return e(t)}function r(e,t,n,r,i,s,o){try{var a=e[s](o);var c=a.value}catch(e){n(e);return}if(a.done){t(c)}else{Promise.resolve(c).then(r,i)}}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,s){var o=e.apply(t,n);function a(e){r(o,i,s,a,c,"next",e)}function c(e){r(o,i,s,a,c,"throw",e)}a(undefined)})}}function s(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function o(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function a(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function c(e,t){var n=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n==null)return;var r=[];var i=true;var s=false;var o,a;try{for(n=n.call(e);!(i=(o=n.next()).done);i=true){r.push(o.value);if(t&&r.length===t)break}}catch(e){s=true;a=e}finally{try{if(!i&&n["return"]!=null)n["return"]()}finally{if(s)throw a}}return r}function u(){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 l(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var r=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}r.forEach(function(t){s(e,t,n[t])})}return e}function p(e,n){return t(e)||c(e,n)||m(e,n)||u()}function E(e){return n(e)||a(e)||m(e)||l()}function f(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function m(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}function g(e,t){var n,r,i,s={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return o.next=a(0),o["throw"]=a(1),o["return"]=a(2),typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(e){return function(t){return c([e,t])}}function c(a){if(n)throw new TypeError("Generator is already executing.");while(o&&(o=0,a[0]&&(s=0)),s)try{if(n=1,r&&(i=a[0]&2?r["return"]:a[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;if(r=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:s.label++;return{value:a[1],done:false};case 5:s.label++;r=a[1];a=[0];continue;case 7:a=s.ops.pop();s.trys.pop();continue;default:if(!(i=s.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){s=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(a[0]===6&&s.label<i[1]){s.label=i[1];i=a;break}if(i&&s.label<i[2]){s.label=i[2];s.ops.push(a);break}if(i[2])s.ops.pop();s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e];r=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var y=Object.defineProperty;var h=function(e,t){return y(e,"name",{value:t,configurable:!0})};import S from"node:process";import{hideBin as v}from"yargs/helpers";import D from"yargs/yargs";var O={name:"@cyberskill/shared",type:"module",version:"1.144.0",description:"CyberSkill Shared",author:"Stephen Cheng",license:"MIT",homepage:"https://github.com/cyberskill-world/shared#readme",repository:{type:"git",url:"git+https://github.com/cyberskill-world/shared.git"},bugs:{url:"https://github.com/cyberskill-world/shared/issues"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./config":{types:"./dist/config/index.d.ts",import:"./dist/config/index.js",require:"./dist/config/index.cjs"},"./config/commitlint":{types:"./dist/config/commitlint/index.d.ts",import:"./dist/config/commitlint/index.js",require:"./dist/config/commitlint/index.cjs"},"./config/env":{types:"./dist/config/env/index.d.ts",import:"./dist/config/env/index.js",require:"./dist/config/env/index.cjs"},"./config/eslint":{types:"./dist/config/eslint/index.d.ts",import:"./dist/config/eslint/index.js",require:"./dist/config/eslint/index.cjs"},"./config/graphql-codegen":{types:"./dist/config/graphql-codegen/index.d.ts",import:"./dist/config/graphql-codegen/index.js",require:"./dist/config/graphql-codegen/index.cjs"},"./config/lint-staged":{types:"./dist/config/lint-staged/index.d.ts",import:"./dist/config/lint-staged/index.js",require:"./dist/config/lint-staged/index.cjs"},"./constant":{types:"./dist/constant/index.d.ts",import:"./dist/constant/index.js",require:"./dist/constant/index.cjs"},"./node":{types:"./dist/node/index.d.ts",import:"./dist/node/index.js",require:"./dist/node/index.cjs"},"./node/apollo-server":{types:"./dist/node/apollo-server/index.d.ts",import:"./dist/node/apollo-server/index.js",require:"./dist/node/apollo-server/index.cjs"},"./node/cli":{types:"./dist/node/cli/index.d.ts",import:"./dist/node/cli/index.js",require:"./dist/node/cli/index.cjs"},"./node/command":{types:"./dist/node/command/index.d.ts",import:"./dist/node/command/index.js",require:"./dist/node/command/index.cjs"},"./node/express":{types:"./dist/node/express/index.d.ts",import:"./dist/node/express/index.js",require:"./dist/node/express/index.cjs"},"./node/fs":{types:"./dist/node/fs/index.d.ts",import:"./dist/node/fs/index.js",require:"./dist/node/fs/index.cjs"},"./node/log":{types:"./dist/node/log/index.d.ts",import:"./dist/node/log/index.js",require:"./dist/node/log/index.cjs"},"./node/mongo":{types:"./dist/node/mongo/index.d.ts",import:"./dist/node/mongo/index.js",require:"./dist/node/mongo/index.cjs"},"./node/package":{types:"./dist/node/package/index.d.ts",import:"./dist/node/package/index.js",require:"./dist/node/package/index.cjs"},"./node/path":{types:"./dist/node/path/index.d.ts",import:"./dist/node/path/index.js",require:"./dist/node/path/index.cjs"},"./node/storage":{types:"./dist/node/storage/index.d.ts",import:"./dist/node/storage/index.js",require:"./dist/node/storage/index.cjs"},"./node/ws":{types:"./dist/node/ws/index.d.ts",import:"./dist/node/ws/index.js",require:"./dist/node/ws/index.cjs"},"./react":{types:"./dist/react/index.d.ts",import:"./dist/react/index.js",require:"./dist/react/index.cjs"},"./react/apollo-client":{types:"./dist/react/apollo-client/index.d.ts",import:"./dist/react/apollo-client/index.js",require:"./dist/react/apollo-client/index.cjs"},"./react/apollo-error":{types:"./dist/react/apollo-error/index.d.ts",import:"./dist/react/apollo-error/index.js",require:"./dist/react/apollo-error/index.cjs"},"./react/i18next":{types:"./dist/react/i18next/index.d.ts",import:"./dist/react/i18next/index.js",require:"./dist/react/i18next/index.cjs"},"./react/loading":{types:"./dist/react/loading/index.d.ts",import:"./dist/react/loading/index.js",require:"./dist/react/loading/index.cjs"},"./react/log":{types:"./dist/react/log/index.d.ts",import:"./dist/react/log/index.js",require:"./dist/react/log/index.cjs"},"./react/next-intl":{types:"./dist/react/next-intl/index.d.ts",import:"./dist/react/next-intl/index.js",require:"./dist/react/next-intl/index.cjs"},"./react/storage":{types:"./dist/react/storage/index.d.ts",import:"./dist/react/storage/index.js",require:"./dist/react/storage/index.cjs"},"./react/toast":{types:"./dist/react/toast/index.d.ts",import:"./dist/react/toast/index.js",require:"./dist/react/toast/index.cjs"},"./react/vitest":{types:"./dist/react/vitest/index.d.ts",import:"./dist/react/vitest/index.js",require:"./dist/react/vitest/index.cjs"},"./style/reset.css":{import:"./dist/style/reset.css",require:"./dist/style/reset.css"},"./typescript":{types:"./dist/typescript/index.d.ts",import:"./dist/typescript/index.js",require:"./dist/typescript/index.cjs"},"./util":{types:"./dist/util/index.d.ts",import:"./dist/util/index.js",require:"./dist/util/index.cjs"}},typesVersions:{"*":{config:["dist/config/index.d.ts"],constant:["dist/constant/index.d.ts"],node:["dist/node/index.d.ts"],react:["dist/react/index.d.ts"],typescript:["dist/typescript/index.d.ts"],util:["dist/util/index.d.ts"]}},bin:{cyberskill:"dist/node/cli/index.js"},files:["dist","public"],scripts:{build:"tsup",dev:"tsup --watch",lint:"tsx src/node/cli/index.ts lint","lint:fix":"tsx src/node/cli/index.ts lint:fix","lint:inspect":"tsx src/node/cli/index.ts lint:inspect",reset:"tsx src/node/cli/index.ts reset",prepare:"tsx src/node/cli/index.ts prepare",inspect:"tsx src/node/cli/index.ts inspect","test:unit":"tsx src/node/cli/index.ts test:unit","test:e2e":"tsx src/node/cli/index.ts test:e2e",commitlint:"tsx src/node/cli/index.ts commitlint"},dependencies:{"@antfu/eslint-config":"4.13.0","@apollo/client":"3.13.8","@apollo/server":"4.12.0","@dotenvx/dotenvx":"1.43.0","@eddeee888/gcg-typescript-resolver-files":"0.12.0","@eslint-react/eslint-plugin":"1.49.0","@graphql-codegen/cli":"5.0.6","@graphql-codegen/client-preset":"4.8.1","@microsoft/api-extractor":"7.52.7","@nestjs/common":"11.1.0","@nestjs/core":"11.1.0","@next/eslint-plugin-next":"15.3.2","@testing-library/jest-dom":"6.6.3","@testing-library/react":"16.3.0","@vitejs/plugin-react-swc":"3.9.0","@vitest/browser":"3.1.3","body-parser":"2.2.0",chalk:"5.4.1",classnames:"2.5.1",compression:"1.8.0",consola:"3.4.2","cookie-parser":"1.4.7",cors:"2.8.5","crypto-js":"4.2.0","date-fns":"4.1.0","dotenv-cli":"8.0.0",envalid:"8.0.0","eslint-config-next":"15.3.2","eslint-plugin-format":"1.0.1","eslint-plugin-react-hooks":"5.2.0","eslint-plugin-react-refresh":"0.4.20",express:"4.21.2","express-session":"1.18.1","express-useragent":"1.0.15","fs-extra":"11.3.0",globals:"16.1.0",graphql:"16.11.0","graphql-ws":"6.0.4",i18next:"25.1.1",jsdom:"26.1.0",localforage:"1.10.0","migrate-mongo":"12.1.3","modern-normalize":"3.0.1",mongodb:"6.16.0",mongoose:"8.14.1","mongoose-aggregate-paginate-v2":"1.1.4","mongoose-paginate-v2":"1.9.0","next-intl":"4.1.0","node-fetch":"3.3.2","node-persist":"4.0.4",playwright:"1.52.0","postcss-modules":"6.0.1",qs:"6.14.0",react:"19.1.0","react-dom":"19.1.0","react-hot-toast":"2.5.2","react-i18next":"15.5.1","react-icons":"5.5.0",sass:"1.87.0",slugify:"1.6.6",tsup:"8.4.0",tsx:"4.19.4",typescript:"5.8.3",unorm:"1.6.0",uuid:"11.1.0",vite:"6.3.5",vitest:"3.1.3","vitest-browser-react":"0.1.1",ws:"8.18.2",yargs:"17.7.2"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},devDependencies:{"@commitlint/cli":"19.8.0","@commitlint/config-conventional":"19.8.0","@eslint/config-inspector":"1.0.2","@types/body-parser":"1.19.5","@types/compression":"1.7.5","@types/cookie-parser":"1.4.8","@types/cors":"2.8.17","@types/crypto-js":"4.2.2","@types/express":"4.17.21","@types/express-session":"1.18.1","@types/express-useragent":"1.0.5","@types/fs-extra":"11.0.4","@types/migrate-mongo":"10.0.5","@types/mongoose-aggregate-paginate-v2":"1.0.12","@types/node":"22.15.14","@types/node-persist":"3.1.8","@types/react":"19.1.3","@types/react-dom":"19.1.3","@types/unorm":"1.3.31","@types/uuid":"10.0.0","@types/ws":"8.18.1","@types/yargs":"17.0.33",eslint:"9.26.0","lint-staged":"15.5.2","node-modules-inspector":"0.6.8","simple-git-hooks":"2.13.0"}};var C=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});import{exec as I}from"node:child_process";import N from"node:process";import*as T from"node:util";var x=".cyberskill-storage";import A from"@dotenvx/dotenvx";import{bool as _,cleanEnv as R,str as G}from"envalid";import b from"node:os";import P from"node:path";import M from"node:process";var w=!1;function j(){w||(A.config(),w=!0)}h(j,"loadEnvFile");function L(){j();var e=R(M.env,{CWD:G({default:M.cwd()}),DEBUG:_({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:G({default:P.join(b.homedir(),x)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}h(L,"getEnv");var U=function(e){return e.Error="error",e.Warning="warning",e}({});import k from"chalk";import F from"consola";import{GraphQLError as q}from"graphql";var Y={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};var V=L();V.DEBUG||(F.level=4);function B(e){var t=k[e];return typeof t=="function"?t:k.green}h(B,"chalkKeyword");var K={silent:F.silent,level:F.level,fatal:F.fatal,error:F.error,warn:F.warn,log:F.log,info:F.info,success:F.success,ready:F.ready,start:F.start,box:F.box,debug:F.debug,trace:F.trace,verbose:F.verbose,printBoxedLog:function e(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(t===null||t===void 0?void 0:t.length)){F.box(k.green(e));return}t.forEach(function(e){var t=e.file,r=e.position,i=e.rule,s=e.message;F.log("".concat(k.gray("File:")," ").concat(k.blue("".concat(t).concat(r?":".concat(r):"")))),i&&F.log(" ".concat(B(n)("Rule:")," ").concat(i)),F.log(" ".concat(B(n)("Message:")," ").concat(s))}),F.box(B(n)("".concat(e," : ").concat(t.length))),F.log(k.gray("─".repeat(40)))}};function H(e,t){var n=t!==null&&t!==void 0?t:{},r=n.shouldLog,i=r===void 0?!0:r,s=n.returnValue,a=n.callback,c=o(e,Error)?e:new Error(typeof e=="string"?e:"Unknown error");return i&&K.error(c.message),a&&typeof a=="function"&&a(c),s||{success:!1,message:c.message,code:Y.INTERNAL_SERVER_ERROR.CODE}}h(H,"catchError");var Q=function(e){return e.DEPENDENCY="dependencies",e.DEV_DEPENDENCY="devDependencies",e.PEER_DEPENDENCY="peerDependencies",e.BUNDLE_DEPENDENCY="bundleDependencies",e.OPTIONAL_DEPENDENCY="optionalDependencies",e}({});import W from"node-fetch";import J from"fs-extra";var z=J.lstatSync,$=J.readdirSync,X=J.mkdirSync,Z=J.readFileSync,ee=J.unlinkSync,et=J.statSync,en=J.readJsonSync;function er(e,t,n){J.writeFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}h(er,"writeFileSync");function ei(e,t,n){J.appendFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}h(ei,"appendFileSync");function es(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}return t.every(function(e){return J.pathExistsSync(e)})}h(es,"pathExistsSync");function eo(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}t.forEach(function(e){es(e)&&J.removeSync(e)})}h(eo,"removeSync");import ea from"fs-extra";import ec from"node:path";var eu=L(),el=ec;function ed(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=el).resolve.apply(r,[eu.CWD].concat(E(t)))}h(ed,"resolveWorkingPath");function ep(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=el).join.apply(r,E(t))}h(ep,"join");var eE=L(),ef=eE.CWD,em="@cyberskill/shared",eg="node_modules",ey="dist",eh="package.json",eS="package-lock.json",ev="tsconfig.json",eD=".gitignore",eO=".simple-git-hooks.json",eC="pnpm-lock.yaml",eI=".git/hooks/",eN=".git/COMMIT_EDITMSG",eT=".migrate-mongo.config.js",ex=function(){var e=ea.readJsonSync(ed(eh)).name===em?ef:ep(ef,eg,em);return ep(e,ey)}(),eA="cyberskill",e_="src/node/cli/index.ts",eR="eslint",eG="eslint",eb="vitest";var eP="vitest",eM="@commitlint/cli",ew="@commitlint/config-conventional",ej="commitlint",eL="lint-staged",eU="lint-staged",ek="typescript",eF="tsc",eq="tsx",eY="git",eV="pnpm",eB="pnpm exec",eK="simple-git-hooks",eH="simple-git-hooks",eQ="@eslint/config-inspector",eW="eslint-config-inspector",eJ="node-modules-inspector",ez="node-modules-inspector",e$="migrate-mongo",eX="./node_modules/migrate-mongo/bin/migrate-mongo",eZ={CYBERSKILL_DIRECTORY:ex,WORKING_DIRECTORY:ef,TS_CONFIG:ed(ev),GIT_IGNORE:ed(eD),GIT_HOOK:ed(eI),GIT_COMMIT_MSG:ed(eN),SIMPLE_GIT_HOOKS_JSON:ed(eO),PACKAGE_JSON:ed(eh),PACKAGE_LOCK_JSON:ed(eS),PNPM_LOCK_YAML:ed(eC),NODE_MODULES:ed(eg),MIGRATE_MONGO_CONFIG:ed(eT),LINT_STAGED_CONFIG:ed("".concat(ex,"/config/lint-staged/index.js")),COMMITLINT_CONFIG:ed("".concat(ex,"/config/commitlint/index.js")),UNIT_TEST_CONFIG:ed("".concat(ex,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:ed("".concat(ex,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:ed("".concat(ex,"/react/vitest/vitest.e2e.js"))};function e0(e){var t=e.isCurrentProject;return d({"pre-commit":eU,"commit-msg":ej},t&&{"pre-push":tp("".concat(eY," pull"))})}h(e0,"createGitHooksConfig");function e1(e){var t=e.type,n=e.packages,r=e.command;var s=n===null||n===void 0?void 0:n.reduce(function(e,t){return e.some(function(e){return e.name===t.name})||e.push(t),e},[]);return function(){return i(function(){var e;return g(this,function(n){switch(n.label){case 0:switch(t){case C.CLI:return[3,1];case C.STRING:return[3,4]}return[3,5];case 1:e=s===null||s===void 0?void 0:s.length;if(!e)return[3,3];return[4,e7(s,{update:!0})];case 2:e=n.sent();n.label=3;case 3:return[2,(e,tf(tp("".concat(eB," ").concat(r))))];case 4:return[2,tf(tp(r))];case 5:throw new Error("Unsupported command type");case 6:return[2]}})})()}}h(e1,"buildCommand");var e2={simpleGitHooks:e1({type:C.CLI,packages:[{name:eK,type:Q.DEV_DEPENDENCY}],command:eH}),eslintInspect:e1({type:C.CLI,packages:[{name:eQ,type:Q.DEV_DEPENDENCY}],command:eW}),nodeModulesInspect:e1({type:C.CLI,packages:[{name:eJ,type:Q.DEV_DEPENDENCY}],command:ez}),eslintCheck:e1({type:C.CLI,packages:[{name:eR,type:Q.DEV_DEPENDENCY}],command:"".concat(eG," ").concat(eZ.WORKING_DIRECTORY," --no-cache")}),eslintFix:e1({type:C.CLI,packages:[{name:eR,type:Q.DEV_DEPENDENCY}],command:"".concat(eG," ").concat(eZ.WORKING_DIRECTORY," --fix --no-cache")}),typescriptCheck:e1({type:C.CLI,packages:[{name:ek,type:Q.DEPENDENCY}],command:"".concat(eF," -p ").concat(eZ.TS_CONFIG," --noEmit")}),testUnit:e1({type:C.CLI,packages:[{name:eb,type:Q.DEV_DEPENDENCY}],command:"".concat(eP," --config ").concat(eZ.UNIT_TEST_CONFIG)}),testE2e:e1({type:C.CLI,packages:[{name:eb,type:Q.DEV_DEPENDENCY}],command:"".concat(eP," --config ").concat(eZ.E2E_TEST_CONFIG)}),mongoMigrateCreate:h(function(e){return e1({type:C.CLI,packages:[{name:e$,type:Q.DEPENDENCY}],command:"".concat(eq," ").concat(eX," create ").concat(e," -f ").concat(eZ.MIGRATE_MONGO_CONFIG)})()},"mongoMigrateCreate"),mongoMigrateUp:e1({type:C.CLI,packages:[{name:e$,type:Q.DEPENDENCY}],command:"".concat(eq," ").concat(eX," up -f ").concat(eZ.MIGRATE_MONGO_CONFIG)}),mongoMigrateDown:e1({type:C.CLI,packages:[{name:e$,type:Q.DEPENDENCY}],command:"".concat(eq," ").concat(eX," down -f ").concat(eZ.MIGRATE_MONGO_CONFIG)}),commitLint:e1({type:C.CLI,packages:[{name:eM,type:Q.DEV_DEPENDENCY},{name:ew,type:Q.DEV_DEPENDENCY}],command:"".concat(ej," --edit ").concat(eZ.GIT_COMMIT_MSG," --config ").concat(eZ.COMMITLINT_CONFIG)}),lintStaged:e1({type:C.CLI,packages:[{name:eL,type:Q.DEV_DEPENDENCY}],command:"".concat(eU," --config ").concat(eZ.LINT_STAGED_CONFIG)}),configureGitHook:e1({type:C.STRING,command:"".concat(eY," config core.hooksPath ").concat(eZ.GIT_HOOK)}),build:e1({type:C.STRING,command:"".concat(eV," run --if-present build")}),pnpmInstallStandard:e1({type:C.STRING,command:"".concat(eV," install --ignore-scripts --no-frozen-lockfile")}),pnpmInstallLegacy:e1({type:C.STRING,command:"".concat(eV," install --ignore-scripts --no-frozen-lockfile --legacy-peer-deps")}),pnpmInstallForce:e1({type:C.STRING,command:"".concat(eV," install --ignore-scripts --no-frozen-lockfile --force")})};var e4=L();function e3(e){return i(function(){var t,n,r,i;return g(this,function(s){switch(s.label){case 0:s.trys.push([0,3,,4]);return[4,W("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:t=s.sent();if(!t.ok)throw new Error("Failed to fetch latest version: ".concat(t.status," ").concat(t.statusText));return[4,t.json()];case 2:n=s.sent(),r=n.version;return[2,{success:!0,result:r}];case 3:i=s.sent();return[2,H(i)];case 4:return[2]}})})()}h(e3,"getLatestPackageVersion");function e5(e){return i(function(){var t,n,r,i,s,o,a,c,u,l,d,p,E,f,m,y,h,S,v,D,O,C,I,N;return g(this,function(g){switch(g.label){case 0:g.trys.push([0,2,,3]);if(!e){if(es(eZ.PACKAGE_JSON)){t=en(eZ.PACKAGE_JSON),n=t.name,r=n===void 0?"":n,i=t.version,s=i===void 0?"":i;return[2,{success:!0,result:{name:r,currentVersion:s,latestVersion:s,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:!1,isDevDependency:!1,installedPath:eZ.PACKAGE_JSON,file:t}}]}return[2,{success:!0,result:{name:"",currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:!1,isDevDependency:!1,installedPath:"",file:{}}}]}if(!es(eZ.PACKAGE_JSON))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===Q.DEPENDENCY,isDevDependency:e.type===Q.DEV_DEPENDENCY,installedPath:"",file:{}}}];o=en(eZ.PACKAGE_JSON),a=o.name,c=o.version,u=c===void 0?"":c,l=o.dependencies,d=l===void 0?{}:l,p=o.devDependencies,E=p===void 0?{}:p;if(e.name===a)return[2,{success:!0,result:{name:a,currentVersion:u,latestVersion:u,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:e.type===Q.DEPENDENCY,isDevDependency:e.type===Q.DEV_DEPENDENCY,installedPath:eZ.PACKAGE_JSON,file:o}}];f=e.name in d,m=e.name in E;return[4,e3(e.name)];case 1:y=g.sent();if(!y.success)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:f,isDevDependency:m,installedPath:"",file:{}}}];if(!f&&!m)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:y.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===Q.DEPENDENCY,isDevDependency:e.type===Q.DEV_DEPENDENCY,installedPath:"",file:{}}}];v=(S=(h=d[e.name])!==null&&h!==void 0?h:E[e.name])!==null&&S!==void 0?S:"",D=ep(e4.CWD,eg,e.name,eh);if(!es(D))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:y.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:f,isDevDependency:m,installedPath:"",file:{}}}];O=en(D),C=O.version,I=C===void 0?"":C;return[2,v!==I?{success:!0,result:{name:e.name,currentVersion:I||v,latestVersion:y.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:!1,isDependency:f,isDevDependency:m,installedPath:D,file:O}}:{success:!0,result:{name:e.name,currentVersion:v,latestVersion:y.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:v===y.result,isDependency:f,isDevDependency:m,installedPath:D,file:O}}];case 2:N=g.sent();return[2,H(N)];case 3:return[2]}})})()}h(e5,"getPackage");function e8(e){return i(function(){var t,n,r,i,s;return g(this,function(o){try{;r=en(eZ.PACKAGE_JSON),i=(t=r.dependencies)!==null&&t!==void 0?t:{},s=(n=r.devDependencies)!==null&&n!==void 0?n:{};e.isDependency?i[e.name]=e.latestVersion:e.isDevDependency&&(s[e.name]=e.latestVersion),er(eZ.PACKAGE_JSON,JSON.stringify(r,null,4)),K.info('Updated "'.concat(e.name,'" to version ').concat(e.latestVersion))}catch(e){H(e)}return[2]})})()}h(e8,"updatePackage");function e6(){return i(function(){var e,t,n,r,i,s,o,a,c,u,l,d,p;return g(this,function(E){switch(E.label){case 0:E.trys.push([0,12,,13]);e=[{command:h(function(){return e2.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:h(function(){return e2.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:h(function(){return e2.pnpmInstallForce()},"command"),message:"Retrying with force install"}];t=true,n=false,r=undefined;E.label=1;case 1:E.trys.push([1,9,10,11]);i=e[Symbol.iterator]();E.label=2;case 2:if(!!(t=(s=i.next()).done))return[3,8];o=s.value,a=o.command,c=o.message;E.label=3;case 3:E.trys.push([3,6,,7]);return[4,a()];case 4:u=E.sent();return[4,tg("".concat(c," using: ").concat(u),u)];case 5:E.sent();return[2];case 6:l=E.sent();H(l);return[3,7];case 7:t=true;return[3,2];case 8:return[3,11];case 9:d=E.sent();n=true;r=d;return[3,11];case 10:try{if(!t&&i.return!=null){i.return()}}finally{if(n){throw r}}return[7];case 11:return[3,13];case 12:p=E.sent();H(p);return[3,13];case 13:return[2]}})})()}h(e6,"installDependencies");function e7(e,t){return i(function(){var n,r,i,s,o,a,c,u,l,d,p,E;return g(this,function(f){switch(f.label){case 0:if(!es(eZ.PACKAGE_JSON)){K.error("package.json not found. Aborting setup.");return[2]}f.label=1;case 1:f.trys.push([1,16,,17]);return[4,Promise.all(e.map(e5))];case 2:n=f.sent().filter(function(e){return e.success?!e.result.isCurrentProject&&(!e.result.isInstalled||!e.result.isUpToDate):!1});r=n.length>0;if(!r)return[3,7];return[4,Promise.all(n.map(function(e){return e.success?e8(e.result):Promise.resolve()}))];case 3:f.sent();return[4,e6()];case 4:f.sent();i=["Running ESLint with auto-fix"];return[4,e2.eslintFix()];case 5:return[4,tg.apply(void 0,i.concat([f.sent()]))];case 6:r=f.sent();f.label=7;case 7:r;o=true,a=false,c=undefined;f.label=8;case 8:f.trys.push([8,13,14,15]);u=((s=t===null||t===void 0?void 0:t.postInstallActions)!==null&&s!==void 0?s:[])[Symbol.iterator]();f.label=9;case 9:if(!!(o=(l=u.next()).done))return[3,12];d=l.value;return[4,d()];case 10:f.sent();f.label=11;case 11:o=true;return[3,9];case 12:return[3,15];case 13:p=f.sent();a=true;c=p;return[3,15];case 14:try{if(!o&&u.return!=null){u.return()}}finally{if(a){throw c}}return[7];case 15:return[3,17];case 16:E=f.sent();H(E);return[3,17];case 17:return[2]}})})()}h(e7,"setupPackages");import e9 from"node-persist";var te=L();function tt(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=e9.defaultInstance;if(e)return[3,2];return[4,e9.init({dir:te.CYBERSKILL_STORAGE_DIRECTORY})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})})()}h(tt,"initNodePersist");var tn={get:function e(e){return i(function(){var t,n;return g(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tt()];case 1:r.sent();return[4,e9.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,H(n,{returnValue:null})];case 4:return[2]}})})()},set:function e(e,t){return i(function(){var n;return g(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tt()];case 1:r.sent();return[4,e9.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();H(n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return i(function(){var t;return g(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tt()];case 1:n.sent();return[4,e9.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();H(t);return[3,4];case 4:return[2]}})})()},keys:function e(){return i(function(){var e,t;return g(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tt()];case 1:n.sent();return[4,e9.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(K.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,H(t,{returnValue:[]})];case 4:return[2]}})})()},getLogLink:function e(e){return i(function(){return g(this,function(t){try{return[2,"".concat(te.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,H(e,{returnValue:null})]}return[2]})})()}};var tr=L(),ti=T.promisify(I);function ts(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,e5()];case 1:e=t.sent();return[2,e.success?e.result.name:Date.now().toString()]}})})()}h(ts,"getPackageName");function to(e){return i(function(){var t,n;return g(this,function(r){switch(r.label){case 0:if(e.length===0)return[2];return[4,ts()];case 1:t=r.sent();r.label=2;case 2:r.trys.push([2,4,,5]);return[4,tn.set(t,e)];case 3:r.sent(),setTimeout(function(){return i(function(){var e;return g(this,function(n){switch(n.label){case 0:return[4,tn.getLogLink(t)];case 1:e=n.sent();e&&K.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},0);return[3,5];case 4:n=r.sent();H(n);return[3,5];case 5:return[2]}})})()}h(to,"saveErrorListToStorage");function ta(){return i(function(){var e,t,n;return g(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,ts()];case 1:e=r.sent();return[4,tn.get(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:[]];case 3:n=r.sent();return[2,H(n,{returnValue:[]})];case 4:return[2]}})})()}h(ta,"getStoredErrorLists");function tc(){return i(function(){var e,t;return g(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,ts()];case 1:e=n.sent();return[4,tn.remove(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();H(t);return[3,4];case 4:return[2]}})})()}h(tc,"clearAllErrorLists");function tu(e){var t=[],n=[],r="",i=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,s=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,o=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var a,c,u,l,d;var p=i.exec(e)||[],E=s.exec(e)||[],f=o.exec(e)||[];var m,g,y,h,S,v;p.length&&r?t.push({file:r,position:"".concat(p[1],":").concat(p[2]),type:p[3]===U.Error?U.Error:U.Warning,message:(m=p===null||p===void 0?void 0:(a=p[4])===null||a===void 0?void 0:a.trim())!==null&&m!==void 0?m:"",rule:(g=p===null||p===void 0?void 0:(c=p[5])===null||c===void 0?void 0:c.trim())!==null&&g!==void 0?g:""}):E.length?t.push({file:(y=E===null||E===void 0?void 0:E[1])!==null&&y!==void 0?y:"",position:"".concat(E[2],":").concat(E[3]),type:E[4]===U.Error?U.Error:U.Warning,message:(h=E===null||E===void 0?void 0:(u=E[5])===null||u===void 0?void 0:u.trim())!==null&&h!==void 0?h:""}):f.length?t.push({file:"commitlint",type:U.Error,message:(S=f===null||f===void 0?void 0:(l=f[1])===null||l===void 0?void 0:l.trim())!==null&&S!==void 0?S:"",rule:(v=f===null||f===void 0?void 0:(d=f[2])===null||d===void 0?void 0:d.trim())!==null&&v!==void 0?v:""}):n.push(e.trim())}}),t.length&&to(t),tr.DEBUG&&n.length&&(K.warn("Unmatched lines:"),n.forEach(function(e){return K.info(" ".concat(e))}))}h(tu,"parseTextErrors");function tl(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,i=e.line,s=e.column,o=e.ruleId,a=e.message;n.push({type:r===2?U.Error:U.Warning,file:t,position:"".concat(i,":").concat(s),rule:o,message:a})})}),n.length&&to(n)}catch(t){tu(e)}}h(tl,"parseCommandOutput");function td(e){return i(function(e){var t,n,r,i,s,o,a,c,u;var l=arguments;return g(this,function(d){switch(d.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:tl;n=new AbortController;N.on("SIGINT",function(){K.warn("Process interrupted. Terminating..."),n.abort(),N.exit()});d.label=1;case 1:d.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,ti(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=d.sent(),i=r.stdout,s=r.stderr;[i,s].forEach(function(e){return e&&t(e)});d.label=3;case 3:return[3,5];case 4:o=d.sent();a=o.stdout,c=o.stderr,u=o.message;[a,c].forEach(function(e){return e&&t(e)}),!c&&!a&&K.error("Command failed: ".concat(u));return[3,5];case 5:return[2]}})}).apply(this,arguments)}h(td,"executeCommand");function tp(e){return{raw:!0,cmd:e}}h(tp,"rawCommand");function tE(e,t){return(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(eB," ").concat(eq," ").concat(e_," ").concat(e):"".concat(eB," ").concat(eA," ").concat(e)}h(tE,"formatCLI");function tf(e,t){return typeof e=="function"?tE(e(t),t):(typeof e==="undefined"?"undefined":f(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?tE(e,t):e}h(tf,"formatCommand");function tm(e){return i(function(){var t,n,r;return g(this,function(i){switch(i.label){case 0:return[4,e5({name:em})];case 1:t=i.sent();if(t.success){n={isCurrentProject:t.result.isCurrentProject},r=typeof e=="function"?e(n):e;return[2,Object.fromEntries(Object.entries(r).map(function(e){var t=p(e,2),r=t[0],i=t[1];return[r,tf(i,n)]}))]}return[2]}})})()}h(tm,"resolveCommands");function tg(e,t){return i(function(){var n;return g(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);K.start("".concat(e)),tr.DEBUG&&K.info("→ ".concat(t));return[4,td(t)];case 1:r.sent(),K.success("".concat(e," done."));return[3,3];case 2:n=r.sent();H(n);return[3,3];case 3:return[2]}})})()}h(tg,"runCommand");function ty(){return i(function(){var e,t;return g(this,function(n){switch(n.label){case 0:if(!es(eZ.TS_CONFIG))return[3,3];t=["Performing TypeScript validation"];return[4,e2.typescriptCheck()];case 1:return[4,tg.apply(void 0,t.concat([n.sent()]))];case 2:e=n.sent();return[3,4];case 3:e=K.warn("No TypeScript configuration found. Skipping type check.");n.label=4;case 4:e;return[2]}})})()}h(ty,"checkTypescript");function th(){return i(function(){var e,t,n,r;var i=arguments;return g(this,function(s){switch(s.label){case 0:e=i.length>0&&i[0]!==void 0?i[0]:!1;if(!e)return[3,3];n=["Running ESLint with auto-fix"];return[4,e2.eslintFix()];case 1:return[4,tg.apply(void 0,n.concat([s.sent()]))];case 2:t=s.sent();return[3,6];case 3:r=["Running ESLint check"];return[4,e2.eslintCheck()];case 4:return[4,tg.apply(void 0,r.concat([s.sent()]))];case 5:t=s.sent();s.label=6;case 6:t;return[2]}})}).apply(this,arguments)}h(th,"checkEslint");function tS(e,t){if(!t.length)return;var n=e==="Errors"?"red":"yellow";K.printBoxedLog(e==="Errors"?"✖ Errors":"⚠ Warnings",t,n)}h(tS,"printIssues");function tv(){return i(function(){return g(this,function(e){setTimeout(function(){return i(function(){var e,t,n;return g(this,function(r){switch(r.label){case 0:return[4,ta()];case 1:e=r.sent(),t=e.filter(function(e){return e.type===U.Error}),n=e.filter(function(e){return e.type===U.Warning});!t.length&&!n.length?K.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(tS("Warnings",n),tS("Errors",t),(t.length>0||n.length>0)&&S.exit(1));return[2]}})})()},0);return[2]})})()}h(tv,"showCheckResult");function tD(){return i(function(){var e,t,n,r;return g(this,function(i){switch(i.label){case 0:return[4,tc()];case 1:i.sent();return[4,e5({name:em})];case 2:e=i.sent();if(!e.success){K.error("Failed to retrieve package information. Aborting lint-staged.");return[2]}t=e.result.isCurrentProject;if(!t)return[3,5];n=["Building package: ".concat(em)];return[4,e2.build()];case 3:return[4,tg.apply(void 0,n.concat([i.sent()]))];case 4:t=i.sent();i.label=5;case 5:t;r=["Executing lint-staged"];return[4,e2.lintStaged()];case 6:return[4,tg.apply(void 0,r.concat([i.sent()]))];case 7:i.sent(),tv();return[2]}})})()}h(tD,"lintStaged");function tO(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Inspecting ESLint configuration"];return[4,e2.eslintInspect()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(tO,"inspectLint");function tC(){return i(function(){return g(this,function(e){switch(e.label){case 0:return[4,tc()];case 1:e.sent();return[4,Promise.all([ty(),th()])];case 2:e.sent(),tv();return[2]}})})()}h(tC,"lintCheck");function tI(){return i(function(){return g(this,function(e){switch(e.label){case 0:return[4,tc()];case 1:e.sent();return[4,Promise.all([ty(),th(!0)])];case 2:e.sent(),tv();return[2]}})})()}h(tI,"lintFix");function tN(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,tc()];case 1:t.sent();e=["Validating commit message"];return[4,e2.commitLint()];case 2:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 3:t.sent(),tv();return[2]}})})()}h(tN,"commitLint");function tT(){return i(function(){var e,t,n,r;return g(this,function(i){switch(i.label){case 0:e=["Configuring Git hooks"];return[4,e2.configureGitHook()];case 1:return[4,tg.apply(void 0,e.concat([i.sent()]))];case 2:i.sent(),eo(eZ.GIT_HOOK);return[4,tm(e0)];case 3:t=i.sent();er(eZ.SIMPLE_GIT_HOOKS_JSON,JSON.stringify(t,null,4));n="\n".concat(eO,"\n");es(eZ.GIT_IGNORE)?Z(eZ.GIT_IGNORE,"utf-8").split("\n").includes(eO)||ei(eZ.GIT_IGNORE,n):er(eZ.GIT_IGNORE,n);r=["Setting up simple-git-hooks"];return[4,e2.simpleGitHooks()];case 4:return[4,tg.apply(void 0,r.concat([i.sent()]))];case 5:i.sent();return[2]}})})()}h(tT,"setupGitHook");function tx(){return i(function(){return g(this,function(e){switch(e.label){case 0:return[4,e7([{name:em,type:Q.DEPENDENCY}],{update:!0,postInstallActions:[tT]})];case 1:e.sent();return[2]}})})()}h(tx,"prepare");function tA(){return i(function(){return g(this,function(e){switch(e.label){case 0:eo(eZ.NODE_MODULES,eZ.PNPM_LOCK_YAML);return[4,e6()];case 1:e.sent();return[4,tT()];case 2:e.sent();return[2]}})})()}h(tA,"reset");function t_(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Inspecting project dependencies"];return[4,e2.nodeModulesInspect()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(t_,"inspect");function tR(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Running unit tests"];return[4,e2.testUnit()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(tR,"testUnit");function tG(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Running end-to-end tests"];return[4,e2.testE2e()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(tG,"testE2E");function tb(e){return i(function(){var t;return g(this,function(n){switch(n.label){case 0:t=["Creating MongoDB migration"];return[4,e2.mongoMigrateCreate(e)];case 1:return[4,tg.apply(void 0,t.concat([n.sent()]))];case 2:n.sent();return[2]}})})()}h(tb,"mongoMigrateCreate");function tP(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Running MongoDB migrations"];return[4,e2.mongoMigrateUp()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(tP,"mongoMigrateUp");function tM(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Rolling back MongoDB migration"];return[4,e2.mongoMigrateDown()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(tM,"mongoMigrateDown");(function(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,D(v(S.argv)).scriptName(eA).usage("$0 <command> [options]").command("lint","Check code for linting issues",tC).command("lint:fix","Fix linting issues automatically",tI).command("lint:inspect","View active ESLint configuration",tO).command("lint-staged","Run lint checks on staged files",tD).command("commitlint","Validate commit message format",tN).command("prepare","Initialize project and dependencies",tx).command("reset","Reset the project and reinstall dependencies",tA).command("inspect","Analyze installed project dependencies",t_).command("test:unit","Run unit test suite",tR).command("test:e2e","Run end-to-end test suite",tG).command("mongo:migrate:create <name>","Create a MongoDB migration",function(e){return e.positional("name",{describe:"Migration name",type:"string"})},function(e){return i(function(){return g(this,function(t){switch(t.label){case 0:if(!e.name){K.error("Migration name is required.");return[2]}return[4,tb(e.name)];case 1:t.sent();return[2]}})})()}).command("mongo:migrate:up","Apply all MongoDB migrations",tP).command("mongo:migrate:down","Rollback last MongoDB migration",tM).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(O.version).epilog('\uD83D\uDCA1 Tip: Use "--help" with any command to see options\n').parse()];case 1:t.sent();return[3,3];case 2:e=t.sent();H(e),S.exit(1);return[3,3];case 3:return[2]}})})()})();
1
+ function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(t){if(Array.isArray(t))return e(t)}function r(e,t,n,r,i,s,o){try{var a=e[s](o);var c=a.value}catch(e){n(e);return}if(a.done){t(c)}else{Promise.resolve(c).then(r,i)}}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,s){var o=e.apply(t,n);function a(e){r(o,i,s,a,c,"next",e)}function c(e){r(o,i,s,a,c,"throw",e)}a(undefined)})}}function s(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function o(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function a(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function c(e,t){var n=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n==null)return;var r=[];var i=true;var s=false;var o,a;try{for(n=n.call(e);!(i=(o=n.next()).done);i=true){r.push(o.value);if(t&&r.length===t)break}}catch(e){s=true;a=e}finally{try{if(!i&&n["return"]!=null)n["return"]()}finally{if(s)throw a}}return r}function u(){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 l(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var r=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}r.forEach(function(t){s(e,t,n[t])})}return e}function p(e,n){return t(e)||c(e,n)||m(e,n)||u()}function E(e){return n(e)||a(e)||m(e)||l()}function f(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function m(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}function g(e,t){var n,r,i,s={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return o.next=a(0),o["throw"]=a(1),o["return"]=a(2),typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(e){return function(t){return c([e,t])}}function c(a){if(n)throw new TypeError("Generator is already executing.");while(o&&(o=0,a[0]&&(s=0)),s)try{if(n=1,r&&(i=a[0]&2?r["return"]:a[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;if(r=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:s.label++;return{value:a[1],done:false};case 5:s.label++;r=a[1];a=[0];continue;case 7:a=s.ops.pop();s.trys.pop();continue;default:if(!(i=s.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){s=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(a[0]===6&&s.label<i[1]){s.label=i[1];i=a;break}if(i&&s.label<i[2]){s.label=i[2];s.ops.push(a);break}if(i[2])s.ops.pop();s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e];r=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var y=Object.defineProperty;var h=function(e,t){return y(e,"name",{value:t,configurable:!0})};import S from"node:process";import{hideBin as v}from"yargs/helpers";import D from"yargs/yargs";var O={name:"@cyberskill/shared",type:"module",version:"1.145.0",description:"CyberSkill Shared",author:"Stephen Cheng",license:"MIT",homepage:"https://github.com/cyberskill-world/shared#readme",repository:{type:"git",url:"git+https://github.com/cyberskill-world/shared.git"},bugs:{url:"https://github.com/cyberskill-world/shared/issues"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./config":{types:"./dist/config/index.d.ts",import:"./dist/config/index.js",require:"./dist/config/index.cjs"},"./config/commitlint":{types:"./dist/config/commitlint/index.d.ts",import:"./dist/config/commitlint/index.js",require:"./dist/config/commitlint/index.cjs"},"./config/env":{types:"./dist/config/env/index.d.ts",import:"./dist/config/env/index.js",require:"./dist/config/env/index.cjs"},"./config/eslint":{types:"./dist/config/eslint/index.d.ts",import:"./dist/config/eslint/index.js",require:"./dist/config/eslint/index.cjs"},"./config/graphql-codegen":{types:"./dist/config/graphql-codegen/index.d.ts",import:"./dist/config/graphql-codegen/index.js",require:"./dist/config/graphql-codegen/index.cjs"},"./config/lint-staged":{types:"./dist/config/lint-staged/index.d.ts",import:"./dist/config/lint-staged/index.js",require:"./dist/config/lint-staged/index.cjs"},"./constant":{types:"./dist/constant/index.d.ts",import:"./dist/constant/index.js",require:"./dist/constant/index.cjs"},"./node":{types:"./dist/node/index.d.ts",import:"./dist/node/index.js",require:"./dist/node/index.cjs"},"./node/apollo-server":{types:"./dist/node/apollo-server/index.d.ts",import:"./dist/node/apollo-server/index.js",require:"./dist/node/apollo-server/index.cjs"},"./node/cli":{types:"./dist/node/cli/index.d.ts",import:"./dist/node/cli/index.js",require:"./dist/node/cli/index.cjs"},"./node/command":{types:"./dist/node/command/index.d.ts",import:"./dist/node/command/index.js",require:"./dist/node/command/index.cjs"},"./node/express":{types:"./dist/node/express/index.d.ts",import:"./dist/node/express/index.js",require:"./dist/node/express/index.cjs"},"./node/fs":{types:"./dist/node/fs/index.d.ts",import:"./dist/node/fs/index.js",require:"./dist/node/fs/index.cjs"},"./node/log":{types:"./dist/node/log/index.d.ts",import:"./dist/node/log/index.js",require:"./dist/node/log/index.cjs"},"./node/mongo":{types:"./dist/node/mongo/index.d.ts",import:"./dist/node/mongo/index.js",require:"./dist/node/mongo/index.cjs"},"./node/package":{types:"./dist/node/package/index.d.ts",import:"./dist/node/package/index.js",require:"./dist/node/package/index.cjs"},"./node/path":{types:"./dist/node/path/index.d.ts",import:"./dist/node/path/index.js",require:"./dist/node/path/index.cjs"},"./node/storage":{types:"./dist/node/storage/index.d.ts",import:"./dist/node/storage/index.js",require:"./dist/node/storage/index.cjs"},"./node/ws":{types:"./dist/node/ws/index.d.ts",import:"./dist/node/ws/index.js",require:"./dist/node/ws/index.cjs"},"./react":{types:"./dist/react/index.d.ts",import:"./dist/react/index.js",require:"./dist/react/index.cjs"},"./react/apollo-client":{types:"./dist/react/apollo-client/index.d.ts",import:"./dist/react/apollo-client/index.js",require:"./dist/react/apollo-client/index.cjs"},"./react/apollo-error":{types:"./dist/react/apollo-error/index.d.ts",import:"./dist/react/apollo-error/index.js",require:"./dist/react/apollo-error/index.cjs"},"./react/i18next":{types:"./dist/react/i18next/index.d.ts",import:"./dist/react/i18next/index.js",require:"./dist/react/i18next/index.cjs"},"./react/loading":{types:"./dist/react/loading/index.d.ts",import:"./dist/react/loading/index.js",require:"./dist/react/loading/index.cjs"},"./react/log":{types:"./dist/react/log/index.d.ts",import:"./dist/react/log/index.js",require:"./dist/react/log/index.cjs"},"./react/next-intl":{types:"./dist/react/next-intl/index.d.ts",import:"./dist/react/next-intl/index.js",require:"./dist/react/next-intl/index.cjs"},"./react/storage":{types:"./dist/react/storage/index.d.ts",import:"./dist/react/storage/index.js",require:"./dist/react/storage/index.cjs"},"./react/toast":{types:"./dist/react/toast/index.d.ts",import:"./dist/react/toast/index.js",require:"./dist/react/toast/index.cjs"},"./react/vitest":{types:"./dist/react/vitest/index.d.ts",import:"./dist/react/vitest/index.js",require:"./dist/react/vitest/index.cjs"},"./style/reset.css":{import:"./dist/style/reset.css",require:"./dist/style/reset.css"},"./typescript":{types:"./dist/typescript/index.d.ts",import:"./dist/typescript/index.js",require:"./dist/typescript/index.cjs"},"./util":{types:"./dist/util/index.d.ts",import:"./dist/util/index.js",require:"./dist/util/index.cjs"}},typesVersions:{"*":{config:["dist/config/index.d.ts"],constant:["dist/constant/index.d.ts"],node:["dist/node/index.d.ts"],react:["dist/react/index.d.ts"],typescript:["dist/typescript/index.d.ts"],util:["dist/util/index.d.ts"]}},bin:{cyberskill:"dist/node/cli/index.js"},files:["dist","public"],scripts:{build:"tsup",dev:"tsup --watch",lint:"tsx src/node/cli/index.ts lint","lint:fix":"tsx src/node/cli/index.ts lint:fix","lint:inspect":"tsx src/node/cli/index.ts lint:inspect",reset:"tsx src/node/cli/index.ts reset",prepare:"tsx src/node/cli/index.ts prepare",inspect:"tsx src/node/cli/index.ts inspect","test:unit":"tsx src/node/cli/index.ts test:unit","test:e2e":"tsx src/node/cli/index.ts test:e2e",commitlint:"tsx src/node/cli/index.ts commitlint"},dependencies:{"@antfu/eslint-config":"4.13.0","@apollo/client":"3.13.8","@apollo/server":"4.12.0","@dotenvx/dotenvx":"1.43.0","@eddeee888/gcg-typescript-resolver-files":"0.12.0","@eslint-react/eslint-plugin":"1.49.0","@graphql-codegen/cli":"5.0.6","@graphql-codegen/client-preset":"4.8.1","@microsoft/api-extractor":"7.52.7","@nestjs/common":"11.1.0","@nestjs/core":"11.1.0","@next/eslint-plugin-next":"15.3.2","@testing-library/jest-dom":"6.6.3","@testing-library/react":"16.3.0","@vitejs/plugin-react-swc":"3.9.0","@vitest/browser":"3.1.3","body-parser":"2.2.0",chalk:"5.4.1",classnames:"2.5.1",compression:"1.8.0",consola:"3.4.2","cookie-parser":"1.4.7",cors:"2.8.5","crypto-js":"4.2.0","date-fns":"4.1.0","dotenv-cli":"8.0.0",envalid:"8.0.0","eslint-config-next":"15.3.2","eslint-plugin-format":"1.0.1","eslint-plugin-react-hooks":"5.2.0","eslint-plugin-react-refresh":"0.4.20",express:"4.21.2","express-session":"1.18.1","express-useragent":"1.0.15","fs-extra":"11.3.0",globals:"16.1.0",graphql:"16.11.0","graphql-ws":"6.0.4",i18next:"25.1.1",jsdom:"26.1.0",localforage:"1.10.0","migrate-mongo":"12.1.3","modern-normalize":"3.0.1",mongodb:"6.16.0",mongoose:"8.14.1","mongoose-aggregate-paginate-v2":"1.1.4","mongoose-paginate-v2":"1.9.0","next-intl":"4.1.0","node-fetch":"3.3.2","node-persist":"4.0.4",playwright:"1.52.0","postcss-modules":"6.0.1",qs:"6.14.0",react:"19.1.0","react-dom":"19.1.0","react-hot-toast":"2.5.2","react-i18next":"15.5.1","react-icons":"5.5.0",sass:"1.87.0",slugify:"1.6.6",tsup:"8.4.0",tsx:"4.19.4",typescript:"5.8.3",unorm:"1.6.0",uuid:"11.1.0",vite:"6.3.5",vitest:"3.1.3","vitest-browser-react":"0.1.1",ws:"8.18.2",yargs:"17.7.2"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},devDependencies:{"@commitlint/cli":"19.8.0","@commitlint/config-conventional":"19.8.0","@eslint/config-inspector":"1.0.2","@types/body-parser":"1.19.5","@types/compression":"1.7.5","@types/cookie-parser":"1.4.8","@types/cors":"2.8.17","@types/crypto-js":"4.2.2","@types/express":"4.17.21","@types/express-session":"1.18.1","@types/express-useragent":"1.0.5","@types/fs-extra":"11.0.4","@types/migrate-mongo":"10.0.5","@types/mongoose-aggregate-paginate-v2":"1.0.12","@types/node":"22.15.15","@types/node-persist":"3.1.8","@types/react":"19.1.3","@types/react-dom":"19.1.3","@types/unorm":"1.3.31","@types/uuid":"10.0.0","@types/ws":"8.18.1","@types/yargs":"17.0.33",eslint:"9.26.0","lint-staged":"15.5.2","node-modules-inspector":"0.6.8","simple-git-hooks":"2.13.0"}};var C=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});import{exec as I}from"node:child_process";import N from"node:process";import*as T from"node:util";var x=".cyberskill-storage";import A from"@dotenvx/dotenvx";import{bool as _,cleanEnv as R,str as G}from"envalid";import b from"node:os";import P from"node:path";import M from"node:process";var w=!1;function j(){w||(A.config(),w=!0)}h(j,"loadEnvFile");function L(){j();var e=R(M.env,{CWD:G({default:M.cwd()}),DEBUG:_({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:G({default:P.join(b.homedir(),x)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}h(L,"getEnv");var U=function(e){return e.Error="error",e.Warning="warning",e}({});import k from"chalk";import F from"consola";import{GraphQLError as q}from"graphql";var Y={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};var V=L();V.DEBUG||(F.level=4);function B(e){var t=k[e];return typeof t=="function"?t:k.green}h(B,"chalkKeyword");var K={silent:F.silent,level:F.level,fatal:F.fatal,error:F.error,warn:F.warn,log:F.log,info:F.info,success:F.success,ready:F.ready,start:F.start,box:F.box,debug:F.debug,trace:F.trace,verbose:F.verbose,printBoxedLog:function e(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(t===null||t===void 0?void 0:t.length)){F.box(k.green(e));return}t.forEach(function(e){var t=e.file,r=e.position,i=e.rule,s=e.message;F.log("".concat(k.gray("File:")," ").concat(k.blue("".concat(t).concat(r?":".concat(r):"")))),i&&F.log(" ".concat(B(n)("Rule:")," ").concat(i)),F.log(" ".concat(B(n)("Message:")," ").concat(s))}),F.box(B(n)("".concat(e," : ").concat(t.length))),F.log(k.gray("─".repeat(40)))}};function H(e,t){var n=t!==null&&t!==void 0?t:{},r=n.shouldLog,i=r===void 0?!0:r,s=n.returnValue,a=n.callback,c=o(e,Error)?e:new Error(typeof e=="string"?e:"Unknown error");return i&&K.error(c.message),a&&typeof a=="function"&&a(c),s||{success:!1,message:c.message,code:Y.INTERNAL_SERVER_ERROR.CODE}}h(H,"catchError");var Q=function(e){return e.DEPENDENCY="dependencies",e.DEV_DEPENDENCY="devDependencies",e.PEER_DEPENDENCY="peerDependencies",e.BUNDLE_DEPENDENCY="bundleDependencies",e.OPTIONAL_DEPENDENCY="optionalDependencies",e}({});import W from"node-fetch";import J from"fs-extra";var z=J.lstatSync,$=J.readdirSync,X=J.mkdirSync,Z=J.readFileSync,ee=J.unlinkSync,et=J.statSync,en=J.readJsonSync;function er(e,t,n){J.writeFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}h(er,"writeFileSync");function ei(e,t,n){J.appendFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}h(ei,"appendFileSync");function es(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}return t.every(function(e){return J.pathExistsSync(e)})}h(es,"pathExistsSync");function eo(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}t.forEach(function(e){es(e)&&J.removeSync(e)})}h(eo,"removeSync");import ea from"fs-extra";import ec from"node:path";var eu=L(),el=ec;function ed(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=el).resolve.apply(r,[eu.CWD].concat(E(t)))}h(ed,"resolveWorkingPath");function ep(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=el).join.apply(r,E(t))}h(ep,"join");var eE=L(),ef=eE.CWD,em="@cyberskill/shared",eg="node_modules",ey="dist",eh="package.json",eS="package-lock.json",ev="tsconfig.json",eD=".gitignore",eO=".simple-git-hooks.json",eC="pnpm-lock.yaml",eI=".git/hooks/",eN=".git/COMMIT_EDITMSG",eT=".migrate-mongo.config.js",ex=function(){var e=ea.readJsonSync(ed(eh)).name===em?ef:ep(ef,eg,em);return ep(e,ey)}(),eA="cyberskill",e_="src/node/cli/index.ts",eR="eslint",eG="eslint",eb="vitest";var eP="vitest",eM="@commitlint/cli",ew="@commitlint/config-conventional",ej="commitlint",eL="lint-staged",eU="lint-staged",ek="typescript",eF="tsc",eq="tsx",eY="git",eV="pnpm",eB="pnpm exec",eK="simple-git-hooks",eH="simple-git-hooks",eQ="@eslint/config-inspector",eW="eslint-config-inspector",eJ="node-modules-inspector",ez="node-modules-inspector",e$="migrate-mongo",eX="./node_modules/migrate-mongo/bin/migrate-mongo",eZ={CYBERSKILL_DIRECTORY:ex,WORKING_DIRECTORY:ef,TS_CONFIG:ed(ev),GIT_IGNORE:ed(eD),GIT_HOOK:ed(eI),GIT_COMMIT_MSG:ed(eN),SIMPLE_GIT_HOOKS_JSON:ed(eO),PACKAGE_JSON:ed(eh),PACKAGE_LOCK_JSON:ed(eS),PNPM_LOCK_YAML:ed(eC),NODE_MODULES:ed(eg),MIGRATE_MONGO_CONFIG:ed(eT),LINT_STAGED_CONFIG:ed("".concat(ex,"/config/lint-staged/index.js")),COMMITLINT_CONFIG:ed("".concat(ex,"/config/commitlint/index.js")),UNIT_TEST_CONFIG:ed("".concat(ex,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:ed("".concat(ex,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:ed("".concat(ex,"/react/vitest/vitest.e2e.js"))};function e0(e){var t=e.isCurrentProject;return d({"pre-commit":eU,"commit-msg":ej},t&&{"pre-push":tp("".concat(eY," pull"))})}h(e0,"createGitHooksConfig");function e1(e){var t=e.type,n=e.packages,r=e.command;var s=n===null||n===void 0?void 0:n.reduce(function(e,t){return e.some(function(e){return e.name===t.name})||e.push(t),e},[]);return function(){return i(function(){var e;return g(this,function(n){switch(n.label){case 0:switch(t){case C.CLI:return[3,1];case C.STRING:return[3,4]}return[3,5];case 1:e=s===null||s===void 0?void 0:s.length;if(!e)return[3,3];return[4,e7(s,{update:!0})];case 2:e=n.sent();n.label=3;case 3:return[2,(e,tf(tp("".concat(eB," ").concat(r))))];case 4:return[2,tf(tp(r))];case 5:throw new Error("Unsupported command type");case 6:return[2]}})})()}}h(e1,"buildCommand");var e2={simpleGitHooks:e1({type:C.CLI,packages:[{name:eK,type:Q.DEV_DEPENDENCY}],command:eH}),eslintInspect:e1({type:C.CLI,packages:[{name:eQ,type:Q.DEV_DEPENDENCY}],command:eW}),nodeModulesInspect:e1({type:C.CLI,packages:[{name:eJ,type:Q.DEV_DEPENDENCY}],command:ez}),eslintCheck:e1({type:C.CLI,packages:[{name:eR,type:Q.DEV_DEPENDENCY}],command:"".concat(eG," ").concat(eZ.WORKING_DIRECTORY," --no-cache")}),eslintFix:e1({type:C.CLI,packages:[{name:eR,type:Q.DEV_DEPENDENCY}],command:"".concat(eG," ").concat(eZ.WORKING_DIRECTORY," --fix --no-cache")}),typescriptCheck:e1({type:C.CLI,packages:[{name:ek,type:Q.DEPENDENCY}],command:"".concat(eF," -p ").concat(eZ.TS_CONFIG," --noEmit")}),testUnit:e1({type:C.CLI,packages:[{name:eb,type:Q.DEV_DEPENDENCY}],command:"".concat(eP," --config ").concat(eZ.UNIT_TEST_CONFIG)}),testE2e:e1({type:C.CLI,packages:[{name:eb,type:Q.DEV_DEPENDENCY}],command:"".concat(eP," --config ").concat(eZ.E2E_TEST_CONFIG)}),mongoMigrateCreate:h(function(e){return e1({type:C.CLI,packages:[{name:e$,type:Q.DEPENDENCY}],command:"".concat(eq," ").concat(eX," create ").concat(e," -f ").concat(eZ.MIGRATE_MONGO_CONFIG)})()},"mongoMigrateCreate"),mongoMigrateUp:e1({type:C.CLI,packages:[{name:e$,type:Q.DEPENDENCY}],command:"".concat(eq," ").concat(eX," up -f ").concat(eZ.MIGRATE_MONGO_CONFIG)}),mongoMigrateDown:e1({type:C.CLI,packages:[{name:e$,type:Q.DEPENDENCY}],command:"".concat(eq," ").concat(eX," down -f ").concat(eZ.MIGRATE_MONGO_CONFIG)}),commitLint:e1({type:C.CLI,packages:[{name:eM,type:Q.DEV_DEPENDENCY},{name:ew,type:Q.DEV_DEPENDENCY}],command:"".concat(ej," --edit ").concat(eZ.GIT_COMMIT_MSG," --config ").concat(eZ.COMMITLINT_CONFIG)}),lintStaged:e1({type:C.CLI,packages:[{name:eL,type:Q.DEV_DEPENDENCY}],command:"".concat(eU," --config ").concat(eZ.LINT_STAGED_CONFIG)}),configureGitHook:e1({type:C.STRING,command:"".concat(eY," config core.hooksPath ").concat(eZ.GIT_HOOK)}),build:e1({type:C.STRING,command:"".concat(eV," run --if-present build")}),pnpmInstallStandard:e1({type:C.STRING,command:"".concat(eV," install --ignore-scripts --frozen-lockfile")}),pnpmInstallLegacy:e1({type:C.STRING,command:"".concat(eV," install --ignore-scripts --frozen-lockfile --legacy-peer-deps")}),pnpmInstallForce:e1({type:C.STRING,command:"".concat(eV," install --ignore-scripts --frozen-lockfile --force")})};var e4=L();function e3(e){return i(function(){var t,n,r,i;return g(this,function(s){switch(s.label){case 0:s.trys.push([0,3,,4]);return[4,W("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:t=s.sent();if(!t.ok)throw new Error("Failed to fetch latest version: ".concat(t.status," ").concat(t.statusText));return[4,t.json()];case 2:n=s.sent(),r=n.version;return[2,{success:!0,result:r}];case 3:i=s.sent();return[2,H(i)];case 4:return[2]}})})()}h(e3,"getLatestPackageVersion");function e5(e){return i(function(){var t,n,r,i,s,o,a,c,u,l,d,p,E,f,m,y,h,S,v,D,O,C,I,N;return g(this,function(g){switch(g.label){case 0:g.trys.push([0,2,,3]);if(!e){if(es(eZ.PACKAGE_JSON)){t=en(eZ.PACKAGE_JSON),n=t.name,r=n===void 0?"":n,i=t.version,s=i===void 0?"":i;return[2,{success:!0,result:{name:r,currentVersion:s,latestVersion:s,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:!1,isDevDependency:!1,installedPath:eZ.PACKAGE_JSON,file:t}}]}return[2,{success:!0,result:{name:"",currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:!1,isDevDependency:!1,installedPath:"",file:{}}}]}if(!es(eZ.PACKAGE_JSON))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===Q.DEPENDENCY,isDevDependency:e.type===Q.DEV_DEPENDENCY,installedPath:"",file:{}}}];o=en(eZ.PACKAGE_JSON),a=o.name,c=o.version,u=c===void 0?"":c,l=o.dependencies,d=l===void 0?{}:l,p=o.devDependencies,E=p===void 0?{}:p;if(e.name===a)return[2,{success:!0,result:{name:a,currentVersion:u,latestVersion:u,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:e.type===Q.DEPENDENCY,isDevDependency:e.type===Q.DEV_DEPENDENCY,installedPath:eZ.PACKAGE_JSON,file:o}}];f=e.name in d,m=e.name in E;return[4,e3(e.name)];case 1:y=g.sent();if(!y.success)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:f,isDevDependency:m,installedPath:"",file:{}}}];if(!f&&!m)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:y.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===Q.DEPENDENCY,isDevDependency:e.type===Q.DEV_DEPENDENCY,installedPath:"",file:{}}}];v=(S=(h=d[e.name])!==null&&h!==void 0?h:E[e.name])!==null&&S!==void 0?S:"",D=ep(e4.CWD,eg,e.name,eh);if(!es(D))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:y.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:f,isDevDependency:m,installedPath:"",file:{}}}];O=en(D),C=O.version,I=C===void 0?"":C;return[2,v!==I?{success:!0,result:{name:e.name,currentVersion:I||v,latestVersion:y.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:!1,isDependency:f,isDevDependency:m,installedPath:D,file:O}}:{success:!0,result:{name:e.name,currentVersion:v,latestVersion:y.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:v===y.result,isDependency:f,isDevDependency:m,installedPath:D,file:O}}];case 2:N=g.sent();return[2,H(N)];case 3:return[2]}})})()}h(e5,"getPackage");function e8(e){return i(function(){var t,n,r,i,s;return g(this,function(o){try{;r=en(eZ.PACKAGE_JSON),i=(t=r.dependencies)!==null&&t!==void 0?t:{},s=(n=r.devDependencies)!==null&&n!==void 0?n:{};e.isDependency?i[e.name]=e.latestVersion:e.isDevDependency&&(s[e.name]=e.latestVersion),er(eZ.PACKAGE_JSON,JSON.stringify(r,null,4)),K.info('Updated "'.concat(e.name,'" to version ').concat(e.latestVersion))}catch(e){H(e)}return[2]})})()}h(e8,"updatePackage");function e6(){return i(function(){var e,t,n,r,i,s,o,a,c,u,l,d,p;return g(this,function(E){switch(E.label){case 0:E.trys.push([0,12,,13]);e=[{command:h(function(){return e2.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:h(function(){return e2.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:h(function(){return e2.pnpmInstallForce()},"command"),message:"Retrying with force install"}];t=true,n=false,r=undefined;E.label=1;case 1:E.trys.push([1,9,10,11]);i=e[Symbol.iterator]();E.label=2;case 2:if(!!(t=(s=i.next()).done))return[3,8];o=s.value,a=o.command,c=o.message;E.label=3;case 3:E.trys.push([3,6,,7]);return[4,a()];case 4:u=E.sent();return[4,tg("".concat(c," using: ").concat(u),u)];case 5:E.sent();return[2];case 6:l=E.sent();H(l);return[3,7];case 7:t=true;return[3,2];case 8:return[3,11];case 9:d=E.sent();n=true;r=d;return[3,11];case 10:try{if(!t&&i.return!=null){i.return()}}finally{if(n){throw r}}return[7];case 11:return[3,13];case 12:p=E.sent();H(p);return[3,13];case 13:return[2]}})})()}h(e6,"installDependencies");function e7(e,t){return i(function(){var n,r,i,s,o,a,c,u,l,d,p,E;return g(this,function(f){switch(f.label){case 0:if(!es(eZ.PACKAGE_JSON)){K.error("package.json not found. Aborting setup.");return[2]}f.label=1;case 1:f.trys.push([1,16,,17]);return[4,Promise.all(e.map(e5))];case 2:n=f.sent().filter(function(e){return e.success?!e.result.isCurrentProject&&(!e.result.isInstalled||!e.result.isUpToDate):!1});r=n.length>0;if(!r)return[3,7];return[4,Promise.all(n.map(function(e){return e.success?e8(e.result):Promise.resolve()}))];case 3:f.sent();return[4,e6()];case 4:f.sent();i=["Running ESLint with auto-fix"];return[4,e2.eslintFix()];case 5:return[4,tg.apply(void 0,i.concat([f.sent()]))];case 6:r=f.sent();f.label=7;case 7:r;o=true,a=false,c=undefined;f.label=8;case 8:f.trys.push([8,13,14,15]);u=((s=t===null||t===void 0?void 0:t.postInstallActions)!==null&&s!==void 0?s:[])[Symbol.iterator]();f.label=9;case 9:if(!!(o=(l=u.next()).done))return[3,12];d=l.value;return[4,d()];case 10:f.sent();f.label=11;case 11:o=true;return[3,9];case 12:return[3,15];case 13:p=f.sent();a=true;c=p;return[3,15];case 14:try{if(!o&&u.return!=null){u.return()}}finally{if(a){throw c}}return[7];case 15:return[3,17];case 16:E=f.sent();H(E);return[3,17];case 17:return[2]}})})()}h(e7,"setupPackages");import e9 from"node-persist";var te=L();function tt(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=e9.defaultInstance;if(e)return[3,2];return[4,e9.init({dir:te.CYBERSKILL_STORAGE_DIRECTORY})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})})()}h(tt,"initNodePersist");var tn={get:function e(e){return i(function(){var t,n;return g(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tt()];case 1:r.sent();return[4,e9.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,H(n,{returnValue:null})];case 4:return[2]}})})()},set:function e(e,t){return i(function(){var n;return g(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tt()];case 1:r.sent();return[4,e9.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();H(n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return i(function(){var t;return g(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tt()];case 1:n.sent();return[4,e9.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();H(t);return[3,4];case 4:return[2]}})})()},keys:function e(){return i(function(){var e,t;return g(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tt()];case 1:n.sent();return[4,e9.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(K.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,H(t,{returnValue:[]})];case 4:return[2]}})})()},getLogLink:function e(e){return i(function(){return g(this,function(t){try{return[2,"".concat(te.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,H(e,{returnValue:null})]}return[2]})})()}};var tr=L(),ti=T.promisify(I);function ts(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,e5()];case 1:e=t.sent();return[2,e.success?e.result.name:Date.now().toString()]}})})()}h(ts,"getPackageName");function to(e){return i(function(){var t,n;return g(this,function(r){switch(r.label){case 0:if(e.length===0)return[2];return[4,ts()];case 1:t=r.sent();r.label=2;case 2:r.trys.push([2,4,,5]);return[4,tn.set(t,e)];case 3:r.sent(),setTimeout(function(){return i(function(){var e;return g(this,function(n){switch(n.label){case 0:return[4,tn.getLogLink(t)];case 1:e=n.sent();e&&K.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},0);return[3,5];case 4:n=r.sent();H(n);return[3,5];case 5:return[2]}})})()}h(to,"saveErrorListToStorage");function ta(){return i(function(){var e,t,n;return g(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,ts()];case 1:e=r.sent();return[4,tn.get(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:[]];case 3:n=r.sent();return[2,H(n,{returnValue:[]})];case 4:return[2]}})})()}h(ta,"getStoredErrorLists");function tc(){return i(function(){var e,t;return g(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,ts()];case 1:e=n.sent();return[4,tn.remove(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();H(t);return[3,4];case 4:return[2]}})})()}h(tc,"clearAllErrorLists");function tu(e){var t=[],n=[],r="",i=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,s=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,o=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var a,c,u,l,d;var p=i.exec(e)||[],E=s.exec(e)||[],f=o.exec(e)||[];var m,g,y,h,S,v;p.length&&r?t.push({file:r,position:"".concat(p[1],":").concat(p[2]),type:p[3]===U.Error?U.Error:U.Warning,message:(m=p===null||p===void 0?void 0:(a=p[4])===null||a===void 0?void 0:a.trim())!==null&&m!==void 0?m:"",rule:(g=p===null||p===void 0?void 0:(c=p[5])===null||c===void 0?void 0:c.trim())!==null&&g!==void 0?g:""}):E.length?t.push({file:(y=E===null||E===void 0?void 0:E[1])!==null&&y!==void 0?y:"",position:"".concat(E[2],":").concat(E[3]),type:E[4]===U.Error?U.Error:U.Warning,message:(h=E===null||E===void 0?void 0:(u=E[5])===null||u===void 0?void 0:u.trim())!==null&&h!==void 0?h:""}):f.length?t.push({file:"commitlint",type:U.Error,message:(S=f===null||f===void 0?void 0:(l=f[1])===null||l===void 0?void 0:l.trim())!==null&&S!==void 0?S:"",rule:(v=f===null||f===void 0?void 0:(d=f[2])===null||d===void 0?void 0:d.trim())!==null&&v!==void 0?v:""}):n.push(e.trim())}}),t.length&&to(t),tr.DEBUG&&n.length&&(K.warn("Unmatched lines:"),n.forEach(function(e){return K.info(" ".concat(e))}))}h(tu,"parseTextErrors");function tl(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,i=e.line,s=e.column,o=e.ruleId,a=e.message;n.push({type:r===2?U.Error:U.Warning,file:t,position:"".concat(i,":").concat(s),rule:o,message:a})})}),n.length&&to(n)}catch(t){tu(e)}}h(tl,"parseCommandOutput");function td(e){return i(function(e){var t,n,r,i,s,o,a,c,u;var l=arguments;return g(this,function(d){switch(d.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:tl;n=new AbortController;N.on("SIGINT",function(){K.warn("Process interrupted. Terminating..."),n.abort(),N.exit()});d.label=1;case 1:d.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,ti(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=d.sent(),i=r.stdout,s=r.stderr;[i,s].forEach(function(e){return e&&t(e)});d.label=3;case 3:return[3,5];case 4:o=d.sent();a=o.stdout,c=o.stderr,u=o.message;[a,c].forEach(function(e){return e&&t(e)}),!c&&!a&&K.error("Command failed: ".concat(u));return[3,5];case 5:return[2]}})}).apply(this,arguments)}h(td,"executeCommand");function tp(e){return{raw:!0,cmd:e}}h(tp,"rawCommand");function tE(e,t){return(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(eB," ").concat(eq," ").concat(e_," ").concat(e):"".concat(eB," ").concat(eA," ").concat(e)}h(tE,"formatCLI");function tf(e,t){return typeof e=="function"?tE(e(t),t):(typeof e==="undefined"?"undefined":f(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?tE(e,t):e}h(tf,"formatCommand");function tm(e){return i(function(){var t,n,r;return g(this,function(i){switch(i.label){case 0:return[4,e5({name:em})];case 1:t=i.sent();if(t.success){n={isCurrentProject:t.result.isCurrentProject},r=typeof e=="function"?e(n):e;return[2,Object.fromEntries(Object.entries(r).map(function(e){var t=p(e,2),r=t[0],i=t[1];return[r,tf(i,n)]}))]}return[2]}})})()}h(tm,"resolveCommands");function tg(e,t){return i(function(){var n;return g(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);K.start("".concat(e)),tr.DEBUG&&K.info("→ ".concat(t));return[4,td(t)];case 1:r.sent(),K.success("".concat(e," done."));return[3,3];case 2:n=r.sent();H(n);return[3,3];case 3:return[2]}})})()}h(tg,"runCommand");function ty(){return i(function(){var e,t;return g(this,function(n){switch(n.label){case 0:if(!es(eZ.TS_CONFIG))return[3,3];t=["Performing TypeScript validation"];return[4,e2.typescriptCheck()];case 1:return[4,tg.apply(void 0,t.concat([n.sent()]))];case 2:e=n.sent();return[3,4];case 3:e=K.warn("No TypeScript configuration found. Skipping type check.");n.label=4;case 4:e;return[2]}})})()}h(ty,"checkTypescript");function th(){return i(function(){var e,t,n,r;var i=arguments;return g(this,function(s){switch(s.label){case 0:e=i.length>0&&i[0]!==void 0?i[0]:!1;if(!e)return[3,3];n=["Running ESLint with auto-fix"];return[4,e2.eslintFix()];case 1:return[4,tg.apply(void 0,n.concat([s.sent()]))];case 2:t=s.sent();return[3,6];case 3:r=["Running ESLint check"];return[4,e2.eslintCheck()];case 4:return[4,tg.apply(void 0,r.concat([s.sent()]))];case 5:t=s.sent();s.label=6;case 6:t;return[2]}})}).apply(this,arguments)}h(th,"checkEslint");function tS(e,t){if(!t.length)return;var n=e==="Errors"?"red":"yellow";K.printBoxedLog(e==="Errors"?"✖ Errors":"⚠ Warnings",t,n)}h(tS,"printIssues");function tv(){return i(function(){return g(this,function(e){setTimeout(function(){return i(function(){var e,t,n;return g(this,function(r){switch(r.label){case 0:return[4,ta()];case 1:e=r.sent(),t=e.filter(function(e){return e.type===U.Error}),n=e.filter(function(e){return e.type===U.Warning});!t.length&&!n.length?K.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(tS("Warnings",n),tS("Errors",t),(t.length>0||n.length>0)&&S.exit(1));return[2]}})})()},0);return[2]})})()}h(tv,"showCheckResult");function tD(){return i(function(){var e,t,n,r;return g(this,function(i){switch(i.label){case 0:return[4,tc()];case 1:i.sent();return[4,e5({name:em})];case 2:e=i.sent();if(!e.success){K.error("Failed to retrieve package information. Aborting lint-staged.");return[2]}t=e.result.isCurrentProject;if(!t)return[3,5];n=["Building package: ".concat(em)];return[4,e2.build()];case 3:return[4,tg.apply(void 0,n.concat([i.sent()]))];case 4:t=i.sent();i.label=5;case 5:t;r=["Executing lint-staged"];return[4,e2.lintStaged()];case 6:return[4,tg.apply(void 0,r.concat([i.sent()]))];case 7:i.sent(),tv();return[2]}})})()}h(tD,"lintStaged");function tO(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Inspecting ESLint configuration"];return[4,e2.eslintInspect()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(tO,"inspectLint");function tC(){return i(function(){return g(this,function(e){switch(e.label){case 0:return[4,tc()];case 1:e.sent();return[4,Promise.all([ty(),th()])];case 2:e.sent(),tv();return[2]}})})()}h(tC,"lintCheck");function tI(){return i(function(){return g(this,function(e){switch(e.label){case 0:return[4,tc()];case 1:e.sent();return[4,Promise.all([ty(),th(!0)])];case 2:e.sent(),tv();return[2]}})})()}h(tI,"lintFix");function tN(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,tc()];case 1:t.sent();e=["Validating commit message"];return[4,e2.commitLint()];case 2:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 3:t.sent(),tv();return[2]}})})()}h(tN,"commitLint");function tT(){return i(function(){var e,t,n,r;return g(this,function(i){switch(i.label){case 0:e=["Configuring Git hooks"];return[4,e2.configureGitHook()];case 1:return[4,tg.apply(void 0,e.concat([i.sent()]))];case 2:i.sent(),eo(eZ.GIT_HOOK);return[4,tm(e0)];case 3:t=i.sent();er(eZ.SIMPLE_GIT_HOOKS_JSON,JSON.stringify(t,null,4));n="\n".concat(eO,"\n");es(eZ.GIT_IGNORE)?Z(eZ.GIT_IGNORE,"utf-8").split("\n").includes(eO)||ei(eZ.GIT_IGNORE,n):er(eZ.GIT_IGNORE,n);r=["Setting up simple-git-hooks"];return[4,e2.simpleGitHooks()];case 4:return[4,tg.apply(void 0,r.concat([i.sent()]))];case 5:i.sent();return[2]}})})()}h(tT,"setupGitHook");function tx(){return i(function(){return g(this,function(e){switch(e.label){case 0:return[4,e7([{name:em,type:Q.DEPENDENCY}],{update:!0,postInstallActions:[tT]})];case 1:e.sent();return[2]}})})()}h(tx,"prepare");function tA(){return i(function(){return g(this,function(e){switch(e.label){case 0:eo(eZ.NODE_MODULES,eZ.PNPM_LOCK_YAML);return[4,e6()];case 1:e.sent();return[4,tT()];case 2:e.sent();return[2]}})})()}h(tA,"reset");function t_(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Inspecting project dependencies"];return[4,e2.nodeModulesInspect()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(t_,"inspect");function tR(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Running unit tests"];return[4,e2.testUnit()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(tR,"testUnit");function tG(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Running end-to-end tests"];return[4,e2.testE2e()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(tG,"testE2E");function tb(e){return i(function(){var t;return g(this,function(n){switch(n.label){case 0:t=["Creating MongoDB migration"];return[4,e2.mongoMigrateCreate(e)];case 1:return[4,tg.apply(void 0,t.concat([n.sent()]))];case 2:n.sent();return[2]}})})()}h(tb,"mongoMigrateCreate");function tP(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Running MongoDB migrations"];return[4,e2.mongoMigrateUp()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(tP,"mongoMigrateUp");function tM(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:e=["Rolling back MongoDB migration"];return[4,e2.mongoMigrateDown()];case 1:return[4,tg.apply(void 0,e.concat([t.sent()]))];case 2:t.sent();return[2]}})})()}h(tM,"mongoMigrateDown");(function(){return i(function(){var e;return g(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,D(v(S.argv)).scriptName(eA).usage("$0 <command> [options]").command("lint","Check code for linting issues",tC).command("lint:fix","Fix linting issues automatically",tI).command("lint:inspect","View active ESLint configuration",tO).command("lint-staged","Run lint checks on staged files",tD).command("commitlint","Validate commit message format",tN).command("prepare","Initialize project and dependencies",tx).command("reset","Reset the project and reinstall dependencies",tA).command("inspect","Analyze installed project dependencies",t_).command("test:unit","Run unit test suite",tR).command("test:e2e","Run end-to-end test suite",tG).command("mongo:migrate:create <name>","Create a MongoDB migration",function(e){return e.positional("name",{describe:"Migration name",type:"string"})},function(e){return i(function(){return g(this,function(t){switch(t.label){case 0:if(!e.name){K.error("Migration name is required.");return[2]}return[4,tb(e.name)];case 1:t.sent();return[2]}})})()}).command("mongo:migrate:up","Apply all MongoDB migrations",tP).command("mongo:migrate:down","Rollback last MongoDB migration",tM).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(O.version).epilog('\uD83D\uDCA1 Tip: Use "--help" with any command to see options\n').parse()];case 1:t.sent();return[3,3];case 2:e=t.sent();H(e),S.exit(1);return[3,3];case 3:return[2]}})})()})();
@@ -1 +1 @@
1
- "use strict";function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(t){if(Array.isArray(t))return e(t)}function r(e,t,n,r,a,o,s){try{var i=e[o](s);var c=i.value}catch(e){n(e);return}if(i.done){t(c)}else{Promise.resolve(c).then(r,a)}}function a(e){return function(){var t=this,n=arguments;return new Promise(function(a,o){var s=e.apply(t,n);function i(e){r(s,a,o,i,c,"next",e)}function c(e){r(s,a,o,i,c,"throw",e)}i(undefined)})}}function o(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function s(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function i(e,t){var n=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n==null)return;var r=[];var a=true;var o=false;var s,i;try{for(n=n.call(e);!(a=(s=n.next()).done);a=true){r.push(s.value);if(t&&r.length===t)break}}catch(e){o=true;i=e}finally{try{if(!a&&n["return"]!=null)n["return"]()}finally{if(o)throw i}}return r}function c(){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 u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e,n){return t(e)||i(e,n)||f(e,n)||c()}function E(e){return n(e)||s(e)||f(e)||u()}function d(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function f(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}function p(e,t){var n,r,a,o={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=i(0),s["throw"]=i(1),s["return"]=i(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function i(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,i[0]&&(o=0)),o)try{if(n=1,r&&(a=i[0]&2?r["return"]:i[0]?r["throw"]||((a=r["return"])&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;if(r=0,a)i=[i[0]&2,a.value];switch(i[0]){case 0:case 1:a=i;break;case 4:o.label++;return{value:i[1],done:false};case 5:o.label++;r=i[1];i=[0];continue;case 7:i=o.ops.pop();o.trys.pop();continue;default:if(!(a=o.trys,a=a.length>0&&a[a.length-1])&&(i[0]===6||i[0]===2)){o=0;continue}if(i[0]===3&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(i[0]===6&&o.label<a[1]){o.label=a[1];a=i;break}if(a&&o.label<a[2]){o.label=a[2];o.ops.push(i);break}if(a[2])o.ops.pop();o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e];r=0}finally{n=a=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}}var m=Object.create;var S=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var y=function(e,t){return S(e,"name",{value:t,configurable:!0})};var I=function(e,t){for(var n in t)S(e,n,{get:t[n],enumerable:!0})},h=function(e,t,n,r){var a=true,o=false,s=undefined;if(t&&(typeof t==="undefined"?"undefined":d(t))=="object"||typeof t=="function")try{var i=function(){var a=u.value;!C.call(e,a)&&a!==n&&S(e,a,{get:function(){return t[a]},enumerable:!(r=D(t,a))||r.enumerable})};for(var c=O(t)[Symbol.iterator](),u;!(a=(u=c.next()).done);a=true)i()}catch(e){o=true;s=e}finally{try{if(!a&&c.return!=null){c.return()}}finally{if(o){throw s}}}return e};var N=function(e,t,n){return n=e!=null?m(v(e)):{},h(t||!e||!e.__esModule?S(n,"default",{value:e,enumerable:!0}):n,e)},T=function(e){return h(S({},"__esModule",{value:!0}),e)};var A={};I(A,{clearAllErrorLists:function(){return tu},formatCommand:function(){return tm},getStoredErrorLists:function(){return tc},rawCommand:function(){return tf},resolveCommands:function(){return tS},runCommand:function(){return tD}});module.exports=T(A);var g=require("child_process"),_=N(require("process"),1),R=N(require("util"),1);var G=".cyberskill-storage";var P=N(require("@dotenvx/dotenvx"),1),M=require("envalid"),b=N(require("os"),1),L=N(require("path"),1),U=N(require("process"),1);var w=!1;function k(){w||(P.default.config(),w=!0)}y(k,"loadEnvFile");function F(){k();var e=(0,M.cleanEnv)(U.default.env,{CWD:(0,M.str)({default:U.default.cwd()}),DEBUG:(0,M.bool)({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:(0,M.str)({default:L.default.join(b.default.homedir(),G)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}y(F,"getEnv");var Y=function(e){return e.Error="error",e.Warning="warning",e}({});var V=N(require("chalk"),1),x=N(require("consola"),1),j=require("graphql");var q={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};var K=F();K.DEBUG||(x.default.level=4);function B(e){var t=V.default[e];return typeof t=="function"?t:V.default.green}y(B,"chalkKeyword");var Q={silent:x.default.silent,level:x.default.level,fatal:x.default.fatal,error:x.default.error,warn:x.default.warn,log:x.default.log,info:x.default.info,success:x.default.success,ready:x.default.ready,start:x.default.start,box:x.default.box,debug:x.default.debug,trace:x.default.trace,verbose:x.default.verbose,printBoxedLog:function e(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(t===null||t===void 0?void 0:t.length)){x.default.box(V.default.green(e));return}t.forEach(function(e){var t=e.file,r=e.position,a=e.rule,o=e.message;x.default.log("".concat(V.default.gray("File:")," ").concat(V.default.blue("".concat(t).concat(r?":".concat(r):"")))),a&&x.default.log(" ".concat(B(n)("Rule:")," ").concat(a)),x.default.log(" ".concat(B(n)("Message:")," ").concat(o))}),x.default.box(B(n)("".concat(e," : ").concat(t.length))),x.default.log(V.default.gray("─".repeat(40)))}};function H(e,t){var n=t!==null&&t!==void 0?t:{},r=n.shouldLog,a=r===void 0?!0:r,s=n.returnValue,i=n.callback,c=o(e,Error)?e:new Error(typeof e=="string"?e:"Unknown error");return a&&Q.error(c.message),i&&typeof i=="function"&&i(c),s||{success:!1,message:c.message,code:q.INTERNAL_SERVER_ERROR.CODE}}y(H,"catchError");var W=function(e){return e.DEPENDENCY="dependencies",e.DEV_DEPENDENCY="devDependencies",e.PEER_DEPENDENCY="peerDependencies",e.BUNDLE_DEPENDENCY="bundleDependencies",e.OPTIONAL_DEPENDENCY="optionalDependencies",e}({});var J=N(require("node-fetch"),1);var z=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});var $=N(require("fs-extra"),1),X=N(require("path"),1);var Z=$.default,ee=Z.lstatSync,et=Z.readdirSync,en=Z.mkdirSync,er=Z.readFileSync,ea=Z.unlinkSync,eo=Z.statSync,es=$.default.readJsonSync;function ei(e,t,n){$.default.writeFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}y(ei,"writeFileSync");function ec(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}return t.every(function(e){return $.default.pathExistsSync(e)})}y(ec,"pathExistsSync");var eu=N(require("fs-extra"),1);var el=N(require("path"),1);var eE=F(),ed=el.default;function ef(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=ed).resolve.apply(r,[eE.CWD].concat(E(t)))}y(ef,"resolveWorkingPath");function ep(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=ed).join.apply(r,E(t))}y(ep,"join");var em=F(),eS=em.CWD,eD="@cyberskill/shared",eO="node_modules",ev="dist",eC="package.json",ey="package-lock.json",eI="tsconfig.json",eh=".gitignore",eN=".simple-git-hooks.json",eT="pnpm-lock.yaml",eA=".git/hooks/",eg=".git/COMMIT_EDITMSG",e_=".migrate-mongo.config.js",eR=function(){var e=eu.default.readJsonSync(ef(eC)).name===eD?eS:ep(eS,eO,eD);return ep(e,ev)}(),eG="cyberskill",eP="src/node/cli/index.ts",eM="eslint",eb="eslint",eL="vitest";var eU="vitest",ew="@commitlint/cli",ek="@commitlint/config-conventional",eF="commitlint",eY="lint-staged",eV="lint-staged",ex="typescript",ej="tsc",eq="tsx",eK="git",eB="pnpm",eQ="pnpm exec",eH="simple-git-hooks",eW="simple-git-hooks",eJ="@eslint/config-inspector",ez="eslint-config-inspector",e$="node-modules-inspector",eX="node-modules-inspector",eZ="migrate-mongo",e0="./node_modules/migrate-mongo/bin/migrate-mongo",e1={CYBERSKILL_DIRECTORY:eR,WORKING_DIRECTORY:eS,TS_CONFIG:ef(eI),GIT_IGNORE:ef(eh),GIT_HOOK:ef(eA),GIT_COMMIT_MSG:ef(eg),SIMPLE_GIT_HOOKS_JSON:ef(eN),PACKAGE_JSON:ef(eC),PACKAGE_LOCK_JSON:ef(ey),PNPM_LOCK_YAML:ef(eT),NODE_MODULES:ef(eO),MIGRATE_MONGO_CONFIG:ef(e_),LINT_STAGED_CONFIG:ef("".concat(eR,"/config/lint-staged/index.js")),COMMITLINT_CONFIG:ef("".concat(eR,"/config/commitlint/index.js")),UNIT_TEST_CONFIG:ef("".concat(eR,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:ef("".concat(eR,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:ef("".concat(eR,"/react/vitest/vitest.e2e.js"))};function e2(e){var t=e.type,n=e.packages,r=e.command;var o=n===null||n===void 0?void 0:n.reduce(function(e,t){return e.some(function(e){return e.name===t.name})||e.push(t),e},[]);return function(){return a(function(){var e;return p(this,function(n){switch(n.label){case 0:switch(t){case z.CLI:return[3,1];case z.STRING:return[3,4]}return[3,5];case 1:e=o===null||o===void 0?void 0:o.length;if(!e)return[3,3];return[4,e9(o,{update:!0})];case 2:e=n.sent();n.label=3;case 3:return[2,(e,tm(tf("".concat(eQ," ").concat(r))))];case 4:return[2,tm(tf(r))];case 5:throw new Error("Unsupported command type");case 6:return[2]}})})()}}y(e2,"buildCommand");var e4={simpleGitHooks:e2({type:z.CLI,packages:[{name:eH,type:W.DEV_DEPENDENCY}],command:eW}),eslintInspect:e2({type:z.CLI,packages:[{name:eJ,type:W.DEV_DEPENDENCY}],command:ez}),nodeModulesInspect:e2({type:z.CLI,packages:[{name:e$,type:W.DEV_DEPENDENCY}],command:eX}),eslintCheck:e2({type:z.CLI,packages:[{name:eM,type:W.DEV_DEPENDENCY}],command:"".concat(eb," ").concat(e1.WORKING_DIRECTORY," --no-cache")}),eslintFix:e2({type:z.CLI,packages:[{name:eM,type:W.DEV_DEPENDENCY}],command:"".concat(eb," ").concat(e1.WORKING_DIRECTORY," --fix --no-cache")}),typescriptCheck:e2({type:z.CLI,packages:[{name:ex,type:W.DEPENDENCY}],command:"".concat(ej," -p ").concat(e1.TS_CONFIG," --noEmit")}),testUnit:e2({type:z.CLI,packages:[{name:eL,type:W.DEV_DEPENDENCY}],command:"".concat(eU," --config ").concat(e1.UNIT_TEST_CONFIG)}),testE2e:e2({type:z.CLI,packages:[{name:eL,type:W.DEV_DEPENDENCY}],command:"".concat(eU," --config ").concat(e1.E2E_TEST_CONFIG)}),mongoMigrateCreate:y(function(e){return e2({type:z.CLI,packages:[{name:eZ,type:W.DEPENDENCY}],command:"".concat(eq," ").concat(e0," create ").concat(e," -f ").concat(e1.MIGRATE_MONGO_CONFIG)})()},"mongoMigrateCreate"),mongoMigrateUp:e2({type:z.CLI,packages:[{name:eZ,type:W.DEPENDENCY}],command:"".concat(eq," ").concat(e0," up -f ").concat(e1.MIGRATE_MONGO_CONFIG)}),mongoMigrateDown:e2({type:z.CLI,packages:[{name:eZ,type:W.DEPENDENCY}],command:"".concat(eq," ").concat(e0," down -f ").concat(e1.MIGRATE_MONGO_CONFIG)}),commitLint:e2({type:z.CLI,packages:[{name:ew,type:W.DEV_DEPENDENCY},{name:ek,type:W.DEV_DEPENDENCY}],command:"".concat(eF," --edit ").concat(e1.GIT_COMMIT_MSG," --config ").concat(e1.COMMITLINT_CONFIG)}),lintStaged:e2({type:z.CLI,packages:[{name:eY,type:W.DEV_DEPENDENCY}],command:"".concat(eV," --config ").concat(e1.LINT_STAGED_CONFIG)}),configureGitHook:e2({type:z.STRING,command:"".concat(eK," config core.hooksPath ").concat(e1.GIT_HOOK)}),build:e2({type:z.STRING,command:"".concat(eB," run --if-present build")}),pnpmInstallStandard:e2({type:z.STRING,command:"".concat(eB," install --ignore-scripts --no-frozen-lockfile")}),pnpmInstallLegacy:e2({type:z.STRING,command:"".concat(eB," install --ignore-scripts --no-frozen-lockfile --legacy-peer-deps")}),pnpmInstallForce:e2({type:z.STRING,command:"".concat(eB," install --ignore-scripts --no-frozen-lockfile --force")})};var e3=F();function e5(e){return a(function(){var t,n,r,a;return p(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,(0,J.default)("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:t=o.sent();if(!t.ok)throw new Error("Failed to fetch latest version: ".concat(t.status," ").concat(t.statusText));return[4,t.json()];case 2:n=o.sent(),r=n.version;return[2,{success:!0,result:r}];case 3:a=o.sent();return[2,H(a)];case 4:return[2]}})})()}y(e5,"getLatestPackageVersion");function e7(e){return a(function(){var t,n,r,a,o,s,i,c,u,l,E,d,f,m,S,D,O,v,C,y,I,h,N,T;return p(this,function(p){switch(p.label){case 0:p.trys.push([0,2,,3]);if(!e){if(ec(e1.PACKAGE_JSON)){t=es(e1.PACKAGE_JSON),n=t.name,r=n===void 0?"":n,a=t.version,o=a===void 0?"":a;return[2,{success:!0,result:{name:r,currentVersion:o,latestVersion:o,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:!1,isDevDependency:!1,installedPath:e1.PACKAGE_JSON,file:t}}]}return[2,{success:!0,result:{name:"",currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:!1,isDevDependency:!1,installedPath:"",file:{}}}]}if(!ec(e1.PACKAGE_JSON))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===W.DEPENDENCY,isDevDependency:e.type===W.DEV_DEPENDENCY,installedPath:"",file:{}}}];s=es(e1.PACKAGE_JSON),i=s.name,c=s.version,u=c===void 0?"":c,l=s.dependencies,E=l===void 0?{}:l,d=s.devDependencies,f=d===void 0?{}:d;if(e.name===i)return[2,{success:!0,result:{name:i,currentVersion:u,latestVersion:u,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:e.type===W.DEPENDENCY,isDevDependency:e.type===W.DEV_DEPENDENCY,installedPath:e1.PACKAGE_JSON,file:s}}];m=e.name in E,S=e.name in f;return[4,e5(e.name)];case 1:D=p.sent();if(!D.success)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:"",file:{}}}];if(!m&&!S)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:D.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===W.DEPENDENCY,isDevDependency:e.type===W.DEV_DEPENDENCY,installedPath:"",file:{}}}];C=(v=(O=E[e.name])!==null&&O!==void 0?O:f[e.name])!==null&&v!==void 0?v:"",y=ep(e3.CWD,eO,e.name,eC);if(!ec(y))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:D.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:"",file:{}}}];I=es(y),h=I.version,N=h===void 0?"":h;return[2,C!==N?{success:!0,result:{name:e.name,currentVersion:N||C,latestVersion:D.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:y,file:I}}:{success:!0,result:{name:e.name,currentVersion:C,latestVersion:D.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:C===D.result,isDependency:m,isDevDependency:S,installedPath:y,file:I}}];case 2:T=p.sent();return[2,H(T)];case 3:return[2]}})})()}y(e7,"getPackage");function e6(e){return a(function(){var t,n,r,a,o;return p(this,function(s){try{;r=es(e1.PACKAGE_JSON),a=(t=r.dependencies)!==null&&t!==void 0?t:{},o=(n=r.devDependencies)!==null&&n!==void 0?n:{};e.isDependency?a[e.name]=e.latestVersion:e.isDevDependency&&(o[e.name]=e.latestVersion),ei(e1.PACKAGE_JSON,JSON.stringify(r,null,4)),Q.info('Updated "'.concat(e.name,'" to version ').concat(e.latestVersion))}catch(e){H(e)}return[2]})})()}y(e6,"updatePackage");function e8(){return a(function(){var e,t,n,r,a,o,s,i,c,u,l,E,d;return p(this,function(f){switch(f.label){case 0:f.trys.push([0,12,,13]);e=[{command:y(function(){return e4.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:y(function(){return e4.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:y(function(){return e4.pnpmInstallForce()},"command"),message:"Retrying with force install"}];t=true,n=false,r=undefined;f.label=1;case 1:f.trys.push([1,9,10,11]);a=e[Symbol.iterator]();f.label=2;case 2:if(!!(t=(o=a.next()).done))return[3,8];s=o.value,i=s.command,c=s.message;f.label=3;case 3:f.trys.push([3,6,,7]);return[4,i()];case 4:u=f.sent();return[4,tD("".concat(c," using: ").concat(u),u)];case 5:f.sent();return[2];case 6:l=f.sent();H(l);return[3,7];case 7:t=true;return[3,2];case 8:return[3,11];case 9:E=f.sent();n=true;r=E;return[3,11];case 10:try{if(!t&&a.return!=null){a.return()}}finally{if(n){throw r}}return[7];case 11:return[3,13];case 12:d=f.sent();H(d);return[3,13];case 13:return[2]}})})()}y(e8,"installDependencies");function e9(e,t){return a(function(){var n,r,a,o,s,i,c,u,l,E,d,f;return p(this,function(p){switch(p.label){case 0:if(!ec(e1.PACKAGE_JSON)){Q.error("package.json not found. Aborting setup.");return[2]}p.label=1;case 1:p.trys.push([1,16,,17]);return[4,Promise.all(e.map(e7))];case 2:n=p.sent().filter(function(e){return e.success?!e.result.isCurrentProject&&(!e.result.isInstalled||!e.result.isUpToDate):!1});r=n.length>0;if(!r)return[3,7];return[4,Promise.all(n.map(function(e){return e.success?e6(e.result):Promise.resolve()}))];case 3:p.sent();return[4,e8()];case 4:p.sent();a=["Running ESLint with auto-fix"];return[4,e4.eslintFix()];case 5:return[4,tD.apply(void 0,a.concat([p.sent()]))];case 6:r=p.sent();p.label=7;case 7:r;s=true,i=false,c=undefined;p.label=8;case 8:p.trys.push([8,13,14,15]);u=((o=t===null||t===void 0?void 0:t.postInstallActions)!==null&&o!==void 0?o:[])[Symbol.iterator]();p.label=9;case 9:if(!!(s=(l=u.next()).done))return[3,12];E=l.value;return[4,E()];case 10:p.sent();p.label=11;case 11:s=true;return[3,9];case 12:return[3,15];case 13:d=p.sent();i=true;c=d;return[3,15];case 14:try{if(!s&&u.return!=null){u.return()}}finally{if(i){throw c}}return[7];case 15:return[3,17];case 16:f=p.sent();H(f);return[3,17];case 17:return[2]}})})()}y(e9,"setupPackages");var te=N(require("node-persist"),1);var tt=F();function tn(){return a(function(){var e;return p(this,function(t){switch(t.label){case 0:e=te.default.defaultInstance;if(e)return[3,2];return[4,te.default.init({dir:tt.CYBERSKILL_STORAGE_DIRECTORY})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})})()}y(tn,"initNodePersist");var tr={get:function e(e){return a(function(){var t,n;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tn()];case 1:r.sent();return[4,te.default.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,H(n,{returnValue:null})];case 4:return[2]}})})()},set:function e(e,t){return a(function(){var n;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tn()];case 1:r.sent();return[4,te.default.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();H(n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return a(function(){var t;return p(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tn()];case 1:n.sent();return[4,te.default.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();H(t);return[3,4];case 4:return[2]}})})()},keys:function e(){return a(function(){var e,t;return p(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tn()];case 1:n.sent();return[4,te.default.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(Q.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,H(t,{returnValue:[]})];case 4:return[2]}})})()},getLogLink:function e(e){return a(function(){return p(this,function(t){try{return[2,"".concat(tt.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,H(e,{returnValue:null})]}return[2]})})()}};var ta=F(),to=R.promisify(g.exec);function ts(){return a(function(){var e;return p(this,function(t){switch(t.label){case 0:return[4,e7()];case 1:e=t.sent();return[2,e.success?e.result.name:Date.now().toString()]}})})()}y(ts,"getPackageName");function ti(e){return a(function(){var t,n;return p(this,function(r){switch(r.label){case 0:if(e.length===0)return[2];return[4,ts()];case 1:t=r.sent();r.label=2;case 2:r.trys.push([2,4,,5]);return[4,tr.set(t,e)];case 3:r.sent(),setTimeout(function(){return a(function(){var e;return p(this,function(n){switch(n.label){case 0:return[4,tr.getLogLink(t)];case 1:e=n.sent();e&&Q.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},0);return[3,5];case 4:n=r.sent();H(n);return[3,5];case 5:return[2]}})})()}y(ti,"saveErrorListToStorage");function tc(){return a(function(){var e,t,n;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,ts()];case 1:e=r.sent();return[4,tr.get(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:[]];case 3:n=r.sent();return[2,H(n,{returnValue:[]})];case 4:return[2]}})})()}y(tc,"getStoredErrorLists");function tu(){return a(function(){var e,t;return p(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,ts()];case 1:e=n.sent();return[4,tr.remove(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();H(t);return[3,4];case 4:return[2]}})})()}y(tu,"clearAllErrorLists");function tl(e){var t=[],n=[],r="",a=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,o=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,s=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var i,c,u,l,E;var d=a.exec(e)||[],f=o.exec(e)||[],p=s.exec(e)||[];var m,S,D,O,v,C;d.length&&r?t.push({file:r,position:"".concat(d[1],":").concat(d[2]),type:d[3]===Y.Error?Y.Error:Y.Warning,message:(m=d===null||d===void 0?void 0:(i=d[4])===null||i===void 0?void 0:i.trim())!==null&&m!==void 0?m:"",rule:(S=d===null||d===void 0?void 0:(c=d[5])===null||c===void 0?void 0:c.trim())!==null&&S!==void 0?S:""}):f.length?t.push({file:(D=f===null||f===void 0?void 0:f[1])!==null&&D!==void 0?D:"",position:"".concat(f[2],":").concat(f[3]),type:f[4]===Y.Error?Y.Error:Y.Warning,message:(O=f===null||f===void 0?void 0:(u=f[5])===null||u===void 0?void 0:u.trim())!==null&&O!==void 0?O:""}):p.length?t.push({file:"commitlint",type:Y.Error,message:(v=p===null||p===void 0?void 0:(l=p[1])===null||l===void 0?void 0:l.trim())!==null&&v!==void 0?v:"",rule:(C=p===null||p===void 0?void 0:(E=p[2])===null||E===void 0?void 0:E.trim())!==null&&C!==void 0?C:""}):n.push(e.trim())}}),t.length&&ti(t),ta.DEBUG&&n.length&&(Q.warn("Unmatched lines:"),n.forEach(function(e){return Q.info(" ".concat(e))}))}y(tl,"parseTextErrors");function tE(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,a=e.line,o=e.column,s=e.ruleId,i=e.message;n.push({type:r===2?Y.Error:Y.Warning,file:t,position:"".concat(a,":").concat(o),rule:s,message:i})})}),n.length&&ti(n)}catch(t){tl(e)}}y(tE,"parseCommandOutput");function td(e){return a(function(e){var t,n,r,a,o,s,i,c,u;var l=arguments;return p(this,function(E){switch(E.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:tE;n=new AbortController;_.default.on("SIGINT",function(){Q.warn("Process interrupted. Terminating..."),n.abort(),_.default.exit()});E.label=1;case 1:E.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,to(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=E.sent(),a=r.stdout,o=r.stderr;[a,o].forEach(function(e){return e&&t(e)});E.label=3;case 3:return[3,5];case 4:s=E.sent();i=s.stdout,c=s.stderr,u=s.message;[i,c].forEach(function(e){return e&&t(e)}),!c&&!i&&Q.error("Command failed: ".concat(u));return[3,5];case 5:return[2]}})}).apply(this,arguments)}y(td,"executeCommand");function tf(e){return{raw:!0,cmd:e}}y(tf,"rawCommand");function tp(e,t){return(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(eQ," ").concat(eq," ").concat(eP," ").concat(e):"".concat(eQ," ").concat(eG," ").concat(e)}y(tp,"formatCLI");function tm(e,t){return typeof e=="function"?tp(e(t),t):(typeof e==="undefined"?"undefined":d(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?tp(e,t):e}y(tm,"formatCommand");function tS(e){return a(function(){var t,n,r;return p(this,function(a){switch(a.label){case 0:return[4,e7({name:eD})];case 1:t=a.sent();if(t.success){n={isCurrentProject:t.result.isCurrentProject},r=typeof e=="function"?e(n):e;return[2,Object.fromEntries(Object.entries(r).map(function(e){var t=l(e,2),r=t[0],a=t[1];return[r,tm(a,n)]}))]}return[2]}})})()}y(tS,"resolveCommands");function tD(e,t){return a(function(){var n;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);Q.start("".concat(e)),ta.DEBUG&&Q.info("→ ".concat(t));return[4,td(t)];case 1:r.sent(),Q.success("".concat(e," done."));return[3,3];case 2:n=r.sent();H(n);return[3,3];case 3:return[2]}})})()}y(tD,"runCommand");0&&(module.exports={clearAllErrorLists:clearAllErrorLists,formatCommand:formatCommand,getStoredErrorLists:getStoredErrorLists,rawCommand:rawCommand,resolveCommands:resolveCommands,runCommand:runCommand});
1
+ "use strict";function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(t){if(Array.isArray(t))return e(t)}function r(e,t,n,r,a,o,s){try{var i=e[o](s);var c=i.value}catch(e){n(e);return}if(i.done){t(c)}else{Promise.resolve(c).then(r,a)}}function a(e){return function(){var t=this,n=arguments;return new Promise(function(a,o){var s=e.apply(t,n);function i(e){r(s,a,o,i,c,"next",e)}function c(e){r(s,a,o,i,c,"throw",e)}i(undefined)})}}function o(e,t){if(t!=null&&typeof Symbol!=="undefined"&&t[Symbol.hasInstance]){return!!t[Symbol.hasInstance](e)}else{return e instanceof t}}function s(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function i(e,t){var n=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n==null)return;var r=[];var a=true;var o=false;var s,i;try{for(n=n.call(e);!(a=(s=n.next()).done);a=true){r.push(s.value);if(t&&r.length===t)break}}catch(e){o=true;i=e}finally{try{if(!a&&n["return"]!=null)n["return"]()}finally{if(o)throw i}}return r}function c(){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 u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e,n){return t(e)||i(e,n)||f(e,n)||c()}function E(e){return n(e)||s(e)||f(e)||u()}function d(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function f(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}function p(e,t){var n,r,a,o={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=i(0),s["throw"]=i(1),s["return"]=i(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function i(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,i[0]&&(o=0)),o)try{if(n=1,r&&(a=i[0]&2?r["return"]:i[0]?r["throw"]||((a=r["return"])&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;if(r=0,a)i=[i[0]&2,a.value];switch(i[0]){case 0:case 1:a=i;break;case 4:o.label++;return{value:i[1],done:false};case 5:o.label++;r=i[1];i=[0];continue;case 7:i=o.ops.pop();o.trys.pop();continue;default:if(!(a=o.trys,a=a.length>0&&a[a.length-1])&&(i[0]===6||i[0]===2)){o=0;continue}if(i[0]===3&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(i[0]===6&&o.label<a[1]){o.label=a[1];a=i;break}if(a&&o.label<a[2]){o.label=a[2];o.ops.push(i);break}if(a[2])o.ops.pop();o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e];r=0}finally{n=a=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}}var m=Object.create;var S=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var y=function(e,t){return S(e,"name",{value:t,configurable:!0})};var I=function(e,t){for(var n in t)S(e,n,{get:t[n],enumerable:!0})},h=function(e,t,n,r){var a=true,o=false,s=undefined;if(t&&(typeof t==="undefined"?"undefined":d(t))=="object"||typeof t=="function")try{var i=function(){var a=u.value;!C.call(e,a)&&a!==n&&S(e,a,{get:function(){return t[a]},enumerable:!(r=D(t,a))||r.enumerable})};for(var c=O(t)[Symbol.iterator](),u;!(a=(u=c.next()).done);a=true)i()}catch(e){o=true;s=e}finally{try{if(!a&&c.return!=null){c.return()}}finally{if(o){throw s}}}return e};var N=function(e,t,n){return n=e!=null?m(v(e)):{},h(t||!e||!e.__esModule?S(n,"default",{value:e,enumerable:!0}):n,e)},T=function(e){return h(S({},"__esModule",{value:!0}),e)};var A={};I(A,{clearAllErrorLists:function(){return tu},formatCommand:function(){return tm},getStoredErrorLists:function(){return tc},rawCommand:function(){return tf},resolveCommands:function(){return tS},runCommand:function(){return tD}});module.exports=T(A);var g=require("child_process"),_=N(require("process"),1),R=N(require("util"),1);var G=".cyberskill-storage";var P=N(require("@dotenvx/dotenvx"),1),M=require("envalid"),b=N(require("os"),1),L=N(require("path"),1),U=N(require("process"),1);var w=!1;function k(){w||(P.default.config(),w=!0)}y(k,"loadEnvFile");function F(){k();var e=(0,M.cleanEnv)(U.default.env,{CWD:(0,M.str)({default:U.default.cwd()}),DEBUG:(0,M.bool)({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:(0,M.str)({default:L.default.join(b.default.homedir(),G)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}y(F,"getEnv");var Y=function(e){return e.Error="error",e.Warning="warning",e}({});var V=N(require("chalk"),1),x=N(require("consola"),1),j=require("graphql");var q={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};var K=F();K.DEBUG||(x.default.level=4);function B(e){var t=V.default[e];return typeof t=="function"?t:V.default.green}y(B,"chalkKeyword");var Q={silent:x.default.silent,level:x.default.level,fatal:x.default.fatal,error:x.default.error,warn:x.default.warn,log:x.default.log,info:x.default.info,success:x.default.success,ready:x.default.ready,start:x.default.start,box:x.default.box,debug:x.default.debug,trace:x.default.trace,verbose:x.default.verbose,printBoxedLog:function e(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(t===null||t===void 0?void 0:t.length)){x.default.box(V.default.green(e));return}t.forEach(function(e){var t=e.file,r=e.position,a=e.rule,o=e.message;x.default.log("".concat(V.default.gray("File:")," ").concat(V.default.blue("".concat(t).concat(r?":".concat(r):"")))),a&&x.default.log(" ".concat(B(n)("Rule:")," ").concat(a)),x.default.log(" ".concat(B(n)("Message:")," ").concat(o))}),x.default.box(B(n)("".concat(e," : ").concat(t.length))),x.default.log(V.default.gray("─".repeat(40)))}};function H(e,t){var n=t!==null&&t!==void 0?t:{},r=n.shouldLog,a=r===void 0?!0:r,s=n.returnValue,i=n.callback,c=o(e,Error)?e:new Error(typeof e=="string"?e:"Unknown error");return a&&Q.error(c.message),i&&typeof i=="function"&&i(c),s||{success:!1,message:c.message,code:q.INTERNAL_SERVER_ERROR.CODE}}y(H,"catchError");var W=function(e){return e.DEPENDENCY="dependencies",e.DEV_DEPENDENCY="devDependencies",e.PEER_DEPENDENCY="peerDependencies",e.BUNDLE_DEPENDENCY="bundleDependencies",e.OPTIONAL_DEPENDENCY="optionalDependencies",e}({});var J=N(require("node-fetch"),1);var z=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});var $=N(require("fs-extra"),1),X=N(require("path"),1);var Z=$.default,ee=Z.lstatSync,et=Z.readdirSync,en=Z.mkdirSync,er=Z.readFileSync,ea=Z.unlinkSync,eo=Z.statSync,es=$.default.readJsonSync;function ei(e,t,n){$.default.writeFileSync(e,t,n!==null&&n!==void 0?n:"utf-8")}y(ei,"writeFileSync");function ec(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}return t.every(function(e){return $.default.pathExistsSync(e)})}y(ec,"pathExistsSync");var eu=N(require("fs-extra"),1);var el=N(require("path"),1);var eE=F(),ed=el.default;function ef(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=ed).resolve.apply(r,[eE.CWD].concat(E(t)))}y(ef,"resolveWorkingPath");function ep(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=ed).join.apply(r,E(t))}y(ep,"join");var em=F(),eS=em.CWD,eD="@cyberskill/shared",eO="node_modules",ev="dist",eC="package.json",ey="package-lock.json",eI="tsconfig.json",eh=".gitignore",eN=".simple-git-hooks.json",eT="pnpm-lock.yaml",eA=".git/hooks/",eg=".git/COMMIT_EDITMSG",e_=".migrate-mongo.config.js",eR=function(){var e=eu.default.readJsonSync(ef(eC)).name===eD?eS:ep(eS,eO,eD);return ep(e,ev)}(),eG="cyberskill",eP="src/node/cli/index.ts",eM="eslint",eb="eslint",eL="vitest";var eU="vitest",ew="@commitlint/cli",ek="@commitlint/config-conventional",eF="commitlint",eY="lint-staged",eV="lint-staged",ex="typescript",ej="tsc",eq="tsx",eK="git",eB="pnpm",eQ="pnpm exec",eH="simple-git-hooks",eW="simple-git-hooks",eJ="@eslint/config-inspector",ez="eslint-config-inspector",e$="node-modules-inspector",eX="node-modules-inspector",eZ="migrate-mongo",e0="./node_modules/migrate-mongo/bin/migrate-mongo",e1={CYBERSKILL_DIRECTORY:eR,WORKING_DIRECTORY:eS,TS_CONFIG:ef(eI),GIT_IGNORE:ef(eh),GIT_HOOK:ef(eA),GIT_COMMIT_MSG:ef(eg),SIMPLE_GIT_HOOKS_JSON:ef(eN),PACKAGE_JSON:ef(eC),PACKAGE_LOCK_JSON:ef(ey),PNPM_LOCK_YAML:ef(eT),NODE_MODULES:ef(eO),MIGRATE_MONGO_CONFIG:ef(e_),LINT_STAGED_CONFIG:ef("".concat(eR,"/config/lint-staged/index.js")),COMMITLINT_CONFIG:ef("".concat(eR,"/config/commitlint/index.js")),UNIT_TEST_CONFIG:ef("".concat(eR,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:ef("".concat(eR,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:ef("".concat(eR,"/react/vitest/vitest.e2e.js"))};function e2(e){var t=e.type,n=e.packages,r=e.command;var o=n===null||n===void 0?void 0:n.reduce(function(e,t){return e.some(function(e){return e.name===t.name})||e.push(t),e},[]);return function(){return a(function(){var e;return p(this,function(n){switch(n.label){case 0:switch(t){case z.CLI:return[3,1];case z.STRING:return[3,4]}return[3,5];case 1:e=o===null||o===void 0?void 0:o.length;if(!e)return[3,3];return[4,e9(o,{update:!0})];case 2:e=n.sent();n.label=3;case 3:return[2,(e,tm(tf("".concat(eQ," ").concat(r))))];case 4:return[2,tm(tf(r))];case 5:throw new Error("Unsupported command type");case 6:return[2]}})})()}}y(e2,"buildCommand");var e4={simpleGitHooks:e2({type:z.CLI,packages:[{name:eH,type:W.DEV_DEPENDENCY}],command:eW}),eslintInspect:e2({type:z.CLI,packages:[{name:eJ,type:W.DEV_DEPENDENCY}],command:ez}),nodeModulesInspect:e2({type:z.CLI,packages:[{name:e$,type:W.DEV_DEPENDENCY}],command:eX}),eslintCheck:e2({type:z.CLI,packages:[{name:eM,type:W.DEV_DEPENDENCY}],command:"".concat(eb," ").concat(e1.WORKING_DIRECTORY," --no-cache")}),eslintFix:e2({type:z.CLI,packages:[{name:eM,type:W.DEV_DEPENDENCY}],command:"".concat(eb," ").concat(e1.WORKING_DIRECTORY," --fix --no-cache")}),typescriptCheck:e2({type:z.CLI,packages:[{name:ex,type:W.DEPENDENCY}],command:"".concat(ej," -p ").concat(e1.TS_CONFIG," --noEmit")}),testUnit:e2({type:z.CLI,packages:[{name:eL,type:W.DEV_DEPENDENCY}],command:"".concat(eU," --config ").concat(e1.UNIT_TEST_CONFIG)}),testE2e:e2({type:z.CLI,packages:[{name:eL,type:W.DEV_DEPENDENCY}],command:"".concat(eU," --config ").concat(e1.E2E_TEST_CONFIG)}),mongoMigrateCreate:y(function(e){return e2({type:z.CLI,packages:[{name:eZ,type:W.DEPENDENCY}],command:"".concat(eq," ").concat(e0," create ").concat(e," -f ").concat(e1.MIGRATE_MONGO_CONFIG)})()},"mongoMigrateCreate"),mongoMigrateUp:e2({type:z.CLI,packages:[{name:eZ,type:W.DEPENDENCY}],command:"".concat(eq," ").concat(e0," up -f ").concat(e1.MIGRATE_MONGO_CONFIG)}),mongoMigrateDown:e2({type:z.CLI,packages:[{name:eZ,type:W.DEPENDENCY}],command:"".concat(eq," ").concat(e0," down -f ").concat(e1.MIGRATE_MONGO_CONFIG)}),commitLint:e2({type:z.CLI,packages:[{name:ew,type:W.DEV_DEPENDENCY},{name:ek,type:W.DEV_DEPENDENCY}],command:"".concat(eF," --edit ").concat(e1.GIT_COMMIT_MSG," --config ").concat(e1.COMMITLINT_CONFIG)}),lintStaged:e2({type:z.CLI,packages:[{name:eY,type:W.DEV_DEPENDENCY}],command:"".concat(eV," --config ").concat(e1.LINT_STAGED_CONFIG)}),configureGitHook:e2({type:z.STRING,command:"".concat(eK," config core.hooksPath ").concat(e1.GIT_HOOK)}),build:e2({type:z.STRING,command:"".concat(eB," run --if-present build")}),pnpmInstallStandard:e2({type:z.STRING,command:"".concat(eB," install --ignore-scripts --frozen-lockfile")}),pnpmInstallLegacy:e2({type:z.STRING,command:"".concat(eB," install --ignore-scripts --frozen-lockfile --legacy-peer-deps")}),pnpmInstallForce:e2({type:z.STRING,command:"".concat(eB," install --ignore-scripts --frozen-lockfile --force")})};var e3=F();function e5(e){return a(function(){var t,n,r,a;return p(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,(0,J.default)("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:t=o.sent();if(!t.ok)throw new Error("Failed to fetch latest version: ".concat(t.status," ").concat(t.statusText));return[4,t.json()];case 2:n=o.sent(),r=n.version;return[2,{success:!0,result:r}];case 3:a=o.sent();return[2,H(a)];case 4:return[2]}})})()}y(e5,"getLatestPackageVersion");function e7(e){return a(function(){var t,n,r,a,o,s,i,c,u,l,E,d,f,m,S,D,O,v,C,y,I,h,N,T;return p(this,function(p){switch(p.label){case 0:p.trys.push([0,2,,3]);if(!e){if(ec(e1.PACKAGE_JSON)){t=es(e1.PACKAGE_JSON),n=t.name,r=n===void 0?"":n,a=t.version,o=a===void 0?"":a;return[2,{success:!0,result:{name:r,currentVersion:o,latestVersion:o,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:!1,isDevDependency:!1,installedPath:e1.PACKAGE_JSON,file:t}}]}return[2,{success:!0,result:{name:"",currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:!1,isDevDependency:!1,installedPath:"",file:{}}}]}if(!ec(e1.PACKAGE_JSON))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===W.DEPENDENCY,isDevDependency:e.type===W.DEV_DEPENDENCY,installedPath:"",file:{}}}];s=es(e1.PACKAGE_JSON),i=s.name,c=s.version,u=c===void 0?"":c,l=s.dependencies,E=l===void 0?{}:l,d=s.devDependencies,f=d===void 0?{}:d;if(e.name===i)return[2,{success:!0,result:{name:i,currentVersion:u,latestVersion:u,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:e.type===W.DEPENDENCY,isDevDependency:e.type===W.DEV_DEPENDENCY,installedPath:e1.PACKAGE_JSON,file:s}}];m=e.name in E,S=e.name in f;return[4,e5(e.name)];case 1:D=p.sent();if(!D.success)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:"",file:{}}}];if(!m&&!S)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:D.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===W.DEPENDENCY,isDevDependency:e.type===W.DEV_DEPENDENCY,installedPath:"",file:{}}}];C=(v=(O=E[e.name])!==null&&O!==void 0?O:f[e.name])!==null&&v!==void 0?v:"",y=ep(e3.CWD,eO,e.name,eC);if(!ec(y))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:D.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:"",file:{}}}];I=es(y),h=I.version,N=h===void 0?"":h;return[2,C!==N?{success:!0,result:{name:e.name,currentVersion:N||C,latestVersion:D.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:y,file:I}}:{success:!0,result:{name:e.name,currentVersion:C,latestVersion:D.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:C===D.result,isDependency:m,isDevDependency:S,installedPath:y,file:I}}];case 2:T=p.sent();return[2,H(T)];case 3:return[2]}})})()}y(e7,"getPackage");function e6(e){return a(function(){var t,n,r,a,o;return p(this,function(s){try{;r=es(e1.PACKAGE_JSON),a=(t=r.dependencies)!==null&&t!==void 0?t:{},o=(n=r.devDependencies)!==null&&n!==void 0?n:{};e.isDependency?a[e.name]=e.latestVersion:e.isDevDependency&&(o[e.name]=e.latestVersion),ei(e1.PACKAGE_JSON,JSON.stringify(r,null,4)),Q.info('Updated "'.concat(e.name,'" to version ').concat(e.latestVersion))}catch(e){H(e)}return[2]})})()}y(e6,"updatePackage");function e8(){return a(function(){var e,t,n,r,a,o,s,i,c,u,l,E,d;return p(this,function(f){switch(f.label){case 0:f.trys.push([0,12,,13]);e=[{command:y(function(){return e4.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:y(function(){return e4.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:y(function(){return e4.pnpmInstallForce()},"command"),message:"Retrying with force install"}];t=true,n=false,r=undefined;f.label=1;case 1:f.trys.push([1,9,10,11]);a=e[Symbol.iterator]();f.label=2;case 2:if(!!(t=(o=a.next()).done))return[3,8];s=o.value,i=s.command,c=s.message;f.label=3;case 3:f.trys.push([3,6,,7]);return[4,i()];case 4:u=f.sent();return[4,tD("".concat(c," using: ").concat(u),u)];case 5:f.sent();return[2];case 6:l=f.sent();H(l);return[3,7];case 7:t=true;return[3,2];case 8:return[3,11];case 9:E=f.sent();n=true;r=E;return[3,11];case 10:try{if(!t&&a.return!=null){a.return()}}finally{if(n){throw r}}return[7];case 11:return[3,13];case 12:d=f.sent();H(d);return[3,13];case 13:return[2]}})})()}y(e8,"installDependencies");function e9(e,t){return a(function(){var n,r,a,o,s,i,c,u,l,E,d,f;return p(this,function(p){switch(p.label){case 0:if(!ec(e1.PACKAGE_JSON)){Q.error("package.json not found. Aborting setup.");return[2]}p.label=1;case 1:p.trys.push([1,16,,17]);return[4,Promise.all(e.map(e7))];case 2:n=p.sent().filter(function(e){return e.success?!e.result.isCurrentProject&&(!e.result.isInstalled||!e.result.isUpToDate):!1});r=n.length>0;if(!r)return[3,7];return[4,Promise.all(n.map(function(e){return e.success?e6(e.result):Promise.resolve()}))];case 3:p.sent();return[4,e8()];case 4:p.sent();a=["Running ESLint with auto-fix"];return[4,e4.eslintFix()];case 5:return[4,tD.apply(void 0,a.concat([p.sent()]))];case 6:r=p.sent();p.label=7;case 7:r;s=true,i=false,c=undefined;p.label=8;case 8:p.trys.push([8,13,14,15]);u=((o=t===null||t===void 0?void 0:t.postInstallActions)!==null&&o!==void 0?o:[])[Symbol.iterator]();p.label=9;case 9:if(!!(s=(l=u.next()).done))return[3,12];E=l.value;return[4,E()];case 10:p.sent();p.label=11;case 11:s=true;return[3,9];case 12:return[3,15];case 13:d=p.sent();i=true;c=d;return[3,15];case 14:try{if(!s&&u.return!=null){u.return()}}finally{if(i){throw c}}return[7];case 15:return[3,17];case 16:f=p.sent();H(f);return[3,17];case 17:return[2]}})})()}y(e9,"setupPackages");var te=N(require("node-persist"),1);var tt=F();function tn(){return a(function(){var e;return p(this,function(t){switch(t.label){case 0:e=te.default.defaultInstance;if(e)return[3,2];return[4,te.default.init({dir:tt.CYBERSKILL_STORAGE_DIRECTORY})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})})()}y(tn,"initNodePersist");var tr={get:function e(e){return a(function(){var t,n;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tn()];case 1:r.sent();return[4,te.default.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,H(n,{returnValue:null})];case 4:return[2]}})})()},set:function e(e,t){return a(function(){var n;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,tn()];case 1:r.sent();return[4,te.default.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();H(n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return a(function(){var t;return p(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tn()];case 1:n.sent();return[4,te.default.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();H(t);return[3,4];case 4:return[2]}})})()},keys:function e(){return a(function(){var e,t;return p(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,tn()];case 1:n.sent();return[4,te.default.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(Q.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,H(t,{returnValue:[]})];case 4:return[2]}})})()},getLogLink:function e(e){return a(function(){return p(this,function(t){try{return[2,"".concat(tt.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,H(e,{returnValue:null})]}return[2]})})()}};var ta=F(),to=R.promisify(g.exec);function ts(){return a(function(){var e;return p(this,function(t){switch(t.label){case 0:return[4,e7()];case 1:e=t.sent();return[2,e.success?e.result.name:Date.now().toString()]}})})()}y(ts,"getPackageName");function ti(e){return a(function(){var t,n;return p(this,function(r){switch(r.label){case 0:if(e.length===0)return[2];return[4,ts()];case 1:t=r.sent();r.label=2;case 2:r.trys.push([2,4,,5]);return[4,tr.set(t,e)];case 3:r.sent(),setTimeout(function(){return a(function(){var e;return p(this,function(n){switch(n.label){case 0:return[4,tr.getLogLink(t)];case 1:e=n.sent();e&&Q.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},0);return[3,5];case 4:n=r.sent();H(n);return[3,5];case 5:return[2]}})})()}y(ti,"saveErrorListToStorage");function tc(){return a(function(){var e,t,n;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,ts()];case 1:e=r.sent();return[4,tr.get(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:[]];case 3:n=r.sent();return[2,H(n,{returnValue:[]})];case 4:return[2]}})})()}y(tc,"getStoredErrorLists");function tu(){return a(function(){var e,t;return p(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,ts()];case 1:e=n.sent();return[4,tr.remove(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();H(t);return[3,4];case 4:return[2]}})})()}y(tu,"clearAllErrorLists");function tl(e){var t=[],n=[],r="",a=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,o=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,s=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var i,c,u,l,E;var d=a.exec(e)||[],f=o.exec(e)||[],p=s.exec(e)||[];var m,S,D,O,v,C;d.length&&r?t.push({file:r,position:"".concat(d[1],":").concat(d[2]),type:d[3]===Y.Error?Y.Error:Y.Warning,message:(m=d===null||d===void 0?void 0:(i=d[4])===null||i===void 0?void 0:i.trim())!==null&&m!==void 0?m:"",rule:(S=d===null||d===void 0?void 0:(c=d[5])===null||c===void 0?void 0:c.trim())!==null&&S!==void 0?S:""}):f.length?t.push({file:(D=f===null||f===void 0?void 0:f[1])!==null&&D!==void 0?D:"",position:"".concat(f[2],":").concat(f[3]),type:f[4]===Y.Error?Y.Error:Y.Warning,message:(O=f===null||f===void 0?void 0:(u=f[5])===null||u===void 0?void 0:u.trim())!==null&&O!==void 0?O:""}):p.length?t.push({file:"commitlint",type:Y.Error,message:(v=p===null||p===void 0?void 0:(l=p[1])===null||l===void 0?void 0:l.trim())!==null&&v!==void 0?v:"",rule:(C=p===null||p===void 0?void 0:(E=p[2])===null||E===void 0?void 0:E.trim())!==null&&C!==void 0?C:""}):n.push(e.trim())}}),t.length&&ti(t),ta.DEBUG&&n.length&&(Q.warn("Unmatched lines:"),n.forEach(function(e){return Q.info(" ".concat(e))}))}y(tl,"parseTextErrors");function tE(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,a=e.line,o=e.column,s=e.ruleId,i=e.message;n.push({type:r===2?Y.Error:Y.Warning,file:t,position:"".concat(a,":").concat(o),rule:s,message:i})})}),n.length&&ti(n)}catch(t){tl(e)}}y(tE,"parseCommandOutput");function td(e){return a(function(e){var t,n,r,a,o,s,i,c,u;var l=arguments;return p(this,function(E){switch(E.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:tE;n=new AbortController;_.default.on("SIGINT",function(){Q.warn("Process interrupted. Terminating..."),n.abort(),_.default.exit()});E.label=1;case 1:E.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,to(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=E.sent(),a=r.stdout,o=r.stderr;[a,o].forEach(function(e){return e&&t(e)});E.label=3;case 3:return[3,5];case 4:s=E.sent();i=s.stdout,c=s.stderr,u=s.message;[i,c].forEach(function(e){return e&&t(e)}),!c&&!i&&Q.error("Command failed: ".concat(u));return[3,5];case 5:return[2]}})}).apply(this,arguments)}y(td,"executeCommand");function tf(e){return{raw:!0,cmd:e}}y(tf,"rawCommand");function tp(e,t){return(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(eQ," ").concat(eq," ").concat(eP," ").concat(e):"".concat(eQ," ").concat(eG," ").concat(e)}y(tp,"formatCLI");function tm(e,t){return typeof e=="function"?tp(e(t),t):(typeof e==="undefined"?"undefined":d(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?tp(e,t):e}y(tm,"formatCommand");function tS(e){return a(function(){var t,n,r;return p(this,function(a){switch(a.label){case 0:return[4,e7({name:eD})];case 1:t=a.sent();if(t.success){n={isCurrentProject:t.result.isCurrentProject},r=typeof e=="function"?e(n):e;return[2,Object.fromEntries(Object.entries(r).map(function(e){var t=l(e,2),r=t[0],a=t[1];return[r,tm(a,n)]}))]}return[2]}})})()}y(tS,"resolveCommands");function tD(e,t){return a(function(){var n;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);Q.start("".concat(e)),ta.DEBUG&&Q.info("→ ".concat(t));return[4,td(t)];case 1:r.sent(),Q.success("".concat(e," done."));return[3,3];case 2:n=r.sent();H(n);return[3,3];case 3:return[2]}})})()}y(tD,"runCommand");0&&(module.exports={clearAllErrorLists:clearAllErrorLists,formatCommand:formatCommand,getStoredErrorLists:getStoredErrorLists,rawCommand:rawCommand,resolveCommands:resolveCommands,runCommand:runCommand});
@@ -1 +1 @@
1
- function e(e,n){if(n==null||n>e.length)n=e.length;for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function n(e){if(Array.isArray(e))return e}function t(n){if(Array.isArray(n))return e(n)}function r(e,n,t,r,a,o,s){try{var i=e[o](s);var c=i.value}catch(e){t(e);return}if(i.done){n(c)}else{Promise.resolve(c).then(r,a)}}function a(e){return function(){var n=this,t=arguments;return new Promise(function(a,o){var s=e.apply(n,t);function i(e){r(s,a,o,i,c,"next",e)}function c(e){r(s,a,o,i,c,"throw",e)}i(undefined)})}}function o(e,n){if(n!=null&&typeof Symbol!=="undefined"&&n[Symbol.hasInstance]){return!!n[Symbol.hasInstance](e)}else{return e instanceof n}}function s(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function i(e,n){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var r=[];var a=true;var o=false;var s,i;try{for(t=t.call(e);!(a=(s=t.next()).done);a=true){r.push(s.value);if(n&&r.length===n)break}}catch(e){o=true;i=e}finally{try{if(!a&&t["return"]!=null)t["return"]()}finally{if(o)throw i}}return r}function c(){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 u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e,t){return n(e)||i(e,t)||f(e,t)||c()}function E(e){return t(e)||s(e)||f(e)||u()}function d(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function f(n,t){if(!n)return;if(typeof n==="string")return e(n,t);var r=Object.prototype.toString.call(n).slice(8,-1);if(r==="Object"&&n.constructor)r=n.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(n,t)}function p(e,n){var t,r,a,o={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=i(0),s["throw"]=i(1),s["return"]=i(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function i(e){return function(n){return c([e,n])}}function c(i){if(t)throw new TypeError("Generator is already executing.");while(s&&(s=0,i[0]&&(o=0)),o)try{if(t=1,r&&(a=i[0]&2?r["return"]:i[0]?r["throw"]||((a=r["return"])&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;if(r=0,a)i=[i[0]&2,a.value];switch(i[0]){case 0:case 1:a=i;break;case 4:o.label++;return{value:i[1],done:false};case 5:o.label++;r=i[1];i=[0];continue;case 7:i=o.ops.pop();o.trys.pop();continue;default:if(!(a=o.trys,a=a.length>0&&a[a.length-1])&&(i[0]===6||i[0]===2)){o=0;continue}if(i[0]===3&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(i[0]===6&&o.label<a[1]){o.label=a[1];a=i;break}if(a&&o.label<a[2]){o.label=a[2];o.ops.push(i);break}if(a[2])o.ops.pop();o.trys.pop();continue}i=n.call(e,o)}catch(e){i=[6,e];r=0}finally{t=a=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}}var m=Object.defineProperty;var S=function(e,n){return m(e,"name",{value:n,configurable:!0})};import{exec as D}from"node:child_process";import O from"node:process";import*as C from"node:util";var y=".cyberskill-storage";import v from"@dotenvx/dotenvx";import{bool as I,cleanEnv as h,str as T}from"envalid";import N from"node:os";import A from"node:path";import _ from"node:process";var g=!1;function R(){g||(v.config(),g=!0)}S(R,"loadEnvFile");function G(){R();var e=h(_.env,{CWD:T({default:_.cwd()}),DEBUG:I({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:T({default:A.join(N.homedir(),y)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}S(G,"getEnv");var P=function(e){return e.Error="error",e.Warning="warning",e}({});import M from"chalk";import L from"consola";import{GraphQLError as b}from"graphql";var U={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};var w=G();w.DEBUG||(L.level=4);function k(e){var n=M[e];return typeof n=="function"?n:M.green}S(k,"chalkKeyword");var F={silent:L.silent,level:L.level,fatal:L.fatal,error:L.error,warn:L.warn,log:L.log,info:L.info,success:L.success,ready:L.ready,start:L.start,box:L.box,debug:L.debug,trace:L.trace,verbose:L.verbose,printBoxedLog:function e(e,n){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(n===null||n===void 0?void 0:n.length)){L.box(M.green(e));return}n.forEach(function(e){var n=e.file,r=e.position,a=e.rule,o=e.message;L.log("".concat(M.gray("File:")," ").concat(M.blue("".concat(n).concat(r?":".concat(r):"")))),a&&L.log(" ".concat(k(t)("Rule:")," ").concat(a)),L.log(" ".concat(k(t)("Message:")," ").concat(o))}),L.box(k(t)("".concat(e," : ").concat(n.length))),L.log(M.gray("─".repeat(40)))}};function Y(e,n){var t=n!==null&&n!==void 0?n:{},r=t.shouldLog,a=r===void 0?!0:r,s=t.returnValue,i=t.callback,c=o(e,Error)?e:new Error(typeof e=="string"?e:"Unknown error");return a&&F.error(c.message),i&&typeof i=="function"&&i(c),s||{success:!1,message:c.message,code:U.INTERNAL_SERVER_ERROR.CODE}}S(Y,"catchError");var V=function(e){return e.DEPENDENCY="dependencies",e.DEV_DEPENDENCY="devDependencies",e.PEER_DEPENDENCY="peerDependencies",e.BUNDLE_DEPENDENCY="bundleDependencies",e.OPTIONAL_DEPENDENCY="optionalDependencies",e}({});import x from"node-fetch";var j=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});import K from"fs-extra";var Q=K.lstatSync,B=K.readdirSync,H=K.mkdirSync,q=K.readFileSync,W=K.unlinkSync,J=K.statSync,$=K.readJsonSync;function z(e,n,t){K.writeFileSync(e,n,t!==null&&t!==void 0?t:"utf-8")}S(z,"writeFileSync");function X(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++){n[t]=arguments[t]}return n.every(function(e){return K.pathExistsSync(e)})}S(X,"pathExistsSync");import Z from"fs-extra";import ee from"node:path";var en=G(),et=ee;function er(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++){n[t]=arguments[t]}var r;return(r=et).resolve.apply(r,[en.CWD].concat(E(n)))}S(er,"resolveWorkingPath");function ea(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++){n[t]=arguments[t]}var r;return(r=et).join.apply(r,E(n))}S(ea,"join");var eo=G(),es=eo.CWD,ei="@cyberskill/shared",ec="node_modules",eu="dist",el="package.json",eE="package-lock.json",ed="tsconfig.json",ef=".gitignore",ep=".simple-git-hooks.json",em="pnpm-lock.yaml",eS=".git/hooks/",eD=".git/COMMIT_EDITMSG",eO=".migrate-mongo.config.js",eC=function(){var e=Z.readJsonSync(er(el)).name===ei?es:ea(es,ec,ei);return ea(e,eu)}(),ey="cyberskill",ev="src/node/cli/index.ts",eI="eslint",eh="eslint",eT="vitest";var eN="vitest",eA="@commitlint/cli",e_="@commitlint/config-conventional",eg="commitlint",eR="lint-staged",eG="lint-staged",eP="typescript",eM="tsc",eL="tsx",eb="git",eU="pnpm",ew="pnpm exec",ek="simple-git-hooks",eF="simple-git-hooks",eY="@eslint/config-inspector",eV="eslint-config-inspector",ex="node-modules-inspector",ej="node-modules-inspector",eK="migrate-mongo",eQ="./node_modules/migrate-mongo/bin/migrate-mongo",eB={CYBERSKILL_DIRECTORY:eC,WORKING_DIRECTORY:es,TS_CONFIG:er(ed),GIT_IGNORE:er(ef),GIT_HOOK:er(eS),GIT_COMMIT_MSG:er(eD),SIMPLE_GIT_HOOKS_JSON:er(ep),PACKAGE_JSON:er(el),PACKAGE_LOCK_JSON:er(eE),PNPM_LOCK_YAML:er(em),NODE_MODULES:er(ec),MIGRATE_MONGO_CONFIG:er(eO),LINT_STAGED_CONFIG:er("".concat(eC,"/config/lint-staged/index.js")),COMMITLINT_CONFIG:er("".concat(eC,"/config/commitlint/index.js")),UNIT_TEST_CONFIG:er("".concat(eC,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:er("".concat(eC,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:er("".concat(eC,"/react/vitest/vitest.e2e.js"))};function eH(e){var n=e.type,t=e.packages,r=e.command;var o=t===null||t===void 0?void 0:t.reduce(function(e,n){return e.some(function(e){return e.name===n.name})||e.push(n),e},[]);return function(){return a(function(){var e;return p(this,function(t){switch(t.label){case 0:switch(n){case j.CLI:return[3,1];case j.STRING:return[3,4]}return[3,5];case 1:e=o===null||o===void 0?void 0:o.length;if(!e)return[3,3];return[4,eZ(o,{update:!0})];case 2:e=t.sent();t.label=3;case 3:return[2,(e,no(nr("".concat(ew," ").concat(r))))];case 4:return[2,no(nr(r))];case 5:throw new Error("Unsupported command type");case 6:return[2]}})})()}}S(eH,"buildCommand");var eq={simpleGitHooks:eH({type:j.CLI,packages:[{name:ek,type:V.DEV_DEPENDENCY}],command:eF}),eslintInspect:eH({type:j.CLI,packages:[{name:eY,type:V.DEV_DEPENDENCY}],command:eV}),nodeModulesInspect:eH({type:j.CLI,packages:[{name:ex,type:V.DEV_DEPENDENCY}],command:ej}),eslintCheck:eH({type:j.CLI,packages:[{name:eI,type:V.DEV_DEPENDENCY}],command:"".concat(eh," ").concat(eB.WORKING_DIRECTORY," --no-cache")}),eslintFix:eH({type:j.CLI,packages:[{name:eI,type:V.DEV_DEPENDENCY}],command:"".concat(eh," ").concat(eB.WORKING_DIRECTORY," --fix --no-cache")}),typescriptCheck:eH({type:j.CLI,packages:[{name:eP,type:V.DEPENDENCY}],command:"".concat(eM," -p ").concat(eB.TS_CONFIG," --noEmit")}),testUnit:eH({type:j.CLI,packages:[{name:eT,type:V.DEV_DEPENDENCY}],command:"".concat(eN," --config ").concat(eB.UNIT_TEST_CONFIG)}),testE2e:eH({type:j.CLI,packages:[{name:eT,type:V.DEV_DEPENDENCY}],command:"".concat(eN," --config ").concat(eB.E2E_TEST_CONFIG)}),mongoMigrateCreate:S(function(e){return eH({type:j.CLI,packages:[{name:eK,type:V.DEPENDENCY}],command:"".concat(eL," ").concat(eQ," create ").concat(e," -f ").concat(eB.MIGRATE_MONGO_CONFIG)})()},"mongoMigrateCreate"),mongoMigrateUp:eH({type:j.CLI,packages:[{name:eK,type:V.DEPENDENCY}],command:"".concat(eL," ").concat(eQ," up -f ").concat(eB.MIGRATE_MONGO_CONFIG)}),mongoMigrateDown:eH({type:j.CLI,packages:[{name:eK,type:V.DEPENDENCY}],command:"".concat(eL," ").concat(eQ," down -f ").concat(eB.MIGRATE_MONGO_CONFIG)}),commitLint:eH({type:j.CLI,packages:[{name:eA,type:V.DEV_DEPENDENCY},{name:e_,type:V.DEV_DEPENDENCY}],command:"".concat(eg," --edit ").concat(eB.GIT_COMMIT_MSG," --config ").concat(eB.COMMITLINT_CONFIG)}),lintStaged:eH({type:j.CLI,packages:[{name:eR,type:V.DEV_DEPENDENCY}],command:"".concat(eG," --config ").concat(eB.LINT_STAGED_CONFIG)}),configureGitHook:eH({type:j.STRING,command:"".concat(eb," config core.hooksPath ").concat(eB.GIT_HOOK)}),build:eH({type:j.STRING,command:"".concat(eU," run --if-present build")}),pnpmInstallStandard:eH({type:j.STRING,command:"".concat(eU," install --ignore-scripts --no-frozen-lockfile")}),pnpmInstallLegacy:eH({type:j.STRING,command:"".concat(eU," install --ignore-scripts --no-frozen-lockfile --legacy-peer-deps")}),pnpmInstallForce:eH({type:j.STRING,command:"".concat(eU," install --ignore-scripts --no-frozen-lockfile --force")})};var eW=G();function eJ(e){return a(function(){var n,t,r,a;return p(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,x("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:n=o.sent();if(!n.ok)throw new Error("Failed to fetch latest version: ".concat(n.status," ").concat(n.statusText));return[4,n.json()];case 2:t=o.sent(),r=t.version;return[2,{success:!0,result:r}];case 3:a=o.sent();return[2,Y(a)];case 4:return[2]}})})()}S(eJ,"getLatestPackageVersion");function e$(e){return a(function(){var n,t,r,a,o,s,i,c,u,l,E,d,f,m,S,D,O,C,y,v,I,h,T,N;return p(this,function(p){switch(p.label){case 0:p.trys.push([0,2,,3]);if(!e){if(X(eB.PACKAGE_JSON)){n=$(eB.PACKAGE_JSON),t=n.name,r=t===void 0?"":t,a=n.version,o=a===void 0?"":a;return[2,{success:!0,result:{name:r,currentVersion:o,latestVersion:o,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:!1,isDevDependency:!1,installedPath:eB.PACKAGE_JSON,file:n}}]}return[2,{success:!0,result:{name:"",currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:!1,isDevDependency:!1,installedPath:"",file:{}}}]}if(!X(eB.PACKAGE_JSON))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===V.DEPENDENCY,isDevDependency:e.type===V.DEV_DEPENDENCY,installedPath:"",file:{}}}];s=$(eB.PACKAGE_JSON),i=s.name,c=s.version,u=c===void 0?"":c,l=s.dependencies,E=l===void 0?{}:l,d=s.devDependencies,f=d===void 0?{}:d;if(e.name===i)return[2,{success:!0,result:{name:i,currentVersion:u,latestVersion:u,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:e.type===V.DEPENDENCY,isDevDependency:e.type===V.DEV_DEPENDENCY,installedPath:eB.PACKAGE_JSON,file:s}}];m=e.name in E,S=e.name in f;return[4,eJ(e.name)];case 1:D=p.sent();if(!D.success)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:"",file:{}}}];if(!m&&!S)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:D.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===V.DEPENDENCY,isDevDependency:e.type===V.DEV_DEPENDENCY,installedPath:"",file:{}}}];y=(C=(O=E[e.name])!==null&&O!==void 0?O:f[e.name])!==null&&C!==void 0?C:"",v=ea(eW.CWD,ec,e.name,el);if(!X(v))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:D.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:"",file:{}}}];I=$(v),h=I.version,T=h===void 0?"":h;return[2,y!==T?{success:!0,result:{name:e.name,currentVersion:T||y,latestVersion:D.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:v,file:I}}:{success:!0,result:{name:e.name,currentVersion:y,latestVersion:D.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:y===D.result,isDependency:m,isDevDependency:S,installedPath:v,file:I}}];case 2:N=p.sent();return[2,Y(N)];case 3:return[2]}})})()}S(e$,"getPackage");function ez(e){return a(function(){var n,t,r,a,o;return p(this,function(s){try{;r=$(eB.PACKAGE_JSON),a=(n=r.dependencies)!==null&&n!==void 0?n:{},o=(t=r.devDependencies)!==null&&t!==void 0?t:{};e.isDependency?a[e.name]=e.latestVersion:e.isDevDependency&&(o[e.name]=e.latestVersion),z(eB.PACKAGE_JSON,JSON.stringify(r,null,4)),F.info('Updated "'.concat(e.name,'" to version ').concat(e.latestVersion))}catch(e){Y(e)}return[2]})})()}S(ez,"updatePackage");function eX(){return a(function(){var e,n,t,r,a,o,s,i,c,u,l,E,d;return p(this,function(f){switch(f.label){case 0:f.trys.push([0,12,,13]);e=[{command:S(function(){return eq.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:S(function(){return eq.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:S(function(){return eq.pnpmInstallForce()},"command"),message:"Retrying with force install"}];n=true,t=false,r=undefined;f.label=1;case 1:f.trys.push([1,9,10,11]);a=e[Symbol.iterator]();f.label=2;case 2:if(!!(n=(o=a.next()).done))return[3,8];s=o.value,i=s.command,c=s.message;f.label=3;case 3:f.trys.push([3,6,,7]);return[4,i()];case 4:u=f.sent();return[4,ni("".concat(c," using: ").concat(u),u)];case 5:f.sent();return[2];case 6:l=f.sent();Y(l);return[3,7];case 7:n=true;return[3,2];case 8:return[3,11];case 9:E=f.sent();t=true;r=E;return[3,11];case 10:try{if(!n&&a.return!=null){a.return()}}finally{if(t){throw r}}return[7];case 11:return[3,13];case 12:d=f.sent();Y(d);return[3,13];case 13:return[2]}})})()}S(eX,"installDependencies");function eZ(e,n){return a(function(){var t,r,a,o,s,i,c,u,l,E,d,f;return p(this,function(p){switch(p.label){case 0:if(!X(eB.PACKAGE_JSON)){F.error("package.json not found. Aborting setup.");return[2]}p.label=1;case 1:p.trys.push([1,16,,17]);return[4,Promise.all(e.map(e$))];case 2:t=p.sent().filter(function(e){return e.success?!e.result.isCurrentProject&&(!e.result.isInstalled||!e.result.isUpToDate):!1});r=t.length>0;if(!r)return[3,7];return[4,Promise.all(t.map(function(e){return e.success?ez(e.result):Promise.resolve()}))];case 3:p.sent();return[4,eX()];case 4:p.sent();a=["Running ESLint with auto-fix"];return[4,eq.eslintFix()];case 5:return[4,ni.apply(void 0,a.concat([p.sent()]))];case 6:r=p.sent();p.label=7;case 7:r;s=true,i=false,c=undefined;p.label=8;case 8:p.trys.push([8,13,14,15]);u=((o=n===null||n===void 0?void 0:n.postInstallActions)!==null&&o!==void 0?o:[])[Symbol.iterator]();p.label=9;case 9:if(!!(s=(l=u.next()).done))return[3,12];E=l.value;return[4,E()];case 10:p.sent();p.label=11;case 11:s=true;return[3,9];case 12:return[3,15];case 13:d=p.sent();i=true;c=d;return[3,15];case 14:try{if(!s&&u.return!=null){u.return()}}finally{if(i){throw c}}return[7];case 15:return[3,17];case 16:f=p.sent();Y(f);return[3,17];case 17:return[2]}})})()}S(eZ,"setupPackages");import e0 from"node-persist";var e1=G();function e2(){return a(function(){var e;return p(this,function(n){switch(n.label){case 0:e=e0.defaultInstance;if(e)return[3,2];return[4,e0.init({dir:e1.CYBERSKILL_STORAGE_DIRECTORY})];case 1:e=n.sent();n.label=2;case 2:e;return[2]}})})()}S(e2,"initNodePersist");var e4={get:function e(e){return a(function(){var n,t;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,e2()];case 1:r.sent();return[4,e0.getItem(e)];case 2:return[2,(n=r.sent())!==null&&n!==void 0?n:null];case 3:t=r.sent();return[2,Y(t,{returnValue:null})];case 4:return[2]}})})()},set:function e(e,n){return a(function(){var t;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,e2()];case 1:r.sent();return[4,e0.setItem(e,n)];case 2:r.sent();return[3,4];case 3:t=r.sent();Y(t);return[3,4];case 4:return[2]}})})()},remove:function e(e){return a(function(){var n;return p(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,e2()];case 1:t.sent();return[4,e0.removeItem(e)];case 2:t.sent();return[3,4];case 3:n=t.sent();Y(n);return[3,4];case 4:return[2]}})})()},keys:function e(){return a(function(){var e,n;return p(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,e2()];case 1:t.sent();return[4,e0.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(F.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:n=t.sent();return[2,Y(n,{returnValue:[]})];case 4:return[2]}})})()},getLogLink:function e(e){return a(function(){return p(this,function(n){try{return[2,"".concat(e1.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,Y(e,{returnValue:null})]}return[2]})})()}};var e3=G(),e5=C.promisify(D);function e7(){return a(function(){var e;return p(this,function(n){switch(n.label){case 0:return[4,e$()];case 1:e=n.sent();return[2,e.success?e.result.name:Date.now().toString()]}})})()}S(e7,"getPackageName");function e6(e){return a(function(){var n,t;return p(this,function(r){switch(r.label){case 0:if(e.length===0)return[2];return[4,e7()];case 1:n=r.sent();r.label=2;case 2:r.trys.push([2,4,,5]);return[4,e4.set(n,e)];case 3:r.sent(),setTimeout(function(){return a(function(){var e;return p(this,function(t){switch(t.label){case 0:return[4,e4.getLogLink(n)];case 1:e=t.sent();e&&F.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},0);return[3,5];case 4:t=r.sent();Y(t);return[3,5];case 5:return[2]}})})()}S(e6,"saveErrorListToStorage");function e8(){return a(function(){var e,n,t;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,e7()];case 1:e=r.sent();return[4,e4.get(e)];case 2:return[2,(n=r.sent())!==null&&n!==void 0?n:[]];case 3:t=r.sent();return[2,Y(t,{returnValue:[]})];case 4:return[2]}})})()}S(e8,"getStoredErrorLists");function e9(){return a(function(){var e,n;return p(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,e7()];case 1:e=t.sent();return[4,e4.remove(e)];case 2:t.sent();return[3,4];case 3:n=t.sent();Y(n);return[3,4];case 4:return[2]}})})()}S(e9,"clearAllErrorLists");function ne(e){var n=[],t=[],r="",a=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,o=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,s=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var i,c,u,l,E;var d=a.exec(e)||[],f=o.exec(e)||[],p=s.exec(e)||[];var m,S,D,O,C,y;d.length&&r?n.push({file:r,position:"".concat(d[1],":").concat(d[2]),type:d[3]===P.Error?P.Error:P.Warning,message:(m=d===null||d===void 0?void 0:(i=d[4])===null||i===void 0?void 0:i.trim())!==null&&m!==void 0?m:"",rule:(S=d===null||d===void 0?void 0:(c=d[5])===null||c===void 0?void 0:c.trim())!==null&&S!==void 0?S:""}):f.length?n.push({file:(D=f===null||f===void 0?void 0:f[1])!==null&&D!==void 0?D:"",position:"".concat(f[2],":").concat(f[3]),type:f[4]===P.Error?P.Error:P.Warning,message:(O=f===null||f===void 0?void 0:(u=f[5])===null||u===void 0?void 0:u.trim())!==null&&O!==void 0?O:""}):p.length?n.push({file:"commitlint",type:P.Error,message:(C=p===null||p===void 0?void 0:(l=p[1])===null||l===void 0?void 0:l.trim())!==null&&C!==void 0?C:"",rule:(y=p===null||p===void 0?void 0:(E=p[2])===null||E===void 0?void 0:E.trim())!==null&&y!==void 0?y:""}):t.push(e.trim())}}),n.length&&e6(n),e3.DEBUG&&t.length&&(F.warn("Unmatched lines:"),t.forEach(function(e){return F.info(" ".concat(e))}))}S(ne,"parseTextErrors");function nn(e){try{var n=JSON.parse(e),t=[];n.forEach(function(e){var n=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,a=e.line,o=e.column,s=e.ruleId,i=e.message;t.push({type:r===2?P.Error:P.Warning,file:n,position:"".concat(a,":").concat(o),rule:s,message:i})})}),t.length&&e6(t)}catch(n){ne(e)}}S(nn,"parseCommandOutput");function nt(e){return a(function(e){var n,t,r,a,o,s,i,c,u;var l=arguments;return p(this,function(E){switch(E.label){case 0:n=l.length>1&&l[1]!==void 0?l[1]:nn;t=new AbortController;O.on("SIGINT",function(){F.warn("Process interrupted. Terminating..."),t.abort(),O.exit()});E.label=1;case 1:E.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,e5(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:r=E.sent(),a=r.stdout,o=r.stderr;[a,o].forEach(function(e){return e&&n(e)});E.label=3;case 3:return[3,5];case 4:s=E.sent();i=s.stdout,c=s.stderr,u=s.message;[i,c].forEach(function(e){return e&&n(e)}),!c&&!i&&F.error("Command failed: ".concat(u));return[3,5];case 5:return[2]}})}).apply(this,arguments)}S(nt,"executeCommand");function nr(e){return{raw:!0,cmd:e}}S(nr,"rawCommand");function na(e,n){return(n===null||n===void 0?void 0:n.isCurrentProject)?"".concat(ew," ").concat(eL," ").concat(ev," ").concat(e):"".concat(ew," ").concat(ey," ").concat(e)}S(na,"formatCLI");function no(e,n){return typeof e=="function"?na(e(n),n):(typeof e==="undefined"?"undefined":d(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?na(e,n):e}S(no,"formatCommand");function ns(e){return a(function(){var n,t,r;return p(this,function(a){switch(a.label){case 0:return[4,e$({name:ei})];case 1:n=a.sent();if(n.success){t={isCurrentProject:n.result.isCurrentProject},r=typeof e=="function"?e(t):e;return[2,Object.fromEntries(Object.entries(r).map(function(e){var n=l(e,2),r=n[0],a=n[1];return[r,no(a,t)]}))]}return[2]}})})()}S(ns,"resolveCommands");function ni(e,n){return a(function(){var t;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);F.start("".concat(e)),e3.DEBUG&&F.info("→ ".concat(n));return[4,nt(n)];case 1:r.sent(),F.success("".concat(e," done."));return[3,3];case 2:t=r.sent();Y(t);return[3,3];case 3:return[2]}})})()}S(ni,"runCommand");export{e9 as clearAllErrorLists,no as formatCommand,e8 as getStoredErrorLists,nr as rawCommand,ns as resolveCommands,ni as runCommand};
1
+ function e(e,n){if(n==null||n>e.length)n=e.length;for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function n(e){if(Array.isArray(e))return e}function t(n){if(Array.isArray(n))return e(n)}function r(e,n,t,r,a,o,s){try{var i=e[o](s);var c=i.value}catch(e){t(e);return}if(i.done){n(c)}else{Promise.resolve(c).then(r,a)}}function a(e){return function(){var n=this,t=arguments;return new Promise(function(a,o){var s=e.apply(n,t);function i(e){r(s,a,o,i,c,"next",e)}function c(e){r(s,a,o,i,c,"throw",e)}i(undefined)})}}function o(e,n){if(n!=null&&typeof Symbol!=="undefined"&&n[Symbol.hasInstance]){return!!n[Symbol.hasInstance](e)}else{return e instanceof n}}function s(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function i(e,n){var t=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t==null)return;var r=[];var a=true;var o=false;var s,i;try{for(t=t.call(e);!(a=(s=t.next()).done);a=true){r.push(s.value);if(n&&r.length===n)break}}catch(e){o=true;i=e}finally{try{if(!a&&t["return"]!=null)t["return"]()}finally{if(o)throw i}}return r}function c(){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 u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e,t){return n(e)||i(e,t)||f(e,t)||c()}function E(e){return t(e)||s(e)||f(e)||u()}function d(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function f(n,t){if(!n)return;if(typeof n==="string")return e(n,t);var r=Object.prototype.toString.call(n).slice(8,-1);if(r==="Object"&&n.constructor)r=n.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(n,t)}function p(e,n){var t,r,a,o={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=i(0),s["throw"]=i(1),s["return"]=i(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function i(e){return function(n){return c([e,n])}}function c(i){if(t)throw new TypeError("Generator is already executing.");while(s&&(s=0,i[0]&&(o=0)),o)try{if(t=1,r&&(a=i[0]&2?r["return"]:i[0]?r["throw"]||((a=r["return"])&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;if(r=0,a)i=[i[0]&2,a.value];switch(i[0]){case 0:case 1:a=i;break;case 4:o.label++;return{value:i[1],done:false};case 5:o.label++;r=i[1];i=[0];continue;case 7:i=o.ops.pop();o.trys.pop();continue;default:if(!(a=o.trys,a=a.length>0&&a[a.length-1])&&(i[0]===6||i[0]===2)){o=0;continue}if(i[0]===3&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(i[0]===6&&o.label<a[1]){o.label=a[1];a=i;break}if(a&&o.label<a[2]){o.label=a[2];o.ops.push(i);break}if(a[2])o.ops.pop();o.trys.pop();continue}i=n.call(e,o)}catch(e){i=[6,e];r=0}finally{t=a=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}}var m=Object.defineProperty;var S=function(e,n){return m(e,"name",{value:n,configurable:!0})};import{exec as D}from"node:child_process";import O from"node:process";import*as C from"node:util";var y=".cyberskill-storage";import v from"@dotenvx/dotenvx";import{bool as I,cleanEnv as h,str as T}from"envalid";import N from"node:os";import A from"node:path";import _ from"node:process";var g=!1;function R(){g||(v.config(),g=!0)}S(R,"loadEnvFile");function G(){R();var e=h(_.env,{CWD:T({default:_.cwd()}),DEBUG:I({default:!1}),CYBERSKILL_STORAGE_DIRECTORY:T({default:A.join(N.homedir(),y)})});return{CWD:e.CWD,DEBUG:e.DEBUG,CYBERSKILL_STORAGE_DIRECTORY:e.CYBERSKILL_STORAGE_DIRECTORY}}S(G,"getEnv");var P=function(e){return e.Error="error",e.Warning="warning",e}({});import M from"chalk";import L from"consola";import{GraphQLError as b}from"graphql";var U={GRAPHQL_PARSE_FAILED:{CODE:"GRAPHQL_PARSE_FAILED",MESSAGE:"The GraphQL operation string contains a syntax error."},GRAPHQL_VALIDATION_FAILED:{CODE:"GRAPHQL_VALIDATION_FAILED",MESSAGE:"The GraphQL operation is not valid against the server's schema."},BAD_USER_INPUT:{CODE:"BAD_USER_INPUT",MESSAGE:"The GraphQL operation includes an invalid value for a field argument."},PERSISTED_QUERY_NOT_FOUND:{CODE:"PERSISTED_QUERY_NOT_FOUND",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ cache."},PERSISTED_QUERY_NOT_SUPPORTED:{CODE:"PERSISTED_QUERY_NOT_SUPPORTED",MESSAGE:"A client sent the hash of a query string to execute via automatic persisted queries, but the server has disabled APQ."},OPERATION_RESOLUTION_FAILURE:{CODE:"OPERATION_RESOLUTION_FAILURE",MESSAGE:"The request was parsed successfully and is valid against the server's schema, but the server couldn't resolve which operation to run. This occurs when a request containing multiple named operations doesn't specify which operation to run (i.e.,operationName), or if the named operation isn't included in the request."},CONTINUE:{CODE:100,MESSAGE:"Continue"},SWITCHING_PROTOCOLS:{CODE:101,MESSAGE:"Switching Protocols"},PROCESSING:{CODE:102,MESSAGE:"Processing"},OK:{CODE:200,MESSAGE:"OK"},CREATED:{CODE:201,MESSAGE:"Created"},ACCEPTED:{CODE:202,MESSAGE:"Accepted"},NON_AUTHORITATIVE_INFORMATION:{CODE:203,MESSAGE:"Non Authoritative Information"},NO_CONTENT:{CODE:204,MESSAGE:"No Content"},RESET_CONTENT:{CODE:205,MESSAGE:"Reset Content"},PARTIAL_CONTENT:{CODE:206,MESSAGE:"Partial Content"},MULTI_STATUS:{CODE:207,MESSAGE:"Multi-Status"},MULTIPLE_CHOICES:{CODE:300,MESSAGE:"Multiple Choices"},MOVED_PERMANENTLY:{CODE:301,MESSAGE:"Moved Permanently"},MOVED_TEMPORARILY:{CODE:302,MESSAGE:"Moved Temporarily"},SEE_OTHER:{CODE:303,MESSAGE:"See Other"},NOT_MODIFIED:{CODE:304,MESSAGE:"Not Modified"},USE_PROXY:{CODE:305,MESSAGE:"Use Proxy"},TEMPORARY_REDIRECT:{CODE:307,MESSAGE:"Temporary Redirect"},PERMANENT_REDIRECT:{CODE:308,MESSAGE:"Permanent Redirect"},BAD_REQUEST:{CODE:400,MESSAGE:"Bad Request"},UNAUTHORIZED:{CODE:401,MESSAGE:"Unauthorized"},PAYMENT_REQUIRED:{CODE:402,MESSAGE:"Payment Required"},FORBIDDEN:{CODE:403,MESSAGE:"Forbidden"},NOT_FOUND:{CODE:404,MESSAGE:"Not Found"},METHOD_NOT_ALLOWED:{CODE:405,MESSAGE:"Method Not Allowed"},NOT_ACCEPTABLE:{CODE:406,MESSAGE:"Not Acceptable"},PROXY_AUTHENTICATION_REQUIRED:{CODE:407,MESSAGE:"Proxy Authentication Required"},REQUEST_TIMEOUT:{CODE:408,MESSAGE:"Request Timeout"},CONFLICT:{CODE:409,MESSAGE:"Conflict"},GONE:{CODE:410,MESSAGE:"Gone"},LENGTH_REQUIRED:{CODE:411,MESSAGE:"Length Required"},PRECONDITION_FAILED:{CODE:412,MESSAGE:"Precondition Failed"},REQUEST_TOO_LONG:{CODE:413,MESSAGE:"Request Entity Too Large"},REQUEST_URI_TOO_LONG:{CODE:414,MESSAGE:"Request-URI Too Long"},UNSUPPORTED_MEDIA_TYPE:{CODE:415,MESSAGE:"Unsupported Media Type"},REQUESTED_RANGE_NOT_SATISFIABLE:{CODE:416,MESSAGE:"Requested Range Not Satisfiable"},EXPECTATION_FAILED:{CODE:417,MESSAGE:"Expectation Failed"},IM_A_TEAPOT:{CODE:418,MESSAGE:"I'm a teapot"},INSUFFICIENT_SPACE_ON_RESOURCE:{CODE:419,MESSAGE:"Insufficient Space on Resource"},METHOD_FAILURE:{CODE:420,MESSAGE:"Method Failure"},MISDIRECTED_REQUEST:{CODE:421,MESSAGE:"Misdirected Request"},UNPROCESSABLE_ENTITY:{CODE:422,MESSAGE:"Unprocessable Entity"},LOCKED:{CODE:423,MESSAGE:"Locked"},FAILED_DEPENDENCY:{CODE:424,MESSAGE:"Failed Dependency"},PRECONDITION_REQUIRED:{CODE:428,MESSAGE:"Precondition Required"},TOO_MANY_REQUESTS:{CODE:429,MESSAGE:"Too Many Requests"},REQUEST_HEADER_FIELDS_TOO_LARGE:{CODE:431,MESSAGE:"Request Header Fields Too Large"},UNAVAILABLE_FOR_LEGAL_REASONS:{CODE:451,MESSAGE:"Unavailable For Legal Reasons"},INTERNAL_SERVER_ERROR:{CODE:500,MESSAGE:"Internal Server Error"},NOT_IMPLEMENTED:{CODE:501,MESSAGE:"Not Implemented"},BAD_GATEWAY:{CODE:502,MESSAGE:"Bad Gateway"},SERVICE_UNAVAILABLE:{CODE:503,MESSAGE:"Service Unavailable"},GATEWAY_TIMEOUT:{CODE:504,MESSAGE:"Gateway Timeout"},HTTP_VERSION_NOT_SUPPORTED:{CODE:505,MESSAGE:"HTTP Version Not Supported"},INSUFFICIENT_STORAGE:{CODE:507,MESSAGE:"Insufficient Storage"},NETWORK_AUTHENTICATION_REQUIRED:{CODE:511,MESSAGE:"Network Authentication Required"}};var w=G();w.DEBUG||(L.level=4);function k(e){var n=M[e];return typeof n=="function"?n:M.green}S(k,"chalkKeyword");var F={silent:L.silent,level:L.level,fatal:L.fatal,error:L.error,warn:L.warn,log:L.log,info:L.info,success:L.success,ready:L.ready,start:L.start,box:L.box,debug:L.debug,trace:L.trace,verbose:L.verbose,printBoxedLog:function e(e,n){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"red";if(!(n===null||n===void 0?void 0:n.length)){L.box(M.green(e));return}n.forEach(function(e){var n=e.file,r=e.position,a=e.rule,o=e.message;L.log("".concat(M.gray("File:")," ").concat(M.blue("".concat(n).concat(r?":".concat(r):"")))),a&&L.log(" ".concat(k(t)("Rule:")," ").concat(a)),L.log(" ".concat(k(t)("Message:")," ").concat(o))}),L.box(k(t)("".concat(e," : ").concat(n.length))),L.log(M.gray("─".repeat(40)))}};function Y(e,n){var t=n!==null&&n!==void 0?n:{},r=t.shouldLog,a=r===void 0?!0:r,s=t.returnValue,i=t.callback,c=o(e,Error)?e:new Error(typeof e=="string"?e:"Unknown error");return a&&F.error(c.message),i&&typeof i=="function"&&i(c),s||{success:!1,message:c.message,code:U.INTERNAL_SERVER_ERROR.CODE}}S(Y,"catchError");var V=function(e){return e.DEPENDENCY="dependencies",e.DEV_DEPENDENCY="devDependencies",e.PEER_DEPENDENCY="peerDependencies",e.BUNDLE_DEPENDENCY="bundleDependencies",e.OPTIONAL_DEPENDENCY="optionalDependencies",e}({});import x from"node-fetch";var j=function(e){return e.CLI="CLI",e.STRING="STRING",e.FUNCTION="FUNCTION",e}({});import K from"fs-extra";var Q=K.lstatSync,B=K.readdirSync,H=K.mkdirSync,q=K.readFileSync,W=K.unlinkSync,J=K.statSync,$=K.readJsonSync;function z(e,n,t){K.writeFileSync(e,n,t!==null&&t!==void 0?t:"utf-8")}S(z,"writeFileSync");function X(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++){n[t]=arguments[t]}return n.every(function(e){return K.pathExistsSync(e)})}S(X,"pathExistsSync");import Z from"fs-extra";import ee from"node:path";var en=G(),et=ee;function er(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++){n[t]=arguments[t]}var r;return(r=et).resolve.apply(r,[en.CWD].concat(E(n)))}S(er,"resolveWorkingPath");function ea(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++){n[t]=arguments[t]}var r;return(r=et).join.apply(r,E(n))}S(ea,"join");var eo=G(),es=eo.CWD,ei="@cyberskill/shared",ec="node_modules",eu="dist",el="package.json",eE="package-lock.json",ed="tsconfig.json",ef=".gitignore",ep=".simple-git-hooks.json",em="pnpm-lock.yaml",eS=".git/hooks/",eD=".git/COMMIT_EDITMSG",eO=".migrate-mongo.config.js",eC=function(){var e=Z.readJsonSync(er(el)).name===ei?es:ea(es,ec,ei);return ea(e,eu)}(),ey="cyberskill",ev="src/node/cli/index.ts",eI="eslint",eh="eslint",eT="vitest";var eN="vitest",eA="@commitlint/cli",e_="@commitlint/config-conventional",eg="commitlint",eR="lint-staged",eG="lint-staged",eP="typescript",eM="tsc",eL="tsx",eb="git",eU="pnpm",ew="pnpm exec",ek="simple-git-hooks",eF="simple-git-hooks",eY="@eslint/config-inspector",eV="eslint-config-inspector",ex="node-modules-inspector",ej="node-modules-inspector",eK="migrate-mongo",eQ="./node_modules/migrate-mongo/bin/migrate-mongo",eB={CYBERSKILL_DIRECTORY:eC,WORKING_DIRECTORY:es,TS_CONFIG:er(ed),GIT_IGNORE:er(ef),GIT_HOOK:er(eS),GIT_COMMIT_MSG:er(eD),SIMPLE_GIT_HOOKS_JSON:er(ep),PACKAGE_JSON:er(el),PACKAGE_LOCK_JSON:er(eE),PNPM_LOCK_YAML:er(em),NODE_MODULES:er(ec),MIGRATE_MONGO_CONFIG:er(eO),LINT_STAGED_CONFIG:er("".concat(eC,"/config/lint-staged/index.js")),COMMITLINT_CONFIG:er("".concat(eC,"/config/commitlint/index.js")),UNIT_TEST_CONFIG:er("".concat(eC,"/react/vitest/vitest.unit.js")),UNIT_TEST_SETUP_CONFIG:er("".concat(eC,"/react/vitest/vitest.unit.setup.js")),E2E_TEST_CONFIG:er("".concat(eC,"/react/vitest/vitest.e2e.js"))};function eH(e){var n=e.type,t=e.packages,r=e.command;var o=t===null||t===void 0?void 0:t.reduce(function(e,n){return e.some(function(e){return e.name===n.name})||e.push(n),e},[]);return function(){return a(function(){var e;return p(this,function(t){switch(t.label){case 0:switch(n){case j.CLI:return[3,1];case j.STRING:return[3,4]}return[3,5];case 1:e=o===null||o===void 0?void 0:o.length;if(!e)return[3,3];return[4,eZ(o,{update:!0})];case 2:e=t.sent();t.label=3;case 3:return[2,(e,no(nr("".concat(ew," ").concat(r))))];case 4:return[2,no(nr(r))];case 5:throw new Error("Unsupported command type");case 6:return[2]}})})()}}S(eH,"buildCommand");var eq={simpleGitHooks:eH({type:j.CLI,packages:[{name:ek,type:V.DEV_DEPENDENCY}],command:eF}),eslintInspect:eH({type:j.CLI,packages:[{name:eY,type:V.DEV_DEPENDENCY}],command:eV}),nodeModulesInspect:eH({type:j.CLI,packages:[{name:ex,type:V.DEV_DEPENDENCY}],command:ej}),eslintCheck:eH({type:j.CLI,packages:[{name:eI,type:V.DEV_DEPENDENCY}],command:"".concat(eh," ").concat(eB.WORKING_DIRECTORY," --no-cache")}),eslintFix:eH({type:j.CLI,packages:[{name:eI,type:V.DEV_DEPENDENCY}],command:"".concat(eh," ").concat(eB.WORKING_DIRECTORY," --fix --no-cache")}),typescriptCheck:eH({type:j.CLI,packages:[{name:eP,type:V.DEPENDENCY}],command:"".concat(eM," -p ").concat(eB.TS_CONFIG," --noEmit")}),testUnit:eH({type:j.CLI,packages:[{name:eT,type:V.DEV_DEPENDENCY}],command:"".concat(eN," --config ").concat(eB.UNIT_TEST_CONFIG)}),testE2e:eH({type:j.CLI,packages:[{name:eT,type:V.DEV_DEPENDENCY}],command:"".concat(eN," --config ").concat(eB.E2E_TEST_CONFIG)}),mongoMigrateCreate:S(function(e){return eH({type:j.CLI,packages:[{name:eK,type:V.DEPENDENCY}],command:"".concat(eL," ").concat(eQ," create ").concat(e," -f ").concat(eB.MIGRATE_MONGO_CONFIG)})()},"mongoMigrateCreate"),mongoMigrateUp:eH({type:j.CLI,packages:[{name:eK,type:V.DEPENDENCY}],command:"".concat(eL," ").concat(eQ," up -f ").concat(eB.MIGRATE_MONGO_CONFIG)}),mongoMigrateDown:eH({type:j.CLI,packages:[{name:eK,type:V.DEPENDENCY}],command:"".concat(eL," ").concat(eQ," down -f ").concat(eB.MIGRATE_MONGO_CONFIG)}),commitLint:eH({type:j.CLI,packages:[{name:eA,type:V.DEV_DEPENDENCY},{name:e_,type:V.DEV_DEPENDENCY}],command:"".concat(eg," --edit ").concat(eB.GIT_COMMIT_MSG," --config ").concat(eB.COMMITLINT_CONFIG)}),lintStaged:eH({type:j.CLI,packages:[{name:eR,type:V.DEV_DEPENDENCY}],command:"".concat(eG," --config ").concat(eB.LINT_STAGED_CONFIG)}),configureGitHook:eH({type:j.STRING,command:"".concat(eb," config core.hooksPath ").concat(eB.GIT_HOOK)}),build:eH({type:j.STRING,command:"".concat(eU," run --if-present build")}),pnpmInstallStandard:eH({type:j.STRING,command:"".concat(eU," install --ignore-scripts --frozen-lockfile")}),pnpmInstallLegacy:eH({type:j.STRING,command:"".concat(eU," install --ignore-scripts --frozen-lockfile --legacy-peer-deps")}),pnpmInstallForce:eH({type:j.STRING,command:"".concat(eU," install --ignore-scripts --frozen-lockfile --force")})};var eW=G();function eJ(e){return a(function(){var n,t,r,a;return p(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);return[4,x("https://registry.npmjs.org/".concat(e,"/latest"))];case 1:n=o.sent();if(!n.ok)throw new Error("Failed to fetch latest version: ".concat(n.status," ").concat(n.statusText));return[4,n.json()];case 2:t=o.sent(),r=t.version;return[2,{success:!0,result:r}];case 3:a=o.sent();return[2,Y(a)];case 4:return[2]}})})()}S(eJ,"getLatestPackageVersion");function e$(e){return a(function(){var n,t,r,a,o,s,i,c,u,l,E,d,f,m,S,D,O,C,y,v,I,h,T,N;return p(this,function(p){switch(p.label){case 0:p.trys.push([0,2,,3]);if(!e){if(X(eB.PACKAGE_JSON)){n=$(eB.PACKAGE_JSON),t=n.name,r=t===void 0?"":t,a=n.version,o=a===void 0?"":a;return[2,{success:!0,result:{name:r,currentVersion:o,latestVersion:o,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:!1,isDevDependency:!1,installedPath:eB.PACKAGE_JSON,file:n}}]}return[2,{success:!0,result:{name:"",currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:!1,isDevDependency:!1,installedPath:"",file:{}}}]}if(!X(eB.PACKAGE_JSON))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===V.DEPENDENCY,isDevDependency:e.type===V.DEV_DEPENDENCY,installedPath:"",file:{}}}];s=$(eB.PACKAGE_JSON),i=s.name,c=s.version,u=c===void 0?"":c,l=s.dependencies,E=l===void 0?{}:l,d=s.devDependencies,f=d===void 0?{}:d;if(e.name===i)return[2,{success:!0,result:{name:i,currentVersion:u,latestVersion:u,isCurrentProject:!0,isInstalled:!0,isUpToDate:!0,isDependency:e.type===V.DEPENDENCY,isDevDependency:e.type===V.DEV_DEPENDENCY,installedPath:eB.PACKAGE_JSON,file:s}}];m=e.name in E,S=e.name in f;return[4,eJ(e.name)];case 1:D=p.sent();if(!D.success)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:"",isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:"",file:{}}}];if(!m&&!S)return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:D.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:e.type===V.DEPENDENCY,isDevDependency:e.type===V.DEV_DEPENDENCY,installedPath:"",file:{}}}];y=(C=(O=E[e.name])!==null&&O!==void 0?O:f[e.name])!==null&&C!==void 0?C:"",v=ea(eW.CWD,ec,e.name,el);if(!X(v))return[2,{success:!0,result:{name:e.name,currentVersion:"",latestVersion:D.result,isCurrentProject:!1,isInstalled:!1,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:"",file:{}}}];I=$(v),h=I.version,T=h===void 0?"":h;return[2,y!==T?{success:!0,result:{name:e.name,currentVersion:T||y,latestVersion:D.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:!1,isDependency:m,isDevDependency:S,installedPath:v,file:I}}:{success:!0,result:{name:e.name,currentVersion:y,latestVersion:D.result,isCurrentProject:!1,isInstalled:!0,isUpToDate:y===D.result,isDependency:m,isDevDependency:S,installedPath:v,file:I}}];case 2:N=p.sent();return[2,Y(N)];case 3:return[2]}})})()}S(e$,"getPackage");function ez(e){return a(function(){var n,t,r,a,o;return p(this,function(s){try{;r=$(eB.PACKAGE_JSON),a=(n=r.dependencies)!==null&&n!==void 0?n:{},o=(t=r.devDependencies)!==null&&t!==void 0?t:{};e.isDependency?a[e.name]=e.latestVersion:e.isDevDependency&&(o[e.name]=e.latestVersion),z(eB.PACKAGE_JSON,JSON.stringify(r,null,4)),F.info('Updated "'.concat(e.name,'" to version ').concat(e.latestVersion))}catch(e){Y(e)}return[2]})})()}S(ez,"updatePackage");function eX(){return a(function(){var e,n,t,r,a,o,s,i,c,u,l,E,d;return p(this,function(f){switch(f.label){case 0:f.trys.push([0,12,,13]);e=[{command:S(function(){return eq.pnpmInstallStandard()},"command"),message:"Installing dependencies (standard)"},{command:S(function(){return eq.pnpmInstallLegacy()},"command"),message:"Retrying with legacy peer dependencies"},{command:S(function(){return eq.pnpmInstallForce()},"command"),message:"Retrying with force install"}];n=true,t=false,r=undefined;f.label=1;case 1:f.trys.push([1,9,10,11]);a=e[Symbol.iterator]();f.label=2;case 2:if(!!(n=(o=a.next()).done))return[3,8];s=o.value,i=s.command,c=s.message;f.label=3;case 3:f.trys.push([3,6,,7]);return[4,i()];case 4:u=f.sent();return[4,ni("".concat(c," using: ").concat(u),u)];case 5:f.sent();return[2];case 6:l=f.sent();Y(l);return[3,7];case 7:n=true;return[3,2];case 8:return[3,11];case 9:E=f.sent();t=true;r=E;return[3,11];case 10:try{if(!n&&a.return!=null){a.return()}}finally{if(t){throw r}}return[7];case 11:return[3,13];case 12:d=f.sent();Y(d);return[3,13];case 13:return[2]}})})()}S(eX,"installDependencies");function eZ(e,n){return a(function(){var t,r,a,o,s,i,c,u,l,E,d,f;return p(this,function(p){switch(p.label){case 0:if(!X(eB.PACKAGE_JSON)){F.error("package.json not found. Aborting setup.");return[2]}p.label=1;case 1:p.trys.push([1,16,,17]);return[4,Promise.all(e.map(e$))];case 2:t=p.sent().filter(function(e){return e.success?!e.result.isCurrentProject&&(!e.result.isInstalled||!e.result.isUpToDate):!1});r=t.length>0;if(!r)return[3,7];return[4,Promise.all(t.map(function(e){return e.success?ez(e.result):Promise.resolve()}))];case 3:p.sent();return[4,eX()];case 4:p.sent();a=["Running ESLint with auto-fix"];return[4,eq.eslintFix()];case 5:return[4,ni.apply(void 0,a.concat([p.sent()]))];case 6:r=p.sent();p.label=7;case 7:r;s=true,i=false,c=undefined;p.label=8;case 8:p.trys.push([8,13,14,15]);u=((o=n===null||n===void 0?void 0:n.postInstallActions)!==null&&o!==void 0?o:[])[Symbol.iterator]();p.label=9;case 9:if(!!(s=(l=u.next()).done))return[3,12];E=l.value;return[4,E()];case 10:p.sent();p.label=11;case 11:s=true;return[3,9];case 12:return[3,15];case 13:d=p.sent();i=true;c=d;return[3,15];case 14:try{if(!s&&u.return!=null){u.return()}}finally{if(i){throw c}}return[7];case 15:return[3,17];case 16:f=p.sent();Y(f);return[3,17];case 17:return[2]}})})()}S(eZ,"setupPackages");import e0 from"node-persist";var e1=G();function e2(){return a(function(){var e;return p(this,function(n){switch(n.label){case 0:e=e0.defaultInstance;if(e)return[3,2];return[4,e0.init({dir:e1.CYBERSKILL_STORAGE_DIRECTORY})];case 1:e=n.sent();n.label=2;case 2:e;return[2]}})})()}S(e2,"initNodePersist");var e4={get:function e(e){return a(function(){var n,t;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,e2()];case 1:r.sent();return[4,e0.getItem(e)];case 2:return[2,(n=r.sent())!==null&&n!==void 0?n:null];case 3:t=r.sent();return[2,Y(t,{returnValue:null})];case 4:return[2]}})})()},set:function e(e,n){return a(function(){var t;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,e2()];case 1:r.sent();return[4,e0.setItem(e,n)];case 2:r.sent();return[3,4];case 3:t=r.sent();Y(t);return[3,4];case 4:return[2]}})})()},remove:function e(e){return a(function(){var n;return p(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,e2()];case 1:t.sent();return[4,e0.removeItem(e)];case 2:t.sent();return[3,4];case 3:n=t.sent();Y(n);return[3,4];case 4:return[2]}})})()},keys:function e(){return a(function(){var e,n;return p(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,e2()];case 1:t.sent();return[4,e0.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(F.warn("[Storage:keys] Invalid keys response:",e),[])];case 3:n=t.sent();return[2,Y(n,{returnValue:[]})];case 4:return[2]}})})()},getLogLink:function e(e){return a(function(){return p(this,function(n){try{return[2,"".concat(e1.CYBERSKILL_STORAGE_DIRECTORY," (key: ").concat(e,")")]}catch(e){return[2,Y(e,{returnValue:null})]}return[2]})})()}};var e3=G(),e5=C.promisify(D);function e7(){return a(function(){var e;return p(this,function(n){switch(n.label){case 0:return[4,e$()];case 1:e=n.sent();return[2,e.success?e.result.name:Date.now().toString()]}})})()}S(e7,"getPackageName");function e6(e){return a(function(){var n,t;return p(this,function(r){switch(r.label){case 0:if(e.length===0)return[2];return[4,e7()];case 1:n=r.sent();r.label=2;case 2:r.trys.push([2,4,,5]);return[4,e4.set(n,e)];case 3:r.sent(),setTimeout(function(){return a(function(){var e;return p(this,function(t){switch(t.label){case 0:return[4,e4.getLogLink(n)];case 1:e=t.sent();e&&F.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})})()},0);return[3,5];case 4:t=r.sent();Y(t);return[3,5];case 5:return[2]}})})()}S(e6,"saveErrorListToStorage");function e8(){return a(function(){var e,n,t;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,e7()];case 1:e=r.sent();return[4,e4.get(e)];case 2:return[2,(n=r.sent())!==null&&n!==void 0?n:[]];case 3:t=r.sent();return[2,Y(t,{returnValue:[]})];case 4:return[2]}})})()}S(e8,"getStoredErrorLists");function e9(){return a(function(){var e,n;return p(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,e7()];case 1:e=t.sent();return[4,e4.remove(e)];case 2:t.sent();return[3,4];case 3:n=t.sent();Y(n);return[3,4];case 4:return[2]}})})()}S(e9,"clearAllErrorLists");function ne(e){var n=[],t=[],r="",a=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,o=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,s=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var i,c,u,l,E;var d=a.exec(e)||[],f=o.exec(e)||[],p=s.exec(e)||[];var m,S,D,O,C,y;d.length&&r?n.push({file:r,position:"".concat(d[1],":").concat(d[2]),type:d[3]===P.Error?P.Error:P.Warning,message:(m=d===null||d===void 0?void 0:(i=d[4])===null||i===void 0?void 0:i.trim())!==null&&m!==void 0?m:"",rule:(S=d===null||d===void 0?void 0:(c=d[5])===null||c===void 0?void 0:c.trim())!==null&&S!==void 0?S:""}):f.length?n.push({file:(D=f===null||f===void 0?void 0:f[1])!==null&&D!==void 0?D:"",position:"".concat(f[2],":").concat(f[3]),type:f[4]===P.Error?P.Error:P.Warning,message:(O=f===null||f===void 0?void 0:(u=f[5])===null||u===void 0?void 0:u.trim())!==null&&O!==void 0?O:""}):p.length?n.push({file:"commitlint",type:P.Error,message:(C=p===null||p===void 0?void 0:(l=p[1])===null||l===void 0?void 0:l.trim())!==null&&C!==void 0?C:"",rule:(y=p===null||p===void 0?void 0:(E=p[2])===null||E===void 0?void 0:E.trim())!==null&&y!==void 0?y:""}):t.push(e.trim())}}),n.length&&e6(n),e3.DEBUG&&t.length&&(F.warn("Unmatched lines:"),t.forEach(function(e){return F.info(" ".concat(e))}))}S(ne,"parseTextErrors");function nn(e){try{var n=JSON.parse(e),t=[];n.forEach(function(e){var n=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,a=e.line,o=e.column,s=e.ruleId,i=e.message;t.push({type:r===2?P.Error:P.Warning,file:n,position:"".concat(a,":").concat(o),rule:s,message:i})})}),t.length&&e6(t)}catch(n){ne(e)}}S(nn,"parseCommandOutput");function nt(e){return a(function(e){var n,t,r,a,o,s,i,c,u;var l=arguments;return p(this,function(E){switch(E.label){case 0:n=l.length>1&&l[1]!==void 0?l[1]:nn;t=new AbortController;O.on("SIGINT",function(){F.warn("Process interrupted. Terminating..."),t.abort(),O.exit()});E.label=1;case 1:E.trys.push([1,4,,5]);if(!(typeof e=="string"))return[3,3];return[4,e5(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:r=E.sent(),a=r.stdout,o=r.stderr;[a,o].forEach(function(e){return e&&n(e)});E.label=3;case 3:return[3,5];case 4:s=E.sent();i=s.stdout,c=s.stderr,u=s.message;[i,c].forEach(function(e){return e&&n(e)}),!c&&!i&&F.error("Command failed: ".concat(u));return[3,5];case 5:return[2]}})}).apply(this,arguments)}S(nt,"executeCommand");function nr(e){return{raw:!0,cmd:e}}S(nr,"rawCommand");function na(e,n){return(n===null||n===void 0?void 0:n.isCurrentProject)?"".concat(ew," ").concat(eL," ").concat(ev," ").concat(e):"".concat(ew," ").concat(ey," ").concat(e)}S(na,"formatCLI");function no(e,n){return typeof e=="function"?na(e(n),n):(typeof e==="undefined"?"undefined":d(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?na(e,n):e}S(no,"formatCommand");function ns(e){return a(function(){var n,t,r;return p(this,function(a){switch(a.label){case 0:return[4,e$({name:ei})];case 1:n=a.sent();if(n.success){t={isCurrentProject:n.result.isCurrentProject},r=typeof e=="function"?e(t):e;return[2,Object.fromEntries(Object.entries(r).map(function(e){var n=l(e,2),r=n[0],a=n[1];return[r,no(a,t)]}))]}return[2]}})})()}S(ns,"resolveCommands");function ni(e,n){return a(function(){var t;return p(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);F.start("".concat(e)),e3.DEBUG&&F.info("→ ".concat(n));return[4,nt(n)];case 1:r.sent(),F.success("".concat(e," done."));return[3,3];case 2:t=r.sent();Y(t);return[3,3];case 3:return[2]}})})()}S(ni,"runCommand");export{e9 as clearAllErrorLists,no as formatCommand,e8 as getStoredErrorLists,nr as rawCommand,ns as resolveCommands,ni as runCommand};