nemcss 0.1.2
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 +45 -0
- package/bin/nemcss.js +44 -0
- package/package.json +36 -0
- package/schemas/nemcss.config.schema.json +138 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# nemcss
|
|
2
|
+
|
|
3
|
+
> A design-token-driven CSS utility generator
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
# global
|
|
7
|
+
npm install -g nemcss
|
|
8
|
+
|
|
9
|
+
# local (per project)
|
|
10
|
+
npm install -D nemcss
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
When installed locally, run commands via `npx nemcss <command>` or add them as scripts in your `package.json`.
|
|
14
|
+
|
|
15
|
+
`nemcss` reads your design tokens and a `nemcss.config.json` file, then generates CSS custom properties and utility classes. Add `@nemcss base;` to your CSS input file. `nemcss` replaces it at build time with the generated output.
|
|
16
|
+
|
|
17
|
+
## CLI commands
|
|
18
|
+
|
|
19
|
+
| Command | Description |
|
|
20
|
+
| ------------------------------------- | ------------------------------------------------------------------------------ |
|
|
21
|
+
| `nemcss init` | Scaffold `nemcss.config.json` and example token files in the current directory |
|
|
22
|
+
| `nemcss build -i <input> -o <output>` | One-shot build: scan content files and write CSS |
|
|
23
|
+
| `nemcss watch -i <input> -o <output>` | Watch mode: rebuild on token, content, or config changes |
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
A minimal `nemcss.config.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"content": ["src/**/*.html", "src/**/*.tsx"],
|
|
32
|
+
"tokensDir": "design-tokens",
|
|
33
|
+
"theme": {
|
|
34
|
+
"colors": {
|
|
35
|
+
"source": "design-tokens/colors.json",
|
|
36
|
+
"utilities": [
|
|
37
|
+
{ "prefix": "text", "property": "color" },
|
|
38
|
+
{ "prefix": "bg", "property": "background-color" }
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For the full configuration reference, see the [root README](../../README.md).
|
package/bin/nemcss.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("child_process");
|
|
4
|
+
|
|
5
|
+
const PLATFORMS = {
|
|
6
|
+
"darwin-arm64": "@nemcss/cli-darwin-arm64",
|
|
7
|
+
"darwin-x64": "@nemcss/cli-darwin-x64",
|
|
8
|
+
"linux-x64": "@nemcss/cli-linux-x64",
|
|
9
|
+
"linux-arm64": "@nemcss/cli-linux-arm64",
|
|
10
|
+
"win32-x64": "@nemcss/cli-win32-x64",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const key = `${process.platform}-${process.arch}`;
|
|
14
|
+
const pkg = PLATFORMS[key];
|
|
15
|
+
|
|
16
|
+
if (!pkg) {
|
|
17
|
+
console.error(`nemcss: unsupported platform: ${key}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let binPath;
|
|
22
|
+
try {
|
|
23
|
+
binPath = require.resolve(
|
|
24
|
+
`${pkg}/bin/nemcss${process.platform === "win32" ? ".exe" : ""}`,
|
|
25
|
+
);
|
|
26
|
+
} catch {
|
|
27
|
+
console.error(
|
|
28
|
+
`nemcss: platform package ${pkg} is not installed. Try reinstalling nemcss.`,
|
|
29
|
+
);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const result = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
34
|
+
|
|
35
|
+
if (result.error) {
|
|
36
|
+
console.error(`nemcss: failed to run binary: ${result.error.message}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (result.signal) {
|
|
41
|
+
process.kill(process.pid, result.signal);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
process.exit(result.status ?? 1);
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nemcss",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Command-line interface for nemcss, a design-token-driven CSS utility generator",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/liv7c/nemcss.git",
|
|
9
|
+
"directory": "packages/nemcss"
|
|
10
|
+
},
|
|
11
|
+
"author": "Olivia Coumans",
|
|
12
|
+
"bin": {
|
|
13
|
+
"nemcss": "./bin/nemcss.js"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/liv7c/nemcss/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"command-line",
|
|
20
|
+
"css generator"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"bin",
|
|
27
|
+
"schemas"
|
|
28
|
+
],
|
|
29
|
+
"optionalDependencies": {
|
|
30
|
+
"@nemcss/cli-darwin-arm64": "0.1.2",
|
|
31
|
+
"@nemcss/cli-darwin-x64": "0.1.2",
|
|
32
|
+
"@nemcss/cli-linux-x64": "0.1.2",
|
|
33
|
+
"@nemcss/cli-linux-arm64": "0.1.2",
|
|
34
|
+
"@nemcss/cli-win32-x64": "0.1.2"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "NemCSS Configuration",
|
|
4
|
+
"description": "Configuration file for the NemCSS utility CSS generator",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"content": {
|
|
8
|
+
"type": "array",
|
|
9
|
+
"items": { "type": "string" },
|
|
10
|
+
"description": "Glob patterns for content files to scan for used classes",
|
|
11
|
+
"examples": [["src/**/*.html", "src/**/*.tsx"]]
|
|
12
|
+
},
|
|
13
|
+
"tokensDir": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"default": "design-tokens",
|
|
16
|
+
"description": "Directory containing design token JSON files"
|
|
17
|
+
},
|
|
18
|
+
"theme": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"description": "Primitive design token sources. Each key is a token group name.",
|
|
21
|
+
"defaultSnippets": [
|
|
22
|
+
{
|
|
23
|
+
"label": "Token group",
|
|
24
|
+
"description": "Add a token group, e.g colors or spacings",
|
|
25
|
+
"body": {
|
|
26
|
+
"${1:groupName}": {
|
|
27
|
+
"source": "${2:design-tokens/tokens.json}",
|
|
28
|
+
"prefix": "${3:prefix}"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"additionalProperties": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"required": ["source"],
|
|
36
|
+
"defaultSnippets": [
|
|
37
|
+
{
|
|
38
|
+
"label": "Token group config",
|
|
39
|
+
"body": {
|
|
40
|
+
"source": "${1:design-tokens/tokens.json}",
|
|
41
|
+
"prefix": "${2:prefix}"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"properties": {
|
|
46
|
+
"source": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"description": "Path to the token JSON file, relative to nemcss.config.json"
|
|
49
|
+
},
|
|
50
|
+
"prefix": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "CSS custom property prefix for this token group"
|
|
53
|
+
},
|
|
54
|
+
"utilities": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"description": "Utility classes to generate for every token in this group",
|
|
57
|
+
"items": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"required": ["prefix", "property"],
|
|
60
|
+
"defaultSnippets": [
|
|
61
|
+
{
|
|
62
|
+
"label": "Utility",
|
|
63
|
+
"body": {
|
|
64
|
+
"prefix": "${1:p}",
|
|
65
|
+
"property": "${2:padding}"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"properties": {
|
|
70
|
+
"prefix": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"description": "CSS class prefix for this utility",
|
|
73
|
+
"minLength": 1
|
|
74
|
+
},
|
|
75
|
+
"property": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"description": "CSS property to set",
|
|
78
|
+
"minLength": 1
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"additionalProperties": false
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"additionalProperties": false
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"semantic": {
|
|
89
|
+
"type": "object",
|
|
90
|
+
"description": "Semantic token groups. Each key becomes both a CSS custom property prefix and a utility class prefix.",
|
|
91
|
+
"defaultSnippets": [
|
|
92
|
+
{
|
|
93
|
+
"label": "Semantic group",
|
|
94
|
+
"description": "Add a semantic group, e.g text, bg or border",
|
|
95
|
+
"body": {
|
|
96
|
+
"${1:groupName}": {
|
|
97
|
+
"property": "${2:color}",
|
|
98
|
+
"tokens": {
|
|
99
|
+
"${3:tokenName}": "{${4:colors}.${5:variant}}"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"additionalProperties": {
|
|
106
|
+
"type": "object",
|
|
107
|
+
"required": ["property", "tokens"],
|
|
108
|
+
"defaultSnippets": [
|
|
109
|
+
{
|
|
110
|
+
"label": "Semantic group config",
|
|
111
|
+
"body": {
|
|
112
|
+
"property": "${1:color}",
|
|
113
|
+
"tokens": {
|
|
114
|
+
"${2:tokenName}": "{${3:colors}.${4:variant}}"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"properties": {
|
|
120
|
+
"property": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"description": "CSS property for this utility group",
|
|
123
|
+
"minLength": 1
|
|
124
|
+
},
|
|
125
|
+
"tokens": {
|
|
126
|
+
"type": "object",
|
|
127
|
+
"description": "Semantic name to primitive token reference. Each entry generates a CSS custom property and a utility class.",
|
|
128
|
+
"additionalProperties": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"pattern": "^\\{[^.{}]+\\.[^.{}]+\\}$"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"additionalProperties": false
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|