style-dictionary 4.3.0 → 4.3.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.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ export type BuildOptions = {
3
+ config?: string;
4
+ platform?: string[];
5
+ verbose?: boolean;
6
+ warn?: boolean;
7
+ silent?: boolean;
8
+ };
@@ -6,21 +6,39 @@ import path from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import node_fs from 'node:fs';
8
8
  import JSON5 from 'json5';
9
- import program from 'commander';
9
+ import { Command } from 'commander';
10
10
  // usually also node:fs in this context, but can be customized by user
11
11
  import { fs } from 'style-dictionary/fs';
12
12
  import StyleDictionary from 'style-dictionary';
13
13
  import { logWarningLevels, logVerbosityLevels } from '../lib/enums/index.js';
14
14
 
15
+ /**
16
+ * @typedef {{
17
+ * config?: string;
18
+ * platform?: string[];
19
+ * verbose?: boolean;
20
+ * warn?: boolean;
21
+ * silent?: boolean;
22
+ * }} BuildOptions
23
+ */
24
+
25
+ const program = new Command();
15
26
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
16
27
  const { silent, verbose } = logVerbosityLevels;
17
28
  const pkg = JSON5.parse(node_fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
18
29
 
30
+ /**
31
+ * @param {string} val
32
+ * @param {string[]} arr
33
+ */
19
34
  function collect(val, arr) {
20
35
  arr.push(val);
21
36
  return arr;
22
37
  }
23
38
 
39
+ /**
40
+ * @param {BuildOptions} options
41
+ */
24
42
  function getConfigPath(options) {
25
43
  let configPath = options.config;
26
44
 
@@ -108,6 +126,10 @@ program.on('command:*', function () {
108
126
  process.exit(1);
109
127
  });
110
128
 
129
+ /**
130
+ * @param {string} configPath
131
+ * @param {BuildOptions} options
132
+ */
111
133
  function getSD(configPath, options) {
112
134
  let verbosity;
113
135
  let warnings;
@@ -120,27 +142,33 @@ function getSD(configPath, options) {
120
142
  return new StyleDictionary(configPath, { verbosity, warnings });
121
143
  }
122
144
 
145
+ /**
146
+ * @param {BuildOptions} [options]
147
+ */
123
148
  async function styleDictionaryBuild(options) {
124
149
  options = options || {};
125
150
  const configPath = getConfigPath(options);
126
151
  const sd = getSD(configPath, options);
127
152
 
128
153
  if (options.platform && options.platform.length > 0) {
129
- return Promise.all(options.platforms.map((platform) => sd.buildPlatform(platform)));
154
+ await Promise.all(options.platform.map((platform) => sd.buildPlatform(platform)));
130
155
  } else {
131
- return sd.buildAllPlatforms();
156
+ await sd.buildAllPlatforms();
132
157
  }
133
158
  }
134
159
 
160
+ /**
161
+ * @param {BuildOptions} [options]
162
+ */
135
163
  async function styleDictionaryClean(options) {
136
164
  options = options || {};
137
165
  const configPath = getConfigPath(options);
138
166
  const sd = getSD(configPath, options);
139
167
 
140
168
  if (options.platform && options.platform.length > 0) {
141
- return Promise.all(options.platforms.map((platform) => sd.cleanPlatform(platform)));
169
+ await Promise.all(options.platform.map((platform) => sd.cleanPlatform(platform)));
142
170
  } else {
143
- return sd.cleanAllPlatforms();
171
+ await sd.cleanAllPlatforms();
144
172
  }
145
173
  }
146
174
 
@@ -12,6 +12,6 @@
12
12
  "author": "",
13
13
  "license": "Apache-2.0",
14
14
  "devDependencies": {
15
- "style-dictionary": "^4.3.0"
15
+ "style-dictionary": "^4.3.2"
16
16
  }
17
17
  }
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "devDependencies": {
14
14
  "eslint-config-react-app": "^7.0.1",
15
- "style-dictionary": "^4.3.0"
15
+ "style-dictionary": "^4.3.2"
16
16
  },
17
17
  "resolutions": {
18
18
  "immer": "8.0.1",
@@ -29,7 +29,7 @@
29
29
  "eslint-config-react-app": "^7.0.1",
30
30
  "jest": "~25.2.6",
31
31
  "react-test-renderer": "~16.13.1",
32
- "style-dictionary": "^4.3.0"
32
+ "style-dictionary": "^4.3.2"
33
33
  },
34
34
  "jest": {
35
35
  "preset": "react-native"
@@ -10,6 +10,6 @@
10
10
  "author": "",
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^4.3.0"
13
+ "style-dictionary": "^4.3.2"
14
14
  }
15
15
  }
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^4.3.0"
19
+ "style-dictionary": "^4.3.2"
20
20
  }
21
21
  }
@@ -9,6 +9,6 @@
9
9
  },
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
- "style-dictionary": "^4.3.0"
12
+ "style-dictionary": "^4.3.2"
13
13
  }
14
14
  }
@@ -10,6 +10,6 @@
10
10
  "author": "",
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^4.3.0"
13
+ "style-dictionary": "^4.3.2"
14
14
  }
15
15
  }
@@ -17,6 +17,6 @@
17
17
  "author": "Kelly Harrop <kn.harrop@gmail.com>",
18
18
  "license": "Apache-2.0",
19
19
  "devDependencies": {
20
- "style-dictionary": "^4.3.0"
20
+ "style-dictionary": "^4.3.2"
21
21
  }
22
22
  }
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^4.3.0"
19
+ "style-dictionary": "^4.3.2"
20
20
  }
21
21
  }
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "homepage": "https://github.com/dbanksdesign/style-dictionary-node#readme",
22
22
  "devDependencies": {
23
- "style-dictionary": "^4.3.0",
23
+ "style-dictionary": "^4.3.2",
24
24
  "tinycolor2": "^1.4.1"
25
25
  }
26
26
  }
@@ -17,6 +17,6 @@
17
17
  "author": "",
18
18
  "license": "Apache-2.0",
19
19
  "devDependencies": {
20
- "style-dictionary": "^4.3.0"
20
+ "style-dictionary": "^4.3.2"
21
21
  }
22
22
  }
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^4.3.0"
19
+ "style-dictionary": "^4.3.2"
20
20
  }
21
21
  }
@@ -16,6 +16,6 @@
16
16
  "devDependencies": {
17
17
  "aws-sdk": "^2.7.21",
18
18
  "fs-extra": "^1.0.0",
19
- "style-dictionary": "^4.3.0"
19
+ "style-dictionary": "^4.3.2"
20
20
  }
21
21
  }
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^4.3.0",
13
+ "style-dictionary": "^4.3.2",
14
14
  "tailwindcss": "^3.4.15",
15
15
  "mocha": "^10.2.0",
16
16
  "chai": "^5.1.1"
@@ -16,6 +16,6 @@
16
16
  "author": "",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
- "style-dictionary": "^4.3.0"
19
+ "style-dictionary": "^4.3.2"
20
20
  }
21
21
  }
@@ -12,6 +12,6 @@
12
12
  "license": "ISC",
13
13
  "devDependencies": {
14
14
  "colorjs.io": "^0.5.2",
15
- "style-dictionary": "^4.3.0"
15
+ "style-dictionary": "^4.3.2"
16
16
  }
17
17
  }
@@ -11,6 +11,6 @@
11
11
  "author": "",
12
12
  "license": "MIT",
13
13
  "devDependencies": {
14
- "style-dictionary": "^4.3.0"
14
+ "style-dictionary": "^4.3.2"
15
15
  }
16
16
  }
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "Apache-2.0",
12
12
  "devDependencies": {
13
- "style-dictionary": "^4.3.0",
13
+ "style-dictionary": "^4.3.2",
14
14
  "yaml": "^1.10.0"
15
15
  }
16
16
  }
@@ -80,7 +80,7 @@ export default class StyleDictionary extends Register {
80
80
  // Placeholder is transformed on prepublish -> see scripts/inject-version.js
81
81
  // Another option might be import pkg from './package.json' with { "type": "json" } which would work in both browser and node, but support is not there yet.
82
82
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility
83
- static VERSION = '4.3.0';
83
+ static VERSION = '4.3.2';
84
84
 
85
85
  /** @returns {Config} */
86
86
  get options() {
@@ -1655,6 +1655,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
1655
1655
  * @typedef {Object} flutterClassOpts
1656
1656
  * @property {boolean} [flutterClassOpts.showFileHeader=true] - Whether or not to include a comment that has the build date
1657
1657
  * @property {OutputReferences} [flutterClassOpts.outputReferences=false] - Whether or not to keep [references](/#/formats?id=references-in-output-files) (a -> b -> c) in the output.
1658
+ * @property {String} [flutterClassOpts.className] - The name of the generated Dart Class
1658
1659
  * @param {FormatArgs & { options?: flutterClassOpts }} options
1659
1660
  * @example
1660
1661
  * ```dart
@@ -829,7 +829,7 @@ export default {
829
829
  transform: function (token, _, options) {
830
830
  const nonParsed = options.usesDtcg ? token.$value : token.value;
831
831
  // if the dimension already has a unit (non-digit / . period character)
832
- if (`${nonParsed}`.match(/[^0-9.]/g)) {
832
+ if (`${nonParsed}`.match(/[^0-9.-]+$/)) {
833
833
  return nonParsed;
834
834
  }
835
835
  const parsedVal = parseFloat(nonParsed);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "style-dictionary",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "description": "Style once, use everywhere. A build system for creating cross-platform styles.",
5
5
  "keywords": [
6
6
  "style dictionary",
@@ -120,7 +120,7 @@
120
120
  "@zip.js/zip.js": "^2.7.44",
121
121
  "chalk": "^5.3.0",
122
122
  "change-case": "^5.3.0",
123
- "commander": "^8.3.0",
123
+ "commander": "^12.1.0",
124
124
  "is-plain-obj": "^4.1.0",
125
125
  "json5": "^2.2.2",
126
126
  "patch-package": "^8.0.0",