atomsystem 0.1.22 → 0.1.24
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 +67 -0
- package/cli/add.js +0 -1
- package/cli/init.js +8 -6
- package/package.json +2 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import StyleDictionary from "style-dictionary";
|
|
2
|
+
|
|
3
|
+
const valueWithUnit = (val) => {
|
|
4
|
+
return typeof val === "number" ? `${val}px` : val;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// register it with register method
|
|
8
|
+
StyleDictionary.registerFormat({
|
|
9
|
+
name: "css/variables-multi-context",
|
|
10
|
+
format: ({ dictionary }) => {
|
|
11
|
+
const root = [];
|
|
12
|
+
const light = [];
|
|
13
|
+
const dark = [];
|
|
14
|
+
|
|
15
|
+
dictionary.allTokens.map((token) => {
|
|
16
|
+
const name = `--${token.name}`;
|
|
17
|
+
const val = token.value;
|
|
18
|
+
if (
|
|
19
|
+
typeof token.value === "object" &&
|
|
20
|
+
(token.value.light || token.value.dark)
|
|
21
|
+
) {
|
|
22
|
+
if (token.value.light) {
|
|
23
|
+
light.push(`${name}: ${valueWithUnit(val.light)};`);
|
|
24
|
+
}
|
|
25
|
+
if (token.value.dark) {
|
|
26
|
+
dark.push(`${name}: ${valueWithUnit(val.dark)};`);
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
root.push(`${name}: ${valueWithUnit(val)};`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return `
|
|
33
|
+
@import "tailwindcss";
|
|
34
|
+
|
|
35
|
+
@theme {
|
|
36
|
+
${root.join("\n")}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:root{
|
|
40
|
+
${root.join("\n")}
|
|
41
|
+
}
|
|
42
|
+
.light {
|
|
43
|
+
${light.join("\n")}
|
|
44
|
+
}
|
|
45
|
+
.dark {
|
|
46
|
+
${dark.join("\n")}
|
|
47
|
+
}`.trim();
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const sd = new StyleDictionary({
|
|
52
|
+
source: ["token.json"],
|
|
53
|
+
platforms: {
|
|
54
|
+
css: {
|
|
55
|
+
transformGroup: "css",
|
|
56
|
+
buildPath: "app/",
|
|
57
|
+
files: [
|
|
58
|
+
{
|
|
59
|
+
destination: "globals.css",
|
|
60
|
+
format: "css/variables-multi-context",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
await sd.buildAllPlatforms();
|
package/cli/add.js
CHANGED
package/cli/init.js
CHANGED
|
@@ -15,10 +15,13 @@ const __dirname = path.dirname(__filename);
|
|
|
15
15
|
// 패키지 내부 경로 설정
|
|
16
16
|
const packageRoot = path.join(__dirname, "..");
|
|
17
17
|
const tokenFile = path.join(packageRoot, "token.json");
|
|
18
|
+
const buildFile = path.join(packageRoot, "/build/build-tokens.js");
|
|
18
19
|
|
|
19
20
|
// 프로젝트 루트 경로 (사용자가 실행한 곳)
|
|
20
21
|
const projectRoot = process.cwd();
|
|
21
22
|
const targetTokenFile = path.join(projectRoot, "token.json");
|
|
23
|
+
const targetBuildDir = path.join(projectRoot, "build");
|
|
24
|
+
const targetBuildFile = path.join(projectRoot, "/build/build-tokens.js");
|
|
22
25
|
|
|
23
26
|
// 사용자에게 Next.js 설치 여부 질문
|
|
24
27
|
inquirer
|
|
@@ -53,12 +56,7 @@ inquirer
|
|
|
53
56
|
|
|
54
57
|
packageJson.scripts = {
|
|
55
58
|
...packageJson.scripts,
|
|
56
|
-
|
|
57
|
-
build: "next build",
|
|
58
|
-
build_token:
|
|
59
|
-
"node tokens/buildTokenSplit.js && node tokens/buildMergeCss.js",
|
|
60
|
-
start: "next start",
|
|
61
|
-
lint: "next lint",
|
|
59
|
+
"token-build": "node build/build-tokens.js",
|
|
62
60
|
};
|
|
63
61
|
|
|
64
62
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
@@ -103,6 +101,10 @@ inquirer
|
|
|
103
101
|
copyFileSync(tokenFile, targetTokenFile);
|
|
104
102
|
console.log(`✅ Copied: token.json -> ${targetTokenFile}`);
|
|
105
103
|
|
|
104
|
+
if (!fs.existsSync(targetBuildDir)) mkdirSync(targetBuildDir);
|
|
105
|
+
copyFileSync(buildFile, targetBuildFile);
|
|
106
|
+
console.log(`✅ Copied: ${buildFile} -> ${targetTokenFile}`);
|
|
107
|
+
|
|
106
108
|
console.log("🚀 Token setup complete!");
|
|
107
109
|
})
|
|
108
110
|
.catch((error) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atomsystem",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://system.atomground.com",
|
|
6
6
|
"bin": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"token.json",
|
|
12
12
|
"tokens",
|
|
13
13
|
"tailwind.config.ts",
|
|
14
|
+
"build",
|
|
14
15
|
"app/templates"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|