@night-slayer18/leetcode-cli 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -239,9 +239,9 @@ Please create a new repository on your Git provider and copy the URL.`));let{url
|
|
|
239
239
|
`).length;console.log(),console.log(l.bold(`\u{1F4CA} Unified Diff: ${t} \u2192 ${n}`)),console.log(l.gray("\u2500".repeat(60))),console.log();let i=diffLines(e,o),a=0,c=0;for(let g of i){let u=g.value.split(`
|
|
240
240
|
`).filter(p=>p!=="");if(g.added){a+=u.length;for(let p of u)console.log(l.green("+ "+p));}else if(g.removed){c+=u.length;for(let p of u)console.log(l.red("- "+p));}else if(u.length<=6)for(let p of u)console.log(l.gray(" "+p));else console.log(l.gray(" "+u[0])),console.log(l.gray(" "+u[1])),console.log(l.dim(` ... (${u.length-4} unchanged lines)`)),console.log(l.gray(" "+u[u.length-2])),console.log(l.gray(" "+u[u.length-1]));}console.log(),console.log(l.gray("\u2500".repeat(60))),console.log(`${l.green("+"+a+" added")} ${l.gray("\xB7")} ${l.red("-"+c+" removed")} ${l.gray("\xB7")} ${l.gray(s+" \u2192 "+r+" lines")}`);}function ro(e,o,t,n,s){if(s)cr(e,o,t,n);else {Kt(e,t),Kt(o,n);let r=diffLines(e,o),i=0,a=0;for(let c of r){let g=c.value.split(`
|
|
241
241
|
`).filter(u=>u!=="");c.added?i+=g.length:c.removed&&(a+=g.length);}console.log(),console.log(l.gray("\u2500".repeat(60))),console.log(`${l.bold("Summary:")} ${l.green("+"+i+" added")} ${l.gray("\xB7")} ${l.red("-"+a+" removed")}`),console.log(l.gray("Tip: Use --unified for line-by-line diff"));}}async function Zt(e,o){let{authorized:t}=await $();if(!t)return;let n=w.getWorkDir(),s=Ue("Finding solution file...").start();try{let r=await H(n,e);if(!r){s.fail(`No solution file found for problem ${e}`),console.log(l.gray("Run `leetcode pick "+e+"` first to create a solution file."));return}let i=await readFile(r,"utf-8");if(s.text="Fetching comparison target...",o.file){if(s.stop(),!existsSync(o.file)){console.log(l.red(`File not found: ${o.file}`));return}if(!de(o.file,n)){console.log(l.red("\u26A0\uFE0F Security Error: File path is outside the configured workspace")),console.log(l.gray(`File: ${o.file}`)),console.log(l.gray(`Workspace: ${n}`)),console.log(l.yellow(`
|
|
242
|
-
For security reasons, you can only diff files from within your workspace.`));return}let p=await readFile(o.file,"utf-8");ro(i,p,"Your Solution",o.file,o.unified??!1);return}let a=await h.getProblemById(e);if(!a){s.fail(`Problem ${e} not found`);return}if(o.submission){let p=parseInt(o.submission,10),b=await h.getSubmissionDetails(p);s.stop(),ro(i,b.code,"Your Solution",`Submission #${p}`,o.unified??!1);return}let g=(await h.getSubmissionList(a.titleSlug,50)).find(p=>p.statusDisplay==="Accepted");if(!g){s.fail("No accepted submissions found for this problem"),console.log(l.gray("Tip: Use --file to compare with a local file instead"));return}let u=await h.getSubmissionDetails(parseInt(g.id,10));s.stop(),ro(i,u.code,"Your Solution","Last Accepted",o.unified??!1);}catch(r){s.fail("Failed to diff"),r instanceof Error&&console.log(l.red(r.message));}}async function en(){let e=k.getActive(),o=k.getConfig(e);console.log(),console.log(l.bold.cyan(`\u{1F4C1} Active Workspace: ${e}`)),console.log(l.gray("\u2500".repeat(40))),console.log(` workDir: ${l.white(o.workDir)}`),console.log(` lang: ${l.white(o.lang)}`),o.editor&&console.log(` editor: ${l.white(o.editor)}`),o.syncRepo&&console.log(` syncRepo: ${l.white(o.syncRepo)}`),console.log();}async function on(){let e=k.list(),o=k.getActive();console.log(),console.log(l.bold("Workspaces:")),console.log();for(let t of e){let n=k.getConfig(t),s=t===o?l.green("\u25B8 "):" ",r=t===o?l.green.bold(t):t;console.log(`${s}${r}`),console.log(` ${l.gray(n.workDir)}`);}console.log();}async function tn(e,o){if(k.exists(e)){console.log(l.red(`Workspace "${e}" already exists`));return}let t=o.workdir??join(homedir(),"leetcode",e),n={workDir:t,lang:"typescript"};k.create(e,n)?(console.log(l.green(`\u2713 Created workspace "${e}"`)),console.log(` workDir: ${l.gray(t)}`),console.log(),console.log(l.gray(`Switch to it: leetcode workspace use ${e}`))):console.log(l.red("Failed to create workspace"));}async function nn(e){if(!k.exists(e)){console.log(l.red(`Workspace "${e}" not found`)),console.log(l.gray("Use `leetcode workspace list` to see available workspaces"));return}if(k.setActive(e)){let t=k.getConfig(e);console.log(l.green(`\u2713 Switched to workspace "${e}"`)),console.log(` workDir: ${l.gray(t.workDir)}`);}else console.log(l.red("Failed to switch workspace"));}async function sn(e){if(e==="default"){console.log(l.red("Cannot delete the default workspace"));return}if(!k.exists(e)){console.log(l.red(`Workspace "${e}" not found`));return}let{confirmed:o}=await to.prompt([{type:"confirm",name:"confirmed",message:`Delete workspace "${e}"? (files in workDir will NOT be deleted)`,default:false}]);if(!o){console.log(l.gray("Cancelled"));return}let t=k.delete(e);console.log(t?l.green(`\u2713 Deleted workspace "${e}"`):l.red("Failed to delete workspace"));}var io=join(homedir(),".leetcode"),Pe=join(io,"version-cache.json"),br=1440*60*1e3;function wr(){existsSync(io)||mkdirSync(io,{recursive:true});}function rn(){if(existsSync(Pe))try{return JSON.parse(readFileSync(Pe,"utf-8"))}catch{return null}return null}function Sr(e){wr(),writeFileSync(Pe,JSON.stringify(e,null,2));}var re={shouldCheck(){let e=rn();return e?Date.now()-e.lastCheck>br:true},getCached(){return rn()},updateCache(e,o){Sr({lastCheck:Date.now(),latestVersion:e,hasBreakingChanges:o});},clearCache(){existsSync(Pe)&&unlinkSync(Pe);}};function he(e,o){let t=e.replace("v","").split(".").map(Number),n=o.replace("v","").split(".").map(Number);for(let s=0;s<3;s++){let r=t[s]||0,i=n[s]||0;if(r>i)return true;if(r<i)return false}return false}function ln(e,o){let t=parseInt(e.replace("v","").split(".")[0])||0;return (parseInt(o.replace("v","").split(".")[0])||0)>t}var Tr=fileURLToPath(import.meta.url),gn=dirname(Tr),Dr="https://registry.npmjs.org/@night-slayer18/leetcode-cli/latest",xr="@night-slayer18/leetcode-cli";function be(){let e=[join(gn,"../package.json"),join(gn,"../../package.json")];for(let o of e)try{let t=JSON.parse(readFileSync(o,"utf-8"));if(t.version)return t.version}catch{continue}throw new Error("Could not read package.json version. Ensure you are running from a valid installation.")}async function dn(){let o=(await kn(Dr,{timeout:{request:1e4},retry:{limit:2}}).json()).version,t=be(),n=ln(t,o);return {version:o,hasBreakingChanges:n}}function Er(e,o,t){console.log();let n=60,s="\u256D"+"\u2500".repeat(n-2)+"\u256E",r="\u2570"+"\u2500".repeat(n-2)+"\u256F";console.log(l.cyan(s));let i=` \u{1F680} Update available: ${l.gray(e)} \u2192 ${l.green(o)}`;if(console.log(l.cyan("\u2502")+i.padEnd(n+18)+l.cyan("\u2502")),t){console.log(l.cyan("\u2502")+"".padEnd(n-2)+l.cyan("\u2502"));let c=` ${l.yellow("\u26A0\uFE0F This update contains breaking changes!")}`;console.log(l.cyan("\u2502")+c.padEnd(n+20)+l.cyan("\u2502"));let g=` ${l.gray("Run:")} leetcode changelog ${l.gray("to review changes")}`;console.log(l.cyan("\u2502")+g.padEnd(n+16)+l.cyan("\u2502"));}console.log(l.cyan("\u2502")+"".padEnd(n-2)+l.cyan("\u2502"));let a=` ${l.gray("Run:")} npm update -g ${xr}`;console.log(l.cyan("\u2502")+a.padEnd(n+8)+l.cyan("\u2502")),console.log(l.cyan(r)),console.log();}async function un(e){let o=be();e.force&&re.clearCache();let t=re.getCached(),n,s;if(t&&!re.shouldCheck()&&!e.force)n=t.latestVersion,s=t.hasBreakingChanges;else {let r=Ue("Checking for updates...").start();try{let i=await dn();n=i.version,s=i.hasBreakingChanges,re.updateCache(n,s),r.stop();}catch(i){r.fail("Failed to check for updates"),process.env.DEBUG&&console.log(l.gray(` Debug: ${i instanceof Error?i.message:String(i)}`)),console.log(l.gray(" Could not reach npm registry. Check your internet connection."));return}}he(o
|
|
243
|
-
`)))):(console.log(),console.log(l.green("\u2713")+` You're on the latest version (${l.cyan(o)})`),console.log());}async function pn(){if(!re.shouldCheck()){let e=re.getCached();e&&he(
|
|
244
|
-
`),r=false;for(let i of s)if(!(i.trim()===""&&!r)){if(i.startsWith("> **Release Date**")){let a=i.replace("> **Release Date**: ","").trim();console.log(l.gray(` \u{1F4C5} ${a}`));continue}if(i.startsWith("> **Focus**")){let a=i.replace("> **Focus**: ","").trim();console.log(l.gray(` \u{1F3AF} ${a}`)),console.log();continue}if(i.startsWith("### ")){let a=i.replace("### ","").trim();if(console.log(),/^[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u.test(a))console.log(l.bold.yellow(` ${a}`));else {let g="\u{1F4CC}";a.includes("Breaking")?g="\u26A0\uFE0F":a.includes("Feature")||a.includes("New")?g="\u{1F680}":a.includes("Fix")||a.includes("Bug")?g="\u{1F41B}":a.includes("Security")?g="\u{1F512}":a.includes("Improvement")?g="\u2728":a.includes("Architecture")?g="\u{1F3D7}\uFE0F":a.includes("Testing")?g="\u{1F9EA}":a.includes("Config")&&(g="\u2699\uFE0F"),console.log(l.bold.yellow(` ${g} ${a}`));}r=true;continue}if(i.startsWith("#### ")){let a=i.replace("#### ","").trim();console.log(l.bold.white(` ${a}`));continue}if(i.startsWith("- **")){let a=i.match(/^- \*\*(.+?)\*\*:?\s*(.*)/);console.log(a?l.cyan(` \u2022 ${l.bold(a[1])}`)+(a[2]?l.white(`: ${a[2]}`):""):l.cyan(` \u2022 ${i.replace("- ","")}`));continue}if(i.startsWith("- ")){let a=i.replace("- ","").trim();console.log(l.white(` \u2022 ${a}`));continue}i.startsWith("---")||i.trim()===">"||i.trim()&&console.log(l.gray(` ${i.trim()}`));}}async function hn(e,o={}){let t=Ue("Fetching changelog...").start();try{let n=await jr();t.stop();let s=Mr(n);if(s.length===0){console.log(l.yellow("No release entries found."));return}let r=Ur(),i=s;if(e){let a=e.startsWith("v")?e:`v${e}`;if(i=s.filter(c=>c.version===a),i.length===0){console.log(l.red(`Version ${e} not found in changelog.`)),console.log(l.gray("Available versions: "+s.map(c=>c.version).join(", ")));return}}else if(o.latest)i=s.slice(0,1);else if(o.breaking){if(i=s.filter(a=>a.hasBreakingChanges),i.length===0){console.log(l.green("\u2713 No breaking changes in any release."));return}}else if(o.all)i=s;else {if(i=s.filter(a=>he(a.version,r)),i.length===0){console.log(l.green(`\u2713 You're on the latest version (${r})`)),console.log(l.gray("Use --all to see the full changelog."));return}console.log(l.gray(`Showing changes since your version (${r})`)),console.log(l.gray("Use --all to see the full changelog."));}console.log(),console.log(l.bold.cyan("\u{1F4CB} LeetCode CLI Release Notes")),console.log(l.gray("\u2500".repeat(50))),console.log();for(let a of i)qr(a.version,a.content,a.hasBreakingChanges),console.log(l.gray("\u2500".repeat(60))),console.log();if(!e&&!o.latest){let a=s.filter(c=>c.hasBreakingChanges).length;console.log(l.gray(`Showing ${i.length} of ${s.length} releases`)),a>0&&!o.breaking&&console.log(l.yellow(`${a} release(s) contain breaking changes. Use --breaking to filter.`));}}catch{t.fail("Failed to fetch changelog"),console.log(l.gray(" Could not fetch release notes from GitHub.")),console.log(l.gray(" Visit: https://github.com/night-slayer18/leetcode-cli/blob/main/docs/releases.md"));}}var C=new Command;C.configureHelp({sortSubcommands:true,subcommandTerm:e=>{let o=e.name(),t=e.alias(),n=t?`${o}|${t}`:o;return l.cyan(n.padEnd(16))},subcommandDescription:e=>l.white(e.description()),optionTerm:e=>l.yellow(e.flags),optionDescription:e=>l.white(e.description)});C.name("leetcode").usage("[command] [options]").description(l.bold.cyan("\u{1F525} A modern LeetCode CLI built with TypeScript")).version("2.2.
|
|
242
|
+
For security reasons, you can only diff files from within your workspace.`));return}let p=await readFile(o.file,"utf-8");ro(i,p,"Your Solution",o.file,o.unified??!1);return}let a=await h.getProblemById(e);if(!a){s.fail(`Problem ${e} not found`);return}if(o.submission){let p=parseInt(o.submission,10),b=await h.getSubmissionDetails(p);s.stop(),ro(i,b.code,"Your Solution",`Submission #${p}`,o.unified??!1);return}let g=(await h.getSubmissionList(a.titleSlug,50)).find(p=>p.statusDisplay==="Accepted");if(!g){s.fail("No accepted submissions found for this problem"),console.log(l.gray("Tip: Use --file to compare with a local file instead"));return}let u=await h.getSubmissionDetails(parseInt(g.id,10));s.stop(),ro(i,u.code,"Your Solution","Last Accepted",o.unified??!1);}catch(r){s.fail("Failed to diff"),r instanceof Error&&console.log(l.red(r.message));}}async function en(){let e=k.getActive(),o=k.getConfig(e);console.log(),console.log(l.bold.cyan(`\u{1F4C1} Active Workspace: ${e}`)),console.log(l.gray("\u2500".repeat(40))),console.log(` workDir: ${l.white(o.workDir)}`),console.log(` lang: ${l.white(o.lang)}`),o.editor&&console.log(` editor: ${l.white(o.editor)}`),o.syncRepo&&console.log(` syncRepo: ${l.white(o.syncRepo)}`),console.log();}async function on(){let e=k.list(),o=k.getActive();console.log(),console.log(l.bold("Workspaces:")),console.log();for(let t of e){let n=k.getConfig(t),s=t===o?l.green("\u25B8 "):" ",r=t===o?l.green.bold(t):t;console.log(`${s}${r}`),console.log(` ${l.gray(n.workDir)}`);}console.log();}async function tn(e,o){if(k.exists(e)){console.log(l.red(`Workspace "${e}" already exists`));return}let t=o.workdir??join(homedir(),"leetcode",e),n={workDir:t,lang:"typescript"};k.create(e,n)?(console.log(l.green(`\u2713 Created workspace "${e}"`)),console.log(` workDir: ${l.gray(t)}`),console.log(),console.log(l.gray(`Switch to it: leetcode workspace use ${e}`))):console.log(l.red("Failed to create workspace"));}async function nn(e){if(!k.exists(e)){console.log(l.red(`Workspace "${e}" not found`)),console.log(l.gray("Use `leetcode workspace list` to see available workspaces"));return}if(k.setActive(e)){let t=k.getConfig(e);console.log(l.green(`\u2713 Switched to workspace "${e}"`)),console.log(` workDir: ${l.gray(t.workDir)}`);}else console.log(l.red("Failed to switch workspace"));}async function sn(e){if(e==="default"){console.log(l.red("Cannot delete the default workspace"));return}if(!k.exists(e)){console.log(l.red(`Workspace "${e}" not found`));return}let{confirmed:o}=await to.prompt([{type:"confirm",name:"confirmed",message:`Delete workspace "${e}"? (files in workDir will NOT be deleted)`,default:false}]);if(!o){console.log(l.gray("Cancelled"));return}let t=k.delete(e);console.log(t?l.green(`\u2713 Deleted workspace "${e}"`):l.red("Failed to delete workspace"));}var io=join(homedir(),".leetcode"),Pe=join(io,"version-cache.json"),br=1440*60*1e3;function wr(){existsSync(io)||mkdirSync(io,{recursive:true});}function rn(){if(existsSync(Pe))try{return JSON.parse(readFileSync(Pe,"utf-8"))}catch{return null}return null}function Sr(e){wr(),writeFileSync(Pe,JSON.stringify(e,null,2));}var re={shouldCheck(){let e=rn();return e?Date.now()-e.lastCheck>br:true},getCached(){return rn()},updateCache(e,o){Sr({lastCheck:Date.now(),latestVersion:e,hasBreakingChanges:o});},clearCache(){existsSync(Pe)&&unlinkSync(Pe);}};function he(e,o){let t=e.replace("v","").split(".").map(Number),n=o.replace("v","").split(".").map(Number);for(let s=0;s<3;s++){let r=t[s]||0,i=n[s]||0;if(r>i)return true;if(r<i)return false}return false}function ln(e,o){let t=parseInt(e.replace("v","").split(".")[0])||0;return (parseInt(o.replace("v","").split(".")[0])||0)>t}var Tr=fileURLToPath(import.meta.url),gn=dirname(Tr),Dr="https://registry.npmjs.org/@night-slayer18/leetcode-cli/latest",xr="@night-slayer18/leetcode-cli";function be(){let e=[join(gn,"../package.json"),join(gn,"../../package.json")];for(let o of e)try{let t=JSON.parse(readFileSync(o,"utf-8"));if(t.version)return t.version}catch{continue}throw new Error("Could not read package.json version. Ensure you are running from a valid installation.")}async function dn(){let o=(await kn(Dr,{timeout:{request:1e4},retry:{limit:2}}).json()).version,t=be(),n=ln(t,o);return {version:o,hasBreakingChanges:n}}function Er(e,o,t){console.log();let n=60,s="\u256D"+"\u2500".repeat(n-2)+"\u256E",r="\u2570"+"\u2500".repeat(n-2)+"\u256F";console.log(l.cyan(s));let i=` \u{1F680} Update available: ${l.gray(e)} \u2192 ${l.green(o)}`;if(console.log(l.cyan("\u2502")+i.padEnd(n+18)+l.cyan("\u2502")),t){console.log(l.cyan("\u2502")+"".padEnd(n-2)+l.cyan("\u2502"));let c=` ${l.yellow("\u26A0\uFE0F This update contains breaking changes!")}`;console.log(l.cyan("\u2502")+c.padEnd(n+20)+l.cyan("\u2502"));let g=` ${l.gray("Run:")} leetcode changelog ${l.gray("to review changes")}`;console.log(l.cyan("\u2502")+g.padEnd(n+16)+l.cyan("\u2502"));}console.log(l.cyan("\u2502")+"".padEnd(n-2)+l.cyan("\u2502"));let a=` ${l.gray("Run:")} npm update -g ${xr}`;console.log(l.cyan("\u2502")+a.padEnd(n+8)+l.cyan("\u2502")),console.log(l.cyan(r)),console.log();}async function un(e){let o=be();e.force&&re.clearCache();let t=re.getCached(),n,s;if(t&&!re.shouldCheck()&&!e.force)n=t.latestVersion,s=t.hasBreakingChanges;else {let r=Ue("Checking for updates...").start();try{let i=await dn();n=i.version,s=i.hasBreakingChanges,re.updateCache(n,s),r.stop();}catch(i){r.fail("Failed to check for updates"),process.env.DEBUG&&console.log(l.gray(` Debug: ${i instanceof Error?i.message:String(i)}`)),console.log(l.gray(" Could not reach npm registry. Check your internet connection."));return}}he(n,o)?(Er(o,n,s),e.checkOnly||s&&(console.log(l.yellow("\u{1F4A1} Tip: Review the changelog before updating to check for breaking changes.")),console.log(l.gray(` Run: leetcode changelog
|
|
243
|
+
`)))):(console.log(),console.log(l.green("\u2713")+` You're on the latest version (${l.cyan(o)})`),console.log());}async function pn(){if(!re.shouldCheck()){let e=re.getCached();e&&he(e.latestVersion,be())&&mn(be(),e.latestVersion,e.hasBreakingChanges);return}try{let e=await dn();re.updateCache(e.version,e.hasBreakingChanges),he(e.version,be())&&mn(be(),e.version,e.hasBreakingChanges);}catch{}}function mn(e,o,t){console.log(),t?(console.log(l.yellow(`\u26A0\uFE0F Update ${e} \u2192 ${o} available (breaking changes!)`)),console.log(l.gray(" Run: leetcode changelog && leetcode update"))):(console.log(l.cyan(`\u{1F680} Update available: ${e} \u2192 ${o}`)),console.log(l.gray(" Run: leetcode update"))),console.log();}var Nr=fileURLToPath(import.meta.url),yn=dirname(Nr),Ir="https://raw.githubusercontent.com/night-slayer18/leetcode-cli/main/docs/releases.md";function Ur(){let e=[join(yn,"../package.json"),join(yn,"../../package.json")];for(let o of e)try{let t=JSON.parse(readFileSync(o,"utf-8"));if(t.version)return t.version}catch{continue}throw new Error("Could not read package.json version. Ensure you are running from a valid installation.")}async function jr(){return await kn(Ir,{timeout:{request:1e4},retry:{limit:2}}).text()}function Mr(e){let o=[],t=/^## v?([\d.]+)/gm,n=[...e.matchAll(t)];for(let s=0;s<n.length;s++){let r=n[s],i=`v${r[1]}`,a=r.index+r[0].length,c=s+1<n.length?n[s+1].index:e.length,g=e.slice(a,c).trim(),u=g.includes("\u26A0\uFE0F Breaking Change");o.push({version:i,content:g,hasBreakingChanges:u});}return o}function qr(e,o,t){let n=t?l.bgRed.white.bold(` ${e} `)+l.red(" \u26A0\uFE0F BREAKING CHANGES"):l.bgCyan.black.bold(` ${e} `);console.log(n),console.log();let s=o.split(`
|
|
244
|
+
`),r=false;for(let i of s)if(!(i.trim()===""&&!r)){if(i.startsWith("> **Release Date**")){let a=i.replace("> **Release Date**: ","").trim();console.log(l.gray(` \u{1F4C5} ${a}`));continue}if(i.startsWith("> **Focus**")){let a=i.replace("> **Focus**: ","").trim();console.log(l.gray(` \u{1F3AF} ${a}`)),console.log();continue}if(i.startsWith("### ")){let a=i.replace("### ","").trim();if(console.log(),/^[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u.test(a))console.log(l.bold.yellow(` ${a}`));else {let g="\u{1F4CC}";a.includes("Breaking")?g="\u26A0\uFE0F":a.includes("Feature")||a.includes("New")?g="\u{1F680}":a.includes("Fix")||a.includes("Bug")?g="\u{1F41B}":a.includes("Security")?g="\u{1F512}":a.includes("Improvement")?g="\u2728":a.includes("Architecture")?g="\u{1F3D7}\uFE0F":a.includes("Testing")?g="\u{1F9EA}":a.includes("Config")&&(g="\u2699\uFE0F"),console.log(l.bold.yellow(` ${g} ${a}`));}r=true;continue}if(i.startsWith("#### ")){let a=i.replace("#### ","").trim();console.log(l.bold.white(` ${a}`));continue}if(i.startsWith("- **")){let a=i.match(/^- \*\*(.+?)\*\*:?\s*(.*)/);console.log(a?l.cyan(` \u2022 ${l.bold(a[1])}`)+(a[2]?l.white(`: ${a[2]}`):""):l.cyan(` \u2022 ${i.replace("- ","")}`));continue}if(i.startsWith("- ")){let a=i.replace("- ","").trim();console.log(l.white(` \u2022 ${a}`));continue}i.startsWith("---")||i.trim()===">"||i.trim()&&console.log(l.gray(` ${i.trim()}`));}}async function hn(e,o={}){let t=Ue("Fetching changelog...").start();try{let n=await jr();t.stop();let s=Mr(n);if(s.length===0){console.log(l.yellow("No release entries found."));return}let r=Ur(),i=s;if(e){let a=e.startsWith("v")?e:`v${e}`;if(i=s.filter(c=>c.version===a),i.length===0){console.log(l.red(`Version ${e} not found in changelog.`)),console.log(l.gray("Available versions: "+s.map(c=>c.version).join(", ")));return}}else if(o.latest)i=s.slice(0,1);else if(o.breaking){if(i=s.filter(a=>a.hasBreakingChanges),i.length===0){console.log(l.green("\u2713 No breaking changes in any release."));return}}else if(o.all)i=s;else {if(i=s.filter(a=>he(a.version,r)),i.length===0){console.log(l.green(`\u2713 You're on the latest version (${r})`)),console.log(l.gray("Use --all to see the full changelog."));return}console.log(l.gray(`Showing changes since your version (${r})`)),console.log(l.gray("Use --all to see the full changelog."));}console.log(),console.log(l.bold.cyan("\u{1F4CB} LeetCode CLI Release Notes")),console.log(l.gray("\u2500".repeat(50))),console.log();for(let a of i)qr(a.version,a.content,a.hasBreakingChanges),console.log(l.gray("\u2500".repeat(60))),console.log();if(!e&&!o.latest){let a=s.filter(c=>c.hasBreakingChanges).length;console.log(l.gray(`Showing ${i.length} of ${s.length} releases`)),a>0&&!o.breaking&&console.log(l.yellow(`${a} release(s) contain breaking changes. Use --breaking to filter.`));}}catch{t.fail("Failed to fetch changelog"),console.log(l.gray(" Could not fetch release notes from GitHub.")),console.log(l.gray(" Visit: https://github.com/night-slayer18/leetcode-cli/blob/main/docs/releases.md"));}}var C=new Command;C.configureHelp({sortSubcommands:true,subcommandTerm:e=>{let o=e.name(),t=e.alias(),n=t?`${o}|${t}`:o;return l.cyan(n.padEnd(16))},subcommandDescription:e=>l.white(e.description()),optionTerm:e=>l.yellow(e.flags),optionDescription:e=>l.white(e.description)});C.name("leetcode").usage("[command] [options]").description(l.bold.cyan("\u{1F525} A modern LeetCode CLI built with TypeScript")).version("2.2.2","-v, --version","Output the version number").helpOption("-h, --help","Display help for command").addHelpText("after",`
|
|
245
245
|
${l.yellow("Examples:")}
|
|
246
246
|
${l.cyan("$ leetcode login")} Login to LeetCode
|
|
247
247
|
${l.cyan("$ leetcode list -d easy")} List easy problems
|