@tokens-studio/tokenscript-schemas 0.0.13 → 0.1.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/README.md +21 -0
- package/bundled/functions/adjust_chroma.json +60 -0
- package/bundled/functions/adjust_hue.json +60 -0
- package/bundled/functions/adjust_lightness.json +60 -0
- package/bundled/functions/adjust_to_contrast.json +67 -0
- package/bundled/functions/alpha_blend.json +31 -0
- package/bundled/functions/alpha_scale.json +27 -0
- package/bundled/functions/analogous.json +32 -0
- package/bundled/functions/apca_contrast.json +27 -0
- package/bundled/functions/are_similar.json +73 -0
- package/bundled/functions/auto_text_color.json +66 -0
- package/bundled/functions/best_contrast.json +28 -0
- package/bundled/functions/chroma.json +54 -0
- package/bundled/functions/clamp_chroma.json +66 -0
- package/bundled/functions/clamp_lightness.json +66 -0
- package/bundled/functions/clamp_to_gamut.json +23 -0
- package/bundled/functions/complement.json +24 -0
- package/bundled/functions/contrast_ratio.json +27 -0
- package/bundled/functions/cooler.json +52 -0
- package/bundled/functions/darken.json +28 -0
- package/bundled/functions/delta_e_2000.json +40 -0
- package/bundled/functions/delta_e_76.json +27 -0
- package/bundled/functions/delta_e_ok.json +27 -0
- package/bundled/functions/desaturate.json +28 -0
- package/bundled/functions/distributed.json +36 -0
- package/bundled/functions/diverging.json +36 -0
- package/bundled/functions/grayscale.json +24 -0
- package/bundled/functions/harmonize.json +65 -0
- package/bundled/functions/hue.json +54 -0
- package/bundled/functions/hue_difference.json +27 -0
- package/bundled/functions/in_gamut.json +27 -0
- package/bundled/functions/interpolate.json +66 -0
- package/bundled/functions/invert.json +1 -1
- package/bundled/functions/is_cool.json +23 -0
- package/bundled/functions/is_dark.json +27 -0
- package/bundled/functions/is_light.json +27 -0
- package/bundled/functions/is_neutral.json +65 -0
- package/bundled/functions/is_warm.json +23 -0
- package/bundled/functions/lighten.json +28 -0
- package/bundled/functions/lightness.json +61 -0
- package/bundled/functions/luminance.json +23 -0
- package/bundled/functions/meets_contrast.json +31 -0
- package/bundled/functions/mix.json +32 -0
- package/bundled/functions/monochromatic.json +28 -0
- package/bundled/functions/muted.json +59 -0
- package/bundled/functions/neutral_variant.json +59 -0
- package/bundled/functions/relative_luminance.json +61 -0
- package/bundled/functions/rotate_hue.json +28 -0
- package/bundled/functions/saturate.json +28 -0
- package/bundled/functions/scale_chroma.json +60 -0
- package/bundled/functions/scale_lightness.json +60 -0
- package/bundled/functions/sepia.json +59 -0
- package/bundled/functions/set_chroma.json +28 -0
- package/bundled/functions/set_hue.json +28 -0
- package/bundled/functions/set_lightness.json +28 -0
- package/bundled/functions/shade_scale.json +28 -0
- package/bundled/functions/split_complement.json +28 -0
- package/bundled/functions/steps.json +32 -0
- package/bundled/functions/tetradic.json +24 -0
- package/bundled/functions/tint_scale.json +36 -0
- package/bundled/functions/to_gamut.json +59 -0
- package/bundled/functions/triadic.json +24 -0
- package/bundled/functions/vibrant.json +59 -0
- package/bundled/functions/warmer.json +52 -0
- package/bundled/functions/wcag_level.json +60 -0
- package/bundled/functions.json +2602 -6
- package/bundled/registry.json +3705 -84
- package/bundled/types/css-color.json +151 -0
- package/bundled/types/hsl-color.json +66 -0
- package/bundled/types/hsv-color.json +57 -0
- package/bundled/types/hwb-color.json +66 -0
- package/bundled/types/lab-color.json +57 -0
- package/bundled/types/lch-color.json +57 -0
- package/bundled/types/okhsl-color.json +57 -0
- package/bundled/types/okhsv-color.json +57 -0
- package/bundled/types/oklab-color.json +87 -0
- package/bundled/types/oklch-color.json +57 -0
- package/bundled/types/p3-color.json +57 -0
- package/bundled/types/p3-linear-color.json +57 -0
- package/bundled/types/rgb-color.json +12 -3
- package/bundled/types/srgb-color.json +77 -0
- package/bundled/types/srgb-linear-color.json +67 -0
- package/bundled/types/xyz-d50-color.json +57 -0
- package/bundled/types/xyz-d65-color.json +77 -0
- package/bundled/types.json +1067 -43
- package/dist/cli/index.cjs +231 -22
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +231 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/src/bundler/index.ts +7 -0
- package/src/bundler/presets/css.ts +21 -0
- package/src/bundler/presets/index.ts +47 -0
- package/src/bundler/presets/types.ts +10 -0
- package/src/bundler/selective-bundler.ts +9 -0
- package/src/bundler/types.ts +1 -0
- package/src/cli/commands/bundle.test.ts +34 -0
- package/src/cli/commands/bundle.ts +37 -11
- package/src/cli/commands/list.ts +36 -4
- package/src/cli/commands/presets.ts +81 -0
- package/src/cli/index.ts +12 -1
- package/src/cli/output-generator.ts +8 -2
- package/src/cli/version-info.ts +93 -0
- package/src/schemas/types/css-color/from-hsl-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-hwb-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-lab-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-lch-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-oklab-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-oklch-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-p3-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-rgb-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-srgb-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-xyz-d50-color.tokenscript +17 -4
- package/src/schemas/types/css-color/from-xyz-d65-color.tokenscript +17 -4
- package/src/schemas/types/css-color/unit.test.ts +216 -0
- package/src/schemas/types/hex-color/unit.test.ts +18 -0
- package/src/schemas/types/hsl-color/hsla-initializer.tokenscript +17 -0
- package/src/schemas/types/hsl-color/initializer.tokenscript +6 -1
- package/src/schemas/types/hsl-color/schema.json +9 -0
- package/src/schemas/types/hsl-color/unit.test.ts +95 -1
- package/src/schemas/types/hsv-color/initializer.tokenscript +6 -1
- package/src/schemas/types/hsv-color/unit.test.ts +44 -0
- package/src/schemas/types/hwb-color/hwba-initializer.tokenscript +17 -0
- package/src/schemas/types/hwb-color/initializer.tokenscript +6 -1
- package/src/schemas/types/hwb-color/schema.json +9 -0
- package/src/schemas/types/hwb-color/unit.test.ts +70 -0
- package/src/schemas/types/lab-color/initializer.tokenscript +6 -1
- package/src/schemas/types/lab-color/unit.test.ts +44 -0
- package/src/schemas/types/lch-color/initializer.tokenscript +6 -1
- package/src/schemas/types/lch-color/unit.test.ts +44 -0
- package/src/schemas/types/okhsl-color/initializer.tokenscript +8 -1
- package/src/schemas/types/okhsl-color/unit.test.ts +37 -0
- package/src/schemas/types/okhsv-color/initializer.tokenscript +8 -1
- package/src/schemas/types/okhsv-color/unit.test.ts +37 -0
- package/src/schemas/types/oklab-color/initializer.tokenscript +6 -1
- package/src/schemas/types/oklab-color/unit.test.ts +58 -0
- package/src/schemas/types/oklch-color/initializer.tokenscript +6 -1
- package/src/schemas/types/oklch-color/unit.test.ts +58 -0
- package/src/schemas/types/p3-color/initializer.tokenscript +6 -1
- package/src/schemas/types/p3-color/unit.test.ts +47 -0
- package/src/schemas/types/rgb-color/initializer.tokenscript +7 -1
- package/src/schemas/types/rgb-color/rgba-initializer.tokenscript +17 -0
- package/src/schemas/types/rgb-color/schema.json +9 -0
- package/src/schemas/types/rgb-color/unit.test.ts +110 -1
- package/src/schemas/types/srgb-color/initializer.tokenscript +6 -1
- package/src/schemas/types/srgb-color/unit.test.ts +89 -0
- package/bundled/types/rgba-color.json +0 -89
package/dist/cli/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import ulog from 'ulog';
|
|
|
4
4
|
import { mkdir, writeFile, readFile, readdir, access } from 'fs/promises';
|
|
5
5
|
import { dirname, join } from 'path';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
import { readFileSync } from 'fs';
|
|
7
9
|
|
|
8
10
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
11
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
@@ -11,6 +13,49 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
11
13
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
14
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
15
|
});
|
|
16
|
+
|
|
17
|
+
// src/bundler/presets/css.ts
|
|
18
|
+
var css = {
|
|
19
|
+
name: "CSS",
|
|
20
|
+
description: "CSS color types",
|
|
21
|
+
types: [
|
|
22
|
+
"hex-color",
|
|
23
|
+
"rgb-color",
|
|
24
|
+
"hsl-color",
|
|
25
|
+
"oklch-color",
|
|
26
|
+
"oklab-color",
|
|
27
|
+
// Converting colors to css strings
|
|
28
|
+
"css-color"
|
|
29
|
+
],
|
|
30
|
+
functions: ["lighten", "darken", "saturate", "desaturate", "mix", "invert"]
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/bundler/presets/index.ts
|
|
34
|
+
var BUNDLE_PRESETS = {
|
|
35
|
+
css
|
|
36
|
+
};
|
|
37
|
+
function expandPresetSchemas(schemas) {
|
|
38
|
+
const expanded = [];
|
|
39
|
+
for (const schema of schemas) {
|
|
40
|
+
if (schema.startsWith("preset:")) {
|
|
41
|
+
const presetName = schema.slice(7);
|
|
42
|
+
const preset = BUNDLE_PRESETS[presetName];
|
|
43
|
+
if (preset) {
|
|
44
|
+
for (const type of preset.types) {
|
|
45
|
+
expanded.push(type === "*" ? "*" : `type:${type}`);
|
|
46
|
+
}
|
|
47
|
+
for (const func of preset.functions) {
|
|
48
|
+
expanded.push(func === "*" ? "*" : `function:${func}`);
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
console.warn(`\u26A0 Unknown preset: ${presetName}`);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
expanded.push(schema);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return expanded;
|
|
58
|
+
}
|
|
14
59
|
async function bundleSchemaFromDirectory(schemaDir, options) {
|
|
15
60
|
const schemaJsonPath = join(schemaDir, "schema.json");
|
|
16
61
|
const schemaContent = await readFile(schemaJsonPath, "utf-8");
|
|
@@ -385,12 +430,15 @@ async function bundleSelectiveSchemas(options) {
|
|
|
385
430
|
});
|
|
386
431
|
}
|
|
387
432
|
}
|
|
433
|
+
const baseCommand = "npx @tokens-studio/tokenscript-schemas bundle";
|
|
434
|
+
const generatedBy = options.cliArgs?.length ? `${baseCommand} ${options.cliArgs.join(" ")}` : void 0;
|
|
388
435
|
return {
|
|
389
436
|
schemas: bundledSchemas,
|
|
390
437
|
metadata: {
|
|
391
438
|
requestedSchemas: options.schemas,
|
|
392
439
|
resolvedDependencies: allSchemas,
|
|
393
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
440
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
441
|
+
generatedBy
|
|
394
442
|
},
|
|
395
443
|
dependencyTree
|
|
396
444
|
};
|
|
@@ -416,16 +464,78 @@ function validateBundleConfig(data) {
|
|
|
416
464
|
output: config.output
|
|
417
465
|
};
|
|
418
466
|
}
|
|
467
|
+
var __filename$1 = fileURLToPath(import.meta.url);
|
|
468
|
+
var __dirname$1 = dirname(__filename$1);
|
|
469
|
+
function getGitSha() {
|
|
470
|
+
try {
|
|
471
|
+
return execSync("git rev-parse --short HEAD", {
|
|
472
|
+
encoding: "utf-8",
|
|
473
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
474
|
+
}).trim();
|
|
475
|
+
} catch {
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function isGitRepo() {
|
|
480
|
+
try {
|
|
481
|
+
execSync("git rev-parse --git-dir", {
|
|
482
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
483
|
+
});
|
|
484
|
+
return true;
|
|
485
|
+
} catch {
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
function getPackageVersion() {
|
|
490
|
+
try {
|
|
491
|
+
const paths = [
|
|
492
|
+
join(__dirname$1, "../../package.json"),
|
|
493
|
+
// From src/cli
|
|
494
|
+
join(__dirname$1, "../../../package.json")
|
|
495
|
+
// From dist/cli
|
|
496
|
+
];
|
|
497
|
+
for (const path of paths) {
|
|
498
|
+
try {
|
|
499
|
+
const pkg = JSON.parse(readFileSync(path, "utf-8"));
|
|
500
|
+
return pkg.version || "unknown";
|
|
501
|
+
} catch {
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return "unknown";
|
|
505
|
+
} catch {
|
|
506
|
+
return "unknown";
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function getVersionInfo() {
|
|
510
|
+
const githubUrl = "https://github.com/tokens-studio/tokenscript-schemas";
|
|
511
|
+
const isLocal = isGitRepo();
|
|
512
|
+
let version;
|
|
513
|
+
if (isLocal) {
|
|
514
|
+
const sha = getGitSha();
|
|
515
|
+
version = sha ? `local-${sha}` : "local";
|
|
516
|
+
} else {
|
|
517
|
+
version = getPackageVersion();
|
|
518
|
+
}
|
|
519
|
+
return {
|
|
520
|
+
version,
|
|
521
|
+
githubUrl,
|
|
522
|
+
isLocal
|
|
523
|
+
};
|
|
524
|
+
}
|
|
419
525
|
|
|
420
526
|
// src/cli/output-generator.ts
|
|
421
527
|
function generateOutput(options) {
|
|
422
528
|
const { schemas, includeHelper = true } = options;
|
|
423
529
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
424
|
-
const
|
|
530
|
+
const versionInfo = getVersionInfo();
|
|
425
531
|
const lines = [];
|
|
426
532
|
lines.push("// Auto-generated by @tokens-studio/tokenscript-schemas");
|
|
533
|
+
lines.push(`// Version: ${versionInfo.version}`);
|
|
534
|
+
lines.push(`// GitHub: ${versionInfo.githubUrl}`);
|
|
535
|
+
if (options.generatedBy) {
|
|
536
|
+
lines.push(`// Command: ${options.generatedBy}`);
|
|
537
|
+
}
|
|
427
538
|
lines.push(`// Generated: ${timestamp}`);
|
|
428
|
-
lines.push(`// Schemas: ${schemaList}`);
|
|
429
539
|
lines.push("");
|
|
430
540
|
lines.push('import { Config } from "@tokens-studio/tokenscript-interpreter";');
|
|
431
541
|
lines.push("");
|
|
@@ -512,36 +622,38 @@ function formatDryRunOutput(schemas, resolvedDependencies) {
|
|
|
512
622
|
return lines.join("\n");
|
|
513
623
|
}
|
|
514
624
|
function findSchemasDir() {
|
|
515
|
-
const
|
|
516
|
-
const
|
|
517
|
-
const
|
|
518
|
-
const
|
|
625
|
+
const __filename2 = fileURLToPath(import.meta.url);
|
|
626
|
+
const __dirname2 = dirname(__filename2);
|
|
627
|
+
const fromSource = join(__dirname2, "../../schemas");
|
|
628
|
+
const fromDist = join(__dirname2, "../../../src/schemas");
|
|
519
629
|
try {
|
|
520
630
|
const fs = __require("fs");
|
|
521
|
-
if (fs.existsSync(fromDist)) {
|
|
522
|
-
return fromDist;
|
|
523
|
-
}
|
|
524
631
|
if (fs.existsSync(fromSource)) {
|
|
525
632
|
return fromSource;
|
|
526
633
|
}
|
|
634
|
+
if (fs.existsSync(fromDist)) {
|
|
635
|
+
return fromDist;
|
|
636
|
+
}
|
|
527
637
|
} catch {
|
|
528
638
|
}
|
|
529
|
-
return
|
|
639
|
+
return fromSource;
|
|
530
640
|
}
|
|
531
|
-
async function bundleSchemas(schemas, schemasDir) {
|
|
641
|
+
async function bundleSchemas(schemas, schemasDir, cliArgs) {
|
|
532
642
|
const resolvedSchemasDir = findSchemasDir();
|
|
533
643
|
log2.info("Bundling schemas:", schemas);
|
|
534
644
|
log2.debug("Schemas directory:", resolvedSchemasDir);
|
|
535
645
|
const result = await bundleSelectiveSchemas({
|
|
536
646
|
schemas,
|
|
537
|
-
schemasDir: resolvedSchemasDir
|
|
647
|
+
schemasDir: resolvedSchemasDir,
|
|
648
|
+
cliArgs
|
|
538
649
|
});
|
|
539
650
|
log2.info(
|
|
540
651
|
`Resolved ${result.metadata.resolvedDependencies.length} schemas (including dependencies)`
|
|
541
652
|
);
|
|
542
653
|
const output = generateOutput({
|
|
543
654
|
schemas: result.schemas,
|
|
544
|
-
includeHelper: true
|
|
655
|
+
includeHelper: true,
|
|
656
|
+
generatedBy: result.metadata.generatedBy
|
|
545
657
|
});
|
|
546
658
|
return {
|
|
547
659
|
output,
|
|
@@ -564,7 +676,25 @@ async function handleBundleCommand(schemas, options = {}) {
|
|
|
564
676
|
if (!configSchemas || configSchemas.length === 0) {
|
|
565
677
|
throw new Error("No schemas specified. Provide schemas as arguments or via --config");
|
|
566
678
|
}
|
|
567
|
-
|
|
679
|
+
configSchemas = expandPresetSchemas(configSchemas);
|
|
680
|
+
const cliArgs = [];
|
|
681
|
+
if (schemas.length > 0) {
|
|
682
|
+
cliArgs.push(...schemas);
|
|
683
|
+
}
|
|
684
|
+
if (options.config) {
|
|
685
|
+
cliArgs.push("--config", options.config);
|
|
686
|
+
}
|
|
687
|
+
if (options.output) {
|
|
688
|
+
cliArgs.push("--output", options.output);
|
|
689
|
+
}
|
|
690
|
+
if (options.dryRun) {
|
|
691
|
+
cliArgs.push("--dry-run");
|
|
692
|
+
}
|
|
693
|
+
const { output, metadata, dependencyTree } = await bundleSchemas(
|
|
694
|
+
configSchemas,
|
|
695
|
+
void 0,
|
|
696
|
+
cliArgs
|
|
697
|
+
);
|
|
568
698
|
console.log("");
|
|
569
699
|
console.log(formatDependencyTree(dependencyTree, metadata.requestedSchemas));
|
|
570
700
|
console.log("");
|
|
@@ -584,14 +714,32 @@ async function handleBundleCommand(schemas, options = {}) {
|
|
|
584
714
|
}
|
|
585
715
|
}
|
|
586
716
|
var log3 = ulog("list");
|
|
587
|
-
|
|
717
|
+
function findSchemasDir2() {
|
|
718
|
+
const __filename2 = fileURLToPath(import.meta.url);
|
|
719
|
+
const __dirname2 = dirname(__filename2);
|
|
720
|
+
const fromDist = join(__dirname2, "../../src/schemas");
|
|
721
|
+
const fromSource = join(__dirname2, "../../schemas");
|
|
722
|
+
try {
|
|
723
|
+
const fs = __require("fs");
|
|
724
|
+
if (fs.existsSync(fromDist)) {
|
|
725
|
+
return fromDist;
|
|
726
|
+
}
|
|
727
|
+
if (fs.existsSync(fromSource)) {
|
|
728
|
+
return fromSource;
|
|
729
|
+
}
|
|
730
|
+
} catch {
|
|
731
|
+
}
|
|
732
|
+
return fromDist;
|
|
733
|
+
}
|
|
734
|
+
async function listSchemas(schemasDir, options = {}) {
|
|
735
|
+
const resolvedSchemasDir = findSchemasDir2();
|
|
588
736
|
const showTypes = options.types || !options.types && !options.functions;
|
|
589
737
|
const showFunctions = options.functions || !options.types && !options.functions;
|
|
590
738
|
const types = [];
|
|
591
739
|
const functions = [];
|
|
592
740
|
if (showTypes) {
|
|
593
741
|
try {
|
|
594
|
-
const typesDir = join(
|
|
742
|
+
const typesDir = join(resolvedSchemasDir, "types");
|
|
595
743
|
const typeEntries = await readdir(typesDir, { withFileTypes: true });
|
|
596
744
|
types.push(
|
|
597
745
|
...typeEntries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort()
|
|
@@ -602,7 +750,7 @@ async function listSchemas(schemasDir = join(process.cwd(), "src/schemas"), opti
|
|
|
602
750
|
}
|
|
603
751
|
if (showFunctions) {
|
|
604
752
|
try {
|
|
605
|
-
const functionsDir = join(
|
|
753
|
+
const functionsDir = join(resolvedSchemasDir, "functions");
|
|
606
754
|
const funcEntries = await readdir(functionsDir, { withFileTypes: true });
|
|
607
755
|
functions.push(
|
|
608
756
|
...funcEntries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort()
|
|
@@ -640,15 +788,68 @@ async function handleListCommand(options = {}) {
|
|
|
640
788
|
const output = formatListOutput(result, options);
|
|
641
789
|
console.log(output);
|
|
642
790
|
}
|
|
791
|
+
var log4 = ulog("presets");
|
|
792
|
+
function formatPresetInfo() {
|
|
793
|
+
const lines = [];
|
|
794
|
+
lines.push("=".repeat(60));
|
|
795
|
+
lines.push("Available Bundle Presets");
|
|
796
|
+
lines.push("=".repeat(60));
|
|
797
|
+
for (const [key, preset] of Object.entries(BUNDLE_PRESETS)) {
|
|
798
|
+
lines.push("");
|
|
799
|
+
lines.push(`preset:${key}`);
|
|
800
|
+
lines.push(` ${preset.description}`);
|
|
801
|
+
const typesCount = preset.types.length === 1 && preset.types[0] === "*" ? "all" : preset.types.length;
|
|
802
|
+
lines.push("");
|
|
803
|
+
lines.push(` Types (${typesCount}):`);
|
|
804
|
+
if (preset.types.length > 0 && preset.types[0] !== "*") {
|
|
805
|
+
for (const type of preset.types) {
|
|
806
|
+
lines.push(` - ${type}`);
|
|
807
|
+
}
|
|
808
|
+
} else {
|
|
809
|
+
lines.push(` - all`);
|
|
810
|
+
}
|
|
811
|
+
const functionsCount = preset.functions.length === 1 && preset.functions[0] === "*" ? "all" : preset.functions.length;
|
|
812
|
+
lines.push("");
|
|
813
|
+
lines.push(` Functions (${functionsCount}):`);
|
|
814
|
+
if (preset.functions.length > 0 && preset.functions[0] !== "*") {
|
|
815
|
+
for (const func of preset.functions) {
|
|
816
|
+
lines.push(` - ${func}`);
|
|
817
|
+
}
|
|
818
|
+
} else {
|
|
819
|
+
lines.push(` - all`);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
lines.push("");
|
|
823
|
+
lines.push("=".repeat(60));
|
|
824
|
+
lines.push("Usage Examples:");
|
|
825
|
+
lines.push("=".repeat(60));
|
|
826
|
+
lines.push("npx tokenscript-schemas bundle preset:css");
|
|
827
|
+
lines.push("npx tokenscript-schemas bundle preset:css type:oklab-color");
|
|
828
|
+
lines.push("npx tokenscript-schemas bundle type:hex-color function:lighten");
|
|
829
|
+
lines.push("");
|
|
830
|
+
lines.push("Note: You can combine multiple presets and specific schemas!");
|
|
831
|
+
return lines.join("\n");
|
|
832
|
+
}
|
|
833
|
+
async function handlePresetsCommand() {
|
|
834
|
+
try {
|
|
835
|
+
log4.info("Listing available presets");
|
|
836
|
+
const output = formatPresetInfo();
|
|
837
|
+
console.log(output);
|
|
838
|
+
log4.info(`Listed ${Object.keys(BUNDLE_PRESETS).length} presets`);
|
|
839
|
+
} catch (error) {
|
|
840
|
+
log4.error("Failed to list presets:", error);
|
|
841
|
+
throw error;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
643
844
|
|
|
644
845
|
// src/cli/index.ts
|
|
645
|
-
var
|
|
846
|
+
var log5 = ulog("cli");
|
|
646
847
|
var cli = cac("tokenscript-schemas");
|
|
647
848
|
cli.command("bundle [...schemas]", "Bundle schemas into a JS file").option("-c, --config <path>", "Path to config file").option("-o, --output <path>", "Output file path", { default: "./tokenscript-schemas.js" }).option("-d, --dry-run", "Preview what would be bundled without writing").action(async (schemas, options) => {
|
|
648
849
|
try {
|
|
649
850
|
await handleBundleCommand(schemas, options);
|
|
650
851
|
} catch (error) {
|
|
651
|
-
|
|
852
|
+
log5.error("Error:", error);
|
|
652
853
|
process.exit(1);
|
|
653
854
|
}
|
|
654
855
|
});
|
|
@@ -656,12 +857,20 @@ cli.command("list", "List available schemas").option("--types", "List only type
|
|
|
656
857
|
try {
|
|
657
858
|
await handleListCommand(options);
|
|
658
859
|
} catch (error) {
|
|
659
|
-
|
|
860
|
+
log5.error("Error:", error);
|
|
861
|
+
process.exit(1);
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
cli.command("presets", "List available bundle presets").action(async () => {
|
|
865
|
+
try {
|
|
866
|
+
await handlePresetsCommand();
|
|
867
|
+
} catch (error) {
|
|
868
|
+
log5.error("Error:", error);
|
|
660
869
|
process.exit(1);
|
|
661
870
|
}
|
|
662
871
|
});
|
|
663
872
|
cli.help();
|
|
664
|
-
cli.version("0.0.
|
|
873
|
+
cli.version("0.0.14");
|
|
665
874
|
cli.parse();
|
|
666
875
|
//# sourceMappingURL=index.js.map
|
|
667
876
|
//# sourceMappingURL=index.js.map
|