@dsai-io/tools 1.2.5 → 1.3.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 +4 -0
- package/dist/cli/index.cjs +164 -24
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +164 -24
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +32 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -19
- package/dist/index.js.map +1 -1
- package/package.json +112 -112
package/README.md
CHANGED
package/dist/cli/index.cjs
CHANGED
|
@@ -8340,7 +8340,7 @@ function transformImports(content, options) {
|
|
|
8340
8340
|
const { aliases } = options;
|
|
8341
8341
|
let result = content;
|
|
8342
8342
|
result = result.replace(
|
|
8343
|
-
/(from\s+['"])
|
|
8343
|
+
/(from\s+['"])\.\.\/\.\.\/types(?:\/([^'"]+))?(['"])/g,
|
|
8344
8344
|
(_match, prefix, subpath, suffix) => {
|
|
8345
8345
|
if (subpath) {
|
|
8346
8346
|
return `${prefix}${aliases.importAlias}${aliases.components}/types/${subpath}${suffix}`;
|
|
@@ -8348,6 +8348,18 @@ function transformImports(content, options) {
|
|
|
8348
8348
|
return `${prefix}${aliases.importAlias}${aliases.components}/types${suffix}`;
|
|
8349
8349
|
}
|
|
8350
8350
|
);
|
|
8351
|
+
result = result.replace(
|
|
8352
|
+
/(from\s+['"])\.\.\/\.\.\/hooks\/(\w+)(['"])/g,
|
|
8353
|
+
`$1${aliases.importAlias}${aliases.hooks}/$2$3`
|
|
8354
|
+
);
|
|
8355
|
+
result = result.replace(
|
|
8356
|
+
/(from\s+['"])\.\.\/\.\.\/utils\/(\w+(?:\/\w+)?)(['"])/g,
|
|
8357
|
+
`$1${aliases.importAlias}${aliases.utils}/$2$3`
|
|
8358
|
+
);
|
|
8359
|
+
result = result.replace(
|
|
8360
|
+
/(from\s+['"])\.\.\/\.\.\/utils(['"])/g,
|
|
8361
|
+
`$1${aliases.importAlias}${aliases.utils}$2`
|
|
8362
|
+
);
|
|
8351
8363
|
result = result.replace(
|
|
8352
8364
|
/(from\s+['"])\.\.\/(([A-Z]\w+)(\/[^'"]+)?)(['"])/g,
|
|
8353
8365
|
(_match, prefix, _fullPath, dirName, subPath, suffix) => {
|
|
@@ -8358,18 +8370,6 @@ function transformImports(content, options) {
|
|
|
8358
8370
|
return `${prefix}${aliases.importAlias}${aliases.ui}/${kebab}${suffix}`;
|
|
8359
8371
|
}
|
|
8360
8372
|
);
|
|
8361
|
-
result = result.replace(
|
|
8362
|
-
/(from\s+['"])(?:\.\.\/)+hooks\/(\w+)(['"])/g,
|
|
8363
|
-
`$1${aliases.importAlias}${aliases.hooks}/$2$3`
|
|
8364
|
-
);
|
|
8365
|
-
result = result.replace(
|
|
8366
|
-
/(from\s+['"])(?:\.\.\/)+utils\/(\w+(?:\/\w+)?)(['"])/g,
|
|
8367
|
-
`$1${aliases.importAlias}${aliases.utils}/$2$3`
|
|
8368
|
-
);
|
|
8369
|
-
result = result.replace(
|
|
8370
|
-
/(from\s+['"])(?:\.\.\/)+utils(['"])/g,
|
|
8371
|
-
`$1${aliases.importAlias}${aliases.utils}$2`
|
|
8372
|
-
);
|
|
8373
8373
|
return result;
|
|
8374
8374
|
}
|
|
8375
8375
|
function normalizeExtensions(content, tsx) {
|
|
@@ -8425,16 +8425,17 @@ function writeRegistryItems(tree, options) {
|
|
|
8425
8425
|
for (const item of tree.items) {
|
|
8426
8426
|
const targetBaseDir = getTargetDir(item.type, aliases);
|
|
8427
8427
|
for (const file of item.files) {
|
|
8428
|
-
const fileName = path4.basename(file.path);
|
|
8429
8428
|
let targetPath;
|
|
8430
8429
|
if (file.target) {
|
|
8431
8430
|
targetPath = path4.join(projectDir, file.target);
|
|
8432
8431
|
} else if (item.type === "registry:ui" || item.type === "registry:component") {
|
|
8433
|
-
targetPath = path4.join(projectDir, targetBaseDir, item.name,
|
|
8434
|
-
} else if (item.type === "registry:
|
|
8432
|
+
targetPath = path4.join(projectDir, targetBaseDir, item.name, path4.basename(file.path));
|
|
8433
|
+
} else if (item.type === "registry:hook") {
|
|
8434
|
+
targetPath = path4.join(projectDir, targetBaseDir, item.name, path4.basename(file.path));
|
|
8435
|
+
} else if (file.path.includes("/")) {
|
|
8435
8436
|
targetPath = path4.join(projectDir, targetBaseDir, file.path);
|
|
8436
8437
|
} else {
|
|
8437
|
-
targetPath = path4.join(projectDir, targetBaseDir,
|
|
8438
|
+
targetPath = path4.join(projectDir, targetBaseDir, path4.basename(file.path));
|
|
8438
8439
|
}
|
|
8439
8440
|
if (fs3.existsSync(targetPath) && !shouldOverwrite) {
|
|
8440
8441
|
if (log) log(` Skipped (exists): ${targetPath}`);
|
|
@@ -8736,9 +8737,9 @@ function formatCount(count, singular, plural) {
|
|
|
8736
8737
|
}
|
|
8737
8738
|
|
|
8738
8739
|
// src/cli/commands/add.ts
|
|
8739
|
-
var VALID_TYPES = ["ui", "hook", "util", "lib", "type"
|
|
8740
|
+
var VALID_TYPES = ["ui", "hook", "util", "lib", "type"];
|
|
8740
8741
|
function createAddCommand() {
|
|
8741
|
-
const cmd = new commander.Command("add").description("Add DSAi items (components, hooks, utils) to your project").argument("[items...]", "Item names to add (e.g., button use-focus-trap cn)").option("--all", "Add all items of the specified type (default: ui)", false).option("--type <type>", "Filter by type: ui, hook, util,
|
|
8742
|
+
const cmd = new commander.Command("add").description("Add DSAi items (components, hooks, utils) to your project").argument("[items...]", "Item names to add (e.g., button use-focus-trap cn)").option("--all", "Add all items of the specified type (default: ui)", false).option("--type <type>", "Filter by type: ui, hook, util, type").option("--overwrite", "Overwrite existing files", false).option("--dry-run", "Preview changes without writing files", false).option("--registry <path>", "Path to local registry directory").option("--list", "List all available items", false).action(async (items, opts, cmdObj) => {
|
|
8742
8743
|
const parentOpts = cmdObj.parent?.opts() ?? {};
|
|
8743
8744
|
const allOpts = {
|
|
8744
8745
|
...parentOpts,
|
|
@@ -8788,7 +8789,7 @@ ${colors.bold("Available items:")}
|
|
|
8788
8789
|
if (!grouped[type]) grouped[type] = [];
|
|
8789
8790
|
grouped[type].push(item);
|
|
8790
8791
|
}
|
|
8791
|
-
const displayOrder = ["ui", "hook", "util", "lib", "type"
|
|
8792
|
+
const displayOrder = ["ui", "hook", "util", "lib", "type"];
|
|
8792
8793
|
for (const type of displayOrder) {
|
|
8793
8794
|
const typeItems = grouped[type];
|
|
8794
8795
|
if (!typeItems || typeItems.length === 0) continue;
|
|
@@ -14087,7 +14088,7 @@ function analyzeImports(files, knownNpmDeps) {
|
|
|
14087
14088
|
importPattern.lastIndex = 0;
|
|
14088
14089
|
while ((m2 = importPattern.exec(file.content)) !== null) {
|
|
14089
14090
|
const specifier = m2[1] ?? "";
|
|
14090
|
-
const typesPattern =
|
|
14091
|
+
const typesPattern = /^\.\.\/\.\.\/types(?:\/.*)?$/;
|
|
14091
14092
|
if (typesPattern.test(specifier)) {
|
|
14092
14093
|
registryDeps.add("dsai-types");
|
|
14093
14094
|
continue;
|
|
@@ -14107,6 +14108,16 @@ function analyzeImports(files, knownNpmDeps) {
|
|
|
14107
14108
|
if (regName) registryDeps.add(regName);
|
|
14108
14109
|
continue;
|
|
14109
14110
|
}
|
|
14111
|
+
const siblingUtilPattern = /^\.\.\/([a-z][\w-]*)(?:\/.*)?$/;
|
|
14112
|
+
const siblingUtilMatch = siblingUtilPattern.exec(specifier);
|
|
14113
|
+
if (siblingUtilMatch && siblingUtilMatch[1]) {
|
|
14114
|
+
const siblingDir = siblingUtilMatch[1];
|
|
14115
|
+
const regName = UTIL_SUBPATH_TO_REGISTRY[siblingDir];
|
|
14116
|
+
if (regName) {
|
|
14117
|
+
registryDeps.add(regName);
|
|
14118
|
+
continue;
|
|
14119
|
+
}
|
|
14120
|
+
}
|
|
14110
14121
|
const compPattern = /^\.\.\/(\.\.\/)?(?:components\/)?([A-Z]\w+)(?:\/.*)?$/;
|
|
14111
14122
|
const compMatch = compPattern.exec(specifier);
|
|
14112
14123
|
if (compMatch && compMatch[2]) {
|
|
@@ -14250,6 +14261,8 @@ function buildTypesItem(reactSrcDir, log) {
|
|
|
14250
14261
|
const files = sourceFiles.map((f) => {
|
|
14251
14262
|
let content = f.content;
|
|
14252
14263
|
content = content.replace(/export \{[^}]*\} from ['"]\.\.\/utils\/[^'"]+['"];?\n?/g, "");
|
|
14264
|
+
content = content.replace(/export\s+(?!type)\{[^}]*\}\s+from\s+['"]\.\/[^'"]+['"];?\n?/g, "");
|
|
14265
|
+
content = content.replace(/\/\*\*\s*\n\s*\*\s*@deprecated[^*]*\*\/\s*\n/g, "");
|
|
14253
14266
|
return {
|
|
14254
14267
|
path: `types/${f.path}`,
|
|
14255
14268
|
type: "registry:type",
|
|
@@ -14392,9 +14405,135 @@ function createRegistryCommand() {
|
|
|
14392
14405
|
}
|
|
14393
14406
|
|
|
14394
14407
|
// src/version.ts
|
|
14395
|
-
var version = "
|
|
14396
|
-
|
|
14397
|
-
// src/cli/
|
|
14408
|
+
var version = "1.3.0";
|
|
14409
|
+
|
|
14410
|
+
// src/cli/commands/info.ts
|
|
14411
|
+
var registry = {
|
|
14412
|
+
package: "@dsai-io/tools",
|
|
14413
|
+
version,
|
|
14414
|
+
description: "Design System AI Toolkit \u2014 build, validate, and manage design tokens and icons.",
|
|
14415
|
+
documentation: "https://github.com/michelve/dsai",
|
|
14416
|
+
cli: {
|
|
14417
|
+
binary: "dsai",
|
|
14418
|
+
globalOptions: [
|
|
14419
|
+
{ flag: "-c, --config <path>", description: "Path to config file" },
|
|
14420
|
+
{ flag: "--cwd <dir>", description: "Working directory" },
|
|
14421
|
+
{ flag: "--debug", description: "Enable debug mode" },
|
|
14422
|
+
{ flag: "-q, --quiet", description: "Quiet mode \u2014 minimal output" },
|
|
14423
|
+
{ flag: "--dry-run", description: "Dry run \u2014 don't write files" },
|
|
14424
|
+
{ flag: "-v, --version", description: "Show version number" },
|
|
14425
|
+
{ flag: "-h, --help", description: "Show help" }
|
|
14426
|
+
],
|
|
14427
|
+
commands: [
|
|
14428
|
+
{
|
|
14429
|
+
name: "add [items...]",
|
|
14430
|
+
description: "Add DSAi items (components, hooks, utils) to your project",
|
|
14431
|
+
options: ["--all", "--type <type>", "--overwrite", "--dry-run", "--list"]
|
|
14432
|
+
},
|
|
14433
|
+
{
|
|
14434
|
+
name: "tokens build",
|
|
14435
|
+
description: "Build design tokens from source collections",
|
|
14436
|
+
options: ["--platforms <list>", "--watch", "--clean", "--theme <name>", "--list-themes"]
|
|
14437
|
+
},
|
|
14438
|
+
{
|
|
14439
|
+
name: "tokens validate",
|
|
14440
|
+
description: "Validate design token files",
|
|
14441
|
+
options: ["--fix", "--strict"]
|
|
14442
|
+
},
|
|
14443
|
+
{
|
|
14444
|
+
name: "tokens transform",
|
|
14445
|
+
description: "Transform Figma exports to Style Dictionary format",
|
|
14446
|
+
options: ["--dry-run", "--default-mode <mode>", "--ignore-modes <list>"]
|
|
14447
|
+
},
|
|
14448
|
+
{
|
|
14449
|
+
name: "tokens sync",
|
|
14450
|
+
description: "Sync tokens flat file",
|
|
14451
|
+
options: ["--format <format>"]
|
|
14452
|
+
},
|
|
14453
|
+
{
|
|
14454
|
+
name: "tokens postprocess",
|
|
14455
|
+
description: "Post-process CSS theme files",
|
|
14456
|
+
options: []
|
|
14457
|
+
},
|
|
14458
|
+
{
|
|
14459
|
+
name: "tokens snapshots list",
|
|
14460
|
+
description: "List all token collection snapshots",
|
|
14461
|
+
options: []
|
|
14462
|
+
},
|
|
14463
|
+
{
|
|
14464
|
+
name: "tokens snapshots info <id>",
|
|
14465
|
+
description: "Show snapshot details",
|
|
14466
|
+
options: []
|
|
14467
|
+
},
|
|
14468
|
+
{
|
|
14469
|
+
name: "tokens snapshots rollback <id>",
|
|
14470
|
+
description: "Rollback to a snapshot",
|
|
14471
|
+
options: ["--dry-run"]
|
|
14472
|
+
},
|
|
14473
|
+
{
|
|
14474
|
+
name: "icons build",
|
|
14475
|
+
description: "Generate icon components from SVG files",
|
|
14476
|
+
options: ["--format <format>", "--no-optimize", "--dry-run"]
|
|
14477
|
+
},
|
|
14478
|
+
{
|
|
14479
|
+
name: "init",
|
|
14480
|
+
description: "Initialize DSAi configuration with interactive prompts",
|
|
14481
|
+
options: ["--yes", "--template <template>", "--force"]
|
|
14482
|
+
},
|
|
14483
|
+
{
|
|
14484
|
+
name: "config",
|
|
14485
|
+
description: "Display resolved configuration",
|
|
14486
|
+
options: ["--json"]
|
|
14487
|
+
},
|
|
14488
|
+
{
|
|
14489
|
+
name: "registry build",
|
|
14490
|
+
description: "Build component registry JSON from source",
|
|
14491
|
+
options: ["--src <path>", "--out <path>", "--verbose"]
|
|
14492
|
+
},
|
|
14493
|
+
{
|
|
14494
|
+
name: "info",
|
|
14495
|
+
description: "Show tool inventory and capabilities",
|
|
14496
|
+
options: ["--json"]
|
|
14497
|
+
}
|
|
14498
|
+
]
|
|
14499
|
+
}
|
|
14500
|
+
};
|
|
14501
|
+
function printInfo() {
|
|
14502
|
+
const log = (msg) => {
|
|
14503
|
+
console.log(msg);
|
|
14504
|
+
};
|
|
14505
|
+
log("");
|
|
14506
|
+
log(colors.bold(`${registry.package} v${registry.version}`));
|
|
14507
|
+
log(colors.muted(registry.description));
|
|
14508
|
+
log(colors.muted("\u2500".repeat(60)));
|
|
14509
|
+
log("");
|
|
14510
|
+
log(colors.bold("CLI Commands"));
|
|
14511
|
+
log("");
|
|
14512
|
+
for (const cmd of registry.cli.commands) {
|
|
14513
|
+
const opts = cmd.options.length > 0 ? colors.muted(` [${cmd.options.join(", ")}]`) : "";
|
|
14514
|
+
log(` ${colors.command(`dsai ${cmd.name}`)}${opts}`);
|
|
14515
|
+
log(` ${colors.muted(cmd.description)}`);
|
|
14516
|
+
}
|
|
14517
|
+
log("");
|
|
14518
|
+
log(colors.bold("Global Options"));
|
|
14519
|
+
log("");
|
|
14520
|
+
for (const opt of registry.cli.globalOptions) {
|
|
14521
|
+
log(` ${colors.cyan(opt.flag)} ${colors.muted(opt.description)}`);
|
|
14522
|
+
}
|
|
14523
|
+
log("");
|
|
14524
|
+
log(colors.bold("Documentation"));
|
|
14525
|
+
log(` ${colors.path(registry.documentation)}`);
|
|
14526
|
+
log("");
|
|
14527
|
+
}
|
|
14528
|
+
function createInfoCommand() {
|
|
14529
|
+
return new commander.Command("info").description("Show tool inventory and capabilities").option("--json", "Output as JSON for agent consumption", false).action((options) => {
|
|
14530
|
+
if (options.json) {
|
|
14531
|
+
console.log(JSON.stringify(registry, null, 2));
|
|
14532
|
+
} else {
|
|
14533
|
+
printInfo();
|
|
14534
|
+
}
|
|
14535
|
+
});
|
|
14536
|
+
}
|
|
14398
14537
|
function createProgram() {
|
|
14399
14538
|
const program2 = new commander.Command().name("dsai").description(
|
|
14400
14539
|
`${colors.bold("DSAI Tools")} - Design System AI Toolkit
|
|
@@ -14461,6 +14600,7 @@ async function run(args = process.argv) {
|
|
|
14461
14600
|
program.addCommand(createInitCommand());
|
|
14462
14601
|
program.addCommand(createConfigCommand());
|
|
14463
14602
|
program.addCommand(createRegistryCommand());
|
|
14603
|
+
program.addCommand(createInfoCommand());
|
|
14464
14604
|
setupErrorHandling(program);
|
|
14465
14605
|
await program.parseAsync(args);
|
|
14466
14606
|
}
|