@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foundrykit/cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
@@ -25,7 +25,7 @@
25
25
  "glob": "^10.3.10",
26
26
  "inquirer": "^9.2.15",
27
27
  "node-fetch": "^3.3.0",
28
- "@foundrykit/types": "1.1.0"
28
+ "@foundrykit/types": "2.0.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^20.19.9",
@@ -25,6 +25,7 @@ interface AddOptions {
25
25
  withAnimation?: boolean;
26
26
  path?: string;
27
27
  overwrite?: boolean;
28
+ force?: boolean;
28
29
  }
29
30
 
30
31
  export type { AddOptions };
@@ -164,7 +165,7 @@ export async function addSingleComponent(
164
165
 
165
166
  try {
166
167
  // Fetch component data from registry
167
- const componentData = await registry.getComponent(id);
168
+ const componentData = await registry.getComponent(id, options.force);
168
169
 
169
170
  // Check for existing files
170
171
  if (
@@ -3,7 +3,7 @@ import chalk from 'chalk';
3
3
  import inquirer from 'inquirer';
4
4
  import fs from 'fs-extra';
5
5
  import path from 'path';
6
- import { addSingleComponent, type AddOptions } from './add.js';
6
+ import { addSingleComponent, hasConflictingFiles, type AddOptions } from './add.js';
7
7
  import { getRegistry } from '../lib/registry.js';
8
8
  import type { InstalledComponent } from '@foundrykit/types';
9
9
 
@@ -22,7 +22,7 @@ export function updateCommand() {
22
22
  // Update single named component
23
23
  try {
24
24
  console.log(chalk.blue(`šŸ”„ Updating ${id}...`));
25
- await addSingleComponent(id, { ...options, overwrite: true });
25
+ await addSingleComponent(id, { ...options, overwrite: true, force: true });
26
26
  } catch (error) {
27
27
  console.error(chalk.red(`āŒ Failed to update ${id}:`));
28
28
  console.error(chalk.red(error instanceof Error ? error.message : String(error)));
@@ -39,12 +39,45 @@ export function updateCommand() {
39
39
  }
40
40
 
41
41
  const config = await fs.readJson(configPath);
42
- const installed: Record<string, InstalledComponent> = config.installedComponents ?? {};
43
- const installedIds = Object.keys(installed);
42
+ let installed: Record<string, InstalledComponent> = config.installedComponents ?? {};
43
+ let installedIds = Object.keys(installed);
44
44
 
45
45
  if (installedIds.length === 0) {
46
- console.log(chalk.yellow('No installed components found. Use "foundrykit add" to install components.'));
47
- return;
46
+ // No tracking data yet — fall back to scanning the filesystem
47
+ console.log(chalk.gray('No install tracking found. Scanning filesystem for installed components...'));
48
+ const registry = getRegistry();
49
+ let allComponents;
50
+ try {
51
+ allComponents = await registry.getComponents();
52
+ } catch (error) {
53
+ console.error(chalk.red('āŒ Failed to fetch registry:'));
54
+ console.error(chalk.red(error instanceof Error ? error.message : String(error)));
55
+ process.exit(1);
56
+ }
57
+
58
+ for (const component of allComponents) {
59
+ try {
60
+ const componentData = await registry.getComponent(component.id);
61
+ if (await hasConflictingFiles(componentData, options)) {
62
+ installed[component.id] = {
63
+ id: component.id,
64
+ version: null,
65
+ installedAt: new Date().toISOString(),
66
+ };
67
+ }
68
+ } catch {
69
+ // skip unfetchable components
70
+ }
71
+ }
72
+
73
+ installedIds = Object.keys(installed);
74
+
75
+ if (installedIds.length === 0) {
76
+ console.log(chalk.yellow('No installed components found. Use "foundrykit add" to install components.'));
77
+ return;
78
+ }
79
+
80
+ console.log(chalk.gray(`Found ${installedIds.length} installed component(s) via filesystem scan.`));
48
81
  }
49
82
 
50
83
  if (options.opt) {
@@ -135,7 +168,7 @@ async function runUpdates(ids: string[], options: AddOptions): Promise<void> {
135
168
  for (const compId of ids) {
136
169
  try {
137
170
  console.log(chalk.blue(`\nšŸ”„ Updating ${compId}...`));
138
- await addSingleComponent(compId, { ...options, overwrite: true });
171
+ await addSingleComponent(compId, { ...options, overwrite: true, force: true });
139
172
  } catch (error) {
140
173
  console.error(chalk.red(`āŒ Failed to update ${compId}:`));
141
174
  console.error(chalk.red(error instanceof Error ? error.message : String(error)));
@@ -90,7 +90,7 @@ export class RegistryService {
90
90
  /**
91
91
  * Fetch a specific component by ID
92
92
  */
93
- async getComponent(id: string): Promise<ComponentData> {
93
+ async getComponent(id: string, force = false): Promise<ComponentData> {
94
94
  // Check if it's a special dependency first
95
95
  if (this.isSpecialDependency(id)) {
96
96
  return this.createSpecialDependency(id);
@@ -100,7 +100,7 @@ export class RegistryService {
100
100
  const cachedComponent = cache?.componentData?.[id];
101
101
  const hasValidCache = cache ? this.isCacheValid(cache) : false;
102
102
 
103
- if (cachedComponent && hasValidCache) {
103
+ if (!force && cachedComponent && hasValidCache) {
104
104
  console.log(chalk.gray(`Using cached data for component: ${id}`));
105
105
  return cachedComponent;
106
106
  }