boardui 0.2.2 → 0.3.0
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 +40 -7
- package/dist/index.js +338 -94
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,10 @@ npx boardui@latest add button select date-picker
|
|
|
11
11
|
|
|
12
12
|
# browse what's available
|
|
13
13
|
npx boardui@latest list
|
|
14
|
+
|
|
15
|
+
# activate BoardUI Pro, then install a Pro component or template
|
|
16
|
+
npx boardui@latest login YOUR_LICENSE_KEY
|
|
17
|
+
npx boardui@latest add calendar template-ai-chat
|
|
14
18
|
```
|
|
15
19
|
|
|
16
20
|
## Commands
|
|
@@ -48,30 +52,59 @@ an interactive picker.
|
|
|
48
52
|
|
|
49
53
|
Prints all available components grouped by type.
|
|
50
54
|
|
|
55
|
+
### `login [key]`
|
|
56
|
+
|
|
57
|
+
Activates a BoardUI Pro license for this machine and stores the license and
|
|
58
|
+
Lemon Squeezy instance ID in the operating system's user config directory. If
|
|
59
|
+
the key is omitted, the CLI prompts for it.
|
|
60
|
+
|
|
61
|
+
Use the literal key from the Lemon Squeezy receipt without angle brackets:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npx boardui@latest login 12CA1606-...
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `logout`
|
|
68
|
+
|
|
69
|
+
Releases this machine's Lemon Squeezy activation and removes the locally stored
|
|
70
|
+
license.
|
|
71
|
+
|
|
51
72
|
## Environment
|
|
52
73
|
|
|
53
74
|
| Variable | Description |
|
|
54
75
|
| --- | --- |
|
|
55
76
|
| `BOARDUI_REGISTRY_URL` | Override the registry base URL (default `https://www.boardui.com/r`). Useful for testing against `http://localhost:3000/r`. |
|
|
56
|
-
| `
|
|
77
|
+
| `BOARDUI_PRO_REGISTRY_URL` | Override the Pro registry base URL (default `https://www.boardui.com/api/pro/r`). |
|
|
78
|
+
| `BOARDUI_LICENSE_KEY` | Provide a Pro license non-interactively, such as in CI. |
|
|
79
|
+
| `BOARDUI_LICENSE_INSTANCE` | Optional Lemon Squeezy instance ID paired with `BOARDUI_LICENSE_KEY`. |
|
|
80
|
+
| `BOARDUI_TELEMETRY_DISABLED=1` | Disable anonymous successful-command telemetry. |
|
|
57
81
|
| `DO_NOT_TRACK=1` | Standard opt-out; also disables BoardUI telemetry. |
|
|
58
82
|
| `BOARDUI_TELEMETRY_URL` | Override the telemetry endpoint. Intended for local testing. |
|
|
59
83
|
|
|
60
84
|
## Anonymous telemetry
|
|
61
85
|
|
|
62
86
|
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
|
-
|
|
87
|
+
the CLI version, detected package manager, and whether `--pro` was used. After a
|
|
88
|
+
successful `boardui add`, it sends the CLI version, package manager, and the
|
|
89
|
+
component names explicitly requested by the user. Automatically resolved
|
|
90
|
+
dependencies are not included. A random installation ID is stored in the
|
|
91
|
+
operating system's user config directory so repeat runs can be counted without
|
|
92
|
+
collecting identity.
|
|
66
93
|
|
|
67
94
|
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
|
|
95
|
+
addresses, other command arguments, or telemetry for `list`. Telemetry is
|
|
96
|
+
best-effort and never changes whether a command succeeds. Disable it with
|
|
70
97
|
`BOARDUI_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.
|
|
71
98
|
|
|
99
|
+
On BoardUI's servers, these events are retained as lifetime counters and
|
|
100
|
+
anonymous daily buckets used for daily, weekly, and monthly trend reporting.
|
|
101
|
+
The daily buckets do not expire automatically.
|
|
102
|
+
|
|
72
103
|
## Releasing
|
|
73
104
|
|
|
74
|
-
1.
|
|
105
|
+
1. Run `npm version <patch|minor|major> --no-git-tag-version` so
|
|
106
|
+
`package.json` and `package-lock.json` stay in sync. The CLI reads its
|
|
107
|
+
displayed and telemetry version from `package.json` at runtime.
|
|
75
108
|
2. `cd cli && npm install && npm run build`
|
|
76
109
|
3. Smoke test: `node dist/index.js list`
|
|
77
110
|
4. `npm publish`
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
-
import
|
|
5
|
+
import pc5 from "picocolors";
|
|
6
6
|
|
|
7
7
|
// src/commands/add.ts
|
|
8
|
-
import { existsSync as
|
|
9
|
-
import
|
|
8
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
9
|
+
import path4 from "path";
|
|
10
10
|
import ora from "ora";
|
|
11
11
|
import pc from "picocolors";
|
|
12
12
|
import prompts from "prompts";
|
|
@@ -131,11 +131,120 @@ async function installPackages(pm, packages, cwd) {
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
// src/lib/license.ts
|
|
135
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, rmSync, writeFileSync } from "fs";
|
|
136
|
+
import { homedir, hostname } from "os";
|
|
137
|
+
import path2 from "path";
|
|
138
|
+
var LICENSE_API = "https://api.lemonsqueezy.com/v1/licenses";
|
|
139
|
+
var PRO_PRODUCT_IDS = /* @__PURE__ */ new Set([1220683, 1268490]);
|
|
140
|
+
function configRoot() {
|
|
141
|
+
if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
|
|
142
|
+
if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
|
|
143
|
+
return path2.join(homedir(), ".config");
|
|
144
|
+
}
|
|
145
|
+
function licenseFile() {
|
|
146
|
+
return path2.join(configRoot(), "boardui", "license.json");
|
|
147
|
+
}
|
|
148
|
+
function getLicense() {
|
|
149
|
+
const envKey = process.env.BOARDUI_LICENSE_KEY;
|
|
150
|
+
if (envKey) {
|
|
151
|
+
return {
|
|
152
|
+
licenseKey: envKey,
|
|
153
|
+
instanceId: process.env.BOARDUI_LICENSE_INSTANCE ?? "",
|
|
154
|
+
instanceName: "env"
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const file = licenseFile();
|
|
159
|
+
if (!existsSync2(file)) return null;
|
|
160
|
+
const stored = JSON.parse(readFileSync2(file, "utf8"));
|
|
161
|
+
if (typeof stored.licenseKey !== "string" || stored.licenseKey.length === 0) return null;
|
|
162
|
+
return {
|
|
163
|
+
licenseKey: stored.licenseKey,
|
|
164
|
+
instanceId: typeof stored.instanceId === "string" ? stored.instanceId : "",
|
|
165
|
+
instanceName: typeof stored.instanceName === "string" ? stored.instanceName : ""
|
|
166
|
+
};
|
|
167
|
+
} catch {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async function licenseApi(endpoint, fields) {
|
|
172
|
+
let response;
|
|
173
|
+
try {
|
|
174
|
+
response = await fetch(`${LICENSE_API}/${endpoint}`, {
|
|
175
|
+
method: "POST",
|
|
176
|
+
headers: {
|
|
177
|
+
Accept: "application/json",
|
|
178
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
179
|
+
},
|
|
180
|
+
body: new URLSearchParams(fields)
|
|
181
|
+
});
|
|
182
|
+
} catch (error) {
|
|
183
|
+
throw new Error("Could not reach the license server. Check your network connection.", {
|
|
184
|
+
cause: error
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return await response.json();
|
|
188
|
+
}
|
|
189
|
+
async function activateLicense(licenseKey) {
|
|
190
|
+
const instanceName = `boardui-cli@${hostname()}`;
|
|
191
|
+
const data = await licenseApi("activate", {
|
|
192
|
+
license_key: licenseKey,
|
|
193
|
+
instance_name: instanceName
|
|
194
|
+
});
|
|
195
|
+
if (!data.activated || !data.instance) {
|
|
196
|
+
throw new Error(data.error ?? "Could not activate this license key.");
|
|
197
|
+
}
|
|
198
|
+
const file = licenseFile();
|
|
199
|
+
mkdirSync(path2.dirname(file), { recursive: true });
|
|
200
|
+
writeFileSync(
|
|
201
|
+
file,
|
|
202
|
+
JSON.stringify(
|
|
203
|
+
{
|
|
204
|
+
licenseKey,
|
|
205
|
+
instanceId: data.instance.id,
|
|
206
|
+
instanceName
|
|
207
|
+
},
|
|
208
|
+
null,
|
|
209
|
+
2
|
|
210
|
+
) + "\n"
|
|
211
|
+
);
|
|
212
|
+
return {
|
|
213
|
+
seatsUsed: data.license_key?.activation_usage ?? 1,
|
|
214
|
+
seatLimit: data.license_key?.activation_limit ?? 0,
|
|
215
|
+
productName: data.meta?.product_name ?? "BoardUI Pro",
|
|
216
|
+
warning: data.meta && !PRO_PRODUCT_IDS.has(data.meta.product_id) ? `This key belongs to "${data.meta.product_name}", not BoardUI Pro \u2014 pro installs will be refused.` : void 0
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
async function deactivateLicense() {
|
|
220
|
+
const license = getLicense();
|
|
221
|
+
if (!license) return false;
|
|
222
|
+
if (license.instanceId) {
|
|
223
|
+
const data = await licenseApi("deactivate", {
|
|
224
|
+
license_key: license.licenseKey,
|
|
225
|
+
instance_id: license.instanceId
|
|
226
|
+
});
|
|
227
|
+
if (!data.deactivated && data.error) {
|
|
228
|
+
rmSync(licenseFile(), { force: true });
|
|
229
|
+
throw new Error(`${data.error} (the locally stored key was removed anyway)`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
rmSync(licenseFile(), { force: true });
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
|
|
134
236
|
// src/lib/registry.ts
|
|
135
237
|
var DEFAULT_REGISTRY_URL = "https://www.boardui.com/r";
|
|
238
|
+
var DEFAULT_PRO_REGISTRY_URL = "https://www.boardui.com/api/pro/r";
|
|
136
239
|
function registryBaseUrl() {
|
|
137
240
|
return (process.env.BOARDUI_REGISTRY_URL ?? DEFAULT_REGISTRY_URL).replace(/\/$/, "");
|
|
138
241
|
}
|
|
242
|
+
function proRegistryBaseUrl() {
|
|
243
|
+
return (process.env.BOARDUI_PRO_REGISTRY_URL ?? DEFAULT_PRO_REGISTRY_URL).replace(/\/$/, "");
|
|
244
|
+
}
|
|
245
|
+
function assetsBaseUrl() {
|
|
246
|
+
return (process.env.BOARDUI_ASSETS_URL ?? "https://www.boardui.com").replace(/\/$/, "");
|
|
247
|
+
}
|
|
139
248
|
async function fetchJson(url) {
|
|
140
249
|
let response;
|
|
141
250
|
try {
|
|
@@ -157,8 +266,46 @@ async function fetchJson(url) {
|
|
|
157
266
|
async function fetchRegistryIndex() {
|
|
158
267
|
return fetchJson(`${registryBaseUrl()}/registry.json`);
|
|
159
268
|
}
|
|
269
|
+
async function fetchProRegistryItem(name) {
|
|
270
|
+
const license = getLicense();
|
|
271
|
+
if (!license) {
|
|
272
|
+
throw new Error(
|
|
273
|
+
`"${name}" is not in the public registry. If it's a BoardUI Pro component, run \`boardui login <license-key>\` first (the key is in your Lemon Squeezy receipt).`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
let response;
|
|
277
|
+
try {
|
|
278
|
+
response = await fetch(`${proRegistryBaseUrl()}/${name}`, {
|
|
279
|
+
headers: {
|
|
280
|
+
Authorization: `Bearer ${license.licenseKey}`,
|
|
281
|
+
...license.instanceId ? { "X-BoardUI-Instance": license.instanceId } : {}
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
} catch (error) {
|
|
285
|
+
throw new Error("Could not reach the BoardUI pro registry. Check your network connection.", {
|
|
286
|
+
cause: error
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
if (!response.ok) {
|
|
290
|
+
let message = `Pro registry request failed (${response.status}).`;
|
|
291
|
+
try {
|
|
292
|
+
const body = await response.json();
|
|
293
|
+
if (body.error) message = body.error;
|
|
294
|
+
} catch {
|
|
295
|
+
}
|
|
296
|
+
throw new Error(message);
|
|
297
|
+
}
|
|
298
|
+
return await response.json();
|
|
299
|
+
}
|
|
160
300
|
async function fetchRegistryItem(name) {
|
|
161
|
-
|
|
301
|
+
try {
|
|
302
|
+
return await fetchJson(`${registryBaseUrl()}/${name}.json`);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
if (error instanceof Error && error.message.startsWith("Not found in the registry")) {
|
|
305
|
+
return fetchProRegistryItem(name);
|
|
306
|
+
}
|
|
307
|
+
throw error;
|
|
308
|
+
}
|
|
162
309
|
}
|
|
163
310
|
async function resolveItems(names) {
|
|
164
311
|
const resolved = /* @__PURE__ */ new Map();
|
|
@@ -188,6 +335,98 @@ async function resolveItems(names) {
|
|
|
188
335
|
return ordered;
|
|
189
336
|
}
|
|
190
337
|
|
|
338
|
+
// src/lib/telemetry.ts
|
|
339
|
+
import { randomUUID } from "crypto";
|
|
340
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
341
|
+
import { homedir as homedir2 } from "os";
|
|
342
|
+
import path3 from "path";
|
|
343
|
+
|
|
344
|
+
// src/version.ts
|
|
345
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
346
|
+
var packageJson = JSON.parse(
|
|
347
|
+
readFileSync3(new URL("../package.json", import.meta.url), "utf8")
|
|
348
|
+
);
|
|
349
|
+
var CLI_VERSION = packageJson.version;
|
|
350
|
+
|
|
351
|
+
// src/lib/telemetry.ts
|
|
352
|
+
var DEFAULT_TELEMETRY_URL = "https://www.boardui.com/api/cli/telemetry";
|
|
353
|
+
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;
|
|
354
|
+
function envFlagEnabled(value) {
|
|
355
|
+
return ["1", "true", "yes"].includes(value?.toLowerCase() ?? "");
|
|
356
|
+
}
|
|
357
|
+
function isTelemetryEnabled() {
|
|
358
|
+
return !(envFlagEnabled(process.env.BOARDUI_TELEMETRY_DISABLED) || envFlagEnabled(process.env.DO_NOT_TRACK));
|
|
359
|
+
}
|
|
360
|
+
function configRoot2() {
|
|
361
|
+
if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
|
|
362
|
+
if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
|
|
363
|
+
return path3.join(homedir2(), ".config");
|
|
364
|
+
}
|
|
365
|
+
function anonymousIdFile() {
|
|
366
|
+
return path3.join(configRoot2(), "boardui", "telemetry.json");
|
|
367
|
+
}
|
|
368
|
+
function getAnonymousId() {
|
|
369
|
+
const file = anonymousIdFile();
|
|
370
|
+
try {
|
|
371
|
+
if (existsSync3(file)) {
|
|
372
|
+
const stored = JSON.parse(readFileSync4(file, "utf8"));
|
|
373
|
+
if (typeof stored.anonymousId === "string" && UUID_V4_RE.test(stored.anonymousId)) {
|
|
374
|
+
return stored.anonymousId;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
const anonymousId = randomUUID();
|
|
378
|
+
mkdirSync2(path3.dirname(file), { recursive: true, mode: 448 });
|
|
379
|
+
writeFileSync2(file, `${JSON.stringify({ anonymousId }, null, 2)}
|
|
380
|
+
`, {
|
|
381
|
+
encoding: "utf8",
|
|
382
|
+
mode: 384
|
|
383
|
+
});
|
|
384
|
+
return anonymousId;
|
|
385
|
+
} catch {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
async function sendTelemetryEvent(event) {
|
|
390
|
+
if (!isTelemetryEnabled()) return;
|
|
391
|
+
const anonymousId = getAnonymousId();
|
|
392
|
+
if (!anonymousId) return;
|
|
393
|
+
const controller = new AbortController();
|
|
394
|
+
const timeout = setTimeout(() => controller.abort(), 1500);
|
|
395
|
+
try {
|
|
396
|
+
await fetch(process.env.BOARDUI_TELEMETRY_URL ?? DEFAULT_TELEMETRY_URL, {
|
|
397
|
+
method: "POST",
|
|
398
|
+
headers: { "Content-Type": "application/json" },
|
|
399
|
+
body: JSON.stringify({
|
|
400
|
+
...event,
|
|
401
|
+
anonymousId,
|
|
402
|
+
cliVersion: CLI_VERSION
|
|
403
|
+
}),
|
|
404
|
+
signal: controller.signal
|
|
405
|
+
});
|
|
406
|
+
} catch {
|
|
407
|
+
} finally {
|
|
408
|
+
clearTimeout(timeout);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
async function trackInitSuccess({
|
|
412
|
+
packageManager,
|
|
413
|
+
pro
|
|
414
|
+
}) {
|
|
415
|
+
await sendTelemetryEvent({ event: "init", packageManager, pro });
|
|
416
|
+
}
|
|
417
|
+
async function trackAddSuccess({
|
|
418
|
+
packageManager,
|
|
419
|
+
components
|
|
420
|
+
}) {
|
|
421
|
+
const uniqueComponents = [...new Set(components)];
|
|
422
|
+
if (uniqueComponents.length === 0) return;
|
|
423
|
+
await sendTelemetryEvent({
|
|
424
|
+
event: "add",
|
|
425
|
+
packageManager,
|
|
426
|
+
components: uniqueComponents
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
191
430
|
// src/commands/add.ts
|
|
192
431
|
var TYPE_LABEL = {
|
|
193
432
|
base: "Base components",
|
|
@@ -240,6 +479,7 @@ async function add(components, options) {
|
|
|
240
479
|
console.log("Nothing to add.");
|
|
241
480
|
return;
|
|
242
481
|
}
|
|
482
|
+
const requestedComponents = [...new Set(names)];
|
|
243
483
|
const spinner = ora("Resolving components...").start();
|
|
244
484
|
let items;
|
|
245
485
|
try {
|
|
@@ -252,12 +492,12 @@ async function add(components, options) {
|
|
|
252
492
|
spinner.succeed(
|
|
253
493
|
`Resolved ${items.length} item${items.length === 1 ? "" : "s"}: ${items.map((i) => i.name).join(", ")}`
|
|
254
494
|
);
|
|
255
|
-
const targetRoot = options.path ?
|
|
495
|
+
const targetRoot = options.path ? path4.resolve(process.cwd(), options.path) : options.dir ? path4.resolve(process.cwd(), options.dir) : sourceRoot(project);
|
|
256
496
|
const writesByPath = /* @__PURE__ */ new Map();
|
|
257
497
|
for (const item of items) {
|
|
258
498
|
for (const file of item.files) {
|
|
259
499
|
const relPath = file.target ?? file.path;
|
|
260
|
-
const absPath =
|
|
500
|
+
const absPath = path4.join(targetRoot, relPath);
|
|
261
501
|
const pending = writesByPath.get(absPath);
|
|
262
502
|
if (pending) {
|
|
263
503
|
if (pending.content !== file.content) {
|
|
@@ -271,7 +511,7 @@ async function add(components, options) {
|
|
|
271
511
|
absPath,
|
|
272
512
|
relPath,
|
|
273
513
|
content: file.content,
|
|
274
|
-
exists:
|
|
514
|
+
exists: existsSync4(absPath)
|
|
275
515
|
});
|
|
276
516
|
}
|
|
277
517
|
}
|
|
@@ -309,12 +549,44 @@ The following files already exist:`));
|
|
|
309
549
|
skipped++;
|
|
310
550
|
continue;
|
|
311
551
|
}
|
|
312
|
-
|
|
313
|
-
|
|
552
|
+
mkdirSync3(path4.dirname(write.absPath), { recursive: true });
|
|
553
|
+
writeFileSync3(write.absPath, write.content);
|
|
314
554
|
written++;
|
|
315
555
|
console.log(` ${pc.green(write.exists ? "overwrote" : "created")} ${write.relPath}`);
|
|
316
556
|
}
|
|
317
557
|
if (skipped > 0) console.log(pc.dim(` skipped ${skipped} existing file${skipped === 1 ? "" : "s"}`));
|
|
558
|
+
const assets = items.flatMap((item) => item.assets ?? []);
|
|
559
|
+
if (assets.length > 0) {
|
|
560
|
+
const assetSpinner = ora(`Downloading ${assets.length} template asset${assets.length === 1 ? "" : "s"}...`).start();
|
|
561
|
+
let fetched = 0;
|
|
562
|
+
let assetSkipped = 0;
|
|
563
|
+
const failures = [];
|
|
564
|
+
for (const asset of assets) {
|
|
565
|
+
const absPath = path4.join(targetRoot, asset.target);
|
|
566
|
+
if (existsSync4(absPath) && !options.overwrite) {
|
|
567
|
+
assetSkipped++;
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
try {
|
|
571
|
+
const response = await fetch(`${assetsBaseUrl()}${asset.url}`);
|
|
572
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
573
|
+
mkdirSync3(path4.dirname(absPath), { recursive: true });
|
|
574
|
+
writeFileSync3(absPath, Buffer.from(await response.arrayBuffer()));
|
|
575
|
+
fetched++;
|
|
576
|
+
} catch {
|
|
577
|
+
failures.push(asset.target);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if (failures.length > 0) {
|
|
581
|
+
assetSpinner.warn(
|
|
582
|
+
`Downloaded ${fetched} asset${fetched === 1 ? "" : "s"}; failed: ${failures.join(", ")} \u2014 re-run with --overwrite to retry.`
|
|
583
|
+
);
|
|
584
|
+
} else {
|
|
585
|
+
assetSpinner.succeed(
|
|
586
|
+
`Downloaded ${fetched} asset${fetched === 1 ? "" : "s"}${assetSkipped > 0 ? ` (${assetSkipped} already present)` : ""}.`
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
318
590
|
const wanted = /* @__PURE__ */ new Map();
|
|
319
591
|
for (const item of items) {
|
|
320
592
|
for (const spec of item.dependencies ?? []) {
|
|
@@ -358,90 +630,20 @@ ${pc.bold("Note:")} import the BoardUI styles in your root layout or global css:
|
|
|
358
630
|
}
|
|
359
631
|
console.log(pc.green(`
|
|
360
632
|
Done. ${written} file${written === 1 ? "" : "s"} written.`));
|
|
633
|
+
if (written > 0) {
|
|
634
|
+
await trackAddSuccess({
|
|
635
|
+
packageManager: project.packageManager,
|
|
636
|
+
components: requestedComponents
|
|
637
|
+
});
|
|
638
|
+
}
|
|
361
639
|
}
|
|
362
640
|
|
|
363
641
|
// src/commands/init.ts
|
|
364
|
-
import { existsSync as
|
|
365
|
-
import
|
|
642
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
643
|
+
import path5 from "path";
|
|
366
644
|
import ora2 from "ora";
|
|
367
645
|
import pc2 from "picocolors";
|
|
368
646
|
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
647
|
var RUNTIME_DEPS = ["react-aria-components", "tailwind-merge", "@remixicon/react"];
|
|
446
648
|
var DEV_DEPS = ["tailwindcss", "@tailwindcss/postcss"];
|
|
447
649
|
var PRO_DEPS = ["recharts", "motion", "prism-react-renderer", "@internationalized/date"];
|
|
@@ -468,7 +670,7 @@ async function init(options) {
|
|
|
468
670
|
const { confirmed } = await prompts2({
|
|
469
671
|
type: "confirm",
|
|
470
672
|
name: "confirmed",
|
|
471
|
-
message: `Set up BoardUI in ${
|
|
673
|
+
message: `Set up BoardUI in ${path5.basename(project.cwd)}? (installs Tailwind v4 + runtime deps, writes styles/ and utils/)`,
|
|
472
674
|
initial: true
|
|
473
675
|
});
|
|
474
676
|
if (!confirmed) {
|
|
@@ -504,17 +706,17 @@ async function init(options) {
|
|
|
504
706
|
return;
|
|
505
707
|
}
|
|
506
708
|
spinner.succeed("Foundations fetched.");
|
|
507
|
-
const targetRoot = options.dir ?
|
|
709
|
+
const targetRoot = options.dir ? path5.resolve(process.cwd(), options.dir) : sourceRoot(project);
|
|
508
710
|
for (const item of items) {
|
|
509
711
|
for (const file of item.files) {
|
|
510
712
|
const relPath = file.target ?? file.path;
|
|
511
|
-
const absPath =
|
|
512
|
-
if (
|
|
713
|
+
const absPath = path5.join(targetRoot, relPath);
|
|
714
|
+
if (existsSync5(absPath) && !options.overwrite) {
|
|
513
715
|
console.log(` ${pc2.dim("skipped (exists)")} ${relPath}`);
|
|
514
716
|
continue;
|
|
515
717
|
}
|
|
516
|
-
|
|
517
|
-
|
|
718
|
+
mkdirSync4(path5.dirname(absPath), { recursive: true });
|
|
719
|
+
writeFileSync4(absPath, file.content);
|
|
518
720
|
console.log(` ${pc2.green("created")} ${relPath}`);
|
|
519
721
|
}
|
|
520
722
|
}
|
|
@@ -575,6 +777,42 @@ Add a component with ${pc3.cyan("npx boardui add <name>")}
|
|
|
575
777
|
`);
|
|
576
778
|
}
|
|
577
779
|
|
|
780
|
+
// src/commands/login.ts
|
|
781
|
+
import pc4 from "picocolors";
|
|
782
|
+
import prompts3 from "prompts";
|
|
783
|
+
async function login(key) {
|
|
784
|
+
let licenseKey = key?.trim();
|
|
785
|
+
if (!licenseKey) {
|
|
786
|
+
const answer = await prompts3({
|
|
787
|
+
type: "password",
|
|
788
|
+
name: "key",
|
|
789
|
+
message: "Paste your BoardUI Pro license key (from your Lemon Squeezy receipt)"
|
|
790
|
+
});
|
|
791
|
+
licenseKey = typeof answer.key === "string" ? answer.key.trim() : "";
|
|
792
|
+
}
|
|
793
|
+
if (!licenseKey) {
|
|
794
|
+
throw new Error("No license key given.");
|
|
795
|
+
}
|
|
796
|
+
const result = await activateLicense(licenseKey);
|
|
797
|
+
console.log(pc4.green(`
|
|
798
|
+
\u2713 License activated for ${result.productName}.`));
|
|
799
|
+
if (result.seatLimit > 0) {
|
|
800
|
+
console.log(pc4.dim(` Seats in use: ${result.seatsUsed}/${result.seatLimit}`));
|
|
801
|
+
}
|
|
802
|
+
if (result.warning) {
|
|
803
|
+
console.log(pc4.yellow(` ${result.warning}`));
|
|
804
|
+
}
|
|
805
|
+
console.log(pc4.dim(" Try it: npx boardui add agent-progress"));
|
|
806
|
+
}
|
|
807
|
+
async function logout() {
|
|
808
|
+
if (!getLicense()) {
|
|
809
|
+
console.log(pc4.dim("No license is stored on this machine."));
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
await deactivateLicense();
|
|
813
|
+
console.log(pc4.green("\u2713 Seat released and license removed from this machine."));
|
|
814
|
+
}
|
|
815
|
+
|
|
578
816
|
// src/index.ts
|
|
579
817
|
var program = new Command();
|
|
580
818
|
program.name("boardui").description("Add BoardUI components to your project.").version(CLI_VERSION, "-v, --version");
|
|
@@ -587,8 +825,14 @@ program.command("add").description("Add components to your project.").argument("
|
|
|
587
825
|
program.command("list").description("List all available components.").action(async () => {
|
|
588
826
|
await list();
|
|
589
827
|
});
|
|
828
|
+
program.command("login").description("Activate a BoardUI Pro license key on this machine.").argument("[key]", "license key from your Lemon Squeezy receipt").action(async (key) => {
|
|
829
|
+
await login(key);
|
|
830
|
+
});
|
|
831
|
+
program.command("logout").description("Release this machine's Pro seat and remove the stored key.").action(async () => {
|
|
832
|
+
await logout();
|
|
833
|
+
});
|
|
590
834
|
program.parseAsync().catch((error) => {
|
|
591
|
-
console.error(
|
|
835
|
+
console.error(pc5.red(`
|
|
592
836
|
${error.message}`));
|
|
593
837
|
process.exit(1);
|
|
594
838
|
});
|