boardui 0.2.1 → 0.2.3

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 +19 -0
  2. package/dist/index.js +125 -16
  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,24 @@ 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-command 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. After a
64
+ successful `boardui add`, it sends the CLI version, package manager, and the
65
+ component names explicitly requested by the user. Automatically resolved
66
+ dependencies are not included. A random installation ID is stored in the
67
+ operating system's user config directory so repeat runs can be counted without
68
+ collecting identity.
69
+
70
+ BoardUI does not send project paths, source code, dependency names, email
71
+ addresses, other command arguments, or telemetry for `list`. Telemetry is
72
+ best-effort and never changes whether a command succeeds. Disable it with
73
+ `BOARDUI_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.
55
74
 
56
75
  ## Releasing
57
76
 
package/dist/index.js CHANGED
@@ -5,8 +5,8 @@ import { Command } from "commander";
5
5
  import pc4 from "picocolors";
6
6
 
7
7
  // src/commands/add.ts
8
- import { existsSync as existsSync2, mkdirSync, writeFileSync } from "fs";
9
- import path2 from "path";
8
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
9
+ import path3 from "path";
10
10
  import ora from "ora";
11
11
  import pc from "picocolors";
12
12
  import prompts from "prompts";
@@ -188,6 +188,94 @@ async function resolveItems(names) {
188
188
  return ordered;
189
189
  }
190
190
 
191
+ // src/lib/telemetry.ts
192
+ import { randomUUID } from "crypto";
193
+ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
194
+ import { homedir } from "os";
195
+ import path2 from "path";
196
+
197
+ // src/version.ts
198
+ var CLI_VERSION = "0.2.3";
199
+
200
+ // src/lib/telemetry.ts
201
+ var DEFAULT_TELEMETRY_URL = "https://www.boardui.com/api/cli/telemetry";
202
+ 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;
203
+ function envFlagEnabled(value) {
204
+ return ["1", "true", "yes"].includes(value?.toLowerCase() ?? "");
205
+ }
206
+ function isTelemetryEnabled() {
207
+ return !(envFlagEnabled(process.env.BOARDUI_TELEMETRY_DISABLED) || envFlagEnabled(process.env.DO_NOT_TRACK));
208
+ }
209
+ function configRoot() {
210
+ if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
211
+ if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
212
+ return path2.join(homedir(), ".config");
213
+ }
214
+ function anonymousIdFile() {
215
+ return path2.join(configRoot(), "boardui", "telemetry.json");
216
+ }
217
+ function getAnonymousId() {
218
+ const file = anonymousIdFile();
219
+ try {
220
+ if (existsSync2(file)) {
221
+ const stored = JSON.parse(readFileSync2(file, "utf8"));
222
+ if (typeof stored.anonymousId === "string" && UUID_V4_RE.test(stored.anonymousId)) {
223
+ return stored.anonymousId;
224
+ }
225
+ }
226
+ const anonymousId = randomUUID();
227
+ mkdirSync(path2.dirname(file), { recursive: true, mode: 448 });
228
+ writeFileSync(file, `${JSON.stringify({ anonymousId }, null, 2)}
229
+ `, {
230
+ encoding: "utf8",
231
+ mode: 384
232
+ });
233
+ return anonymousId;
234
+ } catch {
235
+ return null;
236
+ }
237
+ }
238
+ async function sendTelemetryEvent(event) {
239
+ if (!isTelemetryEnabled()) return;
240
+ const anonymousId = getAnonymousId();
241
+ if (!anonymousId) return;
242
+ const controller = new AbortController();
243
+ const timeout = setTimeout(() => controller.abort(), 1500);
244
+ try {
245
+ await fetch(process.env.BOARDUI_TELEMETRY_URL ?? DEFAULT_TELEMETRY_URL, {
246
+ method: "POST",
247
+ headers: { "Content-Type": "application/json" },
248
+ body: JSON.stringify({
249
+ ...event,
250
+ anonymousId,
251
+ cliVersion: CLI_VERSION
252
+ }),
253
+ signal: controller.signal
254
+ });
255
+ } catch {
256
+ } finally {
257
+ clearTimeout(timeout);
258
+ }
259
+ }
260
+ async function trackInitSuccess({
261
+ packageManager,
262
+ pro
263
+ }) {
264
+ await sendTelemetryEvent({ event: "init", packageManager, pro });
265
+ }
266
+ async function trackAddSuccess({
267
+ packageManager,
268
+ components
269
+ }) {
270
+ const uniqueComponents = [...new Set(components)];
271
+ if (uniqueComponents.length === 0) return;
272
+ await sendTelemetryEvent({
273
+ event: "add",
274
+ packageManager,
275
+ components: uniqueComponents
276
+ });
277
+ }
278
+
191
279
  // src/commands/add.ts
192
280
  var TYPE_LABEL = {
193
281
  base: "Base components",
@@ -240,6 +328,7 @@ async function add(components, options) {
240
328
  console.log("Nothing to add.");
241
329
  return;
242
330
  }
331
+ const requestedComponents = [...new Set(names)];
243
332
  const spinner = ora("Resolving components...").start();
244
333
  let items;
245
334
  try {
@@ -252,12 +341,12 @@ async function add(components, options) {
252
341
  spinner.succeed(
253
342
  `Resolved ${items.length} item${items.length === 1 ? "" : "s"}: ${items.map((i) => i.name).join(", ")}`
254
343
  );
255
- const targetRoot = options.path ? path2.resolve(process.cwd(), options.path) : options.dir ? path2.resolve(process.cwd(), options.dir) : sourceRoot(project);
344
+ const targetRoot = options.path ? path3.resolve(process.cwd(), options.path) : options.dir ? path3.resolve(process.cwd(), options.dir) : sourceRoot(project);
256
345
  const writesByPath = /* @__PURE__ */ new Map();
257
346
  for (const item of items) {
258
347
  for (const file of item.files) {
259
348
  const relPath = file.target ?? file.path;
260
- const absPath = path2.join(targetRoot, relPath);
349
+ const absPath = path3.join(targetRoot, relPath);
261
350
  const pending = writesByPath.get(absPath);
262
351
  if (pending) {
263
352
  if (pending.content !== file.content) {
@@ -271,7 +360,7 @@ async function add(components, options) {
271
360
  absPath,
272
361
  relPath,
273
362
  content: file.content,
274
- exists: existsSync2(absPath)
363
+ exists: existsSync3(absPath)
275
364
  });
276
365
  }
277
366
  }
@@ -309,8 +398,8 @@ The following files already exist:`));
309
398
  skipped++;
310
399
  continue;
311
400
  }
312
- mkdirSync(path2.dirname(write.absPath), { recursive: true });
313
- writeFileSync(write.absPath, write.content);
401
+ mkdirSync2(path3.dirname(write.absPath), { recursive: true });
402
+ writeFileSync2(write.absPath, write.content);
314
403
  written++;
315
404
  console.log(` ${pc.green(write.exists ? "overwrote" : "created")} ${write.relPath}`);
316
405
  }
@@ -358,11 +447,17 @@ ${pc.bold("Note:")} import the BoardUI styles in your root layout or global css:
358
447
  }
359
448
  console.log(pc.green(`
360
449
  Done. ${written} file${written === 1 ? "" : "s"} written.`));
450
+ if (written > 0) {
451
+ await trackAddSuccess({
452
+ packageManager: project.packageManager,
453
+ components: requestedComponents
454
+ });
455
+ }
361
456
  }
362
457
 
363
458
  // src/commands/init.ts
364
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
365
- import path3 from "path";
459
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
460
+ import path4 from "path";
366
461
  import ora2 from "ora";
367
462
  import pc2 from "picocolors";
368
463
  import prompts2 from "prompts";
@@ -392,7 +487,7 @@ async function init(options) {
392
487
  const { confirmed } = await prompts2({
393
488
  type: "confirm",
394
489
  name: "confirmed",
395
- message: `Set up BoardUI in ${path3.basename(project.cwd)}? (installs Tailwind v4 + runtime deps, writes styles/ and utils/)`,
490
+ message: `Set up BoardUI in ${path4.basename(project.cwd)}? (installs Tailwind v4 + runtime deps, writes styles/ and utils/)`,
396
491
  initial: true
397
492
  });
398
493
  if (!confirmed) {
@@ -404,12 +499,14 @@ async function init(options) {
404
499
  const missingRuntime = runtimeDeps.filter((pkg) => !project.installedDependencies.has(pkg));
405
500
  const missingDev = DEV_DEPS.filter((pkg) => !project.installedDependencies.has(pkg));
406
501
  const missing = [...missingRuntime, ...missingDev];
502
+ let dependenciesReady = true;
407
503
  if (missing.length > 0) {
408
504
  const spinner2 = ora2(`Installing ${missing.join(", ")} with ${project.packageManager}...`).start();
409
505
  try {
410
506
  await installPackages(project.packageManager, missing, project.cwd);
411
507
  spinner2.succeed("Dependencies installed.");
412
508
  } catch (error) {
509
+ dependenciesReady = false;
413
510
  spinner2.fail(`Failed to install dependencies: ${error.message}`);
414
511
  console.log(pc2.dim(`Install manually: ${project.packageManager} add ${missing.join(" ")}`));
415
512
  }
@@ -426,21 +523,25 @@ async function init(options) {
426
523
  return;
427
524
  }
428
525
  spinner.succeed("Foundations fetched.");
429
- const targetRoot = options.dir ? path3.resolve(process.cwd(), options.dir) : sourceRoot(project);
526
+ const targetRoot = options.dir ? path4.resolve(process.cwd(), options.dir) : sourceRoot(project);
430
527
  for (const item of items) {
431
528
  for (const file of item.files) {
432
529
  const relPath = file.target ?? file.path;
433
- const absPath = path3.join(targetRoot, relPath);
434
- if (existsSync3(absPath) && !options.overwrite) {
530
+ const absPath = path4.join(targetRoot, relPath);
531
+ if (existsSync4(absPath) && !options.overwrite) {
435
532
  console.log(` ${pc2.dim("skipped (exists)")} ${relPath}`);
436
533
  continue;
437
534
  }
438
- mkdirSync2(path3.dirname(absPath), { recursive: true });
439
- writeFileSync2(absPath, file.content);
535
+ mkdirSync3(path4.dirname(absPath), { recursive: true });
536
+ writeFileSync3(absPath, file.content);
440
537
  console.log(` ${pc2.green("created")} ${relPath}`);
441
538
  }
442
539
  }
443
540
  const globalsPath = project.usesSrcDir ? "src/styles/globals.css" : "styles/globals.css";
541
+ const telemetry = dependenciesReady ? trackInitSuccess({
542
+ packageManager: project.packageManager,
543
+ pro: Boolean(options.pro)
544
+ }) : Promise.resolve();
444
545
  console.log(`
445
546
  ${pc2.bold("Almost done \u2014 wire up the styles:")}
446
547
 
@@ -459,6 +560,14 @@ ${pc2.bold("Almost done \u2014 wire up the styles:")}
459
560
 
460
561
  ${pc2.cyan("npx boardui add button select date-picker")}
461
562
  `);
563
+ await telemetry;
564
+ if (dependenciesReady && isTelemetryEnabled()) {
565
+ console.log(
566
+ pc2.dim(
567
+ "Anonymous init telemetry is enabled (no project paths or source code). Set BOARDUI_TELEMETRY_DISABLED=1 to opt out.\n"
568
+ )
569
+ );
570
+ }
462
571
  }
463
572
 
464
573
  // src/commands/list.ts
@@ -487,7 +596,7 @@ Add a component with ${pc3.cyan("npx boardui add <name>")}
487
596
 
488
597
  // src/index.ts
489
598
  var program = new Command();
490
- program.name("boardui").description("Add BoardUI components to your project.").version("0.2.1", "-v, --version");
599
+ program.name("boardui").description("Add BoardUI components to your project.").version(CLI_VERSION, "-v, --version");
491
600
  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) => {
492
601
  await init(options);
493
602
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boardui",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Add BoardUI components to your project.",
5
5
  "license": "MIT",
6
6
  "type": "module",