boardui 0.4.1 → 0.4.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.
Files changed (2) hide show
  1. package/dist/index.js +70 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -139,7 +139,7 @@ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, rm
139
139
  import { homedir, hostname } from "os";
140
140
  import path2 from "path";
141
141
  var LICENSE_API = "https://api.lemonsqueezy.com/v1/licenses";
142
- var PRO_PRODUCT_IDS = /* @__PURE__ */ new Set([1220683]);
142
+ var PRO_PRODUCT_IDS = /* @__PURE__ */ new Set([1220683, 1268490]);
143
143
  function configRoot() {
144
144
  if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
145
145
  if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
@@ -216,7 +216,25 @@ async function activateLicense(licenseKey) {
216
216
  seatsUsed: data.license_key?.activation_usage ?? 1,
217
217
  seatLimit: data.license_key?.activation_limit ?? 0,
218
218
  productName: data.meta?.product_name ?? "BoardUI Pro",
219
- 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
219
+ warning: data.meta && !PRO_PRODUCT_IDS.has(data.meta.product_id) ? `This key belongs to "${data.meta.product_name}", which this CLI version does not recognize as BoardUI Pro. The server has the final say \u2014 if pro installs are refused, update the CLI (npx boardui@latest) or contact hi@boardui.com.` : void 0
220
+ };
221
+ }
222
+ async function validateStoredLicense() {
223
+ const license = getLicense();
224
+ if (!license) return null;
225
+ const fields = { license_key: license.licenseKey };
226
+ if (license.instanceId) fields.instance_id = license.instanceId;
227
+ const data = await licenseApi("validate", fields);
228
+ if (!data.valid) {
229
+ return { valid: false, error: data.error ?? "This license key is not valid." };
230
+ }
231
+ return {
232
+ valid: true,
233
+ status: data.license_key?.status,
234
+ seatsUsed: data.license_key?.activation_usage,
235
+ seatLimit: data.license_key?.activation_limit,
236
+ productName: data.meta?.product_name,
237
+ unknownProduct: data.meta ? !PRO_PRODUCT_IDS.has(data.meta.product_id) : void 0
220
238
  };
221
239
  }
222
240
  async function deactivateLicense() {
@@ -1218,7 +1236,23 @@ ${proItem.example}
1218
1236
  if (installable.length === 0) {
1219
1237
  return text(proPitch(lockedPro));
1220
1238
  }
1221
- const items = await resolveItems(installable);
1239
+ const proNamesSet = new Set(pro.items.map((item) => item.name));
1240
+ let items;
1241
+ let proFailure = null;
1242
+ try {
1243
+ items = await resolveItems(installable);
1244
+ } catch (error) {
1245
+ const freeSubset = installable.filter((name) => !proNamesSet.has(name));
1246
+ const proSubset = installable.filter((name) => proNamesSet.has(name));
1247
+ if (proSubset.length === 0) throw error;
1248
+ proFailure = { names: proSubset, message: error.message };
1249
+ if (freeSubset.length === 0) {
1250
+ return errorText(
1251
+ `Pro item${proSubset.length === 1 ? "" : "s"} (${proSubset.join(", ")}) could not be fetched: ${proFailure.message}`
1252
+ );
1253
+ }
1254
+ items = await resolveItems(freeSubset);
1255
+ }
1222
1256
  const targetRoot = sourceRoot(project);
1223
1257
  const report = writeFiles(collectWrites(items, targetRoot, project.cwd), overwrite);
1224
1258
  const assets = await downloadAssets(items, targetRoot, overwrite);
@@ -1263,6 +1297,13 @@ ${proItem.example}
1263
1297
  NOT installed (pro, no license): ${lockedPro.map((item) => item.name).join(", ")}.
1264
1298
 
1265
1299
  ${proPitch(lockedPro)}`;
1300
+ }
1301
+ if (proFailure) {
1302
+ result += `
1303
+
1304
+ ---
1305
+
1306
+ NOT installed \u2014 pro fetch failed for ${proFailure.names.join(", ")}: ${proFailure.message}`;
1266
1307
  }
1267
1308
  return text(result);
1268
1309
  }
@@ -1391,10 +1432,13 @@ ${proPitch(lockedPro)}`;
1391
1432
  },
1392
1433
  safe(async ({ licenseKey }) => {
1393
1434
  const result = await activateLicense(licenseKey.trim());
1394
- const lines = [
1435
+ const lines = result.warning ? [
1436
+ `License key activated and stored (product: ${result.productName}).`,
1437
+ `Warning: ${result.warning}`,
1438
+ ...result.seatLimit > 0 ? [`Seats in use: ${result.seatsUsed}/${result.seatLimit}.`] : []
1439
+ ] : [
1395
1440
  `License activated for ${result.productName}. Pro installs are unlocked on this machine.`,
1396
1441
  ...result.seatLimit > 0 ? [`Seats in use: ${result.seatsUsed}/${result.seatLimit}.`] : [],
1397
- ...result.warning ? [`Warning: ${result.warning}`] : [],
1398
1442
  "",
1399
1443
  'Try it: install_components with a pro item, e.g. ["agent-progress"].'
1400
1444
  ];
@@ -1405,7 +1449,7 @@ ${proPitch(lockedPro)}`;
1405
1449
  "license_status",
1406
1450
  {
1407
1451
  title: "Check Pro license status",
1408
- description: "Whether a BoardUI Pro license is active on this machine (key is shown masked).",
1452
+ description: "Validates the stored BoardUI Pro license against Lemon Squeezy (product, status, seats) \u2014 not just whether a key file exists. Key is shown masked.",
1409
1453
  annotations: { readOnlyHint: true }
1410
1454
  },
1411
1455
  safe(async () => {
@@ -1415,8 +1459,27 @@ ${proPitch(lockedPro)}`;
1415
1459
  `No Pro license on this machine. Pro items need a one-time purchase: ${PRICING_URL} \u2014 if the user already purchased, ask for their license key and call activate_license.`
1416
1460
  );
1417
1461
  }
1462
+ let validation;
1463
+ try {
1464
+ validation = await validateStoredLicense();
1465
+ } catch {
1466
+ return text(
1467
+ `A license key is stored (${maskKey(license.licenseKey)}) but the license server could not be reached to validate it. Pro installs validate server-side on every download, so try one to find out.`
1468
+ );
1469
+ }
1470
+ if (!validation || !validation.valid) {
1471
+ return text(
1472
+ `A license key is stored (${maskKey(license.licenseKey)}) but Lemon Squeezy rejects it: ${validation?.error ?? "not valid"}. Ask the user to re-check the key from their receipt, or contact hi@boardui.com.`
1473
+ );
1474
+ }
1475
+ const seats = validation.seatLimit && validation.seatLimit > 0 ? ` Seats: ${validation.seatsUsed}/${validation.seatLimit}.` : "";
1476
+ if (validation.unknownProduct) {
1477
+ return text(
1478
+ `License key ${maskKey(license.licenseKey)} is valid and ${validation.status} for "${validation.productName}", which this CLI version does not recognize as BoardUI Pro.${seats} The server has the final say \u2014 try a pro install; if it is refused, update the CLI or contact hi@boardui.com.`
1479
+ );
1480
+ }
1418
1481
  return text(
1419
- `Pro license active: ${maskKey(license.licenseKey)} (${license.instanceName || "stored locally"}). Pro components and templates install like free ones.`
1482
+ `Pro license valid and ${validation.status}: ${maskKey(license.licenseKey)} ("${validation.productName}").${seats} Pro components and templates install like free ones.`
1420
1483
  );
1421
1484
  })
1422
1485
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boardui",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Add BoardUI components to your project.",
5
5
  "license": "MIT",
6
6
  "type": "module",