Skip to content

Commit b9a2956

Browse files
junghyeonsuclaude
andauthored
feat(cli): add --seed-react-version option to add and add-all (#1720)
Maps a supported SEED React version (1.0/1.1/1.2) to its archived registry domain (https://v1-2.seed-design.io) so users don't need the exact baseUrl; unsupported versions throw with the allowed list. Sets framework=react and takes precedence over --baseUrl/--framework. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 254a964 commit b9a2956

6 files changed

Lines changed: 86 additions & 16 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
"@seed-design/cli": minor
3+
---
4+
5+
`add`, `add-all` 명령어에 `--seed-react-version` 옵션을 추가합니다.
6+
7+
- 설치한 `@seed-design/react` 버전에 맞는 스니펫 레지스트리를 CLI가 자동으로 찾아줍니다. 정확한 `--baseUrl`을 직접 지정할 필요가 없습니다.
8+
- `--baseUrl`, `--framework`보다 우선 적용됩니다.
9+
10+
```sh
11+
npx @seed-design/cli@latest add --seed-react-version 1.2 ui:action-button
12+
```

docs/content/react/getting-started/cli/commands.mdx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,29 @@ npx @seed-design/cli@latest add ui:action-button ui:alert-dialog
118118
|------|------|
119119
| `-c, --cwd <cwd>` | 작업 디렉토리. 기본값은 현재 디렉토리 |
120120
| `-u, --baseUrl <baseUrl>` | 레지스트리 base URL |
121+
| `--seed-react-version <version>` | 지정한 SEED React 버전의 레지스트리 사용 (예: `1.2`). `--baseUrl`/`--framework`보다 우선 |
121122
| `-f, --framework <framework>` | 대상 프레임워크 (`react` 또는 `lynx`). config의 `framework` 값을 덮어씀 |
122123
| `--on-diff <mode>` | 파일 충돌 처리 방식 지정 (`overwrite` 또는 `backup`) |
123124
| `-a, --all` | **Deprecated**. 현재는 에러를 출력하고 `add-all` 사용을 안내 |
124125
| `--verbose` | 실패 시 stack trace 등 상세 오류 정보 출력 |
125126
| `-h, --help` | 도움말 출력 |
126127

127-
### baseUrl 사용하기
128+
### 버전에 맞는 스니펫 받기
128129

129-
`--baseUrl` 옵션을 사용하면 스니펫을 다운로드할 레지스트리를 직접 지정할 수 있습니다.
130-
131-
기본값은 배포 환경 기준 [`https://seed-design.io`](https://seed-design.io)입니다.
132-
133-
이 옵션은 특정 SEED React 패키지와 호환되는 스니펫이 필요한 경우 활용할 수 있습니다.
130+
프로젝트에 설치된 SEED 패키지 버전과 호환되는 스니펫이 필요하면 버전 옵션을 사용하세요. 해당 버전이 배포된 레지스트리 주소를 CLI가 자동으로 찾아줍니다.
134131

135132
```package-install
136-
npx @seed-design/cli@latest add --baseUrl https://1-0.seed-design.pages.dev
133+
npx @seed-design/cli@latest add --seed-react-version 1.2 ui:action-button
137134
```
138135

136+
버전 옵션은 base URL과 프레임워크(react)를 함께 결정하므로 `--baseUrl` / `--framework`보다 우선해요.
137+
138+
#### baseUrl 직접 지정
139+
140+
레지스트리 주소를 직접 지정하려면 `--baseUrl`을 사용하세요. 기본값은 배포 환경 기준 [`https://seed-design.io`](https://seed-design.io)입니다.
141+
139142
```package-install
140-
npx @seed-design/cli@latest add --baseUrl https://1-1.seed-design.pages.dev
143+
npx @seed-design/cli@latest add --baseUrl https://v1-2.seed-design.io
141144
```
142145

143146
### 파일 충돌 처리
@@ -183,6 +186,7 @@ npx @seed-design/cli@latest add-all ui --include-deprecated # ui 레지스트리
183186
| `--include-deprecated` | deprecated 항목 포함 |
184187
| `-c, --cwd <cwd>` | 작업 디렉토리. 기본값은 현재 디렉토리 |
185188
| `-u, --baseUrl <baseUrl>` | 레지스트리 base URL |
189+
| `--seed-react-version <version>` | 지정한 SEED React 버전의 레지스트리 사용 (예: `1.2`). `--baseUrl`/`--framework`보다 우선 |
186190
| `-f, --framework <framework>` | 대상 프레임워크 (`react` 또는 `lynx`). config의 `framework` 값을 덮어씀 |
187191
| `--on-diff <mode>` | 파일 충돌 처리 방식 지정 (`overwrite` 또는 `backup`) |
188192
| `--verbose` | 실패 시 stack trace 등 상세 오류 정보 출력 |

packages/cli/src/commands/add-all.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { CAC } from "cac";
1010
import { BASE_URL } from "../constants";
1111
import { analytics } from "../utils/analytics";
1212
import { highlight } from "../utils/color";
13+
import { resolveSeedVersion } from "../utils/registry-source";
1314
import {
1415
analyzeRegistryItemCompatibility,
1516
getProjectSeedPackageVersionSpecs,
@@ -30,6 +31,7 @@ const addAllOptionsSchema = z.object({
3031
includeDeprecated: z.boolean().optional(),
3132
cwd: z.string(),
3233
baseUrl: z.string().default(BASE_URL),
34+
seedReactVersion: z.string().optional(),
3335
framework: z.enum(["react", "lynx"]).optional(),
3436
onDiff: z.enum(["overwrite", "backup"]).optional(),
3537
});
@@ -51,6 +53,7 @@ export const addAllCommand = (cli: CAC) => {
5153
"the base url of the registry. defaults to the current directory.",
5254
{ default: BASE_URL },
5355
)
56+
.option("--seed-react-version <version>", "지정한 SEED React 버전의 레지스트리 사용 (예: 1.2)")
5457
.option("-f, --framework <framework>", "프레임워크 (react 또는 lynx)")
5558
.option("--on-diff <mode>", "Action when file differs: overwrite or backup")
5659
.example("seed-design add-all ui --include-deprecated")
@@ -70,9 +73,10 @@ export const addAllCommand = (cli: CAC) => {
7073
const { data: options } = parsed;
7174

7275
const cwd = options.cwd;
73-
const baseUrl = options.baseUrl;
76+
const versionSource = resolveSeedVersion(options);
77+
const baseUrl = versionSource?.baseUrl ?? options.baseUrl;
7478
const config = await getConfig(cwd);
75-
const framework = options.framework ?? config.framework;
79+
const framework = versionSource?.framework ?? options.framework ?? config.framework;
7680
const rootPath = path.resolve(cwd, config.path);
7781

7882
const { start, stop } = p.spinner();

packages/cli/src/commands/add.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { z } from "zod";
99
import type { CAC } from "cac";
1010
import { BASE_URL } from "../constants";
1111
import { highlight } from "../utils/color";
12+
import { resolveSeedVersion } from "../utils/registry-source";
1213
import { installDependencies } from "../utils/install";
1314
import { analytics } from "../utils/analytics";
1415
import {
@@ -32,6 +33,7 @@ const addOptionsSchema = z.object({
3233
all: z.boolean(),
3334
cwd: z.string(),
3435
baseUrl: z.string().default(BASE_URL),
36+
seedReactVersion: z.string().optional(),
3537
framework: z.enum(["react", "lynx"]).optional(),
3638
onDiff: z.enum(["overwrite", "backup"]).optional(),
3739
});
@@ -50,6 +52,7 @@ export const addCommand = (cli: CAC) => {
5052
"the base url of the registry. defaults to the current directory.",
5153
{ default: BASE_URL },
5254
)
55+
.option("--seed-react-version <version>", "지정한 SEED React 버전의 레지스트리 사용 (예: 1.2)")
5356
.option("-f, --framework <framework>", "프레임워크 (react 또는 lynx)")
5457
.option("--on-diff <mode>", "Action when file differs: overwrite or backup")
5558
.example("seed-design add ui:action-button")
@@ -78,9 +81,10 @@ export const addCommand = (cli: CAC) => {
7881
}
7982

8083
const cwd = options.cwd;
81-
const baseUrl = options.baseUrl;
84+
const versionSource = resolveSeedVersion(options);
85+
const baseUrl = versionSource?.baseUrl ?? options.baseUrl;
8286
const config = await getConfig(cwd);
83-
const framework = options.framework ?? config.framework;
87+
const framework = versionSource?.framework ?? options.framework ?? config.framework;
8488
const rootPath = path.resolve(cwd, config.path);
8589

8690
const { start, stop } = p.spinner();
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { CliError } from "./error";
2+
3+
/**
4+
* 아카이브된 SEED React 버전별 레지스트리 도메인.
5+
*
6+
* 모든 minor 버전이 아니라 보존(아카이브)된 버전만 서브도메인으로 배포되어 있어,
7+
* 동적으로 URL을 만들지 않고 알려진 버전만 하드코딩한다. 새 버전을 아카이브하면 여기 추가한다.
8+
*/
9+
const SEED_REACT_VERSION_BASE_URLS: Record<string, string> = {
10+
"1.0": "https://v1-0.seed-design.io",
11+
"1.1": "https://v1-1.seed-design.io",
12+
"1.2": "https://v1-2.seed-design.io",
13+
};
14+
15+
/**
16+
* `--seed-react-version` 옵션을 레지스트리 소스(framework + baseUrl)로 해석한다.
17+
* 옵션이 없으면 null을 반환한다 (= 레거시 `--baseUrl` / `--framework` 경로 사용).
18+
*
19+
* 지원하지 않는 버전이면 사용 가능한 버전을 안내하며 에러를 던진다.
20+
* 옵션이 지정되면 framework도 react로 고정한다. (Lynx는 자체 버전 배포가 없어 별도 옵션을
21+
* 제공하지 않으며, 기본값(latest)을 쓰거나 필요 시 `--baseUrl`로 직접 지정한다.)
22+
*/
23+
export function resolveSeedVersion(opts: {
24+
seedReactVersion?: string;
25+
}): { framework: "react"; baseUrl: string } | null {
26+
const version = opts.seedReactVersion?.trim();
27+
if (!version) return null;
28+
29+
const baseUrl = SEED_REACT_VERSION_BASE_URLS[version];
30+
if (!baseUrl) {
31+
throw new CliError({
32+
message: `지원하지 않는 SEED React 버전이에요: "${opts.seedReactVersion}"`,
33+
hint: `사용 가능한 버전: ${Object.keys(SEED_REACT_VERSION_BASE_URLS).join(", ")}`,
34+
});
35+
}
36+
37+
return { framework: "react", baseUrl };
38+
}

skills/seed-design/references/migration.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,22 @@ npx @seed-design/cli@latest compat
1212

1313
## Install Compatible Snippets
1414

15-
프로젝트의 `@seed-design/react` 버전과 맞는 스니펫이 필요하면 `--baseUrl`사용합니다.
15+
프로젝트에 설치된 SEED 버전과 맞는 스니펫이 필요하면 버전 옵션을 사용합니다. CLI가 해당 버전이 배포된 레지스트리 주소를 자동으로 찾아줍니다.
1616

1717
```bash
18-
npx @seed-design/cli@latest add --baseUrl https://1-0.seed-design.pages.dev ui:action-button
18+
npx @seed-design/cli@latest add --seed-react-version 1.2 ui:action-button
1919
```
2020

21+
`add-all`도 동일하게 동작합니다.
22+
23+
```bash
24+
npx @seed-design/cli@latest add-all --seed-react-version 1.2 ui
25+
```
26+
27+
레지스트리 주소를 직접 알고 있다면 `--baseUrl`로 지정할 수도 있습니다.
28+
2129
```bash
22-
npx @seed-design/cli@latest add-all --baseUrl https://1-1.seed-design.pages.dev ui
30+
npx @seed-design/cli@latest add --baseUrl https://v1-2.seed-design.io ui:action-button
2331
```
2432

2533
## Resolve Custom File Conflicts
@@ -39,6 +47,6 @@ CLI는 파일 내용이 다르면 diff를 보여주고 아래 중 하나를 선
3947
## Recommended Flow
4048

4149
1. `compat`으로 현재 불일치 항목을 먼저 파악합니다.
42-
2. 대상 컴포넌트를 작은 단위로 나눠서 `--baseUrl` 업데이트합니다.
50+
2. 대상 컴포넌트를 작은 단위로 나눠서 버전 옵션(`--seed-react-version`)으로 업데이트합니다.
4351
3. 충돌 파일은 우선 `backup`을 선택해 안전망을 확보합니다.
4452
4. 동작/스타일 검증 후 필요하면 백업 파일의 커스텀을 수동 반영합니다.

0 commit comments

Comments
 (0)