@rhseung/ps-cli 1.4.0 → 1.6.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.
@@ -1,16 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ source_default
4
+ } from "../chunk-ASMT3CRD.js";
5
+ import {
6
+ calculateTierProgress,
7
+ getNextTierMinRating,
3
8
  getTierColor,
4
9
  getTierName,
5
- getUserStats,
6
- source_default
7
- } from "../chunk-NB4OIWND.js";
10
+ getUserStats
11
+ } from "../chunk-NH36IFWR.js";
8
12
  import {
9
13
  Command,
10
14
  CommandBuilder,
11
15
  CommandDef,
12
16
  getSolvedAcHandle
13
- } from "../chunk-7SVCS23X.js";
17
+ } from "../chunk-RVD22OUQ.js";
14
18
  import {
15
19
  __decorateClass
16
20
  } from "../chunk-7MQMPJ3X.js";
@@ -18,8 +22,7 @@ import {
18
22
  // src/commands/stats.tsx
19
23
  import { Alert } from "@inkjs/ui";
20
24
  import { Spinner } from "@inkjs/ui";
21
- import gradient from "gradient-string";
22
- import { Box, Text } from "ink";
25
+ import { Box, Text, Transform } from "ink";
23
26
 
24
27
  // src/hooks/use-user-stats.ts
25
28
  import { useEffect, useState } from "react";
@@ -56,6 +59,16 @@ function useUserStats({
56
59
 
57
60
  // src/commands/stats.tsx
58
61
  import { jsx, jsxs } from "react/jsx-runtime";
62
+ function ProgressBarWithColor({ value, colorFn }) {
63
+ const width = process.stdout.columns || 40;
64
+ const barWidth = Math.max(10, Math.min(30, width - 20));
65
+ const filled = Math.round(value / 100 * barWidth);
66
+ const empty = barWidth - filled;
67
+ const filledBar = "\u2588".repeat(filled);
68
+ const emptyBar = "\u2591".repeat(empty);
69
+ const barText = filledBar + emptyBar;
70
+ return /* @__PURE__ */ jsx(Transform, { transform: (output) => colorFn(output), children: /* @__PURE__ */ jsx(Text, { children: barText }) });
71
+ }
59
72
  function StatsView({ handle, onComplete }) {
60
73
  const { status, user, error } = useUserStats({
61
74
  handle,
@@ -72,16 +85,22 @@ function StatsView({ handle, onComplete }) {
72
85
  }
73
86
  if (user) {
74
87
  const tierName = getTierName(user.tier);
75
- const tierDisplay = user.tier === 31 ? gradient([
76
- { r: 255, g: 124, b: 168 },
77
- { r: 180, g: 145, b: 255 },
78
- { r: 124, g: 249, b: 255 }
79
- ])(tierName) : source_default.hex(getTierColor(user.tier))(tierName);
88
+ const tierColor = getTierColor(user.tier);
89
+ const tierColorFn = typeof tierColor === "string" ? source_default.hex(tierColor) : tierColor.multiline;
90
+ const nextTierMin = getNextTierMinRating(user.tier);
91
+ const progress = user.tier === 31 ? 100 : calculateTierProgress(user.rating, user.tier);
80
92
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
81
93
  /* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsxs(Text, { color: "cyan", bold: true, children: [
82
94
  "\u2728 ",
83
95
  user.handle
84
96
  ] }) }),
97
+ /* @__PURE__ */ jsx(Box, { marginBottom: 1, flexDirection: "row", gap: 1, children: /* @__PURE__ */ jsxs(Text, { children: [
98
+ tierColorFn(tierName),
99
+ " ",
100
+ /* @__PURE__ */ jsx(Text, { bold: true, children: tierColorFn(user.rating.toLocaleString()) }),
101
+ nextTierMin !== null && /* @__PURE__ */ jsx(Text, { bold: true, children: " / " + nextTierMin.toLocaleString() })
102
+ ] }) }),
103
+ /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsx(ProgressBarWithColor, { value: progress, colorFn: tierColorFn }) }),
85
104
  /* @__PURE__ */ jsx(
86
105
  Box,
87
106
  {
@@ -90,11 +109,6 @@ function StatsView({ handle, onComplete }) {
90
109
  borderColor: "gray",
91
110
  alignSelf: "flex-start",
92
111
  children: /* @__PURE__ */ jsxs(Box, { paddingX: 1, paddingY: 0, flexDirection: "column", children: [
93
- /* @__PURE__ */ jsxs(Text, { children: [
94
- tierDisplay,
95
- " ",
96
- /* @__PURE__ */ jsx(Text, { bold: true, children: user.rating.toLocaleString() })
97
- ] }),
98
112
  /* @__PURE__ */ jsxs(Text, { children: [
99
113
  "\uD574\uACB0\uD55C \uBB38\uC81C:",
100
114
  " ",
@@ -11,7 +11,7 @@ import {
11
11
  getProblemId,
12
12
  resolveLanguage,
13
13
  resolveProblemContext
14
- } from "../chunk-7SVCS23X.js";
14
+ } from "../chunk-RVD22OUQ.js";
15
15
  import {
16
16
  __decorateClass,
17
17
  getSupportedLanguagesString
@@ -9,7 +9,7 @@ import {
9
9
  getProblemId,
10
10
  resolveLanguage,
11
11
  resolveProblemContext
12
- } from "../chunk-7SVCS23X.js";
12
+ } from "../chunk-RVD22OUQ.js";
13
13
  import {
14
14
  __decorateClass,
15
15
  getSupportedLanguagesString
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhseung/ps-cli",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "백준(BOJ) 문제 해결을 위한 통합 CLI 도구",
5
5
  "type": "module",
6
6
  "bin": {
@@ -15,7 +15,7 @@
15
15
  "dev": "tsup --watch",
16
16
  "typecheck": "tsc --noEmit",
17
17
  "lint": "eslint",
18
- "format": "prettier",
18
+ "format": "prettier --check .",
19
19
  "check": "prettier --write . && eslint --fix",
20
20
  "patch": "npm version patch && bun publish --access=public",
21
21
  "minor": "npm version minor && bun publish --access=public",