style-dictionary 3.9.0 → 3.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +1 -1
  2. package/examples/advanced/assets-base64-embed/package.json +1 -1
  3. package/examples/advanced/auto-rebuild-watcher/package.json +1 -1
  4. package/examples/advanced/component-cti/package.json +1 -1
  5. package/examples/advanced/create-react-app/package.json +1 -1
  6. package/examples/advanced/create-react-native-app/package.json +1 -1
  7. package/examples/advanced/custom-file-header/package.json +1 -1
  8. package/examples/advanced/custom-filters/package.json +1 -1
  9. package/examples/advanced/custom-formats-with-templates/package.json +1 -1
  10. package/examples/advanced/custom-parser/package.json +1 -1
  11. package/examples/advanced/custom-transforms/package.json +1 -1
  12. package/examples/advanced/font-face-rules/package.json +1 -1
  13. package/examples/advanced/format-helpers/package.json +1 -1
  14. package/examples/advanced/matching-build-files/package.json +1 -1
  15. package/examples/advanced/multi-brand-multi-platform/package.json +1 -1
  16. package/examples/advanced/node-modules-as-config-and-properties/package.json +1 -1
  17. package/examples/advanced/npm-module/package.json +1 -1
  18. package/examples/advanced/referencing_aliasing/package.json +1 -1
  19. package/examples/advanced/s3/package.json +1 -1
  20. package/examples/advanced/tokens-deprecation/package.json +1 -1
  21. package/examples/advanced/transitive-transforms/package.json +1 -1
  22. package/examples/advanced/variables-in-outputs/package.json +1 -1
  23. package/examples/advanced/yaml-tokens/package.json +1 -1
  24. package/lib/common/formatHelpers/createPropertyFormatter.js +4 -1
  25. package/lib/utils/combineJSON.js +16 -14
  26. package/package.json +2 -2
  27. package/types/FormatHelpers.d.ts +5 -4
  28. package/examples/complete/ios/README.md +0 -29
package/README.md CHANGED
@@ -316,7 +316,7 @@ Rather than starting our own spinoff tool, we much prefer bringing Style-Diction
316
316
 
317
317
  I think it's important to stress that it is our shared vision to keep Style-Dictionary as an agnostic (so not "Tokens Studio"-specific) and flexible tool. As Tokens Studio, while we are highly incentivized to see this project progress further to strengthen our product journey, we value the open source community highly and want to make sure this library remains the go-to tool for exporting Design Tokens, whether you use Tokens Studio or not.
318
318
 
319
- We are very open to feedback and collaboration, feel free to reach out to us in [our Slack](https://tokens-studio.slack.com/archives/C0336AEQ06Q)!
319
+ We are very open to feedback and collaboration, feel free to reach out to us in [our Slack](https://join.slack.com/t/tokens-studio/shared_invite/zt-1p8ea3m6t-C163oJcN9g3~YZTKRgo2hg) -> `style-dictionary-v4` channel!
320
320
 
321
321
  ## Mascot
322
322
 
@@ -11,6 +11,6 @@
11
11
  "author": "",
12
12
  "license": "Apache-2.0",
13
13
  "devDependencies": {
14
- "style-dictionary": "3.9.0"
14
+ "style-dictionary": "3.9.2"
15
15
  }
16
16
  }
@@ -17,6 +17,6 @@
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
19
  "chokidar-cli": "^1.2.0",
20
- "style-dictionary": "3.9.0"
20
+ "style-dictionary": "3.9.2"
21
21
  }
22
22
  }
@@ -15,6 +15,6 @@
15
15
  "author": "",
16
16
  "license": "Apache-2.0",
17
17
  "devDependencies": {
18
- "style-dictionary": "3.9.0"
18
+ "style-dictionary": "3.9.2"
19
19
  }
20
20
  }
@@ -10,7 +10,7 @@
10
10
  "styled-components": "^5.3.0"
11
11
  },
12
12
  "devDependencies": {
13
- "style-dictionary": "3.9.0"
13
+ "style-dictionary": "3.9.2"
14
14
  },
15
15
  "resolutions": {
16
16
  "immer": "8.0.1",
@@ -27,7 +27,7 @@
27
27
  "babel-jest": "~25.2.6",
28
28
  "jest": "~25.2.6",
29
29
  "react-test-renderer": "~16.13.1",
30
- "style-dictionary": "3.9.0"
30
+ "style-dictionary": "3.9.2"
31
31
  },
32
32
  "jest": {
33
33
  "preset": "react-native"
@@ -10,6 +10,6 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "devDependencies": {
13
- "style-dictionary": "3.9.0"
13
+ "style-dictionary": "3.9.2"
14
14
  }
15
15
  }
@@ -15,6 +15,6 @@
15
15
  "author": "",
16
16
  "license": "Apache-2.0",
17
17
  "devDependencies": {
18
- "style-dictionary": "3.9.0"
18
+ "style-dictionary": "3.9.2"
19
19
  }
20
20
  }
@@ -18,6 +18,6 @@
18
18
  "handlebars": "^4.7.7",
19
19
  "lodash": "^4.17.21",
20
20
  "pug": "^3.0.2",
21
- "style-dictionary": "3.9.0"
21
+ "style-dictionary": "3.9.2"
22
22
  }
23
23
  }
@@ -9,6 +9,6 @@
9
9
  "author": "",
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
- "style-dictionary": "3.9.0"
12
+ "style-dictionary": "3.9.2"
13
13
  }
14
14
  }
@@ -15,6 +15,6 @@
15
15
  "author": "",
16
16
  "license": "Apache-2.0",
17
17
  "devDependencies": {
18
- "style-dictionary": "3.9.0"
18
+ "style-dictionary": "3.9.2"
19
19
  }
20
20
  }
@@ -8,6 +8,6 @@
8
8
  },
9
9
  "license": "Apache-2.0",
10
10
  "devDependencies": {
11
- "style-dictionary": "3.9.0"
11
+ "style-dictionary": "3.9.2"
12
12
  }
13
13
  }
@@ -10,6 +10,6 @@
10
10
  "author": "",
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "3.9.0"
13
+ "style-dictionary": "3.9.2"
14
14
  }
15
15
  }
@@ -16,6 +16,6 @@
16
16
  "author": "Kelly Harrop <kn.harrop@gmail.com>",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "3.9.0"
19
+ "style-dictionary": "3.9.2"
20
20
  }
21
21
  }
@@ -15,6 +15,6 @@
15
15
  "author": "",
16
16
  "license": "Apache-2.0",
17
17
  "devDependencies": {
18
- "style-dictionary": "3.9.0"
18
+ "style-dictionary": "3.9.2"
19
19
  }
20
20
  }
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "homepage": "https://github.com/dbanksdesign/style-dictionary-node#readme",
21
21
  "devDependencies": {
22
- "style-dictionary": "3.9.0",
22
+ "style-dictionary": "3.9.2",
23
23
  "tinycolor2": "^1.4.1"
24
24
  }
25
25
  }
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "3.9.0"
19
+ "style-dictionary": "3.9.2"
20
20
  }
21
21
  }
@@ -15,6 +15,6 @@
15
15
  "author": "",
16
16
  "license": "Apache-2.0",
17
17
  "devDependencies": {
18
- "style-dictionary": "3.9.0"
18
+ "style-dictionary": "3.9.2"
19
19
  }
20
20
  }
@@ -15,6 +15,6 @@
15
15
  "devDependencies": {
16
16
  "aws-sdk": "^2.7.21",
17
17
  "fs-extra": "^1.0.0",
18
- "style-dictionary": "3.9.0"
18
+ "style-dictionary": "3.9.2"
19
19
  }
20
20
  }
@@ -16,6 +16,6 @@
16
16
  "license": "Apache-2.0",
17
17
  "devDependencies": {
18
18
  "lodash": "^4.17.11",
19
- "style-dictionary": "3.9.0"
19
+ "style-dictionary": "3.9.2"
20
20
  }
21
21
  }
@@ -11,6 +11,6 @@
11
11
  "license": "ISC",
12
12
  "devDependencies": {
13
13
  "chroma-js": "^2.1.0",
14
- "style-dictionary": "3.9.0"
14
+ "style-dictionary": "3.9.2"
15
15
  }
16
16
  }
@@ -10,6 +10,6 @@
10
10
  "author": "",
11
11
  "license": "MIT",
12
12
  "devDependencies": {
13
- "style-dictionary": "3.9.0"
13
+ "style-dictionary": "3.9.2"
14
14
  }
15
15
  }
@@ -9,7 +9,7 @@
9
9
  "author": "",
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
- "style-dictionary": "3.9.0",
12
+ "style-dictionary": "3.9.2",
13
13
  "yaml": "^1.10.0"
14
14
  }
15
15
  }
@@ -184,7 +184,10 @@ function createPropertyFormatter({
184
184
  // because Style Dictionary resolved this in the resolution step.
185
185
  // Here we are undoing that by replacing the value with
186
186
  // the reference's name
187
- if (ref.value && ref.name) {
187
+
188
+ // Safe way to check if object contains a property.
189
+ // below can be replaced with the new safe Object.hasOwn() in evergreen browsers / Node 16.9.0 onwards
190
+ if (Object.prototype.hasOwnProperty.call(ref, 'value') && Object.prototype.hasOwnProperty.call(ref, 'name')) {
188
191
  const replaceFunc = function() {
189
192
  if (format === 'css') {
190
193
  if (outputReferenceFallbacks) {
@@ -11,18 +11,18 @@
11
11
  * and limitations under the License.
12
12
  */
13
13
 
14
- require('json5/lib/register');
14
+ require("json5/lib/register");
15
15
  require.extensions[".jsonc"] = require("./jsonc").register;
16
16
 
17
- var glob = require('glob'),
18
- deepExtend = require('./deepExtend'),
19
- path = require('path'),
20
- fs = require('fs');
17
+ var { globSync } = require("glob"),
18
+ deepExtend = require("./deepExtend"),
19
+ path = require("path"),
20
+ fs = require("fs");
21
21
 
22
22
  function traverseObj(obj, fn) {
23
23
  for (let key in obj) {
24
24
  fn.apply(null, [obj, key, obj[key]]);
25
- if (obj[key] && typeof obj[key] === 'object') {
25
+ if (obj[key] && typeof obj[key] === "object") {
26
26
  traverseObj(obj[key], fn);
27
27
  }
28
28
  }
@@ -39,12 +39,14 @@ function traverseObj(obj, fn) {
39
39
  * @param {Object[]} [parsers=[]] - Custom file parsers
40
40
  * @returns {Object}
41
41
  */
42
- function combineJSON(arr, deep, collision, source, parsers=[]) {
43
- var i, files = [],
42
+ function combineJSON(arr, deep, collision, source, parsers = []) {
43
+ var i,
44
+ files = [],
44
45
  to_ret = {};
45
46
 
46
47
  for (i = 0; i < arr.length; i++) {
47
- var new_files = glob.sync(arr[i], {});
48
+ // Reverse to avoid introducing a breaking change
49
+ var new_files = globSync(arr[i], { posix: true }).reverse();
48
50
  files = files.concat(new_files);
49
51
  }
50
52
 
@@ -61,11 +63,11 @@ function combineJSON(arr, deep, collision, source, parsers=[]) {
61
63
 
62
64
  // Iterate over custom parsers, if the file path matches the parser's
63
65
  // pattern regex, use it's parse function to generate the object
64
- parsers.forEach(({pattern, parse}) => {
66
+ parsers.forEach(({ pattern, parse }) => {
65
67
  if (resolvedPath.match(pattern)) {
66
68
  file_content = parse({
67
- contents: fs.readFileSync(resolvedPath, {encoding:'UTF-8'}),
68
- filePath: resolvedPath
69
+ contents: fs.readFileSync(resolvedPath, { encoding: "UTF-8" }),
70
+ filePath: resolvedPath,
69
71
  });
70
72
  }
71
73
  });
@@ -75,13 +77,13 @@ function combineJSON(arr, deep, collision, source, parsers=[]) {
75
77
  file_content = deepExtend([file_content, require(resolvedPath)]);
76
78
  }
77
79
  } catch (e) {
78
- e.message = 'Failed to load or parse JSON or JS Object: ' + e.message;
80
+ e.message = "Failed to load or parse JSON or JS Object: " + e.message;
79
81
  throw e;
80
82
  }
81
83
 
82
84
  // Add some side data on each property to make filtering easier
83
85
  traverseObj(file_content, (obj) => {
84
- if (obj.hasOwnProperty('value') && !obj.filePath) {
86
+ if (obj.hasOwnProperty("value") && !obj.filePath) {
85
87
  obj.filePath = filePath;
86
88
 
87
89
  obj.isSource = source || source === undefined ? true : false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "style-dictionary",
3
- "version": "3.9.0",
3
+ "version": "3.9.2",
4
4
  "description": "Style once, use everywhere. A build system for creating cross-platform styles.",
5
5
  "keywords": [
6
6
  "style dictionary",
@@ -122,7 +122,7 @@
122
122
  "change-case": "^4.1.2",
123
123
  "commander": "^8.3.0",
124
124
  "fs-extra": "^10.0.0",
125
- "glob": "^7.2.0",
125
+ "glob": "^10.3.10",
126
126
  "json5": "^2.2.2",
127
127
  "jsonc-parser": "^3.0.0",
128
128
  "lodash": "^4.17.15",
@@ -19,6 +19,7 @@ import { File } from "./File";
19
19
  export interface LineFormatting {
20
20
  prefix?: string;
21
21
  commentStyle?: "short" | "long" | "none";
22
+ commentPosition?: "inline" | "above";
22
23
  indentation?: string;
23
24
  separator?: string;
24
25
  suffix?: string;
@@ -53,7 +54,7 @@ export interface FormattedVariablesArgs {
53
54
 
54
55
  export interface FormatHelpers {
55
56
  createPropertyFormatter: (
56
- args: TokenFormatterArgs
57
+ args: TokenFormatterArgs,
57
58
  ) => (token: TransformedToken) => string;
58
59
  fileHeader: (args: FileHeaderArgs) => string;
59
60
  formattedVariables: (args: FormattedVariablesArgs) => string;
@@ -62,15 +63,15 @@ export interface FormatHelpers {
62
63
  iconsWithPrefix: (
63
64
  prefix: string,
64
65
  allTokens: DesignToken[],
65
- options: object
66
+ options: object,
66
67
  ) => string;
67
68
  sortByReference: (
68
- dictionary: Dictionary
69
+ dictionary: Dictionary,
69
70
  ) => (a: TransformedToken, b: TransformedToken) => number;
70
71
  sortByName: (a: DesignToken, b: DesignToken) => number;
71
72
  setSwiftFileProperties: (
72
73
  options: object,
73
74
  objectType: string,
74
- transformGroup: string
75
+ transformGroup: string,
75
76
  ) => string;
76
77
  }
@@ -1,29 +0,0 @@
1
- # StyleDictionary
2
-
3
- [![CI Status](http://img.shields.io/travis/Danny Banks/StyleDictionary.svg?style=flat)](https://travis-ci.org/Danny Banks/StyleDictionary)
4
- [![Version](https://img.shields.io/cocoapods/v/StyleDictionary.svg?style=flat)](http://cocoapods.org/pods/StyleDictionary)
5
- [![License](https://img.shields.io/cocoapods/l/StyleDictionary.svg?style=flat)](http://cocoapods.org/pods/StyleDictionary)
6
- [![Platform](https://img.shields.io/cocoapods/p/StyleDictionary.svg?style=flat)](http://cocoapods.org/pods/StyleDictionary)
7
-
8
- ## Example
9
-
10
- To run the example project, clone the repo, and run `pod install` from the Example directory first.
11
-
12
- ## Requirements
13
-
14
- ## Installation
15
-
16
- StyleDictionary is available through [CocoaPods](http://cocoapods.org). To install
17
- it, you can add the following line to your Podfile:
18
-
19
- ```ruby
20
- pod "StyleDictionary"
21
- ```
22
-
23
- ## Author
24
-
25
- Danny Banks, djb@amazon.com
26
-
27
- ## License
28
-
29
- StyleDictionary is available under the MIT license. See the LICENSE file for more info.