@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/dist/cli/index.js CHANGED
@@ -8312,7 +8312,7 @@ function transformImports(content, options) {
8312
8312
  const { aliases } = options;
8313
8313
  let result = content;
8314
8314
  result = result.replace(
8315
- /(from\s+['"])(?:\.\.\/)+types(?:\/([^'"]+))?(['"])/g,
8315
+ /(from\s+['"])\.\.\/\.\.\/types(?:\/([^'"]+))?(['"])/g,
8316
8316
  (_match, prefix, subpath, suffix) => {
8317
8317
  if (subpath) {
8318
8318
  return `${prefix}${aliases.importAlias}${aliases.components}/types/${subpath}${suffix}`;
@@ -8320,6 +8320,18 @@ function transformImports(content, options) {
8320
8320
  return `${prefix}${aliases.importAlias}${aliases.components}/types${suffix}`;
8321
8321
  }
8322
8322
  );
8323
+ result = result.replace(
8324
+ /(from\s+['"])\.\.\/\.\.\/hooks\/(\w+)(['"])/g,
8325
+ `$1${aliases.importAlias}${aliases.hooks}/$2$3`
8326
+ );
8327
+ result = result.replace(
8328
+ /(from\s+['"])\.\.\/\.\.\/utils\/(\w+(?:\/\w+)?)(['"])/g,
8329
+ `$1${aliases.importAlias}${aliases.utils}/$2$3`
8330
+ );
8331
+ result = result.replace(
8332
+ /(from\s+['"])\.\.\/\.\.\/utils(['"])/g,
8333
+ `$1${aliases.importAlias}${aliases.utils}$2`
8334
+ );
8323
8335
  result = result.replace(
8324
8336
  /(from\s+['"])\.\.\/(([A-Z]\w+)(\/[^'"]+)?)(['"])/g,
8325
8337
  (_match, prefix, _fullPath, dirName, subPath, suffix) => {
@@ -8330,18 +8342,6 @@ function transformImports(content, options) {
8330
8342
  return `${prefix}${aliases.importAlias}${aliases.ui}/${kebab}${suffix}`;
8331
8343
  }
8332
8344
  );
8333
- result = result.replace(
8334
- /(from\s+['"])(?:\.\.\/)+hooks\/(\w+)(['"])/g,
8335
- `$1${aliases.importAlias}${aliases.hooks}/$2$3`
8336
- );
8337
- result = result.replace(
8338
- /(from\s+['"])(?:\.\.\/)+utils\/(\w+(?:\/\w+)?)(['"])/g,
8339
- `$1${aliases.importAlias}${aliases.utils}/$2$3`
8340
- );
8341
- result = result.replace(
8342
- /(from\s+['"])(?:\.\.\/)+utils(['"])/g,
8343
- `$1${aliases.importAlias}${aliases.utils}$2`
8344
- );
8345
8345
  return result;
8346
8346
  }
8347
8347
  function normalizeExtensions(content, tsx) {
@@ -8397,16 +8397,17 @@ function writeRegistryItems(tree, options) {
8397
8397
  for (const item of tree.items) {
8398
8398
  const targetBaseDir = getTargetDir(item.type, aliases);
8399
8399
  for (const file of item.files) {
8400
- const fileName = basename(file.path);
8401
8400
  let targetPath;
8402
8401
  if (file.target) {
8403
8402
  targetPath = join(projectDir, file.target);
8404
8403
  } else if (item.type === "registry:ui" || item.type === "registry:component") {
8405
- targetPath = join(projectDir, targetBaseDir, item.name, fileName);
8406
- } else if (item.type === "registry:type") {
8404
+ targetPath = join(projectDir, targetBaseDir, item.name, basename(file.path));
8405
+ } else if (item.type === "registry:hook") {
8406
+ targetPath = join(projectDir, targetBaseDir, item.name, basename(file.path));
8407
+ } else if (file.path.includes("/")) {
8407
8408
  targetPath = join(projectDir, targetBaseDir, file.path);
8408
8409
  } else {
8409
- targetPath = join(projectDir, targetBaseDir, fileName);
8410
+ targetPath = join(projectDir, targetBaseDir, basename(file.path));
8410
8411
  }
8411
8412
  if (existsSync(targetPath) && !shouldOverwrite) {
8412
8413
  if (log) log(` Skipped (exists): ${targetPath}`);
@@ -8708,9 +8709,9 @@ function formatCount(count, singular, plural) {
8708
8709
  }
8709
8710
 
8710
8711
  // src/cli/commands/add.ts
8711
- var VALID_TYPES = ["ui", "hook", "util", "lib", "type", "style"];
8712
+ var VALID_TYPES = ["ui", "hook", "util", "lib", "type"];
8712
8713
  function createAddCommand() {
8713
- const cmd = new 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, lib, 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) => {
8714
+ const cmd = new 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) => {
8714
8715
  const parentOpts = cmdObj.parent?.opts() ?? {};
8715
8716
  const allOpts = {
8716
8717
  ...parentOpts,
@@ -8760,7 +8761,7 @@ ${colors.bold("Available items:")}
8760
8761
  if (!grouped[type]) grouped[type] = [];
8761
8762
  grouped[type].push(item);
8762
8763
  }
8763
- const displayOrder = ["ui", "hook", "util", "lib", "type", "style"];
8764
+ const displayOrder = ["ui", "hook", "util", "lib", "type"];
8764
8765
  for (const type of displayOrder) {
8765
8766
  const typeItems = grouped[type];
8766
8767
  if (!typeItems || typeItems.length === 0) continue;
@@ -14059,7 +14060,7 @@ function analyzeImports(files, knownNpmDeps) {
14059
14060
  importPattern.lastIndex = 0;
14060
14061
  while ((m2 = importPattern.exec(file.content)) !== null) {
14061
14062
  const specifier = m2[1] ?? "";
14062
- const typesPattern = /\.\.\/(?:\.\.\/)?types(?:\/.*)?$/;
14063
+ const typesPattern = /^\.\.\/\.\.\/types(?:\/.*)?$/;
14063
14064
  if (typesPattern.test(specifier)) {
14064
14065
  registryDeps.add("dsai-types");
14065
14066
  continue;
@@ -14079,6 +14080,16 @@ function analyzeImports(files, knownNpmDeps) {
14079
14080
  if (regName) registryDeps.add(regName);
14080
14081
  continue;
14081
14082
  }
14083
+ const siblingUtilPattern = /^\.\.\/([a-z][\w-]*)(?:\/.*)?$/;
14084
+ const siblingUtilMatch = siblingUtilPattern.exec(specifier);
14085
+ if (siblingUtilMatch && siblingUtilMatch[1]) {
14086
+ const siblingDir = siblingUtilMatch[1];
14087
+ const regName = UTIL_SUBPATH_TO_REGISTRY[siblingDir];
14088
+ if (regName) {
14089
+ registryDeps.add(regName);
14090
+ continue;
14091
+ }
14092
+ }
14082
14093
  const compPattern = /^\.\.\/(\.\.\/)?(?:components\/)?([A-Z]\w+)(?:\/.*)?$/;
14083
14094
  const compMatch = compPattern.exec(specifier);
14084
14095
  if (compMatch && compMatch[2]) {
@@ -14222,6 +14233,8 @@ function buildTypesItem(reactSrcDir, log) {
14222
14233
  const files = sourceFiles.map((f) => {
14223
14234
  let content = f.content;
14224
14235
  content = content.replace(/export \{[^}]*\} from ['"]\.\.\/utils\/[^'"]+['"];?\n?/g, "");
14236
+ content = content.replace(/export\s+(?!type)\{[^}]*\}\s+from\s+['"]\.\/[^'"]+['"];?\n?/g, "");
14237
+ content = content.replace(/\/\*\*\s*\n\s*\*\s*@deprecated[^*]*\*\/\s*\n/g, "");
14225
14238
  return {
14226
14239
  path: `types/${f.path}`,
14227
14240
  type: "registry:type",
@@ -14364,9 +14377,135 @@ function createRegistryCommand() {
14364
14377
  }
14365
14378
 
14366
14379
  // src/version.ts
14367
- var version = "0.0.1";
14368
-
14369
- // src/cli/create-program.ts
14380
+ var version = "1.3.0";
14381
+
14382
+ // src/cli/commands/info.ts
14383
+ var registry = {
14384
+ package: "@dsai-io/tools",
14385
+ version,
14386
+ description: "Design System AI Toolkit \u2014 build, validate, and manage design tokens and icons.",
14387
+ documentation: "https://github.com/michelve/dsai",
14388
+ cli: {
14389
+ binary: "dsai",
14390
+ globalOptions: [
14391
+ { flag: "-c, --config <path>", description: "Path to config file" },
14392
+ { flag: "--cwd <dir>", description: "Working directory" },
14393
+ { flag: "--debug", description: "Enable debug mode" },
14394
+ { flag: "-q, --quiet", description: "Quiet mode \u2014 minimal output" },
14395
+ { flag: "--dry-run", description: "Dry run \u2014 don't write files" },
14396
+ { flag: "-v, --version", description: "Show version number" },
14397
+ { flag: "-h, --help", description: "Show help" }
14398
+ ],
14399
+ commands: [
14400
+ {
14401
+ name: "add [items...]",
14402
+ description: "Add DSAi items (components, hooks, utils) to your project",
14403
+ options: ["--all", "--type <type>", "--overwrite", "--dry-run", "--list"]
14404
+ },
14405
+ {
14406
+ name: "tokens build",
14407
+ description: "Build design tokens from source collections",
14408
+ options: ["--platforms <list>", "--watch", "--clean", "--theme <name>", "--list-themes"]
14409
+ },
14410
+ {
14411
+ name: "tokens validate",
14412
+ description: "Validate design token files",
14413
+ options: ["--fix", "--strict"]
14414
+ },
14415
+ {
14416
+ name: "tokens transform",
14417
+ description: "Transform Figma exports to Style Dictionary format",
14418
+ options: ["--dry-run", "--default-mode <mode>", "--ignore-modes <list>"]
14419
+ },
14420
+ {
14421
+ name: "tokens sync",
14422
+ description: "Sync tokens flat file",
14423
+ options: ["--format <format>"]
14424
+ },
14425
+ {
14426
+ name: "tokens postprocess",
14427
+ description: "Post-process CSS theme files",
14428
+ options: []
14429
+ },
14430
+ {
14431
+ name: "tokens snapshots list",
14432
+ description: "List all token collection snapshots",
14433
+ options: []
14434
+ },
14435
+ {
14436
+ name: "tokens snapshots info <id>",
14437
+ description: "Show snapshot details",
14438
+ options: []
14439
+ },
14440
+ {
14441
+ name: "tokens snapshots rollback <id>",
14442
+ description: "Rollback to a snapshot",
14443
+ options: ["--dry-run"]
14444
+ },
14445
+ {
14446
+ name: "icons build",
14447
+ description: "Generate icon components from SVG files",
14448
+ options: ["--format <format>", "--no-optimize", "--dry-run"]
14449
+ },
14450
+ {
14451
+ name: "init",
14452
+ description: "Initialize DSAi configuration with interactive prompts",
14453
+ options: ["--yes", "--template <template>", "--force"]
14454
+ },
14455
+ {
14456
+ name: "config",
14457
+ description: "Display resolved configuration",
14458
+ options: ["--json"]
14459
+ },
14460
+ {
14461
+ name: "registry build",
14462
+ description: "Build component registry JSON from source",
14463
+ options: ["--src <path>", "--out <path>", "--verbose"]
14464
+ },
14465
+ {
14466
+ name: "info",
14467
+ description: "Show tool inventory and capabilities",
14468
+ options: ["--json"]
14469
+ }
14470
+ ]
14471
+ }
14472
+ };
14473
+ function printInfo() {
14474
+ const log = (msg) => {
14475
+ console.log(msg);
14476
+ };
14477
+ log("");
14478
+ log(colors.bold(`${registry.package} v${registry.version}`));
14479
+ log(colors.muted(registry.description));
14480
+ log(colors.muted("\u2500".repeat(60)));
14481
+ log("");
14482
+ log(colors.bold("CLI Commands"));
14483
+ log("");
14484
+ for (const cmd of registry.cli.commands) {
14485
+ const opts = cmd.options.length > 0 ? colors.muted(` [${cmd.options.join(", ")}]`) : "";
14486
+ log(` ${colors.command(`dsai ${cmd.name}`)}${opts}`);
14487
+ log(` ${colors.muted(cmd.description)}`);
14488
+ }
14489
+ log("");
14490
+ log(colors.bold("Global Options"));
14491
+ log("");
14492
+ for (const opt of registry.cli.globalOptions) {
14493
+ log(` ${colors.cyan(opt.flag)} ${colors.muted(opt.description)}`);
14494
+ }
14495
+ log("");
14496
+ log(colors.bold("Documentation"));
14497
+ log(` ${colors.path(registry.documentation)}`);
14498
+ log("");
14499
+ }
14500
+ function createInfoCommand() {
14501
+ return new Command("info").description("Show tool inventory and capabilities").option("--json", "Output as JSON for agent consumption", false).action((options) => {
14502
+ if (options.json) {
14503
+ console.log(JSON.stringify(registry, null, 2));
14504
+ } else {
14505
+ printInfo();
14506
+ }
14507
+ });
14508
+ }
14370
14509
  function createProgram() {
14371
14510
  const program2 = new Command().name("dsai").description(
14372
14511
  `${colors.bold("DSAI Tools")} - Design System AI Toolkit
@@ -14433,6 +14572,7 @@ async function run(args = process.argv) {
14433
14572
  program.addCommand(createInitCommand());
14434
14573
  program.addCommand(createConfigCommand());
14435
14574
  program.addCommand(createRegistryCommand());
14575
+ program.addCommand(createInfoCommand());
14436
14576
  setupErrorHandling(program);
14437
14577
  await program.parseAsync(args);
14438
14578
  }