Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(examples): add matching build files example #481

Merged
merged 15 commits into from
Nov 14, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [2.10.2](https://github.com/amzn/style-dictionary/compare/v2.10.1...v2.10.2) (2020-10-08)


### Bug Fixes

* **cli:** update clean config path logic ([#454](https://github.com/amzn/style-dictionary/issues/454)) ([3cc3d4e](https://github.com/amzn/style-dictionary/commit/3cc3d4e04f2ee4d0ac8b1f90b725e80f6b53beb4))
* **formats:** fix max call stack issue on json/nested format ([#465](https://github.com/amzn/style-dictionary/issues/465)) ([4064e6a](https://github.com/amzn/style-dictionary/commit/4064e6add00ca3380d9a2c9ef9862f73ef051de9))

### [2.10.1](https://github.com/amzn/style-dictionary/compare/v2.10.0...v2.10.1) (2020-07-09)


Expand Down
14 changes: 14 additions & 0 deletions __tests__/formats/jsonNested.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var dictionary = {
properties: {
color: {
base: {
comment: 'This is a comment',
metadata: [1,2,3],
red: {
primary: { value: '#611D1C' },
secondary: {
Expand Down Expand Up @@ -55,5 +57,17 @@ describe('formats', function() {
expect(test.color.base.red.secondary.inverse)
.toEqual(dictionary.properties.color.base.red.secondary.inverse.value);
});

it('should handle non-token data', function() {
// non-token data is anything in the dictionary object that is not a token object
// i.e. anything in the rest of the object that doesn't have a 'value'

fs.writeFileSync('./__tests__/__output/json-nested.json', formatter(dictionary));
var test = require('../__output/json-nested.json');
expect(test.color.base.comment)
.toEqual(dictionary.properties.color.base.comment);
expect(test.color.base.metadata)
.toEqual(dictionary.properties.color.base.metadata);
})
});
});
36 changes: 21 additions & 15 deletions bin/style-dictionary
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ function collect(val, arr) {
return arr;
}

function getConfigPath(options) {
var configPath = options.config;

if(!configPath) {
if(fs.existsSync('./config.json')) {
configPath = './config.json';
}
else if(fs.existsSync('./config.js')) {
configPath = './config.js';
}
else {
console.error('Build failed; unable to find config file.');
process.exit(1);
}
}

return configPath;
}

program
.version(pkg.version)
.description(pkg.description)
Expand Down Expand Up @@ -59,20 +78,7 @@ program.on('command:*', function () {

function styleDictionaryBuild(options) {
options = options || {};
var configPath = options.config;

if(!configPath) {
if(fs.existsSync('./config.json')) {
configPath = './config.json';
}
else if(fs.existsSync('./config.js')) {
configPath = './config.js';
}
else {
console.error('Build failed; unable to find config file.');
process.exit(1);
}
}
var configPath = getConfigPath(options);

// Create a style dictionary object with the config
var styleDictionary = StyleDictionary.extend( configPath );
Expand All @@ -88,7 +94,7 @@ function styleDictionaryBuild(options) {

function styleDictionaryClean(options) {
options = options || {};
var configPath = options.config ? options.config : './config.json';
var configPath = getConfigPath(options);

// Create a style dictionary object with the config
var styleDictionary = StyleDictionary.extend( configPath );
Expand Down
4 changes: 2 additions & 2 deletions docs/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -724,11 +724,11 @@ import 'package:flutter/material.dart';

class StyleDictionary {
StyleDictionary._();

static const colorBrandPrimary = Color(0x00ff5fff);
static const sizeFontSizeMedium = 16.00;
static const contentFontFamily1 = "NewJune";
```
```

* * *

Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/assets-base64-embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"style-dictionary": "2.10.1"
"style-dictionary": "2.10.2"
}
}
2 changes: 1 addition & 1 deletion examples/advanced/auto-rebuild-watcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"license": "Apache-2.0",
"devDependencies": {
"chokidar-cli": "^1.2.0",
"style-dictionary": "2.10.1"
"style-dictionary": "2.10.2"
}
}
2 changes: 1 addition & 1 deletion examples/advanced/component-cti/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"style-dictionary": "2.10.1"
"style-dictionary": "2.10.2"
}
}
Loading