@cyberskill/shared 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/commands.cjs +1 -1
  2. package/dist/commands.js +1 -1
  3. package/dist/configs/index.cjs +1 -1
  4. package/dist/configs/index.js +1 -1
  5. package/dist/controllers/index.cjs +1 -1
  6. package/dist/controllers/index.js +1 -1
  7. package/dist/controllers/mongoose.cjs +1 -1
  8. package/dist/controllers/mongoose.js +1 -1
  9. package/dist/hooks/react/index.cjs +1 -1
  10. package/dist/hooks/react/index.js +1 -1
  11. package/dist/hooks/react/useLocalStorage.cjs +1 -1
  12. package/dist/hooks/react/useLocalStorage.js +1 -1
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.d.cts +7 -2
  15. package/dist/index.d.ts +7 -2
  16. package/dist/index.js +1 -1
  17. package/dist/typescript/command.d.cts +7 -1
  18. package/dist/typescript/command.d.ts +7 -1
  19. package/dist/typescript/index.d.cts +1 -1
  20. package/dist/typescript/index.d.ts +1 -1
  21. package/dist/utils/command-error.cjs +1 -0
  22. package/dist/utils/command-error.d.cts +18 -0
  23. package/dist/utils/command-error.d.ts +18 -0
  24. package/dist/utils/command-error.js +1 -0
  25. package/dist/utils/command-log.cjs +1 -0
  26. package/dist/utils/command-log.d.cts +3 -0
  27. package/dist/utils/command-log.d.ts +3 -0
  28. package/dist/utils/command-log.js +1 -0
  29. package/dist/utils/command-spinner.cjs +1 -0
  30. package/dist/utils/command-spinner.d.cts +11 -0
  31. package/dist/utils/command-spinner.d.ts +11 -0
  32. package/dist/utils/command-spinner.js +1 -0
  33. package/dist/utils/command.cjs +1 -0
  34. package/dist/utils/command.d.cts +5 -0
  35. package/dist/utils/command.d.ts +5 -0
  36. package/dist/utils/command.js +1 -0
  37. package/dist/utils/index.cjs +1 -1
  38. package/dist/utils/index.d.cts +7 -1
  39. package/dist/utils/index.d.ts +7 -1
  40. package/dist/utils/index.js +1 -1
  41. package/dist/utils/npm-package.cjs +1 -0
  42. package/dist/utils/npm-package.d.cts +15 -0
  43. package/dist/utils/npm-package.d.ts +15 -0
  44. package/dist/utils/npm-package.js +1 -0
  45. package/package.json +1 -2
  46. package/dist/cyberskill-shared-1.6.0.tgz +0 -0
  47. /package/dist/utils/{localStorage.cjs → local-storage.cjs} +0 -0
  48. /package/dist/utils/{localStorage.d.cts → local-storage.d.cts} +0 -0
  49. /package/dist/utils/{localStorage.d.ts → local-storage.d.ts} +0 -0
  50. /package/dist/utils/{localStorage.js → local-storage.js} +0 -0
@@ -0,0 +1,15 @@
1
+ declare function getLatestPackageVersion(packageName: string, forceRefresh?: boolean): Promise<string>;
2
+ /**
3
+ * Check if the installed package is outdated.
4
+ * @param packageName Name of the package.
5
+ * @param forceRefresh Whether to bypass cache and force refresh.
6
+ * @returns True if the installed version is different from the latest version.
7
+ */
8
+ declare function isPackageOutdated(packageName: string, forceRefresh?: boolean): Promise<boolean>;
9
+ /**
10
+ * Update the specified package to the latest version.
11
+ * @param packageName Name of the package.
12
+ */
13
+ declare function updatePackage(packageName: string): Promise<void>;
14
+
15
+ export { getLatestPackageVersion, isPackageOutdated, updatePackage };
@@ -0,0 +1,15 @@
1
+ declare function getLatestPackageVersion(packageName: string, forceRefresh?: boolean): Promise<string>;
2
+ /**
3
+ * Check if the installed package is outdated.
4
+ * @param packageName Name of the package.
5
+ * @param forceRefresh Whether to bypass cache and force refresh.
6
+ * @returns True if the installed version is different from the latest version.
7
+ */
8
+ declare function isPackageOutdated(packageName: string, forceRefresh?: boolean): Promise<boolean>;
9
+ /**
10
+ * Update the specified package to the latest version.
11
+ * @param packageName Name of the package.
12
+ */
13
+ declare function updatePackage(packageName: string): Promise<void>;
14
+
15
+ export { getLatestPackageVersion, isPackageOutdated, updatePackage };
@@ -0,0 +1 @@
1
+ function e(e,t,r,n,o,s,c){try{var a=e[s](c);var i=a.value}catch(e){r(e);return}if(a.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,s){var c=t.apply(r,n);function a(t){e(c,o,s,a,i,"next",t)}function i(t){e(c,o,s,a,i,"throw",t)}a(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 s(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,t){var r,n,o,s,c={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(t){return i([e,t])}}function i(s){if(r)throw new TypeError("Generator is already executing.");while(c)try{if(r=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:c.label++;return{value:s[1],done:false};case 5:c.label++;n=s[1];s=[0];continue;case 7:s=c.ops.pop();c.trys.pop();continue;default:if(!(o=c.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){c=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){c.label=s[1];break}if(s[0]===6&&c.label<o[1]){c.label=o[1];o=s;break}if(o&&c.label<o[2]){c.label=o[2];c.ops.push(s);break}if(o[2])c.ops.pop();c.trys.pop();continue}s=t.call(e,c)}catch(e){s=[6,e];n=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}}import a from"node-fetch";import i from"node:fs";import u from"node:path";import l from"node:process";import f from"chalk";import{exec as p}from"node:child_process";import h from"node:process";import*as g from"node:util";import d from"localforage";var v={get:function e(e){return t(function(){var t;return c(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,d.getItem(e)];case 1:return[2,r.sent()];case 2:t=r.sent();return[2,(console.error('Error getting key "'.concat(e,'":'),t),null)];case 3:return[2]}})})()},set:function e(e,r){return t(function(){var t;return c(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,d.setItem(e,r)];case 1:n.sent();return[3,3];case 2:t=n.sent();console.error('Error setting key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})})()},remove:function e(e){return t(function(){var t;return c(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,d.removeItem(e)];case 1:r.sent();return[3,3];case 2:t=r.sent();console.error('Error removing key "'.concat(e,'":'),t);return[3,3];case 3:return[2]}})})()},clear:function e(){return t(function(){var e;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,d.clear()];case 1:t.sent();return[3,3];case 2:e=t.sent();console.error("Error clearing storage:",e);return[3,3];case 3:return[2]}})})()},key:function e(e){return t(function(){var t;return c(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,d.key(e)];case 1:return[2,r.sent()];case 2:t=r.sent();return[2,(console.error("Error getting key at index ".concat(e,":"),t),null)];case 3:return[2]}})})()},keys:function e(){return t(function(){var e;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,d.keys()];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error("Error getting keys:",e),[])];case 3:return[2]}})})()},length:function e(){return t(function(){var e;return c(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,d.length()];case 1:return[2,t.sent()];case 2:e=t.sent();return[2,(console.error("Error getting storage length:",e),0)];case 3:return[2]}})})()},iterate:function e(e){return t(function(){var t;return c(this,function(r){switch(r.label){case 0:r.trys.push([0,2,,3]);return[4,d.iterate(e)];case 1:r.sent();return[3,3];case 2:t=r.sent();console.error("Error iterating storage:",t);return[3,3];case 3:return[2]}})})()}};var y=function(e){return"error_list:".concat(e)},m=24*60*60*1e3;function b(e){return w.apply(this,arguments)}function w(){w=t(function(e){var t,r,n;return c(this,function(o){switch(o.label){case 0:if(!e.length)return[2];t=Date.now(),r=y(t);o.label=1;case 1:o.trys.push([1,3,,4]);return[4,v.set(r,{errors:e,timestamp:t})];case 2:o.sent(),console.log("✅ Saved ".concat(e.length," errors to storage with key: ").concat(r));return[3,4];case 3:n=o.sent();console.error("❌ Failed to save errors: ".concat(n.message));return[3,4];case 4:return[2]}})});return w.apply(this,arguments)}var O=g.promisify(p),k=f.gray,S=f.white,j=[];function E(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";var r=new Date().toLocaleString();console.log("".concat(t," [").concat(r,"] ").concat(S(e)))}function P(e){var t=/^\s*(\d+):(\d+)\s+(error|warning)\s+(\S+)\s+(\S+)$/,r=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,n=/^✖\s+(.*?)\s+\[(.*?)\]$/,o=[],s="";e.split("\n").forEach(function(e){if(e.startsWith("/"))s=e.trim();else{var c=t.exec(e);if(c&&s)j.push({file:s,position:"".concat(c[1],":").concat(c[2]),type:c[3]==="error"?"error":"warning",message:c[4].trim(),rule:c[5].trim()});else{var a=r.exec(e);if(a)j.push({file:a[1],position:"".concat(a[2],":").concat(a[3]),type:a[4],message:a[5].trim()});else{var i=n.exec(e);i?j.push({file:"commitlint",type:"error",message:i[1].trim(),rule:i[2].trim()}):o.push(e.trim())}}}}),o.length>0&&(console.log(k("Unmatched lines:")),o.forEach(function(e){return console.info(e)}))}function x(e){try{JSON.parse(e).forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,n=e.line,o=e.column,s=e.ruleId,c=e.message;j.push({type:r===2?"error":"warning",file:t,position:"".concat(n,":").concat(o),rule:s,message:c})})})}catch(t){P(e)}}function F(e,t){return I.apply(this,arguments)}function I(){I=t(function(e,t){var r,n,o,s,a,i,u;var l=arguments;return c(this,function(c){switch(c.label){case 0:r=l.length>2&&l[2]!==void 0?l[2]:x;E(t);n=new AbortController;h.on("SIGINT",function(){console.log("Terminating process..."),n.abort(),h.exit()});c.label=1;case 1:c.trys.push([1,5,,6]);return[4,O(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:o=c.sent(),s=o.stdout,a=o.stderr;[s,a].forEach(function(e){return e&&r(e)});i=j.length;if(!i)return[3,4];return[4,b(j)];case 3:i=c.sent();c.label=4;case 4:i;return[3,6];case 5:u=c.sent();console.error("Command failed: ".concat(u.message));return[3,6];case 6:return[2]}})});return I.apply(this,arguments)}var D=24*60*60*1e3;function M(e){return N.apply(this,arguments)}function N(){N=t(function(e){var t,r,n,o,s,i,u,l,f,p;var h=arguments;return c(this,function(c){switch(c.label){case 0:t=h.length>1&&h[1]!==void 0?h[1]:!1;r="npm_version:".concat(e),n="npm_metadata:".concat(e);return[4,v.get(r)];case 1:o=c.sent();return[4,v.get(n)];case 2:s=c.sent(),i=o&&Date.now()-o.timestamp<D;if(!t&&i)return[2,(console.log("Using cached version for ".concat(e,": ").concat(o.version)),o.version)];u={};(s===null||s===void 0?void 0:s.etag)&&(u["If-None-Match"]=s.etag),(s===null||s===void 0?void 0:s.lastModified)&&(u["If-Modified-Since"]=s.lastModified);c.label=3;case 3:c.trys.push([3,8,,9]);console.log("Fetching latest version for ".concat(e,"..."));return[4,a("https://registry.npmjs.org/".concat(e,"/latest"),{headers:u})];case 4:l=c.sent();if(l.status===304&&o)return[2,(console.log("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=c.sent().version;return[4,v.set(r,{version:f,timestamp:Date.now()})];case 6:c.sent();return[4,v.set(n,{etag:l.headers.get("ETag")||void 0,lastModified:l.headers.get("Last-Modified")||void 0})];case 7:return[2,(c.sent(),console.log("Cached latest version for ".concat(e,": ").concat(f)),f)];case 8:p=c.sent();if(console.error("Error fetching latest version for ".concat(e,": ").concat(p.message)),o)return[2,(console.warn("Falling back to cached version for ".concat(e,": ").concat(o.version)),o.version)];throw p;case 9:return[2]}})});return N.apply(this,arguments)}function T(e){return u.join(l.cwd(),"node_modules",e,"package.json")}function _(){return u.join(l.cwd(),"package.json")}function C(e){return J.apply(this,arguments)}function J(){J=t(function(e){var t,r,n,o,s;var a=arguments;return c(this,function(c){switch(c.label){case 0:t=a.length>1&&a[1]!==void 0?a[1]:!0;c.label=1;case 1:c.trys.push([1,3,,4]);r=T(e);if(!i.existsSync(r))return[2,(console.log("".concat(e," is not installed.")),!0)];n=JSON.parse(i.readFileSync(r,"utf-8")).version;return[4,M(e,t)];case 2:o=c.sent();return[2,(console.log("Installed version of ".concat(e,": ").concat(n)),console.log("Latest version of ".concat(e,": ").concat(o)),n!==o)];case 3:s=c.sent();return[2,(console.warn("Failed to check version for ".concat(e,": ").concat(s.message)),!0)];case 4:return[2]}})});return J.apply(this,arguments)}function L(e){return U.apply(this,arguments)}function U(){U=t(function(e){var t,o,a,u;return c(this,function(c){switch(c.label){case 0:c.trys.push([0,4,,5]);return[4,M(e,!0)];case 1:t=c.sent(),o=_(),a=JSON.parse(i.readFileSync(o,"utf-8"));a.dependencies=s(n({},a.dependencies),r({},e,t)),i.writeFileSync(o,JSON.stringify(a,null,2)),console.log("Updated ".concat(e," to version ").concat(t));return[4,F("npm i -f","Installing all dependencies with updated ".concat(e,"..."))];case 2:c.sent();return[4,F("npm run lint:fix","Fixing lint issues for ".concat(e,"..."))];case 3:c.sent(),console.log("".concat(e," updated successfully."));return[3,5];case 4:u=c.sent();throw console.error("Failed to update ".concat(e,": ").concat(u.message)),u;case 5:return[2]}})});return U.apply(this,arguments)}export{M as getLatestPackageVersion,C as isPackageOutdated,L as updatePackage};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cyberskill/shared",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "1.6.1",
5
5
  "description": "CyberSkill Shared",
6
6
  "author": "Stephen Cheng",
7
7
  "license": "MIT",
@@ -145,7 +145,6 @@
145
145
  "lint": "npx tsx src/commands.ts lint",
146
146
  "lint:fix": "npx tsx src/commands.ts lint:fix",
147
147
  "lint:inspect": "npx @eslint/config-inspector",
148
- "release": "semantic-release",
149
148
  "reset": "npx tsx src/commands.ts reset",
150
149
  "setup": "npx tsx src/commands.ts setup"
151
150
  },
Binary file