@foundrykit/cli 2.0.0 → 2.0.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.
package/dist/index.js CHANGED
@@ -756,14 +756,14 @@ Try again later or check your internet connection.`
756
756
  /**
757
757
  * Fetch a specific component by ID
758
758
  */
759
- async getComponent(id) {
759
+ async getComponent(id, force = false) {
760
760
  if (this.isSpecialDependency(id)) {
761
761
  return this.createSpecialDependency(id);
762
762
  }
763
763
  const cache = await this.loadCache();
764
764
  const cachedComponent = cache?.componentData?.[id];
765
765
  const hasValidCache = cache ? this.isCacheValid(cache) : false;
766
- if (cachedComponent && hasValidCache) {
766
+ if (!force && cachedComponent && hasValidCache) {
767
767
  console.log(chalk2.gray(`Using cached data for component: ${id}`));
768
768
  return cachedComponent;
769
769
  }
@@ -1234,7 +1234,7 @@ async function addSingleComponent(id, options) {
1234
1234
  await validateProject2();
1235
1235
  const registry = getRegistry();
1236
1236
  try {
1237
- const componentData = await registry.getComponent(id);
1237
+ const componentData = await registry.getComponent(id, options.force);
1238
1238
  if (!options.overwrite && await hasConflictingFiles(componentData, options)) {
1239
1239
  const { shouldContinue } = await inquirer2.prompt([
1240
1240
  {
@@ -1590,7 +1590,7 @@ function updateCommand() {
1590
1590
  if (id) {
1591
1591
  try {
1592
1592
  console.log(chalk5.blue(`\u{1F504} Updating ${id}...`));
1593
- await addSingleComponent(id, { ...options, overwrite: true });
1593
+ await addSingleComponent(id, { ...options, overwrite: true, force: true });
1594
1594
  } catch (error) {
1595
1595
  console.error(chalk5.red(`\u274C Failed to update ${id}:`));
1596
1596
  console.error(chalk5.red(error instanceof Error ? error.message : String(error)));
@@ -1604,11 +1604,38 @@ function updateCommand() {
1604
1604
  process.exit(1);
1605
1605
  }
1606
1606
  const config = await fs4.readJson(configPath);
1607
- const installed = config.installedComponents ?? {};
1608
- const installedIds = Object.keys(installed);
1607
+ let installed = config.installedComponents ?? {};
1608
+ let installedIds = Object.keys(installed);
1609
1609
  if (installedIds.length === 0) {
1610
- console.log(chalk5.yellow('No installed components found. Use "foundrykit add" to install components.'));
1611
- return;
1610
+ console.log(chalk5.gray("No install tracking found. Scanning filesystem for installed components..."));
1611
+ const registry = getRegistry();
1612
+ let allComponents;
1613
+ try {
1614
+ allComponents = await registry.getComponents();
1615
+ } catch (error) {
1616
+ console.error(chalk5.red("\u274C Failed to fetch registry:"));
1617
+ console.error(chalk5.red(error instanceof Error ? error.message : String(error)));
1618
+ process.exit(1);
1619
+ }
1620
+ for (const component of allComponents) {
1621
+ try {
1622
+ const componentData = await registry.getComponent(component.id);
1623
+ if (await hasConflictingFiles(componentData, options)) {
1624
+ installed[component.id] = {
1625
+ id: component.id,
1626
+ version: null,
1627
+ installedAt: (/* @__PURE__ */ new Date()).toISOString()
1628
+ };
1629
+ }
1630
+ } catch {
1631
+ }
1632
+ }
1633
+ installedIds = Object.keys(installed);
1634
+ if (installedIds.length === 0) {
1635
+ console.log(chalk5.yellow('No installed components found. Use "foundrykit add" to install components.'));
1636
+ return;
1637
+ }
1638
+ console.log(chalk5.gray(`Found ${installedIds.length} installed component(s) via filesystem scan.`));
1612
1639
  }
1613
1640
  if (options.opt) {
1614
1641
  console.log(chalk5.blue(`\u{1F50D} Checking for updates across ${installedIds.length} installed component(s)...`));
@@ -1682,7 +1709,7 @@ async function runUpdates(ids, options) {
1682
1709
  try {
1683
1710
  console.log(chalk5.blue(`
1684
1711
  \u{1F504} Updating ${compId}...`));
1685
- await addSingleComponent(compId, { ...options, overwrite: true });
1712
+ await addSingleComponent(compId, { ...options, overwrite: true, force: true });
1686
1713
  } catch (error) {
1687
1714
  console.error(chalk5.red(`\u274C Failed to update ${compId}:`));
1688
1715
  console.error(chalk5.red(error instanceof Error ? error.message : String(error)));