-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Figma Variables support * Improve docs * Fix Windows tests?
- Loading branch information
Showing
21 changed files
with
2,725 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@cobalt-ui/plugin-css": patch | ||
"@cobalt-ui/utils": patch | ||
--- | ||
|
||
Move glob matching to @cobalt-ui/utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@cobalt-ui/cli": patch | ||
--- | ||
|
||
Remove accidental console.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@cobalt-ui/core": minor | ||
"@cobalt-ui/cli": minor | ||
--- | ||
|
||
Add Figma Variable support natively |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
**/tokens/**/* | ||
test/fixtures/bundle-default/given | ||
test/fixtures/figma-error/given.json | ||
test/fixtures/figma-success/given.jso | ||
test/fixtures/style-dictionary/given.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,20 @@ | |
"name": "Drew Powers", | ||
"email": "[email protected]" | ||
}, | ||
"keywords": ["design tokens", "design tokens community group", "design tokens format module", "dtcg", "cli", "w3c design tokens", "design system", "typescript", "sass", "css", "style tokens", "style system"], | ||
"keywords": [ | ||
"design tokens", | ||
"design tokens community group", | ||
"design tokens format module", | ||
"dtcg", | ||
"cli", | ||
"w3c design tokens", | ||
"design system", | ||
"typescript", | ||
"sass", | ||
"css", | ||
"style tokens", | ||
"style system" | ||
], | ||
"engines": { | ||
"node": ">=18.0.0" | ||
}, | ||
|
@@ -46,6 +59,7 @@ | |
"@types/culori": "^2.0.4", | ||
"@types/node": "^20.11.16", | ||
"execa": "^7.2.0", | ||
"msw": "^2.1.5", | ||
"vitest": "^1.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import fs from 'node:fs'; | ||
import os from 'node:os'; | ||
import {fileURLToPath} from 'node:url'; | ||
import {http, HttpResponse} from 'msw'; | ||
import {setupServer} from 'msw/node'; | ||
import {describe, expect, it, vi} from 'vitest'; | ||
import FIGMA_VARIABLE_API_RESPONSE from './fixtures/figma-success/api_v1_response.json'; | ||
|
||
const FILE_KEY = 'OkPWSU0cusQTumCNno7dm8'; | ||
|
||
// note: running execa like in the other tests doesn’t let us mock the fetch() call with msw. | ||
// so we mock the CLI variables first, then load the JS module in the text scope | ||
|
||
// bug in Node VM on Windows: importing module blows up (errs after `new Script node:vm:99:7, createScript node:vm:255:10, Object.runInThisContext node:vm:303:10`) | ||
|
||
describe('Figma import', () => { | ||
it.skipIf(os.platform() === 'win32')('parses valid syntax correctly', async () => { | ||
const cwd = new URL('./fixtures/figma-success/', import.meta.url); | ||
const server = setupServer(http.get(`https://api.figma.com/v1/files/${FILE_KEY}/variables/local`, () => HttpResponse.json(FIGMA_VARIABLE_API_RESPONSE))); | ||
server.listen(); | ||
|
||
// run CLI | ||
process.argv = ['node', 'bin/cli.js', 'build', '--config', fileURLToPath(new URL('./tokens.config.js', cwd))]; | ||
process.exit = vi.fn(); | ||
const mod = await import('../bin/cli.js'); | ||
await mod.default(); | ||
|
||
expect(fs.readFileSync(new URL('./given.json', cwd), 'utf8')).toMatchFileSnapshot(fileURLToPath(new URL('./want.json', cwd))); | ||
|
||
// clean up | ||
server.close(); | ||
}); | ||
|
||
it.skipIf(os.platform() === 'win32')('throws errors on invalid response', async () => { | ||
const cwd = new URL('./fixtures/figma-error/', import.meta.url); | ||
const server = setupServer(http.get(`https://api.figma.com/v1/files/${FILE_KEY}/variables/local`, () => HttpResponse.json({status: 401, error: true}, {status: 401}))); | ||
server.listen(); | ||
|
||
// run CLI | ||
process.argv = ['node', 'bin/cli.js', 'build', '--config', fileURLToPath(new URL('./tokens.config.js', cwd))]; | ||
process.exit = vi.fn(); | ||
const mod = await import('../bin/cli.js'); | ||
await mod.default(); | ||
|
||
expect(process.exit).toHaveBeenCalledWith(1); | ||
|
||
// clean up | ||
server.close(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pluginJS from '../../../../../packages/plugin-js/dist/index.js'; | ||
|
||
/** @type {import('@cobalt-ui/core').Config} */ | ||
export default { | ||
tokens: ['https://www.figma.com/file/OkPWSU0cusQTumCNno7dm8/Variable-Export?type=design&node-id=0%3A1&mode=design&t=zxhnYAf1FASSHySQ-1'], | ||
outDir: '.', | ||
plugins: [ | ||
pluginJS({ | ||
json: './given.json', | ||
}), | ||
], | ||
}; |
Oops, something went wrong.