sh-ui-cli 0.114.0 → 0.116.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.
- package/bin/sh-ui.mjs +70 -3
- package/data/changelog/versions.json +26 -0
- package/data/registry/react/components/rich-text-editor/index.module.tsx +523 -171
- package/data/registry/react/components/rich-text-editor/index.tailwind.tsx +596 -70
- package/data/registry/react/components/rich-text-editor/index.tsx +523 -171
- package/data/registry/react/components/rich-text-editor/styles.css +103 -5
- package/data/registry/react/components/rich-text-editor/styles.module.css +103 -5
- package/data/registry/react/registry.json +319 -963
- package/data/registry/react/tokens-used.json +4 -1
- package/package.json +1 -1
- package/src/add.mjs +31 -1
- package/src/commands.mjs +6 -0
- package/src/create/generator.js +4 -0
- package/src/doctor.mjs +14 -0
- package/src/init.mjs +19 -0
- package/src/levenshtein.mjs +36 -0
- package/src/list.mjs +13 -0
- package/src/mcp.mjs +14 -0
- package/src/migrate-bundled.mjs +14 -0
- package/src/migrate-v065.mjs +14 -0
- package/src/remove.mjs +15 -0
- package/src/rename-app.mjs +15 -0
- package/src/theme-extract.mjs +13 -0
- package/src/tokens-cmd.mjs +12 -0
- package/src/upgrade-cli.mjs +13 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$description": "컴포넌트별 토큰 의존성 (var(--*) 추출). build-registry-tokens.mjs 가 자동 생성.",
|
|
3
|
-
"$generated": "2026-
|
|
3
|
+
"$generated": "2026-06-01T06:54:04.570Z",
|
|
4
4
|
"components": {
|
|
5
5
|
"button": {
|
|
6
6
|
"plain": [
|
|
@@ -533,6 +533,7 @@
|
|
|
533
533
|
"--primary",
|
|
534
534
|
"--radius",
|
|
535
535
|
"--ring",
|
|
536
|
+
"--sh-ui-rte-c-",
|
|
536
537
|
"--space-1",
|
|
537
538
|
"--space-2",
|
|
538
539
|
"--space-3",
|
|
@@ -551,6 +552,7 @@
|
|
|
551
552
|
"--opacity-disabled",
|
|
552
553
|
"--primary",
|
|
553
554
|
"--radius",
|
|
555
|
+
"--sh-ui-rte-c-",
|
|
554
556
|
"--space-1",
|
|
555
557
|
"--space-2",
|
|
556
558
|
"--space-3",
|
|
@@ -571,6 +573,7 @@
|
|
|
571
573
|
"--primary",
|
|
572
574
|
"--radius",
|
|
573
575
|
"--ring",
|
|
576
|
+
"--sh-ui-rte-c-",
|
|
574
577
|
"--space-1",
|
|
575
578
|
"--space-2",
|
|
576
579
|
"--space-3",
|
package/package.json
CHANGED
package/src/add.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { pathToFileURL } from "node:url";
|
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
6
|
import { select } from "@inquirer/prompts";
|
|
7
7
|
import { formatUnifiedDiff } from "./diff.mjs";
|
|
8
|
+
import { suggest } from "./levenshtein.mjs";
|
|
8
9
|
import { getRegistryRoot, getTokensRoot, getPeerVersionsPath } from "./paths.mjs";
|
|
9
10
|
import { THEME_BASES } from "./constants.js";
|
|
10
11
|
import {
|
|
@@ -20,6 +21,25 @@ import {
|
|
|
20
21
|
rewriteCrossComponentImports,
|
|
21
22
|
} from "./css-bundle.mjs";
|
|
22
23
|
|
|
24
|
+
export const HELP_TEXT = `sh-ui add — 컴포넌트 소스를 프로젝트로 복사 + 필요한 패키지 자동 설치
|
|
25
|
+
|
|
26
|
+
사용법:
|
|
27
|
+
sh-ui add <component...>
|
|
28
|
+
sh-ui add tokens 설정 기반 토큰 파일 생성 (특수값)
|
|
29
|
+
|
|
30
|
+
옵션:
|
|
31
|
+
--skip-install 외부 패키지 자동 설치 생략
|
|
32
|
+
--diff 파일을 쓰지 않고 변경 내역(unified diff)만 출력
|
|
33
|
+
--force 기존 파일을 모두 덮어쓰기 (prompt 없음)
|
|
34
|
+
--keep 기존 파일을 모두 유지 (prompt 없음)
|
|
35
|
+
--app <name> monorepo 라우팅 시 대상 ui-{name} 명시
|
|
36
|
+
|
|
37
|
+
예:
|
|
38
|
+
sh-ui add button
|
|
39
|
+
sh-ui add button card --diff
|
|
40
|
+
sh-ui add tokens
|
|
41
|
+
`;
|
|
42
|
+
|
|
23
43
|
/**
|
|
24
44
|
* 기존 파일과 registry 파일 내용이 다를 때 keep/overwrite 결정.
|
|
25
45
|
* strategy 가 "prompt" 면 사용자에게 묻고, 그 외엔 즉시 결정.
|
|
@@ -336,6 +356,16 @@ function effectiveFramework(entry, cssFramework) {
|
|
|
336
356
|
return hasVariant ? cssFramework : "plain";
|
|
337
357
|
}
|
|
338
358
|
|
|
359
|
+
/** 컴포넌트 not-found 에러 메시지. 가까운 후보가 있으면 "혹시 …?" 를 덧붙인다. */
|
|
360
|
+
export function buildNotFoundMessage(name, platform, candidates) {
|
|
361
|
+
const hits = suggest(name, candidates);
|
|
362
|
+
const hint = hits.length ? ` 혹시 ${hits.join(", ")}?` : "";
|
|
363
|
+
return (
|
|
364
|
+
`'${name}' 컴포넌트를 ${platform} 레지스트리에서 찾을 수 없습니다.${hint}` +
|
|
365
|
+
` 전체 목록: sh-ui list --all`
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
339
369
|
async function addComponent(name, config, cwd, installed, pendingDeps, diffMode, summary, conflictResolver, validationCtx) {
|
|
340
370
|
const registryRoot = getRegistryRoot(config.platform);
|
|
341
371
|
const registry = JSON.parse(
|
|
@@ -344,7 +374,7 @@ async function addComponent(name, config, cwd, installed, pendingDeps, diffMode,
|
|
|
344
374
|
const entry = registry.components?.[name];
|
|
345
375
|
if (!entry) {
|
|
346
376
|
throw new Error(
|
|
347
|
-
|
|
377
|
+
buildNotFoundMessage(name, config.platform, Object.keys(registry.components ?? {})),
|
|
348
378
|
);
|
|
349
379
|
}
|
|
350
380
|
|
package/src/commands.mjs
ADDED
package/src/create/generator.js
CHANGED
|
@@ -678,6 +678,10 @@ async function inferMonorepoPlatform(cwd) {
|
|
|
678
678
|
* @param {string} [options.onConflict] 'prompt' | 'keep' | 'overwrite'
|
|
679
679
|
*/
|
|
680
680
|
export async function addComponent(options = {}) {
|
|
681
|
+
// monorepo 라우팅은 컴포넌트별 registry 조회를 직접 하지 않고 add() 로 위임한다.
|
|
682
|
+
// 따라서 not-found 처리(오타 추천 포함)는 add.mjs 의 addComponent 가 공유 헬퍼
|
|
683
|
+
// buildNotFoundMessage 로 던지는 메시지를 그대로 쓴다 — standalone 경로와 동일,
|
|
684
|
+
// 메시지 로직 중복 없음 (DRY).
|
|
681
685
|
const { add } = await import('../add.mjs');
|
|
682
686
|
|
|
683
687
|
const cwd = options.cwd ? path.resolve(options.cwd) : process.cwd();
|
package/src/doctor.mjs
CHANGED
|
@@ -18,6 +18,20 @@ import {
|
|
|
18
18
|
findMissingTokens,
|
|
19
19
|
} from "./tokens-validate.mjs";
|
|
20
20
|
|
|
21
|
+
export const HELP_TEXT = `sh-ui doctor — 프로젝트 정합성 점검
|
|
22
|
+
|
|
23
|
+
사용법:
|
|
24
|
+
sh-ui doctor
|
|
25
|
+
|
|
26
|
+
점검 항목:
|
|
27
|
+
config sh-ui.config.json 존재·필드 유효성
|
|
28
|
+
tokens tokens.css 정의·필요 변수 누락 여부
|
|
29
|
+
설치된 컴포넌트 소스/스타일 파일 정합성
|
|
30
|
+
|
|
31
|
+
예:
|
|
32
|
+
sh-ui doctor
|
|
33
|
+
`;
|
|
34
|
+
|
|
21
35
|
const ICON = { ok: "✓", warn: "⚠", fail: "✗" };
|
|
22
36
|
|
|
23
37
|
class Report {
|
package/src/init.mjs
CHANGED
|
@@ -13,6 +13,25 @@ import {
|
|
|
13
13
|
CSS_FRAMEWORKS_PLANNED,
|
|
14
14
|
} from "./constants.js";
|
|
15
15
|
|
|
16
|
+
export const HELP_TEXT = `sh-ui init — sh-ui.config.json 생성 (기존 프로젝트에 sh-ui 얹기)
|
|
17
|
+
|
|
18
|
+
사용법:
|
|
19
|
+
sh-ui init [options]
|
|
20
|
+
|
|
21
|
+
옵션:
|
|
22
|
+
--platform <react|flutter> 타겟 플랫폼
|
|
23
|
+
--base <neutral|zinc|...> 색 베이스
|
|
24
|
+
--radius <none|sm|md|lg|xl|full> 모서리 반경
|
|
25
|
+
--mode <light|dark|light-dark> 색 모드
|
|
26
|
+
--cssFramework <plain|tailwind|css-modules> CSS 전략 (vanilla-extract 예정)
|
|
27
|
+
--force 기존 sh-ui.config.json 덮어쓰기
|
|
28
|
+
--yes 대화형 프롬프트 생략 (기본값 채택)
|
|
29
|
+
|
|
30
|
+
예:
|
|
31
|
+
sh-ui init
|
|
32
|
+
sh-ui init --platform react --base neutral --mode light-dark --yes
|
|
33
|
+
`;
|
|
34
|
+
|
|
16
35
|
const CHOICES = {
|
|
17
36
|
platform: INIT_PLATFORMS,
|
|
18
37
|
base: THEME_BASES,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// 의존성 없는 편집거리 + 후보 제안. diff.mjs 가 LCS 를 자체 구현한 관행을 따른다.
|
|
2
|
+
|
|
3
|
+
/** 두 문자열의 Levenshtein 편집거리 (삽입/삭제/치환 비용 1). */
|
|
4
|
+
export function levenshtein(a, b) {
|
|
5
|
+
const m = a.length;
|
|
6
|
+
const n = b.length;
|
|
7
|
+
if (m === 0) return n;
|
|
8
|
+
if (n === 0) return m;
|
|
9
|
+
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
10
|
+
let curr = new Array(n + 1);
|
|
11
|
+
for (let i = 1; i <= m; i++) {
|
|
12
|
+
curr[0] = i;
|
|
13
|
+
for (let j = 1; j <= n; j++) {
|
|
14
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
15
|
+
curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
|
|
16
|
+
}
|
|
17
|
+
[prev, curr] = [curr, prev];
|
|
18
|
+
}
|
|
19
|
+
return prev[n];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* input 과 가까운 candidates 를 거리 오름차순으로 반환.
|
|
24
|
+
* @param {string} input
|
|
25
|
+
* @param {string[]} candidates
|
|
26
|
+
* @param {{max?: number, maxDistance?: number}} [opts]
|
|
27
|
+
* @returns {string[]} 거리 <= maxDistance 인 후보 상위 max 개 (없으면 빈 배열)
|
|
28
|
+
*/
|
|
29
|
+
export function suggest(input, candidates, { max = 3, maxDistance = 2 } = {}) {
|
|
30
|
+
return candidates
|
|
31
|
+
.map((name) => ({ name, dist: levenshtein(input, name) }))
|
|
32
|
+
.filter((c) => c.dist <= maxDistance)
|
|
33
|
+
.sort((a, b) => a.dist - b.dist || a.name.localeCompare(b.name))
|
|
34
|
+
.slice(0, max)
|
|
35
|
+
.map((c) => c.name);
|
|
36
|
+
}
|
package/src/list.mjs
CHANGED
|
@@ -3,6 +3,19 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import { resolve, relative } from "node:path";
|
|
4
4
|
import { getRegistryRoot } from "./paths.mjs";
|
|
5
5
|
|
|
6
|
+
export const HELP_TEXT = `sh-ui list — 현재 설치된 컴포넌트 목록 표시
|
|
7
|
+
|
|
8
|
+
사용법:
|
|
9
|
+
sh-ui list
|
|
10
|
+
|
|
11
|
+
옵션:
|
|
12
|
+
--all 설치되지 않은 컴포넌트까지 모두 표시
|
|
13
|
+
|
|
14
|
+
예:
|
|
15
|
+
sh-ui list
|
|
16
|
+
sh-ui list --all
|
|
17
|
+
`;
|
|
18
|
+
|
|
6
19
|
function resolveDest(template, config) {
|
|
7
20
|
return template.replace(/\{([a-zA-Z0-9_]+)\}/g, (m, key) => {
|
|
8
21
|
const v = config.paths?.[key];
|
package/src/mcp.mjs
CHANGED
|
@@ -56,6 +56,20 @@ import { THEME_PRESET_NAMES } from "./create/theme/presets.js";
|
|
|
56
56
|
import { decodeTheme } from "./create/theme/decode.js";
|
|
57
57
|
import { encodeTheme } from "./create/theme/encode.js";
|
|
58
58
|
|
|
59
|
+
export const HELP_TEXT = `sh-ui mcp — IDE-내 AI 용 MCP 서버 / 설정
|
|
60
|
+
|
|
61
|
+
사용법:
|
|
62
|
+
sh-ui mcp MCP 서버(stdio) 시작
|
|
63
|
+
sh-ui mcp init --client <name> IDE MCP 설정 파일에 sh-ui 엔트리 자동 추가
|
|
64
|
+
|
|
65
|
+
옵션 (mcp init):
|
|
66
|
+
--client <name> claude-code | cursor | claude-desktop | codex
|
|
67
|
+
|
|
68
|
+
예:
|
|
69
|
+
sh-ui mcp
|
|
70
|
+
sh-ui mcp init --client claude-code
|
|
71
|
+
`;
|
|
72
|
+
|
|
59
73
|
const PLATFORMS = INIT_PLATFORMS;
|
|
60
74
|
const BASES = THEME_BASES;
|
|
61
75
|
const RADII = THEME_RADII;
|
package/src/migrate-bundled.mjs
CHANGED
|
@@ -16,6 +16,20 @@ import { existsSync } from "node:fs";
|
|
|
16
16
|
import { resolve, relative, dirname, join } from "node:path";
|
|
17
17
|
import { upsertSection, stripStylesImport } from "./css-bundle.mjs";
|
|
18
18
|
|
|
19
|
+
export const HELP_TEXT = `sh-ui migrate bundled — cssStrategy=bundled 로 전환
|
|
20
|
+
|
|
21
|
+
사용법:
|
|
22
|
+
sh-ui migrate bundled per-component styles.css → 단일 sh-ui-components.css
|
|
23
|
+
|
|
24
|
+
옵션:
|
|
25
|
+
--apply 실제 적용 (미지정 시 미리보기)
|
|
26
|
+
--bundle <path> 번들 CSS 파일 경로 명시
|
|
27
|
+
|
|
28
|
+
예:
|
|
29
|
+
sh-ui migrate bundled
|
|
30
|
+
sh-ui migrate bundled --apply
|
|
31
|
+
`;
|
|
32
|
+
|
|
19
33
|
async function loadConfig(cwd) {
|
|
20
34
|
const configPath = resolve(cwd, "sh-ui.config.json");
|
|
21
35
|
if (!existsSync(configPath)) {
|
package/src/migrate-v065.mjs
CHANGED
|
@@ -14,6 +14,20 @@ import * as fsp from "node:fs/promises";
|
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
16
|
|
|
17
|
+
export const HELP_TEXT = `sh-ui migrate-v065 — v0.64.x → v0.65 자동 마이그레이션
|
|
18
|
+
|
|
19
|
+
사용법:
|
|
20
|
+
sh-ui migrate-v065 ui-app 컴포넌트를 ui-core 단일 SoT 로 dedup 이동
|
|
21
|
+
|
|
22
|
+
옵션:
|
|
23
|
+
--dry-run 변경 plan 만 출력 (기본값 — 미지정 시 동작)
|
|
24
|
+
--apply 실제 적용
|
|
25
|
+
|
|
26
|
+
예:
|
|
27
|
+
sh-ui migrate-v065
|
|
28
|
+
sh-ui migrate-v065 --apply
|
|
29
|
+
`;
|
|
30
|
+
|
|
17
31
|
const COMPONENT_KINDS = ["components", "hooks", "lib"];
|
|
18
32
|
|
|
19
33
|
async function fileExists(p) {
|
package/src/remove.mjs
CHANGED
|
@@ -2,6 +2,21 @@ import { readFile, rm, rmdir, readdir, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { dirname, resolve, relative } from "node:path";
|
|
4
4
|
import { getRegistryRoot } from "./paths.mjs";
|
|
5
|
+
|
|
6
|
+
export const HELP_TEXT = `sh-ui remove — 설치된 컴포넌트 파일 삭제
|
|
7
|
+
|
|
8
|
+
사용법:
|
|
9
|
+
sh-ui remove <component...>
|
|
10
|
+
|
|
11
|
+
옵션:
|
|
12
|
+
--force 사용자가 수정한 파일도 삭제
|
|
13
|
+
--dry-run 변경 대상만 출력하고 실제로는 삭제하지 않음
|
|
14
|
+
|
|
15
|
+
예:
|
|
16
|
+
sh-ui remove button
|
|
17
|
+
sh-ui remove button card --dry-run
|
|
18
|
+
`;
|
|
19
|
+
|
|
5
20
|
import {
|
|
6
21
|
removeSection,
|
|
7
22
|
isStyleFile,
|
package/src/rename-app.mjs
CHANGED
|
@@ -19,6 +19,21 @@ import { spawn } from "node:child_process";
|
|
|
19
19
|
import { join, relative, resolve } from "node:path";
|
|
20
20
|
import { createInterface } from "node:readline/promises";
|
|
21
21
|
|
|
22
|
+
export const HELP_TEXT = `sh-ui rename-app — monorepo 의 앱 이름 일괄 변경
|
|
23
|
+
|
|
24
|
+
사용법:
|
|
25
|
+
sh-ui rename-app <old> <new> apps/<old>/, ui-<old>/ 디렉토리 + 모든 import/path 패턴
|
|
26
|
+
|
|
27
|
+
옵션:
|
|
28
|
+
--yes 대화형 확인 생략
|
|
29
|
+
--dry-run 변경 대상만 출력하고 실제로는 변경하지 않음
|
|
30
|
+
--skip-install 변경 후 pnpm install 생략
|
|
31
|
+
|
|
32
|
+
예:
|
|
33
|
+
sh-ui rename-app web admin
|
|
34
|
+
sh-ui rename-app web admin --dry-run
|
|
35
|
+
`;
|
|
36
|
+
|
|
22
37
|
/** 텍스트 파일로 처리할 확장자 (전체 파일을 읽어 치환). */
|
|
23
38
|
const TEXT_EXT = new Set([
|
|
24
39
|
".ts", ".tsx", ".js", ".mjs", ".cjs",
|
package/src/theme-extract.mjs
CHANGED
|
@@ -17,6 +17,19 @@ import { resolve, relative } from "node:path";
|
|
|
17
17
|
import { parseBlocks } from "./tokens-diff.mjs";
|
|
18
18
|
import { encodeTheme } from "./create/theme/encode.js";
|
|
19
19
|
|
|
20
|
+
export const HELP_TEXT = `sh-ui theme — 현재 토큰을 테마 코드로 추출
|
|
21
|
+
|
|
22
|
+
사용법:
|
|
23
|
+
sh-ui theme extract tokens.css 의 색·radius 를 base64 로 추출 (stdout)
|
|
24
|
+
|
|
25
|
+
옵션:
|
|
26
|
+
--out <path> 추출 결과를 stdout 대신 파일로 저장
|
|
27
|
+
|
|
28
|
+
예:
|
|
29
|
+
sh-ui theme extract
|
|
30
|
+
sh-ui theme extract --out theme.txt
|
|
31
|
+
`;
|
|
32
|
+
|
|
20
33
|
/**
|
|
21
34
|
* Dart 의 ShUiColorTokens 필드명 ↔ TOKEN_KEYS (hyphen) 매핑.
|
|
22
35
|
* inject.js 의 DART_FIELD_SOURCES 와 같은 매핑을 reverse 로 사용.
|
package/src/tokens-cmd.mjs
CHANGED
|
@@ -17,6 +17,18 @@ import { THEME_BASES } from "./constants.js";
|
|
|
17
17
|
import { parseBlocks, diffBlocks, applyAdditions } from "./tokens-diff.mjs";
|
|
18
18
|
import { parseDartTokens, diffDartTokens } from "./tokens-diff-dart.mjs";
|
|
19
19
|
|
|
20
|
+
export const HELP_TEXT = `sh-ui tokens — tokens.css 비교/업그레이드
|
|
21
|
+
|
|
22
|
+
사용법:
|
|
23
|
+
sh-ui tokens diff tokens.css 와 buildTokens 결과 비교
|
|
24
|
+
sh-ui tokens upgrade --apply 추가된 변수만 적용 (사용자 편집 보존)
|
|
25
|
+
sh-ui tokens upgrade --replace buildTokens 결과로 통째 덮어쓰기
|
|
26
|
+
|
|
27
|
+
예:
|
|
28
|
+
sh-ui tokens diff
|
|
29
|
+
sh-ui tokens upgrade --apply
|
|
30
|
+
`;
|
|
31
|
+
|
|
20
32
|
async function loadTokensBuilder() {
|
|
21
33
|
const url = pathToFileURL(resolve(getTokensRoot(), "build.mjs")).href;
|
|
22
34
|
return import(url);
|
package/src/upgrade-cli.mjs
CHANGED
|
@@ -15,6 +15,19 @@ import { dirname, resolve } from "node:path";
|
|
|
15
15
|
import { fileURLToPath } from "node:url";
|
|
16
16
|
import { spawn } from "node:child_process";
|
|
17
17
|
|
|
18
|
+
export const HELP_TEXT = `sh-ui upgrade-cli — sh-ui-cli 자체를 최신으로 업그레이드
|
|
19
|
+
|
|
20
|
+
사용법:
|
|
21
|
+
sh-ui upgrade-cli 최신 버전 확인 + 변경 내역 미리보기
|
|
22
|
+
|
|
23
|
+
옵션:
|
|
24
|
+
--apply 실제 설치 후 진단 (미지정 시 미리보기만)
|
|
25
|
+
|
|
26
|
+
예:
|
|
27
|
+
sh-ui upgrade-cli
|
|
28
|
+
sh-ui upgrade-cli --apply
|
|
29
|
+
`;
|
|
30
|
+
|
|
18
31
|
const CLI_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
19
32
|
const REGISTRY_URL = "https://registry.npmjs.org/sh-ui-cli/latest";
|
|
20
33
|
|