ksk-design-system 1.61.0 → 1.61.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.
@@ -513,5 +513,7 @@ const invokedDirectly =
513
513
 
514
514
  if (invokedDirectly) {
515
515
  const pkgRoot = resolve(dirname(new URL(import.meta.url).pathname), "..")
516
- process.exit(runCheckMigrationCli(process.argv.slice(2), { cwd: process.cwd(), pkgRoot }))
516
+ // process.exit() は stdout がパイプのとき未フラッシュ分を捨てる(issue #394)。
517
+ // ここはモジュール末尾なので exitCode を立てれば、自然終了時に出力が掃かれる。
518
+ process.exitCode = runCheckMigrationCli(process.argv.slice(2), { cwd: process.cwd(), pkgRoot })
517
519
  }
package/bin/init.js CHANGED
@@ -35,6 +35,24 @@ const force = args.includes("--force")
35
35
  /** scripts/codemod/ 配下にあるが codemod として呼べないもの(雛形・読み取り専用スキャナ) */
36
36
  const NON_CODEMOD = new Set(["template", "check-migration"])
37
37
 
38
+ /**
39
+ * 出力を掃いてから終了する(issue #394)。
40
+ *
41
+ * stdout がパイプのとき Node の書き込みは非同期で、process.exit() は未フラッシュ分を
42
+ * 捨てる。`ksk-ds lint --format json | jq` のように出力が 64KB(パイプバッファ1個分)を
43
+ * 超えると、そこで切られた壊れた JSON が相手に渡っていた。ファイルへのリダイレクトでは
44
+ * 書き込みが同期なので再現せず、パイプのときだけ壊れる。
45
+ *
46
+ * stream の書き込みは順序が保証されるので、最後に積んだ空 write のコールバックは
47
+ * 先行する出力が全部掃けた後に呼ばれる。それを待ってから exit する。
48
+ */
49
+ async function exitWith(code) {
50
+ if (process.stdout.writable) {
51
+ await new Promise((resolve) => process.stdout.write("", () => resolve()))
52
+ }
53
+ process.exit(code)
54
+ }
55
+
38
56
  if (cmd === "help" || cmd === "--help" || cmd === "-h") {
39
57
  console.log(`ksk-design-system CLI
40
58
 
@@ -54,19 +72,19 @@ if (cmd === "help" || cmd === "--help" || cmd === "-h") {
54
72
  npx ksk-ds codemod <name> [DIR] --dry 破壊変更の自動移行(事前確認)
55
73
  npx ksk-ds codemod <name> [DIR] 破壊変更の自動移行(書き込み)
56
74
  `)
57
- process.exit(0)
75
+ await exitWith(0)
58
76
  }
59
77
 
60
78
  if (cmd === "lint") {
61
79
  const { runLintCli } = await import("./lint.js")
62
80
  const status = await runLintCli(args.slice(1), { cwd: process.cwd(), pkgRoot })
63
- process.exit(status)
81
+ await exitWith(status)
64
82
  }
65
83
 
66
84
  if (cmd === "check-migration") {
67
85
  const { runCheckMigrationCli } = await import("./check-migration.js")
68
86
  const status = runCheckMigrationCli(args.slice(1), { cwd: process.cwd(), pkgRoot })
69
- process.exit(status)
87
+ await exitWith(status)
70
88
  }
71
89
 
72
90
  if (cmd === "check-duplicates") {
@@ -75,22 +93,22 @@ if (cmd === "check-duplicates") {
75
93
  cwd: process.cwd(),
76
94
  pkgRoot,
77
95
  })
78
- process.exit(status)
96
+ await exitWith(status)
79
97
  }
80
98
 
81
99
  if (cmd === "codemod") {
82
- process.exit(runCodemod(args.slice(1)))
100
+ await exitWith(runCodemod(args.slice(1)))
83
101
  }
84
102
 
85
103
  if (cmd === "demo") {
86
104
  runDemo(args.slice(1))
87
- process.exit(0)
105
+ await exitWith(0)
88
106
  }
89
107
 
90
108
  if (cmd !== "init") {
91
109
  console.error(`未知のコマンド: ${cmd}`)
92
110
  console.error(`npx ksk-design-system help を参照してください`)
93
- process.exit(1)
111
+ await exitWith(1)
94
112
  }
95
113
 
96
114
  // ─── codemod ────────────────────────────────────────────────
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "name": "KSK Design System — Component Contracts",
4
- "version": "1.61.0",
4
+ "version": "1.61.1",
5
5
  "description": "全コンポーネントの構造化定義。バリアント・アクセシビリティ要件・使用ルールを機械可読形式で管理。",
6
6
  "counts": {
7
7
  "ui": 68,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "name": "KSK Design System — Semantic Token Hex Cache",
4
- "version": "1.61.0",
4
+ "version": "1.61.1",
5
5
  "description": "semantic / semanticDark トークン(var(--Primitive-*) 参照)を実 hex に解決したサイドカー生成物。hex はデフォルト(Blue)テーマでの解決値であり、Brand 系(meta.themeDependentKeys に列挙)はテーマ差し替え(orange/green/violet 等)で実色が変わる。テーマ別の完全解決値は `ksk-design-system/native` エクスポート(バンドル済み native トークンモジュール)の themes を参照。tokens.json 本体のスキーマは変更せず、AI がこのファイルだけで実色を把握できるようにし、primitive 値の変更による semantic 実色のドリフトを --check で機械検出する。",
6
6
  "generatedBy": "scripts/generate-token-hex-cache.mjs",
7
7
  "theme": "default",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ksk-design-system",
3
- "version": "1.61.0",
3
+ "version": "1.61.1",
4
4
  "type": "module",
5
5
  "description": "KSK Design System — フリーランス向けマルチテーマ対応デザインシステム",
6
6
  "license": "MIT",