@design-sync/sync
Design Sync CLI
Usage
Install package:
npm install -D @design-sync/sync
yarn add --dev @design-sync/sync
pnpm install @design-sync/sync
bun install @design-sync/sync
Initialize:
npm run design-sync init
yarn design-sync init
pnpm design-sync init
bun design-sync init
follow the prompt to create a design-sync.config
file or pass -y
to skip the prompt and use the default values.
Sync:
npm run design-sync sync
yarn dlx design-sync sync
pnpm dlx design-sync sync
bun design-sync sync
Configuration
The configuration file is a design-sync.config.ts
file in the root of your project.
uri
: (string) the uri of a git repository to download the design tokens from, eg gh:owner/repo/path/to/file/or/folder#branch
supports github
, gitlab
, sourcehut
and bitbucket
see giget for more info.auth
: (string) Custom Authorization token to use for downloading tokens. (Can be overridden with GIGET_AUTH
environment variable).out
: (string) the output directory for the generated filesplugins
: (array) plugins to use, see plugins for more infoschemaExtensions
(array)- schema extensions to use, see schema extensions for more infoprettify
: (boolean) format the generated files using prettier
, default: false
Plugins
Css
Transforms DTFM json to css variables and classes
Usage:
in the config file add the plugin to the plugins array
import { cssPlugin } from '@design-sync/sync'
export default {
plugins: [cssPlugin({
extractAsStyles: ['typography'],
outDir: 'css',
typographyAsFontProperty: false,
selectors: {
dark: '@media (prefers-color-scheme: dark)',
light: '@media (prefers-color-scheme: light)',
},
})],
}
Transforms DTFM json to vanilla extract themes
Usage:
in the config file add the plugin to the plugins array
import { vanillaExtractPlugin } from '@design-sync/sync'
export default {
plugins: [vanillaExtractPlugin({
outDir: 'vanilla-extract',
themeContractName: 'contract',
themeContractVarName: 'theme',
})],
}
JSON (flat)
Transforms DTFM json to flat json file without all the tokens metadata and types, also dereference all token aliases
Usage:
in the config file add the plugin to the plugins array
import { jsonPlugin } from '@design-sync/sync'
export default {
plugins: [jsonPlugin({
outDir: 'json',
})],
}
Schema Extensions
- Modes -> allow you to override tokens per mode (dark, light, etc) and generate a theme for each mode, enabled by default.
- Color Modifiers -> allow you to modify colors using common color modifiers like lighten, darken, saturate, etc, enabled by default.
- Color Generators -> allow you to generate more colors dynamically using color modifiers, enabled by default.
Development
- Clone this repository
- Install latest LTS version of Node.js
- Enable Corepack using
corepack enable
- Install dependencies using
pnpm install
- Run interactive tests using
pnpm dev
License
Made with 💛
Published under MIT License.