@terrazzo/cli 0.0.12 → 0.0.13

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @terrazzo/cli
2
2
 
3
+ ## 0.0.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [#289](https://github.com/terrazzoapp/terrazzo/pull/289) [`0fc9738`](https://github.com/terrazzoapp/terrazzo/commit/0fc9738bb3dfecb680d225e4bd3970f21cfe8079) Thanks [@drwpow](https://github.com/drwpow)! - Add YAML support
8
+
9
+ - Updated dependencies [[`0fc9738`](https://github.com/terrazzoapp/terrazzo/commit/0fc9738bb3dfecb680d225e4bd3970f21cfe8079), [`6a875b1`](https://github.com/terrazzoapp/terrazzo/commit/6a875b163539dba8111911851a7819732056b3aa)]:
10
+ - @terrazzo/parser@0.0.13
11
+
3
12
  ## 0.0.12
4
13
 
5
14
  ### Patch Changes
package/bin/cli.js CHANGED
@@ -30,6 +30,7 @@ import fs from 'node:fs';
30
30
  import path from 'node:path';
31
31
  import { fileURLToPath } from 'node:url';
32
32
  import pc from 'picocolors';
33
+ import yamlToMomoa from 'yaml-to-momoa';
33
34
  import parser from 'yargs-parser';
34
35
 
35
36
  dotenv.config();
@@ -113,7 +114,7 @@ export default async function main() {
113
114
 
114
115
  const watch = args.includes('-w') || args.includes('--watch');
115
116
 
116
- let { tokens, ast } = await parse(rawSchemas, { config });
117
+ let { tokens, ast } = await parse(rawSchemas, { config, yamlToMomoa });
117
118
  let result = await build(tokens, { ast, config });
118
119
  writeFiles(result, config);
119
120
 
@@ -129,7 +130,7 @@ export default async function main() {
129
130
  tokenWatcher.on('change', async (filename) => {
130
131
  try {
131
132
  rawSchemas = await loadTokens(config.tokens);
132
- const parseResult = await parse(rawSchemas, { config });
133
+ const parseResult = await parse(rawSchemas, { config, yamlToMomoa });
133
134
  tokens = parseResult.tokens;
134
135
  ast = parseResult.ast;
135
136
  result = await build(tokens, { ast, config });
@@ -148,7 +149,7 @@ export default async function main() {
148
149
  );
149
150
  config = (await import(filename)).default;
150
151
  rawSchema = await loadTokens(config.tokens);
151
- const parseResult = await parse(tokens, { config });
152
+ const parseResult = await parse(tokens, { config, yamlToMomoa });
152
153
  tokens = parseResult.tokens;
153
154
  ast = parseResult.ast;
154
155
  result = await build(tokens, { ast, config });
@@ -171,7 +172,7 @@ export default async function main() {
171
172
  const rawSchemas = await loadTokens(flags._[0] ? [resolveTokenPath(flags._[0])] : config.tokens);
172
173
  const filename = flags._[0] || config.tokens[0];
173
174
  console.log(pc.underline(filename.protocol === 'file:' ? fileURLToPath(filename) : filename));
174
- await parse(rawSchemas, { config, continueOnError: true }); // will throw if errors
175
+ await parse(rawSchemas, { config, continueOnError: true, yamlToMomoa }); // will throw if errors
175
176
  printSuccess(`No errors ${time(start)}`);
176
177
  break;
177
178
  }
@@ -182,7 +183,7 @@ export default async function main() {
182
183
  }
183
184
 
184
185
  const rawSchema = await loadTokens(flags._[0] ? [resolveTokenPath(flags._[0])] : config.tokens);
185
- const parseResult = await parse(rawSchema, { config, continueOnError: true }); // will throw if errors
186
+ const parseResult = await parse(rawSchema, { config, continueOnError: true, yamlToMomoa }); // will throw if errors
186
187
 
187
188
  // TODO
188
189
 
@@ -245,6 +246,21 @@ async function loadTokens(tokenPaths) {
245
246
  process.exit(1);
246
247
  }
247
248
 
249
+ // if this is the default value, also check for tokens.yaml
250
+ if (tokenPaths.length === 1 && tokenPaths[0].href === new URL('./tokens.json', cwd).href) {
251
+ if (!fs.existsSync(tokenPaths[0])) {
252
+ const yamlPath = new URL('./tokens.yaml', cwd);
253
+ if (fs.existsSync(yamlPath)) {
254
+ tokenPaths[0] = yamlPath;
255
+ } else {
256
+ printErrors(
257
+ `Could not locate ${path.relative(fileURLToPath(cwd), fileURLToPath(tokenPaths[0]))}. To create one, run \`npx tz init\`.`,
258
+ );
259
+ process.exit(1);
260
+ }
261
+ }
262
+ }
263
+
248
264
  // download/read
249
265
  for (let i = 0; i < tokenPaths.length; i++) {
250
266
  const filename = tokenPaths[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terrazzo/cli",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "CLI for managing design tokens using the Design Tokens Community Group (DTCG) standard and generating code for any platform via plugins.",
5
5
  "type": "module",
6
6
  "author": {
@@ -36,12 +36,13 @@
36
36
  "dotenv": "^16.4.5",
37
37
  "merge-anything": "^5.1.7",
38
38
  "picocolors": "^1.0.1",
39
+ "yaml-to-momoa": "^0.0.1",
39
40
  "yargs-parser": "^21.1.1",
40
- "@terrazzo/parser": "^0.0.12",
41
+ "@terrazzo/parser": "^0.0.13",
41
42
  "@terrazzo/token-tools": "^0.0.6"
42
43
  },
43
44
  "devDependencies": {
44
- "typescript": "^5.5.3"
45
+ "typescript": "^5.5.4"
45
46
  },
46
47
  "scripts": {
47
48
  "build": "pnpm run build:clean && pnpm run build:ts",
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { type Config, type ConfigInit } from '@terrazzo/parser';
2
- export declare function defineConfig(config: Config): ConfigInit;
package/dist/index.js DELETED
@@ -1,5 +0,0 @@
1
- import { defineConfig as defineConfigCore } from '@terrazzo/parser';
2
- export function defineConfig(config) {
3
- return defineConfigCore(config, { cwd: new URL(`file://${process.cwd()}/`) });
4
- }
5
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,IAAI,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AAElG,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,OAAO,gBAAgB,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,GAAG,CAAC,UAAU,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAChF,CAAC"}