@terrazzo/cli 0.10.2 → 0.10.5
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 +15 -0
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -90
- package/dist/index.js.map +1 -1
- package/dist/lab/assets/index-CFxsC-3z.js +10 -0
- package/dist/lab/assets/index-CFxsC-3z.js.map +1 -0
- package/dist/lab/index.html +1 -1
- package/package.json +12 -12
- package/dist/lab/assets/index-Br21kkVL.js +0 -50
- package/dist/lab/assets/index-Br21kkVL.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @terrazzo/cli
|
|
2
2
|
|
|
3
|
+
## 0.10.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix bug in `tz init` where it’s not clear that <kbd>Space</kbd> is needed to install plugins, rather than <kbd>Enter</kbd>.
|
|
8
|
+
|
|
9
|
+
## 0.10.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#533](https://github.com/terrazzoapp/terrazzo/pull/533) [`e1a612f`](https://github.com/terrazzoapp/terrazzo/commit/e1a612f2297662b1dfd4ca517c83b9679960a5cf) Thanks [@pvignau](https://github.com/pvignau)! - Auto-install CSS plugin with Sass during init
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`6141d4f`](https://github.com/terrazzoapp/terrazzo/commit/6141d4f5a9790be73b314c517d9da010f237814e)]:
|
|
16
|
+
- @terrazzo/parser@0.10.3
|
|
17
|
+
|
|
3
18
|
## 0.10.2
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,6 @@ declare function resolveTokenPath(filename: string, {
|
|
|
56
56
|
}): url0.URL;
|
|
57
57
|
/** Print time elapsed */
|
|
58
58
|
declare function time(start: number): string;
|
|
59
|
-
//# sourceMappingURL=shared.d.ts.map
|
|
60
59
|
//#endregion
|
|
61
60
|
//#region src/build.d.ts
|
|
62
61
|
interface BuildOptions {
|
|
@@ -80,7 +79,6 @@ declare function writeFiles(result: BuildRunnerResult, {
|
|
|
80
79
|
config: ConfigInit;
|
|
81
80
|
logger: Logger;
|
|
82
81
|
}): void;
|
|
83
|
-
//# sourceMappingURL=build.d.ts.map
|
|
84
82
|
//#endregion
|
|
85
83
|
//#region src/check.d.ts
|
|
86
84
|
interface CheckOptions {
|
|
@@ -95,12 +93,10 @@ declare function checkCmd({
|
|
|
95
93
|
logger,
|
|
96
94
|
positionals
|
|
97
95
|
}: CheckOptions): Promise<void>;
|
|
98
|
-
//# sourceMappingURL=check.d.ts.map
|
|
99
96
|
//#endregion
|
|
100
97
|
//#region src/help.d.ts
|
|
101
98
|
/** Show help */
|
|
102
99
|
declare function helpCmd(): void;
|
|
103
|
-
//# sourceMappingURL=help.d.ts.map
|
|
104
100
|
//#endregion
|
|
105
101
|
//#region src/init.d.ts
|
|
106
102
|
interface InitOptions {
|
|
@@ -109,7 +105,6 @@ interface InitOptions {
|
|
|
109
105
|
declare function initCmd({
|
|
110
106
|
logger
|
|
111
107
|
}: InitOptions): Promise<void>;
|
|
112
|
-
//# sourceMappingURL=init.d.ts.map
|
|
113
108
|
//#endregion
|
|
114
109
|
//#region src/lab.d.ts
|
|
115
110
|
interface LabBuildOptions {
|
|
@@ -122,7 +117,6 @@ declare function labCmd({
|
|
|
122
117
|
config,
|
|
123
118
|
logger
|
|
124
119
|
}: LabBuildOptions): Promise<void>;
|
|
125
|
-
//# sourceMappingURL=lab.d.ts.map
|
|
126
120
|
//#endregion
|
|
127
121
|
//#region src/normalize.d.ts
|
|
128
122
|
interface NormalizeOptions {
|
|
@@ -133,17 +127,12 @@ declare function normalizeCmd(filename: string, {
|
|
|
133
127
|
logger,
|
|
134
128
|
output
|
|
135
129
|
}: NormalizeOptions): Promise<void>;
|
|
136
|
-
//# sourceMappingURL=normalize.d.ts.map
|
|
137
130
|
//#endregion
|
|
138
131
|
//#region src/version.d.ts
|
|
139
132
|
declare function versionCmd(): void;
|
|
140
|
-
//# sourceMappingURL=version.d.ts.map
|
|
141
|
-
|
|
142
133
|
//#endregion
|
|
143
134
|
//#region src/index.d.ts
|
|
144
135
|
declare function defineConfig(config: Config): ConfigInit;
|
|
145
|
-
//# sourceMappingURL=index.d.ts.map
|
|
146
|
-
|
|
147
136
|
//#endregion
|
|
148
137
|
export { BuildOptions, CheckOptions, Command, DEFAULT_CONFIG_PATH, DEFAULT_TOKENS_PATH, Flags, GREEN_CHECK, InitOptions, LabBuildOptions, LoadConfigOptions, NormalizeOptions, buildCmd, checkCmd, cwd, defineConfig, helpCmd, initCmd, labCmd, loadConfig, loadTokens, normalizeCmd, printError, printSuccess, resolveConfig, resolveTokenPath, time, versionCmd, writeFiles };
|
|
149
138
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/shared.ts","../src/build.ts","../src/check.ts","../src/help.ts","../src/init.ts","../src/lab.ts","../src/normalize.ts","../src/version.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;cAMa,KAAiD,IAAA,CAA9C;cACH,qBAA2D,IAAA,CAAxC;cACnB,qBAAmD,IAAA,CAAhC;AAFnB,KAID,OAAA,GAJkD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/shared.ts","../src/build.ts","../src/check.ts","../src/help.ts","../src/init.ts","../src/lab.ts","../src/normalize.ts","../src/version.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;cAMa,KAAiD,IAAA,CAA9C;cACH,qBAA2D,IAAA,CAAxC;cACnB,qBAAmD,IAAA,CAAhC;AAFnB,KAID,OAAA,GAJkD,OAA9C,GAA8C,OAAA,GAAA,MAAA,GAAA,MAAA,GAAA,SAAA;AACjD,cAKA,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A,CDZA;EAAA,MAAA;EAAA,UAAA;EAAA,KAAA;EAAA;AAAA,CAAA,ECYgD,YDZhD,CAAA,ECY4D,ODZ5D,CAAA,IAAA,CAAA;AAatB;AACO,iBCiFS,UAAA,CDjFT,MAAA,ECiF4B,iBDjF5B,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;EACE,MAAA,ECgF2E,UDhF3E;EACC,MAAA,EC+E8F,MD/E9F;CAAM,CAAA,EAAA,IAAA;;;UE1BC,YAAA;;;EFEJ,MAAiD,EECpD,UFDoD;EACjD,MAAA,EECH,MFDG;AACb;AAEA;AAEa,iBEAS,QAAA,CFAkB;EAAA,MAAA;EAAA,MAAA;EAAA;AAAA,CAAA,EEAwB,YFAxB,CAAA,EEAoC,OFApC,CAAA,IAAA,CAAA;;;;iBGXxB,OAAA,CAAA;;;UCiFC,WAAA;UACP;;AJ7EG,iBIgFS,OAAA,CJhFwC;EAAA;AAAA,CAAA,EIgFpB,WJhFoB,CAAA,EIgFT,OJhFS,CAAA,IAAA,CAAA;;;UKG7C,eAAA;SACR;ELJI,MAAiD,EKKpD,ULLoD;EACjD,UAAA,EAAA,MAAA;EACA,MAAA,EKKH,MLLG;AAEb;AAEa,iBKIS,MAAA,CLJkB;EAAA,MAAA;EAAA;AAAA,CAAA,EKIS,eLJT,CAAA,EKIwB,OLJxB,CAAA,IAAA,CAAA;;;UMLvB,gBAAA;UACP;UACA;ANHV;AACa,iBMWS,YAAA,CNXkD,QAAxC,EAAwC,MAAA,EAAA;EAAA,MAAA;EAAA;AAAA,CAAA,EMWC,gBNXD,CAAA,EMWiB,ONXjB,CAAA,IAAA,CAAA;;;iBOLxD,UAAA,CAAA;;;APYC,iBQGD,YAAA,CRHM,MAAA,EQGe,MRHf,CAAA,EQGwB,URHxB"}
|
package/dist/index.js
CHANGED
|
@@ -187,7 +187,7 @@ function resolveConfig(filename) {
|
|
|
187
187
|
if (filename) {
|
|
188
188
|
const configPath = new URL(filename, cwd);
|
|
189
189
|
if (fs.existsSync(configPath)) return configPath.href;
|
|
190
|
-
return
|
|
190
|
+
return;
|
|
191
191
|
}
|
|
192
192
|
return [
|
|
193
193
|
".js",
|
|
@@ -285,12 +285,10 @@ async function buildCmd({ config, configPath, flags, logger }) {
|
|
|
285
285
|
console.error(pc.red(`✗ ${err.message || err}`));
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
-
|
|
289
|
-
tokenWatcher.on("change", async (filename) => {
|
|
288
|
+
chokidar.watch(config.tokens.map((filename) => fileURLToPath(filename))).on("change", async (filename) => {
|
|
290
289
|
await rebuild({ messageBefore: `${pc.dim(dt.format(/* @__PURE__ */ new Date()))} ${pc.green("tz")}} ${pc.yellow(filename)} updated ${GREEN_CHECK}` });
|
|
291
290
|
});
|
|
292
|
-
|
|
293
|
-
configWatcher.on("change", async () => {
|
|
291
|
+
chokidar.watch(resolveConfig(configPath)).on("change", async () => {
|
|
294
292
|
await rebuild({ messageBefore: `${pc.dim(dt.format(/* @__PURE__ */ new Date()))} ${pc.green("tz")} ${pc.yellow("Config updated. Reloading…")}` });
|
|
295
293
|
});
|
|
296
294
|
await new Promise(() => {});
|
|
@@ -320,8 +318,7 @@ function writeFiles(result, { config, logger }) {
|
|
|
320
318
|
async function checkCmd({ config, logger, positionals }) {
|
|
321
319
|
try {
|
|
322
320
|
const startTime = performance.now();
|
|
323
|
-
const
|
|
324
|
-
const sources = await loadTokens(tokenPaths, { logger });
|
|
321
|
+
const sources = await loadTokens(positionals.slice(1).length ? positionals.slice(1).map((tokenPath) => resolveTokenPath(tokenPath, { logger })) : config.tokens, { logger });
|
|
325
322
|
if (!sources?.length) {
|
|
326
323
|
logger.error({
|
|
327
324
|
group: "config",
|
|
@@ -446,11 +443,11 @@ async function initCmd({ logger }) {
|
|
|
446
443
|
}]
|
|
447
444
|
})];
|
|
448
445
|
if (ds) {
|
|
449
|
-
const s = spinner();
|
|
450
|
-
s.start("Downloading");
|
|
446
|
+
const s$1 = spinner();
|
|
447
|
+
s$1.start("Downloading");
|
|
451
448
|
const tokenSource = await fetch(new URL(ds.tokens[0], DTCG_ROOT_URL)).then((res) => res.text());
|
|
452
449
|
fs.writeFileSync(tokensPath, tokenSource);
|
|
453
|
-
s.stop("Download complete");
|
|
450
|
+
s$1.stop("Download complete");
|
|
454
451
|
}
|
|
455
452
|
}
|
|
456
453
|
const existingPlugins = config.plugins.map((p) => p.name);
|
|
@@ -458,32 +455,37 @@ async function initCmd({ logger }) {
|
|
|
458
455
|
message: "Install plugins?",
|
|
459
456
|
options: [
|
|
460
457
|
{
|
|
461
|
-
value: "@terrazzo/plugin-css",
|
|
458
|
+
value: ["@terrazzo/plugin-css"],
|
|
462
459
|
label: "CSS"
|
|
463
460
|
},
|
|
464
461
|
{
|
|
465
|
-
value: "@terrazzo/plugin-js",
|
|
462
|
+
value: ["@terrazzo/plugin-js"],
|
|
466
463
|
label: "JS + TS"
|
|
467
464
|
},
|
|
468
465
|
{
|
|
469
|
-
value: "@terrazzo/plugin-sass",
|
|
466
|
+
value: ["@terrazzo/plugin-css", "@terrazzo/plugin-sass"],
|
|
470
467
|
label: "Sass"
|
|
471
468
|
},
|
|
472
469
|
{
|
|
473
|
-
value: "@terrazzo/plugin-tailwind",
|
|
470
|
+
value: ["@terrazzo/plugin-tailwind"],
|
|
474
471
|
label: "Tailwind"
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
value: ["NONE"],
|
|
475
|
+
label: "None"
|
|
475
476
|
}
|
|
476
477
|
],
|
|
477
|
-
required:
|
|
478
|
+
required: true
|
|
478
479
|
});
|
|
479
|
-
const newPlugins = Array.isArray(pluginSelection) ? pluginSelection.filter((p) => !existingPlugins.includes(p)) : [];
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
const newPlugins = Array.isArray(pluginSelection) ? Array.from(new Set(pluginSelection.flat().filter((p) => !existingPlugins.includes(p)))) : [];
|
|
481
|
+
let plugins = [];
|
|
482
|
+
const pluginCount = `${newPlugins.length} ${pluralize(newPlugins.length, "plugin", "plugins")}`;
|
|
483
|
+
const s = spinner();
|
|
484
|
+
if (!(newPlugins.length === 1 && newPlugins[0] === "NONE")) {
|
|
485
|
+
plugins = newPlugins.filter((p) => p !== "NONE").map((p) => ({
|
|
482
486
|
specifier: p.replace("@terrazzo/plugin-", ""),
|
|
483
487
|
package: p
|
|
484
488
|
}));
|
|
485
|
-
const pluginCount = `${newPlugins.length} ${pluralize(newPlugins.length, "plugin", "plugins")}`;
|
|
486
|
-
const s = spinner();
|
|
487
489
|
s.start(`Installing ${pluginCount}`);
|
|
488
490
|
await new Promise((resolve, reject) => {
|
|
489
491
|
const subprocess = exec([
|
|
@@ -494,71 +496,74 @@ async function initCmd({ logger }) {
|
|
|
494
496
|
subprocess.on("error", reject);
|
|
495
497
|
subprocess.on("exit", resolve);
|
|
496
498
|
});
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
name: p.specifier
|
|
512
|
-
}
|
|
513
|
-
}],
|
|
514
|
-
attributes: []
|
|
515
|
-
})));
|
|
516
|
-
if (!astExport) {
|
|
517
|
-
logger.error({
|
|
518
|
-
group: "config",
|
|
519
|
-
message: `SyntaxError: ${relConfigPath} does not have default export.`
|
|
520
|
-
});
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
const astConfig = astExport.declaration.type === "CallExpression" ? astExport.declaration.arguments[0] : astExport.declaration;
|
|
524
|
-
if (astConfig.type !== "ObjectExpression") {
|
|
525
|
-
logger.error({
|
|
526
|
-
group: "config",
|
|
527
|
-
message: `Config: expected object default export, received ${astConfig.type}`
|
|
528
|
-
});
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
const pluginsArray = astConfig.properties.find((property) => property.type === "Property" && property.key.type === "Identifier" && property.key.name === "plugins")?.value;
|
|
532
|
-
const pluginsAst = plugins.map((p) => ({
|
|
533
|
-
type: "CallExpression",
|
|
534
|
-
callee: {
|
|
499
|
+
}
|
|
500
|
+
s.message("Updating config");
|
|
501
|
+
if (configPath) {
|
|
502
|
+
const ast = parseModule(fs.readFileSync(configPath, "utf8"));
|
|
503
|
+
const astExport = ast.body.find((node) => node.type === "ExportDefaultDeclaration");
|
|
504
|
+
ast.body.push(...plugins.map((p) => ({
|
|
505
|
+
type: "ImportDeclaration",
|
|
506
|
+
source: {
|
|
507
|
+
type: "Literal",
|
|
508
|
+
value: p.package
|
|
509
|
+
},
|
|
510
|
+
specifiers: [{
|
|
511
|
+
type: "ImportDefaultSpecifier",
|
|
512
|
+
local: {
|
|
535
513
|
type: "Identifier",
|
|
536
514
|
name: p.specifier
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
method: false,
|
|
554
|
-
shorthand: false
|
|
515
|
+
}
|
|
516
|
+
}],
|
|
517
|
+
attributes: []
|
|
518
|
+
})));
|
|
519
|
+
if (!astExport) {
|
|
520
|
+
logger.error({
|
|
521
|
+
group: "config",
|
|
522
|
+
message: `SyntaxError: ${relConfigPath} does not have default export.`
|
|
523
|
+
});
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
const astConfig = astExport.declaration.type === "CallExpression" ? astExport.declaration.arguments[0] : astExport.declaration;
|
|
527
|
+
if (astConfig.type !== "ObjectExpression") {
|
|
528
|
+
logger.error({
|
|
529
|
+
group: "config",
|
|
530
|
+
message: `Config: expected object default export, received ${astConfig.type}`
|
|
555
531
|
});
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
const pluginsArray = astConfig.properties.find((property) => property.type === "Property" && property.key.type === "Identifier" && property.key.name === "plugins")?.value;
|
|
535
|
+
const pluginsAst = plugins.map((p) => ({
|
|
536
|
+
type: "CallExpression",
|
|
537
|
+
callee: {
|
|
538
|
+
type: "Identifier",
|
|
539
|
+
name: p.specifier
|
|
540
|
+
},
|
|
541
|
+
arguments: [],
|
|
542
|
+
optional: false
|
|
543
|
+
}));
|
|
544
|
+
if (pluginsArray) pluginsArray.elements.push(...pluginsAst);
|
|
545
|
+
else astConfig.properties.push({
|
|
546
|
+
type: "Property",
|
|
547
|
+
key: {
|
|
548
|
+
type: "Identifier",
|
|
549
|
+
name: "plugins"
|
|
550
|
+
},
|
|
551
|
+
value: {
|
|
552
|
+
type: "ArrayExpression",
|
|
553
|
+
elements: pluginsAst
|
|
554
|
+
},
|
|
555
|
+
kind: "init",
|
|
556
|
+
computed: false,
|
|
557
|
+
method: false,
|
|
558
|
+
shorthand: false
|
|
559
|
+
});
|
|
560
|
+
fs.writeFileSync(configPath, generate(ast, { format: {
|
|
561
|
+
indent: { style: " " },
|
|
562
|
+
quotes: "single",
|
|
563
|
+
semicolons: true
|
|
564
|
+
} }));
|
|
565
|
+
} else {
|
|
566
|
+
fs.writeFileSync(DEFAULT_CONFIG_PATH, `import { defineConfig } from '@terrazzo/cli';
|
|
562
567
|
${plugins.map((p) => `import ${p.specifier} from '${p.package}';`).join("\n")}
|
|
563
568
|
export default defineConfig({
|
|
564
569
|
tokens: ['./tokens.json'],
|
|
@@ -598,8 +603,7 @@ async function labCmd({ config, logger }) {
|
|
|
598
603
|
port: 9e3,
|
|
599
604
|
overrideGlobalObjects: false,
|
|
600
605
|
async fetch(request) {
|
|
601
|
-
const
|
|
602
|
-
const pathname = url.pathname;
|
|
606
|
+
const pathname = new URL(request.url).pathname;
|
|
603
607
|
if (pathname === "/") return new Response(Readable.toWeb(createReadStream(fileURLToPath(import.meta.resolve("./lab/index.html")))), { headers: { "Content-Type": "text/html" } });
|
|
604
608
|
if (pathname === "/api/tokens") {
|
|
605
609
|
if (request.method === "GET") return new Response(Readable.toWeb(createReadStream(tokenFileUrl)), { headers: {
|
|
@@ -666,10 +670,9 @@ async function normalizeCmd(filename, { logger, output }) {
|
|
|
666
670
|
switch (token.$type) {
|
|
667
671
|
case "color":
|
|
668
672
|
case "dimension":
|
|
669
|
-
case "duration":
|
|
673
|
+
case "duration":
|
|
670
674
|
if (node.value.members[$valueI].value.type === "String") {
|
|
671
|
-
const
|
|
672
|
-
const newValueNode = newValueContainer.members.find(findMember("$value"));
|
|
675
|
+
const newValueNode = parse$1(JSON.stringify({ $value: token.$value })).body.members.find(findMember("$value"));
|
|
673
676
|
node.value.members[$valueI] = newValueNode;
|
|
674
677
|
const { $extensions } = getObjMembers(node.value);
|
|
675
678
|
if ($extensions?.type === "Object") {
|
|
@@ -678,14 +681,12 @@ async function normalizeCmd(filename, { logger, output }) {
|
|
|
678
681
|
const modeName = mode.members[i].name.value;
|
|
679
682
|
const modeValue = token.mode[modeName];
|
|
680
683
|
if (typeof modeValue === "string" && isAlias(modeValue)) continue;
|
|
681
|
-
const
|
|
682
|
-
const newModeValueNode = newModeValueContainer.members.find(findMember(modeName));
|
|
684
|
+
const newModeValueNode = parse$1(JSON.stringify({ [modeName]: token.mode[modeName].$value })).body.members.find(findMember(modeName));
|
|
683
685
|
mode.members[i] = newModeValueNode;
|
|
684
686
|
}
|
|
685
687
|
}
|
|
686
688
|
}
|
|
687
689
|
break;
|
|
688
|
-
}
|
|
689
690
|
}
|
|
690
691
|
} });
|
|
691
692
|
const outputLoc = new URL(output, cwd);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["config: ConfigInit","configPath: string | undefined","tokenPaths: URL[]","res","message: string","startTime?: number","filename?: string","filename: string","start: number","result: BuildRunnerResult","DESIGN_SYSTEMS: Record<DesignSystem, { name: string; author: string; tokens: string[] }>","name: string","member: MemberNode","filename: string","config: Config","normalizedConfig: Config"],"sources":["../src/shared.ts","../src/build.ts","../src/check.ts","../src/help.ts","../src/init.ts","../src/lab.ts","../src/normalize.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type ConfigInit, defineConfig, type Logger } from '@terrazzo/parser';\nimport pc from 'picocolors';\n\nexport const cwd = new URL(`${pathToFileURL(process.cwd())}/`); // trailing slash needed to interpret as directory\nexport const DEFAULT_CONFIG_PATH = new URL('./terrazzo.config.mjs', cwd);\nexport const DEFAULT_TOKENS_PATH = new URL('./tokens.json', cwd);\n\nexport type Command = 'build' | 'check' | 'help' | 'init' | 'version';\n\nexport const GREEN_CHECK = pc.green('✔');\n\nexport interface Flags {\n /** --config, -c */\n config?: string;\n /** --out, -o */\n out?: string;\n /** --help */\n help?: boolean;\n /** --watch, -w */\n watch?: boolean;\n /** --version */\n version?: boolean;\n}\n\nexport interface LoadConfigOptions {\n cmd: Command;\n flags: Flags;\n logger: Logger;\n}\n\n/** Load config */\nexport async function loadConfig({ cmd, flags, logger }: LoadConfigOptions) {\n try {\n let config: ConfigInit = {\n tokens: [DEFAULT_TOKENS_PATH],\n outDir: new URL('./tokens/', cwd),\n plugins: [],\n lint: { build: { enabled: true }, rules: {} },\n ignore: { tokens: [], deprecated: false },\n };\n let configPath: string | undefined;\n\n if (typeof flags.config === 'string') {\n if (flags.config === '') {\n logger.error({ group: 'config', message: 'Missing path after --config flag' });\n process.exit(1);\n }\n configPath = resolveConfig(flags.config);\n }\n\n const resolvedConfigPath = resolveConfig(configPath);\n if (resolvedConfigPath) {\n try {\n const mod = await import(resolvedConfigPath);\n if (!mod.default) {\n // we format it immediately below\n throw new Error(\n `No default export found in ${path.relative(cwd.href, resolvedConfigPath)}. See https://terrazzo.dev/docs/cli for instructions.`,\n );\n }\n config = defineConfig(mod.default, { cwd, logger });\n } catch (err) {\n logger.error({ group: 'config', message: (err as Error).message || (err as string) });\n }\n } else if (cmd !== 'init' && cmd !== 'check') {\n logger.error({ group: 'config', message: 'No config file found. Create one with `npx terrazzo init`.' });\n }\n\n return { config, configPath: resolvedConfigPath! };\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n\n/** load tokens */\nexport async function loadTokens(tokenPaths: URL[], { logger }: { logger: Logger }) {\n try {\n const allTokens = [];\n\n if (!Array.isArray(tokenPaths)) {\n logger.error({ group: 'config', message: `loadTokens: Expected array, received ${typeof tokenPaths}` });\n }\n\n // if this is the default value, also check for tokens.yaml\n if (tokenPaths.length === 1 && tokenPaths[0]!.href === DEFAULT_TOKENS_PATH.href) {\n if (!fs.existsSync(tokenPaths[0]!)) {\n const yamlPath = new URL('./tokens.yaml', cwd);\n if (fs.existsSync(yamlPath)) {\n tokenPaths[0] = yamlPath;\n } else {\n logger.error({\n group: 'config',\n message: `Could not locate ${path.relative(cwd.href, tokenPaths[0]!.href)}. To create one, run \\`npx tz init\\`.`,\n });\n return;\n }\n }\n }\n\n // download/read\n for (let i = 0; i < tokenPaths.length; i++) {\n const filename = tokenPaths[i];\n\n if (!(filename instanceof URL)) {\n logger.error({ group: 'config', message: `Expected URL, received ${filename}`, label: `loadTokens[${i}]` });\n return;\n } else if (filename.protocol === 'http:' || filename.protocol === 'https:') {\n try {\n // if Figma URL\n if (filename.host === 'figma.com' || filename.host === 'www.figma.com') {\n const [_, fileKeyword, fileKey] = filename.pathname.split('/');\n if (fileKeyword !== 'file' || !fileKey) {\n logger.error({\n group: 'config',\n message: `Unexpected Figma URL. Expected \"https://www.figma.com/file/:file_key/:file_name?…\", received \"${filename.href}\"`,\n });\n }\n const headers = new Headers({\n Accept: '*/*',\n 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0',\n });\n if (process.env.FIGMA_ACCESS_TOKEN) {\n headers.set('X-FIGMA-TOKEN', process.env.FIGMA_ACCESS_TOKEN);\n } else {\n logger.warn({ group: 'config', message: 'FIGMA_ACCESS_TOKEN not set' });\n }\n const res = await fetch(`https://api.figma.com/v1/files/${fileKey}/variables/local`, {\n method: 'GET',\n headers,\n });\n if (res.ok) {\n allTokens.push({ filename, src: await res.text() });\n }\n const message = res.status !== 404 ? JSON.stringify(await res.json(), undefined, 2) : '';\n logger.error({\n group: 'config',\n message: `Figma responded with ${res.status}${message ? `:\\n${message}` : ''}`,\n });\n break;\n }\n\n // otherwise, expect YAML/JSON\n const res = await fetch(filename, {\n method: 'GET',\n headers: { Accept: '*/*', 'User-Agent': 'Mozilla/5.0 Gecko/20100101 Firefox/123.0' },\n });\n allTokens.push({ filename, src: await res.text() });\n } catch (err) {\n logger.error({ group: 'config', message: `${filename.href}: ${err}` });\n return;\n }\n } else {\n if (fs.existsSync(filename)) {\n allTokens.push({ filename, src: fs.readFileSync(filename, 'utf8') });\n } else {\n logger.error({\n group: 'config',\n message: `Could not locate ${path.relative(cwd.href, filename.href)}. To create one, run \\`npx tz init\\`.`,\n });\n return;\n }\n }\n }\n\n return allTokens;\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n\n/** Print error */\nexport function printError(message: string) {\n console.error(pc.red(`✗ ${message}`));\n}\n\n/** Print success */\nexport function printSuccess(message: string, startTime?: number) {\n console.log(`${GREEN_CHECK} ${message}${startTime ? ` ${time(startTime)}` : ''}`);\n}\n\n/** Resolve config */\nexport function resolveConfig(filename?: string) {\n // --config [configpath]\n if (filename) {\n const configPath = new URL(filename, cwd);\n if (fs.existsSync(configPath)) {\n return configPath.href; // ⚠️ ESM wants \"file://...\" URLs on Windows & Unix.\n }\n return undefined;\n }\n\n // note: the order isn’t significant; just try for most-common first.\n // if a user has multiple files differing only by file extension, behavior is\n // unpredictable and that’s on them.\n return ['.js', '.mjs', '.cjs']\n .map((ext) => new URL(`./terrazzo.config${ext}`, cwd))\n .find((configPath) => fs.existsSync(configPath))?.href; // ⚠️ ESM wants \"file://...\" URLs on Windows & Unix.;\n}\n\n/** Resolve tokens.json path (for lint command) */\nexport function resolveTokenPath(filename: string, { logger }: { logger: Logger }) {\n const tokensPath = new URL(filename, cwd);\n if (!fs.existsSync(tokensPath)) {\n logger.error({ group: 'config', message: `Could not locate ${filename}. Does the file exist?` });\n } else if (!fs.statSync(tokensPath).isFile()) {\n logger.error({ group: 'config', message: `Expected JSON or YAML file, received ${filename}.` });\n }\n return tokensPath;\n}\n\n/** Print time elapsed */\nexport function time(start: number) {\n const diff = performance.now() - start;\n return pc.dim(diff < 750 ? `${Math.round(diff)}ms` : `${(diff / 1000).toFixed(1)}s`);\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { type BuildRunnerResult, build, type ConfigInit, type Logger, parse } from '@terrazzo/parser';\nimport chokidar from 'chokidar';\nimport pc from 'picocolors';\nimport yamlToMomoa from 'yaml-to-momoa';\nimport {\n cwd,\n DEFAULT_TOKENS_PATH,\n type Flags,\n GREEN_CHECK,\n loadTokens,\n printError,\n printSuccess,\n resolveConfig,\n} from './shared.js';\n\nexport interface BuildOptions {\n flags: Flags;\n config: ConfigInit;\n configPath: string;\n logger: Logger;\n}\n\n/** tz build */\nexport async function buildCmd({ config, configPath, flags, logger }: BuildOptions) {\n try {\n const startTime = performance.now();\n if (!Array.isArray(config.plugins) || !config.plugins.length) {\n logger.error({\n group: 'config',\n message: `No plugins defined! Add some in ${configPath || 'terrazzo.config.js'}`,\n });\n }\n\n // first build\n let rawSchemas = await loadTokens(config.tokens, { logger });\n if (!rawSchemas) {\n logger.error({\n group: 'config',\n message: `Error loading ${path.relative(fileURLToPath(cwd), fileURLToPath(config.tokens[0] || DEFAULT_TOKENS_PATH))}`,\n });\n return;\n }\n let { tokens, sources } = await parse(rawSchemas, { config, logger, yamlToMomoa });\n let result = await build(tokens, { sources, config, logger });\n writeFiles(result, { config, logger });\n\n // --watch (handle rebuild)\n if (flags.watch) {\n const dt = new Intl.DateTimeFormat('en-us', {\n hour: '2-digit',\n minute: '2-digit',\n });\n\n async function rebuild({ messageBefore, messageAfter }: { messageBefore?: string; messageAfter?: string } = {}) {\n try {\n if (messageBefore) {\n logger.info({ group: 'plugin', label: 'watch', message: messageBefore });\n }\n rawSchemas = await loadTokens(config.tokens, { logger });\n if (!rawSchemas) {\n throw new Error(\n `Error loading ${path.relative(fileURLToPath(cwd), fileURLToPath(config.tokens[0] || DEFAULT_TOKENS_PATH))}`,\n );\n }\n const parseResult = await parse(rawSchemas, { config, logger, yamlToMomoa });\n tokens = parseResult.tokens;\n sources = parseResult.sources;\n result = await build(tokens, { sources, config, logger });\n if (messageAfter) {\n logger.info({ group: 'plugin', label: 'watch', message: messageAfter });\n }\n writeFiles(result, { config, logger });\n } catch (err) {\n console.error(pc.red(`✗ ${(err as Error).message || (err as string)}`));\n // don’t exit! we’re watching, so continue as long as possible\n }\n }\n\n const tokenWatcher = chokidar.watch(config.tokens.map((filename) => fileURLToPath(filename)));\n tokenWatcher.on('change', async (filename) => {\n await rebuild({\n messageBefore: `${pc.dim(dt.format(new Date()))} ${pc.green('tz')}} ${pc.yellow(filename)} updated ${GREEN_CHECK}`,\n });\n });\n const configWatcher = chokidar.watch(resolveConfig(configPath)!);\n configWatcher.on('change', async () => {\n await rebuild({\n messageBefore: `${pc.dim(dt.format(new Date()))} ${pc.green('tz')} ${pc.yellow('Config updated. Reloading…')}`,\n });\n });\n\n // keep process occupied\n await new Promise(() => {});\n } else {\n printSuccess(\n `${Object.keys(tokens).length} token${Object.keys(tokens).length !== 1 ? 's' : ''} built`,\n startTime,\n );\n }\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n\n/** Write files */\nexport function writeFiles(result: BuildRunnerResult, { config, logger }: { config: ConfigInit; logger: Logger }) {\n for (const { filename, contents } of result.outputFiles) {\n const output = new URL(filename, config.outDir);\n fs.mkdirSync(new URL('.', output), { recursive: true });\n fs.writeFileSync(output, contents);\n logger.debug({ group: 'parser', label: 'buildEnd', message: `Wrote file ${fileURLToPath(output)}` });\n }\n}\n","import { type ConfigInit, type Logger, parse } from '@terrazzo/parser';\nimport yamlToMomoa from 'yaml-to-momoa';\nimport { loadTokens, printError, printSuccess, resolveTokenPath } from './shared.js';\n\nexport interface CheckOptions {\n /** positional CLI args */\n positionals: string[];\n config: ConfigInit;\n logger: Logger;\n}\n\n/** tz check */\nexport async function checkCmd({ config, logger, positionals }: CheckOptions) {\n try {\n const startTime = performance.now();\n const tokenPaths = positionals.slice(1).length\n ? positionals.slice(1).map((tokenPath) => resolveTokenPath(tokenPath, { logger }))\n : config.tokens;\n const sources = await loadTokens(tokenPaths, { logger });\n if (!sources?.length) {\n logger.error({ group: 'config', message: 'Couldn’t find any tokens. Run `npx tz init` to create some.' });\n return;\n }\n await parse(sources, { config, continueOnError: true, logger, yamlToMomoa }); // will throw if errors\n printSuccess('No errors', startTime);\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n","/** Show help */\nexport function helpCmd() {\n console.log(`tz\n [commands]\n build Build token artifacts from tokens.json\n --watch, -w Watch tokens.json for changes and recompile\n --no-lint Disable linters running on build\n check [path] Check tokens.json for errors and run linters\n lint [path] (alias of check)\n init Create a starter tokens.json file\n lab Manage your tokens with a web interface\n\n [options]\n --help Show this message\n --config, -c Path to config (default: ./terrazzo.config.js)\n --quiet Suppress warnings\n`);\n}\n","import { exec } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { confirm, intro, multiselect, outro, select, spinner } from '@clack/prompts';\nimport type { Logger } from '@terrazzo/parser';\nimport { pluralize } from '@terrazzo/token-tools';\nimport { detect } from 'detect-package-manager';\nimport { generate } from 'escodegen';\nimport { type ESTree, parseModule } from 'meriyah';\nimport { cwd, DEFAULT_CONFIG_PATH, DEFAULT_TOKENS_PATH, loadConfig, printError } from './shared.js';\n\nconst INSTALL_COMMAND = {\n npm: 'install -D --silent',\n yarn: 'add -D --silent',\n pnpm: 'add -D --silent',\n bun: 'install -D --silent',\n};\n\n// Local copy of dtcg-examples/index.json. Copied partially for security (no\n// arbitrary injection of URL fetches), but also efficiency (saves a\n// round-trip).\ntype DesignSystem =\n | 'adobe-spectrum'\n | 'apple-hig'\n | 'figma-sds'\n | 'github-primer'\n | 'ibm-carbon'\n | 'microsoft-fluent'\n | 'radix'\n | 'salesforce-lightning'\n | 'shopify-polaris';\n\nconst DTCG_ROOT_URL = 'https://raw.githubusercontent.com/terrazzoapp/dtcg-examples/refs/heads/main/';\nconst DESIGN_SYSTEMS: Record<DesignSystem, { name: string; author: string; tokens: string[] }> = {\n 'adobe-spectrum': {\n name: 'Spectrum',\n author: 'Adobe',\n tokens: ['adobe-spectrum.json'],\n },\n 'apple-hig': {\n name: 'Human Interface Guidelines',\n author: 'Apple',\n tokens: ['apple-hig.json'],\n },\n 'figma-sds': {\n name: 'Simple Design System',\n author: 'Figma',\n tokens: ['figma-sds.json'],\n },\n 'github-primer': {\n name: 'Primer',\n author: 'GitHub',\n tokens: ['github-primer.json'],\n },\n 'ibm-carbon': {\n name: 'Carbon',\n author: 'IBM',\n tokens: ['ibm-carbon.json'],\n },\n 'microsoft-fluent': {\n name: 'Fluent',\n author: 'Microsoft',\n tokens: ['microsoft-fluent.json'],\n },\n radix: {\n name: 'Radix',\n author: 'Radix',\n tokens: ['radix.json'],\n },\n 'salesforce-lightning': {\n name: 'Lightning',\n author: 'Salesforce',\n tokens: ['salesforce-lightning.json'],\n },\n 'shopify-polaris': {\n name: 'Polaris',\n author: 'Shopify',\n tokens: ['shopify-polaris.json'],\n },\n};\n\nexport interface InitOptions {\n logger: Logger;\n}\n\nexport async function initCmd({ logger }: InitOptions) {\n try {\n intro('⛋ Welcome to Terrazzo');\n const packageManager = await detect({ cwd: fileURLToPath(cwd) });\n\n // TODO: pass in CLI flags?\n const { config, configPath } = await loadConfig({ cmd: 'init', flags: {}, logger });\n const relConfigPath = configPath\n ? path.relative(fileURLToPath(cwd), fileURLToPath(new URL(configPath)))\n : undefined;\n\n let tokensPath = config.tokens[0]!;\n let startFromDS = !(tokensPath && fs.existsSync(tokensPath));\n\n // 1. tokens\n if (tokensPath && fs.existsSync(tokensPath)) {\n if (\n await confirm({\n message: `Found tokens at ${path.relative(fileURLToPath(cwd), fileURLToPath(tokensPath))}. Overwrite with a new design system?`,\n })\n ) {\n startFromDS = true;\n }\n } else {\n tokensPath = DEFAULT_TOKENS_PATH;\n }\n\n if (startFromDS) {\n const ds = DESIGN_SYSTEMS[\n (await select({\n message: 'Start from existing design system?',\n options: [\n ...Object.entries(DESIGN_SYSTEMS).map(([id, { author, name }]) => ({\n value: id,\n label: `${author} ${name}`,\n })),\n { value: 'none', label: 'None' },\n ],\n })) as keyof typeof DESIGN_SYSTEMS\n ] as (typeof DESIGN_SYSTEMS)[DesignSystem] | undefined;\n if (ds) {\n // TODO: support multiple tokens files?\n const s = spinner();\n s.start('Downloading');\n const tokenSource = await fetch(new URL(ds.tokens[0]!, DTCG_ROOT_URL)).then((res) => res.text());\n fs.writeFileSync(tokensPath, tokenSource);\n s.stop('Download complete');\n }\n }\n\n // 2. plugins\n const existingPlugins = config.plugins.map((p) => p.name);\n const pluginSelection = await multiselect({\n message: 'Install plugins?',\n options: [\n { value: '@terrazzo/plugin-css', label: 'CSS' },\n { value: '@terrazzo/plugin-js', label: 'JS + TS' },\n { value: '@terrazzo/plugin-sass', label: 'Sass' },\n { value: '@terrazzo/plugin-tailwind', label: 'Tailwind' },\n ],\n required: false,\n });\n const newPlugins = Array.isArray(pluginSelection)\n ? pluginSelection.filter((p) => !existingPlugins.includes(p))\n : [];\n if (newPlugins?.length) {\n const plugins = newPlugins.map((p) => ({ specifier: p.replace('@terrazzo/plugin-', ''), package: p }));\n const pluginCount = `${newPlugins.length} ${pluralize(newPlugins.length, 'plugin', 'plugins')}`;\n\n const s = spinner();\n s.start(`Installing ${pluginCount}`);\n // note: thi sis async to show the spinner\n await new Promise((resolve, reject) => {\n const subprocess = exec([packageManager, INSTALL_COMMAND[packageManager], newPlugins.join(' ')].join(' '), {\n cwd,\n });\n subprocess.on('error', reject);\n subprocess.on('exit', resolve);\n });\n s.message('Updating config');\n if (configPath) {\n const ast = parseModule(fs.readFileSync(configPath, 'utf8'));\n const astExport = ast.body.find((node) => node.type === 'ExportDefaultDeclaration');\n\n // 2a. add plugin imports\n // note: this has the potential to duplicate plugins, but we tried our\n // best to filter already, and this may be the user’s fault if they\n // selected to install a plugin already installed. But also, this is\n // easily-fixable, so let’s not waste too much time here (and possibly\n // introduce bugs).\n ast.body.push(\n ...plugins.map(\n (p) =>\n ({\n type: 'ImportDeclaration',\n source: { type: 'Literal', value: p.package },\n specifiers: [{ type: 'ImportDefaultSpecifier', local: { type: 'Identifier', name: p.specifier } }],\n attributes: [],\n }) as ESTree.ImportDeclaration,\n ),\n );\n\n // 2b. add plugins to config.plugins\n if (!astExport) {\n logger.error({ group: 'config', message: `SyntaxError: ${relConfigPath} does not have default export.` });\n return;\n }\n const astConfig = (\n astExport.declaration.type === 'CallExpression'\n ? // export default defineConfig({ ... })\n astExport.declaration.arguments[0]\n : // export default { ... }\n astExport.declaration\n ) as ESTree.ObjectExpression;\n if (astConfig.type !== 'ObjectExpression') {\n logger.error({\n group: 'config',\n message: `Config: expected object default export, received ${astConfig.type}`,\n });\n return;\n }\n const pluginsArray = (\n astConfig.properties.find(\n (property) =>\n property.type === 'Property' && property.key.type === 'Identifier' && property.key.name === 'plugins', // ASTs are so fun 😑\n ) as ESTree.Property\n )?.value as ESTree.ArrayExpression | undefined;\n const pluginsAst = plugins.map(\n (p) =>\n ({\n type: 'CallExpression',\n callee: {\n type: 'Identifier',\n name: p.specifier,\n },\n arguments: [],\n }) as ESTree.CallExpression,\n );\n if (pluginsArray) {\n pluginsArray.elements.push(...pluginsAst);\n } else {\n astConfig.properties.push({\n type: 'Property',\n key: { type: 'Identifier', name: 'plugins' },\n value: { type: 'ArrayExpression', elements: pluginsAst },\n kind: 'init',\n computed: false,\n method: false,\n shorthand: false,\n });\n }\n\n // 2c. update new file (and we’ll probably format it wrong but hey)\n fs.writeFileSync(\n configPath,\n generate(ast, {\n format: {\n indent: { style: ' ' },\n quotes: 'single',\n semicolons: true,\n },\n }),\n );\n } else {\n // 2a. write new config file (easy)\n fs.writeFileSync(\n DEFAULT_CONFIG_PATH,\n `import { defineConfig } from '@terrazzo/cli';\n${plugins.map((p) => `import ${p.specifier} from '${p.package}';`).join('\\n')}\nexport default defineConfig({\n tokens: ['./tokens.json'],\n plugins: [\n ${plugins.map((p) => `${p.specifier}(),`).join('\\n ')}\n ],\n outDir: './dist/',\n lint: {\n /** @see https://terrazzo.app/docs/cli/lint */\n },\n});`,\n );\n }\n s.stop(`Installed ${pluginCount}`);\n }\n\n outro('⛋ Done! 🎉');\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n","import { createReadStream, createWriteStream, type PathLike } from 'node:fs';\nimport { readdir } from 'node:fs/promises';\nimport { Readable, Writable } from 'node:stream';\nimport { fileURLToPath } from 'node:url';\nimport { serve } from '@hono/node-server';\nimport type { ConfigInit, Logger } from '@terrazzo/parser';\nimport mime from 'mime';\nimport type { Flags } from './shared.js';\n\nexport interface LabBuildOptions {\n flags: Flags;\n config: ConfigInit;\n configPath: string;\n logger: Logger;\n}\n\nexport async function labCmd({ config, logger }: LabBuildOptions) {\n /** TODO: handle multiple files */\n const [tokenFileUrl] = config.tokens;\n\n const staticFiles = new Set();\n const dirEntries = await readdir(fileURLToPath(import.meta.resolve('./lab')), {\n withFileTypes: true,\n recursive: true,\n });\n for (const entry of dirEntries) {\n if (entry.isFile() === false) {\n continue;\n }\n const absolutePath = `${entry.parentPath.replaceAll('\\\\', '/')}/${entry.name}`;\n staticFiles.add(absolutePath.replace(fileURLToPath(import.meta.resolve('./lab')).replaceAll('\\\\', '/'), ''));\n }\n\n const server = serve(\n {\n port: 9000,\n overrideGlobalObjects: false,\n async fetch(request) {\n const url = new URL(request.url);\n const pathname = url.pathname;\n if (pathname === '/') {\n return new Response(\n Readable.toWeb(createReadStream(fileURLToPath(import.meta.resolve('./lab/index.html')))) as ReadableStream,\n {\n headers: {\n 'Content-Type': 'text/html',\n },\n },\n );\n }\n if (pathname === '/api/tokens') {\n if (request.method === 'GET') {\n return new Response(Readable.toWeb(createReadStream(tokenFileUrl as PathLike)) as ReadableStream, {\n headers: {\n 'Content-Type': 'application/json',\n 'Cache-Control': 'no-cache',\n },\n });\n } else if (request.method === 'POST' && request.body) {\n await request.body.pipeTo(Writable.toWeb(createWriteStream(tokenFileUrl as PathLike)));\n return new Response(JSON.stringify({ success: true }), {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n }\n\n if (staticFiles.has(pathname)) {\n return new Response(\n Readable.toWeb(createReadStream(fileURLToPath(import.meta.resolve(`./lab${pathname}`)))) as ReadableStream,\n {\n headers: { 'Content-Type': mime.getType(pathname) ?? 'application/octet-stream' },\n },\n );\n }\n return new Response('Not found', { status: 404 });\n },\n },\n (info) => {\n logger.info({\n group: 'server',\n message: `Token Lab running at http://${info.address === '::' ? 'localhost' : info.address}:${info.port}`,\n });\n },\n );\n /**\n * The cli entrypoint is going to manually exit the process after labCmd returns.\n */\n await new Promise<void>((resolve, reject) => {\n server.on('close', resolve);\n server.on('error', reject);\n });\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { type MemberNode, type ObjectNode, parse as parseJSON, print, type StringNode } from '@humanwhocodes/momoa';\nimport { defineConfig, getObjMembers, type Logger, parse, traverse } from '@terrazzo/parser';\nimport { isAlias } from '@terrazzo/token-tools';\nimport { cwd, printError } from './shared.js';\n\nexport interface NormalizeOptions {\n logger: Logger;\n output: URL;\n}\n\nfunction findMember(name: string) {\n return function (member: MemberNode) {\n return member.name.type === 'String' && member.name.value === name;\n };\n}\n\nexport async function normalizeCmd(filename: string, { logger, output }: NormalizeOptions) {\n try {\n if (!filename) {\n logger.error({ group: 'config', message: 'Expected input: `tz normalize <tokens.json> -o output.json`' });\n return;\n }\n const sourceLoc = new URL(filename, cwd);\n if (!fs.existsSync(sourceLoc)) {\n logger.error({\n group: 'config',\n message: `Couldn’t find ${path.relative(cwd.href, sourceLoc.href)}. Does it exist?`,\n });\n }\n const sourceData = fs.readFileSync(sourceLoc, 'utf8');\n const document = parseJSON(sourceData);\n const { tokens } = await parse([{ src: sourceData, filename: sourceLoc }], {\n config: defineConfig({}, { cwd }),\n logger,\n });\n\n traverse(document, {\n enter(node, _parent, nodePath) {\n const token = tokens[nodePath.join('.')];\n\n if (!token || token.aliasOf || node.type !== 'Member' || node.value.type !== 'Object') {\n return;\n }\n const $valueI = node.value.members.findIndex(findMember('$value'));\n\n switch (token.$type) {\n case 'color':\n case 'dimension':\n case 'duration': {\n if (node.value.members[$valueI]!.value.type === 'String') {\n const newValueContainer = parseJSON(JSON.stringify({ $value: token.$value })).body as ObjectNode;\n const newValueNode = newValueContainer.members.find(findMember('$value'))!;\n node.value.members[$valueI] = newValueNode;\n\n const { $extensions } = getObjMembers(node.value);\n if ($extensions?.type === 'Object') {\n const { mode } = getObjMembers($extensions);\n if (mode?.type === 'Object') {\n for (let i = 0; i < mode.members.length; i++) {\n const modeName = (mode.members[i]!.name as StringNode).value;\n const modeValue = token.mode[modeName]!;\n if (typeof modeValue === 'string' && isAlias(modeValue)) {\n continue;\n }\n const newModeValueContainer = parseJSON(\n JSON.stringify({ [modeName]: token.mode[modeName]!.$value }),\n ).body as ObjectNode;\n const newModeValueNode = newModeValueContainer.members.find(findMember(modeName))!;\n mode.members[i] = newModeValueNode;\n }\n }\n }\n }\n break;\n }\n }\n },\n });\n\n const outputLoc = new URL(output, cwd);\n fs.mkdirSync(new URL('.', outputLoc), { recursive: true });\n fs.writeFileSync(outputLoc, print(document, { indent: 2 }));\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n","import fs from 'node:fs';\n\nexport function versionCmd() {\n const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));\n console.log(version);\n}\n","import { createRequire } from 'node:module';\nimport { pathToFileURL } from 'node:url';\nimport { type Config, type ConfigInit, defineConfig as defineConfigCore } from '@terrazzo/parser';\nimport { cwd } from './shared.js';\n\nexport * from './build.js';\nexport * from './check.js';\nexport * from './help.js';\nexport * from './init.js';\nexport * from './lab.js';\nexport * from './normalize.js';\nexport * from './shared.js';\nexport * from './version.js';\n\nconst require = createRequire(cwd);\n\n// wrap defineConfig from @terrazzo/parser and add Node.js resolution\nexport function defineConfig(config: Config): ConfigInit {\n const normalizedConfig: Config = { ...config }; // note: we only need a shallow copy because we’re only mutating top-level `tokens`\n\n // Resolve tokens from npm modules, if any\n if (typeof normalizedConfig.tokens === 'string' || Array.isArray(normalizedConfig.tokens)) {\n normalizedConfig.tokens = (\n Array.isArray(normalizedConfig.tokens) ? normalizedConfig.tokens : [normalizedConfig.tokens]\n ).map((tokenPath) => {\n if (tokenPath.startsWith('.') || /^(https?|file):\\/\\//i.test(tokenPath)) {\n return tokenPath;\n }\n try {\n return pathToFileURL(require.resolve(tokenPath));\n } catch (err) {\n console.error(err);\n // this will throw an error if Node couldn’t automatically resolve it,\n // which will be true for many token paths. We don’t need to surface\n // that error; it’ll get its own error down the line if it’s a bad path.\n return tokenPath;\n }\n }) as string[];\n }\n\n return defineConfigCore(normalizedConfig, { cwd });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAMA,MAAa,MAAM,IAAI,IAAI,GAAG,cAAc,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC;AAC7D,MAAa,sBAAsB,IAAI,IAAI,yBAAyB;AACpE,MAAa,sBAAsB,IAAI,IAAI,iBAAiB;AAI5D,MAAa,cAAc,GAAG,MAAM,IAAI;;AAsBxC,eAAsB,WAAW,EAAE,KAAK,OAAO,QAA2B,EAAE;AAC1E,KAAI;EACF,IAAIA,SAAqB;GACvB,QAAQ,CAAC,mBAAoB;GAC7B,QAAQ,IAAI,IAAI,aAAa;GAC7B,SAAS,CAAE;GACX,MAAM;IAAE,OAAO,EAAE,SAAS,KAAM;IAAE,OAAO,CAAE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;CAC3B,MAAM,EAAE,SAAS,GAAG,KAAK,MAAM,GAAG,aAAa,IAAI,IAAI,mBAAmB,OAAO,KAAK,MAAM,OAAO,CAAC;AACpG,SAAQ,IAAI,QAAQ;AACrB;;;;ACSD,MAAM,UAAU,cAAc,IAAI;AAGlC,SAAgB,aAAaC,QAA4B;CACvD,MAAMC,mBAA2B,EAAE,GAAG,OAAQ;AAG9C,YAAW,iBAAiB,WAAW,YAAY,MAAM,QAAQ,iBAAiB,OAAO,CACvF,kBAAiB,SAAS,CACxB,MAAM,QAAQ,iBAAiB,OAAO,GAAG,iBAAiB,SAAS,CAAC,iBAAiB,MAAO,GAC5F,IAAI,CAAC,cAAc;AACnB,MAAI,UAAU,WAAW,IAAI,IAAI,uBAAuB,KAAK,UAAU,CACrE,QAAO;AAET,MAAI;AACF,UAAO,cAAc,QAAQ,QAAQ,UAAU,CAAC;EACjD,SAAQ,KAAK;AACZ,WAAQ,MAAM,IAAI;AAIlB,UAAO;EACR;CACF,EAAC;AAGJ,QAAO,eAAiB,kBAAkB,EAAE,IAAK,EAAC;AACnD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["config: ConfigInit","configPath: string | undefined","defineConfig","res","DESIGN_SYSTEMS: Record<DesignSystem, { name: string; author: string; tokens: string[] }>","s","plugins: { specifier: string; package: string }[]","parseJSON","defineConfig","normalizedConfig: Config","defineConfigCore"],"sources":["../src/shared.ts","../src/build.ts","../src/check.ts","../src/help.ts","../src/init.ts","../src/lab.ts","../src/normalize.ts","../src/version.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { type ConfigInit, defineConfig, type Logger } from '@terrazzo/parser';\nimport pc from 'picocolors';\n\nexport const cwd = new URL(`${pathToFileURL(process.cwd())}/`); // trailing slash needed to interpret as directory\nexport const DEFAULT_CONFIG_PATH = new URL('./terrazzo.config.mjs', cwd);\nexport const DEFAULT_TOKENS_PATH = new URL('./tokens.json', cwd);\n\nexport type Command = 'build' | 'check' | 'help' | 'init' | 'version';\n\nexport const GREEN_CHECK = pc.green('✔');\n\nexport interface Flags {\n /** --config, -c */\n config?: string;\n /** --out, -o */\n out?: string;\n /** --help */\n help?: boolean;\n /** --watch, -w */\n watch?: boolean;\n /** --version */\n version?: boolean;\n}\n\nexport interface LoadConfigOptions {\n cmd: Command;\n flags: Flags;\n logger: Logger;\n}\n\n/** Load config */\nexport async function loadConfig({ cmd, flags, logger }: LoadConfigOptions) {\n try {\n let config: ConfigInit = {\n tokens: [DEFAULT_TOKENS_PATH],\n outDir: new URL('./tokens/', cwd),\n plugins: [],\n lint: { build: { enabled: true }, rules: {} },\n ignore: { tokens: [], deprecated: false },\n };\n let configPath: string | undefined;\n\n if (typeof flags.config === 'string') {\n if (flags.config === '') {\n logger.error({ group: 'config', message: 'Missing path after --config flag' });\n process.exit(1);\n }\n configPath = resolveConfig(flags.config);\n }\n\n const resolvedConfigPath = resolveConfig(configPath);\n if (resolvedConfigPath) {\n try {\n const mod = await import(resolvedConfigPath);\n if (!mod.default) {\n // we format it immediately below\n throw new Error(\n `No default export found in ${path.relative(cwd.href, resolvedConfigPath)}. See https://terrazzo.dev/docs/cli for instructions.`,\n );\n }\n config = defineConfig(mod.default, { cwd, logger });\n } catch (err) {\n logger.error({ group: 'config', message: (err as Error).message || (err as string) });\n }\n } else if (cmd !== 'init' && cmd !== 'check') {\n logger.error({ group: 'config', message: 'No config file found. Create one with `npx terrazzo init`.' });\n }\n\n return { config, configPath: resolvedConfigPath! };\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n\n/** load tokens */\nexport async function loadTokens(tokenPaths: URL[], { logger }: { logger: Logger }) {\n try {\n const allTokens = [];\n\n if (!Array.isArray(tokenPaths)) {\n logger.error({ group: 'config', message: `loadTokens: Expected array, received ${typeof tokenPaths}` });\n }\n\n // if this is the default value, also check for tokens.yaml\n if (tokenPaths.length === 1 && tokenPaths[0]!.href === DEFAULT_TOKENS_PATH.href) {\n if (!fs.existsSync(tokenPaths[0]!)) {\n const yamlPath = new URL('./tokens.yaml', cwd);\n if (fs.existsSync(yamlPath)) {\n tokenPaths[0] = yamlPath;\n } else {\n logger.error({\n group: 'config',\n message: `Could not locate ${path.relative(cwd.href, tokenPaths[0]!.href)}. To create one, run \\`npx tz init\\`.`,\n });\n return;\n }\n }\n }\n\n // download/read\n for (let i = 0; i < tokenPaths.length; i++) {\n const filename = tokenPaths[i];\n\n if (!(filename instanceof URL)) {\n logger.error({ group: 'config', message: `Expected URL, received ${filename}`, label: `loadTokens[${i}]` });\n return;\n } else if (filename.protocol === 'http:' || filename.protocol === 'https:') {\n try {\n // if Figma URL\n if (filename.host === 'figma.com' || filename.host === 'www.figma.com') {\n const [_, fileKeyword, fileKey] = filename.pathname.split('/');\n if (fileKeyword !== 'file' || !fileKey) {\n logger.error({\n group: 'config',\n message: `Unexpected Figma URL. Expected \"https://www.figma.com/file/:file_key/:file_name?…\", received \"${filename.href}\"`,\n });\n }\n const headers = new Headers({\n Accept: '*/*',\n 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0',\n });\n if (process.env.FIGMA_ACCESS_TOKEN) {\n headers.set('X-FIGMA-TOKEN', process.env.FIGMA_ACCESS_TOKEN);\n } else {\n logger.warn({ group: 'config', message: 'FIGMA_ACCESS_TOKEN not set' });\n }\n const res = await fetch(`https://api.figma.com/v1/files/${fileKey}/variables/local`, {\n method: 'GET',\n headers,\n });\n if (res.ok) {\n allTokens.push({ filename, src: await res.text() });\n }\n const message = res.status !== 404 ? JSON.stringify(await res.json(), undefined, 2) : '';\n logger.error({\n group: 'config',\n message: `Figma responded with ${res.status}${message ? `:\\n${message}` : ''}`,\n });\n break;\n }\n\n // otherwise, expect YAML/JSON\n const res = await fetch(filename, {\n method: 'GET',\n headers: { Accept: '*/*', 'User-Agent': 'Mozilla/5.0 Gecko/20100101 Firefox/123.0' },\n });\n allTokens.push({ filename, src: await res.text() });\n } catch (err) {\n logger.error({ group: 'config', message: `${filename.href}: ${err}` });\n return;\n }\n } else {\n if (fs.existsSync(filename)) {\n allTokens.push({ filename, src: fs.readFileSync(filename, 'utf8') });\n } else {\n logger.error({\n group: 'config',\n message: `Could not locate ${path.relative(cwd.href, filename.href)}. To create one, run \\`npx tz init\\`.`,\n });\n return;\n }\n }\n }\n\n return allTokens;\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n\n/** Print error */\nexport function printError(message: string) {\n console.error(pc.red(`✗ ${message}`));\n}\n\n/** Print success */\nexport function printSuccess(message: string, startTime?: number) {\n console.log(`${GREEN_CHECK} ${message}${startTime ? ` ${time(startTime)}` : ''}`);\n}\n\n/** Resolve config */\nexport function resolveConfig(filename?: string) {\n // --config [configpath]\n if (filename) {\n const configPath = new URL(filename, cwd);\n if (fs.existsSync(configPath)) {\n return configPath.href; // ⚠️ ESM wants \"file://...\" URLs on Windows & Unix.\n }\n return undefined;\n }\n\n // note: the order isn’t significant; just try for most-common first.\n // if a user has multiple files differing only by file extension, behavior is\n // unpredictable and that’s on them.\n return ['.js', '.mjs', '.cjs']\n .map((ext) => new URL(`./terrazzo.config${ext}`, cwd))\n .find((configPath) => fs.existsSync(configPath))?.href; // ⚠️ ESM wants \"file://...\" URLs on Windows & Unix.;\n}\n\n/** Resolve tokens.json path (for lint command) */\nexport function resolveTokenPath(filename: string, { logger }: { logger: Logger }) {\n const tokensPath = new URL(filename, cwd);\n if (!fs.existsSync(tokensPath)) {\n logger.error({ group: 'config', message: `Could not locate ${filename}. Does the file exist?` });\n } else if (!fs.statSync(tokensPath).isFile()) {\n logger.error({ group: 'config', message: `Expected JSON or YAML file, received ${filename}.` });\n }\n return tokensPath;\n}\n\n/** Print time elapsed */\nexport function time(start: number) {\n const diff = performance.now() - start;\n return pc.dim(diff < 750 ? `${Math.round(diff)}ms` : `${(diff / 1000).toFixed(1)}s`);\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { type BuildRunnerResult, build, type ConfigInit, type Logger, parse } from '@terrazzo/parser';\nimport chokidar from 'chokidar';\nimport pc from 'picocolors';\nimport yamlToMomoa from 'yaml-to-momoa';\nimport {\n cwd,\n DEFAULT_TOKENS_PATH,\n type Flags,\n GREEN_CHECK,\n loadTokens,\n printError,\n printSuccess,\n resolveConfig,\n} from './shared.js';\n\nexport interface BuildOptions {\n flags: Flags;\n config: ConfigInit;\n configPath: string;\n logger: Logger;\n}\n\n/** tz build */\nexport async function buildCmd({ config, configPath, flags, logger }: BuildOptions) {\n try {\n const startTime = performance.now();\n if (!Array.isArray(config.plugins) || !config.plugins.length) {\n logger.error({\n group: 'config',\n message: `No plugins defined! Add some in ${configPath || 'terrazzo.config.js'}`,\n });\n }\n\n // first build\n let rawSchemas = await loadTokens(config.tokens, { logger });\n if (!rawSchemas) {\n logger.error({\n group: 'config',\n message: `Error loading ${path.relative(fileURLToPath(cwd), fileURLToPath(config.tokens[0] || DEFAULT_TOKENS_PATH))}`,\n });\n return;\n }\n let { tokens, sources } = await parse(rawSchemas, { config, logger, yamlToMomoa });\n let result = await build(tokens, { sources, config, logger });\n writeFiles(result, { config, logger });\n\n // --watch (handle rebuild)\n if (flags.watch) {\n const dt = new Intl.DateTimeFormat('en-us', {\n hour: '2-digit',\n minute: '2-digit',\n });\n\n async function rebuild({ messageBefore, messageAfter }: { messageBefore?: string; messageAfter?: string } = {}) {\n try {\n if (messageBefore) {\n logger.info({ group: 'plugin', label: 'watch', message: messageBefore });\n }\n rawSchemas = await loadTokens(config.tokens, { logger });\n if (!rawSchemas) {\n throw new Error(\n `Error loading ${path.relative(fileURLToPath(cwd), fileURLToPath(config.tokens[0] || DEFAULT_TOKENS_PATH))}`,\n );\n }\n const parseResult = await parse(rawSchemas, { config, logger, yamlToMomoa });\n tokens = parseResult.tokens;\n sources = parseResult.sources;\n result = await build(tokens, { sources, config, logger });\n if (messageAfter) {\n logger.info({ group: 'plugin', label: 'watch', message: messageAfter });\n }\n writeFiles(result, { config, logger });\n } catch (err) {\n console.error(pc.red(`✗ ${(err as Error).message || (err as string)}`));\n // don’t exit! we’re watching, so continue as long as possible\n }\n }\n\n const tokenWatcher = chokidar.watch(config.tokens.map((filename) => fileURLToPath(filename)));\n tokenWatcher.on('change', async (filename) => {\n await rebuild({\n messageBefore: `${pc.dim(dt.format(new Date()))} ${pc.green('tz')}} ${pc.yellow(filename)} updated ${GREEN_CHECK}`,\n });\n });\n const configWatcher = chokidar.watch(resolveConfig(configPath)!);\n configWatcher.on('change', async () => {\n await rebuild({\n messageBefore: `${pc.dim(dt.format(new Date()))} ${pc.green('tz')} ${pc.yellow('Config updated. Reloading…')}`,\n });\n });\n\n // keep process occupied\n await new Promise(() => {});\n } else {\n printSuccess(\n `${Object.keys(tokens).length} token${Object.keys(tokens).length !== 1 ? 's' : ''} built`,\n startTime,\n );\n }\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n\n/** Write files */\nexport function writeFiles(result: BuildRunnerResult, { config, logger }: { config: ConfigInit; logger: Logger }) {\n for (const { filename, contents } of result.outputFiles) {\n const output = new URL(filename, config.outDir);\n fs.mkdirSync(new URL('.', output), { recursive: true });\n fs.writeFileSync(output, contents);\n logger.debug({ group: 'parser', label: 'buildEnd', message: `Wrote file ${fileURLToPath(output)}` });\n }\n}\n","import { type ConfigInit, type Logger, parse } from '@terrazzo/parser';\nimport yamlToMomoa from 'yaml-to-momoa';\nimport { loadTokens, printError, printSuccess, resolveTokenPath } from './shared.js';\n\nexport interface CheckOptions {\n /** positional CLI args */\n positionals: string[];\n config: ConfigInit;\n logger: Logger;\n}\n\n/** tz check */\nexport async function checkCmd({ config, logger, positionals }: CheckOptions) {\n try {\n const startTime = performance.now();\n const tokenPaths = positionals.slice(1).length\n ? positionals.slice(1).map((tokenPath) => resolveTokenPath(tokenPath, { logger }))\n : config.tokens;\n const sources = await loadTokens(tokenPaths, { logger });\n if (!sources?.length) {\n logger.error({ group: 'config', message: 'Couldn’t find any tokens. Run `npx tz init` to create some.' });\n return;\n }\n await parse(sources, { config, continueOnError: true, logger, yamlToMomoa }); // will throw if errors\n printSuccess('No errors', startTime);\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n","/** Show help */\nexport function helpCmd() {\n console.log(`tz\n [commands]\n build Build token artifacts from tokens.json\n --watch, -w Watch tokens.json for changes and recompile\n --no-lint Disable linters running on build\n check [path] Check tokens.json for errors and run linters\n lint [path] (alias of check)\n init Create a starter tokens.json file\n lab Manage your tokens with a web interface\n\n [options]\n --help Show this message\n --config, -c Path to config (default: ./terrazzo.config.js)\n --quiet Suppress warnings\n`);\n}\n","import { exec } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { confirm, intro, multiselect, outro, select, spinner } from '@clack/prompts';\nimport type { Logger } from '@terrazzo/parser';\nimport { pluralize } from '@terrazzo/token-tools';\nimport { detect } from 'detect-package-manager';\nimport { generate } from 'escodegen';\nimport { type ESTree, parseModule } from 'meriyah';\nimport { cwd, DEFAULT_CONFIG_PATH, DEFAULT_TOKENS_PATH, loadConfig, printError } from './shared.js';\n\nconst INSTALL_COMMAND = {\n npm: 'install -D --silent',\n yarn: 'add -D --silent',\n pnpm: 'add -D --silent',\n bun: 'install -D --silent',\n};\n\n// Local copy of dtcg-examples/index.json. Copied partially for security (no\n// arbitrary injection of URL fetches), but also efficiency (saves a\n// round-trip).\ntype DesignSystem =\n | 'adobe-spectrum'\n | 'apple-hig'\n | 'figma-sds'\n | 'github-primer'\n | 'ibm-carbon'\n | 'microsoft-fluent'\n | 'radix'\n | 'salesforce-lightning'\n | 'shopify-polaris';\n\nconst DTCG_ROOT_URL = 'https://raw.githubusercontent.com/terrazzoapp/dtcg-examples/refs/heads/main/';\nconst DESIGN_SYSTEMS: Record<DesignSystem, { name: string; author: string; tokens: string[] }> = {\n 'adobe-spectrum': {\n name: 'Spectrum',\n author: 'Adobe',\n tokens: ['adobe-spectrum.json'],\n },\n 'apple-hig': {\n name: 'Human Interface Guidelines',\n author: 'Apple',\n tokens: ['apple-hig.json'],\n },\n 'figma-sds': {\n name: 'Simple Design System',\n author: 'Figma',\n tokens: ['figma-sds.json'],\n },\n 'github-primer': {\n name: 'Primer',\n author: 'GitHub',\n tokens: ['github-primer.json'],\n },\n 'ibm-carbon': {\n name: 'Carbon',\n author: 'IBM',\n tokens: ['ibm-carbon.json'],\n },\n 'microsoft-fluent': {\n name: 'Fluent',\n author: 'Microsoft',\n tokens: ['microsoft-fluent.json'],\n },\n radix: {\n name: 'Radix',\n author: 'Radix',\n tokens: ['radix.json'],\n },\n 'salesforce-lightning': {\n name: 'Lightning',\n author: 'Salesforce',\n tokens: ['salesforce-lightning.json'],\n },\n 'shopify-polaris': {\n name: 'Polaris',\n author: 'Shopify',\n tokens: ['shopify-polaris.json'],\n },\n};\n\nexport interface InitOptions {\n logger: Logger;\n}\n\nexport async function initCmd({ logger }: InitOptions) {\n try {\n intro('⛋ Welcome to Terrazzo');\n const packageManager = await detect({ cwd: fileURLToPath(cwd) });\n\n // TODO: pass in CLI flags?\n const { config, configPath } = await loadConfig({ cmd: 'init', flags: {}, logger });\n const relConfigPath = configPath\n ? path.relative(fileURLToPath(cwd), fileURLToPath(new URL(configPath)))\n : undefined;\n\n let tokensPath = config.tokens[0]!;\n let startFromDS = !(tokensPath && fs.existsSync(tokensPath));\n\n // 1. tokens\n if (tokensPath && fs.existsSync(tokensPath)) {\n if (\n await confirm({\n message: `Found tokens at ${path.relative(fileURLToPath(cwd), fileURLToPath(tokensPath))}. Overwrite with a new design system?`,\n })\n ) {\n startFromDS = true;\n }\n } else {\n tokensPath = DEFAULT_TOKENS_PATH;\n }\n\n if (startFromDS) {\n const ds = DESIGN_SYSTEMS[\n (await select({\n message: 'Start from existing design system?',\n options: [\n ...Object.entries(DESIGN_SYSTEMS).map(([id, { author, name }]) => ({\n value: id,\n label: `${author} ${name}`,\n })),\n { value: 'none', label: 'None' },\n ],\n })) as keyof typeof DESIGN_SYSTEMS\n ] as (typeof DESIGN_SYSTEMS)[DesignSystem] | undefined;\n if (ds) {\n // TODO: support multiple tokens files?\n const s = spinner();\n s.start('Downloading');\n const tokenSource = await fetch(new URL(ds.tokens[0]!, DTCG_ROOT_URL)).then((res) => res.text());\n fs.writeFileSync(tokensPath, tokenSource);\n s.stop('Download complete');\n }\n }\n\n // 2. plugins\n const existingPlugins = config.plugins.map((p) => p.name);\n const pluginSelection = await multiselect({\n message: 'Install plugins?',\n options: [\n { value: ['@terrazzo/plugin-css'], label: 'CSS' },\n { value: ['@terrazzo/plugin-js'], label: 'JS + TS' },\n { value: ['@terrazzo/plugin-css', '@terrazzo/plugin-sass'], label: 'Sass' },\n { value: ['@terrazzo/plugin-tailwind'], label: 'Tailwind' },\n { value: ['NONE'], label: 'None' },\n ],\n required: true,\n });\n const newPlugins = Array.isArray(pluginSelection)\n ? Array.from(new Set(pluginSelection.flat().filter((p) => !existingPlugins.includes(p))))\n : [];\n let plugins: { specifier: string; package: string }[] = [];\n const pluginCount = `${newPlugins.length} ${pluralize(newPlugins.length, 'plugin', 'plugins')}`;\n const s = spinner();\n\n if (!(newPlugins.length === 1 && newPlugins[0] === 'NONE')) {\n plugins = newPlugins\n .filter((p) => p !== 'NONE')\n .map((p) => ({ specifier: p.replace('@terrazzo/plugin-', ''), package: p }));\n\n s.start(`Installing ${pluginCount}`);\n // note: thi sis async to show the spinner\n await new Promise((resolve, reject) => {\n const subprocess = exec([packageManager, INSTALL_COMMAND[packageManager], newPlugins.join(' ')].join(' '), {\n cwd,\n });\n subprocess.on('error', reject);\n subprocess.on('exit', resolve);\n });\n }\n s.message('Updating config');\n if (configPath) {\n const ast = parseModule(fs.readFileSync(configPath, 'utf8'));\n const astExport = ast.body.find((node) => node.type === 'ExportDefaultDeclaration');\n\n // 2a. add plugin imports\n // note: this has the potential to duplicate plugins, but we tried our\n // best to filter already, and this may be the user’s fault if they\n // selected to install a plugin already installed. But also, this is\n // easily-fixable, so let’s not waste too much time here (and possibly\n // introduce bugs).\n ast.body.push(\n ...plugins.map(\n (p) =>\n ({\n type: 'ImportDeclaration',\n source: { type: 'Literal', value: p.package },\n specifiers: [{ type: 'ImportDefaultSpecifier', local: { type: 'Identifier', name: p.specifier } }],\n attributes: [],\n }) as ESTree.ImportDeclaration,\n ),\n );\n\n // 2b. add plugins to config.plugins\n if (!astExport) {\n logger.error({ group: 'config', message: `SyntaxError: ${relConfigPath} does not have default export.` });\n return;\n }\n const astConfig = (\n astExport.declaration.type === 'CallExpression'\n ? // export default defineConfig({ ... })\n astExport.declaration.arguments[0]\n : // export default { ... }\n astExport.declaration\n ) as ESTree.ObjectExpression;\n if (astConfig.type !== 'ObjectExpression') {\n logger.error({\n group: 'config',\n message: `Config: expected object default export, received ${astConfig.type}`,\n });\n return;\n }\n const pluginsArray = (\n astConfig.properties.find(\n (property) =>\n property.type === 'Property' && property.key.type === 'Identifier' && property.key.name === 'plugins', // ASTs are so fun 😑\n ) as ESTree.Property\n )?.value as ESTree.ArrayExpression | undefined;\n const pluginsAst = plugins.map(\n (p) =>\n ({\n type: 'CallExpression',\n callee: {\n type: 'Identifier',\n name: p.specifier,\n },\n arguments: [],\n optional: false,\n }) as ESTree.CallExpression,\n );\n if (pluginsArray) {\n pluginsArray.elements.push(...pluginsAst);\n } else {\n astConfig.properties.push({\n type: 'Property',\n key: { type: 'Identifier', name: 'plugins' },\n value: { type: 'ArrayExpression', elements: pluginsAst },\n kind: 'init',\n computed: false,\n method: false,\n shorthand: false,\n });\n }\n\n // 2c. update new file (and we’ll probably format it wrong but hey)\n fs.writeFileSync(\n configPath,\n generate(ast, {\n format: {\n indent: { style: ' ' },\n quotes: 'single',\n semicolons: true,\n },\n }),\n );\n } else {\n // 2a. write new config file (easy)\n fs.writeFileSync(\n DEFAULT_CONFIG_PATH,\n `import { defineConfig } from '@terrazzo/cli';\n${plugins.map((p) => `import ${p.specifier} from '${p.package}';`).join('\\n')}\nexport default defineConfig({\n tokens: ['./tokens.json'],\n plugins: [\n ${plugins.map((p) => `${p.specifier}(),`).join('\\n ')}\n ],\n outDir: './dist/',\n lint: {\n /** @see https://terrazzo.app/docs/cli/lint */\n },\n});`,\n );\n s.stop(`Installed ${pluginCount}`);\n }\n\n outro('⛋ Done! 🎉');\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n","import { createReadStream, createWriteStream, type PathLike } from 'node:fs';\nimport { readdir } from 'node:fs/promises';\nimport { Readable, Writable } from 'node:stream';\nimport { fileURLToPath } from 'node:url';\nimport { serve } from '@hono/node-server';\nimport type { ConfigInit, Logger } from '@terrazzo/parser';\nimport mime from 'mime';\nimport type { Flags } from './shared.js';\n\nexport interface LabBuildOptions {\n flags: Flags;\n config: ConfigInit;\n configPath: string;\n logger: Logger;\n}\n\nexport async function labCmd({ config, logger }: LabBuildOptions) {\n /** TODO: handle multiple files */\n const [tokenFileUrl] = config.tokens;\n\n const staticFiles = new Set();\n const dirEntries = await readdir(fileURLToPath(import.meta.resolve('./lab')), {\n withFileTypes: true,\n recursive: true,\n });\n for (const entry of dirEntries) {\n if (entry.isFile() === false) {\n continue;\n }\n const absolutePath = `${entry.parentPath.replaceAll('\\\\', '/')}/${entry.name}`;\n staticFiles.add(absolutePath.replace(fileURLToPath(import.meta.resolve('./lab')).replaceAll('\\\\', '/'), ''));\n }\n\n const server = serve(\n {\n port: 9000,\n overrideGlobalObjects: false,\n async fetch(request) {\n const url = new URL(request.url);\n const pathname = url.pathname;\n if (pathname === '/') {\n return new Response(\n Readable.toWeb(createReadStream(fileURLToPath(import.meta.resolve('./lab/index.html')))) as ReadableStream,\n {\n headers: {\n 'Content-Type': 'text/html',\n },\n },\n );\n }\n if (pathname === '/api/tokens') {\n if (request.method === 'GET') {\n return new Response(Readable.toWeb(createReadStream(tokenFileUrl as PathLike)) as ReadableStream, {\n headers: {\n 'Content-Type': 'application/json',\n 'Cache-Control': 'no-cache',\n },\n });\n } else if (request.method === 'POST' && request.body) {\n await request.body.pipeTo(Writable.toWeb(createWriteStream(tokenFileUrl as PathLike)));\n return new Response(JSON.stringify({ success: true }), {\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n }\n\n if (staticFiles.has(pathname)) {\n return new Response(\n Readable.toWeb(createReadStream(fileURLToPath(import.meta.resolve(`./lab${pathname}`)))) as ReadableStream,\n {\n headers: { 'Content-Type': mime.getType(pathname) ?? 'application/octet-stream' },\n },\n );\n }\n return new Response('Not found', { status: 404 });\n },\n },\n (info) => {\n logger.info({\n group: 'server',\n message: `Token Lab running at http://${info.address === '::' ? 'localhost' : info.address}:${info.port}`,\n });\n },\n );\n /**\n * The cli entrypoint is going to manually exit the process after labCmd returns.\n */\n await new Promise<void>((resolve, reject) => {\n server.on('close', resolve);\n server.on('error', reject);\n });\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { type MemberNode, type ObjectNode, parse as parseJSON, print, type StringNode } from '@humanwhocodes/momoa';\nimport { defineConfig, getObjMembers, type Logger, parse, traverse } from '@terrazzo/parser';\nimport { isAlias } from '@terrazzo/token-tools';\nimport { cwd, printError } from './shared.js';\n\nexport interface NormalizeOptions {\n logger: Logger;\n output: URL;\n}\n\nfunction findMember(name: string) {\n return function (member: MemberNode) {\n return member.name.type === 'String' && member.name.value === name;\n };\n}\n\nexport async function normalizeCmd(filename: string, { logger, output }: NormalizeOptions) {\n try {\n if (!filename) {\n logger.error({ group: 'config', message: 'Expected input: `tz normalize <tokens.json> -o output.json`' });\n return;\n }\n const sourceLoc = new URL(filename, cwd);\n if (!fs.existsSync(sourceLoc)) {\n logger.error({\n group: 'config',\n message: `Couldn’t find ${path.relative(cwd.href, sourceLoc.href)}. Does it exist?`,\n });\n }\n const sourceData = fs.readFileSync(sourceLoc, 'utf8');\n const document = parseJSON(sourceData);\n const { tokens } = await parse([{ src: sourceData, filename: sourceLoc }], {\n config: defineConfig({}, { cwd }),\n logger,\n });\n\n traverse(document, {\n enter(node, _parent, nodePath) {\n const token = tokens[nodePath.join('.')];\n\n if (!token || token.aliasOf || node.type !== 'Member' || node.value.type !== 'Object') {\n return;\n }\n const $valueI = node.value.members.findIndex(findMember('$value'));\n\n switch (token.$type) {\n case 'color':\n case 'dimension':\n case 'duration': {\n if (node.value.members[$valueI]!.value.type === 'String') {\n const newValueContainer = parseJSON(JSON.stringify({ $value: token.$value })).body as ObjectNode;\n const newValueNode = newValueContainer.members.find(findMember('$value'))!;\n node.value.members[$valueI] = newValueNode;\n\n const { $extensions } = getObjMembers(node.value);\n if ($extensions?.type === 'Object') {\n const { mode } = getObjMembers($extensions);\n if (mode?.type === 'Object') {\n for (let i = 0; i < mode.members.length; i++) {\n const modeName = (mode.members[i]!.name as StringNode).value;\n const modeValue = token.mode[modeName]!;\n if (typeof modeValue === 'string' && isAlias(modeValue)) {\n continue;\n }\n const newModeValueContainer = parseJSON(\n JSON.stringify({ [modeName]: token.mode[modeName]!.$value }),\n ).body as ObjectNode;\n const newModeValueNode = newModeValueContainer.members.find(findMember(modeName))!;\n mode.members[i] = newModeValueNode;\n }\n }\n }\n }\n break;\n }\n }\n },\n });\n\n const outputLoc = new URL(output, cwd);\n fs.mkdirSync(new URL('.', outputLoc), { recursive: true });\n fs.writeFileSync(outputLoc, print(document, { indent: 2 }));\n } catch (err) {\n printError((err as Error).message);\n process.exit(1);\n }\n}\n","import fs from 'node:fs';\n\nexport function versionCmd() {\n const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));\n console.log(version);\n}\n","import { createRequire } from 'node:module';\nimport { pathToFileURL } from 'node:url';\nimport { type Config, type ConfigInit, defineConfig as defineConfigCore } from '@terrazzo/parser';\nimport { cwd } from './shared.js';\n\nexport * from './build.js';\nexport * from './check.js';\nexport * from './help.js';\nexport * from './init.js';\nexport * from './lab.js';\nexport * from './normalize.js';\nexport * from './shared.js';\nexport * from './version.js';\n\nconst require = createRequire(cwd);\n\n// wrap defineConfig from @terrazzo/parser and add Node.js resolution\nexport function defineConfig(config: Config): ConfigInit {\n const normalizedConfig: Config = { ...config }; // note: we only need a shallow copy because we’re only mutating top-level `tokens`\n\n // Resolve tokens from npm modules, if any\n if (typeof normalizedConfig.tokens === 'string' || Array.isArray(normalizedConfig.tokens)) {\n normalizedConfig.tokens = (\n Array.isArray(normalizedConfig.tokens) ? normalizedConfig.tokens : [normalizedConfig.tokens]\n ).map((tokenPath) => {\n if (tokenPath.startsWith('.') || /^(https?|file):\\/\\//i.test(tokenPath)) {\n return tokenPath;\n }\n try {\n return pathToFileURL(require.resolve(tokenPath));\n } catch (err) {\n console.error(err);\n // this will throw an error if Node couldn’t automatically resolve it,\n // which will be true for many token paths. We don’t need to surface\n // that error; it’ll get its own error down the line if it’s a bad path.\n return tokenPath;\n }\n }) as string[];\n }\n\n return defineConfigCore(normalizedConfig, { cwd });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAMA,MAAa,MAAM,IAAI,IAAI,GAAG,cAAc,QAAQ,KAAK,CAAC,CAAC,GAAG;AAC9D,MAAa,sBAAsB,IAAI,IAAI,yBAAyB,IAAI;AACxE,MAAa,sBAAsB,IAAI,IAAI,iBAAiB,IAAI;AAIhE,MAAa,cAAc,GAAG,MAAM,IAAI;;AAsBxC,eAAsB,WAAW,EAAE,KAAK,OAAO,UAA6B;AAC1E,KAAI;EACF,IAAIA,SAAqB;GACvB,QAAQ,CAAC,oBAAoB;GAC7B,QAAQ,IAAI,IAAI,aAAa,IAAI;GACjC,SAAS,EAAE;GACX,MAAM;IAAE,OAAO,EAAE,SAAS,MAAM;IAAE,OAAO,EAAE;IAAE;GAC7C,QAAQ;IAAE,QAAQ,EAAE;IAAE,YAAY;IAAO;GAC1C;EACD,IAAIC;AAEJ,MAAI,OAAO,MAAM,WAAW,UAAU;AACpC,OAAI,MAAM,WAAW,IAAI;AACvB,WAAO,MAAM;KAAE,OAAO;KAAU,SAAS;KAAoC,CAAC;AAC9E,YAAQ,KAAK,EAAE;;AAEjB,gBAAa,cAAc,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