@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foundrykit/cli",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
@@ -35,8 +35,8 @@
35
35
  "tsup": "^8.0.0",
36
36
  "typescript": "^5.9.2",
37
37
  "vitest": "^1.2.0",
38
- "@foundrykit/eslint-config": "1.0.5",
39
- "@foundrykit/typescript-config": "1.0.5"
38
+ "@foundrykit/typescript-config": "1.0.5",
39
+ "@foundrykit/eslint-config": "1.0.5"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsup",
@@ -3,7 +3,11 @@ 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, hasConflictingFiles, type AddOptions } from './add.js';
6
+ import {
7
+ addSingleComponent,
8
+ hasConflictingFiles,
9
+ type AddOptions,
10
+ } from './add.js';
7
11
  import { getRegistry } from '../lib/registry.js';
8
12
  import type { InstalledComponent } from '@foundrykit/types';
9
13
 
@@ -15,17 +19,27 @@ export function updateCommand() {
15
19
  return new Command('update')
16
20
  .description('Update installed components')
17
21
  .argument('[id]', 'Component or block ID (omit to update all installed)')
18
- .option('--opt', 'interactively select which components to update, showing available upgrades')
22
+ .option(
23
+ '-o, --opt',
24
+ 'interactively select which components to update, showing available upgrades'
25
+ )
26
+ .option('-f, --force', 'bypass cache and fetch fresh data from registry')
19
27
  .option('-p, --path <path>', 'Custom installation path')
20
28
  .action(async (id: string | undefined, options: UpdateOptions) => {
21
29
  if (id) {
22
30
  // Update single named component
23
31
  try {
24
32
  console.log(chalk.blue(`šŸ”„ Updating ${id}...`));
25
- await addSingleComponent(id, { ...options, overwrite: true, force: true });
33
+ await addSingleComponent(id, {
34
+ ...options,
35
+ overwrite: true,
36
+ force: true,
37
+ });
26
38
  } catch (error) {
27
39
  console.error(chalk.red(`āŒ Failed to update ${id}:`));
28
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
40
+ console.error(
41
+ chalk.red(error instanceof Error ? error.message : String(error))
42
+ );
29
43
  process.exit(1);
30
44
  }
31
45
  return;
@@ -34,24 +48,35 @@ export function updateCommand() {
34
48
  // Load installed components from config
35
49
  const configPath = path.join(process.cwd(), 'foundrykit.config.json');
36
50
  if (!fs.existsSync(configPath)) {
37
- console.error(chalk.red('āŒ FoundryKit not initialized. Run "foundrykit init" first.'));
51
+ console.error(
52
+ chalk.red(
53
+ 'āŒ FoundryKit not initialized. Run "foundrykit init" first.'
54
+ )
55
+ );
38
56
  process.exit(1);
39
57
  }
40
58
 
41
59
  const config = await fs.readJson(configPath);
42
- let installed: Record<string, InstalledComponent> = config.installedComponents ?? {};
60
+ let installed: Record<string, InstalledComponent> =
61
+ config.installedComponents ?? {};
43
62
  let installedIds = Object.keys(installed);
44
63
 
45
64
  if (installedIds.length === 0) {
46
65
  // No tracking data yet — fall back to scanning the filesystem
47
- console.log(chalk.gray('No install tracking found. Scanning filesystem for installed components...'));
66
+ console.log(
67
+ chalk.gray(
68
+ 'No install tracking found. Scanning filesystem for installed components...'
69
+ )
70
+ );
48
71
  const registry = getRegistry();
49
72
  let allComponents;
50
73
  try {
51
74
  allComponents = await registry.getComponents();
52
75
  } catch (error) {
53
76
  console.error(chalk.red('āŒ Failed to fetch registry:'));
54
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
77
+ console.error(
78
+ chalk.red(error instanceof Error ? error.message : String(error))
79
+ );
55
80
  process.exit(1);
56
81
  }
57
82
 
@@ -73,19 +98,35 @@ export function updateCommand() {
73
98
  installedIds = Object.keys(installed);
74
99
 
75
100
  if (installedIds.length === 0) {
76
- console.log(chalk.yellow('No installed components found. Use "foundrykit add" to install components.'));
101
+ console.log(
102
+ chalk.yellow(
103
+ 'No installed components found. Use "foundrykit add" to install components.'
104
+ )
105
+ );
77
106
  return;
78
107
  }
79
108
 
80
- console.log(chalk.gray(`Found ${installedIds.length} installed component(s) via filesystem scan.`));
109
+ console.log(
110
+ chalk.gray(
111
+ `Found ${installedIds.length} installed component(s) via filesystem scan.`
112
+ )
113
+ );
81
114
  }
82
115
 
83
116
  if (options.opt) {
84
117
  // --opt: fetch registry versions, show which have updates, let user pick
85
- console.log(chalk.blue(`šŸ” Checking for updates across ${installedIds.length} installed component(s)...`));
118
+ console.log(
119
+ chalk.blue(
120
+ `šŸ” Checking for updates across ${installedIds.length} installed component(s)...`
121
+ )
122
+ );
86
123
 
87
124
  const registry = getRegistry();
88
- const withUpdates: Array<{ id: string; installed: string | null; latest: string | null }> = [];
125
+ const withUpdates: Array<{
126
+ id: string;
127
+ installed: string | null;
128
+ latest: string | null;
129
+ }> = [];
89
130
  const upToDate: string[] = [];
90
131
 
91
132
  for (const compId of installedIds) {
@@ -99,21 +140,32 @@ export function updateCommand() {
99
140
  installedVersion !== null &&
100
141
  latestVersion !== installedVersion;
101
142
 
102
- const unknownVersion = installedVersion === null || latestVersion === null;
143
+ const unknownVersion =
144
+ installedVersion === null || latestVersion === null;
103
145
 
104
146
  if (hasUpdate || unknownVersion) {
105
- withUpdates.push({ id: compId, installed: installedVersion, latest: latestVersion });
147
+ withUpdates.push({
148
+ id: compId,
149
+ installed: installedVersion,
150
+ latest: latestVersion,
151
+ });
106
152
  } else {
107
153
  upToDate.push(compId);
108
154
  }
109
155
  } catch {
110
156
  // If we can't fetch, still offer the option to re-install
111
- withUpdates.push({ id: compId, installed: installed[compId]?.version ?? null, latest: null });
157
+ withUpdates.push({
158
+ id: compId,
159
+ installed: installed[compId]?.version ?? null,
160
+ latest: null,
161
+ });
112
162
  }
113
163
  }
114
164
 
115
165
  if (upToDate.length > 0) {
116
- console.log(chalk.gray(`\nāœ“ Already up to date: ${upToDate.join(', ')}`));
166
+ console.log(
167
+ chalk.gray(`\nāœ“ Already up to date: ${upToDate.join(', ')}`)
168
+ );
117
169
  }
118
170
 
119
171
  if (withUpdates.length === 0) {
@@ -121,23 +173,29 @@ export function updateCommand() {
121
173
  return;
122
174
  }
123
175
 
124
- const choices = withUpdates.map(({ id: compId, installed: inst, latest }) => {
125
- let versionLabel: string;
126
- if (inst === null && latest === null) {
127
- versionLabel = chalk.gray('(version unknown)');
128
- } else if (latest === null) {
129
- versionLabel = chalk.gray(`(installed: ${inst} — registry version unknown)`);
130
- } else if (inst === null) {
131
- versionLabel = chalk.cyan(`(latest: ${latest} — install version not tracked)`);
132
- } else {
133
- versionLabel = chalk.cyan(`(${inst} → ${latest})`);
176
+ const choices = withUpdates.map(
177
+ ({ id: compId, installed: inst, latest }) => {
178
+ let versionLabel: string;
179
+ if (inst === null && latest === null) {
180
+ versionLabel = chalk.gray('(version unknown)');
181
+ } else if (latest === null) {
182
+ versionLabel = chalk.gray(
183
+ `(installed: ${inst} — registry version unknown)`
184
+ );
185
+ } else if (inst === null) {
186
+ versionLabel = chalk.cyan(
187
+ `(latest: ${latest} — install version not tracked)`
188
+ );
189
+ } else {
190
+ versionLabel = chalk.cyan(`(${inst} → ${latest})`);
191
+ }
192
+ return {
193
+ name: `${compId} ${versionLabel}`,
194
+ value: compId,
195
+ checked: true,
196
+ };
134
197
  }
135
- return {
136
- name: `${compId} ${versionLabel}`,
137
- value: compId,
138
- checked: true,
139
- };
140
- });
198
+ );
141
199
 
142
200
  const { selectedIds } = await inquirer.prompt([
143
201
  {
@@ -157,7 +215,11 @@ export function updateCommand() {
157
215
  await runUpdates(selectedIds, options);
158
216
  } else {
159
217
  // No flag: update everything
160
- console.log(chalk.blue(`šŸ”„ Updating all ${installedIds.length} installed component(s)...`));
218
+ console.log(
219
+ chalk.blue(
220
+ `šŸ”„ Updating all ${installedIds.length} installed component(s)...`
221
+ )
222
+ );
161
223
  await runUpdates(installedIds, options);
162
224
  }
163
225
  });
@@ -168,10 +230,16 @@ async function runUpdates(ids: string[], options: AddOptions): Promise<void> {
168
230
  for (const compId of ids) {
169
231
  try {
170
232
  console.log(chalk.blue(`\nšŸ”„ Updating ${compId}...`));
171
- await addSingleComponent(compId, { ...options, overwrite: true, force: true });
233
+ await addSingleComponent(compId, {
234
+ ...options,
235
+ overwrite: true,
236
+ force: true,
237
+ });
172
238
  } catch (error) {
173
239
  console.error(chalk.red(`āŒ Failed to update ${compId}:`));
174
- console.error(chalk.red(error instanceof Error ? error.message : String(error)));
240
+ console.error(
241
+ chalk.red(error instanceof Error ? error.message : String(error))
242
+ );
175
243
  failed++;
176
244
  }
177
245
  }
@@ -180,6 +248,8 @@ async function runUpdates(ids: string[], options: AddOptions): Promise<void> {
180
248
  console.log(chalk.yellow(`\n⚠ ${failed} component(s) failed to update.`));
181
249
  process.exit(1);
182
250
  } else {
183
- console.log(chalk.green(`\nāœ… ${ids.length} component(s) updated successfully!`));
251
+ console.log(
252
+ chalk.green(`\nāœ… ${ids.length} component(s) updated successfully!`)
253
+ );
184
254
  }
185
255
  }