From a482a03ded3bb54b872a413e4e5f4a14f05cbc05 Mon Sep 17 00:00:00 2001 From: Danny Banks Date: Thu, 19 Aug 2021 15:57:05 -0700 Subject: [PATCH] chore(release): 3.0.2 --- CHANGELOG.md | 10 ++++ docs/formats.md | 49 +++++++++++++++++-- docs/transforms.md | 2 +- .../advanced/assets-base64-embed/package.json | 2 +- .../auto-rebuild-watcher/package.json | 2 +- examples/advanced/component-cti/package.json | 2 +- .../advanced/create-react-app/package.json | 4 +- .../create-react-native-app/package.json | 2 +- .../advanced/custom-file-header/package.json | 2 +- .../package.json | 2 +- examples/advanced/custom-parser/package.json | 2 +- .../advanced/custom-transforms/package.json | 2 +- examples/advanced/format-helpers/package.json | 2 +- .../matching-build-files/package.json | 2 +- .../multi-brand-multi-platform/package.json | 2 +- .../package.json | 2 +- examples/advanced/npm-module/package.json | 2 +- .../referencing_aliasing/package.json | 2 +- examples/advanced/s3/package.json | 2 +- .../advanced/tokens-deprecation/package.json | 2 +- .../transitive-transforms/package.json | 2 +- .../variables-in-outputs/package.json | 2 +- examples/advanced/yaml-tokens/package.json | 2 +- package-lock.json | 2 +- package.json | 2 +- 25 files changed, 79 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcde8e44..b70680a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ 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. +### [3.0.2](https://github.com/amzn/style-dictionary/compare/v3.0.1...v3.0.2) (2021-08-19) + + +### Bug Fixes + +* **format:** 'typescript/es6-declarations' return type ([#681](https://github.com/amzn/style-dictionary/issues/681)) ([0cf6c52](https://github.com/amzn/style-dictionary/commit/0cf6c52a3f85a91e5763dc31e0fb6efe2a531e25)) +* **lib:** fix `createFormatArgs` positional args ([#655](https://github.com/amzn/style-dictionary/issues/655)) ([29e511d](https://github.com/amzn/style-dictionary/commit/29e511d07e7991430f6f892879aeb0ade0c6a289)), closes [#652](https://github.com/amzn/style-dictionary/issues/652) +* **references:** check if object value is a string before replacement ([#682](https://github.com/amzn/style-dictionary/issues/682)) ([bfc204c](https://github.com/amzn/style-dictionary/commit/bfc204c50e7addde2b98dc5703b9be31b5b44823)) +* **types:** format config expects formatter function ([#650](https://github.com/amzn/style-dictionary/issues/650)) ([b12c4b1](https://github.com/amzn/style-dictionary/commit/b12c4b1c6a94c62c757cd1675d216d9638f8d6e0)) + ### [3.0.1](https://github.com/amzn/style-dictionary/compare/v3.0.0...v3.0.1) (2021-06-07) diff --git a/docs/formats.md b/docs/formats.md index e9d0f048..2844846d 100644 --- a/docs/formats.md +++ b/docs/formats.md @@ -310,13 +310,17 @@ StyleDictionary.registerFormat({ // the `dictionary` object now has `usesReference()` and // `getReferences()` methods. `usesReference()` will return true if // the value has a reference in it. `getReferences()` will return - // an array of references to the whole tokens so that you can access its - // name or any other attributes. + // an array of references to the whole tokens so that you can access their + // names or any other attributes. if (dictionary.usesReference(token.original.value)) { // Note: make sure to use `token.original.value` because // `token.value` is already resolved at this point. - const reference = dictionary.getReferences(token.original.value); - value = reference.name; + const refs = dictionary.getReferences(token.original.value); + refs.forEach(ref => { + value = value.replace(ref.value, function() { + return `${ref.name}`; + }); + }); } return `export const ${token.name} = ${value};` }).join(`\n`) @@ -480,6 +484,43 @@ StyleDictionary.registerFormat({ * * * +### getTypeScriptType +> formatHelpers.getTypeScriptType(value) ⇒ String + +Given some value, returns a basic valid TypeScript type for that value. +Supports numbers, strings, booleans, and arrays of any of those types. + +**Returns**: String - A valid name for a TypeScript type. +``` + + + + + + + + + + +
ParamTypeDescription
value*

A value to check the type of.

+
+ +**Example** +```javascript +StyleDictionary.registerFormat({ + name: 'myCustomFormat', + formatter: function({ dictionary, options }) { + return dictionary.allProperties.map(function(prop) { + var to_ret_prop = 'export const ' + prop.name + ' : ' + getTypeScriptType(prop.value) + ';'; + if (prop.comment) + to_ret_prop = to_ret_prop.concat(' // ' + prop.comment); + return to_ret_prop; + }).join('\n'); + } +}); + +* * * + ### iconsWithPrefix > formatHelpers.iconsWithPrefix(prefix, allTokens, options) ⇒ String diff --git a/docs/transforms.md b/docs/transforms.md index 3258ae7c..370245b4 100644 --- a/docs/transforms.md +++ b/docs/transforms.md @@ -4,7 +4,7 @@ EDIT scripts/handlebars/templates/api.hbs OR JSDOC COMMENT INSTEAD! --> # Transforms -Transforms are functions that modify a [token](tokens.md) so that it can be understood by a specific platform. It can modify the name, value, or attributes of a token - enabling each platform to use the design token in different ways. A simple example is changing pixel values to point values for iOS and dp or sp for Android. Transforms are isolated per platform; each platform begins with the same design token and makes the modifications it needs without affecting other platforms. The order you use transforms matters because transforms are performed sequentially. Transforms are used in your [configuration](config.md), and can be either [pre-defined transforms](transforms.md?id=pre-defined-transforms) supplied by Style Dictionary or [custom transforms](transforms.md?id=defining-custom-transforms). +Transforms are functions that modify a [token](tokens.md) so that it can be understood by a specific platform. It can modify the name, value, or attributes of a token - enabling each platform to use the design token in different ways. A simple example is changing pixel values to point values for iOS and dp or sp for Android. Transforms are isolated per platform; each platform begins with the same design token and makes the modifications it needs without affecting other platforms. The order you use transforms matters because transforms are performed sequentially. Transforms are used in your [configuration](config.md), and can be either [pre-defined transforms](transforms.md?id=defining-custom-transforms) supplied by Style Dictionary or [custom transforms](transforms.md?id=defining-custom-transforms). ## Using Transforms You use transforms in your config file under platforms > [platform] > transforms diff --git a/examples/advanced/assets-base64-embed/package.json b/examples/advanced/assets-base64-embed/package.json index 88573264..4c380109 100644 --- a/examples/advanced/assets-base64-embed/package.json +++ b/examples/advanced/assets-base64-embed/package.json @@ -11,6 +11,6 @@ "author": "", "license": "Apache-2.0", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/auto-rebuild-watcher/package.json b/examples/advanced/auto-rebuild-watcher/package.json index f61cd672..23296dcf 100644 --- a/examples/advanced/auto-rebuild-watcher/package.json +++ b/examples/advanced/auto-rebuild-watcher/package.json @@ -17,6 +17,6 @@ "license": "Apache-2.0", "devDependencies": { "chokidar-cli": "^1.2.0", - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/component-cti/package.json b/examples/advanced/component-cti/package.json index 30d384fc..d3e44cdb 100644 --- a/examples/advanced/component-cti/package.json +++ b/examples/advanced/component-cti/package.json @@ -15,6 +15,6 @@ "author": "", "license": "Apache-2.0", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/create-react-app/package.json b/examples/advanced/create-react-app/package.json index 5d684918..76d7f056 100644 --- a/examples/advanced/create-react-app/package.json +++ b/examples/advanced/create-react-app/package.json @@ -10,7 +10,7 @@ "styled-components": "^5.3.0" }, "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" }, "resolutions": { "immer": "8.0.1", @@ -35,4 +35,4 @@ "not op_mini all" ], "license": "Apache-2.0" -} +} \ No newline at end of file diff --git a/examples/advanced/create-react-native-app/package.json b/examples/advanced/create-react-native-app/package.json index e53e7ee4..93f06a58 100644 --- a/examples/advanced/create-react-native-app/package.json +++ b/examples/advanced/create-react-native-app/package.json @@ -27,7 +27,7 @@ "babel-jest": "~25.2.6", "jest": "~25.2.6", "react-test-renderer": "~16.13.1", - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" }, "jest": { "preset": "react-native" diff --git a/examples/advanced/custom-file-header/package.json b/examples/advanced/custom-file-header/package.json index e0e202e4..dadffd68 100644 --- a/examples/advanced/custom-file-header/package.json +++ b/examples/advanced/custom-file-header/package.json @@ -10,6 +10,6 @@ "author": "", "license": "ISC", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/custom-formats-with-templates/package.json b/examples/advanced/custom-formats-with-templates/package.json index 2dea7bf9..69d88afa 100644 --- a/examples/advanced/custom-formats-with-templates/package.json +++ b/examples/advanced/custom-formats-with-templates/package.json @@ -18,6 +18,6 @@ "handlebars": "^4.7.7", "lodash": "^4.17.21", "pug": "^3.0.2", - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/custom-parser/package.json b/examples/advanced/custom-parser/package.json index 0d7127b9..5a01cf1e 100644 --- a/examples/advanced/custom-parser/package.json +++ b/examples/advanced/custom-parser/package.json @@ -9,6 +9,6 @@ "author": "", "license": "Apache-2.0", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/custom-transforms/package.json b/examples/advanced/custom-transforms/package.json index 9620b98a..55f02cf6 100644 --- a/examples/advanced/custom-transforms/package.json +++ b/examples/advanced/custom-transforms/package.json @@ -15,6 +15,6 @@ "author": "", "license": "Apache-2.0", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/format-helpers/package.json b/examples/advanced/format-helpers/package.json index 47277628..c1f9e606 100644 --- a/examples/advanced/format-helpers/package.json +++ b/examples/advanced/format-helpers/package.json @@ -10,6 +10,6 @@ "author": "", "license": "Apache-2.0", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/matching-build-files/package.json b/examples/advanced/matching-build-files/package.json index 95900568..684b50d8 100644 --- a/examples/advanced/matching-build-files/package.json +++ b/examples/advanced/matching-build-files/package.json @@ -16,6 +16,6 @@ "author": "Kelly Harrop ", "license": "Apache-2.0", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/multi-brand-multi-platform/package.json b/examples/advanced/multi-brand-multi-platform/package.json index 4cacb8fe..9d1a3361 100644 --- a/examples/advanced/multi-brand-multi-platform/package.json +++ b/examples/advanced/multi-brand-multi-platform/package.json @@ -15,6 +15,6 @@ "author": "", "license": "Apache-2.0", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/node-modules-as-config-and-properties/package.json b/examples/advanced/node-modules-as-config-and-properties/package.json index d6059c49..a59d71ab 100644 --- a/examples/advanced/node-modules-as-config-and-properties/package.json +++ b/examples/advanced/node-modules-as-config-and-properties/package.json @@ -19,7 +19,7 @@ }, "homepage": "https://github.com/dbanksdesign/style-dictionary-node#readme", "devDependencies": { - "style-dictionary": "3.0.1", + "style-dictionary": "3.0.2", "tinycolor2": "^1.4.1" } } \ No newline at end of file diff --git a/examples/advanced/npm-module/package.json b/examples/advanced/npm-module/package.json index b05a0727..196fbcdd 100644 --- a/examples/advanced/npm-module/package.json +++ b/examples/advanced/npm-module/package.json @@ -16,6 +16,6 @@ "author": "", "license": "Apache-2.0", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/referencing_aliasing/package.json b/examples/advanced/referencing_aliasing/package.json index 6675774e..acfab9e0 100644 --- a/examples/advanced/referencing_aliasing/package.json +++ b/examples/advanced/referencing_aliasing/package.json @@ -15,6 +15,6 @@ "author": "", "license": "Apache-2.0", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/s3/package.json b/examples/advanced/s3/package.json index ce751e3e..461ef617 100644 --- a/examples/advanced/s3/package.json +++ b/examples/advanced/s3/package.json @@ -15,6 +15,6 @@ "devDependencies": { "aws-sdk": "^2.7.21", "fs-extra": "^1.0.0", - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/tokens-deprecation/package.json b/examples/advanced/tokens-deprecation/package.json index 2f37d211..2fbc8c9f 100644 --- a/examples/advanced/tokens-deprecation/package.json +++ b/examples/advanced/tokens-deprecation/package.json @@ -16,6 +16,6 @@ "license": "Apache-2.0", "devDependencies": { "lodash": "^4.17.11", - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/transitive-transforms/package.json b/examples/advanced/transitive-transforms/package.json index c48805db..f6744f91 100644 --- a/examples/advanced/transitive-transforms/package.json +++ b/examples/advanced/transitive-transforms/package.json @@ -11,6 +11,6 @@ "license": "ISC", "devDependencies": { "chroma-js": "^2.1.0", - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/variables-in-outputs/package.json b/examples/advanced/variables-in-outputs/package.json index ed8f45bd..e5a8598b 100644 --- a/examples/advanced/variables-in-outputs/package.json +++ b/examples/advanced/variables-in-outputs/package.json @@ -10,6 +10,6 @@ "author": "", "license": "MIT", "devDependencies": { - "style-dictionary": "3.0.1" + "style-dictionary": "3.0.2" } } \ No newline at end of file diff --git a/examples/advanced/yaml-tokens/package.json b/examples/advanced/yaml-tokens/package.json index 1f8be9bf..9d5033e3 100644 --- a/examples/advanced/yaml-tokens/package.json +++ b/examples/advanced/yaml-tokens/package.json @@ -9,7 +9,7 @@ "author": "", "license": "Apache-2.0", "devDependencies": { - "style-dictionary": "3.0.1", + "style-dictionary": "3.0.2", "yaml": "^1.10.0" } } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a1c3812f..68e6fa2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "style-dictionary", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 47e4c13c..6a379c77 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "style-dictionary", - "version": "3.0.1", + "version": "3.0.2", "description": "Style once, use everywhere. A build system for creating cross-platform styles.", "keywords": [ "style dictionary",