boardui 0.2.1 → 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.
- package/README.md +16 -0
- package/dist/index.js +99 -9
- 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
|
@@ -361,11 +361,87 @@ Done. ${written} file${written === 1 ? "" : "s"} written.`));
|
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
// src/commands/init.ts
|
|
364
|
-
import { existsSync as
|
|
365
|
-
import
|
|
364
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
365
|
+
import path4 from "path";
|
|
366
366
|
import ora2 from "ora";
|
|
367
367
|
import pc2 from "picocolors";
|
|
368
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
|
|
369
445
|
var RUNTIME_DEPS = ["react-aria-components", "tailwind-merge", "@remixicon/react"];
|
|
370
446
|
var DEV_DEPS = ["tailwindcss", "@tailwindcss/postcss"];
|
|
371
447
|
var PRO_DEPS = ["recharts", "motion", "prism-react-renderer", "@internationalized/date"];
|
|
@@ -392,7 +468,7 @@ async function init(options) {
|
|
|
392
468
|
const { confirmed } = await prompts2({
|
|
393
469
|
type: "confirm",
|
|
394
470
|
name: "confirmed",
|
|
395
|
-
message: `Set up BoardUI in ${
|
|
471
|
+
message: `Set up BoardUI in ${path4.basename(project.cwd)}? (installs Tailwind v4 + runtime deps, writes styles/ and utils/)`,
|
|
396
472
|
initial: true
|
|
397
473
|
});
|
|
398
474
|
if (!confirmed) {
|
|
@@ -404,12 +480,14 @@ async function init(options) {
|
|
|
404
480
|
const missingRuntime = runtimeDeps.filter((pkg) => !project.installedDependencies.has(pkg));
|
|
405
481
|
const missingDev = DEV_DEPS.filter((pkg) => !project.installedDependencies.has(pkg));
|
|
406
482
|
const missing = [...missingRuntime, ...missingDev];
|
|
483
|
+
let dependenciesReady = true;
|
|
407
484
|
if (missing.length > 0) {
|
|
408
485
|
const spinner2 = ora2(`Installing ${missing.join(", ")} with ${project.packageManager}...`).start();
|
|
409
486
|
try {
|
|
410
487
|
await installPackages(project.packageManager, missing, project.cwd);
|
|
411
488
|
spinner2.succeed("Dependencies installed.");
|
|
412
489
|
} catch (error) {
|
|
490
|
+
dependenciesReady = false;
|
|
413
491
|
spinner2.fail(`Failed to install dependencies: ${error.message}`);
|
|
414
492
|
console.log(pc2.dim(`Install manually: ${project.packageManager} add ${missing.join(" ")}`));
|
|
415
493
|
}
|
|
@@ -426,21 +504,25 @@ async function init(options) {
|
|
|
426
504
|
return;
|
|
427
505
|
}
|
|
428
506
|
spinner.succeed("Foundations fetched.");
|
|
429
|
-
const targetRoot = options.dir ?
|
|
507
|
+
const targetRoot = options.dir ? path4.resolve(process.cwd(), options.dir) : sourceRoot(project);
|
|
430
508
|
for (const item of items) {
|
|
431
509
|
for (const file of item.files) {
|
|
432
510
|
const relPath = file.target ?? file.path;
|
|
433
|
-
const absPath =
|
|
434
|
-
if (
|
|
511
|
+
const absPath = path4.join(targetRoot, relPath);
|
|
512
|
+
if (existsSync4(absPath) && !options.overwrite) {
|
|
435
513
|
console.log(` ${pc2.dim("skipped (exists)")} ${relPath}`);
|
|
436
514
|
continue;
|
|
437
515
|
}
|
|
438
|
-
|
|
439
|
-
|
|
516
|
+
mkdirSync3(path4.dirname(absPath), { recursive: true });
|
|
517
|
+
writeFileSync3(absPath, file.content);
|
|
440
518
|
console.log(` ${pc2.green("created")} ${relPath}`);
|
|
441
519
|
}
|
|
442
520
|
}
|
|
443
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();
|
|
444
526
|
console.log(`
|
|
445
527
|
${pc2.bold("Almost done \u2014 wire up the styles:")}
|
|
446
528
|
|
|
@@ -459,6 +541,14 @@ ${pc2.bold("Almost done \u2014 wire up the styles:")}
|
|
|
459
541
|
|
|
460
542
|
${pc2.cyan("npx boardui add button select date-picker")}
|
|
461
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
|
+
}
|
|
462
552
|
}
|
|
463
553
|
|
|
464
554
|
// src/commands/list.ts
|
|
@@ -487,7 +577,7 @@ Add a component with ${pc3.cyan("npx boardui add <name>")}
|
|
|
487
577
|
|
|
488
578
|
// src/index.ts
|
|
489
579
|
var program = new Command();
|
|
490
|
-
program.name("boardui").description("Add BoardUI components to your project.").version(
|
|
580
|
+
program.name("boardui").description("Add BoardUI components to your project.").version(CLI_VERSION, "-v, --version");
|
|
491
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) => {
|
|
492
582
|
await init(options);
|
|
493
583
|
});
|