Skip to content

Commit

Permalink
Merge new develop into master for release (#209)
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

* Added 'json/flat' format (#192)

* Fix: #195 (#196)

* updating contributing to reflect the package manager and testing suite correctly (#197)

* Add Sass maps formats (#193)

* added ‘sass/map-flat’ and ‘sass/map-deep’ formats + updated tests

* fixed inconsistend newlines in templates for sass maps

* improved recursive processJsonNode function

* updated snapshots tests

* removed unused function

* Better examples (#164)

* changed folder structure

* removed table in Readme of Basic example (not clear and probably also some cells were wrong)

* small update for the Basic example to make it more clear how aliases are referenced

* renamed the “npm” example to “npm module”

* updated “npm” example to use the same config and properties as the “basic” example

* removed license (no sense here) and updated package.json

* updated the s3 example making it more similar to other examples and adding some more assets to be uploaded and linked/embedded in tokens

* updated logo in main Readme in example folder

* updated the Readme for the S3 example

* tried to re-organise the “react” folder in two separate folders

the web app doesn’t compile

* removed spaces from “example” sub-folder

* renamed “example” folder to “examples”

* removed numbers from “examples” sub-folder names

* removed space in sub-folder names

* added advanced example on how to use a watcher to auto-rebuild

see: #171

* small update to Readme for “auto-rebuild-watcher”

* added advanced example on how to have a multi-platform multi-brand suite

* added advanced example on how to use custom templates

* fixed “watch” npm script declaration

* moved packages under “devDependencies” for “custom templates” package

* added a comment in an example of the lodash templating syntax

* remove invisible characters from Readme

* added “clean” npm script call where missing in examples package.json

* added .gitignore file where was missing in examples folder

* updated the config file for the “npm module” example

* added a comment to explain better how the “formatter” function works

* updated the “init” command to expose only the possible/meaningful options + updated documentation for the “examples” page

* added comment about collecting more examples

* updated the Readme for the “examples” folder

* updated “version.js” script as per Danny suggestion

* added advanced example on how to use custom transforms

* updated basic example to use “format” instead of “template” to avoid the alert in console

* added advanced example about referencing/aliasing

* updated example to show reference to an “object-like” value

* removed the advanced examples for react and react native

* added a “create react app” example (with Sass)

* better config for S3 example

* simplified the example for “S3”

* re-introduced android + ios in S3 example

* added a “assets-base64-embed” example

* finalised the “assets-base64-embed” example

* updated Readme for “npm” example + fixed the “prepublishOnly” script option (previous one was deprecated)

* removed the “create-react-app-sass” example (I’ll add it later in a separate ticket)

* updated the documentation

* New cut at documentation PR using current develop branch (#198)

* New cut at documentation PR using current develop branch

* Apply @didoo's suggestions from code review

Co-Authored-By: chazzmoney <[email protected]>

* updates based on didoo's thoughts

* Updating the architecture documentation page (#200)

* updates per didoo and dbanks

* typo

* generation differences

* minor fixes and updates

* making sure sd init command documentation is correct, for now

* updates for clarity around properties and references

* fixing up another alias piece

* Addressing some comments in architecture diagram (#204)

* Final touches on build diagram and architecture (#206)

* Final touches on build diagram and architecture

* Updating build diagram

* Updating build diagram

* Configuration doc update

* fixing snapshot whitespace issues, discovered actual failing test on merge...

* Fixing merge conflict issues

* v2.6.0 release (#210)
  • Loading branch information
chazzmoney authored Dec 1, 2018
1 parent 1531a8f commit 3a17ac1
Show file tree
Hide file tree
Showing 458 changed files with 4,729 additions and 5,897 deletions.
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ We are always happy to receive code and documentation contributions to the frame
3. Adding to the included transforms, transformGroups, and formats, please read [this section](#what-should-be-included).


## Package Manager and dependencies

We use npm as our package manager. After downloading the repo, please use the command "npm ci" to ensure you use the package-lock dependency tree. Note that you need NPM 5.7.0 or higher to use this command.


## 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].
Expand All @@ -49,7 +54,7 @@ We separate each function/method into its own file and group them into directori

## Testing

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

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

Expand Down
53 changes: 47 additions & 6 deletions __tests__/formats/__snapshots__/all.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`formats all should return android/colors as a string 1`] = `
Generated on Sat, 01 Jan 2000 00:00:00 GMT
-->
<resources>
<color name=\\"color_red\\">#FF0000</color>
<color name=\\"color_red\\">#FF0000</color><!-- comment -->
</resources>
"
Expand Down Expand Up @@ -78,7 +78,7 @@ exports[`formats all should return css/variables as a string 1`] = `
*/
:root {
--color_red: #FF0000;
--color_red: #FF0000; /* comment */
}
"
`;
Expand Down Expand Up @@ -181,7 +181,7 @@ exports[`formats all should return ios/plist as a string 1`] = `
<key>a</key>
<real>1</real>
</dict>
<!-- comment -->
</dict>
</plist>
"
Expand Down Expand Up @@ -357,7 +357,7 @@ exports[`formats all should return javascript/es6 as a string 1`] = `
* Generated on Sat, 01 Jan 2000 00:00:00 GMT
*/
export const color_red = \\"#FF0000\\";"
export const color_red = \\"#FF0000\\"; // comment"
`;
exports[`formats all should return javascript/module as a string 1`] = `
Expand All @@ -374,6 +374,7 @@ module.exports = {
\\"value\\": \\"#FF0000\\"
},
\\"name\\": \\"color_red\\",
\\"comment\\": \\"comment\\",
\\"attributes\\": {
\\"category\\": \\"color\\",
\\"type\\": \\"red\\"
Expand Down Expand Up @@ -401,6 +402,7 @@ var _styleDictionary = {
\\"value\\": \\"#FF0000\\"
},
\\"name\\": \\"color_red\\",
\\"comment\\": \\"comment\\",
\\"attributes\\": {
\\"category\\": \\"color\\",
\\"type\\": \\"red\\"
Expand Down Expand Up @@ -439,6 +441,7 @@ exports[`formats all should return javascript/umd as a string 1`] = `
\\"value\\": \\"#FF0000\\"
},
\\"name\\": \\"color_red\\",
\\"comment\\": \\"comment\\",
\\"attributes\\": {
\\"category\\": \\"color\\",
\\"type\\": \\"red\\"
Expand All @@ -463,6 +466,7 @@ exports[`formats all should return json as a string 1`] = `
\\"value\\": \\"#FF0000\\"
},
\\"name\\": \\"color_red\\",
\\"comment\\": \\"comment\\",
\\"attributes\\": {
\\"category\\": \\"color\\",
\\"type\\": \\"red\\"
Expand All @@ -478,6 +482,12 @@ exports[`formats all should return json as a string 1`] = `
exports[`formats all should return json/asset as a string 1`] = `"{}"`;
exports[`formats all should return json/flat as a string 1`] = `
"{
\\"color_red\\": \\"#FF0000\\"
}"
`;
exports[`formats all should return json/nested as a string 1`] = `
"{
\\"color\\": {
Expand All @@ -501,7 +511,38 @@ exports[`formats all should return less/variables as a string 1`] = `
* Generated on Sat, 01 Jan 2000 00:00:00 GMT
*/
@color_red: #FF0000;"
@color_red: #FF0000; /* comment */"
`;
exports[`formats all should return sass/map-deep as a string 1`] = `
"
/*
Do not edit directly
Generated on Sat, 01 Jan 2000 00:00:00 GMT
*/
$color_red: #FF0000 !default; // comment
$tokens: (
'color': (
'red': $color_red
)
);
"
`;
exports[`formats all should return sass/map-flat as a string 1`] = `
"
/*
Do not edit directly
Generated on Sat, 01 Jan 2000 00:00:00 GMT
*/
$tokens: (
// comment
'color_red': #FF0000
);
"
`;
exports[`formats all should return scss/icons as a string 1`] = `
Expand All @@ -519,7 +560,7 @@ exports[`formats all should return scss/variables as a string 1`] = `
* Generated on Sat, 01 Jan 2000 00:00:00 GMT
*/
$color_red: #FF0000;"
$color_red: #FF0000; /* comment */"
`;
exports[`formats all should return sketch/palette as a string 1`] = `
Expand Down
47 changes: 47 additions & 0 deletions __tests__/formats/__snapshots__/scssMaps.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`formats sass/map-deep sass/map-deep snapshot 1`] = `
"
/*
Do not edit directly
Generated on Sat, 01 Jan 2000 00:00:00 GMT
*/
$size-font-small: 12rem !default;
$size-font-large: 18rem !default;
$color-base-red: #ff0000 !default; // comment
$color-white: #ffffff !default;
$tokens: (
'size': (
'font': (
'small': $size-font-small,
'large': $size-font-large
)
),
'color': (
'base': (
'red': $color-base-red
),
'white': $color-white
)
);
"
`;

exports[`formats sass/map-flat sass/map-flat snapshot 1`] = `
"
/*
Do not edit directly
Generated on Sat, 01 Jan 2000 00:00:00 GMT
*/
$tokens: (
'size-font-small': 12rem,
'size-font-large': 18rem,
// comment
'color-base-red': #ff0000,
'color-white': #ffffff
);
"
`;
2 changes: 2 additions & 0 deletions __tests__/formats/all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var dictionary = {
value: '#FF0000',
original: { value: '#FF0000' },
name: 'color_red',
comment: 'comment',
attributes: {
category: 'color',
type: 'red',
Expand All @@ -45,6 +46,7 @@ var dictionary = {
value: '#FF0000',
original: { value: '#FF0000' },
name: 'color_red',
comment: 'comment',
attributes: {
category: 'color',
type: 'red',
Expand Down
63 changes: 63 additions & 0 deletions __tests__/formats/jsonFlat.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

var formats = require('../../lib/common/formats');
var fs = require('fs-extra');
var helpers = require('../__helpers');

var file = {
"destination": "__output/",
"format": "json/flat"
};

var dictionary = {
"allProperties": [{
"name": "color-base-red",
"value": "#EF5350",
"original": {
"value": "#EF5350"
},
"attributes": {
"category": "color",
"type": "base",
"item": "red"
},
"path": [
"color",
"base",
"red"
]
}]
};

var formatter = formats['json/flat'].bind(file);

describe('formats', () => {
describe('json/flat', () => {

beforeEach(() => {
helpers.clearOutput();
});

afterEach(() => {
helpers.clearOutput();
});

it('should be a valid JSON file', () => {
fs.writeFileSync('./__tests__/__output/output.flat.json', formatter(dictionary) );
var test = require('../__output/output.flat.json');
expect(test['color-base-red']).toEqual(dictionary.allProperties[0].value);
});
});

});
Loading

0 comments on commit 3a17ac1

Please sign in to comment.