boardui 0.2.2 → 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.
- package/README.md +9 -6
- package/dist/index.js +102 -83
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,20 +53,23 @@ Prints all available components grouped by type.
|
|
|
53
53
|
| Variable | Description |
|
|
54
54
|
| --- | --- |
|
|
55
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
|
|
56
|
+
| `BOARDUI_TELEMETRY_DISABLED=1` | Disable anonymous successful-command telemetry. |
|
|
57
57
|
| `DO_NOT_TRACK=1` | Standard opt-out; also disables BoardUI telemetry. |
|
|
58
58
|
| `BOARDUI_TELEMETRY_URL` | Override the telemetry endpoint. Intended for local testing. |
|
|
59
59
|
|
|
60
60
|
## Anonymous telemetry
|
|
61
61
|
|
|
62
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.
|
|
64
|
-
|
|
65
|
-
|
|
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.
|
|
66
69
|
|
|
67
70
|
BoardUI does not send project paths, source code, dependency names, email
|
|
68
|
-
addresses, command arguments, or telemetry for `
|
|
69
|
-
best-effort and never changes whether
|
|
71
|
+
addresses, other command arguments, or telemetry for `list`. Telemetry is
|
|
72
|
+
best-effort and never changes whether a command succeeds. Disable it with
|
|
70
73
|
`BOARDUI_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.
|
|
71
74
|
|
|
72
75
|
## Releasing
|
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
|
|
9
|
-
import
|
|
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 ?
|
|
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 =
|
|
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:
|
|
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
|
-
|
|
313
|
-
|
|
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,6 +447,12 @@ ${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
|
|
@@ -366,82 +461,6 @@ import path4 from "path";
|
|
|
366
461
|
import ora2 from "ora";
|
|
367
462
|
import pc2 from "picocolors";
|
|
368
463
|
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
|
|
445
464
|
var RUNTIME_DEPS = ["react-aria-components", "tailwind-merge", "@remixicon/react"];
|
|
446
465
|
var DEV_DEPS = ["tailwindcss", "@tailwindcss/postcss"];
|
|
447
466
|
var PRO_DEPS = ["recharts", "motion", "prism-react-renderer", "@internationalized/date"];
|