boardui 0.5.8 → 0.5.10

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 (3) hide show
  1. package/README.md +28 -3
  2. package/dist/index.js +130 -23
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -32,12 +32,19 @@ always-on design rules for AI agents (semantic tokens, type scale,
32
32
  conventions) as a fenced section in `AGENTS.md` plus a Cursor rule at
33
33
  `.cursor/rules/boardui.mdc` — MCP context is on-demand, these are not.
34
34
 
35
+ Tailwind v4 needs something to compile it. When the project already has an
36
+ integration (create-next-app 16.4+ ships `@tailwindcss/turbopack`, Vite
37
+ templates `@tailwindcss/vite`, or a PostCSS config loads `@tailwindcss/postcss`),
38
+ `init` leaves PostCSS alone. Otherwise it installs `@tailwindcss/postcss` and
39
+ prints the `postcss.config.mjs` line. `--postcss` sets PostCSS up regardless.
40
+
35
41
  | Option | Description |
36
42
  | --- | --- |
37
- | `-y, --yes` | Skip confirmation prompts |
43
+ | `-y, --yes` | Skip the confirmation prompt (use it in CI, scripts and coding agents) |
38
44
  | `-o, --overwrite` | Overwrite existing files |
39
45
  | `-d, --dir <dir>` | Target directory (defaults to the project source root) |
40
46
  | `--pro` | Also install dependencies used by BoardUI Pro components |
47
+ | `--postcss` | Set up `@tailwindcss/postcss` even when Tailwind already compiles another way |
41
48
 
42
49
  ### `add [components...]`
43
50
 
@@ -52,7 +59,23 @@ an interactive picker.
52
59
  | `-p, --path <path>` | Custom directory to write files into |
53
60
  | `-d, --dir <dir>` | Target directory (defaults to the project source root) |
54
61
  | `-o, --overwrite` | Overwrite existing files |
55
- | `-y, --yes` | Skip prompts (skips existing files, installs deps) |
62
+ | `-y, --yes` | Skip prompts: keep existing files, install deps (use it in CI, scripts and coding agents) |
63
+
64
+ ### CI, scripts, and coding agents
65
+
66
+ `init` and `add` ask before they install packages or touch files that already
67
+ exist. Without a terminal to answer (CI, a script, a coding agent's shell),
68
+ they stop with exit code 1 and name the flag to use instead of guessing:
69
+
70
+ ```bash
71
+ npx boardui@latest init --yes
72
+ npx boardui@latest add button select --yes
73
+ ```
74
+
75
+ `--yes` accepts the defaults: install the dependencies and keep existing
76
+ files. Add `--overwrite` to replace existing files, and name the components or
77
+ pass `--all` instead of using the interactive picker. A run that has nothing
78
+ to ask (no existing files, every dependency installed) needs no flag.
56
79
 
57
80
  ### `list`
58
81
 
@@ -80,7 +103,9 @@ tagged with `source: "mcp"`.
80
103
 
81
104
  Activates a BoardUI Pro license for this machine and stores the license and
82
105
  Lemon Squeezy instance ID in the operating system's user config directory. If
83
- the key is omitted, the CLI prompts for it.
106
+ the key is omitted, the CLI prompts for it. Without a terminal to type it into,
107
+ `login` stops with exit code 1 instead: pass the key as an argument, or in CI
108
+ skip `login` and set `BOARDUI_LICENSE_KEY`.
84
109
 
85
110
  Use the literal key from the Lemon Squeezy receipt without angle brackets:
86
111
 
package/dist/index.js CHANGED
@@ -161,6 +161,36 @@ function installCommand(pm, packages) {
161
161
  return ["npm", "install", ...packages];
162
162
  }
163
163
  }
164
+ var BUNDLER_TAILWIND = ["@tailwindcss/turbopack", "@tailwindcss/vite", "@tailwindcss/webpack"];
165
+ var POSTCSS_CONFIGS = [
166
+ "postcss.config.mjs",
167
+ "postcss.config.js",
168
+ "postcss.config.cjs",
169
+ "postcss.config.ts",
170
+ "postcss.config.mts",
171
+ "postcss.config.cts",
172
+ ".postcssrc",
173
+ ".postcssrc.json",
174
+ ".postcssrc.js",
175
+ ".postcssrc.cjs",
176
+ ".postcssrc.mjs",
177
+ ".postcssrc.yml",
178
+ ".postcssrc.yaml"
179
+ ];
180
+ function detectTailwindCompiler(cwd, installed) {
181
+ const bundler = BUNDLER_TAILWIND.find((pkg) => installed.has(pkg));
182
+ if (bundler) return bundler;
183
+ for (const name of POSTCSS_CONFIGS) {
184
+ const file = path3.join(cwd, name);
185
+ try {
186
+ if (existsSync2(file) && readFileSync2(file, "utf8").includes("@tailwindcss/postcss")) {
187
+ return "@tailwindcss/postcss";
188
+ }
189
+ } catch {
190
+ }
191
+ }
192
+ return void 0;
193
+ }
164
194
  function parseJsonc(raw) {
165
195
  let out = "";
166
196
  let i = 0;
@@ -239,6 +269,7 @@ function readProject(cwd) {
239
269
  config,
240
270
  packageManager: detectPackageManager(cwd, Boolean(config)),
241
271
  isNextJs: installedDependencies.has("next"),
272
+ tailwindCompiler: detectTailwindCompiler(cwd, installedDependencies),
242
273
  hasAtAlias,
243
274
  usesSrcDir,
244
275
  installedDependencies,
@@ -504,6 +535,14 @@ async function resolveItems(names) {
504
535
  // src/lib/installer.ts
505
536
  var RUNTIME_DEPS = ["react-aria-components", "tailwind-merge", "@remixicon/react"];
506
537
  var DEV_DEPS = ["tailwindcss", "@tailwindcss/postcss"];
538
+ var POSTCSS_PLUGIN = "@tailwindcss/postcss";
539
+ function tailwindDevDeps(project, postcss = false) {
540
+ const withPlugin = postcss || !project.tailwindCompiler;
541
+ return DEV_DEPS.filter((pkg) => withPlugin || pkg !== POSTCSS_PLUGIN);
542
+ }
543
+ function needsPostcssStep(project, postcss = false) {
544
+ return project.tailwindCompiler !== POSTCSS_PLUGIN && (postcss || !project.tailwindCompiler);
545
+ }
507
546
  var PRO_DEPS = ["recharts", "motion", "prism-react-renderer", "@internationalized/date"];
508
547
  var INIT_ITEMS = ["globals", "cx", "use-dismiss-on-outside-press", "rules"];
509
548
  var RULES_ITEM_NAME = "rules";
@@ -741,6 +780,14 @@ async function trackAddSuccess({
741
780
  });
742
781
  }
743
782
 
783
+ // src/lib/terminal.ts
784
+ function canPrompt() {
785
+ return Boolean(process.stdin.isTTY);
786
+ }
787
+ function requireTerminal(message) {
788
+ if (!canPrompt()) throw new Error(message);
789
+ }
790
+
744
791
  // src/commands/add.ts
745
792
  var TYPE_LABEL = {
746
793
  base: "Base components",
@@ -788,6 +835,9 @@ async function add(components, options) {
788
835
  const index = await fetchRegistryIndex();
789
836
  names = index.items.map((item) => item.name);
790
837
  } else if (names.length === 0) {
838
+ requireTerminal(
839
+ "boardui add was given no component names, and the interactive picker needs a terminal.\nName the components (for example `npx boardui add button select`) or pass --all."
840
+ );
791
841
  names = await pickComponents();
792
842
  }
793
843
  if (names.length === 0) {
@@ -810,8 +860,23 @@ async function add(components, options) {
810
860
  const targetRoot = options.path ? path7.resolve(process.cwd(), options.path) : options.dir ? path7.resolve(process.cwd(), options.dir) : sourceRoot(project);
811
861
  const writes = collectWrites(items, targetRoot, project.cwd, project.config);
812
862
  const conflicts = writes.filter((w) => w.exists);
863
+ const wanted = missingDependencies(items, project);
864
+ const missingDev = tailwindDevDeps(project).filter((pkg) => !project.installedDependencies.has(pkg));
865
+ for (const pkg of missingDev) wanted.set(pkg, pkg);
866
+ const asksAboutFiles = conflicts.length > 0 && !options.overwrite && !options.yes;
867
+ const asksToInstall = wanted.size > 0 && !options.yes;
868
+ if (asksAboutFiles || asksToInstall) {
869
+ requireTerminal(
870
+ [
871
+ "boardui add needs answers, and no terminal is attached to give them:",
872
+ ...asksAboutFiles ? [` - ${conflicts.length} file${conflicts.length === 1 ? " already exists" : "s already exist"}: keep or overwrite?`] : [],
873
+ ...asksToInstall ? [` - install ${[...wanted.keys()].join(", ")}?`] : [],
874
+ "Re-run with --yes to keep existing files and install the dependencies. Add --overwrite to replace existing files instead."
875
+ ].join("\n")
876
+ );
877
+ }
813
878
  let overwrite = Boolean(options.overwrite);
814
- if (conflicts.length > 0 && !overwrite && !options.yes) {
879
+ if (asksAboutFiles) {
815
880
  console.log(pc.yellow(`
816
881
  The following files already exist:`));
817
882
  for (const c of conflicts) console.log(` ${c.relPath}`);
@@ -852,13 +917,10 @@ The following files already exist:`));
852
917
  );
853
918
  }
854
919
  }
855
- const wanted = missingDependencies(items, project);
856
- const missingDev = DEV_DEPS.filter((pkg) => !project.installedDependencies.has(pkg));
857
- for (const pkg of missingDev) wanted.set(pkg, pkg);
858
920
  if (wanted.size > 0) {
859
921
  const packages = [...wanted.values()];
860
922
  let install = true;
861
- if (!options.yes) {
923
+ if (asksToInstall) {
862
924
  const { confirmed } = await prompts({
863
925
  type: "confirm",
864
926
  name: "confirmed",
@@ -890,7 +952,7 @@ The following files already exist:`));
890
952
  )
891
953
  );
892
954
  }
893
- if (missingDev.length > 0) {
955
+ if (missingDev.includes(POSTCSS_PLUGIN)) {
894
956
  console.log(
895
957
  `
896
958
  ${pc.bold("Note:")} Tailwind was installed. Make sure a ${pc.cyan("postcss.config.mjs")} loads ${pc.cyan("@tailwindcss/postcss")}, or run ${pc.cyan("npx boardui init")} to set the project up.`
@@ -940,6 +1002,9 @@ async function init(options) {
940
1002
  );
941
1003
  }
942
1004
  if (!options.yes) {
1005
+ requireTerminal(
1006
+ "boardui init asks for confirmation, and no terminal is attached to answer it.\nRe-run with --yes to install the dependencies and write styles/ and utils/ (existing files are kept)."
1007
+ );
943
1008
  const { confirmed } = await prompts2({
944
1009
  type: "confirm",
945
1010
  name: "confirmed",
@@ -953,7 +1018,9 @@ async function init(options) {
953
1018
  }
954
1019
  const runtimeDeps = options.pro ? [...RUNTIME_DEPS, ...PRO_DEPS] : RUNTIME_DEPS;
955
1020
  const missingRuntime = runtimeDeps.filter((pkg) => !project.installedDependencies.has(pkg));
956
- const missingDev = DEV_DEPS.filter((pkg) => !project.installedDependencies.has(pkg));
1021
+ const missingDev = tailwindDevDeps(project, options.postcss).filter(
1022
+ (pkg) => !project.installedDependencies.has(pkg)
1023
+ );
957
1024
  const missing = [...missingRuntime, ...missingDev];
958
1025
  let dependenciesReady = true;
959
1026
  if (missing.length > 0) {
@@ -969,6 +1036,13 @@ async function init(options) {
969
1036
  } else {
970
1037
  console.log(pc2.dim("All required dependencies already installed."));
971
1038
  }
1039
+ if (project.tailwindCompiler && project.tailwindCompiler !== POSTCSS_PLUGIN && !options.postcss) {
1040
+ console.log(
1041
+ pc2.dim(
1042
+ `Tailwind v4 already compiles through ${project.tailwindCompiler}, so PostCSS is left alone (add --postcss to set it up anyway).`
1043
+ )
1044
+ );
1045
+ }
972
1046
  const spinner = ora2("Fetching BoardUI foundations...").start();
973
1047
  let items;
974
1048
  try {
@@ -995,24 +1069,38 @@ async function init(options) {
995
1069
  packageManager: project.packageManager,
996
1070
  pro: Boolean(options.pro)
997
1071
  }) : Promise.resolve();
998
- console.log(`
999
- ${pc2.bold("Almost done \u2014 wire up the styles:")}
1000
-
1001
- 1. Import the BoardUI stylesheet in your root layout (app/layout.tsx):
1072
+ const steps = [
1073
+ `Import the BoardUI stylesheet in your root layout (app/layout.tsx):
1002
1074
 
1003
1075
  ${pc2.cyan(`import "${mappedImport("@/styles/globals.css", project.config)}";`)}
1004
1076
 
1005
1077
  ${pc2.dim(`(replaces the default create-next-app "./globals.css" import;`)}
1006
- ${pc2.dim(`in a shared UI package, import the exported stylesheet in each consuming app)`)}
1078
+ ${pc2.dim(`in a shared UI package, import the exported stylesheet in each consuming app)`)}`,
1079
+ // theme.css builds --font-sans from --font-inter on :root, so the
1080
+ // variable belongs on <html>. Without it the page renders in the system font.
1081
+ project.isNextJs ? `Load Inter in the same layout. The theme reads its typeface from --font-inter:
1007
1082
 
1008
- 2. Make sure PostCSS uses Tailwind v4 (postcss.config.mjs):
1083
+ ${pc2.cyan('import { Inter } from "next/font/google";')}
1084
+ ${pc2.cyan('const inter = Inter({ variable: "--font-inter", subsets: ["latin"], axes: ["opsz"] });')}
1085
+ ${pc2.cyan('<html lang="en" className={`${inter.variable} h-full antialiased`}>')}
1009
1086
 
1010
- ${pc2.cyan(`export default { plugins: { "@tailwindcss/postcss": {} } };`)}
1087
+ ${pc2.dim("(on <html>, in place of create-next-app's Geist fonts; without it, text falls back to the system font)")}` : `Load Inter and set ${pc2.cyan("--font-inter")} to its font family on :root.
1088
+ ${pc2.dim("(the theme reads its typeface from it; without it, text falls back to the system font)")}`,
1089
+ ...needsPostcssStep(project, options.postcss) ? [
1090
+ `Make sure PostCSS uses Tailwind v4 (postcss.config.mjs):
1011
1091
 
1012
- 3. Add components:
1092
+ ${pc2.cyan(`export default { plugins: { "@tailwindcss/postcss": {} } };`)}`
1093
+ ] : [],
1094
+ `Add components:
1013
1095
 
1014
- ${pc2.cyan("npx boardui add button select date-picker")}
1015
- `);
1096
+ ${pc2.cyan("npx boardui add button select date-picker")}`
1097
+ ];
1098
+ console.log(
1099
+ `
1100
+ ${pc2.bold("Almost done \u2014 wire up the styles:")}
1101
+
1102
+ ` + steps.map((step, index) => ` ${index + 1}. ${step}`).join("\n\n") + "\n"
1103
+ );
1016
1104
  await telemetry;
1017
1105
  if (dependenciesReady && isTelemetryEnabled()) {
1018
1106
  console.log(
@@ -1053,6 +1141,9 @@ import prompts3 from "prompts";
1053
1141
  async function login(key) {
1054
1142
  let licenseKey = key?.trim();
1055
1143
  if (!licenseKey) {
1144
+ requireTerminal(
1145
+ "boardui login asks for your license key, and no terminal is attached to type it.\nPass the key as an argument (npx boardui login YOUR_LICENSE_KEY), or in CI skip login and set BOARDUI_LICENSE_KEY."
1146
+ );
1056
1147
  const answer = await prompts3({
1057
1148
  type: "password",
1058
1149
  name: "key",
@@ -1092,6 +1183,13 @@ import { instrument } from "@posthog/mcp";
1092
1183
  import { PostHog } from "posthog-node";
1093
1184
  import { z } from "zod";
1094
1185
 
1186
+ // src/lib/mcp-analytics.ts
1187
+ var HANDSHAKE_EVENTS = /* @__PURE__ */ new Set(["$mcp_initialize", "$mcp_tools_list"]);
1188
+ function dropHandshakeEvents(capture) {
1189
+ if (HANDSHAKE_EVENTS.has(capture.event) && capture.properties.$mcp_is_error !== true) return null;
1190
+ return capture;
1191
+ }
1192
+
1095
1193
  // ../lib/agent/rtl.ts
1096
1194
  var RTL_SETUP_GUIDE = [
1097
1195
  "## RTL Support",
@@ -1371,6 +1469,7 @@ async function mcp() {
1371
1469
  posthog.on("error", () => console.error("[mcp-analytics] PostHog delivery failed."));
1372
1470
  instrument(server, posthog, {
1373
1471
  eventProperties: () => ({ $mcp_transport: "stdio" }),
1472
+ beforeSend: dropHandshakeEvents,
1374
1473
  logger: (message) => {
1375
1474
  if (/warning|failed/i.test(message)) console.error(`[mcp-analytics] ${message}`);
1376
1475
  }
@@ -1648,6 +1747,7 @@ NOT installed \u2014 pro fetch failed for ${proFailure.names.join(", ")}: ${proF
1648
1747
  inputSchema: {
1649
1748
  pro: z.boolean().optional().describe("Also install the deps BoardUI Pro components use \u2014 recharts, motion, ... (default false)."),
1650
1749
  overwrite: z.boolean().optional().describe("Overwrite existing style/util files (default false: skip them)."),
1750
+ postcss: z.boolean().optional().describe("Set up @tailwindcss/postcss even when Tailwind v4 already compiles another way, e.g. create-next-app 16.4+'s @tailwindcss/turbopack (default false: only when nothing compiles Tailwind yet)."),
1651
1751
  projectDir: z.string().optional().describe("Absolute path of the project root; defaults to the server's working directory.")
1652
1752
  },
1653
1753
  annotations: { destructiveHint: false }
@@ -1656,12 +1756,13 @@ NOT installed \u2014 pro fetch failed for ${proFailure.names.join(", ")}: ${proF
1656
1756
  async ({
1657
1757
  pro = false,
1658
1758
  overwrite = false,
1759
+ postcss = false,
1659
1760
  projectDir
1660
1761
  }) => {
1661
1762
  const project = loadProject(projectDir);
1662
1763
  const runtimeDeps = pro ? [...RUNTIME_DEPS, ...PRO_DEPS] : RUNTIME_DEPS;
1663
1764
  const missing = new Map(
1664
- [...runtimeDeps, ...DEV_DEPS].filter((pkg) => !project.installedDependencies.has(pkg)).map((pkg) => [pkg, pkg])
1765
+ [...runtimeDeps, ...tailwindDevDeps(project, postcss)].filter((pkg) => !project.installedDependencies.has(pkg)).map((pkg) => [pkg, pkg])
1665
1766
  );
1666
1767
  const deps = await installMissingDependencies(project, missing);
1667
1768
  const items = await resolveItems(INIT_ITEMS);
@@ -1686,6 +1787,7 @@ NOT installed \u2014 pro fetch failed for ${proFailure.names.join(", ")}: ${proF
1686
1787
  ],
1687
1788
  "",
1688
1789
  formatDependencyOutcome(project, missing, true, deps),
1790
+ ...project.tailwindCompiler && project.tailwindCompiler !== POSTCSS_PLUGIN && !postcss ? [`Tailwind v4 already compiles through ${project.tailwindCompiler}, so PostCSS is left alone (pass postcss: true to set it up anyway).`] : [],
1689
1791
  "",
1690
1792
  ...report.created.map((relPath) => ` created ${relPath}`),
1691
1793
  ...report.overwritten.map((relPath) => ` overwrote ${relPath}`),
@@ -1693,9 +1795,14 @@ NOT installed \u2014 pro fetch failed for ${proFailure.names.join(", ")}: ${proF
1693
1795
  ...rulesLines.length ? ["", ...rulesLines] : [],
1694
1796
  "",
1695
1797
  "Finish the wiring:",
1696
- `1. Import the BoardUI stylesheet in the consuming app's root layout: import "${mappedImport("@/styles/globals.css", project.config)}"; \u2014 replacing the default create-next-app "./globals.css" import.`,
1697
- '2. Make sure PostCSS uses Tailwind v4 (postcss.config.mjs): export default { plugins: { "@tailwindcss/postcss": {} } };',
1698
- '3. Install components with install_components, e.g. ["button", "select", "date-picker"].',
1798
+ ...[
1799
+ `Import the BoardUI stylesheet in the consuming app's root layout: import "${mappedImport("@/styles/globals.css", project.config)}"; \u2014 replacing the default create-next-app "./globals.css" import.`,
1800
+ // theme.css builds --font-sans from --font-inter on :root, so the
1801
+ // variable belongs on <html>; without it the page renders in the system font.
1802
+ project.isNextJs ? 'Load Inter in the same layout, because the theme reads its typeface from --font-inter: import { Inter } from "next/font/google"; const inter = Inter({ variable: "--font-inter", subsets: ["latin"], axes: ["opsz"] }); then put inter.variable on <html> (className={`${inter.variable} h-full antialiased`}) in place of create-next-app\'s Geist fonts. Without it, text falls back to the system font.' : "Load Inter and set --font-inter to its font family on :root. The theme reads its typeface from it; without it, text falls back to the system font.",
1803
+ ...needsPostcssStep(project, postcss) ? ['Make sure PostCSS uses Tailwind v4 (postcss.config.mjs): export default { plugins: { "@tailwindcss/postcss": {} } };'] : [],
1804
+ 'Install components with install_components, e.g. ["button", "select", "date-picker"].'
1805
+ ].map((step, index) => `${index + 1}. ${step}`),
1699
1806
  "",
1700
1807
  mappedDocumentation(RTL_SETUP_GUIDE, project.config),
1701
1808
  ...staleStylesheet ? [
@@ -1967,10 +2074,10 @@ ${pc5.dim("Update any time: npx boardui@latest skill --force")}`
1967
2074
  // src/index.ts
1968
2075
  var program = new Command();
1969
2076
  program.name("boardui").description("Add BoardUI components to your project.").version(CLI_VERSION, "-v, --version");
1970
- program.command("init").description("Set up BoardUI in an existing Next.js project (deps, theme, utils).").option("-y, --yes", "skip confirmation prompts").option("-o, --overwrite", "overwrite existing files").option("-d, --dir <dir>", "target directory (defaults to the project source root)").option("--pro", "also install the deps BoardUI Pro components use (recharts, motion, ...)").action(async (options) => {
2077
+ program.command("init").description("Set up BoardUI in an existing Next.js project (deps, theme, utils).").option("-y, --yes", "skip the confirmation prompt (use it in CI, scripts and coding agents)").option("-o, --overwrite", "overwrite existing files").option("-d, --dir <dir>", "target directory (defaults to the project source root)").option("--pro", "also install the deps BoardUI Pro components use (recharts, motion, ...)").option("--postcss", "set up @tailwindcss/postcss even when Tailwind already compiles another way (e.g. @tailwindcss/turbopack)").action(async (options) => {
1971
2078
  await init(options);
1972
2079
  });
1973
- program.command("add").description("Add components to your project.").argument("[components...]", "component names (run `boardui list` to see them)").option("-a, --all", "add every component in the registry").option("-p, --path <path>", "custom directory to write component files into").option("-d, --dir <dir>", "target directory (defaults to the project source root)").option("-o, --overwrite", "overwrite existing files").option("-y, --yes", "skip prompts (skips existing files, installs deps)").action(async (components, options) => {
2080
+ program.command("add").description("Add components to your project.").argument("[components...]", "component names (run `boardui list` to see them)").option("-a, --all", "add every component in the registry").option("-p, --path <path>", "custom directory to write component files into").option("-d, --dir <dir>", "target directory (defaults to the project source root)").option("-o, --overwrite", "overwrite existing files").option("-y, --yes", "skip prompts: keep existing files, install deps (use it in CI, scripts and coding agents)").action(async (components, options) => {
1974
2081
  await add(components, options);
1975
2082
  });
1976
2083
  program.command("list").description("List all available components.").action(async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boardui",
3
- "version": "0.5.8",
3
+ "version": "0.5.10",
4
4
  "description": "Add BoardUI components to your project.",
5
5
  "license": "MIT",
6
6
  "type": "module",