Skip to content

Commit

Permalink
v2.5.0 (#191)
Browse files Browse the repository at this point in the history
* improved error messages for registerTemplate

* updated error message

* Introduce option to control the generation of the "Do not edit" header (#132)

* stage #1 - formats.js

* stage #2 - templates

* reset changes to template + simplified changes to formats

(now the “options” object is assigned to the “file” element)

* fixed wrong parameter passed to fileHeader function

* updated documentation

* updates after PR comments

* removing the confusing static-style-guide stuff (#157)

* Fixes #72

* handle no command and invalid commands with friendly console output (#156)

* Add json5 support (#165)

* Removing unnecessary backticks (#172)

* Merge Jest Branch (#169)

* Jest testing (#133)

* moved all the existing tests to Jest
* finalised Jest tests for “utils” removing assert dependency
* finalised Jest tests for “register” removing assert dependency + moved tests under correct folder
* finalised Jest tests for “transform” removing assert dependency + moved tests under correct folder + removed extra file
* updated path for “service” files/folders
* removed output folder
* updated the paths to ignore in the Jest config in package.json
* finalised Jest tests for “clean” removing assert dependency + other small changes
* added “__output” to the list of folders ignored by Jest
* some tunings + more tests
* more tests cleanup
* fixed test for exportPlatform
* fixed last tests, and now all tests are green!
* Added first snapshot tests! Yay!
* added mock for dates to avoid failing snapshots tests
* updated tests
* first attempt to fix the UTC date problem on CI (reference: boblauer/MockDate#9)
* second attempt to fix the UTC date problem on CI
* removed the TZ=UTC env environment to test if is really needed
* updated all the occurrences of new Date in the templates
* restored linting before running the tests suite
* code style fix
* fixed wrong porting of the test for buildAllPlatforms

* test(all): Fix for all tests to match the date and remove of mockdate (#148)

inspiration jestjs/jest#2234

* test(javascript/es6): Add test for es6 (#149)

* test: add registerTemplate (#147)

* add tests for transform object (#151)

* add tests for transform object
* split up complex test in multiple smaller tests

* Jest flatten props (#163)

* Adding tests for lib/utils/flattenProperties.js (#146)

* Adding tests for lib/utils/flattenProperties.js

* update to use lodash sortby function

* update to use lodash sortby function

* Add babel-jest (#173)

* feat(json-nested): Add JSON nested transform (#167)

Added JSON nested transform, Added test for it and Documentation update

re #139

* Fix errors and improve error messaging (#158)

* updated error messaging. Fixes for issues with references.

* adding in didoo's test from #118

* cleanup of terminology

* fixed resolveObject to correctly replace multiple references. modified testing suite to reflect new test.

* updates per comments by didoo and dbanksdesign

* case sensitive, oops.

* case sensitive, oops.

* minor updates based on PR feedback

* merging with develop to ensure we stay synched

* removing cli error handling and moving to module

* removing per dannys comments

* making constants for group errors per Dannys comments

* switch to error grouping mindset and naming

* switch to error grouping mindset and naming

* per danny's comment

* fix flush to execute across all groups if called with no group; remove flush on uncaught exceptions to prevent confusion

* simplify, simplify, simplify

* changed out error naming to message mindset, cleaned out console.log, fixed issues with simplified GroupMessages

* sepearate circular reference tests into separate expects

* avoid using string so we dont get it confused with String

* Deprecating templates (#152)

* Displaying a warning when using templates in the config or registerTemplate
* Moving built-in templates to formats

* Porting over a stragler test (#190)

* 2.5.0
  • Loading branch information
dbanksdesign authored and chazzmoney committed Nov 2, 2018
1 parent 41fedba commit fa6ebeb
Show file tree
Hide file tree
Showing 174 changed files with 9,969 additions and 7,533 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["env"]
}
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"parserOptions": {
"ecmaVersion": 6
},
"env": {
"node": true,
"mocha": true
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ We are always happy to receive code and documentation contributions to the frame

1. This framework is released under the [Apache license][license]. Any code you submit will be released under that license. For substantial contributions, we may ask you to sign a [Contributor License Agreement (CLA)][cla].
2. For any significant features or API changes please reach out to us to avoid any duplicate effort.
3. Adding to the included transforms, transformGroups, formats, and templates, please read [this section](#what-should-be-included).
3. Adding to the included transforms, transformGroups, and formats, please read [this section](#what-should-be-included).


## Code Style

We use ESLint on the code to ensure a consistent style. Any new code committed must pass our ESLint tests. Take a look at our [ESLint file][eslint].

### Code Rules
1. **Do not mutate property names or values in a format or template.** Mutations like this should happen in a transformer.
1. **Be as generic as possible.** Do not hard-code any values or configuration in formats or templates.
1. **Do not mutate property names or values in a format.** Mutations like this should happen in a transformer.
1. **Be as generic as possible.** Do not hard-code any values or configuration in formats.
1. **Fail loudly.** Users should be aware if something is missing or configurations aren't correct. This will help debug any issues instead of failing silently.
1. **Rely on few dependencies.** This framework is meant to be extended and allows for customization. We don't want to bring a slew of dependencies that most people don't need.

## What should be included?

Anything that contributes to the idea of creating cross-platform styles.

### What transforms/transform groups/formats/templates should be included?
### What transforms/transform groups/formats should be included?

If it has a generic and flexible enough use-case, it can be included. We would like to keep this type of code to a minimum because we don't want to be a swiss army knife that does everything out of the box. Instead, we want to focus on core tasks that are useful to the largest number of projects. The spirit of this framework is to allow flexibility and modularity so that anyone can fit it to their needs. This is why you can write your own transforms, formats, and templates with the register methods.
If it has a generic and flexible enough use-case, it can be included. We would like to keep this type of code to a minimum because we don't want to be a swiss army knife that does everything out of the box. Instead, we want to focus on core tasks that are useful to the largest number of projects. The spirit of this framework is to allow flexibility and modularity so that anyone can fit it to their needs. This is why you can write your own transforms, and formats with the register methods.

### Where do things go?

Expand All @@ -51,7 +51,7 @@ We separate each function/method into its own file and group them into directori

Any new features should implement the proper unit tests. We use mocha and chai to test our framework.

If you are adding a new transform, action, format, or template, please add new unit tests. You can see examples in test/formats.
If you are adding a new transform, action, or format: please add new unit tests. You can see examples in test/formats.


[issues]: https://github.com/amzn/style-dictionary/issues
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ This tells the style dictionary build system how and what to build. The default
"buildPath": "build/android/",
"files": [{
"destination": "font_dimens.xml",
"template": "android/fontDimens"
"format": "android/fontDimens"
}]
}
}
Expand All @@ -140,8 +140,9 @@ This tells the style dictionary build system how and what to build. The default
| platform.buildPath | String (optional) | Base path to build the files, must end with a trailing slash. |
| platform.files | Array (optional) | Files to be generated for this platform. |
| platform.file.destination | String (optional) | Location to build the file, will be appended to the buildPath. |
| platform.file.format | String (optional) | Format used to generate the file. Can be a built-in one or you can create your own. Must declare a format or a template. |
| platform.file.template | String (optional) | Template used to generate the file. Can be a built-in one or you can create your own. [More on formats and templates](https://amzn.github.io/style-dictionary/formats_and_templates) |
| platform.file.format | String (optional) | Format used to generate the file. Can be a built-in one or you can create your own. [More on formats](https://amzn.github.io/style-dictionary/#/formats) |
| platform.file.options | Object (optional) | A set of extra options associated with the file. |
| platform.file.options.showFileHeader | Boolean | If the generated file should have a "Do not edit + Timestamp" header (where the format supports it). By default is "true". |

### Properties
```json
Expand Down Expand Up @@ -254,7 +255,7 @@ The comment will appear in the output files, where relevant or the output forma

## Extending

The style dictionary build system is made to be extended. We don't know exactly how everyone will want to use style dictionaries in their project, which is why it is easy to create custom transforms, templates, and formats.
The style dictionary build system is made to be extended. We don't know exactly how everyone will want to use style dictionaries in their project, which is why it is easy to create custom transforms and formats.

```javascript
const StyleDictionary = require('style-dictionary').extend('config.json');
Expand All @@ -273,7 +274,7 @@ StyleDictionary.registerTransform({
StyleDictionary.buildAllPlatforms();
```

For more information on creating your own transforms, templates, and formats, take a look at our [docs](https://amzn.github.io/style-dictionary/).
For more information on creating your own transforms and formats, take a look at our [docs](https://amzn.github.io/style-dictionary/).

## Mascot

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions test/configs/test.json → __tests__/__configs/test.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"source": ["test/properties/**/*.json"],
"source": ["__tests__/__properties/**/*.json"],
"platforms": {
"web": {
"transformGroup": "web",
"prefix": "smop",
"buildPath": "test/output/web/",
"buildPath": "__tests__/__output/web/",
"files": [
{
"destination": "_icons.css",
Expand All @@ -21,7 +21,7 @@
"scss": {
"transformGroup": "scss",
"prefix": "smop",
"buildPath": "test/output/scss/",
"buildPath": "__tests__/__output/scss/",
"files": [
{
"destination": "_icons.scss",
Expand All @@ -35,7 +35,7 @@
"less": {
"transformGroup": "less",
"prefix": "smop",
"buildPath": "test/output/less/",
"buildPath": "__tests__/__output/less/",
"files": [
{
"destination": "_icons.less",
Expand All @@ -48,17 +48,17 @@
},
"android": {
"transformGroup": "android",
"buildPath": "test/output/",
"buildPath": "__tests__/__output/",
"files": [
{
"destination": "android/colors.xml",
"template": "android/colors"
"format": "android/colors"
},{
"destination": "android/font_dimen.xml",
"template": "android/fontDimens"
"format": "android/fontDimens"
},{
"destination": "android/dimens.xml",
"template": "android/dimens"
"format": "android/dimens"
}
],
"actions": [
Expand All @@ -67,14 +67,14 @@
},
"ios": {
"transformGroup": "ios",
"buildPath": "test/output/ios/",
"buildPath": "__tests__/__output/ios/",
"files": [
{
"destination": "style_dictionary.plist",
"template": "ios/plist"
"format": "ios/plist"
},{
"destination": "style_dictionary.h",
"template": "ios/macros"
"format": "ios/macros"
}
]
}
Expand Down
88 changes: 88 additions & 0 deletions __tests__/__configs/test.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
// some comment
source: ['test/properties/**/*.json'],
platforms: {
web: {
transformGroup: 'web',
prefix: 'smop',
buildPath: 'test/output/web/',
files: [
{
destination: '_icons.css',
format: 'scss/icons',
},
{
destination: '_variables.css',
format: 'scss/variables',
},
{
destination: '_styles.js',
format: 'javascript/module',
},
],
},
scss: {
transformGroup: 'scss',
prefix: 'smop',
buildPath: 'test/output/scss/',
files: [
{
destination: '_icons.scss',
format: 'scss/icons',
},
{
destination: '_variables.scss',
format: 'scss/variables',
},
],
},
less: {
transformGroup: 'less',
prefix: 'smop',
buildPath: 'test/output/less/',
files: [
{
destination: '_icons.less',
format: 'less/icons',
},
{
destination: '_variables.less',
format: 'less/variables',
},
],
},
android: {
transformGroup: 'android',
buildPath: 'test/output/',
files: [
{
destination: 'android/colors.xml',
template: 'android/colors',
},
{
destination: 'android/font_dimen.xml',
template: 'android/fontDimens',
},
{
destination: 'android/dimens.xml',
template: 'android/dimens',
},
],
actions: ['android/copyImages'],
},
ios: {
transformGroup: 'ios',
buildPath: 'test/output/ios/',
files: [
{
destination: 'style_dictionary.plist',
template: 'ios/plist',
},
{
destination: 'style_dictionary.h',
template: 'ios/macros',
},
],
},
},
}
2 changes: 1 addition & 1 deletion test/helpers.js → __tests__/__helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var fs = require('fs-extra');

module.exports = {
clearOutput: function() {
fs.emptyDirSync('test/output');
fs.emptyDirSync('__tests__/__output');
},

fileToJSON: function(path) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{

"a": "{b}",
"b": "{c}",
"c": "{d}",
"d": "{a}"
}
}
8 changes: 8 additions & 0 deletions __tests__/__json_files/circular_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"a": {
"b": {
"c": "{j}"
}
},
"j": "{a.b.c}"
}
10 changes: 10 additions & 0 deletions __tests__/__json_files/circular_3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"a": {
"b": "{c.d.e}"
},
"c": {
"d": {
"e": "{a.b}"
}
}
}
17 changes: 17 additions & 0 deletions __tests__/__json_files/circular_4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"a": {
"b": {
"c": {
"d": "{e.f.g}"
}
}
},
"e": {
"f": {
"g": "{h.i}"
}
},
"h": {
"i": "{a.b.c.d}"
}
}
6 changes: 6 additions & 0 deletions __tests__/__json_files/circular_5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"k": "{l}",
"l": "{m}",
"m": "{l}",
"n": "{k}"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions __tests__/__json_files/not_circular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"prop1" : { "value": "test1 value" },
"prop2" : { "value": "test2 value" },
"prop3" : { "value": "{prop1.value}" },
"prop4" : { "value": "{prop3.value}" },
"prop12" : { "value": "{prop1.value}, {prop2.value} and some extra stuff" },
"prop124" : { "value": "{prop1.value}, {prop2.value} and {prop4.value}" }
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions __tests__/__json_files/shallow/3.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
json5A: 5,
// some comment
d: {
json5e: 1,
},
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions __tests__/__properties/font.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"asset": {
"font": {
"icon": {
"value": "./test/__assets/fonts/scapp_icons-regular.ttf"
}
}
}
}
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions __tests__/__properties/images/flags/us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"asset": {
"image": {
"flag": {
"us": {
"mdpi": {
"value": "__tests__/__assets/images/mdpi/flag_us_base.png"
},
"hdpi": {
"value": "__tests__/__assets/images/hdpi/flag_us_base.png"
},
"xhdpi": {
"value": "__tests__/__assets/images/xhdpi/flag_us_base.png"
},
"xxhdpi": {
"value": "__tests__/__assets/images/xxhdpi/flag_us_base.png"
}
}
}
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit fa6ebeb

Please sign in to comment.