@rhseung/ps-cli 1.9.0 → 1.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runSolution
4
- } from "./chunk-TTTS4CDS.js";
4
+ } from "./chunk-YZUGYJA4.js";
5
5
  import {
6
6
  Command,
7
7
  CommandBuilder,
@@ -13,7 +13,7 @@ import {
13
13
  icons,
14
14
  resolveLanguage,
15
15
  resolveProblemContext
16
- } from "./chunk-JZK2464U.js";
16
+ } from "./chunk-Q5NECGFA.js";
17
17
 
18
18
  // src/commands/test.tsx
19
19
  import { Alert, Spinner } from "@inkjs/ui";
@@ -13,7 +13,7 @@ import {
13
13
  getSupportedLanguagesString,
14
14
  resolveLanguage,
15
15
  resolveProblemContext
16
- } from "./chunk-JZK2464U.js";
16
+ } from "./chunk-Q5NECGFA.js";
17
17
 
18
18
  // src/commands/submit.tsx
19
19
  import { Badge, StatusMessage, Alert, Spinner } from "@inkjs/ui";
@@ -12,7 +12,7 @@ import {
12
12
  getSolvingDirPath,
13
13
  logger,
14
14
  resolveProblemContext
15
- } from "./chunk-JZK2464U.js";
15
+ } from "./chunk-Q5NECGFA.js";
16
16
 
17
17
  // src/commands/archive.tsx
18
18
  import { StatusMessage, Alert, Spinner } from "@inkjs/ui";
@@ -8,11 +8,10 @@ import {
8
8
  CommandDef,
9
9
  __decorateClass,
10
10
  defineFlags,
11
- findSolutionFile,
12
11
  getEditor,
13
12
  logger,
14
13
  resolveProblemContext
15
- } from "./chunk-JZK2464U.js";
14
+ } from "./chunk-Q5NECGFA.js";
16
15
 
17
16
  // src/commands/open.tsx
18
17
  import { StatusMessage, Alert, Spinner } from "@inkjs/ui";
@@ -242,13 +241,7 @@ var OpenCommand = class extends Command {
242
241
  return;
243
242
  }
244
243
  const mode = flags.editor ? "editor" : "browser";
245
- let problemPath = context.archiveDir;
246
- if (flags.editor) {
247
- try {
248
- problemPath = await findSolutionFile(context.archiveDir);
249
- } catch {
250
- }
251
- }
244
+ const problemPath = context.archiveDir;
252
245
  await this.renderView(OpenView, {
253
246
  problemId: context.problemId,
254
247
  problemDir: problemPath,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getProblem,
4
4
  scrapeProblem
5
- } from "./chunk-YH6VDCNG.js";
5
+ } from "./chunk-YCFY6UCA.js";
6
6
  import {
7
7
  Command,
8
8
  CommandBuilder,
@@ -22,7 +22,7 @@ import {
22
22
  logger,
23
23
  parseTimeLimitToMs,
24
24
  resolveProblemContext
25
- } from "./chunk-JZK2464U.js";
25
+ } from "./chunk-Q5NECGFA.js";
26
26
 
27
27
  // src/commands/fetch.tsx
28
28
  import { StatusMessage, Alert, Spinner } from "@inkjs/ui";
@@ -11324,6 +11324,7 @@ var logger = {
11324
11324
  // src/utils/help.ts
11325
11325
  function generateGlobalHelp(commands) {
11326
11326
  const title = psGradient.multiline(`
11327
+
11327
11328
  \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557
11328
11329
  \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551
11329
11330
  \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  logger
4
- } from "./chunk-JZK2464U.js";
4
+ } from "./chunk-Q5NECGFA.js";
5
5
 
6
6
  // src/services/scraper.ts
7
7
  import * as cheerio from "cheerio";
@@ -59,6 +59,117 @@ async function fetchWithRetry(url, context) {
59
59
  // src/services/scraper.ts
60
60
  var BOJ_BASE_URL = "https://www.acmicpc.net";
61
61
  var SOLVED_AC_BASE_URL = "https://solved.ac";
62
+ function tableToMarkdown($, $table) {
63
+ const rows = [];
64
+ let maxCols = 0;
65
+ const thead = $table.find("thead");
66
+ if (thead.length > 0) {
67
+ thead.find("tr").each((_, tr) => {
68
+ const $tr = $(tr);
69
+ const cells = [];
70
+ const cellElements = $tr.find("th, td");
71
+ if (cellElements.length > 0) {
72
+ cellElements.each((_2, cell) => {
73
+ const cellContent = htmlToMarkdown($, $(cell)).trim().replace(/\n/g, " ").replace(/\|/g, "\\|");
74
+ cells.push(cellContent || " ");
75
+ });
76
+ } else {
77
+ const trText = $tr.text().trim();
78
+ if (trText) {
79
+ const textCells = trText.split(/\s+/).filter((v) => v.length > 0);
80
+ textCells.forEach((cellText) => {
81
+ cells.push(cellText.replace(/\|/g, "\\|"));
82
+ });
83
+ }
84
+ }
85
+ if (cells.length > 0) {
86
+ rows.push(cells);
87
+ maxCols = Math.max(maxCols, cells.length);
88
+ }
89
+ });
90
+ }
91
+ const tbody = $table.find("tbody");
92
+ if (tbody.length > 0) {
93
+ tbody.find("tr").each((_, tr) => {
94
+ const $tr = $(tr);
95
+ const cells = [];
96
+ const cellElements = $tr.find("td, th");
97
+ if (cellElements.length > 0) {
98
+ cellElements.each((_2, cell) => {
99
+ const cellContent = htmlToMarkdown($, $(cell)).trim().replace(/\n/g, " ").replace(/\|/g, "\\|");
100
+ cells.push(cellContent || " ");
101
+ });
102
+ } else {
103
+ const trText = $tr.text().trim();
104
+ if (trText) {
105
+ const textCells = trText.split(/\s+/).filter((v) => v.length > 0);
106
+ textCells.forEach((cellText) => {
107
+ cells.push(cellText.replace(/\|/g, "\\|"));
108
+ });
109
+ }
110
+ }
111
+ if (cells.length > 0) {
112
+ rows.push(cells);
113
+ maxCols = Math.max(maxCols, cells.length);
114
+ }
115
+ });
116
+ }
117
+ if (rows.length === 0) {
118
+ $table.find("tr").each((_, tr) => {
119
+ const $tr = $(tr);
120
+ const cells = [];
121
+ const cellElements = $tr.find("th, td");
122
+ if (cellElements.length > 0) {
123
+ cellElements.each((_2, cell) => {
124
+ const cellContent = htmlToMarkdown($, $(cell)).trim().replace(/\n/g, " ").replace(/\|/g, "\\|");
125
+ cells.push(cellContent || " ");
126
+ });
127
+ } else {
128
+ const trText = $tr.text().trim();
129
+ if (trText) {
130
+ const textCells = trText.split(/\s+/).filter((v) => v.length > 0);
131
+ textCells.forEach((cellText) => {
132
+ cells.push(cellText.replace(/\|/g, "\\|"));
133
+ });
134
+ }
135
+ }
136
+ if (cells.length > 0) {
137
+ rows.push(cells);
138
+ maxCols = Math.max(maxCols, cells.length);
139
+ }
140
+ });
141
+ }
142
+ if (rows.length === 0 || maxCols === 0) {
143
+ return "";
144
+ }
145
+ rows.forEach((row) => {
146
+ while (row.length < maxCols) {
147
+ row.push(" ");
148
+ }
149
+ });
150
+ const markdownRows = [];
151
+ const hasHeader = thead.length > 0 || rows.length > 0 && $table.find("tr").first().find("th").length > 0;
152
+ if (hasHeader && rows.length > 0) {
153
+ const headerRow = `| ${rows[0].join(" | ")} |`;
154
+ markdownRows.push(headerRow);
155
+ const separator = `|${"---|".repeat(maxCols)}`;
156
+ markdownRows.push(separator);
157
+ for (let i = 1; i < rows.length; i++) {
158
+ markdownRows.push(`| ${rows[i].join(" | ")} |`);
159
+ }
160
+ } else {
161
+ if (rows.length > 0) {
162
+ const headerRow = `| ${rows[0].join(" | ")} |`;
163
+ markdownRows.push(headerRow);
164
+ const separator = `|${"---|".repeat(maxCols)}`;
165
+ markdownRows.push(separator);
166
+ for (let i = 1; i < rows.length; i++) {
167
+ markdownRows.push(`| ${rows[i].join(" | ")} |`);
168
+ }
169
+ }
170
+ }
171
+ return markdownRows.length > 0 ? markdownRows.join("\n") + "\n\n" : "";
172
+ }
62
173
  function htmlToMarkdown($, element) {
63
174
  if (element.length === 0) return "";
64
175
  let result = "";
@@ -75,6 +186,11 @@ function htmlToMarkdown($, element) {
75
186
  } else if (node.type === "tag") {
76
187
  const tagName = node.name.toLowerCase();
77
188
  const $node = $(node);
189
+ if (tagName === "thead" || tagName === "tbody" || tagName === "tr" || tagName === "th" || tagName === "td") {
190
+ if ($node.parent().is("table") || $node.closest("table").length > 0) {
191
+ return;
192
+ }
193
+ }
78
194
  switch (tagName) {
79
195
  case "sup":
80
196
  result += `^${htmlToMarkdown($, $node)}`;
@@ -139,6 +255,23 @@ ${preContent}
139
255
  case "li":
140
256
  result += htmlToMarkdown($, $node);
141
257
  break;
258
+ case "table": {
259
+ const tableContent = tableToMarkdown($, $node);
260
+ if (tableContent) {
261
+ result += tableContent;
262
+ }
263
+ break;
264
+ }
265
+ case "thead":
266
+ case "tbody":
267
+ case "tr":
268
+ case "th":
269
+ case "td":
270
+ if ($node.closest("table").not($node).length > 0) {
271
+ break;
272
+ }
273
+ result += htmlToMarkdown($, $node);
274
+ break;
142
275
  case "img": {
143
276
  const imgSrc = $node.attr("src") || "";
144
277
  const imgAlt = $node.attr("alt") || "\uC774\uBBF8\uC9C0";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  getLanguageConfig
4
- } from "./chunk-JZK2464U.js";
4
+ } from "./chunk-Q5NECGFA.js";
5
5
 
6
6
  // src/services/runner.ts
7
7
  import { readFile } from "fs/promises";
@@ -3,8 +3,8 @@ import {
3
3
  ArchiveCommand,
4
4
  ArchiveView,
5
5
  archive_default
6
- } from "../chunk-D5PTJ4WQ.js";
7
- import "../chunk-JZK2464U.js";
6
+ } from "../chunk-457JZK3K.js";
7
+ import "../chunk-Q5NECGFA.js";
8
8
  export {
9
9
  ArchiveCommand,
10
10
  ArchiveView,
@@ -7,7 +7,7 @@ import {
7
7
  getConfigMetadata,
8
8
  icons,
9
9
  logger
10
- } from "../chunk-JZK2464U.js";
10
+ } from "../chunk-Q5NECGFA.js";
11
11
 
12
12
  // src/commands/config.tsx
13
13
  import { StatusMessage, Select, TextInput, Alert } from "@inkjs/ui";
@@ -3,9 +3,9 @@ import {
3
3
  FetchCommand,
4
4
  FetchView,
5
5
  fetch_default
6
- } from "../chunk-SBBC4CBS.js";
7
- import "../chunk-YH6VDCNG.js";
8
- import "../chunk-JZK2464U.js";
6
+ } from "../chunk-M4LNYKJF.js";
7
+ import "../chunk-YCFY6UCA.js";
8
+ import "../chunk-Q5NECGFA.js";
9
9
  export {
10
10
  FetchCommand,
11
11
  FetchView,
@@ -14,7 +14,7 @@ import {
14
14
  getSolvingDir,
15
15
  getSupportedLanguages,
16
16
  icons
17
- } from "../chunk-JZK2464U.js";
17
+ } from "../chunk-Q5NECGFA.js";
18
18
 
19
19
  // src/commands/init.tsx
20
20
  import {
@@ -3,9 +3,9 @@ import {
3
3
  OpenCommand,
4
4
  OpenView,
5
5
  open_default
6
- } from "../chunk-XV6UUPQC.js";
6
+ } from "../chunk-AHVAVNFM.js";
7
7
  import "../chunk-QGMWUOJ3.js";
8
- import "../chunk-JZK2464U.js";
8
+ import "../chunk-Q5NECGFA.js";
9
9
  export {
10
10
  OpenCommand,
11
11
  OpenView,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runSolution
4
- } from "../chunk-TTTS4CDS.js";
4
+ } from "../chunk-YZUGYJA4.js";
5
5
  import {
6
6
  Command,
7
7
  CommandBuilder,
@@ -13,7 +13,7 @@ import {
13
13
  icons,
14
14
  resolveLanguage,
15
15
  resolveProblemContext
16
- } from "../chunk-JZK2464U.js";
16
+ } from "../chunk-Q5NECGFA.js";
17
17
 
18
18
  // src/commands/run.tsx
19
19
  import { join } from "path";
@@ -1,26 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  SubmitView
4
- } from "../chunk-EGPBBIJ2.js";
4
+ } from "../chunk-3H74PQRX.js";
5
5
  import {
6
6
  TestView
7
- } from "../chunk-YXLVFZZH.js";
7
+ } from "../chunk-2YSOO6AM.js";
8
8
  import {
9
9
  ArchiveView
10
- } from "../chunk-D5PTJ4WQ.js";
10
+ } from "../chunk-457JZK3K.js";
11
11
  import {
12
12
  FetchView
13
- } from "../chunk-SBBC4CBS.js";
13
+ } from "../chunk-M4LNYKJF.js";
14
14
  import {
15
15
  fetchWithRetry,
16
16
  getProblem,
17
17
  searchProblems
18
- } from "../chunk-YH6VDCNG.js";
18
+ } from "../chunk-YCFY6UCA.js";
19
19
  import {
20
20
  OpenView
21
- } from "../chunk-XV6UUPQC.js";
21
+ } from "../chunk-AHVAVNFM.js";
22
22
  import "../chunk-QGMWUOJ3.js";
23
- import "../chunk-TTTS4CDS.js";
23
+ import "../chunk-YZUGYJA4.js";
24
24
  import {
25
25
  Command,
26
26
  CommandBuilder,
@@ -37,7 +37,7 @@ import {
37
37
  logger,
38
38
  resolveLanguage,
39
39
  source_default
40
- } from "../chunk-JZK2464U.js";
40
+ } from "../chunk-Q5NECGFA.js";
41
41
 
42
42
  // src/commands/search.tsx
43
43
  import { existsSync } from "fs";
@@ -5,7 +5,7 @@ import {
5
5
  getUserTagRatings,
6
6
  getUserTop100,
7
7
  scrapeUserStats
8
- } from "../chunk-YH6VDCNG.js";
8
+ } from "../chunk-YCFY6UCA.js";
9
9
  import {
10
10
  Command,
11
11
  CommandBuilder,
@@ -25,7 +25,7 @@ import {
25
25
  icons,
26
26
  logger,
27
27
  source_default
28
- } from "../chunk-JZK2464U.js";
28
+ } from "../chunk-Q5NECGFA.js";
29
29
 
30
30
  // src/commands/stats.tsx
31
31
  import { Alert, Spinner } from "@inkjs/ui";
@@ -3,9 +3,9 @@ import {
3
3
  SubmitCommand,
4
4
  SubmitView,
5
5
  submit_default
6
- } from "../chunk-EGPBBIJ2.js";
6
+ } from "../chunk-3H74PQRX.js";
7
7
  import "../chunk-QGMWUOJ3.js";
8
- import "../chunk-JZK2464U.js";
8
+ import "../chunk-Q5NECGFA.js";
9
9
  export {
10
10
  SubmitCommand,
11
11
  SubmitView,
@@ -3,9 +3,9 @@ import {
3
3
  TestCommand,
4
4
  TestView,
5
5
  test_default
6
- } from "../chunk-YXLVFZZH.js";
7
- import "../chunk-TTTS4CDS.js";
8
- import "../chunk-JZK2464U.js";
6
+ } from "../chunk-2YSOO6AM.js";
7
+ import "../chunk-YZUGYJA4.js";
8
+ import "../chunk-Q5NECGFA.js";
9
9
  export {
10
10
  TestCommand,
11
11
  TestView,
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  generateGlobalHelp,
4
4
  logger
5
- } from "./chunk-JZK2464U.js";
5
+ } from "./chunk-Q5NECGFA.js";
6
6
 
7
7
  // src/index.ts
8
8
  import { existsSync } from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhseung/ps-cli",
3
- "version": "1.9.0",
3
+ "version": "1.9.8",
4
4
  "description": "백준(BOJ) 문제 해결을 위한 통합 CLI 도구",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,7 +22,9 @@
22
22
  "check": "prettier --write . && eslint --fix",
23
23
  "patch": "npm version patch && bun publish --access=public",
24
24
  "minor": "npm version minor && bun publish --access=public",
25
- "major": "npm version major && bun publish --access=public"
25
+ "major": "npm version major && bun publish --access=public",
26
+ "unlink": "npm unlink -g @rhseung/ps-cli",
27
+ "prepare": "husky || true"
26
28
  },
27
29
  "keywords": [
28
30
  "boj",
@@ -44,6 +46,7 @@
44
46
  "dependencies": {
45
47
  "@inkjs/ui": "^2.0.0",
46
48
  "@pppp606/ink-chart": "^0.2.4",
49
+ "@rhseung/ps-cli": "^1.9.1",
47
50
  "@types/gradient-string": "^1.1.6",
48
51
  "chalk": "^5.3.0",
49
52
  "cheerio": "^1.0.0",
@@ -58,15 +61,16 @@
58
61
  "devDependencies": {
59
62
  "@types/node": "^22.10.2",
60
63
  "@types/react": "^18.3.12",
61
- "tsup": "^8.3.5",
62
- "typescript": "^5.7.2",
63
- "typescript-eslint": "^8.50.1",
64
64
  "eslint-config-prettier": "^10.1.8",
65
65
  "eslint-plugin-import": "^2.32.0",
66
66
  "eslint-plugin-prettier": "^5.5.4",
67
67
  "eslint-plugin-react-hooks": "^7.0.1",
68
68
  "eslint-plugin-react-refresh": "^0.4.26",
69
- "globals": "^16.5.0"
69
+ "globals": "^16.5.0",
70
+ "husky": "^9.1.7",
71
+ "tsup": "^8.3.5",
72
+ "typescript": "^5.7.2",
73
+ "typescript-eslint": "^8.50.1"
70
74
  },
71
75
  "engines": {
72
76
  "node": ">=18.0.0"