prefix-by
This parser helps you prefix the name of your collections, groups and tokens from your SDTF token tree.
Interface
interface parser {
name: 'prefix-by';
options: ({
all: string
} |
{
group?: string;
collection?: string;
token?: string;
}) & { applyTo?: SDTFQuery }
}Options
Parameter
Required
Type
Default
Description
all
false
string
Select all collections, groups and tokens in your SDTF token graph.
group
false
string
Select all groups in your SDTF token graph.
collection
false
string
Select all collections in your SDTF token graph.
token
false
string
Select all tokens in your SDTF token graph.
applyTo
false
| { collection: string | true }
| { group: string | true }
| { token: string | true }
| SDTFQueryThe selection where to apply the transformation.
collection, group, token take a Regex string or true to select anything of the kind.
An SDTFQuery can be used for advance use cases.
Basic usage: Prefix color tokens
{
"spacing": {
"1": {
"$type": "dimension",
"$value": {
"default": {
"value": 4,
"unit": "px"
}
}
}
},
"colors": {
"black": {
"$type": "color",
"$value": {
"default": {
"model": "hex",
"hex": "#000000",
"alpha": 1
}
}
}
}
}{
"version": "2",
"repository": "@organization/repository",
// Only use the personalAccessToken when working with the CLI
"personalAccessToken": "<your-personal-access-token>",
"rules": [
{
"name": "Prefix color tokens",
"parsers": [
{
"name": "prefix-by",
"options": {
"token": "ds-",
"applyTo": {
"where": {
"token": ".*",
"withTypes": {
"include": [
"color"
]
},
"select": {
"parents": true
}
}
}
}
},
{
"name": "to-sdtf",
"output": {
"type": "file",
"filePath": "tokens.json"
}
}
]
}
]
}{
"colors": {
"ds-black": {
"$type": "color",
"$value": {
"default": {
"model": "hex",
"hex": "#000000",
"alpha": 1
}
}
}
},
"spacing": {
"1": {
"$type": "dimension",
"$value": {
"default": {
"value": 4,
"unit": "px"
}
}
}
}
}Last updated
Was this helpful?