sparkle-design-cli 1.3.0 → 1.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/README.md CHANGED
@@ -76,6 +76,44 @@ sparkle-design-cli -c ./config/custom.json -o ./dist/styles.css
76
76
  - `font-pro`: プロポーショナルフォント(Google Fonts の名前)
77
77
  - `font-mono`: モノスペースフォント(Google Fonts の名前)
78
78
  - `radius`: 角丸設定(sm, md, lg など)
79
+ - `source-packages`: (オプション)`@source` ディレクティブで追加スキャンする npm パッケージの配列
80
+
81
+ ### source-packages オプション
82
+
83
+ `@goodpatch/sparkle-design` を npm パッケージとして利用するプロジェクトでは、TailwindCSS v4 がパッケージ内のユーティリティクラスを検出できるように `@source` ディレクティブが必要です。
84
+
85
+ `source-packages` を設定すると、CLI が `globals.css` に `@source` ディレクティブを自動挿入します。`@goodpatch/sparkle-design` は常にデフォルトで含まれます。
86
+
87
+ ```json
88
+ {
89
+ "primary": "blue",
90
+ "font-mono": "BIZ UDGothic",
91
+ "font-pro": "BIZ UDPGothic",
92
+ "radius": "md",
93
+ "source-packages": []
94
+ }
95
+ ```
96
+
97
+ 追加の npm パッケージ(拡張リポジトリなど)をスキャン対象にする場合:
98
+
99
+ ```json
100
+ {
101
+ "source-packages": ["@scope/my-extension-design"]
102
+ }
103
+ ```
104
+
105
+ 生成される `globals.css`:
106
+
107
+ ```css
108
+ @import "tailwindcss";
109
+ /* npm パッケージのコンテンツスキャン(Tailwind がクラスを検出するために必要) */
110
+ @source "../node_modules/@goodpatch/sparkle-design/dist";
111
+ @source "../node_modules/@scope/my-extension-design/dist";
112
+ /* Sparkle Design のカスタム定義(Tailwindの後にインポート) */
113
+ @import "./sparkle-design.css";
114
+ ```
115
+
116
+ > **注意**: `source-packages` を指定しない場合、`@source` ディレクティブは生成されません。
79
117
 
80
118
  ## 出力
81
119
 
@@ -53,6 +53,9 @@ function createSourceBlock(sourcePackages = []) {
53
53
  * @returns {string} sparkle-design.css importブロック
54
54
  */
55
55
  function createSparkleImportBlock(sourcePackages = []) {
56
+ if (sourcePackages === null || sourcePackages === undefined) {
57
+ return ['', COMMENTS.SPARKLE_IMPORT, IMPORTS.SPARKLE_DESIGN, ''].join('\n');
58
+ }
56
59
  return ['', createSourceBlock(sourcePackages), COMMENTS.SPARKLE_IMPORT, IMPORTS.SPARKLE_DESIGN, ''].join('\n');
57
60
  }
58
61
 
@@ -128,10 +131,10 @@ function reconstructGlobalsCss(globalsContent, fontImportBlock, sparkleImportBlo
128
131
  * - sparkle-design.css importをTailwindの後に配置
129
132
  * @param {Array<string>} fontImports フォントimport文の配列
130
133
  * @param {string} globalsPath globals.cssのパス
131
- * @param {Array<string>} sourcePackages 追加パッケージ名の配列
134
+ * @param {Array<string>|null} sourcePackages 追加パッケージ名の配列(null の場合は @source を生成しない)
132
135
  * @returns {boolean} globals.css の更新に成功した場合は true
133
136
  */
134
- export function updateGlobalsWithFonts(fontImports, globalsPath, sourcePackages = []) {
137
+ export function updateGlobalsWithFonts(fontImports, globalsPath, sourcePackages = null) {
135
138
  if (fontImports.length === 0) {
136
139
  return false;
137
140
  }
@@ -177,9 +180,9 @@ export function updateGlobalsWithFonts(fontImports, globalsPath, sourcePackages
177
180
  * フォント管理の自動処理を実行する
178
181
  * sparkle-design.css からフォントimportを抽出し、globals.css に移動する
179
182
  * @param {string} sparkleDesignPath sparkle-design.cssのパス
180
- * @param {Array<string>} sourcePackages 追加パッケージ名の配列
183
+ * @param {Array<string>|null} sourcePackages 追加パッケージ名の配列(null の場合は @source を生成しない)
181
184
  */
182
- export function manageFontImports(sparkleDesignPath, sourcePackages = []) {
185
+ export function manageFontImports(sparkleDesignPath, sourcePackages = null) {
183
186
  try {
184
187
  // 1. globals.cssのパスを推定(sparkle-design.cssと同じディレクトリ)
185
188
  const globalsPath = path.join(path.dirname(sparkleDesignPath), 'globals.css');
@@ -137,7 +137,7 @@ export function generateCSS(configPath = null, outputPath = null) {
137
137
 
138
138
  // 6. フォント管理の自動処理を実行
139
139
  console.log(MESSAGES.FONT_MANAGEMENT_START);
140
- const sourcePackages = config['source-packages'] || [];
140
+ const sourcePackages = 'source-packages' in config ? (config['source-packages'] || []) : null;
141
141
  manageFontImports(resolvedOutputPath, sourcePackages);
142
142
 
143
143
  console.log(MESSAGES.SUCCESS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sparkle-design-cli",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Sparkle Design CSS Generator - デザインシステムCSSを設定ファイルから生成するツール",
5
5
  "main": "lib/generate-css.js",
6
6
  "type": "module",