atomsystem 0.1.35 → 0.1.37
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/build/build-tokens.js +2 -2
- package/cli/init.js +85 -10
- package/package.json +1 -1
package/build/build-tokens.js
CHANGED
|
@@ -181,9 +181,9 @@ myStyleDictionary.registerFormat({
|
|
|
181
181
|
|
|
182
182
|
// global(@theme)인 경우에만 수집해둔 시멘틱 변수(semanticCss)를 추가
|
|
183
183
|
// @theme: Tailwind 유틸리티 클래스 생성에 필요 (bg-primary, text-secondary 등)
|
|
184
|
-
//
|
|
184
|
+
// Tailwind CSS v4의 @theme은 빌드 시 자동으로 :root에도 등록되므로 별도 :root 선언 불필요
|
|
185
185
|
if (selector === "@theme") {
|
|
186
|
-
return `@theme {\n${cssVariables}\n\n${semanticCss}\n}
|
|
186
|
+
return `@theme {\n${cssVariables}\n\n${semanticCss}\n}`;
|
|
187
187
|
}
|
|
188
188
|
return `${selector} {\n${cssVariables}\n} `;
|
|
189
189
|
})
|
package/cli/init.js
CHANGED
|
@@ -17,6 +17,7 @@ const __dirname = path.dirname(__filename);
|
|
|
17
17
|
const packageRoot = path.join(__dirname, "..");
|
|
18
18
|
const tokenFile = path.join(packageRoot, "tokens", "tokens.json");
|
|
19
19
|
const buildFile = path.join(packageRoot, "build", "build-tokens.js");
|
|
20
|
+
const textCssFile = path.join(packageRoot, "css", "text.css");
|
|
20
21
|
|
|
21
22
|
// 프로젝트 루트 경로 (사용자가 실행한 곳)
|
|
22
23
|
const projectRoot = process.cwd();
|
|
@@ -24,6 +25,16 @@ const targetTokenDir = path.join(projectRoot, "tokens");
|
|
|
24
25
|
const targetTokenFile = path.join(targetTokenDir, "tokens.json");
|
|
25
26
|
const targetBuildDir = path.join(projectRoot, "build");
|
|
26
27
|
const targetBuildFile = path.join(targetBuildDir, "build-tokens.js");
|
|
28
|
+
const targetCssDir = path.join(projectRoot, "css");
|
|
29
|
+
const targetTextCssFile = path.join(targetCssDir, "text.css");
|
|
30
|
+
|
|
31
|
+
// 파일 복사 헬퍼: 대상 디렉토리 생성 → 파일 복사 → 로그 출력
|
|
32
|
+
function copyTo(src, dest, label) {
|
|
33
|
+
const dir = path.dirname(dest);
|
|
34
|
+
if (!fs.existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
35
|
+
copyFileSync(src, dest);
|
|
36
|
+
console.log(`✅ Copied: ${label} -> ${dest}`);
|
|
37
|
+
}
|
|
27
38
|
|
|
28
39
|
// 사용자 프로젝트에 package.json이 존재하는지 먼저 확인 (안전장치)
|
|
29
40
|
const packageJsonPath = path.join(projectRoot, "package.json");
|
|
@@ -49,7 +60,7 @@ inquirer
|
|
|
49
60
|
|
|
50
61
|
try {
|
|
51
62
|
await execPromise(
|
|
52
|
-
"npm install next@latest react@latest react-dom@latest tailwindcss clsx react-modal typescript @types/react @types/node @types/react-dom @types/react-modal"
|
|
63
|
+
"npm install next@latest react@latest react-dom@latest tailwindcss @tailwindcss/postcss postcss clsx react-modal typescript @types/react @types/node @types/react-dom @types/react-modal"
|
|
53
64
|
);
|
|
54
65
|
pkgSpinner.succeed("Next.js and React installation complete!");
|
|
55
66
|
} catch (err) {
|
|
@@ -118,7 +129,8 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|
|
118
129
|
{
|
|
119
130
|
path: path.join(appDir, "globals.css"),
|
|
120
131
|
content: `@import "tailwindcss";
|
|
121
|
-
@import "../build/css/_variables.css"
|
|
132
|
+
@import "../build/css/_variables.css";
|
|
133
|
+
@import "../css/text.css";`,
|
|
122
134
|
},
|
|
123
135
|
{
|
|
124
136
|
path: path.join(appDir, "page.tsx"),
|
|
@@ -160,6 +172,56 @@ export default function Page() {
|
|
|
160
172
|
)
|
|
161
173
|
}`,
|
|
162
174
|
},
|
|
175
|
+
// ✅ tsconfig.json: "@/*" 경로 별칭 설정 (예: @/build/typescript/theme)
|
|
176
|
+
{
|
|
177
|
+
path: path.join(projectRoot, "tsconfig.json"),
|
|
178
|
+
content: JSON.stringify({
|
|
179
|
+
compilerOptions: {
|
|
180
|
+
target: "ES2017",
|
|
181
|
+
lib: ["dom", "dom.iterable", "esnext"],
|
|
182
|
+
allowJs: true,
|
|
183
|
+
skipLibCheck: true,
|
|
184
|
+
strict: true,
|
|
185
|
+
noEmit: true,
|
|
186
|
+
esModuleInterop: true,
|
|
187
|
+
module: "esnext",
|
|
188
|
+
moduleResolution: "bundler",
|
|
189
|
+
resolveJsonModule: true,
|
|
190
|
+
isolatedModules: true,
|
|
191
|
+
jsx: "preserve",
|
|
192
|
+
incremental: true,
|
|
193
|
+
plugins: [{ name: "next" }],
|
|
194
|
+
paths: {
|
|
195
|
+
"@/*": ["./*"]
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
include: ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
199
|
+
exclude: ["node_modules"]
|
|
200
|
+
}, null, 2),
|
|
201
|
+
},
|
|
202
|
+
// ✅ next.config.ts: Next.js 기본 설정
|
|
203
|
+
{
|
|
204
|
+
path: path.join(projectRoot, "next.config.ts"),
|
|
205
|
+
content: `import type { NextConfig } from "next";
|
|
206
|
+
|
|
207
|
+
const nextConfig: NextConfig = {
|
|
208
|
+
reactStrictMode: false,
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export default nextConfig;`,
|
|
212
|
+
},
|
|
213
|
+
// ✅ postcss.config.mjs: Tailwind CSS v4 PostCSS 플러그인 등록 (@theme, @import "tailwindcss" 인식)
|
|
214
|
+
{
|
|
215
|
+
path: path.join(projectRoot, "postcss.config.mjs"),
|
|
216
|
+
content: `/** @type {import('postcss-load-config').Config} */
|
|
217
|
+
const config = {
|
|
218
|
+
plugins: {
|
|
219
|
+
"@tailwindcss/postcss": {},
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export default config;`,
|
|
224
|
+
},
|
|
163
225
|
];
|
|
164
226
|
|
|
165
227
|
files.forEach(({ path, content }) => {
|
|
@@ -167,6 +229,23 @@ export default function Page() {
|
|
|
167
229
|
console.log(`✅ Created ${path}`);
|
|
168
230
|
});
|
|
169
231
|
|
|
232
|
+
// ✅ 토큰 빌드 먼저 실행: Theme.tsx가 @/build/typescript/theme를 import하므로
|
|
233
|
+
// 컴포넌트 복사 전에 build-tokens.js를 실행해 theme.ts를 미리 생성해야 합니다.
|
|
234
|
+
const buildTokensPath = path.join(projectRoot, "build", "build-tokens.js");
|
|
235
|
+
if (fs.existsSync(buildTokensPath)) {
|
|
236
|
+
const tokenBuildSpinner = ora("Building design tokens (generating build/typescript/theme.ts)...").start();
|
|
237
|
+
try {
|
|
238
|
+
await execPromise(`node "${buildTokensPath}"`, { cwd: projectRoot });
|
|
239
|
+
tokenBuildSpinner.succeed("Design tokens built successfully!");
|
|
240
|
+
} catch (err) {
|
|
241
|
+
tokenBuildSpinner.fail("Error during token build");
|
|
242
|
+
console.error(err);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
console.warn("⚠️ build-tokens.js not found, skipping token build.");
|
|
247
|
+
}
|
|
248
|
+
|
|
170
249
|
// add.js를 실행하여 Theme, Card 컴포넌트 및 하위 의존성을 복사합니다.
|
|
171
250
|
const addScriptPath = path.join(__dirname, "add.js");
|
|
172
251
|
if (fs.existsSync(addScriptPath)) {
|
|
@@ -185,14 +264,10 @@ export default function Page() {
|
|
|
185
264
|
console.log("🚀 Installation skipped.");
|
|
186
265
|
}
|
|
187
266
|
|
|
188
|
-
// ✅
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (!fs.existsSync(targetBuildDir)) mkdirSync(targetBuildDir, { recursive: true });
|
|
194
|
-
copyFileSync(buildFile, targetBuildFile);
|
|
195
|
-
console.log(`✅ Copied: build-tokens.js -> ${targetBuildFile}`);
|
|
267
|
+
// ✅ 필수 파일 복사 (Next.js 설치 여부와 관계없이 실행)
|
|
268
|
+
copyTo(tokenFile, targetTokenFile, "tokens/tokens.json");
|
|
269
|
+
copyTo(buildFile, targetBuildFile, "build/build-tokens.js");
|
|
270
|
+
copyTo(textCssFile, targetTextCssFile, "css/text.css");
|
|
196
271
|
|
|
197
272
|
console.log("🚀 Token setup complete!");
|
|
198
273
|
})
|