@plus-experience/design-system-carbon 0.2.6 → 0.2.8

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.
Files changed (2) hide show
  1. package/bin/setup.js +58 -24
  2. package/package.json +1 -1
package/bin/setup.js CHANGED
@@ -43,29 +43,42 @@ if (!pkg.dependencies?.next) {
43
43
  run("npm install @carbon/react @carbon/icons-react @ibm/plex clsx tailwind-merge next-themes date-fns recharts");
44
44
  log("Carbon + UI 의존성 설치");
45
45
 
46
- // 5. dev 의존성 (sass)
47
- run("npm install -D sass");
48
- log("sass 설치");
46
+ // 5. dev 의존성 — sass는 더 이상 필요 없음 (carbon.css 사전 컴파일 사용)
49
47
 
48
+ const styleImport = '@import "@plus-experience/design-system-carbon/styles.css";';
49
+ const targetCss = path.join(appDir, "globals.css");
50
50
  const srcCss = path.join(cwd, "node_modules/@plus-experience/design-system-carbon/app/globals.css");
51
- if (fs.existsSync(srcCss)) {
52
- let cssContent = fs.readFileSync(srcCss, "utf8");
53
- const styleImport = '@import "@plus-experience/design-system-carbon/styles.css";';
54
- if (!cssContent.includes(styleImport)) {
55
- cssContent = cssContent.replace(
56
- '@import "tailwindcss/theme"',
57
- '@import "tailwindcss/theme"' + '\n' + styleImport
58
- );
51
+
52
+ if (fs.existsSync(targetCss)) {
53
+ // Don't overwrite user's globals.css — only inject our import line.
54
+ let cssContent = fs.readFileSync(targetCss, "utf8");
55
+ if (cssContent.includes(styleImport)) {
56
+ log("globals.css — 이미 import (스킵)");
57
+ } else {
58
+ // Repair the previous broken patcher's output if present.
59
+ const brokenPattern = /@import\s+["']tailwindcss\/theme["']\s*\n\s*@import\s+["']@plus-experience\/design-system-carbon\/styles\.css["'];\s*([^;]*;)/;
60
+ if (brokenPattern.test(cssContent)) {
61
+ cssContent = cssContent.replace(brokenPattern, `@import "tailwindcss/theme" $1\n${styleImport}`);
62
+ log("globals.css — 깨진 import 라인 복구");
63
+ } else {
64
+ cssContent = injectStyleImport(cssContent, styleImport);
65
+ log("globals.css — Carbon styles import 추가");
66
+ }
67
+ fs.writeFileSync(targetCss, cssContent);
59
68
  }
60
- fs.writeFileSync(path.join(appDir, "globals.css"), cssContent);
61
- log("globals.css 복사");
69
+ } else if (fs.existsSync(srcCss)) {
70
+ // No globals.css yet — seed from our template with the import injected.
71
+ let cssContent = fs.readFileSync(srcCss, "utf8");
72
+ cssContent = injectStyleImport(cssContent, styleImport);
73
+ fs.writeFileSync(targetCss, cssContent);
74
+ log("globals.css 생성");
62
75
  }
63
76
 
64
- // 7. carbon.scss 복사
65
- const srcScss = path.join(cwd, "node_modules/@plus-experience/design-system-carbon/app/carbon.scss");
66
- if (fs.existsSync(srcScss)) {
67
- fs.copyFileSync(srcScss, path.join(appDir, "carbon.scss"));
68
- log("carbon.scss 복사");
77
+ // 7. carbon.scss 더 이상 복사하지 않음 — 사전 컴파일된 carbon.css를 직접 import
78
+ const legacyScss = path.join(appDir, "carbon.scss");
79
+ if (fs.existsSync(legacyScss)) {
80
+ fs.unlinkSync(legacyScss);
81
+ log("기존 carbon.scss 제거 (carbon.css로 마이그레이션)");
69
82
  }
70
83
 
71
84
  // 8. DESIGN_SYSTEM.md + CLAUDE.md + AGENTS.md 설정
@@ -130,6 +143,25 @@ console.log(' import { Button } from "@plus-experience/design-system-carbon/ui
130
143
 
131
144
  // --- helpers ---
132
145
 
146
+ function injectStyleImport(cssContent, styleImport) {
147
+ if (cssContent.includes(styleImport)) return cssContent;
148
+
149
+ // Prefer placing right after a tailwind import so layer order is sane.
150
+ const tailwindImport = cssContent.match(/@import\s+["']tailwindcss[^"']*["'][^;]*;/);
151
+ if (tailwindImport) {
152
+ return cssContent.replace(tailwindImport[0], `${tailwindImport[0]}\n${styleImport}`);
153
+ }
154
+
155
+ // Fall back to any other top-level @import.
156
+ const anyImport = cssContent.match(/@import[^;]*;/);
157
+ if (anyImport) {
158
+ return cssContent.replace(anyImport[0], `${anyImport[0]}\n${styleImport}`);
159
+ }
160
+
161
+ // No imports at all — prepend to the file.
162
+ return `${styleImport}\n${cssContent}`;
163
+ }
164
+
133
165
  function patchNextConfig() {
134
166
  const candidates = ["next.config.ts", "next.config.mjs", "next.config.js"];
135
167
  let configPath = null;
@@ -257,21 +289,23 @@ function patchLayout() {
257
289
  modified = true;
258
290
  }
259
291
 
260
- // Add carbon.scss import if not present
261
- if (!content.includes("carbon.scss")) {
262
- const importLine = 'import "./carbon.scss";';
292
+ // Migrate legacy carbon.scss import carbon.css from package
293
+ const carbonCssImport = 'import "@plus-experience/design-system-carbon/carbon.css";';
294
+ if (/import\s+["']\.\/carbon\.scss["'];?/.test(content)) {
295
+ content = content.replace(/import\s+["']\.\/carbon\.scss["'];?/, carbonCssImport);
296
+ modified = true;
297
+ } else if (!content.includes("@plus-experience/design-system-carbon/carbon.css")) {
263
298
  if (content.includes("import")) {
264
- // Add after last import
265
299
  const lastImportIdx = content.lastIndexOf("import ");
266
300
  const endOfLine = content.indexOf("\n", lastImportIdx);
267
- content = content.slice(0, endOfLine + 1) + importLine + "\n" + content.slice(endOfLine + 1);
301
+ content = content.slice(0, endOfLine + 1) + carbonCssImport + "\n" + content.slice(endOfLine + 1);
268
302
  modified = true;
269
303
  }
270
304
  }
271
305
 
272
306
  if (modified) {
273
307
  fs.writeFileSync(layoutPath, content);
274
- log("app/layout — dark 클래스 + carbon.scss import 추가");
308
+ log("app/layout — dark 클래스 + carbon.css import 추가");
275
309
  } else {
276
310
  log("app/layout — 이미 설정됨 (스킵)");
277
311
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plus-experience/design-system-carbon",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",