sparkle-design-cli 1.3.10 → 1.3.11

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
@@ -23,7 +23,7 @@ npx sparkle-design-cli check src --strict
23
23
  npx sparkle-design-cli check src --format json
24
24
 
25
25
  # Claude / Codex / Cursor 向けの guard 設定を差し込む
26
- npx sparkle-design-cli setup --assistant claude
26
+ npx --yes sparkle-design-cli setup --assistant claude
27
27
  ```
28
28
 
29
29
  ### 後方互換モード
@@ -125,7 +125,7 @@ sparkle-design-cli check --help
125
125
  ```json
126
126
  {
127
127
  "scripts": {
128
- "lint:sparkle": "sparkle-design-cli check src --strict"
128
+ "lint:sparkle": "npx --yes sparkle-design-cli check src --strict"
129
129
  }
130
130
  }
131
131
  ```
@@ -138,16 +138,16 @@ AI エージェントや CI からこの `lint:sparkle` を呼ぶ運用にする
138
138
 
139
139
  ```bash
140
140
  # Claude Code 向け
141
- sparkle-design-cli setup --assistant claude
141
+ npx --yes sparkle-design-cli setup --assistant claude
142
142
 
143
143
  # Codex / AGENTS.md 向け
144
- sparkle-design-cli setup --assistant codex
144
+ npx --yes sparkle-design-cli setup --assistant codex
145
145
 
146
146
  # Cursor rules 向け
147
- sparkle-design-cli setup --assistant cursor
147
+ npx --yes sparkle-design-cli setup --assistant cursor
148
148
 
149
149
  # generic な Markdown を生成
150
- sparkle-design-cli setup --assistant generic
150
+ npx --yes sparkle-design-cli setup --assistant generic
151
151
  ```
152
152
 
153
153
  追加されるもの:
@@ -23,6 +23,31 @@ import {
23
23
  updateGlobalsWithFonts,
24
24
  } from './font-manager.js';
25
25
 
26
+ /**
27
+ * 同一のフォント @import を重複排除する
28
+ * @param {string} cssContent CSS内容
29
+ * @returns {string} 重複排除後のCSS
30
+ */
31
+ function dedupeFontImports(cssContent) {
32
+ const seen = new Set();
33
+
34
+ return cssContent
35
+ .split('\n')
36
+ .filter(line => {
37
+ if (!line.includes('fonts.googleapis.com')) {
38
+ return true;
39
+ }
40
+
41
+ if (seen.has(line)) {
42
+ return false;
43
+ }
44
+
45
+ seen.add(line);
46
+ return true;
47
+ })
48
+ .join('\n');
49
+ }
50
+
26
51
  /**
27
52
  * テンプレート変数を設定値で置換する
28
53
  * @param {string} template CSSテンプレート
@@ -71,6 +96,8 @@ function processTemplate(template, config, grayMapping, radiusMapping, colors) {
71
96
  console.log(MESSAGES.RADIUS_APPLIED(config.radius));
72
97
  }
73
98
 
99
+ processedCSS = dedupeFontImports(processedCSS);
100
+
74
101
  console.log(MESSAGES.TEMPLATE_PROCESSED);
75
102
  return processedCSS;
76
103
  }
@@ -163,6 +190,7 @@ export {
163
190
  hexToRgba,
164
191
  hexToOklch,
165
192
  generateColorTokens,
193
+ dedupeFontImports,
166
194
  // フォント管理
167
195
  extractFontImports,
168
196
  removeFontImportsFromCSS,
package/lib/setup.js CHANGED
@@ -21,6 +21,11 @@ const BLOCK_END = '<!-- sparkle-design-cli:setup:end -->';
21
21
  const TARGET_CANDIDATES = ['src', 'src/components', 'src/features', 'app', 'components'];
22
22
  const UNSAFE_TARGET_PATTERN = /[\s"'`;$&|<>()[\]{}\\]/;
23
23
 
24
+ function buildCheckScript(target, mode) {
25
+ const trailingArgs = mode === 'strict' ? '--strict' : '--format json';
26
+ return `npx --yes sparkle-design-cli check ${target} ${trailingArgs}`;
27
+ }
28
+
24
29
 
25
30
  function escapeRegExp(value) {
26
31
  return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -91,11 +96,18 @@ function isManagedSparkleScript(value, mode) {
91
96
  return false;
92
97
  }
93
98
 
94
- const tokens = value.trim().split(/\s+/);
99
+ let tokens = value.trim().split(/\s+/);
95
100
  if (tokens.length < 3) {
96
101
  return false;
97
102
  }
98
103
 
104
+ if (tokens[0] === 'npx') {
105
+ tokens = tokens.slice(1);
106
+ if (tokens[0] === '--yes') {
107
+ tokens = tokens.slice(1);
108
+ }
109
+ }
110
+
99
111
  if (tokens[0] !== 'sparkle-design-cli' || tokens[1] !== 'check') {
100
112
  return false;
101
113
  }
@@ -169,13 +181,13 @@ function updatePackageJson(filePath, target, force) {
169
181
 
170
182
  const strictResult = resolveScriptUpdate(
171
183
  scripts['lint:sparkle'],
172
- `sparkle-design-cli check ${target} --strict`,
184
+ buildCheckScript(target, 'strict'),
173
185
  'strict',
174
186
  force
175
187
  );
176
188
  const jsonResult = resolveScriptUpdate(
177
189
  scripts['lint:sparkle:json'],
178
- `sparkle-design-cli check ${target} --format json`,
190
+ buildCheckScript(target, 'json'),
179
191
  'json',
180
192
  force
181
193
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sparkle-design-cli",
3
- "version": "1.3.10",
3
+ "version": "1.3.11",
4
4
  "description": "Sparkle Design CSS Generator - デザインシステムCSSを設定ファイルから生成するツール",
5
5
  "main": "lib/generate-css.js",
6
6
  "type": "module",