starwind 1.13.0 → 1.14.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/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "starwind",
9
- version: "1.13.0",
9
+ version: "1.14.0",
10
10
  description: "Add beautifully designed components to your Astro applications",
11
11
  license: "MIT",
12
12
  author: {
@@ -58,7 +58,7 @@ var package_default = {
58
58
  },
59
59
  dependencies: {
60
60
  "@clack/prompts": "^0.11.0",
61
- "@starwind-ui/core": "1.13.0",
61
+ "@starwind-ui/core": "1.14.0",
62
62
  chalk: "^5.6.2",
63
63
  commander: "^14.0.2",
64
64
  execa: "^9.6.0",
@@ -79,7 +79,7 @@ var package_default = {
79
79
  };
80
80
 
81
81
  // src/commands/add.ts
82
- import * as p6 from "@clack/prompts";
82
+ import * as p9 from "@clack/prompts";
83
83
  import { execa as execa2 } from "execa";
84
84
 
85
85
  // src/utils/constants.ts
@@ -971,7 +971,7 @@ async function isValidComponent(component, availableComponents) {
971
971
 
972
972
  // src/commands/init.ts
973
973
  import path2 from "path";
974
- import * as p5 from "@clack/prompts";
974
+ import * as p8 from "@clack/prompts";
975
975
  import semver4 from "semver";
976
976
 
977
977
  // src/templates/starwind.css.ts
@@ -1212,10 +1212,258 @@ ${content}`;
1212
1212
  }
1213
1213
  }
1214
1214
 
1215
+ // src/utils/env.ts
1216
+ import * as p5 from "@clack/prompts";
1217
+ import fs4 from "fs-extra";
1218
+ var ENV_LOCAL_PATH = ".env.local";
1219
+ var GITIGNORE_PATH = ".gitignore";
1220
+ var STARWIND_ENV_CONTENT = `# Starwind Pro registry setup
1221
+ STARWIND_LICENSE_KEY=your_starwind_pro_license_key
1222
+ `;
1223
+ var DEFAULT_GITIGNORE_CONTENT = `# build output
1224
+ dist/
1225
+
1226
+ # generated types
1227
+ .astro/
1228
+
1229
+ # dependencies
1230
+ node_modules/
1231
+
1232
+ # logs
1233
+ npm-debug.log*
1234
+ yarn-debug.log*
1235
+ yarn-error.log*
1236
+ pnpm-debug.log*
1237
+
1238
+ # environment variables
1239
+ .env
1240
+ .env.local
1241
+ .env.production
1242
+
1243
+ # macOS-specific files
1244
+ .DS_Store
1245
+
1246
+ # jetbrains setting folder
1247
+ .idea/
1248
+ `;
1249
+ function hasStarwindLicenseKey(content) {
1250
+ return /^STARWIND_LICENSE_KEY\s*=/m.test(content);
1251
+ }
1252
+ function hasEnvLocalInGitignore(content) {
1253
+ const lines = content.split(/\r?\n/);
1254
+ return lines.some((line) => {
1255
+ const trimmed = line.trim();
1256
+ return trimmed === ".env.local" || trimmed === ".env.local/" || trimmed === ".env*" || trimmed === ".env.*" || trimmed === "*.local";
1257
+ });
1258
+ }
1259
+ async function setupEnvLocal() {
1260
+ try {
1261
+ const exists = await fileExists(ENV_LOCAL_PATH);
1262
+ if (exists) {
1263
+ const content = await fs4.readFile(ENV_LOCAL_PATH, "utf-8");
1264
+ if (hasStarwindLicenseKey(content)) {
1265
+ return true;
1266
+ }
1267
+ const newContent = STARWIND_ENV_CONTENT + "\n" + content;
1268
+ await fs4.writeFile(ENV_LOCAL_PATH, newContent, "utf-8");
1269
+ } else {
1270
+ await fs4.writeFile(ENV_LOCAL_PATH, STARWIND_ENV_CONTENT, "utf-8");
1271
+ }
1272
+ return true;
1273
+ } catch (error) {
1274
+ const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
1275
+ p5.log.error(highlighter.error(`Failed to setup .env.local: ${errorMessage}`));
1276
+ return false;
1277
+ }
1278
+ }
1279
+ async function setupGitignore() {
1280
+ try {
1281
+ const exists = await fileExists(GITIGNORE_PATH);
1282
+ if (exists) {
1283
+ const content = await fs4.readFile(GITIGNORE_PATH, "utf-8");
1284
+ if (hasEnvLocalInGitignore(content)) {
1285
+ return true;
1286
+ }
1287
+ const needsNewline = content.length > 0 && !content.endsWith("\n");
1288
+ const newContent = content + (needsNewline ? "\n" : "") + ".env.local\n";
1289
+ await fs4.writeFile(GITIGNORE_PATH, newContent, "utf-8");
1290
+ } else {
1291
+ await fs4.writeFile(GITIGNORE_PATH, DEFAULT_GITIGNORE_CONTENT, "utf-8");
1292
+ }
1293
+ return true;
1294
+ } catch (error) {
1295
+ const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
1296
+ p5.log.error(highlighter.error(`Failed to setup .gitignore: ${errorMessage}`));
1297
+ return false;
1298
+ }
1299
+ }
1300
+ async function setupStarwindProEnv() {
1301
+ const envResult = await setupEnvLocal();
1302
+ const gitignoreResult = await setupGitignore();
1303
+ return envResult && gitignoreResult;
1304
+ }
1305
+
1306
+ // src/utils/layout.ts
1307
+ import * as p6 from "@clack/prompts";
1308
+ import fs5 from "fs-extra";
1309
+ var LAYOUT_PATHS = ["src/layouts/Layout.astro", "src/layouts/BaseLayout.astro"];
1310
+ async function findLayoutFile() {
1311
+ for (const layoutPath of LAYOUT_PATHS) {
1312
+ if (await fileExists(layoutPath)) {
1313
+ return layoutPath;
1314
+ }
1315
+ }
1316
+ return null;
1317
+ }
1318
+ function hasCssImport(content, cssPath) {
1319
+ const normalizedCssPath = cssPath.replace(/\\/g, "/");
1320
+ const importPatterns = [
1321
+ // import "@/styles/starwind.css"
1322
+ new RegExp(`import\\s+["']${escapeRegExp(normalizedCssPath)}["']`),
1323
+ // import "@/styles/starwind.css";
1324
+ new RegExp(`import\\s+["']${escapeRegExp(normalizedCssPath)}["'];?`),
1325
+ // Handle paths without @/ prefix if cssPath starts with src/
1326
+ ...normalizedCssPath.startsWith("src/") ? [new RegExp(`import\\s+["']@/${escapeRegExp(normalizedCssPath.slice(4))}["']`)] : [],
1327
+ // Handle @/ paths if cssPath doesn't have it
1328
+ ...!normalizedCssPath.startsWith("@/") ? [new RegExp(`import\\s+["']@/${escapeRegExp(normalizedCssPath)}["']`)] : []
1329
+ ];
1330
+ return importPatterns.some((pattern) => pattern.test(content));
1331
+ }
1332
+ function escapeRegExp(string) {
1333
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1334
+ }
1335
+ function toImportPath(cssPath) {
1336
+ const normalizedPath = cssPath.replace(/\\/g, "/");
1337
+ if (normalizedPath.startsWith("@/")) {
1338
+ return normalizedPath;
1339
+ }
1340
+ if (normalizedPath.startsWith("src/")) {
1341
+ return `@/${normalizedPath.slice(4)}`;
1342
+ }
1343
+ return `@/${normalizedPath}`;
1344
+ }
1345
+ function addCssImportToLayout(content, cssPath) {
1346
+ const importPath = toImportPath(cssPath);
1347
+ const importStatement = `import "${importPath}";`;
1348
+ const frontmatterMatch = content.match(/^---\r?\n/);
1349
+ if (frontmatterMatch) {
1350
+ const insertPosition = frontmatterMatch[0].length;
1351
+ return content.slice(0, insertPosition) + importStatement + "\n" + content.slice(insertPosition);
1352
+ } else {
1353
+ return `---
1354
+ ${importStatement}
1355
+ ---
1356
+
1357
+ ${content}`;
1358
+ }
1359
+ }
1360
+ async function setupLayoutCssImport(cssPath) {
1361
+ try {
1362
+ const layoutPath = await findLayoutFile();
1363
+ if (!layoutPath) {
1364
+ return true;
1365
+ }
1366
+ const content = await fs5.readFile(layoutPath, "utf-8");
1367
+ if (hasCssImport(content, cssPath)) {
1368
+ return true;
1369
+ }
1370
+ const updatedContent = addCssImportToLayout(content, cssPath);
1371
+ await fs5.writeFile(layoutPath, updatedContent, "utf-8");
1372
+ return true;
1373
+ } catch (error) {
1374
+ const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
1375
+ p6.log.error(highlighter.error(`Failed to setup CSS import in layout: ${errorMessage}`));
1376
+ return false;
1377
+ }
1378
+ }
1379
+
1380
+ // src/utils/tsconfig.ts
1381
+ import * as p7 from "@clack/prompts";
1382
+ var REQUIRED_TSCONFIG = {
1383
+ extends: "astro/tsconfigs/strict",
1384
+ compilerOptions: {
1385
+ baseUrl: ".",
1386
+ paths: {
1387
+ "@/*": ["src/*"]
1388
+ }
1389
+ }
1390
+ };
1391
+ function validateTsConfig(config) {
1392
+ const hasExtends = config.extends === REQUIRED_TSCONFIG.extends;
1393
+ const hasBaseUrl = config.compilerOptions?.baseUrl === REQUIRED_TSCONFIG.compilerOptions.baseUrl;
1394
+ const paths = config.compilerOptions?.paths;
1395
+ const hasPathAlias = paths !== void 0 && "@/*" in paths && Array.isArray(paths["@/*"]) && paths["@/*"].includes("src/*");
1396
+ return {
1397
+ hasExtends,
1398
+ hasBaseUrl,
1399
+ hasPathAlias,
1400
+ isComplete: hasExtends && hasBaseUrl && hasPathAlias
1401
+ };
1402
+ }
1403
+ function mergeTsConfig(existingConfig) {
1404
+ const validation = validateTsConfig(existingConfig);
1405
+ if (validation.isComplete) {
1406
+ return existingConfig;
1407
+ }
1408
+ const merged = { ...existingConfig };
1409
+ if (!validation.hasExtends) {
1410
+ merged.extends = REQUIRED_TSCONFIG.extends;
1411
+ }
1412
+ if (!merged.compilerOptions) {
1413
+ merged.compilerOptions = {};
1414
+ }
1415
+ if (!validation.hasBaseUrl) {
1416
+ merged.compilerOptions.baseUrl = REQUIRED_TSCONFIG.compilerOptions.baseUrl;
1417
+ }
1418
+ if (!validation.hasPathAlias) {
1419
+ if (!merged.compilerOptions.paths) {
1420
+ merged.compilerOptions.paths = {};
1421
+ }
1422
+ if (!merged.compilerOptions.paths["@/*"] || !merged.compilerOptions.paths["@/*"].includes("src/*")) {
1423
+ merged.compilerOptions.paths["@/*"] = REQUIRED_TSCONFIG.compilerOptions.paths["@/*"];
1424
+ }
1425
+ }
1426
+ return merged;
1427
+ }
1428
+ function createDefaultTsConfig() {
1429
+ return {
1430
+ extends: REQUIRED_TSCONFIG.extends,
1431
+ compilerOptions: {
1432
+ baseUrl: REQUIRED_TSCONFIG.compilerOptions.baseUrl,
1433
+ paths: {
1434
+ "@/*": [...REQUIRED_TSCONFIG.compilerOptions.paths["@/*"]]
1435
+ }
1436
+ }
1437
+ };
1438
+ }
1439
+ async function setupTsConfig() {
1440
+ const TSCONFIG_PATH = "tsconfig.json";
1441
+ try {
1442
+ const exists = await fileExists(TSCONFIG_PATH);
1443
+ if (exists) {
1444
+ const existingConfig = await readJsonFile(TSCONFIG_PATH);
1445
+ const validation = validateTsConfig(existingConfig);
1446
+ if (validation.isComplete) {
1447
+ return true;
1448
+ }
1449
+ const mergedConfig = mergeTsConfig(existingConfig);
1450
+ await writeJsonFile(TSCONFIG_PATH, mergedConfig);
1451
+ } else {
1452
+ const defaultConfig2 = createDefaultTsConfig();
1453
+ await writeJsonFile(TSCONFIG_PATH, defaultConfig2);
1454
+ }
1455
+ return true;
1456
+ } catch (error) {
1457
+ const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
1458
+ p7.log.error(highlighter.error(`Failed to setup tsconfig.json: ${errorMessage}`));
1459
+ return false;
1460
+ }
1461
+ }
1462
+
1215
1463
  // src/commands/init.ts
1216
1464
  async function init(withinAdd = false, options) {
1217
1465
  if (!withinAdd) {
1218
- p5.intro(highlighter.title(" Welcome to the Starwind CLI "));
1466
+ p8.intro(highlighter.title(" Welcome to the Starwind CLI "));
1219
1467
  }
1220
1468
  try {
1221
1469
  if (!await fileExists("package.json")) {
@@ -1234,13 +1482,13 @@ async function init(withinAdd = false, options) {
1234
1482
  twBaseColor: "neutral"
1235
1483
  };
1236
1484
  if (!withinAdd) {
1237
- p5.log.info("Using default configuration values");
1485
+ p8.log.info("Using default configuration values");
1238
1486
  }
1239
1487
  } else {
1240
- configChoices = await p5.group(
1488
+ configChoices = await p8.group(
1241
1489
  {
1242
1490
  // ask where to install components
1243
- installLocation: () => p5.text({
1491
+ installLocation: () => p8.text({
1244
1492
  message: "What is your components directory?",
1245
1493
  placeholder: PATHS.LOCAL_COMPONENTS_DIR,
1246
1494
  initialValue: PATHS.LOCAL_COMPONENTS_DIR,
@@ -1257,7 +1505,7 @@ async function init(withinAdd = false, options) {
1257
1505
  }
1258
1506
  }),
1259
1507
  // ask where to add the css file
1260
- cssFile: () => p5.text({
1508
+ cssFile: () => p8.text({
1261
1509
  message: `Where would you like to add the Tailwind ${highlighter.info(".css")} file?`,
1262
1510
  placeholder: PATHS.LOCAL_CSS_FILE,
1263
1511
  initialValue: PATHS.LOCAL_CSS_FILE,
@@ -1278,7 +1526,7 @@ async function init(withinAdd = false, options) {
1278
1526
  }
1279
1527
  }
1280
1528
  }),
1281
- twBaseColor: () => p5.select({
1529
+ twBaseColor: () => p8.select({
1282
1530
  message: "What Tailwind base color would you like to use?",
1283
1531
  initialValue: "neutral",
1284
1532
  options: [
@@ -1294,7 +1542,7 @@ async function init(withinAdd = false, options) {
1294
1542
  // On Cancel callback that wraps the group
1295
1543
  // So if the user cancels one of the prompts in the group this function will be called
1296
1544
  onCancel: () => {
1297
- p5.cancel("Operation cancelled.");
1545
+ p8.cancel("Operation cancelled.");
1298
1546
  process.exit(0);
1299
1547
  }
1300
1548
  }
@@ -1322,6 +1570,17 @@ async function init(withinAdd = false, options) {
1322
1570
  return "Astro config setup completed";
1323
1571
  }
1324
1572
  });
1573
+ configTasks.push({
1574
+ title: "Setup TypeScript path aliases",
1575
+ task: async () => {
1576
+ const success = await setupTsConfig();
1577
+ if (!success) {
1578
+ throw new Error("Failed to setup tsconfig.json");
1579
+ }
1580
+ await sleep(250);
1581
+ return "TypeScript path aliases configured";
1582
+ }
1583
+ });
1325
1584
  const cssFileExists = await fileExists(configChoices.cssFile);
1326
1585
  let updatedTailwindConfig = tailwindConfig;
1327
1586
  if (configChoices.twBaseColor !== "neutral") {
@@ -1331,15 +1590,15 @@ async function init(withinAdd = false, options) {
1331
1590
  );
1332
1591
  }
1333
1592
  if (cssFileExists) {
1334
- const shouldOverride = options?.defaults ? true : await p5.confirm({
1593
+ const shouldOverride = options?.defaults ? true : await p8.confirm({
1335
1594
  message: `${highlighter.info(configChoices.cssFile)} already exists. Do you want to override it?`
1336
1595
  });
1337
- if (p5.isCancel(shouldOverride)) {
1338
- p5.cancel("Operation cancelled");
1596
+ if (p8.isCancel(shouldOverride)) {
1597
+ p8.cancel("Operation cancelled");
1339
1598
  return process.exit(0);
1340
1599
  }
1341
1600
  if (!shouldOverride) {
1342
- p5.log.info("Skipping Tailwind CSS configuration");
1601
+ p8.log.info("Skipping Tailwind CSS configuration");
1343
1602
  } else {
1344
1603
  configTasks.push({
1345
1604
  title: "Creating Tailwind CSS configuration",
@@ -1360,6 +1619,17 @@ async function init(withinAdd = false, options) {
1360
1619
  }
1361
1620
  });
1362
1621
  }
1622
+ configTasks.push({
1623
+ title: "Adding CSS import to layout",
1624
+ task: async () => {
1625
+ const success = await setupLayoutCssImport(configChoices.cssFile);
1626
+ if (!success) {
1627
+ throw new Error("Failed to add CSS import to layout");
1628
+ }
1629
+ await sleep(250);
1630
+ return "CSS import added to layout";
1631
+ }
1632
+ });
1363
1633
  configTasks.push({
1364
1634
  title: "Updating project configuration",
1365
1635
  task: async () => {
@@ -1383,7 +1653,7 @@ async function init(withinAdd = false, options) {
1383
1653
  const alreadyHasPro = await hasStarwindProRegistry();
1384
1654
  if (!alreadyHasPro) {
1385
1655
  if (!withinAdd) {
1386
- p5.log.info(highlighter.info("Setting up Starwind Pro configuration..."));
1656
+ p8.log.info(highlighter.info("Setting up Starwind Pro configuration..."));
1387
1657
  }
1388
1658
  configTasks.push({
1389
1659
  title: "Setting up Starwind Pro registry",
@@ -1393,9 +1663,20 @@ async function init(withinAdd = false, options) {
1393
1663
  return "Configured Starwind Pro registry in components.json";
1394
1664
  }
1395
1665
  });
1666
+ configTasks.push({
1667
+ title: "Setting up Starwind Pro environment",
1668
+ task: async () => {
1669
+ const success = await setupStarwindProEnv();
1670
+ if (!success) {
1671
+ throw new Error("Failed to setup Starwind Pro environment");
1672
+ }
1673
+ await sleep(250);
1674
+ return "Created .env.local and updated .gitignore";
1675
+ }
1676
+ });
1396
1677
  } else {
1397
1678
  if (!withinAdd) {
1398
- p5.log.info(highlighter.info("Starwind Pro registry already configured"));
1679
+ p8.log.info(highlighter.info("Starwind Pro registry already configured"));
1399
1680
  }
1400
1681
  }
1401
1682
  }
@@ -1403,16 +1684,16 @@ async function init(withinAdd = false, options) {
1403
1684
  if (pkg.dependencies?.astro) {
1404
1685
  const astroVersion = pkg.dependencies.astro.replace(/^\^|~/, "");
1405
1686
  if (!semver4.gte(astroVersion, MIN_ASTRO_VERSION)) {
1406
- const shouldUpgrade = options?.defaults ? true : await p5.confirm({
1687
+ const shouldUpgrade = options?.defaults ? true : await p8.confirm({
1407
1688
  message: `Starwind requires Astro v${MIN_ASTRO_VERSION} or higher. Would you like to upgrade from v${astroVersion}?`,
1408
1689
  initialValue: true
1409
1690
  });
1410
- if (p5.isCancel(shouldUpgrade)) {
1411
- p5.cancel("Operation cancelled");
1691
+ if (p8.isCancel(shouldUpgrade)) {
1692
+ p8.cancel("Operation cancelled");
1412
1693
  return process.exit(0);
1413
1694
  }
1414
1695
  if (!shouldUpgrade) {
1415
- p5.cancel("Astro v5 or higher is required to use Starwind");
1696
+ p8.cancel("Astro v5 or higher is required to use Starwind");
1416
1697
  return process.exit(1);
1417
1698
  }
1418
1699
  installTasks.push({
@@ -1424,16 +1705,16 @@ async function init(withinAdd = false, options) {
1424
1705
  });
1425
1706
  }
1426
1707
  } else {
1427
- const shouldInstall2 = options?.defaults ? true : await p5.confirm({
1708
+ const shouldInstall2 = options?.defaults ? true : await p8.confirm({
1428
1709
  message: `Starwind requires Astro v${MIN_ASTRO_VERSION} or higher. Would you like to install it?`,
1429
1710
  initialValue: true
1430
1711
  });
1431
- if (p5.isCancel(shouldInstall2)) {
1432
- p5.cancel("Operation cancelled");
1712
+ if (p8.isCancel(shouldInstall2)) {
1713
+ p8.cancel("Operation cancelled");
1433
1714
  return process.exit(0);
1434
1715
  }
1435
1716
  if (!shouldInstall2) {
1436
- p5.cancel("Astro is required to use Starwind");
1717
+ p8.cancel("Astro is required to use Starwind");
1437
1718
  return process.exit(1);
1438
1719
  }
1439
1720
  installTasks.push({
@@ -1445,11 +1726,11 @@ async function init(withinAdd = false, options) {
1445
1726
  });
1446
1727
  }
1447
1728
  const otherPackages = getOtherPackages();
1448
- const shouldInstall = options?.defaults ? true : await p5.confirm({
1729
+ const shouldInstall = options?.defaults ? true : await p8.confirm({
1449
1730
  message: `Install ${highlighter.info(otherPackages.join(", "))} using ${highlighter.info(pm)}?`
1450
1731
  });
1451
- if (p5.isCancel(shouldInstall)) {
1452
- p5.cancel("Operation cancelled");
1732
+ if (p8.isCancel(shouldInstall)) {
1733
+ p8.cancel("Operation cancelled");
1453
1734
  return process.exit(0);
1454
1735
  }
1455
1736
  if (shouldInstall) {
@@ -1461,15 +1742,15 @@ async function init(withinAdd = false, options) {
1461
1742
  }
1462
1743
  });
1463
1744
  } else {
1464
- p5.log.warn(
1745
+ p8.log.warn(
1465
1746
  highlighter.warn(`Skipped installation of packages. Make sure to install them manually`)
1466
1747
  );
1467
1748
  }
1468
1749
  if (installTasks.length > 0) {
1469
- await p5.tasks(installTasks);
1750
+ await p8.tasks(installTasks);
1470
1751
  }
1471
1752
  if (configTasks.length > 0) {
1472
- await p5.tasks(configTasks);
1753
+ await p8.tasks(configTasks);
1473
1754
  }
1474
1755
  await sleep(250);
1475
1756
  let nextStepsMessage = `Make sure your layout imports the ${highlighter.infoBright(configChoices.cssFile)} file`;
@@ -1479,17 +1760,17 @@ async function init(withinAdd = false, options) {
1479
1760
  Starwind Pro is now configured! You can install pro components using:
1480
1761
  ${highlighter.info("npx starwind@latest add @starwind-pro/component-name")}
1481
1762
 
1482
- Make sure to set your ${highlighter.infoBright("STARWIND_LICENSE_KEY")} environment variable.`;
1763
+ Make sure to set your ${highlighter.infoBright("STARWIND_LICENSE_KEY")} environment variable in ${highlighter.infoBright(".env.local")}.`;
1483
1764
  }
1484
- p5.note(nextStepsMessage, "Next steps");
1765
+ p8.note(nextStepsMessage, "Next steps");
1485
1766
  if (!withinAdd) {
1486
1767
  sleep(1e3);
1487
- const outroMessage = options?.pro ? "Enjoy using Starwind UI with Pro components! \u{1F680}\u2728" : "Enjoy using Starwind UI \u{1F680}";
1488
- p5.outro(outroMessage);
1768
+ const outroMessage = options?.pro ? "Enjoy using Starwind UI with Pro components! \u{1F680}" : "Enjoy using Starwind UI \u{1F680}";
1769
+ p8.outro(outroMessage);
1489
1770
  }
1490
1771
  } catch (error) {
1491
- p5.log.error(error instanceof Error ? error.message : "Failed to add components");
1492
- p5.cancel("Operation cancelled");
1772
+ p8.log.error(error instanceof Error ? error.message : "Failed to add components");
1773
+ p8.cancel("Operation cancelled");
1493
1774
  process.exit(1);
1494
1775
  }
1495
1776
  }
@@ -1497,21 +1778,21 @@ Make sure to set your ${highlighter.infoBright("STARWIND_LICENSE_KEY")} environm
1497
1778
  // src/commands/add.ts
1498
1779
  async function add(components, options) {
1499
1780
  try {
1500
- p6.intro(highlighter.title(" Welcome to the Starwind CLI "));
1781
+ p9.intro(highlighter.title(" Welcome to the Starwind CLI "));
1501
1782
  const configExists = await fileExists(PATHS.LOCAL_CONFIG_FILE);
1502
1783
  if (!configExists) {
1503
- const shouldInit = await p6.confirm({
1784
+ const shouldInit = await p9.confirm({
1504
1785
  message: `Starwind configuration not found. Would you like to run ${highlighter.info("starwind init")} now?`,
1505
1786
  initialValue: true
1506
1787
  });
1507
- if (p6.isCancel(shouldInit)) {
1508
- p6.cancel("Operation cancelled");
1788
+ if (p9.isCancel(shouldInit)) {
1789
+ p9.cancel("Operation cancelled");
1509
1790
  process.exit(0);
1510
1791
  }
1511
1792
  if (shouldInit) {
1512
1793
  await init(true);
1513
1794
  } else {
1514
- p6.log.error(
1795
+ p9.log.error(
1515
1796
  `Please initialize starwind with ${highlighter.info("starwind init")} before adding components`
1516
1797
  );
1517
1798
  process.exit(1);
@@ -1523,7 +1804,7 @@ async function add(components, options) {
1523
1804
  if (options?.all) {
1524
1805
  const availableComponents = await getAllComponents();
1525
1806
  componentsToInstall = availableComponents.map((c) => c.name);
1526
- p6.log.info(`Adding all ${componentsToInstall.length} available components...`);
1807
+ p9.log.info(`Adding all ${componentsToInstall.length} available components...`);
1527
1808
  } else if (components && components.length > 0) {
1528
1809
  const regularComponents = [];
1529
1810
  for (const component of components) {
@@ -1536,16 +1817,16 @@ async function add(components, options) {
1536
1817
  if (registryComponents.length > 0) {
1537
1818
  const hasProRegistry = await hasStarwindProRegistry();
1538
1819
  if (!hasProRegistry) {
1539
- const shouldSetupPro = await p6.confirm({
1820
+ const shouldSetupPro = await p9.confirm({
1540
1821
  message: `Starwind Pro registry not configured. Would you like to set it up now to install ${registryComponents.join(", ")}?`,
1541
1822
  initialValue: true
1542
1823
  });
1543
- if (p6.isCancel(shouldSetupPro)) {
1544
- p6.cancel("Operation cancelled");
1824
+ if (p9.isCancel(shouldSetupPro)) {
1825
+ p9.cancel("Operation cancelled");
1545
1826
  process.exit(0);
1546
1827
  }
1547
1828
  if (shouldSetupPro) {
1548
- p6.log.info(highlighter.info("Setting up Starwind Pro configuration..."));
1829
+ p9.log.info(highlighter.info("Setting up Starwind Pro configuration..."));
1549
1830
  let cssFile = PATHS.LOCAL_CSS_FILE;
1550
1831
  let baseColor = "neutral";
1551
1832
  try {
@@ -1555,14 +1836,14 @@ async function add(components, options) {
1555
1836
  } catch {
1556
1837
  }
1557
1838
  await setupShadcnProConfig(cssFile, baseColor);
1558
- p6.log.success("Starwind Pro registry configured successfully!");
1839
+ p9.log.success("Starwind Pro registry configured successfully!");
1559
1840
  } else {
1560
- p6.log.error("Cannot install registry components without Starwind Pro configuration");
1561
- p6.cancel("Operation cancelled");
1841
+ p9.log.error("Cannot install registry components without Starwind Pro configuration");
1842
+ p9.cancel("Operation cancelled");
1562
1843
  process.exit(1);
1563
1844
  }
1564
1845
  }
1565
- p6.log.info(`Installing registry components: ${registryComponents.join(", ")}`);
1846
+ p9.log.info(`Installing registry components: ${registryComponents.join(", ")}`);
1566
1847
  const [command, baseArgs] = await getShadcnCommand();
1567
1848
  registryResults = {
1568
1849
  success: [],
@@ -1570,7 +1851,7 @@ async function add(components, options) {
1570
1851
  };
1571
1852
  for (const registryComponent of registryComponents) {
1572
1853
  try {
1573
- p6.log.info(`Installing ${highlighter.info(registryComponent)} via shadcn...`);
1854
+ p9.log.info(`Installing ${highlighter.info(registryComponent)} via shadcn...`);
1574
1855
  await execa2(command, [...baseArgs, "add", registryComponent], {
1575
1856
  stdio: "inherit",
1576
1857
  cwd: process.cwd()
@@ -1597,7 +1878,7 @@ async function add(components, options) {
1597
1878
  Promise.resolve({ valid: [], invalid: [] })
1598
1879
  );
1599
1880
  if (invalid.length > 0) {
1600
- p6.log.warn(
1881
+ p9.log.warn(
1601
1882
  `${highlighter.warn("Invalid components found:")}
1602
1883
  ${invalid.map((name) => ` ${name}`).join("\n")}`
1603
1884
  );
@@ -1605,22 +1886,22 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
1605
1886
  if (valid.length > 0) {
1606
1887
  componentsToInstall = valid;
1607
1888
  } else if (registryComponents.length === 0) {
1608
- p6.log.warn(`${highlighter.warn("No valid components to install")}`);
1609
- p6.cancel("Operation cancelled");
1889
+ p9.log.warn(`${highlighter.warn("No valid components to install")}`);
1890
+ p9.cancel("Operation cancelled");
1610
1891
  return process.exit(0);
1611
1892
  }
1612
1893
  }
1613
1894
  } else {
1614
1895
  const selected = await selectComponents();
1615
1896
  if (!selected) {
1616
- p6.cancel("No components selected");
1897
+ p9.cancel("No components selected");
1617
1898
  return process.exit(0);
1618
1899
  }
1619
1900
  componentsToInstall = selected;
1620
1901
  }
1621
1902
  if (componentsToInstall.length === 0 && registryComponents.length === 0) {
1622
- p6.log.warn(`${highlighter.warn("No components selected")}`);
1623
- p6.cancel("Operation cancelled");
1903
+ p9.log.warn(`${highlighter.warn("No components selected")}`);
1904
+ p9.cancel("Operation cancelled");
1624
1905
  return process.exit(0);
1625
1906
  }
1626
1907
  const results = {
@@ -1664,82 +1945,82 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
1664
1945
  try {
1665
1946
  await updateConfig({ components: installedComponents }, { appendComponents: true });
1666
1947
  } catch (error) {
1667
- p6.log.error(
1948
+ p9.log.error(
1668
1949
  `Failed to update config: ${error instanceof Error ? error.message : "Unknown error"}`
1669
1950
  );
1670
1951
  process.exit(1);
1671
1952
  }
1672
1953
  }
1673
- p6.log.message(`
1954
+ p9.log.message(`
1674
1955
 
1675
1956
  ${highlighter.underline("Installation Summary")}`);
1676
1957
  if (results.failed.length > 0) {
1677
- p6.log.error(
1958
+ p9.log.error(
1678
1959
  `${highlighter.error("Failed to install components:")}
1679
1960
  ${results.failed.map((r) => ` ${r.name} - ${r.status === "failed" ? r.error : "Unknown error"}`).join("\n")}`
1680
1961
  );
1681
1962
  }
1682
1963
  if (results.skipped.length > 0) {
1683
- p6.log.warn(
1964
+ p9.log.warn(
1684
1965
  `${highlighter.warn("Skipped components (already installed):")}
1685
1966
  ${results.skipped.map((r) => ` ${r.name} v${r.version}`).join("\n")}`
1686
1967
  );
1687
1968
  }
1688
1969
  if (results.installed.length > 0) {
1689
- p6.log.success(
1970
+ p9.log.success(
1690
1971
  `${highlighter.success("Successfully installed components:")}
1691
1972
  ${results.installed.map((r) => ` ${r.name} v${r.version}`).join("\n")}`
1692
1973
  );
1693
1974
  }
1694
1975
  if (registryResults) {
1695
1976
  if (registryResults.failed.length > 0) {
1696
- p6.log.error(
1977
+ p9.log.error(
1697
1978
  `${highlighter.error("Failed to install registry components:")}
1698
1979
  ${registryResults.failed.map((name) => ` ${name} - see the error message above for further details`).join("\n")}`
1699
1980
  );
1700
1981
  }
1701
1982
  if (registryResults.success.length > 0) {
1702
- p6.log.success(
1983
+ p9.log.success(
1703
1984
  `${highlighter.success("Successfully installed registry components:")}
1704
1985
  ${registryResults.success.map((name) => ` ${name}`).join("\n")}`
1705
1986
  );
1706
1987
  }
1707
1988
  }
1708
1989
  await sleep(1e3);
1709
- p6.outro("Enjoy using Starwind UI \u{1F680}");
1990
+ p9.outro("Enjoy using Starwind UI \u{1F680}");
1710
1991
  } catch (error) {
1711
- p6.log.error(error instanceof Error ? error.message : "Failed to add components");
1712
- p6.cancel("Operation cancelled");
1992
+ p9.log.error(error instanceof Error ? error.message : "Failed to add components");
1993
+ p9.cancel("Operation cancelled");
1713
1994
  process.exit(1);
1714
1995
  }
1715
1996
  }
1716
1997
 
1717
1998
  // src/commands/remove.ts
1718
- import * as p7 from "@clack/prompts";
1999
+ import * as p10 from "@clack/prompts";
1719
2000
  async function remove(components, options) {
1720
2001
  try {
1721
- p7.intro(highlighter.title(" Welcome to the Starwind CLI "));
2002
+ p10.intro(highlighter.title(" Welcome to the Starwind CLI "));
1722
2003
  const configExists = await fileExists(PATHS.LOCAL_CONFIG_FILE);
1723
2004
  if (!configExists) {
1724
- p7.log.error("No Starwind configuration found. Please run starwind init first.");
2005
+ p10.log.error("No Starwind configuration found. Please run starwind init first.");
1725
2006
  process.exit(1);
1726
2007
  }
1727
2008
  const config = await getConfig();
1728
2009
  const installedComponents = config.components;
1729
2010
  if (installedComponents.length === 0) {
1730
- p7.log.warn("No components are currently installed.");
2011
+ p10.log.warn("No components are currently installed.");
1731
2012
  process.exit(0);
1732
2013
  }
1733
2014
  let componentsToRemove = [];
1734
2015
  if (options?.all) {
1735
2016
  componentsToRemove = installedComponents.map((comp) => comp.name);
1736
- p7.log.info(`Removing all ${componentsToRemove.length} installed components...`);
2017
+ p10.log.info(`Removing all ${componentsToRemove.length} installed components...`);
1737
2018
  } else if (components && components.length > 0) {
1738
2019
  const invalid = components.filter(
1739
2020
  (comp) => !installedComponents.some((ic) => ic.name === comp)
1740
2021
  );
1741
2022
  if (invalid.length > 0) {
1742
- p7.log.warn(
2023
+ p10.log.warn(
1743
2024
  `${highlighter.warn("Components not found:")}
1744
2025
  ${invalid.map((name) => ` ${name}`).join("\n")}`
1745
2026
  );
@@ -1748,7 +2029,7 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
1748
2029
  (comp) => installedComponents.some((ic) => ic.name === comp)
1749
2030
  );
1750
2031
  if (componentsToRemove.length === 0) {
1751
- p7.log.warn("No valid components to remove");
2032
+ p10.log.warn("No valid components to remove");
1752
2033
  process.exit(0);
1753
2034
  }
1754
2035
  } else {
@@ -1756,25 +2037,25 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
1756
2037
  value: comp.name,
1757
2038
  label: comp.name
1758
2039
  }));
1759
- const selected = await p7.multiselect({
2040
+ const selected = await p10.multiselect({
1760
2041
  message: "Select components to remove",
1761
2042
  options: choices
1762
2043
  });
1763
- if (p7.isCancel(selected)) {
1764
- p7.cancel("Operation cancelled");
2044
+ if (p10.isCancel(selected)) {
2045
+ p10.cancel("Operation cancelled");
1765
2046
  process.exit(0);
1766
2047
  }
1767
2048
  componentsToRemove = selected;
1768
2049
  }
1769
2050
  if (componentsToRemove.length === 0) {
1770
- p7.log.warn("No components selected for removal");
2051
+ p10.log.warn("No components selected for removal");
1771
2052
  process.exit(0);
1772
2053
  }
1773
- const confirmed = await p7.confirm({
2054
+ const confirmed = await p10.confirm({
1774
2055
  message: `Remove ${componentsToRemove.map((comp) => highlighter.info(comp)).join(", ")} ${componentsToRemove.length > 1 ? "components" : "component"}?`
1775
2056
  });
1776
- if (!confirmed || p7.isCancel(confirmed)) {
1777
- p7.cancel("Operation cancelled");
2057
+ if (!confirmed || p10.isCancel(confirmed)) {
2058
+ p10.cancel("Operation cancelled");
1778
2059
  process.exit(0);
1779
2060
  }
1780
2061
  const results = {
@@ -1799,61 +2080,61 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
1799
2080
  },
1800
2081
  { appendComponents: false }
1801
2082
  );
1802
- p7.log.message(`
2083
+ p10.log.message(`
1803
2084
 
1804
2085
  ${highlighter.underline("Removal Summary")}`);
1805
2086
  if (results.failed.length > 0) {
1806
- p7.log.error(
2087
+ p10.log.error(
1807
2088
  `${highlighter.error("Failed to remove components:")}
1808
2089
  ${results.failed.map((r) => ` ${r.name} - ${r.error}`).join("\n")}`
1809
2090
  );
1810
2091
  }
1811
2092
  if (results.removed.length > 0) {
1812
- p7.log.success(
2093
+ p10.log.success(
1813
2094
  `${highlighter.success("Successfully removed components:")}
1814
2095
  ${results.removed.map((r) => ` ${r.name}`).join("\n")}`
1815
2096
  );
1816
2097
  }
1817
2098
  await sleep(1e3);
1818
2099
  if (results.removed.length > 0) {
1819
- p7.outro("Components removed successfully \u{1F5D1}\uFE0F");
2100
+ p10.outro("Components removed successfully \u{1F5D1}\uFE0F");
1820
2101
  } else {
1821
- p7.cancel("Errors occurred while removing components");
2102
+ p10.cancel("Errors occurred while removing components");
1822
2103
  process.exit(1);
1823
2104
  }
1824
2105
  } catch (error) {
1825
- p7.log.error(error instanceof Error ? error.message : "Failed to remove components");
1826
- p7.cancel("Operation cancelled");
2106
+ p10.log.error(error instanceof Error ? error.message : "Failed to remove components");
2107
+ p10.cancel("Operation cancelled");
1827
2108
  process.exit(1);
1828
2109
  }
1829
2110
  }
1830
2111
 
1831
2112
  // src/commands/update.ts
1832
- import * as p8 from "@clack/prompts";
2113
+ import * as p11 from "@clack/prompts";
1833
2114
  async function update(components, options) {
1834
2115
  try {
1835
- p8.intro(highlighter.title(" Welcome to the Starwind CLI "));
2116
+ p11.intro(highlighter.title(" Welcome to the Starwind CLI "));
1836
2117
  const configExists = await fileExists(PATHS.LOCAL_CONFIG_FILE);
1837
2118
  if (!configExists) {
1838
- p8.log.error("No Starwind configuration found. Please run starwind init first.");
2119
+ p11.log.error("No Starwind configuration found. Please run starwind init first.");
1839
2120
  process.exit(1);
1840
2121
  }
1841
2122
  const config = await getConfig();
1842
2123
  const installedComponents = config.components;
1843
2124
  if (installedComponents.length === 0) {
1844
- p8.log.warn("No components are currently installed.");
2125
+ p11.log.warn("No components are currently installed.");
1845
2126
  process.exit(0);
1846
2127
  }
1847
2128
  let componentsToUpdate = [];
1848
2129
  if (options?.all) {
1849
2130
  componentsToUpdate = installedComponents.map((comp) => comp.name);
1850
- p8.log.info(`Checking updates for all ${componentsToUpdate.length} installed components...`);
2131
+ p11.log.info(`Checking updates for all ${componentsToUpdate.length} installed components...`);
1851
2132
  } else if (components && components.length > 0) {
1852
2133
  const invalid = components.filter(
1853
2134
  (comp) => !installedComponents.some((ic) => ic.name === comp)
1854
2135
  );
1855
2136
  if (invalid.length > 0) {
1856
- p8.log.warn(
2137
+ p11.log.warn(
1857
2138
  `${highlighter.warn("Components not found in project:")}
1858
2139
  ${invalid.map((name) => ` ${name}`).join("\n")}`
1859
2140
  );
@@ -1862,7 +2143,7 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
1862
2143
  (comp) => installedComponents.some((ic) => ic.name === comp)
1863
2144
  );
1864
2145
  if (componentsToUpdate.length === 0) {
1865
- p8.log.warn("No valid components to update");
2146
+ p11.log.warn("No valid components to update");
1866
2147
  process.exit(0);
1867
2148
  }
1868
2149
  } else {
@@ -1870,18 +2151,18 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
1870
2151
  value: comp.name,
1871
2152
  label: comp.name
1872
2153
  }));
1873
- const selected = await p8.multiselect({
2154
+ const selected = await p11.multiselect({
1874
2155
  message: "Select components to update",
1875
2156
  options: choices
1876
2157
  });
1877
- if (p8.isCancel(selected)) {
1878
- p8.cancel("Operation cancelled");
2158
+ if (p11.isCancel(selected)) {
2159
+ p11.cancel("Operation cancelled");
1879
2160
  process.exit(0);
1880
2161
  }
1881
2162
  componentsToUpdate = selected;
1882
2163
  }
1883
2164
  if (componentsToUpdate.length === 0) {
1884
- p8.log.warn("No components selected for update");
2165
+ p11.log.warn("No components selected for update");
1885
2166
  process.exit(0);
1886
2167
  }
1887
2168
  const results = {
@@ -1932,45 +2213,45 @@ ${invalid.map((name) => ` ${name}`).join("\n")}`
1932
2213
  { appendComponents: false }
1933
2214
  );
1934
2215
  } catch (error) {
1935
- p8.log.error(
2216
+ p11.log.error(
1936
2217
  `Failed to update config: ${error instanceof Error ? error.message : "Unknown error"}`
1937
2218
  );
1938
2219
  process.exit(1);
1939
2220
  }
1940
2221
  }
1941
- p8.log.message(`
2222
+ p11.log.message(`
1942
2223
 
1943
2224
  ${highlighter.underline("Update Summary")}`);
1944
2225
  if (results.failed.length > 0) {
1945
- p8.log.error(
2226
+ p11.log.error(
1946
2227
  `${highlighter.error("Failed to update components:")}
1947
2228
  ${results.failed.map((r) => ` ${r.name} - ${r.error}`).join("\n")}`
1948
2229
  );
1949
2230
  }
1950
2231
  if (results.skipped.length > 0) {
1951
- p8.log.info(
2232
+ p11.log.info(
1952
2233
  `${highlighter.info("Components already up to date or skipped:")}
1953
2234
  ${results.skipped.map((r) => ` ${r.name} (${r.oldVersion})`).join("\n")}`
1954
2235
  );
1955
2236
  }
1956
2237
  if (results.updated.length > 0) {
1957
- p8.log.success(
2238
+ p11.log.success(
1958
2239
  `${highlighter.success("Successfully updated components:")}
1959
2240
  ${results.updated.map((r) => ` ${r.name} (${r.oldVersion} \u2192 ${r.newVersion})`).join("\n")}`
1960
2241
  );
1961
2242
  }
1962
2243
  await sleep(1e3);
1963
2244
  if (results.updated.length > 0) {
1964
- p8.outro("Components updated successfully \u{1F680}");
2245
+ p11.outro("Components updated successfully \u{1F680}");
1965
2246
  } else if (results.skipped.length > 0 && results.failed.length === 0) {
1966
- p8.outro("Components already up to date or skipped \u2728");
2247
+ p11.outro("Components already up to date or skipped \u2728");
1967
2248
  } else {
1968
- p8.cancel("No components were updated");
2249
+ p11.cancel("No components were updated");
1969
2250
  process.exit(1);
1970
2251
  }
1971
2252
  } catch (error) {
1972
- p8.log.error(error instanceof Error ? error.message : "Failed to update components");
1973
- p8.cancel("Operation cancelled");
2253
+ p11.log.error(error instanceof Error ? error.message : "Failed to update components");
2254
+ p11.cancel("Operation cancelled");
1974
2255
  process.exit(1);
1975
2256
  }
1976
2257
  }