boardui 0.2.3 → 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 +31 -1
- package/dist/index.js +254 -29
- 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,11 +52,31 @@ 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`. |
|
|
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`. |
|
|
56
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. |
|
|
@@ -72,9 +96,15 @@ addresses, other command arguments, or telemetry for `list`. Telemetry is
|
|
|
72
96
|
best-effort and never changes whether a command succeeds. Disable it with
|
|
73
97
|
`BOARDUI_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.
|
|
74
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
|
+
|
|
75
103
|
## Releasing
|
|
76
104
|
|
|
77
|
-
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.
|
|
78
108
|
2. `cd cli && npm install && npm run build`
|
|
79
109
|
3. Smoke test: `node dist/index.js list`
|
|
80
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();
|
|
@@ -190,12 +337,16 @@ async function resolveItems(names) {
|
|
|
190
337
|
|
|
191
338
|
// src/lib/telemetry.ts
|
|
192
339
|
import { randomUUID } from "crypto";
|
|
193
|
-
import { existsSync as
|
|
194
|
-
import { homedir } from "os";
|
|
195
|
-
import
|
|
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";
|
|
196
343
|
|
|
197
344
|
// src/version.ts
|
|
198
|
-
|
|
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;
|
|
199
350
|
|
|
200
351
|
// src/lib/telemetry.ts
|
|
201
352
|
var DEFAULT_TELEMETRY_URL = "https://www.boardui.com/api/cli/telemetry";
|
|
@@ -206,26 +357,26 @@ function envFlagEnabled(value) {
|
|
|
206
357
|
function isTelemetryEnabled() {
|
|
207
358
|
return !(envFlagEnabled(process.env.BOARDUI_TELEMETRY_DISABLED) || envFlagEnabled(process.env.DO_NOT_TRACK));
|
|
208
359
|
}
|
|
209
|
-
function
|
|
360
|
+
function configRoot2() {
|
|
210
361
|
if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
|
|
211
362
|
if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
|
|
212
|
-
return
|
|
363
|
+
return path3.join(homedir2(), ".config");
|
|
213
364
|
}
|
|
214
365
|
function anonymousIdFile() {
|
|
215
|
-
return
|
|
366
|
+
return path3.join(configRoot2(), "boardui", "telemetry.json");
|
|
216
367
|
}
|
|
217
368
|
function getAnonymousId() {
|
|
218
369
|
const file = anonymousIdFile();
|
|
219
370
|
try {
|
|
220
|
-
if (
|
|
221
|
-
const stored = JSON.parse(
|
|
371
|
+
if (existsSync3(file)) {
|
|
372
|
+
const stored = JSON.parse(readFileSync4(file, "utf8"));
|
|
222
373
|
if (typeof stored.anonymousId === "string" && UUID_V4_RE.test(stored.anonymousId)) {
|
|
223
374
|
return stored.anonymousId;
|
|
224
375
|
}
|
|
225
376
|
}
|
|
226
377
|
const anonymousId = randomUUID();
|
|
227
|
-
|
|
228
|
-
|
|
378
|
+
mkdirSync2(path3.dirname(file), { recursive: true, mode: 448 });
|
|
379
|
+
writeFileSync2(file, `${JSON.stringify({ anonymousId }, null, 2)}
|
|
229
380
|
`, {
|
|
230
381
|
encoding: "utf8",
|
|
231
382
|
mode: 384
|
|
@@ -341,12 +492,12 @@ async function add(components, options) {
|
|
|
341
492
|
spinner.succeed(
|
|
342
493
|
`Resolved ${items.length} item${items.length === 1 ? "" : "s"}: ${items.map((i) => i.name).join(", ")}`
|
|
343
494
|
);
|
|
344
|
-
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);
|
|
345
496
|
const writesByPath = /* @__PURE__ */ new Map();
|
|
346
497
|
for (const item of items) {
|
|
347
498
|
for (const file of item.files) {
|
|
348
499
|
const relPath = file.target ?? file.path;
|
|
349
|
-
const absPath =
|
|
500
|
+
const absPath = path4.join(targetRoot, relPath);
|
|
350
501
|
const pending = writesByPath.get(absPath);
|
|
351
502
|
if (pending) {
|
|
352
503
|
if (pending.content !== file.content) {
|
|
@@ -360,7 +511,7 @@ async function add(components, options) {
|
|
|
360
511
|
absPath,
|
|
361
512
|
relPath,
|
|
362
513
|
content: file.content,
|
|
363
|
-
exists:
|
|
514
|
+
exists: existsSync4(absPath)
|
|
364
515
|
});
|
|
365
516
|
}
|
|
366
517
|
}
|
|
@@ -398,12 +549,44 @@ The following files already exist:`));
|
|
|
398
549
|
skipped++;
|
|
399
550
|
continue;
|
|
400
551
|
}
|
|
401
|
-
|
|
402
|
-
|
|
552
|
+
mkdirSync3(path4.dirname(write.absPath), { recursive: true });
|
|
553
|
+
writeFileSync3(write.absPath, write.content);
|
|
403
554
|
written++;
|
|
404
555
|
console.log(` ${pc.green(write.exists ? "overwrote" : "created")} ${write.relPath}`);
|
|
405
556
|
}
|
|
406
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
|
+
}
|
|
407
590
|
const wanted = /* @__PURE__ */ new Map();
|
|
408
591
|
for (const item of items) {
|
|
409
592
|
for (const spec of item.dependencies ?? []) {
|
|
@@ -456,8 +639,8 @@ Done. ${written} file${written === 1 ? "" : "s"} written.`));
|
|
|
456
639
|
}
|
|
457
640
|
|
|
458
641
|
// src/commands/init.ts
|
|
459
|
-
import { existsSync as
|
|
460
|
-
import
|
|
642
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
643
|
+
import path5 from "path";
|
|
461
644
|
import ora2 from "ora";
|
|
462
645
|
import pc2 from "picocolors";
|
|
463
646
|
import prompts2 from "prompts";
|
|
@@ -487,7 +670,7 @@ async function init(options) {
|
|
|
487
670
|
const { confirmed } = await prompts2({
|
|
488
671
|
type: "confirm",
|
|
489
672
|
name: "confirmed",
|
|
490
|
-
message: `Set up BoardUI in ${
|
|
673
|
+
message: `Set up BoardUI in ${path5.basename(project.cwd)}? (installs Tailwind v4 + runtime deps, writes styles/ and utils/)`,
|
|
491
674
|
initial: true
|
|
492
675
|
});
|
|
493
676
|
if (!confirmed) {
|
|
@@ -523,17 +706,17 @@ async function init(options) {
|
|
|
523
706
|
return;
|
|
524
707
|
}
|
|
525
708
|
spinner.succeed("Foundations fetched.");
|
|
526
|
-
const targetRoot = options.dir ?
|
|
709
|
+
const targetRoot = options.dir ? path5.resolve(process.cwd(), options.dir) : sourceRoot(project);
|
|
527
710
|
for (const item of items) {
|
|
528
711
|
for (const file of item.files) {
|
|
529
712
|
const relPath = file.target ?? file.path;
|
|
530
|
-
const absPath =
|
|
531
|
-
if (
|
|
713
|
+
const absPath = path5.join(targetRoot, relPath);
|
|
714
|
+
if (existsSync5(absPath) && !options.overwrite) {
|
|
532
715
|
console.log(` ${pc2.dim("skipped (exists)")} ${relPath}`);
|
|
533
716
|
continue;
|
|
534
717
|
}
|
|
535
|
-
|
|
536
|
-
|
|
718
|
+
mkdirSync4(path5.dirname(absPath), { recursive: true });
|
|
719
|
+
writeFileSync4(absPath, file.content);
|
|
537
720
|
console.log(` ${pc2.green("created")} ${relPath}`);
|
|
538
721
|
}
|
|
539
722
|
}
|
|
@@ -594,6 +777,42 @@ Add a component with ${pc3.cyan("npx boardui add <name>")}
|
|
|
594
777
|
`);
|
|
595
778
|
}
|
|
596
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
|
+
|
|
597
816
|
// src/index.ts
|
|
598
817
|
var program = new Command();
|
|
599
818
|
program.name("boardui").description("Add BoardUI components to your project.").version(CLI_VERSION, "-v, --version");
|
|
@@ -606,8 +825,14 @@ program.command("add").description("Add components to your project.").argument("
|
|
|
606
825
|
program.command("list").description("List all available components.").action(async () => {
|
|
607
826
|
await list();
|
|
608
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
|
+
});
|
|
609
834
|
program.parseAsync().catch((error) => {
|
|
610
|
-
console.error(
|
|
835
|
+
console.error(pc5.red(`
|
|
611
836
|
${error.message}`));
|
|
612
837
|
process.exit(1);
|
|
613
838
|
});
|