@bridge-ds/cli 0.11.0 → 0.11.1

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.
Files changed (2) hide show
  1. package/dist/index.js +46 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2543,7 +2543,8 @@ function defineConfig(input) {
2543
2543
  styleSuffix: input.components.styleSuffix ?? ".module.css",
2544
2544
  reference: input.components.reference,
2545
2545
  index: input.components.index,
2546
- specs: input.components.specs
2546
+ specs: input.components.specs,
2547
+ ...input.components.styles ? { styles: input.components.styles.map(trimSlashes) } : {}
2547
2548
  } : void 0,
2548
2549
  docs: { ...input.docs },
2549
2550
  changesets: pkg ? { dir: trimSlashes(input.changesets?.dir ?? ".changeset"), package: pkg } : void 0,
@@ -2667,6 +2668,7 @@ function loadConfig(source) {
2667
2668
  problems.push('"contrast" must be { "path", "modes"? }');
2668
2669
  const comps = d.components;
2669
2670
  if (comps !== void 0 && (!isObj(comps) || !isStr(comps.dir))) problems.push('"components.dir" must be a non-empty string');
2671
+ if (isObj(comps) && comps.styles !== void 0 && !isStrList(comps.styles)) problems.push('"components.styles" must be a list of globs');
2670
2672
  const cs = d.changeset;
2671
2673
  if (cs !== void 0 && (!isObj(cs) || !isStr(cs.package))) problems.push('"changeset.package" must be a non-empty string');
2672
2674
  const css = d.changesets;
@@ -5099,6 +5101,8 @@ var REPO_MODEL_DEFAULTS = {
5099
5101
  componentSpecs: "packages/react/component-specs.json",
5100
5102
  /** Optional token usage notes (group -> sentence), relative to tokens.root, when tokens.usage is not set. */
5101
5103
  tokensUsage: "usage.json",
5104
+ /** Most global stylesheets read (components.styles): a broad glob never turns into hundreds of reads. */
5105
+ maxStylesheets: 50,
5102
5106
  repo: { owner: "peterbono", repo: "ai-design-system-demo", defaultBranch: "main" }
5103
5107
  };
5104
5108
  function siteRepoFromConfig(config, raw, fallback = REPO_MODEL_DEFAULTS.repo) {
@@ -5120,6 +5124,32 @@ function siteRepoFromConfig(config, raw, fallback = REPO_MODEL_DEFAULTS.repo) {
5120
5124
  changes: config.changes ?? DEFAULT_CHANGES_MODE
5121
5125
  };
5122
5126
  }
5127
+ function styleGlobs(config) {
5128
+ if (config.components?.styles) return [...config.components.styles];
5129
+ const parent = parentDir(config.components?.dir ?? REPO_MODEL_DEFAULTS.componentsDir);
5130
+ const at = (dir) => parent ? `${parent}/${dir}/**/*.css` : `${dir}/**/*.css`;
5131
+ return [at("styles"), at("theme")];
5132
+ }
5133
+ function globBase(glob) {
5134
+ const segs = glob.split("/");
5135
+ const fixed = [];
5136
+ for (const seg of segs.slice(0, -1)) {
5137
+ if (/[*?[{]/.test(seg)) break;
5138
+ fixed.push(seg);
5139
+ }
5140
+ return fixed.join("/");
5141
+ }
5142
+ async function listStylesheets(source, config) {
5143
+ const globs = styleGlobs(config);
5144
+ const matchers = globs.map(globToRegExp);
5145
+ const compDir = config.components?.dir ?? REPO_MODEL_DEFAULTS.componentsDir;
5146
+ const bases = [...new Set(globs.map(globBase))].filter((b, _, all) => !all.some((o) => o !== b && (o === "" || b.startsWith(`${o}/`))));
5147
+ const listed = (await Promise.all(bases.map((b) => source.list(b)))).flat();
5148
+ const paths = [...new Set(listed)].filter((p) => matchers.some((re) => re.test(p)) && !p.startsWith(`${compDir}/`)).sort();
5149
+ const max = REPO_MODEL_DEFAULTS.maxStylesheets;
5150
+ if (paths.length <= max) return { globs, paths, problems: [] };
5151
+ return { globs, paths: paths.slice(0, max), problems: [`components.styles matches ${paths.length} files: Bridge reads the first ${max}. Narrow the globs to the stylesheets the library ships.`] };
5152
+ }
5123
5153
  function withModelDefaults(raw) {
5124
5154
  const tokens2 = raw.tokens && typeof raw.tokens === "object" ? raw.tokens : {};
5125
5155
  return {
@@ -5184,6 +5214,10 @@ async function loadRepoModel(source, options = {}) {
5184
5214
  }
5185
5215
  codeRead.push(indexPath);
5186
5216
  }
5217
+ const listedStyles = await listStylesheets(source, config);
5218
+ problems.push(...listedStyles.problems);
5219
+ const stylePaths = listedStyles.paths;
5220
+ codeRead.push(...stylePaths);
5187
5221
  const seen = /* @__PURE__ */ new Set();
5188
5222
  const fresh = (paths) => paths.filter((p) => {
5189
5223
  if (seen.has(p)) return false;
@@ -5251,6 +5285,11 @@ async function loadRepoModel(source, options = {}) {
5251
5285
  const list2 = scanComponents({ dir: comps.dir, files: compFiles, readText: readMore, indexText, indexRel, docsSuffix: comps.docsSuffix, styleSuffix: comps.styleSuffix, describeVar, problems });
5252
5286
  components = { dir: comps.dir, index: indexText === void 0 ? void 0 : indexPath, families: indexText === void 0 ? [] : parseComponentFamilies(indexText, indexRel), list: list2 };
5253
5287
  }
5288
+ const styleVars = {};
5289
+ for (const p of stylePaths) {
5290
+ const text = readMore(p);
5291
+ if (text !== void 0) styleVars[p] = cssVarsIn(text);
5292
+ }
5254
5293
  const specsText = readMore(specsPath);
5255
5294
  let specsFile = null;
5256
5295
  let coverage = [];
@@ -5274,6 +5313,7 @@ async function loadRepoModel(source, options = {}) {
5274
5313
  tokens: { root, files, rows, usage },
5275
5314
  contrast: { path: contrastPath, specs, pairs: pairs3 },
5276
5315
  components,
5316
+ styles: { globs: listedStyles.globs, vars: styleVars },
5277
5317
  specs: { path: specsPath, file: specsFile, coverage }
5278
5318
  };
5279
5319
  }
@@ -5358,7 +5398,8 @@ function buildSnapshot(input) {
5358
5398
  summary: snapshotSummary(model),
5359
5399
  contrast: { ...model.contrast.path ? { path: model.contrast.path } : {}, pairs: model.contrast.pairs.map(({ fgToken: _fg, bgToken: _bg, ...rest }) => rest) },
5360
5400
  audits: input.audits ?? [],
5361
- problems: [...model.problems]
5401
+ problems: [...model.problems],
5402
+ styles: [...model.styles.globs]
5362
5403
  };
5363
5404
  }
5364
5405
  var SNAPSHOT_LLMS_FILE = "llms.txt";
@@ -7609,7 +7650,8 @@ async function rolesReport(opts) {
7609
7650
  }
7610
7651
 
7611
7652
  // src/index.ts
7612
- import { brand, BridgeContext as BridgeContext8, CONFIG_FILE as CONFIG_FILE2, core, detectConfig, GitRefSource, history as hist, LocalSource, ops, optionsFromArgv, serveStdio, toConfigJson, VERSION } from "@bridge-ds/mcp";
7653
+ import { brand, BridgeContext as BridgeContext8, CONFIG_FILE as CONFIG_FILE2, core, detectConfig, GitRefSource, history as hist, LocalSource, ops, optionsFromArgv, serveStdio, toConfigJson } from "@bridge-ds/mcp";
7654
+ var VERSION = true ? "0.11.1" : "dev";
7613
7655
  var MCP_PACKAGE = "@bridge-ds/mcp";
7614
7656
  var HELP = `bridge ${VERSION}: design system as code, for you and your Claude
7615
7657
 
@@ -8270,11 +8312,11 @@ async function main() {
8270
8312
  if (cmd === "review") return runReview(a, root);
8271
8313
  if (cmd === "products" || cmd === "settings" || cmd === "coverage") return runStudioRead(cmd, a, root);
8272
8314
  if (cmd === "docs" && a._[1] === "save") return runDocsSave(a, root);
8315
+ if (cmd === "version" || !cmd && has7(a, "version")) return print(VERSION), 0;
8273
8316
  if (!cmd || has7(a, "help") || cmd === "help") {
8274
8317
  print(HELP);
8275
8318
  return cmd || has7(a, "help") ? 0 : 2;
8276
8319
  }
8277
- if (cmd === "--version" || cmd === "version") return print(VERSION), 0;
8278
8320
  switch (cmd) {
8279
8321
  case "init":
8280
8322
  await init(a, root);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bridge-ds/cli",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "type": "module",
5
5
  "description": "bridge CLI: set up Bridge in a design system repo, check tokens in CI, search and diff tokens, propose changes, start the MCP server.",
6
6
  "license": "MIT",