@terrazzo/cli 0.6.2 → 0.7.0

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,27 @@
1
1
  # @terrazzo/cli
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#454](https://github.com/terrazzoapp/terrazzo/pull/454) [`44ff082`](https://github.com/terrazzoapp/terrazzo/commit/44ff082ec3cc4034dcbcf7702f9676a631c99dde) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ Breaking change: the new color token object format uses "components" instead of "channels". Please update your tokens accordingly.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`44ff082`](https://github.com/terrazzoapp/terrazzo/commit/44ff082ec3cc4034dcbcf7702f9676a631c99dde)]:
12
+ - @terrazzo/token-tools@0.7.0
13
+ - @terrazzo/parser@0.7.0
14
+
15
+ ## 0.6.3
16
+
17
+ ### Patch Changes
18
+
19
+ - [#443](https://github.com/terrazzoapp/terrazzo/pull/443) [`8cc558f`](https://github.com/terrazzoapp/terrazzo/commit/8cc558ff98cef4eb36240918aa594905dfeb11ee) Thanks [@drwpow](https://github.com/drwpow)! - Bugfix: allow resolving from node_modules in @terrazzo/cli (note: @terrazzo/parser/JS API still runs in browser, so it still can’t resolve npm modules).
20
+
21
+ - Updated dependencies [[`8cc558f`](https://github.com/terrazzoapp/terrazzo/commit/8cc558ff98cef4eb36240918aa594905dfeb11ee)]:
22
+ - @terrazzo/parser@0.6.3
23
+ - @terrazzo/token-tools@0.6.3
24
+
3
25
  ## 0.6.2
4
26
 
5
27
  ### Patch Changes
package/bin/cli.js CHANGED
@@ -25,6 +25,7 @@
25
25
  * SOFTWARE.
26
26
  */
27
27
 
28
+ import { createRequire } from 'node:module';
28
29
  import { parseArgs } from 'node:util';
29
30
  import { Logger } from '@terrazzo/parser';
30
31
  import dotenv from 'dotenv';
@@ -32,10 +33,13 @@ import { buildCmd } from '../dist/build.js';
32
33
  import { checkCmd } from '../dist/check.js';
33
34
  import { helpCmd } from '../dist/help.js';
34
35
  import { initCmd } from '../dist/init.js';
36
+ import { labCmd } from '../dist/lab.js';
35
37
  import { normalizeCmd } from '../dist/normalize.js';
36
38
  import { loadConfig } from '../dist/shared.js';
37
39
  import { versionCmd } from '../dist/version.js';
38
40
 
41
+ const require = createRequire(process.cwd());
42
+
39
43
  // Load env vars before anything else
40
44
  // (a user may not use these at all, but in the offchance they do)
41
45
  dotenv.config();
@@ -121,6 +125,16 @@ export default async function main() {
121
125
  await initCmd({ config, flags, logger });
122
126
  break;
123
127
  }
128
+ case 'lab': {
129
+ try {
130
+ require.resolve('@terrazzo/token-lab');
131
+ await labCmd({ config, configPath, flags, logger });
132
+ } catch {
133
+ console.error('Install @terrazzo/token-lab and try again.');
134
+ process.exit(1);
135
+ }
136
+ break;
137
+ }
124
138
  default: {
125
139
  helpCmd();
126
140
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,wBAAgB,OAAO,SAetB"}
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,wBAAgB,OAAO,SAgBtB"}
package/dist/help.js CHANGED
@@ -8,6 +8,7 @@ export function helpCmd() {
8
8
  check [path] Check tokens.json for errors and run linters
9
9
  lint [path] (alias of check)
10
10
  init Create a starter tokens.json file
11
+ lab Manage your tokens with a web interface
11
12
 
12
13
  [options]
13
14
  --help Show this message
package/dist/help.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,MAAM,UAAU,OAAO;IACrB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;CAab,CAAC,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,MAAM,UAAU,OAAO;IACrB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;CAcb,CAAC,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAoC,MAAM,kBAAkB,CAAC;AAGlG,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAEvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAoC,MAAM,kBAAkB,CAAC;AAGlG,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKlD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAwBvD"}
package/dist/index.js CHANGED
@@ -1,6 +1,29 @@
1
+ import { createRequire } from 'node:module';
2
+ import { pathToFileURL } from 'node:url';
1
3
  import { defineConfig as defineConfigCore } from '@terrazzo/parser';
2
4
  import { cwd } from './shared.js';
5
+ const require = createRequire(cwd);
6
+ // wrap defineConfig from @terrazzo/parser and add Node.js resolution
3
7
  export function defineConfig(config) {
4
- return defineConfigCore(config, { cwd });
8
+ const normalizedConfig = { ...config }; // note: we only need a shallow copy because we’re only mutating top-level `tokens`
9
+ // Resolve tokens from npm modules, if any
10
+ if (typeof normalizedConfig.tokens === 'string' || Array.isArray(normalizedConfig.tokens)) {
11
+ normalizedConfig.tokens = (Array.isArray(normalizedConfig.tokens) ? normalizedConfig.tokens : [normalizedConfig.tokens]).map((tokenPath) => {
12
+ if (tokenPath.startsWith('.') || /^(https?|file):\/\//i.test(tokenPath)) {
13
+ return tokenPath;
14
+ }
15
+ try {
16
+ return pathToFileURL(require.resolve(tokenPath));
17
+ }
18
+ catch (err) {
19
+ console.error(err);
20
+ // this will throw an error if Node couldn’t automatically resolve it,
21
+ // which will be true for many token paths. We don’t need to surface
22
+ // that error; it’ll get its own error down the line if it’s a bad path.
23
+ return tokenPath;
24
+ }
25
+ });
26
+ }
27
+ return defineConfigCore(normalizedConfig, { cwd });
5
28
  }
6
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,YAAY,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAIlC,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,OAAO,gBAAgB,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AAC3C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAgC,YAAY,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAIlC,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;AAEnC,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,gBAAgB,GAAW,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,mFAAmF;IAEnI,0CAA0C;IAC1C,IAAI,OAAO,gBAAgB,CAAC,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1F,g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