@foundrykit/cli 2.0.2 → 2.0.4

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
@@ -1586,35 +1586,54 @@ import inquirer3 from "inquirer";
1586
1586
  import fs4 from "fs-extra";
1587
1587
  import path4 from "path";
1588
1588
  function updateCommand() {
1589
- return new Command4("update").description("Update installed components").argument("[id]", "Component or block ID (omit to update all installed)").option("--opt", "interactively select which components to update, showing available upgrades").option("-p, --path <path>", "Custom installation path").action(async (id, options) => {
1589
+ return new Command4("update").description("Update installed components").argument("[id]", "Component or block ID (omit to update all installed)").option(
1590
+ "-o, --opt",
1591
+ "interactively select which components to update, showing available upgrades"
1592
+ ).option("-f, --force", "bypass cache and fetch fresh data from registry").option("-p, --path <path>", "Custom installation path").action(async (id, options) => {
1590
1593
  if (id) {
1591
1594
  try {
1592
1595
  console.log(chalk5.blue(`\u{1F504} Updating ${id}...`));
1593
- await addSingleComponent(id, { ...options, overwrite: true, force: true });
1596
+ await addSingleComponent(id, {
1597
+ ...options,
1598
+ overwrite: true,
1599
+ force: true
1600
+ });
1594
1601
  } catch (error) {
1595
1602
  console.error(chalk5.red(`\u274C Failed to update ${id}:`));
1596
- console.error(chalk5.red(error instanceof Error ? error.message : String(error)));
1603
+ console.error(
1604
+ chalk5.red(error instanceof Error ? error.message : String(error))
1605
+ );
1597
1606
  process.exit(1);
1598
1607
  }
1599
1608
  return;
1600
1609
  }
1601
1610
  const configPath = path4.join(process.cwd(), "foundrykit.config.json");
1602
1611
  if (!fs4.existsSync(configPath)) {
1603
- console.error(chalk5.red('\u274C FoundryKit not initialized. Run "foundrykit init" first.'));
1612
+ console.error(
1613
+ chalk5.red(
1614
+ '\u274C FoundryKit not initialized. Run "foundrykit init" first.'
1615
+ )
1616
+ );
1604
1617
  process.exit(1);
1605
1618
  }
1606
1619
  const config = await fs4.readJson(configPath);
1607
1620
  let installed = config.installedComponents ?? {};
1608
1621
  let installedIds = Object.keys(installed);
1609
1622
  if (installedIds.length === 0) {
1610
- console.log(chalk5.gray("No install tracking found. Scanning filesystem for installed components..."));
1623
+ console.log(
1624
+ chalk5.gray(
1625
+ "No install tracking found. Scanning filesystem for installed components..."
1626
+ )
1627
+ );
1611
1628
  const registry = getRegistry();
1612
1629
  let allComponents;
1613
1630
  try {
1614
1631
  allComponents = await registry.getComponents();
1615
1632
  } catch (error) {
1616
1633
  console.error(chalk5.red("\u274C Failed to fetch registry:"));
1617
- console.error(chalk5.red(error instanceof Error ? error.message : String(error)));
1634
+ console.error(
1635
+ chalk5.red(error instanceof Error ? error.message : String(error))
1636
+ );
1618
1637
  process.exit(1);
1619
1638
  }
1620
1639
  for (const component of allComponents) {
@@ -1632,13 +1651,25 @@ function updateCommand() {
1632
1651
  }
1633
1652
  installedIds = Object.keys(installed);
1634
1653
  if (installedIds.length === 0) {
1635
- console.log(chalk5.yellow('No installed components found. Use "foundrykit add" to install components.'));
1654
+ console.log(
1655
+ chalk5.yellow(
1656
+ 'No installed components found. Use "foundrykit add" to install components.'
1657
+ )
1658
+ );
1636
1659
  return;
1637
1660
  }
1638
- console.log(chalk5.gray(`Found ${installedIds.length} installed component(s) via filesystem scan.`));
1661
+ console.log(
1662
+ chalk5.gray(
1663
+ `Found ${installedIds.length} installed component(s) via filesystem scan.`
1664
+ )
1665
+ );
1639
1666
  }
1640
1667
  if (options.opt) {
1641
- console.log(chalk5.blue(`\u{1F50D} Checking for updates across ${installedIds.length} installed component(s)...`));
1668
+ console.log(
1669
+ chalk5.blue(
1670
+ `\u{1F50D} Checking for updates across ${installedIds.length} installed component(s)...`
1671
+ )
1672
+ );
1642
1673
  const registry = getRegistry();
1643
1674
  const withUpdates = [];
1644
1675
  const upToDate = [];
@@ -1650,39 +1681,55 @@ function updateCommand() {
1650
1681
  const hasUpdate = latestVersion !== null && installedVersion !== null && latestVersion !== installedVersion;
1651
1682
  const unknownVersion = installedVersion === null || latestVersion === null;
1652
1683
  if (hasUpdate || unknownVersion) {
1653
- withUpdates.push({ id: compId, installed: installedVersion, latest: latestVersion });
1684
+ withUpdates.push({
1685
+ id: compId,
1686
+ installed: installedVersion,
1687
+ latest: latestVersion
1688
+ });
1654
1689
  } else {
1655
1690
  upToDate.push(compId);
1656
1691
  }
1657
1692
  } catch {
1658
- withUpdates.push({ id: compId, installed: installed[compId]?.version ?? null, latest: null });
1693
+ withUpdates.push({
1694
+ id: compId,
1695
+ installed: installed[compId]?.version ?? null,
1696
+ latest: null
1697
+ });
1659
1698
  }
1660
1699
  }
1661
1700
  if (upToDate.length > 0) {
1662
- console.log(chalk5.gray(`
1663
- \u2713 Already up to date: ${upToDate.join(", ")}`));
1701
+ console.log(
1702
+ chalk5.gray(`
1703
+ \u2713 Already up to date: ${upToDate.join(", ")}`)
1704
+ );
1664
1705
  }
1665
1706
  if (withUpdates.length === 0) {
1666
1707
  console.log(chalk5.green("\n\u2705 All components are up to date."));
1667
1708
  return;
1668
1709
  }
1669
- const choices = withUpdates.map(({ id: compId, installed: inst, latest }) => {
1670
- let versionLabel;
1671
- if (inst === null && latest === null) {
1672
- versionLabel = chalk5.gray("(version unknown)");
1673
- } else if (latest === null) {
1674
- versionLabel = chalk5.gray(`(installed: ${inst} \u2014 registry version unknown)`);
1675
- } else if (inst === null) {
1676
- versionLabel = chalk5.cyan(`(latest: ${latest} \u2014 install version not tracked)`);
1677
- } else {
1678
- versionLabel = chalk5.cyan(`(${inst} \u2192 ${latest})`);
1710
+ const choices = withUpdates.map(
1711
+ ({ id: compId, installed: inst, latest }) => {
1712
+ let versionLabel;
1713
+ if (inst === null && latest === null) {
1714
+ versionLabel = chalk5.gray("(version unknown)");
1715
+ } else if (latest === null) {
1716
+ versionLabel = chalk5.gray(
1717
+ `(installed: ${inst} \u2014 registry version unknown)`
1718
+ );
1719
+ } else if (inst === null) {
1720
+ versionLabel = chalk5.cyan(
1721
+ `(latest: ${latest} \u2014 install version not tracked)`
1722
+ );
1723
+ } else {
1724
+ versionLabel = chalk5.cyan(`(${inst} \u2192 ${latest})`);
1725
+ }
1726
+ return {
1727
+ name: `${compId} ${versionLabel}`,
1728
+ value: compId,
1729
+ checked: true
1730
+ };
1679
1731
  }
1680
- return {
1681
- name: `${compId} ${versionLabel}`,
1682
- value: compId,
1683
- checked: true
1684
- };
1685
- });
1732
+ );
1686
1733
  const { selectedIds } = await inquirer3.prompt([
1687
1734
  {
1688
1735
  type: "checkbox",
@@ -1698,7 +1745,11 @@ function updateCommand() {
1698
1745
  }
1699
1746
  await runUpdates(selectedIds, options);
1700
1747
  } else {
1701
- console.log(chalk5.blue(`\u{1F504} Updating all ${installedIds.length} installed component(s)...`));
1748
+ console.log(
1749
+ chalk5.blue(
1750
+ `\u{1F504} Updating all ${installedIds.length} installed component(s)...`
1751
+ )
1752
+ );
1702
1753
  await runUpdates(installedIds, options);
1703
1754
  }
1704
1755
  });
@@ -1709,10 +1760,16 @@ async function runUpdates(ids, options) {
1709
1760
  try {
1710
1761
  console.log(chalk5.blue(`
1711
1762
  \u{1F504} Updating ${compId}...`));
1712
- await addSingleComponent(compId, { ...options, overwrite: true, force: true });
1763
+ await addSingleComponent(compId, {
1764
+ ...options,
1765
+ overwrite: true,
1766
+ force: true
1767
+ });
1713
1768
  } catch (error) {
1714
1769
  console.error(chalk5.red(`\u274C Failed to update ${compId}:`));
1715
- console.error(chalk5.red(error instanceof Error ? error.message : String(error)));
1770
+ console.error(
1771
+ chalk5.red(error instanceof Error ? error.message : String(error))
1772
+ );
1716
1773
  failed++;
1717
1774
  }
1718
1775
  }
@@ -1721,8 +1778,10 @@ async function runUpdates(ids, options) {
1721
1778
  \u26A0 ${failed} component(s) failed to update.`));
1722
1779
  process.exit(1);
1723
1780
  } else {
1724
- console.log(chalk5.green(`
1725
- \u2705 ${ids.length} component(s) updated successfully!`));
1781
+ console.log(
1782
+ chalk5.green(`
1783
+ \u2705 ${ids.length} component(s) updated successfully!`)
1784
+ );
1726
1785
  }
1727
1786
  }
1728
1787