@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.cjs
CHANGED
|
@@ -6,6 +6,8 @@ var ulog = require('ulog');
|
|
|
6
6
|
var promises = require('fs/promises');
|
|
7
7
|
var path = require('path');
|
|
8
8
|
var url = require('url');
|
|
9
|
+
var child_process = require('child_process');
|
|
10
|
+
var fs = require('fs');
|
|
9
11
|
|
|
10
12
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
11
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -19,6 +21,49 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
19
21
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
20
22
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
21
23
|
});
|
|
24
|
+
|
|
25
|
+
// src/bundler/presets/css.ts
|
|
26
|
+
var css = {
|
|
27
|
+
name: "CSS",
|
|
28
|
+
description: "CSS color types",
|
|
29
|
+
types: [
|
|
30
|
+
"hex-color",
|
|
31
|
+
"rgb-color",
|
|
32
|
+
"hsl-color",
|
|
33
|
+
"oklch-color",
|
|
34
|
+
"oklab-color",
|
|
35
|
+
// Converting colors to css strings
|
|
36
|
+
"css-color"
|
|
37
|
+
],
|
|
38
|
+
functions: ["lighten", "darken", "saturate", "desaturate", "mix", "invert"]
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/bundler/presets/index.ts
|
|
42
|
+
var BUNDLE_PRESETS = {
|
|
43
|
+
css
|
|
44
|
+
};
|
|
45
|
+
function expandPresetSchemas(schemas) {
|
|
46
|
+
const expanded = [];
|
|
47
|
+
for (const schema of schemas) {
|
|
48
|
+
if (schema.startsWith("preset:")) {
|
|
49
|
+
const presetName = schema.slice(7);
|
|
50
|
+
const preset = BUNDLE_PRESETS[presetName];
|
|
51
|
+
if (preset) {
|
|
52
|
+
for (const type of preset.types) {
|
|
53
|
+
expanded.push(type === "*" ? "*" : `type:${type}`);
|
|
54
|
+
}
|
|
55
|
+
for (const func of preset.functions) {
|
|
56
|
+
expanded.push(func === "*" ? "*" : `function:${func}`);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
console.warn(`\u26A0 Unknown preset: ${presetName}`);
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
expanded.push(schema);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return expanded;
|
|
66
|
+
}
|
|
22
67
|
async function bundleSchemaFromDirectory(schemaDir, options) {
|
|
23
68
|
const schemaJsonPath = path.join(schemaDir, "schema.json");
|
|
24
69
|
const schemaContent = await promises.readFile(schemaJsonPath, "utf-8");
|
|
@@ -393,12 +438,15 @@ async function bundleSelectiveSchemas(options) {
|
|
|
393
438
|
});
|
|
394
439
|
}
|
|
395
440
|
}
|
|
441
|
+
const baseCommand = "npx @tokens-studio/tokenscript-schemas bundle";
|
|
442
|
+
const generatedBy = options.cliArgs?.length ? `${baseCommand} ${options.cliArgs.join(" ")}` : void 0;
|
|
396
443
|
return {
|
|
397
444
|
schemas: bundledSchemas,
|
|
398
445
|
metadata: {
|
|
399
446
|
requestedSchemas: options.schemas,
|
|
400
447
|
resolvedDependencies: allSchemas,
|
|
401
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
448
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
449
|
+
generatedBy
|
|
402
450
|
},
|
|
403
451
|
dependencyTree
|
|
404
452
|
};
|
|
@@ -424,16 +472,78 @@ function validateBundleConfig(data) {
|
|
|
424
472
|
output: config.output
|
|
425
473
|
};
|
|
426
474
|
}
|
|
475
|
+
var __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
476
|
+
var __dirname$1 = path.dirname(__filename$1);
|
|
477
|
+
function getGitSha() {
|
|
478
|
+
try {
|
|
479
|
+
return child_process.execSync("git rev-parse --short HEAD", {
|
|
480
|
+
encoding: "utf-8",
|
|
481
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
482
|
+
}).trim();
|
|
483
|
+
} catch {
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
function isGitRepo() {
|
|
488
|
+
try {
|
|
489
|
+
child_process.execSync("git rev-parse --git-dir", {
|
|
490
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
491
|
+
});
|
|
492
|
+
return true;
|
|
493
|
+
} catch {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function getPackageVersion() {
|
|
498
|
+
try {
|
|
499
|
+
const paths = [
|
|
500
|
+
path.join(__dirname$1, "../../package.json"),
|
|
501
|
+
// From src/cli
|
|
502
|
+
path.join(__dirname$1, "../../../package.json")
|
|
503
|
+
// From dist/cli
|
|
504
|
+
];
|
|
505
|
+
for (const path of paths) {
|
|
506
|
+
try {
|
|
507
|
+
const pkg = JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
508
|
+
return pkg.version || "unknown";
|
|
509
|
+
} catch {
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return "unknown";
|
|
513
|
+
} catch {
|
|
514
|
+
return "unknown";
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function getVersionInfo() {
|
|
518
|
+
const githubUrl = "https://github.com/tokens-studio/tokenscript-schemas";
|
|
519
|
+
const isLocal = isGitRepo();
|
|
520
|
+
let version;
|
|
521
|
+
if (isLocal) {
|
|
522
|
+
const sha = getGitSha();
|
|
523
|
+
version = sha ? `local-${sha}` : "local";
|
|
524
|
+
} else {
|
|
525
|
+
version = getPackageVersion();
|
|
526
|
+
}
|
|
527
|
+
return {
|
|
528
|
+
version,
|
|
529
|
+
githubUrl,
|
|
530
|
+
isLocal
|
|
531
|
+
};
|
|
532
|
+
}
|
|
427
533
|
|
|
428
534
|
// src/cli/output-generator.ts
|
|
429
535
|
function generateOutput(options) {
|
|
430
536
|
const { schemas, includeHelper = true } = options;
|
|
431
537
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
432
|
-
const
|
|
538
|
+
const versionInfo = getVersionInfo();
|
|
433
539
|
const lines = [];
|
|
434
540
|
lines.push("// Auto-generated by @tokens-studio/tokenscript-schemas");
|
|
541
|
+
lines.push(`// Version: ${versionInfo.version}`);
|
|
542
|
+
lines.push(`// GitHub: ${versionInfo.githubUrl}`);
|
|
543
|
+
if (options.generatedBy) {
|
|
544
|
+
lines.push(`// Command: ${options.generatedBy}`);
|
|
545
|
+
}
|
|
435
546
|
lines.push(`// Generated: ${timestamp}`);
|
|
436
|
-
lines.push(`// Schemas: ${schemaList}`);
|
|
437
547
|
lines.push("");
|
|
438
548
|
lines.push('import { Config } from "@tokens-studio/tokenscript-interpreter";');
|
|
439
549
|
lines.push("");
|
|
@@ -520,36 +630,38 @@ function formatDryRunOutput(schemas, resolvedDependencies) {
|
|
|
520
630
|
return lines.join("\n");
|
|
521
631
|
}
|
|
522
632
|
function findSchemasDir() {
|
|
523
|
-
const
|
|
524
|
-
const
|
|
525
|
-
const
|
|
526
|
-
const
|
|
633
|
+
const __filename2 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
634
|
+
const __dirname2 = path.dirname(__filename2);
|
|
635
|
+
const fromSource = path.join(__dirname2, "../../schemas");
|
|
636
|
+
const fromDist = path.join(__dirname2, "../../../src/schemas");
|
|
527
637
|
try {
|
|
528
638
|
const fs = __require("fs");
|
|
529
|
-
if (fs.existsSync(fromDist)) {
|
|
530
|
-
return fromDist;
|
|
531
|
-
}
|
|
532
639
|
if (fs.existsSync(fromSource)) {
|
|
533
640
|
return fromSource;
|
|
534
641
|
}
|
|
642
|
+
if (fs.existsSync(fromDist)) {
|
|
643
|
+
return fromDist;
|
|
644
|
+
}
|
|
535
645
|
} catch {
|
|
536
646
|
}
|
|
537
|
-
return
|
|
647
|
+
return fromSource;
|
|
538
648
|
}
|
|
539
|
-
async function bundleSchemas(schemas, schemasDir) {
|
|
649
|
+
async function bundleSchemas(schemas, schemasDir, cliArgs) {
|
|
540
650
|
const resolvedSchemasDir = findSchemasDir();
|
|
541
651
|
log2.info("Bundling schemas:", schemas);
|
|
542
652
|
log2.debug("Schemas directory:", resolvedSchemasDir);
|
|
543
653
|
const result = await bundleSelectiveSchemas({
|
|
544
654
|
schemas,
|
|
545
|
-
schemasDir: resolvedSchemasDir
|
|
655
|
+
schemasDir: resolvedSchemasDir,
|
|
656
|
+
cliArgs
|
|
546
657
|
});
|
|
547
658
|
log2.info(
|
|
548
659
|
`Resolved ${result.metadata.resolvedDependencies.length} schemas (including dependencies)`
|
|
549
660
|
);
|
|
550
661
|
const output = generateOutput({
|
|
551
662
|
schemas: result.schemas,
|
|
552
|
-
includeHelper: true
|
|
663
|
+
includeHelper: true,
|
|
664
|
+
generatedBy: result.metadata.generatedBy
|
|
553
665
|
});
|
|
554
666
|
return {
|
|
555
667
|
output,
|
|
@@ -572,7 +684,25 @@ async function handleBundleCommand(schemas, options = {}) {
|
|
|
572
684
|
if (!configSchemas || configSchemas.length === 0) {
|
|
573
685
|
throw new Error("No schemas specified. Provide schemas as arguments or via --config");
|
|
574
686
|
}
|
|
575
|
-
|
|
687
|
+
configSchemas = expandPresetSchemas(configSchemas);
|
|
688
|
+
const cliArgs = [];
|
|
689
|
+
if (schemas.length > 0) {
|
|
690
|
+
cliArgs.push(...schemas);
|
|
691
|
+
}
|
|
692
|
+
if (options.config) {
|
|
693
|
+
cliArgs.push("--config", options.config);
|
|
694
|
+
}
|
|
695
|
+
if (options.output) {
|
|
696
|
+
cliArgs.push("--output", options.output);
|
|
697
|
+
}
|
|
698
|
+
if (options.dryRun) {
|
|
699
|
+
cliArgs.push("--dry-run");
|
|
700
|
+
}
|
|
701
|
+
const { output, metadata, dependencyTree } = await bundleSchemas(
|
|
702
|
+
configSchemas,
|
|
703
|
+
void 0,
|
|
704
|
+
cliArgs
|
|
705
|
+
);
|
|
576
706
|
console.log("");
|
|
577
707
|
console.log(formatDependencyTree(dependencyTree, metadata.requestedSchemas));
|
|
578
708
|
console.log("");
|
|
@@ -592,14 +722,32 @@ async function handleBundleCommand(schemas, options = {}) {
|
|
|
592
722
|
}
|
|
593
723
|
}
|
|
594
724
|
var log3 = ulog__default.default("list");
|
|
595
|
-
|
|
725
|
+
function findSchemasDir2() {
|
|
726
|
+
const __filename2 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
727
|
+
const __dirname2 = path.dirname(__filename2);
|
|
728
|
+
const fromDist = path.join(__dirname2, "../../src/schemas");
|
|
729
|
+
const fromSource = path.join(__dirname2, "../../schemas");
|
|
730
|
+
try {
|
|
731
|
+
const fs = __require("fs");
|
|
732
|
+
if (fs.existsSync(fromDist)) {
|
|
733
|
+
return fromDist;
|
|
734
|
+
}
|
|
735
|
+
if (fs.existsSync(fromSource)) {
|
|
736
|
+
return fromSource;
|
|
737
|
+
}
|
|
738
|
+
} catch {
|
|
739
|
+
}
|
|
740
|
+
return fromDist;
|
|
741
|
+
}
|
|
742
|
+
async function listSchemas(schemasDir, options = {}) {
|
|
743
|
+
const resolvedSchemasDir = findSchemasDir2();
|
|
596
744
|
const showTypes = options.types || !options.types && !options.functions;
|
|
597
745
|
const showFunctions = options.functions || !options.types && !options.functions;
|
|
598
746
|
const types = [];
|
|
599
747
|
const functions = [];
|
|
600
748
|
if (showTypes) {
|
|
601
749
|
try {
|
|
602
|
-
const typesDir = path.join(
|
|
750
|
+
const typesDir = path.join(resolvedSchemasDir, "types");
|
|
603
751
|
const typeEntries = await promises.readdir(typesDir, { withFileTypes: true });
|
|
604
752
|
types.push(
|
|
605
753
|
...typeEntries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort()
|
|
@@ -610,7 +758,7 @@ async function listSchemas(schemasDir = path.join(process.cwd(), "src/schemas"),
|
|
|
610
758
|
}
|
|
611
759
|
if (showFunctions) {
|
|
612
760
|
try {
|
|
613
|
-
const functionsDir = path.join(
|
|
761
|
+
const functionsDir = path.join(resolvedSchemasDir, "functions");
|
|
614
762
|
const funcEntries = await promises.readdir(functionsDir, { withFileTypes: true });
|
|
615
763
|
functions.push(
|
|
616
764
|
...funcEntries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort()
|
|
@@ -648,15 +796,68 @@ async function handleListCommand(options = {}) {
|
|
|
648
796
|
const output = formatListOutput(result, options);
|
|
649
797
|
console.log(output);
|
|
650
798
|
}
|
|
799
|
+
var log4 = ulog__default.default("presets");
|
|
800
|
+
function formatPresetInfo() {
|
|
801
|
+
const lines = [];
|
|
802
|
+
lines.push("=".repeat(60));
|
|
803
|
+
lines.push("Available Bundle Presets");
|
|
804
|
+
lines.push("=".repeat(60));
|
|
805
|
+
for (const [key, preset] of Object.entries(BUNDLE_PRESETS)) {
|
|
806
|
+
lines.push("");
|
|
807
|
+
lines.push(`preset:${key}`);
|
|
808
|
+
lines.push(` ${preset.description}`);
|
|
809
|
+
const typesCount = preset.types.length === 1 && preset.types[0] === "*" ? "all" : preset.types.length;
|
|
810
|
+
lines.push("");
|
|
811
|
+
lines.push(` Types (${typesCount}):`);
|
|
812
|
+
if (preset.types.length > 0 && preset.types[0] !== "*") {
|
|
813
|
+
for (const type of preset.types) {
|
|
814
|
+
lines.push(` - ${type}`);
|
|
815
|
+
}
|
|
816
|
+
} else {
|
|
817
|
+
lines.push(` - all`);
|
|
818
|
+
}
|
|
819
|
+
const functionsCount = preset.functions.length === 1 && preset.functions[0] === "*" ? "all" : preset.functions.length;
|
|
820
|
+
lines.push("");
|
|
821
|
+
lines.push(` Functions (${functionsCount}):`);
|
|
822
|
+
if (preset.functions.length > 0 && preset.functions[0] !== "*") {
|
|
823
|
+
for (const func of preset.functions) {
|
|
824
|
+
lines.push(` - ${func}`);
|
|
825
|
+
}
|
|
826
|
+
} else {
|
|
827
|
+
lines.push(` - all`);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
lines.push("");
|
|
831
|
+
lines.push("=".repeat(60));
|
|
832
|
+
lines.push("Usage Examples:");
|
|
833
|
+
lines.push("=".repeat(60));
|
|
834
|
+
lines.push("npx tokenscript-schemas bundle preset:css");
|
|
835
|
+
lines.push("npx tokenscript-schemas bundle preset:css type:oklab-color");
|
|
836
|
+
lines.push("npx tokenscript-schemas bundle type:hex-color function:lighten");
|
|
837
|
+
lines.push("");
|
|
838
|
+
lines.push("Note: You can combine multiple presets and specific schemas!");
|
|
839
|
+
return lines.join("\n");
|
|
840
|
+
}
|
|
841
|
+
async function handlePresetsCommand() {
|
|
842
|
+
try {
|
|
843
|
+
log4.info("Listing available presets");
|
|
844
|
+
const output = formatPresetInfo();
|
|
845
|
+
console.log(output);
|
|
846
|
+
log4.info(`Listed ${Object.keys(BUNDLE_PRESETS).length} presets`);
|
|
847
|
+
} catch (error) {
|
|
848
|
+
log4.error("Failed to list presets:", error);
|
|
849
|
+
throw error;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
651
852
|
|
|
652
853
|
// src/cli/index.ts
|
|
653
|
-
var
|
|
854
|
+
var log5 = ulog__default.default("cli");
|
|
654
855
|
var cli = cac__default.default("tokenscript-schemas");
|
|
655
856
|
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) => {
|
|
656
857
|
try {
|
|
657
858
|
await handleBundleCommand(schemas, options);
|
|
658
859
|
} catch (error) {
|
|
659
|
-
|
|
860
|
+
log5.error("Error:", error);
|
|
660
861
|
process.exit(1);
|
|
661
862
|
}
|
|
662
863
|
});
|
|
@@ -664,12 +865,20 @@ cli.command("list", "List available schemas").option("--types", "List only type
|
|
|
664
865
|
try {
|
|
665
866
|
await handleListCommand(options);
|
|
666
867
|
} catch (error) {
|
|
667
|
-
|
|
868
|
+
log5.error("Error:", error);
|
|
869
|
+
process.exit(1);
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
cli.command("presets", "List available bundle presets").action(async () => {
|
|
873
|
+
try {
|
|
874
|
+
await handlePresetsCommand();
|
|
875
|
+
} catch (error) {
|
|
876
|
+
log5.error("Error:", error);
|
|
668
877
|
process.exit(1);
|
|
669
878
|
}
|
|
670
879
|
});
|
|
671
880
|
cli.help();
|
|
672
|
-
cli.version("0.0.
|
|
881
|
+
cli.version("0.0.14");
|
|
673
882
|
cli.parse();
|
|
674
883
|
//# sourceMappingURL=index.cjs.map
|
|
675
884
|
//# sourceMappingURL=index.cjs.map
|