lism-cli 0.0.1 → 0.3.1

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/lib.d.ts CHANGED
@@ -6,4 +6,433 @@ interface RunCreateArgs {
6
6
  /** `lism create` / `create-lism` から共通で使える実体関数 */
7
7
  declare function runCreate({ template, targetDir, force }: RunCreateArgs): Promise<void>;
8
8
 
9
- export { type RunCreateArgs, runCreate };
9
+ /**
10
+ * CLI 表示用のメッセージ辞書(ja / en)。
11
+ *
12
+ * 命名規則:
13
+ * - `cli.*` … commander の description / argument / option
14
+ * - `create.*` … `lism create` サブコマンド
15
+ * - `ui.*` … `lism ui` 配下
16
+ * - `skill.*` … `lism skill` 配下
17
+ * - `config.*` … lism.config.* まわりのエラー・警告
18
+ * - `common.*` … 汎用
19
+ *
20
+ * プレースホルダは `{name}` 形式(`t()` の `vars` で置換)。
21
+ */
22
+ declare const messages: {
23
+ readonly 'cli.description': {
24
+ readonly ja: "Lism CSS / UI 向け CLI";
25
+ readonly en: "CLI for Lism CSS / UI";
26
+ };
27
+ readonly 'cli.opt.lang': {
28
+ readonly ja: "CLI の表示言語を指定(ja | en)";
29
+ readonly en: "Display language for the CLI (ja | en)";
30
+ };
31
+ readonly 'cli.create.description': {
32
+ readonly ja: "examples テンプレートから新規プロジェクトを生成する";
33
+ readonly en: "Create a new project from an examples template";
34
+ };
35
+ readonly 'cli.create.arg.targetDir': {
36
+ readonly ja: "出力先ディレクトリ";
37
+ readonly en: "Target directory";
38
+ };
39
+ readonly 'cli.create.opt.template': {
40
+ readonly ja: "使用するテンプレート名(例: astro-minimal)";
41
+ readonly en: "Template name to use (e.g. astro-minimal)";
42
+ };
43
+ readonly 'cli.create.opt.force': {
44
+ readonly ja: "既存ディレクトリを強制上書き";
45
+ readonly en: "Overwrite existing directory";
46
+ };
47
+ readonly 'cli.ui.description': {
48
+ readonly ja: "Lism UI コンポーネントの追加・管理";
49
+ readonly en: "Manage Lism UI components";
50
+ };
51
+ readonly 'cli.ui.init.description': {
52
+ readonly ja: "lism.config.js の cli セクションを生成する";
53
+ readonly en: "Generate the cli section of lism.config.js";
54
+ };
55
+ readonly 'cli.ui.init.opt.framework': {
56
+ readonly ja: "フレームワーク";
57
+ readonly en: "Framework";
58
+ };
59
+ readonly 'cli.ui.init.opt.componentsDir': {
60
+ readonly ja: "コンポーネントの出力先ディレクトリ";
61
+ readonly en: "Output directory for components";
62
+ };
63
+ readonly 'cli.ui.init.opt.helperDir': {
64
+ readonly ja: "helper の出力先ディレクトリ";
65
+ readonly en: "Output directory for helpers";
66
+ };
67
+ readonly 'cli.ui.init.opt.force': {
68
+ readonly ja: "既存の cli セクションを上書き";
69
+ readonly en: "Overwrite the existing cli section";
70
+ };
71
+ readonly 'cli.ui.add.description': {
72
+ readonly ja: "コンポーネントを追加する";
73
+ readonly en: "Add components";
74
+ };
75
+ readonly 'cli.ui.add.arg.names': {
76
+ readonly ja: "追加するコンポーネント名";
77
+ readonly en: "Component names to add";
78
+ };
79
+ readonly 'cli.ui.add.opt.overwrite': {
80
+ readonly ja: "既存ファイルを確認なしで上書き";
81
+ readonly en: "Overwrite existing files without confirmation";
82
+ };
83
+ readonly 'cli.ui.add.opt.all': {
84
+ readonly ja: "全コンポーネントを追加";
85
+ readonly en: "Add all components";
86
+ };
87
+ readonly 'cli.ui.list.description': {
88
+ readonly ja: "利用可能なコンポーネント一覧を表示する";
89
+ readonly en: "List available components";
90
+ };
91
+ readonly 'cli.ui.opt.ref': {
92
+ readonly ja: "取得元の Git ref(ブランチ / タグ / コミット)";
93
+ readonly en: "Git ref to fetch from (branch / tag / commit)";
94
+ };
95
+ readonly 'cli.skill.description': {
96
+ readonly ja: "AI エージェント向けスキル(SKILL.md)の配置と管理";
97
+ readonly en: "Manage SKILL.md files for AI agents";
98
+ };
99
+ readonly 'cli.skill.add.description': {
100
+ readonly ja: "スキルを配置する";
101
+ readonly en: "Deploy skills";
102
+ };
103
+ readonly 'cli.skill.add.opt.overwrite': {
104
+ readonly ja: "確認なしで上書き";
105
+ readonly en: "Overwrite without confirmation";
106
+ };
107
+ readonly 'cli.skill.check.description': {
108
+ readonly ja: "配置済みスキルとリモートの差分を確認する";
109
+ readonly en: "Show the diff between installed skills and the remote";
110
+ };
111
+ readonly 'cli.skill.check.opt.verbose': {
112
+ readonly ja: "ファイル単位の差分を表示";
113
+ readonly en: "Show per-file diffs";
114
+ };
115
+ readonly 'cli.skill.update.description': {
116
+ readonly ja: "配置済みスキルを最新版で上書きする(--overwrite 同等)";
117
+ readonly en: "Overwrite installed skills with the latest version (same as --overwrite)";
118
+ };
119
+ readonly 'cli.skill.opt.ref': {
120
+ readonly ja: "GitHub の取得元 ref(ブランチ/タグ/コミット)";
121
+ readonly en: "Git ref to fetch from on GitHub (branch / tag / commit)";
122
+ };
123
+ readonly 'cli.skill.opt.all': {
124
+ readonly ja: "全ツールに配置";
125
+ readonly en: "Deploy to all tools";
126
+ };
127
+ readonly 'cli.skill.opt.toolPath': {
128
+ readonly ja: "{path} に配置";
129
+ readonly en: "Deploy to {path}";
130
+ };
131
+ readonly 'create.templateNotFound': {
132
+ readonly ja: "テンプレート \"{name}\" は見つかりません。利用可能: {list}";
133
+ readonly en: "Template \"{name}\" not found. Available: {list}";
134
+ };
135
+ readonly 'create.promptSelectTemplate': {
136
+ readonly ja: "テンプレートを選択してください:";
137
+ readonly en: "Select a template:";
138
+ };
139
+ readonly 'create.promptTargetDir': {
140
+ readonly ja: "出力先ディレクトリ:";
141
+ readonly en: "Target directory:";
142
+ };
143
+ readonly 'create.confirmOverwrite': {
144
+ readonly ja: "{dir} は既に存在し、空ではありません。上書きしますか?";
145
+ readonly en: "{dir} already exists and is not empty. Overwrite?";
146
+ };
147
+ readonly 'create.aborted': {
148
+ readonly ja: "中断しました。";
149
+ readonly en: "Aborted.";
150
+ };
151
+ readonly 'create.fetching': {
152
+ readonly ja: "テンプレート \"{name}\" を取得中(ref: {ref})...";
153
+ readonly en: "Fetching template \"{name}\" (ref: {ref})...";
154
+ };
155
+ readonly 'create.created': {
156
+ readonly ja: "{dir} にプロジェクトを生成しました。";
157
+ readonly en: "Generated project at {dir}.";
158
+ };
159
+ readonly 'create.nextSteps': {
160
+ readonly ja: "次のコマンドで開発を開始できます:";
161
+ readonly en: "Next steps:";
162
+ };
163
+ readonly 'create.workspaceReplaced': {
164
+ readonly ja: " package.json の workspace:* を ^{version} に置換しました。";
165
+ readonly en: " Replaced workspace:* in package.json with ^{version}.";
166
+ };
167
+ readonly 'create.workspaceFailed': {
168
+ readonly ja: "package.json の書き換えに失敗しました: {reason}";
169
+ readonly en: "Failed to rewrite package.json: {reason}";
170
+ };
171
+ readonly 'ui.catalogFailed': {
172
+ readonly ja: "カタログの取得に失敗しました{refInfo}: {reason}";
173
+ readonly en: "Failed to fetch catalog{refInfo}: {reason}";
174
+ };
175
+ readonly 'ui.add.noConfig': {
176
+ readonly ja: "lism.config.js が見つかりません。セットアップを開始します...\n";
177
+ readonly en: "lism.config.js not found. Starting setup...\n";
178
+ };
179
+ readonly 'ui.add.addingAll': {
180
+ readonly ja: "全 {count} コンポーネントを追加します...";
181
+ readonly en: "Adding all {count} components...";
182
+ };
183
+ readonly 'ui.add.specifyName': {
184
+ readonly ja: "追加するコンポーネント名を指定してください。";
185
+ readonly en: "Specify component names to add.";
186
+ };
187
+ readonly 'ui.add.notFound': {
188
+ readonly ja: "見つからないコンポーネント: {list}";
189
+ readonly en: "Components not found: {list}";
190
+ };
191
+ readonly 'ui.add.componentFetchFailed': {
192
+ readonly ja: "\"{name}\" の取得に失敗しました: {reason}";
193
+ readonly en: "Failed to fetch \"{name}\": {reason}";
194
+ };
195
+ readonly 'ui.add.someFailed': {
196
+ readonly ja: "一部のコンポーネント / helper の追加に失敗しました。";
197
+ readonly en: "Some components / helpers failed to be added.";
198
+ };
199
+ readonly 'ui.add.promptOverwritePolicy': {
200
+ readonly ja: "既存ファイルの上書き方針を選択してください:";
201
+ readonly en: "Select overwrite policy for existing files:";
202
+ };
203
+ readonly 'ui.add.policyAll': {
204
+ readonly ja: "全て上書き";
205
+ readonly en: "Overwrite all";
206
+ };
207
+ readonly 'ui.add.policyNone': {
208
+ readonly ja: "全てスキップ";
209
+ readonly en: "Skip all";
210
+ };
211
+ readonly 'ui.add.policyPerComponent': {
212
+ readonly ja: "コンポーネントごとに確認";
213
+ readonly en: "Ask per component";
214
+ };
215
+ readonly 'ui.add.created': {
216
+ readonly ja: " 作成: {path}";
217
+ readonly en: " Created: {path}";
218
+ };
219
+ readonly 'ui.add.deploying': {
220
+ readonly ja: "{name} を展開中...";
221
+ readonly en: "Deploying {name}...";
222
+ };
223
+ readonly 'ui.add.confirmOverwriteComponent': {
224
+ readonly ja: "{name} は既に存在します。上書きしますか?";
225
+ readonly en: "{name} already exists. Overwrite?";
226
+ };
227
+ readonly 'ui.add.skippedComponent': {
228
+ readonly ja: " スキップ: {name}";
229
+ readonly en: " Skipped: {name}";
230
+ };
231
+ readonly 'ui.add.helperFetchFailed': {
232
+ readonly ja: " helper \"{name}\" の取得に失敗しました: {reason}";
233
+ readonly en: " Failed to fetch helper \"{name}\": {reason}";
234
+ };
235
+ readonly 'ui.add.confirmOverwriteFile': {
236
+ readonly ja: "{path} は既に存在します。上書きしますか?";
237
+ readonly en: "{path} already exists. Overwrite?";
238
+ };
239
+ readonly 'ui.add.skippedFile': {
240
+ readonly ja: " スキップ: {path}";
241
+ readonly en: " Skipped: {path}";
242
+ };
243
+ readonly 'ui.init.promptFramework': {
244
+ readonly ja: "フレームワークを選択してください:";
245
+ readonly en: "Select a framework:";
246
+ };
247
+ readonly 'ui.init.promptComponentsDir': {
248
+ readonly ja: "コンポーネントの出力先ディレクトリ:";
249
+ readonly en: "Output directory for components:";
250
+ };
251
+ readonly 'ui.init.promptHelperDir': {
252
+ readonly ja: "helper の出力先ディレクトリ:";
253
+ readonly en: "Output directory for helpers:";
254
+ };
255
+ readonly 'ui.init.patchedUpdate': {
256
+ readonly ja: "{path} に cli セクションを更新しました。";
257
+ readonly en: "Updated the cli section in {path}.";
258
+ };
259
+ readonly 'ui.init.patchedAdd': {
260
+ readonly ja: "{path} に cli セクションを追記しました。";
261
+ readonly en: "Added the cli section to {path}.";
262
+ };
263
+ readonly 'ui.init.notPatched': {
264
+ readonly ja: "{path} に既に cli セクションが含まれているか、export default が検出できませんでした。手動で追記してください。";
265
+ readonly en: "Either {path} already contains a cli section or no export default was detected. Please add it manually.";
266
+ };
267
+ readonly 'ui.init.created': {
268
+ readonly ja: "{path} を作成しました。";
269
+ readonly en: "Created {path}.";
270
+ };
271
+ readonly 'ui.init.legacyDetected': {
272
+ readonly ja: "{filename} を検出しました。lism.config.js へ移行します。古いファイルは後で削除してください。";
273
+ readonly en: "Detected {filename}. Migrating to lism.config.js. Please remove the old file afterwards.";
274
+ };
275
+ readonly 'ui.init.alreadyExists': {
276
+ readonly ja: "{filename} には既に cli セクションが設定されています。上書きするには --force を指定してください。";
277
+ readonly en: "{filename} already has a cli section. Use --force to overwrite.";
278
+ };
279
+ readonly 'ui.init.willOverwrite': {
280
+ readonly ja: "{filename} の既存の cli セクションを上書きします。";
281
+ readonly en: "Overwriting the existing cli section in {filename}.";
282
+ };
283
+ readonly 'ui.list.fetching': {
284
+ readonly ja: "コンポーネント一覧を取得中...";
285
+ readonly en: "Fetching components list...";
286
+ };
287
+ readonly 'ui.list.header': {
288
+ readonly ja: "コンポーネント:";
289
+ readonly en: "Components:";
290
+ };
291
+ readonly 'ui.list.total': {
292
+ readonly ja: "合計: {count} コンポーネント";
293
+ readonly en: "Total: {count} components";
294
+ };
295
+ readonly 'skill.add.detected': {
296
+ readonly ja: "検出した AI ツール: {list}";
297
+ readonly en: "Detected AI tools: {list}";
298
+ };
299
+ readonly 'skill.add.promptTools': {
300
+ readonly ja: "配置先のツールを選択してください(スペースで選択、Enter で確定):";
301
+ readonly en: "Select target tools (Space to select, Enter to confirm):";
302
+ };
303
+ readonly 'skill.add.noTargets': {
304
+ readonly ja: "配置先が選択されませんでした。";
305
+ readonly en: "No target tools were selected.";
306
+ };
307
+ readonly 'skill.add.fetching': {
308
+ readonly ja: "スキルを取得中(ref: {ref})...";
309
+ readonly en: "Fetching skills (ref: {ref})...";
310
+ };
311
+ readonly 'skill.add.skippedSame': {
312
+ readonly ja: " スキップ(差分なし): {label}";
313
+ readonly en: " Skipped (no changes): {label}";
314
+ };
315
+ readonly 'skill.add.hasDiff': {
316
+ readonly ja: " {label} に差分があります:";
317
+ readonly en: " {label} has changes:";
318
+ };
319
+ readonly 'skill.add.modifiedFiles': {
320
+ readonly ja: " 変更: {count} ファイル";
321
+ readonly en: " Modified: {count} files";
322
+ };
323
+ readonly 'skill.add.addedFiles': {
324
+ readonly ja: " 追加: {count} ファイル";
325
+ readonly en: " Added: {count} files";
326
+ };
327
+ readonly 'skill.add.localOnlyFiles': {
328
+ readonly ja: " 削除: {count} ファイル(ローカルのみに存在、上書き時に削除されます)";
329
+ readonly en: " Deleted: {count} files (local-only, will be removed on overwrite)";
330
+ };
331
+ readonly 'skill.add.confirmOverwrite': {
332
+ readonly ja: "{path} を上書きしますか?";
333
+ readonly en: "Overwrite {path}?";
334
+ };
335
+ readonly 'skill.add.skippedTool': {
336
+ readonly ja: " スキップ: {tool}";
337
+ readonly en: " Skipped: {tool}";
338
+ };
339
+ readonly 'skill.add.deployed': {
340
+ readonly ja: " 配置: {tool} → {path}";
341
+ readonly en: " Deployed: {tool} → {path}";
342
+ };
343
+ readonly 'skill.check.noneInstalled': {
344
+ readonly ja: "インストール済みのスキルは見つかりませんでした。`{invoke} skill add` で配置できます。";
345
+ readonly en: "No installed skills found. Run `{invoke} skill add` to deploy them.";
346
+ };
347
+ readonly 'skill.check.fetching': {
348
+ readonly ja: "リモートスキルを取得中(ref: {ref})...";
349
+ readonly en: "Fetching remote skills (ref: {ref})...";
350
+ };
351
+ readonly 'skill.check.upToDate': {
352
+ readonly ja: " ✓ {label} (最新)";
353
+ readonly en: " ✓ {label} (up to date)";
354
+ };
355
+ readonly 'skill.check.allLatest': {
356
+ readonly ja: "すべてのスキルが最新です。";
357
+ readonly en: "All skills are up to date.";
358
+ };
359
+ readonly 'skill.check.outdated': {
360
+ readonly ja: "{count} 件のツールに差分があります。`{invoke} skill update` で最新に更新できます。";
361
+ readonly en: "{count} tools have changes. Run `{invoke} skill update` to update them.";
362
+ };
363
+ readonly 'skill.check.diffModified': {
364
+ readonly ja: "変更 {count}";
365
+ readonly en: "modified {count}";
366
+ };
367
+ readonly 'skill.check.diffAdded': {
368
+ readonly ja: "追加 {count}";
369
+ readonly en: "added {count}";
370
+ };
371
+ readonly 'skill.check.diffDeleted': {
372
+ readonly ja: "削除 {count}";
373
+ readonly en: "deleted {count}";
374
+ };
375
+ readonly 'config.legacyWarning': {
376
+ readonly ja: "[deprecated] {filename} は廃止予定です。\"{invoke} ui init\" で lism.config.js へ移行してください。";
377
+ readonly en: "[deprecated] {filename} is deprecated. Run \"{invoke} ui init\" to migrate to lism.config.js.";
378
+ };
379
+ readonly 'config.notFound': {
380
+ readonly ja: "lism.config.js / lism.config.mjs / lism-ui.json のいずれも見つかりません。";
381
+ readonly en: "None of lism.config.js / lism.config.mjs / lism-ui.json were found.";
382
+ };
383
+ readonly 'config.cliSectionMissing': {
384
+ readonly ja: "{filename} から CLI 設定(cli キー)を読み込めませんでした。";
385
+ readonly en: "Failed to read the CLI config (cli key) from {filename}.";
386
+ };
387
+ readonly 'config.invalidFramework': {
388
+ readonly ja: "cli.framework は \"react\" または \"astro\" を指定してください。";
389
+ readonly en: "cli.framework must be \"react\" or \"astro\".";
390
+ };
391
+ readonly 'config.invalidComponentsDir': {
392
+ readonly ja: "cli.componentsDir は文字列で指定してください。";
393
+ readonly en: "cli.componentsDir must be a string.";
394
+ };
395
+ readonly 'config.invalidHelperDir': {
396
+ readonly ja: "cli.helperDir は文字列で指定してください。";
397
+ readonly en: "cli.helperDir must be a string.";
398
+ };
399
+ readonly 'config.loadFailed': {
400
+ readonly ja: "{path} を読み込めませんでした(構文エラー等)。修正してから再実行してください: {reason}";
401
+ readonly en: "Failed to load {path} (syntax error, etc). Please fix it and retry: {reason}";
402
+ };
403
+ readonly 'common.done': {
404
+ readonly ja: "完了しました。";
405
+ readonly en: "Done.";
406
+ };
407
+ readonly 'common.help': {
408
+ readonly ja: "ヘルプを表示";
409
+ readonly en: "Show help";
410
+ };
411
+ };
412
+ type MessageKey = keyof typeof messages;
413
+
414
+ /**
415
+ * CLI の i18n(多言語化)基盤。
416
+ *
417
+ * - 既定は英語(`en`)。環境ロケールが `ja*` のときのみ日本語(`ja`)に切り替わる。
418
+ * - `--lang <code>` オプションで明示上書き可能。
419
+ * - メッセージ辞書は `messages.ts` に集約。
420
+ */
421
+
422
+ type Lang = 'ja' | 'en';
423
+ /** 現在の言語を設定する(未知の値は無視) */
424
+ declare function setLang(lang: string | undefined): void;
425
+ /**
426
+ * メッセージキーから現在の言語の文字列を取得し、必要に応じて `{name}` プレースホルダーを置換する。
427
+ */
428
+ declare function t(key: MessageKey, vars?: Record<string, string | number>): string;
429
+ /**
430
+ * ロケール非依存の 2 言語オブジェクトから現在の言語の値を返す。
431
+ * TEMPLATES の label/description や、辞書化しにくい一時的な二択文字列で使う。
432
+ */
433
+ declare function tOf<T>(pair: {
434
+ ja: T;
435
+ en: T;
436
+ }): T;
437
+
438
+ export { type Lang, type RunCreateArgs, runCreate, setLang, t, tOf };
package/dist/lib.js CHANGED
@@ -1,6 +1,12 @@
1
1
  import {
2
- runCreate
3
- } from "./chunk-4TQG5MGT.js";
2
+ runCreate,
3
+ setLang,
4
+ t,
5
+ tOf
6
+ } from "./chunk-3PSCUHIC.js";
4
7
  export {
5
- runCreate
8
+ runCreate,
9
+ setLang,
10
+ t,
11
+ tOf
6
12
  };
package/package.json CHANGED
@@ -1,7 +1,19 @@
1
1
  {
2
2
  "name": "lism-cli",
3
- "version": "0.0.1",
4
- "description": "CLI for adding Lism UI components to your project",
3
+ "version": "0.3.1",
4
+ "description": "CLI for scaffolding projects and adding UI components for Lism CSS / Lism UI.",
5
+ "author": {
6
+ "name": "ddryo",
7
+ "url": "https://github.com/ddryo"
8
+ },
9
+ "license": "MIT",
10
+ "keywords": [
11
+ "lism-css",
12
+ "cli",
13
+ "scaffolding",
14
+ "astro",
15
+ "react"
16
+ ],
5
17
  "type": "module",
6
18
  "bin": {
7
19
  "lism": "./bin/lism.mjs"
@@ -18,12 +30,13 @@
18
30
  "dist",
19
31
  "bin"
20
32
  ],
21
- "scripts": {
22
- "format": "prettier --write . --ignore-path ../../.prettierignore",
23
- "build": "tsup",
24
- "dev": "tsup --watch",
25
- "test": "vitest run",
26
- "prepublishOnly": "pnpm build"
33
+ "homepage": "https://lism-css.com/",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/lism-css/lism-css/tree/main/packages/lism-cli"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/lism-css/lism-css/issues"
27
40
  },
28
41
  "dependencies": {
29
42
  "@inquirer/prompts": "^7.0.0",
@@ -40,5 +53,10 @@
40
53
  "engines": {
41
54
  "node": ">=18.0.0"
42
55
  },
43
- "license": "MIT"
44
- }
56
+ "scripts": {
57
+ "format": "prettier --write . --ignore-path ../../.prettierignore",
58
+ "build": "tsup",
59
+ "dev": "tsup --watch",
60
+ "test": "vitest run"
61
+ }
62
+ }
@@ -1,137 +0,0 @@
1
- // src/commands/create.ts
2
- import fs from "fs";
3
- import path from "path";
4
- import { downloadTemplate } from "giget";
5
- import { select, input, confirm } from "@inquirer/prompts";
6
-
7
- // src/logger.ts
8
- import pc from "picocolors";
9
- var logger = {
10
- info(msg) {
11
- console.log(pc.cyan(msg));
12
- },
13
- success(msg) {
14
- console.log(pc.green(msg));
15
- },
16
- warn(msg) {
17
- console.log(pc.yellow(`WARN: ${msg}`));
18
- },
19
- error(msg) {
20
- console.error(pc.red(`ERROR: ${msg}`));
21
- },
22
- log(msg) {
23
- console.log(msg);
24
- }
25
- };
26
-
27
- // src/version.ts
28
- var LISM_CSS_VERSION = "0.14.0" ? "0.14.0" : "unknown";
29
- var CLI_VERSION = "0.0.1" ? "0.0.1" : "unknown";
30
-
31
- // src/constants.ts
32
- var SOURCE_REPO = "lism-css/lism-css";
33
- var RAW_GITHUB_BASE = "https://raw.githubusercontent.com";
34
- var DEFAULT_UI_REF = "main";
35
- var DEFAULT_SKILL_REF = "main";
36
- var DEFAULT_TEMPLATES_REF = "main";
37
- var UI_COMPONENTS_PATH = "packages/lism-ui/src/components";
38
- var UI_HELPER_PATH = "packages/lism-ui/src/helper";
39
- var UI_REGISTRY_INDEX_PATH = "packages/lism-ui/registry-index.json";
40
- var SKILL_SOURCE_PATH = "skills/lism-css-guide";
41
- var EXAMPLES_PATH = "examples";
42
-
43
- // src/commands/create.ts
44
- var TEMPLATES = [{ name: "astro-minimal", label: "Astro (minimal)", description: "Astro \u30D9\u30FC\u30B9\u306E\u6700\u5C0F\u69CB\u6210" }];
45
- async function runCreate({ template, targetDir, force = false }) {
46
- const tpl = await resolveTemplate(template);
47
- const outDir = path.resolve(process.cwd(), await resolveTargetDir(targetDir, tpl.name));
48
- if (fs.existsSync(outDir) && fs.readdirSync(outDir).length > 0 && !force) {
49
- const ok = await confirm({
50
- message: `${outDir} \u306F\u65E2\u306B\u5B58\u5728\u3057\u3001\u7A7A\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u4E0A\u66F8\u304D\u3057\u307E\u3059\u304B\uFF1F`,
51
- default: false
52
- });
53
- if (!ok) {
54
- logger.warn("\u4E2D\u65AD\u3057\u307E\u3057\u305F\u3002");
55
- return;
56
- }
57
- }
58
- const ref = DEFAULT_TEMPLATES_REF;
59
- logger.info(`\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8 "${tpl.name}" \u3092\u53D6\u5F97\u4E2D\uFF08ref: ${ref}\uFF09...`);
60
- await downloadTemplate(`github:${SOURCE_REPO}/${EXAMPLES_PATH}/${tpl.name}#${ref}`, {
61
- dir: outDir,
62
- force: true,
63
- forceClean: force
64
- });
65
- rewriteWorkspaceDeps(outDir);
66
- logger.success(`${outDir} \u306B\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u751F\u6210\u3057\u307E\u3057\u305F\u3002`);
67
- logger.log("");
68
- logger.log("\u6B21\u306E\u30B3\u30DE\u30F3\u30C9\u3067\u958B\u767A\u3092\u958B\u59CB\u3067\u304D\u307E\u3059:");
69
- const rel = path.relative(process.cwd(), outDir) || ".";
70
- logger.log(` cd ${rel}`);
71
- logger.log(" npm install # or pnpm install / yarn");
72
- logger.log(" npm run dev");
73
- }
74
- async function createCommand(targetDir, options) {
75
- await runCreate({ template: options.template, targetDir, force: options.force });
76
- }
77
- async function resolveTemplate(requested) {
78
- if (requested) {
79
- const found = TEMPLATES.find((t) => t.name === requested);
80
- if (!found) {
81
- throw new Error(`\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8 "${requested}" \u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002\u5229\u7528\u53EF\u80FD: ${TEMPLATES.map((t) => t.name).join(", ")}`);
82
- }
83
- return found;
84
- }
85
- const picked = await select({
86
- message: "\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044:",
87
- choices: TEMPLATES.map((t) => ({ name: `${t.label} \u2014 ${t.description}`, value: t.name }))
88
- });
89
- return TEMPLATES.find((t) => t.name === picked);
90
- }
91
- async function resolveTargetDir(provided, templateName) {
92
- if (provided) return provided;
93
- return input({
94
- message: "\u51FA\u529B\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA:",
95
- default: `./${templateName}`
96
- });
97
- }
98
- function rewriteWorkspaceDeps(projectDir) {
99
- const pkgPath = path.join(projectDir, "package.json");
100
- if (!fs.existsSync(pkgPath)) return;
101
- try {
102
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
103
- let touched = false;
104
- for (const key of ["dependencies", "devDependencies", "peerDependencies"]) {
105
- const deps = pkg[key];
106
- if (!deps) continue;
107
- for (const [name, value] of Object.entries(deps)) {
108
- if (typeof value !== "string") continue;
109
- if (value.startsWith("workspace:")) {
110
- deps[name] = `^${LISM_CSS_VERSION}`;
111
- touched = true;
112
- }
113
- }
114
- }
115
- if (touched) {
116
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
117
- logger.log(` package.json \u306E workspace:* \u3092 ^${LISM_CSS_VERSION} \u306B\u7F6E\u63DB\u3057\u307E\u3057\u305F\u3002`);
118
- }
119
- } catch (err) {
120
- logger.warn(`package.json \u306E\u66F8\u304D\u63DB\u3048\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${String(err)}`);
121
- }
122
- }
123
-
124
- export {
125
- logger,
126
- SOURCE_REPO,
127
- RAW_GITHUB_BASE,
128
- DEFAULT_UI_REF,
129
- DEFAULT_SKILL_REF,
130
- UI_COMPONENTS_PATH,
131
- UI_HELPER_PATH,
132
- UI_REGISTRY_INDEX_PATH,
133
- SKILL_SOURCE_PATH,
134
- CLI_VERSION,
135
- runCreate,
136
- createCommand
137
- };