@foundrykit/cli 2.0.2 → 2.0.3

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