Skip to content

Commit

Permalink
opt-in for storefront tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
mimarz committed May 22, 2024
1 parent fe47cb9 commit cf47c6c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
13 changes: 7 additions & 6 deletions packages/cli/bin/designsystemet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ program
.command('tokens')
.showHelpAfterError()
.description('run Designsystemet token builder')
.option('-t, --tokens [string]', `Path to ${chalk.blue('design-tokens')}`, 'design-tokens')
.option('-o, --out [string]', `Output directory for built ${chalk.blue('design-tokens')}`, 'dist/tokens')
.option('-p, --preview')
.option('-t, --tokens [string]', `Path to ${chalk.blue('design-tokens')}`, './design-tokens')
.option('-o, --out [string]', `Output directory for built ${chalk.blue('design-tokens')}`, './dist/tokens')
.option('-p, --preview', 'Generate preview token.ts files', false)
.action((opts) => {
const tokens = typeof opts.tokens === 'string' ? opts.tokens : 'design-tokens';
const out = typeof opts.out === 'string' ? opts.out : 'dist/tokens';
const tokens = typeof opts.tokens === 'string' ? opts.tokens : './design-tokens';
const out = typeof opts.out === 'string' ? opts.out : './dist/tokens';
const preview = opts.preview;
console.log(`Bulding tokens in ${chalk.green(tokens)}`);
return run({ tokens, out });
return run({ tokens, out, preview });
});

program
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digdir/designsystemet",
"version": "0.0.6",
"version": "0.0.8",
"description": "CLI for Designsystemet",
"author": "Designsystemet team",
"repository": {
Expand All @@ -15,7 +15,7 @@
},
"scripts": {
"designsystemet": "esno ./bin/designsystemet.ts",
"build:tokens": "yarn clean:theme && yarn designsystemet tokens -t ../../design-tokens -o ../../packages/theme/brand",
"build:tokens": "yarn clean:theme && yarn designsystemet tokens -p -t ../../design-tokens -o ../../packages/theme/brand",
"prepublish": "yarn clean && tsc",
"prepublish:tsup": "yarn clean && tsup src/**/*.ts bin/designsystemet.ts --cjsInterop --shims --format esm",
"clean": "rimraf dist",
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/tokens/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ type Options = {
tokens: string;
/** Output directoru for built tokens */
out: string;
/** Generate preview tokens */
preview: boolean;
};

const sd = new StyleDictionary();
Expand Down Expand Up @@ -147,7 +149,7 @@ export async function run(options: Options): Promise<void> {
include,
};

console.log(config);
// console.log(config);

return [`${folderName}: ${fileName}`, config];
})
Expand All @@ -173,7 +175,7 @@ export async function run(options: Options): Promise<void> {
console.log('🏁 Finished building package tokens!');
}

if (storefrontConfigs.length > 0) {
if (storefrontConfigs.length > 0 && options.preview) {
console.log('\n🏗️ Started building storefront tokens…');
await Promise.all(
storefrontConfigs.map(async ([name, config]) => {
Expand Down

0 comments on commit cf47c6c

Please sign in to comment.