@plus-experience/design-system-carbon 0.2.7 → 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 +44 -10
  2. package/package.json +1 -1
package/bin/setup.js CHANGED
@@ -45,18 +45,33 @@ log("Carbon + UI 의존성 설치");
45
45
 
46
46
  // 5. dev 의존성 — sass는 더 이상 필요 없음 (carbon.css 사전 컴파일 사용)
47
47
 
48
+ const styleImport = '@import "@plus-experience/design-system-carbon/styles.css";';
49
+ const targetCss = path.join(appDir, "globals.css");
48
50
  const srcCss = path.join(cwd, "node_modules/@plus-experience/design-system-carbon/app/globals.css");
49
- if (fs.existsSync(srcCss)) {
50
- let cssContent = fs.readFileSync(srcCss, "utf8");
51
- const styleImport = '@import "@plus-experience/design-system-carbon/styles.css";';
52
- if (!cssContent.includes(styleImport)) {
53
- cssContent = cssContent.replace(
54
- '@import "tailwindcss/theme"',
55
- '@import "tailwindcss/theme"' + '\n' + styleImport
56
- );
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);
57
68
  }
58
- fs.writeFileSync(path.join(appDir, "globals.css"), cssContent);
59
- 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 생성");
60
75
  }
61
76
 
62
77
  // 7. carbon.scss는 더 이상 복사하지 않음 — 사전 컴파일된 carbon.css를 직접 import
@@ -128,6 +143,25 @@ console.log(' import { Button } from "@plus-experience/design-system-carbon/ui
128
143
 
129
144
  // --- helpers ---
130
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
+
131
165
  function patchNextConfig() {
132
166
  const candidates = ["next.config.ts", "next.config.mjs", "next.config.js"];
133
167
  let configPath = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plus-experience/design-system-carbon",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",