boardui 0.2.0 → 0.2.2

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 +16 -0
  2. package/dist/index.js +116 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -27,6 +27,7 @@ writes `styles/theme.css`, `styles/typography.css`, `styles/globals.css`,
27
27
  | `-y, --yes` | Skip confirmation prompts |
28
28
  | `-o, --overwrite` | Overwrite existing files |
29
29
  | `-d, --dir <dir>` | Target directory (defaults to the project source root) |
30
+ | `--pro` | Also install dependencies used by BoardUI Pro components |
30
31
 
31
32
  ### `add [components...]`
32
33
 
@@ -52,6 +53,21 @@ Prints all available components grouped by type.
52
53
  | Variable | Description |
53
54
  | --- | --- |
54
55
  | `BOARDUI_REGISTRY_URL` | Override the registry base URL (default `https://www.boardui.com/r`). Useful for testing against `http://localhost:3000/r`. |
56
+ | `BOARDUI_TELEMETRY_DISABLED=1` | Disable anonymous successful-`init` telemetry. |
57
+ | `DO_NOT_TRACK=1` | Standard opt-out; also disables BoardUI telemetry. |
58
+ | `BOARDUI_TELEMETRY_URL` | Override the telemetry endpoint. Intended for local testing. |
59
+
60
+ ## Anonymous telemetry
61
+
62
+ After a successful `boardui init`, the CLI sends one anonymous event containing
63
+ the CLI version, detected package manager, and whether `--pro` was used. A
64
+ random installation ID is stored in the operating system's user config
65
+ directory so repeat runs can be counted without collecting identity.
66
+
67
+ BoardUI does not send project paths, source code, dependency names, email
68
+ addresses, command arguments, or telemetry for `add` and `list`. Telemetry is
69
+ best-effort and never changes whether `init` succeeds. Disable it with
70
+ `BOARDUI_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.
55
71
 
56
72
  ## Releasing
57
73
 
package/dist/index.js CHANGED
@@ -253,14 +253,29 @@ async function add(components, options) {
253
253
  `Resolved ${items.length} item${items.length === 1 ? "" : "s"}: ${items.map((i) => i.name).join(", ")}`
254
254
  );
255
255
  const targetRoot = options.path ? path2.resolve(process.cwd(), options.path) : options.dir ? path2.resolve(process.cwd(), options.dir) : sourceRoot(project);
256
- const writes = [];
256
+ const writesByPath = /* @__PURE__ */ new Map();
257
257
  for (const item of items) {
258
258
  for (const file of item.files) {
259
259
  const relPath = file.target ?? file.path;
260
260
  const absPath = path2.join(targetRoot, relPath);
261
- writes.push({ absPath, relPath, content: file.content, exists: existsSync2(absPath) });
261
+ const pending = writesByPath.get(absPath);
262
+ if (pending) {
263
+ if (pending.content !== file.content) {
264
+ throw new Error(
265
+ `Registry items resolve to conflicting content for ${relPath}.`
266
+ );
267
+ }
268
+ continue;
269
+ }
270
+ writesByPath.set(absPath, {
271
+ absPath,
272
+ relPath,
273
+ content: file.content,
274
+ exists: existsSync2(absPath)
275
+ });
262
276
  }
263
277
  }
278
+ const writes = [...writesByPath.values()];
264
279
  const conflicts = writes.filter((w) => w.exists);
265
280
  let skipExisting = false;
266
281
  if (conflicts.length > 0 && !options.overwrite) {
@@ -346,11 +361,87 @@ Done. ${written} file${written === 1 ? "" : "s"} written.`));
346
361
  }
347
362
 
348
363
  // src/commands/init.ts
349
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
350
- import path3 from "path";
364
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
365
+ import path4 from "path";
351
366
  import ora2 from "ora";
352
367
  import pc2 from "picocolors";
353
368
  import prompts2 from "prompts";
369
+
370
+ // src/lib/telemetry.ts
371
+ import { randomUUID } from "crypto";
372
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
373
+ import { homedir } from "os";
374
+ import path3 from "path";
375
+
376
+ // src/version.ts
377
+ var CLI_VERSION = "0.2.2";
378
+
379
+ // src/lib/telemetry.ts
380
+ var DEFAULT_TELEMETRY_URL = "https://www.boardui.com/api/cli/telemetry";
381
+ var UUID_V4_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
382
+ function envFlagEnabled(value) {
383
+ return ["1", "true", "yes"].includes(value?.toLowerCase() ?? "");
384
+ }
385
+ function isTelemetryEnabled() {
386
+ return !(envFlagEnabled(process.env.BOARDUI_TELEMETRY_DISABLED) || envFlagEnabled(process.env.DO_NOT_TRACK));
387
+ }
388
+ function configRoot() {
389
+ if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
390
+ if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
391
+ return path3.join(homedir(), ".config");
392
+ }
393
+ function anonymousIdFile() {
394
+ return path3.join(configRoot(), "boardui", "telemetry.json");
395
+ }
396
+ function getAnonymousId() {
397
+ const file = anonymousIdFile();
398
+ try {
399
+ if (existsSync3(file)) {
400
+ const stored = JSON.parse(readFileSync2(file, "utf8"));
401
+ if (typeof stored.anonymousId === "string" && UUID_V4_RE.test(stored.anonymousId)) {
402
+ return stored.anonymousId;
403
+ }
404
+ }
405
+ const anonymousId = randomUUID();
406
+ mkdirSync2(path3.dirname(file), { recursive: true, mode: 448 });
407
+ writeFileSync2(file, `${JSON.stringify({ anonymousId }, null, 2)}
408
+ `, {
409
+ encoding: "utf8",
410
+ mode: 384
411
+ });
412
+ return anonymousId;
413
+ } catch {
414
+ return null;
415
+ }
416
+ }
417
+ async function trackInitSuccess({
418
+ packageManager,
419
+ pro
420
+ }) {
421
+ if (!isTelemetryEnabled()) return;
422
+ const anonymousId = getAnonymousId();
423
+ if (!anonymousId) return;
424
+ const controller = new AbortController();
425
+ const timeout = setTimeout(() => controller.abort(), 1500);
426
+ try {
427
+ await fetch(process.env.BOARDUI_TELEMETRY_URL ?? DEFAULT_TELEMETRY_URL, {
428
+ method: "POST",
429
+ headers: { "Content-Type": "application/json" },
430
+ body: JSON.stringify({
431
+ anonymousId,
432
+ cliVersion: CLI_VERSION,
433
+ packageManager,
434
+ pro
435
+ }),
436
+ signal: controller.signal
437
+ });
438
+ } catch {
439
+ } finally {
440
+ clearTimeout(timeout);
441
+ }
442
+ }
443
+
444
+ // src/commands/init.ts
354
445
  var RUNTIME_DEPS = ["react-aria-components", "tailwind-merge", "@remixicon/react"];
355
446
  var DEV_DEPS = ["tailwindcss", "@tailwindcss/postcss"];
356
447
  var PRO_DEPS = ["recharts", "motion", "prism-react-renderer", "@internationalized/date"];
@@ -377,7 +468,7 @@ async function init(options) {
377
468
  const { confirmed } = await prompts2({
378
469
  type: "confirm",
379
470
  name: "confirmed",
380
- message: `Set up BoardUI in ${path3.basename(project.cwd)}? (installs Tailwind v4 + runtime deps, writes styles/ and utils/)`,
471
+ message: `Set up BoardUI in ${path4.basename(project.cwd)}? (installs Tailwind v4 + runtime deps, writes styles/ and utils/)`,
381
472
  initial: true
382
473
  });
383
474
  if (!confirmed) {
@@ -389,12 +480,14 @@ async function init(options) {
389
480
  const missingRuntime = runtimeDeps.filter((pkg) => !project.installedDependencies.has(pkg));
390
481
  const missingDev = DEV_DEPS.filter((pkg) => !project.installedDependencies.has(pkg));
391
482
  const missing = [...missingRuntime, ...missingDev];
483
+ let dependenciesReady = true;
392
484
  if (missing.length > 0) {
393
485
  const spinner2 = ora2(`Installing ${missing.join(", ")} with ${project.packageManager}...`).start();
394
486
  try {
395
487
  await installPackages(project.packageManager, missing, project.cwd);
396
488
  spinner2.succeed("Dependencies installed.");
397
489
  } catch (error) {
490
+ dependenciesReady = false;
398
491
  spinner2.fail(`Failed to install dependencies: ${error.message}`);
399
492
  console.log(pc2.dim(`Install manually: ${project.packageManager} add ${missing.join(" ")}`));
400
493
  }
@@ -411,21 +504,25 @@ async function init(options) {
411
504
  return;
412
505
  }
413
506
  spinner.succeed("Foundations fetched.");
414
- const targetRoot = options.dir ? path3.resolve(process.cwd(), options.dir) : sourceRoot(project);
507
+ const targetRoot = options.dir ? path4.resolve(process.cwd(), options.dir) : sourceRoot(project);
415
508
  for (const item of items) {
416
509
  for (const file of item.files) {
417
510
  const relPath = file.target ?? file.path;
418
- const absPath = path3.join(targetRoot, relPath);
419
- if (existsSync3(absPath) && !options.overwrite) {
511
+ const absPath = path4.join(targetRoot, relPath);
512
+ if (existsSync4(absPath) && !options.overwrite) {
420
513
  console.log(` ${pc2.dim("skipped (exists)")} ${relPath}`);
421
514
  continue;
422
515
  }
423
- mkdirSync2(path3.dirname(absPath), { recursive: true });
424
- writeFileSync2(absPath, file.content);
516
+ mkdirSync3(path4.dirname(absPath), { recursive: true });
517
+ writeFileSync3(absPath, file.content);
425
518
  console.log(` ${pc2.green("created")} ${relPath}`);
426
519
  }
427
520
  }
428
521
  const globalsPath = project.usesSrcDir ? "src/styles/globals.css" : "styles/globals.css";
522
+ const telemetry = dependenciesReady ? trackInitSuccess({
523
+ packageManager: project.packageManager,
524
+ pro: Boolean(options.pro)
525
+ }) : Promise.resolve();
429
526
  console.log(`
430
527
  ${pc2.bold("Almost done \u2014 wire up the styles:")}
431
528
 
@@ -444,6 +541,14 @@ ${pc2.bold("Almost done \u2014 wire up the styles:")}
444
541
 
445
542
  ${pc2.cyan("npx boardui add button select date-picker")}
446
543
  `);
544
+ await telemetry;
545
+ if (dependenciesReady && isTelemetryEnabled()) {
546
+ console.log(
547
+ pc2.dim(
548
+ "Anonymous init telemetry is enabled (no project paths or source code). Set BOARDUI_TELEMETRY_DISABLED=1 to opt out.\n"
549
+ )
550
+ );
551
+ }
447
552
  }
448
553
 
449
554
  // src/commands/list.ts
@@ -472,7 +577,7 @@ Add a component with ${pc3.cyan("npx boardui add <name>")}
472
577
 
473
578
  // src/index.ts
474
579
  var program = new Command();
475
- program.name("boardui").description("Add BoardUI components to your project.").version("0.2.0", "-v, --version");
580
+ program.name("boardui").description("Add BoardUI components to your project.").version(CLI_VERSION, "-v, --version");
476
581
  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) => {
477
582
  await init(options);
478
583
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boardui",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Add BoardUI components to your project.",
5
5
  "license": "MIT",
6
6
  "type": "module",