lc-review 0.0.10 → 0.0.11
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.mjs +52 -21
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,8 @@ import { appendFile, readFile } from "node:fs/promises";
|
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { supermemo } from "supermemo";
|
|
6
|
-
import {
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
|
+
import { encode } from "@toon-format/toon";
|
|
7
8
|
|
|
8
9
|
//#region src/core.ts
|
|
9
10
|
const logRecordSchema = z.object({
|
|
@@ -100966,7 +100967,7 @@ const review = async (logFile, n, premium = false) => {
|
|
|
100966
100967
|
|
|
100967
100968
|
//#endregion
|
|
100968
100969
|
//#region package.json
|
|
100969
|
-
var version = "0.0.
|
|
100970
|
+
var version = "0.0.11";
|
|
100970
100971
|
|
|
100971
100972
|
//#endregion
|
|
100972
100973
|
//#region src/index.ts
|
|
@@ -100974,7 +100975,12 @@ const INCLUDE_PREMIUM = false;
|
|
|
100974
100975
|
const SOLUTIONS_FILE = "./solutions.log";
|
|
100975
100976
|
await main();
|
|
100976
100977
|
async function main() {
|
|
100977
|
-
const args =
|
|
100978
|
+
const { values: globalValues, positionals: args } = parseArgs({
|
|
100979
|
+
args: process.argv.slice(2),
|
|
100980
|
+
options: { agent: { type: "boolean" } },
|
|
100981
|
+
allowPositionals: true,
|
|
100982
|
+
strict: false
|
|
100983
|
+
});
|
|
100978
100984
|
const command = args.shift();
|
|
100979
100985
|
switch (command) {
|
|
100980
100986
|
case "help":
|
|
@@ -101018,13 +101024,14 @@ async function main() {
|
|
|
101018
101024
|
case "debug:show-json-log": {
|
|
101019
101025
|
const logFile = args.shift();
|
|
101020
101026
|
if (!logFile) throw new Error("no log file provided");
|
|
101021
|
-
await showJsonLog(logFile);
|
|
101027
|
+
await showJsonLog(logFile, globalValues.agent === true);
|
|
101022
101028
|
break;
|
|
101023
101029
|
}
|
|
101024
101030
|
case "debug:show-problem-info": {
|
|
101025
|
-
const
|
|
101026
|
-
if (!
|
|
101027
|
-
|
|
101031
|
+
const problemNumbers = args.shift();
|
|
101032
|
+
if (!problemNumbers) throw new Error("no problem numbers provided");
|
|
101033
|
+
const isAgent = globalValues.agent === true;
|
|
101034
|
+
showProblemInfo(problemNumbers.split(","), isAgent);
|
|
101028
101035
|
break;
|
|
101029
101036
|
}
|
|
101030
101037
|
default:
|
|
@@ -101062,26 +101069,50 @@ Debug commands:
|
|
|
101062
101069
|
|
|
101063
101070
|
debug:show-json-log <log_file>
|
|
101064
101071
|
|
|
101065
|
-
debug:show-problem-info <problem_number>
|
|
101072
|
+
debug:show-problem-info <problem_number>[,problem_number,...]
|
|
101066
101073
|
`);
|
|
101067
101074
|
}
|
|
101068
|
-
async function showProblemInfo(
|
|
101069
|
-
const
|
|
101070
|
-
|
|
101071
|
-
|
|
101075
|
+
async function showProblemInfo(problemNumbers, isAgent) {
|
|
101076
|
+
const problems = [];
|
|
101077
|
+
for (const problemNumber of problemNumbers) {
|
|
101078
|
+
const problem = ALL_PROBLEMS.find((p) => p.questionFrontendId === problemNumber);
|
|
101079
|
+
if (problem) problems.push(problem);
|
|
101080
|
+
}
|
|
101081
|
+
if (!problems) {
|
|
101082
|
+
console.log(`No problems found for numbers: ${problemNumbers.join(", ")}`);
|
|
101083
|
+
return;
|
|
101084
|
+
}
|
|
101085
|
+
if (isAgent) {
|
|
101086
|
+
console.log(encode(problems.map((problem) => {
|
|
101087
|
+
return {
|
|
101088
|
+
id: problem.questionFrontendId,
|
|
101089
|
+
title: problem.title,
|
|
101090
|
+
difficulty: problem.difficulty,
|
|
101091
|
+
paidOnly: problem.paidOnly,
|
|
101092
|
+
acRate: problem.acRate,
|
|
101093
|
+
topics: problem.topicTags.map((tag) => tag.slug),
|
|
101094
|
+
url: `https://leetcode.com/problems/${problem.titleSlug}/`
|
|
101095
|
+
};
|
|
101096
|
+
})));
|
|
101072
101097
|
return;
|
|
101073
101098
|
}
|
|
101074
|
-
|
|
101075
|
-
|
|
101076
|
-
|
|
101077
|
-
|
|
101078
|
-
|
|
101079
|
-
|
|
101080
|
-
|
|
101081
|
-
|
|
101099
|
+
for (const problem of problems) {
|
|
101100
|
+
console.log(`ID: ${problem.questionFrontendId}`);
|
|
101101
|
+
console.log(`Title: ${problem.title}`);
|
|
101102
|
+
console.log(`Difficulty: ${problem.difficulty}`);
|
|
101103
|
+
console.log(`Paid only: ${problem.paidOnly}`);
|
|
101104
|
+
console.log(`AC Rate: ${(problem.acRate * 100).toFixed(2)}%`);
|
|
101105
|
+
if (problem.topicTags) console.log(`Topics: ${problem.topicTags.map((tag) => tag.name).join(", ")}`);
|
|
101106
|
+
console.log(`URL: https://leetcode.com/problems/${problem.titleSlug}/`);
|
|
101107
|
+
console.log("");
|
|
101108
|
+
}
|
|
101082
101109
|
}
|
|
101083
|
-
async function showJsonLog(logFile) {
|
|
101110
|
+
async function showJsonLog(logFile, isAgent) {
|
|
101084
101111
|
const records = await readLogFromFile(logFile);
|
|
101112
|
+
if (isAgent) {
|
|
101113
|
+
console.log(encode(records));
|
|
101114
|
+
return;
|
|
101115
|
+
}
|
|
101085
101116
|
console.log(JSON.stringify(records, null, 2));
|
|
101086
101117
|
}
|
|
101087
101118
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lc-review",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "LeetCode flashcards for spaced repetition learning",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "tsdown",
|
|
20
|
+
"build": "tsc --noEmit && tsdown",
|
|
21
21
|
"fmt": "npx prettier --write .",
|
|
22
22
|
"lc-review": "node ./dist/index.mjs",
|
|
23
23
|
"test": "vitest run",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"vitest": "4.0.16"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@toon-format/toon": "2.1.0",
|
|
41
42
|
"supermemo": "2.0.23",
|
|
42
43
|
"zod": "4.2.1"
|
|
43
44
|
},
|