tokenize-css 0.1.0

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 ADDED
@@ -0,0 +1,50 @@
1
+ # tokenize-css
2
+
3
+ CLI tool to convert Design Tokens (Token Studio) to CSS variables.
4
+
5
+ ## Installation
6
+ ```bash
7
+ npm install -g tokenize-css
8
+ ```
9
+
10
+ ## Usage
11
+ ```bash
12
+ tokenize <input> <output> [options]
13
+ ```
14
+
15
+ ### Examples
16
+ ```bash
17
+ # Basic usage
18
+ tokenize tokens.json dist
19
+
20
+ # With full path
21
+ tokenize tokens.json "/path/to/output"
22
+
23
+ # Specify source type
24
+ tokenize tokens.json dist --source token-studio
25
+ ```
26
+
27
+ ### Options
28
+
29
+ | Option | Description | Default |
30
+ |--------|-------------|---------|
31
+ | `-s, --source <type>` | Source type (token-studio, figma-variables) | token-studio |
32
+ | `-V, --version` | Output version | |
33
+ | `-h, --help` | Display help | |
34
+
35
+ ## Supported Sources
36
+
37
+ - āœ… Token Studio
38
+ - šŸ”œ Figma Variables
39
+
40
+ ## Output Files
41
+
42
+ - `colors.css` - Color tokens
43
+ - `spacing.css` - Spacing tokens
44
+ - `typography.css` - Typography tokens
45
+ - `shadows.css` - Shadow tokens
46
+ - `tokens.css` - All tokens combined
47
+
48
+ ## License
49
+
50
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { program } from 'commander';
4
+ import StyleDictionary from 'style-dictionary';
5
+ import chalk from 'chalk';
6
+ import { resolve } from 'path';
7
+ import { createTokenStudioConfig } from '../src/config/token-studio.js';
8
+
9
+ async function build(input, output, source = 'token-studio') {
10
+ console.log(chalk.blue.bold('\nšŸŽØ tokenize-css\n'));
11
+ console.log(chalk.gray(`Source: ${source}`));
12
+ console.log(chalk.gray(`Input: ${input}`));
13
+ console.log(chalk.gray(`Output: ${output}\n`));
14
+
15
+ let config;
16
+
17
+ if (source === 'token-studio') {
18
+ config = createTokenStudioConfig(input, output);
19
+ } else {
20
+ console.error(chalk.red(`āŒ Source "${source}" not supported yet`));
21
+ process.exit(1);
22
+ }
23
+
24
+ try {
25
+ const sd = new StyleDictionary(config);
26
+ await sd.buildAllPlatforms();
27
+ console.log(chalk.green('āœ… Done!\n'));
28
+ } catch (error) {
29
+ console.error(chalk.red(`āŒ Error: ${error.message}`));
30
+ process.exit(1);
31
+ }
32
+ }
33
+
34
+ program
35
+ .name('tokenize')
36
+ .description('Convert Design Tokens to CSS variables')
37
+ .version('0.1.0');
38
+
39
+ program
40
+ .argument('<input>', 'Input tokens file')
41
+ .argument('<output>', 'Output directory')
42
+ .option('-s, --source <type>', 'Source type (token-studio, figma-variables)', 'token-studio')
43
+ .action(async (input, output, options) => {
44
+ const inputPath = resolve(process.cwd(), input);
45
+ const outputPath = resolve(process.cwd(), output);
46
+ await build(inputPath, outputPath, options.source);
47
+ });
48
+
49
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "tokenize-css",
3
+ "version": "0.1.0",
4
+ "description": "CLI tool to convert Design Tokens (Token Studio, Figma Variables) to CSS variables using Style Dictionary",
5
+ "type": "module",
6
+ "bin": {
7
+ "tokenize": "./bin/cli.js"
8
+ },
9
+ "main": "./src/index.js",
10
+ "files": [
11
+ "bin",
12
+ "src"
13
+ ],
14
+ "scripts": {
15
+ "start": "node bin/cli.js",
16
+ "test": "node --test",
17
+ "prepublishOnly": "node bin/cli.js --help"
18
+ },
19
+ "keywords": [
20
+ "design-tokens",
21
+ "design-system",
22
+ "css-variables",
23
+ "css",
24
+ "token-studio",
25
+ "figma",
26
+ "figma-tokens",
27
+ "style-dictionary",
28
+ "cli",
29
+ "tokens",
30
+ "variables"
31
+ ],
32
+ "author": "Aly Zidan",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/AlyZidan/tokenize-css.git"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/AlyZidan/tokenize-css/issues"
40
+ },
41
+ "homepage": "https://github.com/AlyZidan/tokenize-css#readme",
42
+ "engines": {
43
+ "node": ">=18.0.0"
44
+ },
45
+ "dependencies": {
46
+ "chalk": "^5.3.0",
47
+ "commander": "^12.1.0",
48
+ "style-dictionary": "^4.3.0"
49
+ }
50
+ }
@@ -0,0 +1,39 @@
1
+ import StyleDictionary from 'style-dictionary';
2
+
3
+ export function createTokenStudioConfig(input, output) {
4
+ return {
5
+ source: [input],
6
+ platforms: {
7
+ css: {
8
+ transformGroup: 'css',
9
+ buildPath: output.endsWith('/') ? output : `${output}/`,
10
+ files: [
11
+ {
12
+ destination: 'colors.css',
13
+ format: 'css/variables',
14
+ filter: (token) => token.type === 'color'
15
+ },
16
+ {
17
+ destination: 'spacing.css',
18
+ format: 'css/variables',
19
+ filter: (token) => token.type === 'spacing'
20
+ },
21
+ {
22
+ destination: 'typography.css',
23
+ format: 'css/variables',
24
+ filter: (token) => ['fontFamilies', 'fontSizes', 'fontWeights', 'lineHeights'].includes(token.type)
25
+ },
26
+ {
27
+ destination: 'shadows.css',
28
+ format: 'css/variables',
29
+ filter: (token) => token.type === 'boxShadow'
30
+ },
31
+ {
32
+ destination: 'tokens.css',
33
+ format: 'css/variables'
34
+ }
35
+ ]
36
+ }
37
+ }
38
+ };
39
+ }
package/src/parser.js ADDED
File without changes