@cyberskill/shared 1.27.0 → 1.29.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.
- package/README.md +10 -1
- package/dist/commands.cjs +1 -1
- package/dist/commands.js +1 -1
- package/dist/configs/graphql/graphql-codegen.d.cts +1 -0
- package/dist/configs/graphql/graphql-codegen.d.ts +1 -0
- package/dist/configs/graphql/index.d.cts +1 -0
- package/dist/configs/graphql/index.d.ts +1 -0
- package/dist/configs/i18n/react/i18next.cjs +1 -1
- package/dist/configs/i18n/react/i18next.d.cts +2 -2
- package/dist/configs/i18n/react/i18next.d.ts +2 -2
- package/dist/configs/i18n/react/i18next.js +1 -1
- package/dist/configs/i18n/react/index.cjs +1 -1
- package/dist/configs/i18n/react/index.d.cts +1 -1
- package/dist/configs/i18n/react/index.d.ts +1 -1
- package/dist/configs/i18n/react/index.js +1 -1
- package/dist/configs/index.cjs +1 -1
- package/dist/configs/index.js +1 -1
- package/dist/contexts/react/index.d.cts +1 -0
- package/dist/contexts/react/index.d.ts +1 -0
- package/dist/contexts/react/loading.d.cts +1 -0
- package/dist/contexts/react/loading.d.ts +1 -0
- package/dist/contexts/react/next-intl.cjs +1 -0
- package/dist/contexts/react/next-intl.d.cts +8 -0
- package/dist/contexts/react/next-intl.d.ts +8 -0
- package/dist/contexts/react/next-intl.js +1 -0
- package/dist/controllers/index.cjs +1 -1
- package/dist/controllers/index.js +1 -1
- package/dist/controllers/mongo-migration.cjs +1 -1
- package/dist/controllers/mongo-migration.js +1 -1
- package/dist/controllers/mongoose.cjs +1 -1
- package/dist/controllers/mongoose.js +1 -1
- package/dist/hocs/react/index.cjs +1 -0
- package/dist/hocs/react/index.d.cts +9 -0
- package/dist/hocs/react/index.d.ts +9 -0
- package/dist/hocs/react/index.js +1 -0
- package/dist/hocs/react/next-intl.cjs +1 -0
- package/dist/hocs/react/next-intl.d.cts +20 -0
- package/dist/hocs/react/next-intl.d.ts +20 -0
- package/dist/hocs/react/next-intl.js +1 -0
- package/dist/hooks/react/index.cjs +1 -1
- package/dist/hooks/react/index.d.cts +5 -0
- package/dist/hooks/react/index.d.ts +5 -0
- package/dist/hooks/react/index.js +1 -1
- package/dist/hooks/react/use-loading.d.cts +1 -0
- package/dist/hooks/react/use-loading.d.ts +1 -0
- package/dist/hooks/react/use-next-intl.cjs +1 -0
- package/dist/hooks/react/use-next-intl.d.cts +7 -0
- package/dist/hooks/react/use-next-intl.d.ts +7 -0
- package/dist/hooks/react/use-next-intl.js +1 -0
- package/dist/hooks/react/use-storage.cjs +1 -1
- package/dist/hooks/react/use-storage.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +1 -1
- package/dist/providers/react/apollo-client.cjs +1 -1
- package/dist/providers/react/apollo-client.d.cts +5 -3
- package/dist/providers/react/apollo-client.d.ts +5 -3
- package/dist/providers/react/apollo-client.js +1 -1
- package/dist/providers/react/index.cjs +1 -1
- package/dist/providers/react/index.d.cts +5 -0
- package/dist/providers/react/index.d.ts +5 -0
- package/dist/providers/react/index.js +1 -1
- package/dist/providers/react/loading.d.cts +1 -0
- package/dist/providers/react/loading.d.ts +1 -0
- package/dist/providers/react/next-intl.cjs +1 -0
- package/dist/providers/react/next-intl.d.cts +16 -0
- package/dist/providers/react/next-intl.d.ts +16 -0
- package/dist/providers/react/next-intl.js +1 -0
- package/dist/typescript/index.cjs +1 -1
- package/dist/typescript/index.d.cts +5 -1
- package/dist/typescript/index.d.ts +5 -1
- package/dist/typescript/index.js +1 -1
- package/dist/typescript/next-intl.cjs +1 -0
- package/dist/typescript/next-intl.d.cts +23 -0
- package/dist/typescript/next-intl.d.ts +23 -0
- package/dist/typescript/next-intl.js +0 -0
- package/dist/typescript/react.d.cts +9 -2
- package/dist/typescript/react.d.ts +9 -2
- package/dist/utils/command.cjs +1 -1
- package/dist/utils/command.js +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +2 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/npm-package.cjs +1 -1
- package/dist/utils/npm-package.js +1 -1
- package/dist/utils/storage-client.cjs +1 -0
- package/dist/utils/{storage.d.cts → storage-client.d.cts} +2 -3
- package/dist/utils/{storage.d.ts → storage-client.d.ts} +2 -3
- package/dist/utils/storage-client.js +1 -0
- package/dist/utils/storage-server.cjs +1 -0
- package/dist/utils/storage-server.d.cts +11 -0
- package/dist/utils/storage-server.d.ts +11 -0
- package/dist/utils/storage-server.js +1 -0
- package/package.json +14 -7
- package/dist/utils/storage.cjs +0 -1
- package/dist/utils/storage.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e,t,r,n,o,a,c){try{var s=e[a](c);var i=s.value}catch(e){r(e);return}if(s.done){t(i)}else{Promise.resolve(i).then(n,o)}}function t(t){return function(){var r=this,n=arguments;return new Promise(function(o,a){var c=t.apply(r,n);function s(t){e(c,o,a,s,i,"next",t)}function i(t){e(c,o,a,s,i,"throw",t)}s(undefined)})}}function r(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function n(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function a(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{o(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function c(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function s(e,t){var r,n,o,a,c={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return i([e,t])}}function i(a){if(r)throw new TypeError("Generator is already executing.");while(c)try{if(r=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:c.label++;return{value:a[1],done:false};case 5:c.label++;n=a[1];a=[0];continue;case 7:a=c.ops.pop();c.trys.pop();continue;default:if(!(o=c.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){c=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(a[0]===6&&c.label<o[1]){c.label=o[1];o=a;break}if(o&&c.label<o[2]){c.label=o[2];c.ops.push(a);break}if(o[2])c.ops.pop();c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e];n=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var i=Object.create;var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var g=function(e,t){for(var r in t)u(e,r,{get:t[r],enumerable:!0})},h=function(e,t,r,n){var o=true,a=false,s=undefined;if(t&&(typeof t==="undefined"?"undefined":c(t))=="object"||typeof t=="function")try{var i=function(){var o=g.value;!p.call(e,o)&&o!==r&&u(e,o,{get:function(){return t[o]},enumerable:!(n=l(t,o))||n.enumerable})};for(var d=f(t)[Symbol.iterator](),g;!(o=(g=d.next()).done);o=true)i()}catch(e){a=true;s=e}finally{try{if(!o&&d.return!=null){d.return()}}finally{if(a){throw s}}}return e};var y=function(e,t,r){return r=e!=null?i(d(e)):{},h(t||!e||!e.__esModule?u(r,"default",{value:e,enumerable:!0}):r,e)},v=function(e){return h(u({},"__esModule",{value:!0}),e)};var m={};g(m,{getLatestPackageVersion:function(){return el},isCurrentProject:function(){return ey},isPackageOutdated:function(){return ed},updatePackage:function(){return eg}});module.exports=v(m);var b=function(){return(typeof document==="undefined"?"undefined":c(document))>"u"?new URL("file:".concat(__filename)).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href},w=b();var O=y(require("node-fetch"),1),S=y(require("fs"),1),k=y(require("path"),1);var j=require("path"),P=y(require("process"),1),E=require("url"),x=(0,E.fileURLToPath)(w),I=(0,j.dirname)(x),L=P.default.env.INIT_CWD||P.default.cwd();var _=y(require("boxen"),1),q=y(require("chalk"),1),C=require("child_process"),N=y(require("process"),1),D=y(require("util"),1);var R=y(require("localforage"),1),F=y(require("node-persist"),1),T=y(require("os"),1),U=y(require("path"),1),M=y(require("process"),1),A=(typeof window==="undefined"?"undefined":c(window))<"u",J=M.default.env.CYBERSKILL_STORAGE_DIR||U.default.join(T.default.homedir(),".cyberskill-storage");function G(){return B.apply(this,arguments)}function B(){B=t(function(){var e;return s(this,function(t){switch(t.label){case 0:e=!A&&!F.default.defaultInstance;if(!e)return[3,2];return[4,F.default.init({dir:J,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})});return B.apply(this,arguments)}var V={get:function e(e){return t(function(){var t,r,n;return s(this,function(o){switch(o.label){case 0:o.trys.push([0,6,,7]);if(!A)return[3,2];return[4,R.default.getItem(e)];case 1:r=o.sent();return[3,5];case 2:return[4,G()];case 3:o.sent();return[4,F.default.getItem(e)];case 4:r=(t=o.sent())!==null&&t!==void 0?t:null;o.label=5;case 5:return[2,r];case 6:n=o.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),n),null)];case 7:return[2]}})})()},set:function e(e,r){return t(function(){var t,n;return s(this,function(o){switch(o.label){case 0:o.trys.push([0,6,,7]);if(!A)return[3,2];return[4,R.default.setItem(e,r)];case 1:t=o.sent();return[3,5];case 2:return[4,G()];case 3:o.sent();return[4,F.default.setItem(e,r)];case 4:t=o.sent();o.label=5;case 5:t;return[3,7];case 6:n=o.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),n);return[3,7];case 7:return[2]}})})()},remove:function e(e){return t(function(){var t,r;return s(this,function(n){switch(n.label){case 0:n.trys.push([0,6,,7]);if(!A)return[3,2];return[4,R.default.removeItem(e)];case 1:t=n.sent();return[3,5];case 2:return[4,G()];case 3:n.sent();return[4,F.default.removeItem(e)];case 4:t=n.sent();n.label=5;case 5:t;return[3,7];case 6:r=n.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,7];case 7:return[2]}})})()},keys:function e(){return t(function(){var e,t,r;return s(this,function(n){switch(n.label){case 0:n.trys.push([0,5,,6]);if(!A)return[3,2];return[4,R.default.keys()];case 1:return[2,(e=n.sent())!==null&&e!==void 0?e:[]];case 2:return[4,G()];case 3:n.sent();return[4,F.default.keys()];case 4:t=n.sent();return[2,Array.isArray(t)?t:(console.warn("⚠️ [Storage:keys] Invalid keys response:",t),[])];case 5:r=n.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 6:return[2]}})})()},getLogLink:function e(e){return t(function(){return s(this,function(t){try{return[2,"".concat(J," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var W=N.default.env.DEBUG==="true",$=D.promisify(C.exec),K=q.default,Y=K.gray,z=K.blue,H=function(){return Y("[".concat(new Date().toLocaleTimeString(),"]"))};function Q(e){var t=q.default[e];return typeof t=="function"?t:q.default.green}function X(e,t,r,n){var o=Q(t);console.log("".concat(H()," ").concat(o("".concat(r," ").concat(e))," ").concat(n))}function Z(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=r.color,o=n===void 0?"green":n,a=r.padding,c=a===void 0?1:a,s=r.margin,i=s===void 0?1:s,u=r.borderStyle,l=u===void 0?"round":u,f=r.titleColor,d=f===void 0?"bold":f;var p=Q(o),g=Q(d);if(typeof t=="string"){console.log((0,_.default)(g(p("".concat(e,"\n").concat(t))),{padding:c,margin:i,borderStyle:l,borderColor:o}));return}Array.isArray(t)&&t.length&&(t.forEach(function(e){var t=e.file,r=e.position,n=e.rule,o=e.message;console.log("".concat(H()," ").concat(p("File:")," ").concat(z("".concat(t).concat(r?":".concat(r):"")))),n&&console.log(" ".concat(p("Rule:")," ").concat(p(n))),console.log(" ".concat(p("Message:")," ").concat(p(o)))}),console.log((0,_.default)(g(p("".concat(e,": ").concat(t.length))),{padding:c,margin:i,borderStyle:l,borderColor:o})),console.log(Y("─".repeat(40))))}var ee={success:function(e){return X("SUCCESS","green","✔",e)},error:function(e){return X("ERROR","red","✖",e)},warning:function(e){return X("WARNING","yellow","⚠",e)},info:function(e){return X("INFO","blue","ℹ",e)},printBoxedLog:Z},et=function(e){return"error_list:".concat(e)};function er(e){return en.apply(this,arguments)}function en(){en=t(function(e){var r,n,o;return s(this,function(a){switch(a.label){case 0:if(e.length===0)return[2];r=Date.now(),n=et(r);a.label=1;case 1:a.trys.push([1,3,,4]);return[4,V.set(n,{errors:e,timestamp:r})];case 2:a.sent(),setTimeout(/*#__PURE__*/t(function(){var e;return s(this,function(t){switch(t.label){case 0:return[4,V.getLogLink(n)];case 1:e=t.sent();e&&ee.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:o=a.sent();ee.error("Failed to save errors: ".concat(o.message));return[3,4];case 4:return[2]}})});return en.apply(this,arguments)}function eo(e){var t=[],r=[],n="",o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,c=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var s=o.exec(e)||[],i=a.exec(e)||[],u=c.exec(e)||[];s.length&&n?t.push({file:n,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()}):i.length?t.push({file:i[1],position:"".concat(i[2],":").concat(i[3]),type:i[4]==="error"?"error":"warning",message:i[5].trim()}):u.length?t.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):r.push(e.trim())}}),t.length&&er(t),r.length&&W&&(ee.warning("Unmatched lines:"),r.forEach(function(e){return console.log(" ".concat(e))}))}function ea(e){try{var t=JSON.parse(e),r=[];t.forEach(function(e){var t=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,o=e.line,a=e.column,c=e.ruleId,s=e.message;r.push({type:n===2?"error":"warning",file:t,position:"".concat(o,":").concat(a),rule:c,message:s})})}),r.length&&er(r)}catch(t){eo(e)}}function ec(e){return es.apply(this,arguments)}function es(){es=t(function(e){var t,r,n,o,a,c,i,u,l;var f=arguments;return s(this,function(s){switch(s.label){case 0:t=f.length>1&&f[1]!==void 0?f[1]:ea;r=new AbortController;N.default.on("SIGINT",function(){ee.warning("Process interrupted. Terminating..."),r.abort(),N.default.exit()});s.label=1;case 1:s.trys.push([1,3,,4]);return[4,$(e,{maxBuffer:0x6400000,signal:r.signal})];case 2:n=s.sent(),o=n.stdout,a=n.stderr;[o,a].forEach(function(e){return e&&t(e)});return[3,4];case 3:c=s.sent();i=c.stdout,u=c.stderr,l=c.message;[i,u].forEach(function(e){return e&&t(e)}),!u&&!i&&ee.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return es.apply(this,arguments)}var ei=24*60*60*1e3;function eu(e){return e?k.default.join(L,"node_modules",e,"package.json"):k.default.join(L,"package.json")}function el(e){return ef.apply(this,arguments)}function ef(){ef=t(function(e){var t,r,n,o,a,c,i,u,l,f;var d=arguments;return s(this,function(s){switch(s.label){case 0:t=d.length>1&&d[1]!==void 0?d[1]:!1;r="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,V.get(r)];case 1:o=s.sent();return[4,V.get(n)];case 2:a=s.sent(),c=o&&Date.now()-o.timestamp<ei;if(!t&&c)return[2,(ee.info("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];i={};(a===null||a===void 0?void 0:a.etag)&&(i["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(i["If-Modified-Since"]=a.lastModified);s.label=3;case 3:s.trys.push([3,8,,9]);ee.info("Fetching latest version for ".concat(e,"..."));return[4,(0,O.default)("https://registry.npmjs.org/".concat(e,"/latest"),{headers:i})];case 4:u=s.sent();if(u.status===304&&o)return[2,(ee.info("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:l=s.sent().version;return[4,V.set(r,{version:l,timestamp:Date.now()})];case 6:s.sent();return[4,V.set(n,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(s.sent(),ee.success("Cached latest version for ".concat(e,": ").concat(l)),l)];case 8:f=s.sent();if(ee.error("Error fetching latest version for ".concat(e,": ").concat(f.message)),o)return[2,(ee.warning("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw f;case 9:return[2]}})});return ef.apply(this,arguments)}function ed(e){return ep.apply(this,arguments)}function ep(){ep=t(function(e){var t,r,n,o,a;var c=arguments;return s(this,function(s){switch(s.label){case 0:t=c.length>1&&c[1]!==void 0?c[1]:!0;s.label=1;case 1:s.trys.push([1,3,,4]);r=eu(e);if(!S.default.existsSync(r))return[2,(ee.info("".concat(e," is not installed.")),!0)];n=JSON.parse(S.default.readFileSync(r,"utf-8")).version;return[4,el(e,t)];case 2:o=s.sent();return[2,(ee.info("Installed version of ".concat(e,": ").concat(n)),ee.info("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:a=s.sent();return[2,(ee.warning("Failed to check version for ".concat(e,": ").concat(a.message)),!0)];case 4:return[2]}})});return ep.apply(this,arguments)}function eg(e){return eh.apply(this,arguments)}function eh(){eh=t(function(e){var t,o,c,i;return s(this,function(s){switch(s.label){case 0:s.trys.push([0,4,,5]);return[4,el(e,!0)];case 1:t=s.sent(),o=eu();if(!S.default.existsSync(o)){ee.error("package.json not found. Cannot update ".concat(e));return[2]}c=JSON.parse(S.default.readFileSync(o,"utf-8"));c.dependencies=a(n({},c.dependencies),r({},e,t)),S.default.writeFileSync(o,JSON.stringify(c,null,2)),ee.info("Updated ".concat(e," to version ").concat(t));return[4,ec("npm i -f")];case 2:s.sent();return[4,ec("npm run lint:fix")];case 3:s.sent(),ee.success("".concat(e," updated successfully."));return[3,5];case 4:i=s.sent();throw ee.error("Failed to update ".concat(e,": ").concat(i.message)),i;case 5:return[2]}})});return eh.apply(this,arguments)}function ey(e,t){try{var r=k.default.join(e,"package.json");return S.default.existsSync(r)?JSON.parse(S.default.readFileSync(r,"utf-8")).name===t:!1}catch(e){return ee.error("Error reading package.json: ".concat(e.message)),!1}}0&&(module.exports={getLatestPackageVersion:getLatestPackageVersion,isCurrentProject:isCurrentProject,isPackageOutdated:isPackageOutdated,updatePackage:updatePackage});
|
|
1
|
+
"use strict";function e(e,t,r,n,o,a,c){try{var i=e[a](c);var s=i.value}catch(e){r(e);return}if(i.done){t(s)}else{Promise.resolve(s).then(n,o)}}function t(t){return function(){var r=this,n=arguments;return new Promise(function(o,a){var c=t.apply(r,n);function i(t){e(c,o,a,i,s,"next",t)}function s(t){e(c,o,a,i,s,"throw",t)}i(undefined)})}}function r(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function n(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(t){r(e,t,n[t])})}return e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}r.push.apply(r,n)}return r}function a(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{o(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function c(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function i(e,t){var r,n,o,a,c={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),"throw":i(1),"return":i(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function i(e){return function(t){return s([e,t])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(c)try{if(r=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:c.label++;return{value:a[1],done:false};case 5:c.label++;n=a[1];a=[0];continue;case 7:a=c.ops.pop();c.trys.pop();continue;default:if(!(o=c.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){c=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(a[0]===6&&c.label<o[1]){c.label=o[1];o=a;break}if(o&&c.label<o[2]){c.label=o[2];c.ops.push(a);break}if(o[2])c.ops.pop();c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e];n=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var s=Object.create;var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var g=function(e,t){for(var r in t)u(e,r,{get:t[r],enumerable:!0})},h=function(e,t,r,n){var o=true,a=false,i=undefined;if(t&&(typeof t==="undefined"?"undefined":c(t))=="object"||typeof t=="function")try{var s=function(){var o=g.value;!p.call(e,o)&&o!==r&&u(e,o,{get:function(){return t[o]},enumerable:!(n=l(t,o))||n.enumerable})};for(var d=f(t)[Symbol.iterator](),g;!(o=(g=d.next()).done);o=true)s()}catch(e){a=true;i=e}finally{try{if(!o&&d.return!=null){d.return()}}finally{if(a){throw i}}}return e};var y=function(e,t,r){return r=e!=null?s(d(e)):{},h(t||!e||!e.__esModule?u(r,"default",{value:e,enumerable:!0}):r,e)},v=function(e){return h(u({},"__esModule",{value:!0}),e)};var m={};g(m,{getLatestPackageVersion:function(){return es},isCurrentProject:function(){return eg},isPackageOutdated:function(){return el},updatePackage:function(){return ed}});module.exports=v(m);var b=function(){return(typeof document==="undefined"?"undefined":c(document))>"u"?new URL("file:".concat(__filename)).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href},w=b();var O=y(require("node-fetch"),1),S=y(require("fs"),1),k=y(require("path"),1);var j=require("path"),P=y(require("process"),1),E=require("url"),x=(0,E.fileURLToPath)(w),I=(0,j.dirname)(x),L=P.default.env.INIT_CWD||P.default.cwd();var _=y(require("boxen"),1),q=y(require("chalk"),1),C=require("child_process"),N=y(require("process"),1),D=y(require("util"),1);var R=y(require("node-persist"),1),F=y(require("os"),1),T=y(require("path"),1),U=y(require("process"),1),M=U.default.env.CYBERSKILL_STORAGE_DIR||T.default.join(F.default.homedir(),".cyberskill-storage");function A(){return J.apply(this,arguments)}function J(){J=t(function(){var e;return i(this,function(t){switch(t.label){case 0:e=R.default.defaultInstance;if(e)return[3,2];return[4,R.default.init({dir:M,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})});return J.apply(this,arguments)}var G={get:function e(e){return t(function(){var t,r;return i(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,A()];case 1:n.sent();return[4,R.default.getItem(e)];case 2:return[2,(t=n.sent())!==null&&t!==void 0?t:null];case 3:r=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),r),null)];case 4:return[2]}})})()},set:function e(e,r){return t(function(){var t;return i(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,A()];case 1:n.sent();return[4,R.default.setItem(e,r)];case 2:n.sent();return[3,4];case 3:t=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},remove:function e(e){return t(function(){var t;return i(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,A()];case 1:r.sent();return[4,R.default.removeItem(e)];case 2:r.sent();return[3,4];case 3:t=r.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},keys:function e(){return t(function(){var e,t;return i(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,A()];case 1:r.sent();return[4,R.default.keys()];case 2:e=r.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:t=r.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",t),[])];case 4:return[2]}})})()},getLogLink:function e(e){return t(function(){return i(this,function(t){try{return[2,"".concat(M," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var B=N.default.env.DEBUG==="true",V=D.promisify(C.exec),W=q.default,$=W.gray,K=W.blue,Y=function(){return $("[".concat(new Date().toLocaleTimeString(),"]"))};function z(e){var t=q.default[e];return typeof t=="function"?t:q.default.green}function H(e,t,r,n){var o=z(t);console.log("".concat(Y()," ").concat(o("".concat(r," ").concat(e))," ").concat(n))}function Q(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=r.color,o=n===void 0?"green":n,a=r.padding,c=a===void 0?1:a,i=r.margin,s=i===void 0?1:i,u=r.borderStyle,l=u===void 0?"round":u,f=r.titleColor,d=f===void 0?"bold":f;var p=z(o),g=z(d);if(typeof t=="string"){console.log((0,_.default)(g(p("".concat(e,"\n").concat(t))),{padding:c,margin:s,borderStyle:l,borderColor:o}));return}Array.isArray(t)&&t.length&&(t.forEach(function(e){var t=e.file,r=e.position,n=e.rule,o=e.message;console.log("".concat(Y()," ").concat(p("File:")," ").concat(K("".concat(t).concat(r?":".concat(r):"")))),n&&console.log(" ".concat(p("Rule:")," ").concat(p(n))),console.log(" ".concat(p("Message:")," ").concat(p(o)))}),console.log((0,_.default)(g(p("".concat(e,": ").concat(t.length))),{padding:c,margin:s,borderStyle:l,borderColor:o})),console.log($("─".repeat(40))))}var X={success:function(e){return H("SUCCESS","green","✔",e)},error:function(e){return H("ERROR","red","✖",e)},warning:function(e){return H("WARNING","yellow","⚠",e)},info:function(e){return H("INFO","blue","ℹ",e)},printBoxedLog:Q},Z=function(e){return"error_list:".concat(e)};function ee(e){return et.apply(this,arguments)}function et(){et=t(function(e){var r,n,o;return i(this,function(a){switch(a.label){case 0:if(e.length===0)return[2];r=Date.now(),n=Z(r);a.label=1;case 1:a.trys.push([1,3,,4]);return[4,G.set(n,{errors:e,timestamp:r})];case 2:a.sent(),setTimeout(/*#__PURE__*/t(function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,G.getLogLink(n)];case 1:e=t.sent();e&&X.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:o=a.sent();X.error("Failed to save errors: ".concat(o.message));return[3,4];case 4:return[2]}})});return et.apply(this,arguments)}function er(e){var t=[],r=[],n="",o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,c=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var i=o.exec(e)||[],s=a.exec(e)||[],u=c.exec(e)||[];i.length&&n?t.push({file:n,position:"".concat(i[1],":").concat(i[2]),type:i[3]==="error"?"error":"warning",message:i[4].trim(),rule:i[5].trim()}):s.length?t.push({file:s[1],position:"".concat(s[2],":").concat(s[3]),type:s[4]==="error"?"error":"warning",message:s[5].trim()}):u.length?t.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):r.push(e.trim())}}),t.length&&ee(t),r.length&&B&&(X.warning("Unmatched lines:"),r.forEach(function(e){return console.log(" ".concat(e))}))}function en(e){try{var t=JSON.parse(e),r=[];t.forEach(function(e){var t=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,o=e.line,a=e.column,c=e.ruleId,i=e.message;r.push({type:n===2?"error":"warning",file:t,position:"".concat(o,":").concat(a),rule:c,message:i})})}),r.length&&ee(r)}catch(t){er(e)}}function eo(e){return ea.apply(this,arguments)}function ea(){ea=t(function(e){var t,r,n,o,a,c,s,u,l;var f=arguments;return i(this,function(i){switch(i.label){case 0:t=f.length>1&&f[1]!==void 0?f[1]:en;r=new AbortController;N.default.on("SIGINT",function(){X.warning("Process interrupted. Terminating..."),r.abort(),N.default.exit()});i.label=1;case 1:i.trys.push([1,3,,4]);return[4,V(e,{maxBuffer:0x6400000,signal:r.signal})];case 2:n=i.sent(),o=n.stdout,a=n.stderr;[o,a].forEach(function(e){return e&&t(e)});return[3,4];case 3:c=i.sent();s=c.stdout,u=c.stderr,l=c.message;[s,u].forEach(function(e){return e&&t(e)}),!u&&!s&&X.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return ea.apply(this,arguments)}var ec=24*60*60*1e3;function ei(e){return e?k.default.join(L,"node_modules",e,"package.json"):k.default.join(L,"package.json")}function es(e){return eu.apply(this,arguments)}function eu(){eu=t(function(e){var t,r,n,o,a,c,s,u,l,f;var d=arguments;return i(this,function(i){switch(i.label){case 0:t=d.length>1&&d[1]!==void 0?d[1]:!1;r="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,G.get(r)];case 1:o=i.sent();return[4,G.get(n)];case 2:a=i.sent(),c=o&&Date.now()-o.timestamp<ec;if(!t&&c)return[2,(X.info("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];s={};(a===null||a===void 0?void 0:a.etag)&&(s["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(s["If-Modified-Since"]=a.lastModified);i.label=3;case 3:i.trys.push([3,8,,9]);X.info("Fetching latest version for ".concat(e,"..."));return[4,(0,O.default)("https://registry.npmjs.org/".concat(e,"/latest"),{headers:s})];case 4:u=i.sent();if(u.status===304&&o)return[2,(X.info("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:l=i.sent().version;return[4,G.set(r,{version:l,timestamp:Date.now()})];case 6:i.sent();return[4,G.set(n,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(i.sent(),X.success("Cached latest version for ".concat(e,": ").concat(l)),l)];case 8:f=i.sent();if(X.error("Error fetching latest version for ".concat(e,": ").concat(f.message)),o)return[2,(X.warning("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw f;case 9:return[2]}})});return eu.apply(this,arguments)}function el(e){return ef.apply(this,arguments)}function ef(){ef=t(function(e){var t,r,n,o,a;var c=arguments;return i(this,function(i){switch(i.label){case 0:t=c.length>1&&c[1]!==void 0?c[1]:!0;i.label=1;case 1:i.trys.push([1,3,,4]);r=ei(e);if(!S.default.existsSync(r))return[2,(X.info("".concat(e," is not installed.")),!0)];n=JSON.parse(S.default.readFileSync(r,"utf-8")).version;return[4,es(e,t)];case 2:o=i.sent();return[2,(X.info("Installed version of ".concat(e,": ").concat(n)),X.info("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:a=i.sent();return[2,(X.warning("Failed to check version for ".concat(e,": ").concat(a.message)),!0)];case 4:return[2]}})});return ef.apply(this,arguments)}function ed(e){return ep.apply(this,arguments)}function ep(){ep=t(function(e){var t,o,c,s;return i(this,function(i){switch(i.label){case 0:i.trys.push([0,4,,5]);return[4,es(e,!0)];case 1:t=i.sent(),o=ei();if(!S.default.existsSync(o)){X.error("package.json not found. Cannot update ".concat(e));return[2]}c=JSON.parse(S.default.readFileSync(o,"utf-8"));c.dependencies=a(n({},c.dependencies),r({},e,t)),S.default.writeFileSync(o,JSON.stringify(c,null,2)),X.info("Updated ".concat(e," to version ").concat(t));return[4,eo("npm i -f")];case 2:i.sent();return[4,eo("npm run lint:fix")];case 3:i.sent(),X.success("".concat(e," updated successfully."));return[3,5];case 4:s=i.sent();throw X.error("Failed to update ".concat(e,": ").concat(s.message)),s;case 5:return[2]}})});return ep.apply(this,arguments)}function eg(e,t){try{var r=k.default.join(e,"package.json");return S.default.existsSync(r)?JSON.parse(S.default.readFileSync(r,"utf-8")).name===t:!1}catch(e){return X.error("Error reading package.json: ".concat(e.message)),!1}}0&&(module.exports={getLatestPackageVersion:getLatestPackageVersion,isCurrentProject:isCurrentProject,isPackageOutdated:isPackageOutdated,updatePackage:updatePackage});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,r,t,n,o,c,s){try{var a=e[c](s);var i=a.value}catch(e){t(e);return}if(a.done){r(i)}else{Promise.resolve(i).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,c){var s=r.apply(t,n);function a(r){e(s,o,c,a,i,"next",r)}function i(r){e(s,o,c,a,i,"throw",r)}a(undefined)})}}function t(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(r){t(e,r,n[r])})}return e}function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function c(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function a(e,r){var t,n,o,c,s={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return c={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function a(e){return function(r){return i([e,r])}}function i(c){if(t)throw new TypeError("Generator is already executing.");while(s)try{if(t=1,n&&(o=c[0]&2?n["return"]:c[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;if(n=0,o)c=[c[0]&2,o.value];switch(c[0]){case 0:case 1:o=c;break;case 4:s.label++;return{value:c[1],done:false};case 5:s.label++;n=c[1];c=[0];continue;case 7:c=s.ops.pop();s.trys.pop();continue;default:if(!(o=s.trys,o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){s=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){s.label=c[1];break}if(c[0]===6&&s.label<o[1]){s.label=o[1];o=c;break}if(o&&s.label<o[2]){s.label=o[2];s.ops.push(c);break}if(o[2])s.ops.pop();s.trys.pop();continue}c=r.call(e,s)}catch(e){c=[6,e];n=0}finally{t=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}}import i from"node-fetch";import u from"node:fs";import l from"node:path";import{dirname as f}from"node:path";import p from"node:process";import{fileURLToPath as g}from"node:url";var d=g(import.meta.url),h=f(d),m=p.env.INIT_CWD||p.cwd();import y from"boxen";import v from"chalk";import{exec as b}from"node:child_process";import w from"node:process";import*as S from"node:util";import O from"localforage";import k from"node-persist";import j from"node:os";import E from"node:path";import P from"node:process";var I=(typeof window==="undefined"?"undefined":s(window))<"u",x=P.env.CYBERSKILL_STORAGE_DIR||E.join(j.homedir(),".cyberskill-storage");function L(){return C.apply(this,arguments)}function C(){C=r(function(){var e;return a(this,function(r){switch(r.label){case 0:e=!I&&!k.defaultInstance;if(!e)return[3,2];return[4,k.init({dir:x,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return C.apply(this,arguments)}var N={get:function e(e){return r(function(){var r,t,n;return a(this,function(o){switch(o.label){case 0:o.trys.push([0,6,,7]);if(!I)return[3,2];return[4,O.getItem(e)];case 1:t=o.sent();return[3,5];case 2:return[4,L()];case 3:o.sent();return[4,k.getItem(e)];case 4:t=(r=o.sent())!==null&&r!==void 0?r:null;o.label=5;case 5:return[2,t];case 6:n=o.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),n),null)];case 7:return[2]}})})()},set:function e(e,t){return r(function(){var r,n;return a(this,function(o){switch(o.label){case 0:o.trys.push([0,6,,7]);if(!I)return[3,2];return[4,O.setItem(e,t)];case 1:r=o.sent();return[3,5];case 2:return[4,L()];case 3:o.sent();return[4,k.setItem(e,t)];case 4:r=o.sent();o.label=5;case 5:r;return[3,7];case 6:n=o.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),n);return[3,7];case 7:return[2]}})})()},remove:function e(e){return r(function(){var r,t;return a(this,function(n){switch(n.label){case 0:n.trys.push([0,6,,7]);if(!I)return[3,2];return[4,O.removeItem(e)];case 1:r=n.sent();return[3,5];case 2:return[4,L()];case 3:n.sent();return[4,k.removeItem(e)];case 4:r=n.sent();n.label=5;case 5:r;return[3,7];case 6:t=n.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,7];case 7:return[2]}})})()},keys:function e(){return r(function(){var e,r,t;return a(this,function(n){switch(n.label){case 0:n.trys.push([0,5,,6]);if(!I)return[3,2];return[4,O.keys()];case 1:return[2,(e=n.sent())!==null&&e!==void 0?e:[]];case 2:return[4,L()];case 3:n.sent();return[4,k.keys()];case 4:r=n.sent();return[2,Array.isArray(r)?r:(console.warn("⚠️ [Storage:keys] Invalid keys response:",r),[])];case 5:t=n.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",t),[])];case 6:return[2]}})})()},getLogLink:function e(e){return r(function(){return a(this,function(r){try{return[2,"".concat(x," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var D=w.env.DEBUG==="true",F=S.promisify(b),T=v.gray,_=v.blue,R=function(){return T("[".concat(new Date().toLocaleTimeString(),"]"))};function J(e){var r=v[e];return typeof r=="function"?r:v.green}function A(e,r,t,n){var o=J(r);console.log("".concat(R()," ").concat(o("".concat(t," ").concat(e))," ").concat(n))}function M(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=t.color,o=n===void 0?"green":n,c=t.padding,s=c===void 0?1:c,a=t.margin,i=a===void 0?1:a,u=t.borderStyle,l=u===void 0?"round":u,f=t.titleColor,p=f===void 0?"bold":f;var g=J(o),d=J(p);if(typeof r=="string"){console.log(y(d(g("".concat(e,"\n").concat(r))),{padding:s,margin:i,borderStyle:l,borderColor:o}));return}Array.isArray(r)&&r.length&&(r.forEach(function(e){var r=e.file,t=e.position,n=e.rule,o=e.message;console.log("".concat(R()," ").concat(g("File:")," ").concat(_("".concat(r).concat(t?":".concat(t):"")))),n&&console.log(" ".concat(g("Rule:")," ").concat(g(n))),console.log(" ".concat(g("Message:")," ").concat(g(o)))}),console.log(y(d(g("".concat(e,": ").concat(r.length))),{padding:s,margin:i,borderStyle:l,borderColor:o})),console.log(T("─".repeat(40))))}var U={success:function(e){return A("SUCCESS","green","✔",e)},error:function(e){return A("ERROR","red","✖",e)},warning:function(e){return A("WARNING","yellow","⚠",e)},info:function(e){return A("INFO","blue","ℹ",e)},printBoxedLog:M},G=function(e){return"error_list:".concat(e)};function B(e){return W.apply(this,arguments)}function W(){W=r(function(e){var t,n,o;return a(this,function(c){switch(c.label){case 0:if(e.length===0)return[2];t=Date.now(),n=G(t);c.label=1;case 1:c.trys.push([1,3,,4]);return[4,N.set(n,{errors:e,timestamp:t})];case 2:c.sent(),setTimeout(/*#__PURE__*/r(function(){var e;return a(this,function(r){switch(r.label){case 0:return[4,N.getLogLink(n)];case 1:e=r.sent();e&&U.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:o=c.sent();U.error("Failed to save errors: ".concat(o.message));return[3,4];case 4:return[2]}})});return W.apply(this,arguments)}function $(e){var r=[],t=[],n="",o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,c=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,s=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var a=o.exec(e)||[],i=c.exec(e)||[],u=s.exec(e)||[];a.length&&n?r.push({file:n,position:"".concat(a[1],":").concat(a[2]),type:a[3]==="error"?"error":"warning",message:a[4].trim(),rule:a[5].trim()}):i.length?r.push({file:i[1],position:"".concat(i[2],":").concat(i[3]),type:i[4]==="error"?"error":"warning",message:i[5].trim()}):u.length?r.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):t.push(e.trim())}}),r.length&&B(r),t.length&&D&&(U.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function K(e){try{var r=JSON.parse(e),t=[];r.forEach(function(e){var r=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,o=e.line,c=e.column,s=e.ruleId,a=e.message;t.push({type:n===2?"error":"warning",file:r,position:"".concat(o,":").concat(c),rule:s,message:a})})}),t.length&&B(t)}catch(r){$(e)}}function V(e){return Y.apply(this,arguments)}function Y(){Y=r(function(e){var r,t,n,o,c,s,i,u,l;var f=arguments;return a(this,function(a){switch(a.label){case 0:r=f.length>1&&f[1]!==void 0?f[1]:K;t=new AbortController;w.on("SIGINT",function(){U.warning("Process interrupted. Terminating..."),t.abort(),w.exit()});a.label=1;case 1:a.trys.push([1,3,,4]);return[4,F(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:n=a.sent(),o=n.stdout,c=n.stderr;[o,c].forEach(function(e){return e&&r(e)});return[3,4];case 3:s=a.sent();i=s.stdout,u=s.stderr,l=s.message;[i,u].forEach(function(e){return e&&r(e)}),!u&&!i&&U.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return Y.apply(this,arguments)}var q=24*60*60*1e3;function z(e){return e?l.join(m,"node_modules",e,"package.json"):l.join(m,"package.json")}function H(e){return Q.apply(this,arguments)}function Q(){Q=r(function(e){var r,t,n,o,c,s,u,l,f,p;var g=arguments;return a(this,function(a){switch(a.label){case 0:r=g.length>1&&g[1]!==void 0?g[1]:!1;t="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,N.get(t)];case 1:o=a.sent();return[4,N.get(n)];case 2:c=a.sent(),s=o&&Date.now()-o.timestamp<q;if(!r&&s)return[2,(U.info("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];u={};(c===null||c===void 0?void 0:c.etag)&&(u["If-None-Match"]=c.etag),(c===null||c===void 0?void 0:c.lastModified)&&(u["If-Modified-Since"]=c.lastModified);a.label=3;case 3:a.trys.push([3,8,,9]);U.info("Fetching latest version for ".concat(e,"..."));return[4,i("https://registry.npmjs.org/".concat(e,"/latest"),{headers:u})];case 4:l=a.sent();if(l.status===304&&o)return[2,(U.info("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!l.ok)throw new Error("Failed to fetch latest version: ".concat(l.statusText));return[4,l.json()];case 5:f=a.sent().version;return[4,N.set(t,{version:f,timestamp:Date.now()})];case 6:a.sent();return[4,N.set(n,{etag:l.headers.get("ETag")||void 0,lastModified:l.headers.get("Last-Modified")||void 0})];case 7:return[2,(a.sent(),U.success("Cached latest version for ".concat(e,": ").concat(f)),f)];case 8:p=a.sent();if(U.error("Error fetching latest version for ".concat(e,": ").concat(p.message)),o)return[2,(U.warning("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw p;case 9:return[2]}})});return Q.apply(this,arguments)}function X(e){return Z.apply(this,arguments)}function Z(){Z=r(function(e){var r,t,n,o,c;var s=arguments;return a(this,function(a){switch(a.label){case 0:r=s.length>1&&s[1]!==void 0?s[1]:!0;a.label=1;case 1:a.trys.push([1,3,,4]);t=z(e);if(!u.existsSync(t))return[2,(U.info("".concat(e," is not installed.")),!0)];n=JSON.parse(u.readFileSync(t,"utf-8")).version;return[4,H(e,r)];case 2:o=a.sent();return[2,(U.info("Installed version of ".concat(e,": ").concat(n)),U.info("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:c=a.sent();return[2,(U.warning("Failed to check version for ".concat(e,": ").concat(c.message)),!0)];case 4:return[2]}})});return Z.apply(this,arguments)}function ee(e){return er.apply(this,arguments)}function er(){er=r(function(e){var r,o,s,i;return a(this,function(a){switch(a.label){case 0:a.trys.push([0,4,,5]);return[4,H(e,!0)];case 1:r=a.sent(),o=z();if(!u.existsSync(o)){U.error("package.json not found. Cannot update ".concat(e));return[2]}s=JSON.parse(u.readFileSync(o,"utf-8"));s.dependencies=c(n({},s.dependencies),t({},e,r)),u.writeFileSync(o,JSON.stringify(s,null,2)),U.info("Updated ".concat(e," to version ").concat(r));return[4,V("npm i -f")];case 2:a.sent();return[4,V("npm run lint:fix")];case 3:a.sent(),U.success("".concat(e," updated successfully."));return[3,5];case 4:i=a.sent();throw U.error("Failed to update ".concat(e,": ").concat(i.message)),i;case 5:return[2]}})});return er.apply(this,arguments)}function et(e,r){try{var t=l.join(e,"package.json");return u.existsSync(t)?JSON.parse(u.readFileSync(t,"utf-8")).name===r:!1}catch(e){return U.error("Error reading package.json: ".concat(e.message)),!1}}export{H as getLatestPackageVersion,et as isCurrentProject,X as isPackageOutdated,ee as updatePackage};
|
|
1
|
+
function e(e,r,t,n,o,c,a){try{var s=e[c](a);var i=s.value}catch(e){t(e);return}if(s.done){r(i)}else{Promise.resolve(i).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,c){var a=r.apply(t,n);function s(r){e(a,o,c,s,i,"next",r)}function i(r){e(a,o,c,s,i,"throw",r)}s(undefined)})}}function t(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function n(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(r){t(e,r,n[r])})}return e}function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function c(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function a(e,r){var t,n,o,c,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return c={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function s(e){return function(r){return i([e,r])}}function i(c){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(o=c[0]&2?n["return"]:c[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;if(n=0,o)c=[c[0]&2,o.value];switch(c[0]){case 0:case 1:o=c;break;case 4:a.label++;return{value:c[1],done:false};case 5:a.label++;n=c[1];c=[0];continue;case 7:c=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){a=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(c[0]===6&&a.label<o[1]){a.label=o[1];o=c;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(c);break}if(o[2])a.ops.pop();a.trys.pop();continue}c=r.call(e,a)}catch(e){c=[6,e];n=0}finally{t=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}}import s from"node-fetch";import i from"node:fs";import u from"node:path";import{dirname as l}from"node:path";import f from"node:process";import{fileURLToPath as p}from"node:url";var g=p(import.meta.url),d=l(g),h=f.env.INIT_CWD||f.cwd();import m from"boxen";import y from"chalk";import{exec as v}from"node:child_process";import b from"node:process";import*as w from"node:util";import S from"node-persist";import O from"node:os";import k from"node:path";import j from"node:process";var E=j.env.CYBERSKILL_STORAGE_DIR||k.join(O.homedir(),".cyberskill-storage");function P(){return x.apply(this,arguments)}function x(){x=r(function(){var e;return a(this,function(r){switch(r.label){case 0:e=S.defaultInstance;if(e)return[3,2];return[4,S.init({dir:E,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return x.apply(this,arguments)}var I={get:function e(e){return r(function(){var r,t;return a(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,P()];case 1:n.sent();return[4,S.getItem(e)];case 2:return[2,(r=n.sent())!==null&&r!==void 0?r:null];case 3:t=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 4:return[2]}})})()},set:function e(e,t){return r(function(){var r;return a(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,P()];case 1:n.sent();return[4,S.setItem(e,t)];case 2:n.sent();return[3,4];case 3:r=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return r(function(){var r;return a(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,P()];case 1:t.sent();return[4,S.removeItem(e)];case 2:t.sent();return[3,4];case 3:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},keys:function e(){return r(function(){var e,r;return a(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,P()];case 1:t.sent();return[4,S.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 4:return[2]}})})()},getLogLink:function e(e){return r(function(){return a(this,function(r){try{return[2,"".concat(E," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var L=b.env.DEBUG==="true",C=w.promisify(v),N=y.gray,_=y.blue,D=function(){return N("[".concat(new Date().toLocaleTimeString(),"]"))};function F(e){var r=y[e];return typeof r=="function"?r:y.green}function T(e,r,t,n){var o=F(r);console.log("".concat(D()," ").concat(o("".concat(t," ").concat(e))," ").concat(n))}function R(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=t.color,o=n===void 0?"green":n,c=t.padding,a=c===void 0?1:c,s=t.margin,i=s===void 0?1:s,u=t.borderStyle,l=u===void 0?"round":u,f=t.titleColor,p=f===void 0?"bold":f;var g=F(o),d=F(p);if(typeof r=="string"){console.log(m(d(g("".concat(e,"\n").concat(r))),{padding:a,margin:i,borderStyle:l,borderColor:o}));return}Array.isArray(r)&&r.length&&(r.forEach(function(e){var r=e.file,t=e.position,n=e.rule,o=e.message;console.log("".concat(D()," ").concat(g("File:")," ").concat(_("".concat(r).concat(t?":".concat(t):"")))),n&&console.log(" ".concat(g("Rule:")," ").concat(g(n))),console.log(" ".concat(g("Message:")," ").concat(g(o)))}),console.log(m(d(g("".concat(e,": ").concat(r.length))),{padding:a,margin:i,borderStyle:l,borderColor:o})),console.log(N("─".repeat(40))))}var A={success:function(e){return T("SUCCESS","green","✔",e)},error:function(e){return T("ERROR","red","✖",e)},warning:function(e){return T("WARNING","yellow","⚠",e)},info:function(e){return T("INFO","blue","ℹ",e)},printBoxedLog:R},J=function(e){return"error_list:".concat(e)};function M(e){return U.apply(this,arguments)}function U(){U=r(function(e){var t,n,o;return a(this,function(c){switch(c.label){case 0:if(e.length===0)return[2];t=Date.now(),n=J(t);c.label=1;case 1:c.trys.push([1,3,,4]);return[4,I.set(n,{errors:e,timestamp:t})];case 2:c.sent(),setTimeout(/*#__PURE__*/r(function(){var e;return a(this,function(r){switch(r.label){case 0:return[4,I.getLogLink(n)];case 1:e=r.sent();e&&A.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:o=c.sent();A.error("Failed to save errors: ".concat(o.message));return[3,4];case 4:return[2]}})});return U.apply(this,arguments)}function G(e){var r=[],t=[],n="",o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,c=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,a=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))n=e.trim();else{var s=o.exec(e)||[],i=c.exec(e)||[],u=a.exec(e)||[];s.length&&n?r.push({file:n,position:"".concat(s[1],":").concat(s[2]),type:s[3]==="error"?"error":"warning",message:s[4].trim(),rule:s[5].trim()}):i.length?r.push({file:i[1],position:"".concat(i[2],":").concat(i[3]),type:i[4]==="error"?"error":"warning",message:i[5].trim()}):u.length?r.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):t.push(e.trim())}}),r.length&&M(r),t.length&&L&&(A.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function B(e){try{var r=JSON.parse(e),t=[];r.forEach(function(e){var r=e.filePath,n=e.messages;n.forEach(function(e){var n=e.severity,o=e.line,c=e.column,a=e.ruleId,s=e.message;t.push({type:n===2?"error":"warning",file:r,position:"".concat(o,":").concat(c),rule:a,message:s})})}),t.length&&M(t)}catch(r){G(e)}}function W(e){return $.apply(this,arguments)}function $(){$=r(function(e){var r,t,n,o,c,s,i,u,l;var f=arguments;return a(this,function(a){switch(a.label){case 0:r=f.length>1&&f[1]!==void 0?f[1]:B;t=new AbortController;b.on("SIGINT",function(){A.warning("Process interrupted. Terminating..."),t.abort(),b.exit()});a.label=1;case 1:a.trys.push([1,3,,4]);return[4,C(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:n=a.sent(),o=n.stdout,c=n.stderr;[o,c].forEach(function(e){return e&&r(e)});return[3,4];case 3:s=a.sent();i=s.stdout,u=s.stderr,l=s.message;[i,u].forEach(function(e){return e&&r(e)}),!u&&!i&&A.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return $.apply(this,arguments)}var K=24*60*60*1e3;function V(e){return e?u.join(h,"node_modules",e,"package.json"):u.join(h,"package.json")}function Y(e){return q.apply(this,arguments)}function q(){q=r(function(e){var r,t,n,o,c,i,u,l,f,p;var g=arguments;return a(this,function(a){switch(a.label){case 0:r=g.length>1&&g[1]!==void 0?g[1]:!1;t="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,I.get(t)];case 1:o=a.sent();return[4,I.get(n)];case 2:c=a.sent(),i=o&&Date.now()-o.timestamp<K;if(!r&&i)return[2,(A.info("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];u={};(c===null||c===void 0?void 0:c.etag)&&(u["If-None-Match"]=c.etag),(c===null||c===void 0?void 0:c.lastModified)&&(u["If-Modified-Since"]=c.lastModified);a.label=3;case 3:a.trys.push([3,8,,9]);A.info("Fetching latest version for ".concat(e,"..."));return[4,s("https://registry.npmjs.org/".concat(e,"/latest"),{headers:u})];case 4:l=a.sent();if(l.status===304&&o)return[2,(A.info("Cache is still valid for ".concat(e,": ").concat(o.version)),o.version)];if(!l.ok)throw new Error("Failed to fetch latest version: ".concat(l.statusText));return[4,l.json()];case 5:f=a.sent().version;return[4,I.set(t,{version:f,timestamp:Date.now()})];case 6:a.sent();return[4,I.set(n,{etag:l.headers.get("ETag")||void 0,lastModified:l.headers.get("Last-Modified")||void 0})];case 7:return[2,(a.sent(),A.success("Cached latest version for ".concat(e,": ").concat(f)),f)];case 8:p=a.sent();if(A.error("Error fetching latest version for ".concat(e,": ").concat(p.message)),o)return[2,(A.warning("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw p;case 9:return[2]}})});return q.apply(this,arguments)}function z(e){return H.apply(this,arguments)}function H(){H=r(function(e){var r,t,n,o,c;var s=arguments;return a(this,function(a){switch(a.label){case 0:r=s.length>1&&s[1]!==void 0?s[1]:!0;a.label=1;case 1:a.trys.push([1,3,,4]);t=V(e);if(!i.existsSync(t))return[2,(A.info("".concat(e," is not installed.")),!0)];n=JSON.parse(i.readFileSync(t,"utf-8")).version;return[4,Y(e,r)];case 2:o=a.sent();return[2,(A.info("Installed version of ".concat(e,": ").concat(n)),A.info("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:c=a.sent();return[2,(A.warning("Failed to check version for ".concat(e,": ").concat(c.message)),!0)];case 4:return[2]}})});return H.apply(this,arguments)}function Q(e){return X.apply(this,arguments)}function X(){X=r(function(e){var r,o,s,u;return a(this,function(a){switch(a.label){case 0:a.trys.push([0,4,,5]);return[4,Y(e,!0)];case 1:r=a.sent(),o=V();if(!i.existsSync(o)){A.error("package.json not found. Cannot update ".concat(e));return[2]}s=JSON.parse(i.readFileSync(o,"utf-8"));s.dependencies=c(n({},s.dependencies),t({},e,r)),i.writeFileSync(o,JSON.stringify(s,null,2)),A.info("Updated ".concat(e," to version ").concat(r));return[4,W("npm i -f")];case 2:a.sent();return[4,W("npm run lint:fix")];case 3:a.sent(),A.success("".concat(e," updated successfully."));return[3,5];case 4:u=a.sent();throw A.error("Failed to update ".concat(e,": ").concat(u.message)),u;case 5:return[2]}})});return X.apply(this,arguments)}function Z(e,r){try{var t=u.join(e,"package.json");return i.existsSync(t)?JSON.parse(i.readFileSync(t,"utf-8")).name===r:!1}catch(e){return A.error("Error reading package.json: ".concat(e.message)),!1}}export{Y as getLatestPackageVersion,Z as isCurrentProject,z as isPackageOutdated,Q as updatePackage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e,r,t,n,o,u,a){try{var c=e[u](a);var s=c.value}catch(e){t(e);return}if(c.done){r(s)}else{Promise.resolve(s).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,u){var a=r.apply(t,n);function c(r){e(a,o,u,c,s,"next",r)}function s(r){e(a,o,u,c,s,"throw",r)}c(undefined)})}}function t(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function n(e,r){var t,n,o,u,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return u={next:c(0),"throw":c(1),"return":c(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(e){return function(r){return s([e,r])}}function s(u){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(u[0]===6&&a.label<o[1]){a.label=o[1];o=u;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(u);break}if(o[2])a.ops.pop();a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e];n=0}finally{t=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}var o=Object.create;var u=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var s=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty;var l=function(e,r){for(var t in r)u(e,t,{get:r[t],enumerable:!0})},f=function(e,r,n,o){var s=true,l=false,f=undefined;if(r&&(typeof r==="undefined"?"undefined":t(r))=="object"||typeof r=="function")try{var y=function(){var t=v.value;!i.call(e,t)&&t!==n&&u(e,t,{get:function(){return r[t]},enumerable:!(o=a(r,t))||o.enumerable})};for(var p=c(r)[Symbol.iterator](),v;!(s=(v=p.next()).done);s=true)y()}catch(e){l=true;f=e}finally{try{if(!s&&p.return!=null){p.return()}}finally{if(l){throw f}}}return e};var y=function(e,r,t){return t=e!=null?o(s(e)):{},f(r||!e||!e.__esModule?u(t,"default",{value:e,enumerable:!0}):t,e)},p=function(e){return f(u({},"__esModule",{value:!0}),e)};var v={};l(v,{storageClient:function(){return h}});module.exports=p(v);var b=y(require("localforage"),1),h={get:function e(e){return r(function(){var r;return n(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,b.default.getItem(e)];case 1:return[2,t.sent()];case 2:r=t.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),r),null)];case 3:return[2]}})})()},set:function e(e,t){return r(function(){var r;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,b.default.setItem(e,t)];case 1:n.sent();return[3,3];case 2:r=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})})()},remove:function e(e){return r(function(){var r;return n(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,b.default.removeItem(e)];case 1:t.sent();return[3,3];case 2:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})})()},keys:function e(){return r(function(){var e,r;return n(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,b.default.keys()];case 1:return[2,(e=t.sent())!==null&&e!==void 0?e:[]];case 2:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 3:return[2]}})})()}};0&&(module.exports={storageClient:storageClient});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
declare const storageClient: {
|
|
2
2
|
get<T = unknown>(key: string): Promise<T | null>;
|
|
3
3
|
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
4
4
|
remove(key: string): Promise<void>;
|
|
5
5
|
keys(): Promise<string[]>;
|
|
6
|
-
getLogLink(key: string): Promise<string | null>;
|
|
7
6
|
};
|
|
8
7
|
|
|
9
|
-
export {
|
|
8
|
+
export { storageClient };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
declare const storageClient: {
|
|
2
2
|
get<T = unknown>(key: string): Promise<T | null>;
|
|
3
3
|
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
4
4
|
remove(key: string): Promise<void>;
|
|
5
5
|
keys(): Promise<string[]>;
|
|
6
|
-
getLogLink(key: string): Promise<string | null>;
|
|
7
6
|
};
|
|
8
7
|
|
|
9
|
-
export {
|
|
8
|
+
export { storageClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,r,t,n,o,u,s){try{var a=e[u](s);var c=a.value}catch(e){t(e);return}if(a.done){r(c)}else{Promise.resolve(c).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,u){var s=r.apply(t,n);function a(r){e(s,o,u,a,c,"next",r)}function c(r){e(s,o,u,a,c,"throw",r)}a(undefined)})}}function t(e,r){var t,n,o,u,s={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return u={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(e){return function(r){return c([e,r])}}function c(u){if(t)throw new TypeError("Generator is already executing.");while(s)try{if(t=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:s.label++;return{value:u[1],done:false};case 5:s.label++;n=u[1];u=[0];continue;case 7:u=s.ops.pop();s.trys.pop();continue;default:if(!(o=s.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){s=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){s.label=u[1];break}if(u[0]===6&&s.label<o[1]){s.label=o[1];o=u;break}if(o&&s.label<o[2]){s.label=o[2];s.ops.push(u);break}if(o[2])s.ops.pop();s.trys.pop();continue}u=r.call(e,s)}catch(e){u=[6,e];n=0}finally{t=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}import n from"localforage";var o={get:function e(e){return r(function(){var r;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,n.getItem(e)];case 1:return[2,t.sent()];case 2:r=t.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),r),null)];case 3:return[2]}})})()},set:function e(e,o){return r(function(){var r;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,n.setItem(e,o)];case 1:t.sent();return[3,3];case 2:r=t.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})})()},remove:function e(e){return r(function(){var r;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,n.removeItem(e)];case 1:t.sent();return[3,3];case 2:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})})()},keys:function e(){return r(function(){var e,r;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,n.keys()];case 1:return[2,(e=t.sent())!==null&&e!==void 0?e:[]];case 2:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 3:return[2]}})})()}};export{o as storageClient};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e,r,t,n,o,u,a){try{var s=e[u](a);var i=s.value}catch(e){t(e);return}if(s.done){r(i)}else{Promise.resolve(i).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,u){var a=r.apply(t,n);function s(r){e(a,o,u,s,i,"next",r)}function i(r){e(a,o,u,s,i,"throw",r)}s(undefined)})}}function t(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function n(e,r){var t,n,o,u,a={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return u={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function s(e){return function(r){return i([e,r])}}function i(u){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(o=u[0]&2?n["return"]:u[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;if(n=0,o)u=[u[0]&2,o.value];switch(u[0]){case 0:case 1:o=u;break;case 4:a.label++;return{value:u[1],done:false};case 5:a.label++;n=u[1];u=[0];continue;case 7:u=a.ops.pop();a.trys.pop();continue;default:if(!(o=a.trys,o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){a=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(u[0]===6&&a.label<o[1]){a.label=o[1];o=u;break}if(o&&a.label<o[2]){a.label=o[2];a.ops.push(u);break}if(o[2])a.ops.pop();a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e];n=0}finally{t=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}}var o=Object.create;var u=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var i=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var l=function(e,r){for(var t in r)u(e,t,{get:r[t],enumerable:!0})},f=function(e,r,n,o){var i=true,l=false,f=undefined;if(r&&(typeof r==="undefined"?"undefined":t(r))=="object"||typeof r=="function")try{var y=function(){var t=v.value;!c.call(e,t)&&t!==n&&u(e,t,{get:function(){return r[t]},enumerable:!(o=a(r,t))||o.enumerable})};for(var p=s(r)[Symbol.iterator](),v;!(i=(v=p.next()).done);i=true)y()}catch(e){l=true;f=e}finally{try{if(!i&&p.return!=null){p.return()}}finally{if(l){throw f}}}return e};var y=function(e,r,t){return t=e!=null?o(i(e)):{},f(r||!e||!e.__esModule?u(t,"default",{value:e,enumerable:!0}):t,e)},p=function(e){return f(u({},"__esModule",{value:!0}),e)};var v={};l(v,{initNodePersist:function(){return w},storageDir:function(){return m},storageServer:function(){return S}});module.exports=p(v);var g=y(require("node-persist"),1),d=y(require("os"),1),h=y(require("path"),1),b=y(require("process"),1),m=b.default.env.CYBERSKILL_STORAGE_DIR||h.default.join(d.default.homedir(),".cyberskill-storage");function w(){return k.apply(this,arguments)}function k(){k=r(function(){var e;return n(this,function(r){switch(r.label){case 0:e=g.default.defaultInstance;if(e)return[3,2];return[4,g.default.init({dir:m,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return k.apply(this,arguments)}var S={get:function e(e){return r(function(){var r,t;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,w()];case 1:n.sent();return[4,g.default.getItem(e)];case 2:return[2,(r=n.sent())!==null&&r!==void 0?r:null];case 3:t=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 4:return[2]}})})()},set:function e(e,t){return r(function(){var r;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,w()];case 1:n.sent();return[4,g.default.setItem(e,t)];case 2:n.sent();return[3,4];case 3:r=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return r(function(){var r;return n(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,w()];case 1:t.sent();return[4,g.default.removeItem(e)];case 2:t.sent();return[3,4];case 3:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},keys:function e(){return r(function(){var e,r;return n(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,w()];case 1:t.sent();return[4,g.default.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 4:return[2]}})})()},getLogLink:function e(e){return r(function(){return n(this,function(r){try{return[2,"".concat(m," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};0&&(module.exports={initNodePersist:initNodePersist,storageDir:storageDir,storageServer:storageServer});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const storageDir: string;
|
|
2
|
+
declare function initNodePersist(): Promise<void>;
|
|
3
|
+
declare const storageServer: {
|
|
4
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
5
|
+
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
6
|
+
remove(key: string): Promise<void>;
|
|
7
|
+
keys(): Promise<string[]>;
|
|
8
|
+
getLogLink(key: string): Promise<string | null>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { initNodePersist, storageDir, storageServer };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const storageDir: string;
|
|
2
|
+
declare function initNodePersist(): Promise<void>;
|
|
3
|
+
declare const storageServer: {
|
|
4
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
5
|
+
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
6
|
+
remove(key: string): Promise<void>;
|
|
7
|
+
keys(): Promise<string[]>;
|
|
8
|
+
getLogLink(key: string): Promise<string | null>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { initNodePersist, storageDir, storageServer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,r,t,n,o,s,u){try{var i=e[s](u);var a=i.value}catch(e){t(e);return}if(i.done){r(a)}else{Promise.resolve(a).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,s){var u=r.apply(t,n);function i(r){e(u,o,s,i,a,"next",r)}function a(r){e(u,o,s,i,a,"throw",r)}i(undefined)})}}function t(e,r){var t,n,o,s,u={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return s={next:i(0),"throw":i(1),"return":i(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function i(e){return function(r){return a([e,r])}}function a(s){if(t)throw new TypeError("Generator is already executing.");while(u)try{if(t=1,n&&(o=s[0]&2?n["return"]:s[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;if(n=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:u.label++;return{value:s[1],done:false};case 5:u.label++;n=s[1];s=[0];continue;case 7:s=u.ops.pop();u.trys.pop();continue;default:if(!(o=u.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){u=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){u.label=s[1];break}if(s[0]===6&&u.label<o[1]){u.label=o[1];o=s;break}if(o&&u.label<o[2]){u.label=o[2];u.ops.push(s);break}if(o[2])u.ops.pop();u.trys.pop();continue}s=r.call(e,u)}catch(e){s=[6,e];n=0}finally{t=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}}import n from"node-persist";import o from"node:os";import s from"node:path";import u from"node:process";var i=u.env.CYBERSKILL_STORAGE_DIR||s.join(o.homedir(),".cyberskill-storage");function a(){return c.apply(this,arguments)}function c(){c=r(function(){var e;return t(this,function(r){switch(r.label){case 0:e=n.defaultInstance;if(e)return[3,2];return[4,n.init({dir:i,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return c.apply(this,arguments)}var l={get:function e(e){return r(function(){var r,o;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,a()];case 1:t.sent();return[4,n.getItem(e)];case 2:return[2,(r=t.sent())!==null&&r!==void 0?r:null];case 3:o=t.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),o),null)];case 4:return[2]}})})()},set:function e(e,o){return r(function(){var r;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,a()];case 1:t.sent();return[4,n.setItem(e,o)];case 2:t.sent();return[3,4];case 3:r=t.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},remove:function e(e){return r(function(){var r;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,a()];case 1:t.sent();return[4,n.removeItem(e)];case 2:t.sent();return[3,4];case 3:r=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,4];case 4:return[2]}})})()},keys:function e(){return r(function(){var e,r;return t(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,a()];case 1:t.sent();return[4,n.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:r=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 4:return[2]}})})()},getLogLink:function e(e){return r(function(){return t(this,function(r){try{return[2,"".concat(i," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};export{a as initNodePersist,i as storageDir,l as storageServer};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberskill/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.29.0",
|
|
5
5
|
"description": "CyberSkill Shared",
|
|
6
6
|
"author": "Stephen Cheng",
|
|
7
7
|
"license": "MIT",
|
|
@@ -99,6 +99,11 @@
|
|
|
99
99
|
"import": "./dist/controllers/index.js",
|
|
100
100
|
"require": "./dist/controllers/index.cjs"
|
|
101
101
|
},
|
|
102
|
+
"./hocs/react": {
|
|
103
|
+
"types": "./dist/hocs/react/index.d.ts",
|
|
104
|
+
"import": "./dist/hocs/react/index.js",
|
|
105
|
+
"require": "./dist/hocs/react/index.cjs"
|
|
106
|
+
},
|
|
102
107
|
"./hooks/react": {
|
|
103
108
|
"types": "./dist/hooks/react/index.d.ts",
|
|
104
109
|
"import": "./dist/hooks/react/index.js",
|
|
@@ -151,20 +156,21 @@
|
|
|
151
156
|
"dependencies": {
|
|
152
157
|
"@antfu/eslint-config": "4.10.1",
|
|
153
158
|
"@apollo/client": "3.13.4",
|
|
159
|
+
"@apollo/experimental-nextjs-app-support": "0.11.11",
|
|
154
160
|
"@commitlint/cli": "19.8.0",
|
|
155
161
|
"@commitlint/config-conventional": "19.8.0",
|
|
156
|
-
"@eslint-react/eslint-plugin": "1.
|
|
162
|
+
"@eslint-react/eslint-plugin": "1.35.0",
|
|
157
163
|
"@eslint/config-inspector": "1.0.2",
|
|
158
164
|
"@graphql-codegen/cli": "5.0.5",
|
|
159
165
|
"@graphql-codegen/client-preset": "4.7.0",
|
|
160
166
|
"@graphql-codegen/typescript-react-apollo": "4.3.2",
|
|
161
|
-
"@swc/core": "1.11.
|
|
167
|
+
"@swc/core": "1.11.11",
|
|
162
168
|
"@testing-library/jest-dom": "6.6.3",
|
|
163
169
|
"@testing-library/react": "16.2.0",
|
|
164
170
|
"@types/crypto-js": "4.2.2",
|
|
165
171
|
"@types/mongoose-aggregate-paginate-v2": "1.0.12",
|
|
166
172
|
"@types/node-persist": "3.1.8",
|
|
167
|
-
"@types/react": "19.0.
|
|
173
|
+
"@types/react": "19.0.11",
|
|
168
174
|
"@types/react-dom": "19.0.4",
|
|
169
175
|
"@types/unorm": "1.3.31",
|
|
170
176
|
"@types/uuid": "10.0.0",
|
|
@@ -177,7 +183,7 @@
|
|
|
177
183
|
"crypto-js": "4.2.0",
|
|
178
184
|
"date-fns": "4.1.0",
|
|
179
185
|
"eslint": "9.22.0",
|
|
180
|
-
"eslint-config-next": "15.2.
|
|
186
|
+
"eslint-config-next": "15.2.3",
|
|
181
187
|
"eslint-plugin-format": "1.0.1",
|
|
182
188
|
"eslint-plugin-react-hooks": "5.2.0",
|
|
183
189
|
"eslint-plugin-react-refresh": "0.4.19",
|
|
@@ -190,16 +196,17 @@
|
|
|
190
196
|
"mongoose": "8.12.1",
|
|
191
197
|
"mongoose-aggregate-paginate-v2": "1.1.4",
|
|
192
198
|
"mongoose-paginate-v2": "1.9.0",
|
|
199
|
+
"next-intl": "4.0.2",
|
|
193
200
|
"node-fetch": "3.3.2",
|
|
194
201
|
"node-persist": "4.0.4",
|
|
195
202
|
"ora": "8.2.0",
|
|
196
|
-
"playwright": "1.51.
|
|
203
|
+
"playwright": "1.51.1",
|
|
197
204
|
"postcss-modules": "6.0.1",
|
|
198
205
|
"react": "19.0.0",
|
|
199
206
|
"react-dom": "19.0.0",
|
|
200
207
|
"react-i18next": "15.4.1",
|
|
201
208
|
"rimraf": "6.0.1",
|
|
202
|
-
"sass": "1.
|
|
209
|
+
"sass": "1.86.0",
|
|
203
210
|
"simple-git-hooks": "2.11.1",
|
|
204
211
|
"slugify": "1.6.6",
|
|
205
212
|
"tsup": "8.4.0",
|
package/dist/utils/storage.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e,r,t,n,u,o,a){try{var s=e[o](a);var c=s.value}catch(e){t(e);return}if(s.done){r(c)}else{Promise.resolve(c).then(n,u)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(u,o){var a=r.apply(t,n);function s(r){e(a,u,o,s,c,"next",r)}function c(r){e(a,u,o,s,c,"throw",r)}s(undefined)})}}function t(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function n(e,r){var t,n,u,o,a={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]};return o={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(r){return c([e,r])}}function c(o){if(t)throw new TypeError("Generator is already executing.");while(a)try{if(t=1,n&&(u=o[0]&2?n["return"]:o[0]?n["throw"]||((u=n["return"])&&u.call(n),0):n.next)&&!(u=u.call(n,o[1])).done)return u;if(n=0,u)o=[o[0]&2,u.value];switch(o[0]){case 0:case 1:u=o;break;case 4:a.label++;return{value:o[1],done:false};case 5:a.label++;n=o[1];o=[0];continue;case 7:o=a.ops.pop();a.trys.pop();continue;default:if(!(u=a.trys,u=u.length>0&&u[u.length-1])&&(o[0]===6||o[0]===2)){a=0;continue}if(o[0]===3&&(!u||o[1]>u[0]&&o[1]<u[3])){a.label=o[1];break}if(o[0]===6&&a.label<u[1]){a.label=u[1];u=o;break}if(u&&a.label<u[2]){a.label=u[2];a.ops.push(o);break}if(u[2])a.ops.pop();a.trys.pop();continue}o=r.call(e,a)}catch(e){o=[6,e];n=0}finally{t=u=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}}var u=Object.create;var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty;var l=function(e,r){for(var t in r)o(e,t,{get:r[t],enumerable:!0})},f=function(e,r,n,u){var c=true,l=false,f=undefined;if(r&&(typeof r==="undefined"?"undefined":t(r))=="object"||typeof r=="function")try{var y=function(){var t=p.value;!i.call(e,t)&&t!==n&&o(e,t,{get:function(){return r[t]},enumerable:!(u=a(r,t))||u.enumerable})};for(var d=s(r)[Symbol.iterator](),p;!(c=(p=d.next()).done);c=true)y()}catch(e){l=true;f=e}finally{try{if(!c&&d.return!=null){d.return()}}finally{if(l){throw f}}}return e};var y=function(e,r,t){return t=e!=null?u(c(e)):{},f(r||!e||!e.__esModule?o(t,"default",{value:e,enumerable:!0}):t,e)},d=function(e){return f(o({},"__esModule",{value:!0}),e)};var p={};l(p,{storage:function(){return I}});module.exports=d(p);var v=y(require("localforage"),1),g=y(require("node-persist"),1),h=y(require("os"),1),b=y(require("path"),1),m=y(require("process"),1),w=(typeof window==="undefined"?"undefined":t(window))<"u",k=m.default.env.CYBERSKILL_STORAGE_DIR||b.default.join(h.default.homedir(),".cyberskill-storage");function S(){return O.apply(this,arguments)}function O(){O=r(function(){var e;return n(this,function(r){switch(r.label){case 0:e=!w&&!g.default.defaultInstance;if(!e)return[3,2];return[4,g.default.init({dir:k,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return O.apply(this,arguments)}var I={get:function e(e){return r(function(){var r,t,u;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,6,,7]);if(!w)return[3,2];return[4,v.default.getItem(e)];case 1:t=n.sent();return[3,5];case 2:return[4,S()];case 3:n.sent();return[4,g.default.getItem(e)];case 4:t=(r=n.sent())!==null&&r!==void 0?r:null;n.label=5;case 5:return[2,t];case 6:u=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),u),null)];case 7:return[2]}})})()},set:function e(e,t){return r(function(){var r,u;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,6,,7]);if(!w)return[3,2];return[4,v.default.setItem(e,t)];case 1:r=n.sent();return[3,5];case 2:return[4,S()];case 3:n.sent();return[4,g.default.setItem(e,t)];case 4:r=n.sent();n.label=5;case 5:r;return[3,7];case 6:u=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),u);return[3,7];case 7:return[2]}})})()},remove:function e(e){return r(function(){var r,t;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,6,,7]);if(!w)return[3,2];return[4,v.default.removeItem(e)];case 1:r=n.sent();return[3,5];case 2:return[4,S()];case 3:n.sent();return[4,g.default.removeItem(e)];case 4:r=n.sent();n.label=5;case 5:r;return[3,7];case 6:t=n.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,7];case 7:return[2]}})})()},keys:function e(){return r(function(){var e,r,t;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,5,,6]);if(!w)return[3,2];return[4,v.default.keys()];case 1:return[2,(e=n.sent())!==null&&e!==void 0?e:[]];case 2:return[4,S()];case 3:n.sent();return[4,g.default.keys()];case 4:r=n.sent();return[2,Array.isArray(r)?r:(console.warn("⚠️ [Storage:keys] Invalid keys response:",r),[])];case 5:t=n.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",t),[])];case 6:return[2]}})})()},getLogLink:function e(e){return r(function(){return n(this,function(r){try{return[2,"".concat(k," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};0&&(module.exports={storage:storage});
|
package/dist/utils/storage.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,r,t,n,o,s,u){try{var a=e[s](u);var c=a.value}catch(e){t(e);return}if(a.done){r(c)}else{Promise.resolve(c).then(n,o)}}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,s){var u=r.apply(t,n);function a(r){e(u,o,s,a,c,"next",r)}function c(r){e(u,o,s,a,c,"throw",r)}a(undefined)})}}function t(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function n(e,r){var t,n,o,s,u={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),"throw":a(1),"return":a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(e){return function(r){return c([e,r])}}function c(s){if(t)throw new TypeError("Generator is already executing.");while(u)try{if(t=1,n&&(o=s[0]&2?n["return"]:s[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;if(n=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:u.label++;return{value:s[1],done:false};case 5:u.label++;n=s[1];s=[0];continue;case 7:s=u.ops.pop();u.trys.pop();continue;default:if(!(o=u.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){u=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){u.label=s[1];break}if(s[0]===6&&u.label<o[1]){u.label=o[1];o=s;break}if(o&&u.label<o[2]){u.label=o[2];u.ops.push(s);break}if(o[2])u.ops.pop();u.trys.pop();continue}s=r.call(e,u)}catch(e){s=[6,e];n=0}finally{t=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}}import o from"localforage";import s from"node-persist";import u from"node:os";import a from"node:path";import c from"node:process";var i=(typeof window==="undefined"?"undefined":t(window))<"u",l=c.env.CYBERSKILL_STORAGE_DIR||a.join(u.homedir(),".cyberskill-storage");function f(){return p.apply(this,arguments)}function p(){p=r(function(){var e;return n(this,function(r){switch(r.label){case 0:e=!i&&!s.defaultInstance;if(!e)return[3,2];return[4,s.init({dir:l,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=r.sent();r.label=2;case 2:e;return[2]}})});return p.apply(this,arguments)}var y={get:function e(e){return r(function(){var r,t,u;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,6,,7]);if(!i)return[3,2];return[4,o.getItem(e)];case 1:t=n.sent();return[3,5];case 2:return[4,f()];case 3:n.sent();return[4,s.getItem(e)];case 4:t=(r=n.sent())!==null&&r!==void 0?r:null;n.label=5;case 5:return[2,t];case 6:u=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),u),null)];case 7:return[2]}})})()},set:function e(e,t){return r(function(){var r,u;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,6,,7]);if(!i)return[3,2];return[4,o.setItem(e,t)];case 1:r=n.sent();return[3,5];case 2:return[4,f()];case 3:n.sent();return[4,s.setItem(e,t)];case 4:r=n.sent();n.label=5;case 5:r;return[3,7];case 6:u=n.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),u);return[3,7];case 7:return[2]}})})()},remove:function e(e){return r(function(){var r,t;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,6,,7]);if(!i)return[3,2];return[4,o.removeItem(e)];case 1:r=n.sent();return[3,5];case 2:return[4,f()];case 3:n.sent();return[4,s.removeItem(e)];case 4:r=n.sent();n.label=5;case 5:r;return[3,7];case 6:t=n.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,7];case 7:return[2]}})})()},keys:function e(){return r(function(){var e,r,t;return n(this,function(n){switch(n.label){case 0:n.trys.push([0,5,,6]);if(!i)return[3,2];return[4,o.keys()];case 1:return[2,(e=n.sent())!==null&&e!==void 0?e:[]];case 2:return[4,f()];case 3:n.sent();return[4,s.keys()];case 4:r=n.sent();return[2,Array.isArray(r)?r:(console.warn("⚠️ [Storage:keys] Invalid keys response:",r),[])];case 5:t=n.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",t),[])];case 6:return[2]}})})()},getLogLink:function e(e){return r(function(){return n(this,function(r){try{return[2,"".concat(l," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};export{y as storage};
|