@foundrykit/cli 1.0.15 → 1.1.0
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/.turbo/turbo-build.log +20 -0
- package/.turbo/turbo-test.log +42 -0
- package/.turbo/turbo-type-check.log +4 -0
- package/CHANGELOG.md +14 -0
- package/README.md +29 -278
- package/dist/cli.js +105 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.js +105 -10
- package/dist/index.js.map +1 -1
- package/docs/DEPENDENCY_RESOLUTION.md +11 -4
- package/package.json +5 -5
- package/src/commands/add.ts +17 -13
- package/src/commands/doctor.ts +117 -1
- package/src/commands/update.ts +20 -3
- package/src/lib/constants.ts +1 -1
- package/src/lib/registry.ts +19 -6
- package/tests/dependency-resolution.test.ts +9 -9
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @foundrykit/cli@1.0.16 build /Users/isj/Desktop/work/projects/foundry/packages/cli
|
|
4
|
+
> tsup
|
|
5
|
+
|
|
6
|
+
[34mCLI[39m Building entry: {"index":"src/index.ts","cli":"src/index.ts"}
|
|
7
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
+
[34mCLI[39m tsup v8.5.0
|
|
9
|
+
[34mCLI[39m Using tsup config: /Users/isj/Desktop/work/projects/foundry/packages/cli/tsup.config.ts
|
|
10
|
+
[34mCLI[39m Target: es2022
|
|
11
|
+
[34mCLI[39m Cleaning output folder
|
|
12
|
+
[34mESM[39m Build start
|
|
13
|
+
[32mESM[39m [1mdist/cli.js [22m[32m52.51 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/index.js [22m[32m52.51 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/cli.js.map [22m[32m100.57 KB[39m
|
|
16
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m100.57 KB[39m
|
|
17
|
+
[32mESM[39m ⚡️ Build success in 447ms
|
|
18
|
+
DTS Build start
|
|
19
|
+
DTS ⚡️ Build success in 4955ms
|
|
20
|
+
DTS dist/index.d.ts 20.00 B
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
> @foundrykit/cli@1.0.16 test /Users/isj/Desktop/work/projects/foundry/packages/cli
|
|
3
|
+
> vitest run
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
RUN v1.6.1 /Users/isj/Desktop/work/projects/foundry/packages/cli
|
|
7
|
+
|
|
8
|
+
stdout | tests/dependency-resolution.test.ts > Dependency Resolution > Registry Component Fetching > should fetch regular components from registry
|
|
9
|
+
Fetching component: https://test.registry.com/registry/button
|
|
10
|
+
|
|
11
|
+
stdout | tests/dependency-resolution.test.ts > Dependency Resolution > Registry Component Fetching > should handle 404 errors for non-existent components
|
|
12
|
+
Fetching component: https://test.registry.com/registry/non-existent
|
|
13
|
+
|
|
14
|
+
stdout | tests/dependency-resolution.test.ts > Dependency Resolution > Registry Component Fetching > should handle network errors gracefully
|
|
15
|
+
Fetching component: https://test.registry.com/registry/button
|
|
16
|
+
|
|
17
|
+
stdout | tests/dependency-resolution.test.ts > Dependency Resolution > Cache Management > should cache fetched components
|
|
18
|
+
Fetching component: https://test.registry.com/registry/card
|
|
19
|
+
|
|
20
|
+
stdout | tests/dependency-resolution.test.ts > Dependency Resolution > Cache Management > should cache fetched components
|
|
21
|
+
Using cached data for component: card
|
|
22
|
+
|
|
23
|
+
stdout | tests/dependency-resolution.test.ts > Dependency Resolution > Cache Management > should clear cache when requested
|
|
24
|
+
Cache cleared successfully
|
|
25
|
+
|
|
26
|
+
stdout | tests/dependency-resolution.test.ts > Dependency Resolution > Dependency Chain Resolution > should resolve multiple dependencies in order
|
|
27
|
+
Fetching component: https://test.registry.com/registry/button
|
|
28
|
+
|
|
29
|
+
stdout | tests/dependency-resolution.test.ts > Dependency Resolution > Dependency Chain Resolution > should resolve multiple dependencies in order
|
|
30
|
+
Fetching component: https://test.registry.com/registry/card
|
|
31
|
+
|
|
32
|
+
stdout | tests/dependency-resolution.test.ts > Dependency Resolution > Dependency Chain Resolution > should continue installation when a dependency fails
|
|
33
|
+
Fetching component: https://test.registry.com/registry/non-existent
|
|
34
|
+
Fetching component: https://test.registry.com/registry/button
|
|
35
|
+
|
|
36
|
+
✓ tests/dependency-resolution.test.ts (14 tests) 32ms
|
|
37
|
+
|
|
38
|
+
Test Files 1 passed (1)
|
|
39
|
+
Tests 14 passed (14)
|
|
40
|
+
Start at 14:01:44
|
|
41
|
+
Duration 481ms (transform 58ms, setup 0ms, collect 160ms, tests 32ms, environment 0ms, prepare 47ms)
|
|
42
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @foundrykit/cli
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c666749: mass update
|
|
8
|
+
|
|
9
|
+
## 1.0.16
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Just a quick demo for Anvar
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @foundrykit/types@1.0.9
|
|
16
|
+
|
|
3
17
|
## 1.0.15
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,324 +1,75 @@
|
|
|
1
1
|
# @foundrykit/cli
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🌐 **Live Registry** - Fetches components from the hosted registry at [foundry.umiflow.com](https://foundry.umiflow.com)
|
|
8
|
-
- 🎨 **Interactive Selection** - Multi-select components with keyboard navigation
|
|
9
|
-
- 📦 **Smart Dependencies** - Automatically installs required component dependencies
|
|
10
|
-
- 🎯 **Tailwind CSS v4** - Full support for the latest Tailwind CSS version
|
|
11
|
-
- 🔄 **Auto-updates** - Registry automatically updates when new components are released
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
### Global Installation (Recommended)
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
# Using pnpm (recommended)
|
|
19
|
-
pnpm add -g @foundrykit/cli
|
|
20
|
-
|
|
21
|
-
# Using npm
|
|
22
|
-
npm install -g @foundrykit/cli
|
|
23
|
-
|
|
24
|
-
# Using yarn
|
|
25
|
-
yarn global add @foundrykit/cli
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Local Installation
|
|
29
|
-
|
|
30
|
-
You can also use the CLI without installing it globally:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
npx @foundrykit/cli [command]
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Quick Start
|
|
37
|
-
|
|
38
|
-
Initialize FoundryKit in your Next.js project:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
foundrykit init
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
This will:
|
|
45
|
-
- ✅ Detect your Next.js project
|
|
46
|
-
- ✅ Install required FoundryKit dependencies
|
|
47
|
-
- ✅ Set up Tailwind CSS v4 configuration
|
|
48
|
-
- ✅ Create necessary directories and files
|
|
49
|
-
- ✅ Add helper scripts to your package.json
|
|
3
|
+
The FoundryKit CLI initializes projects and installs components from the
|
|
4
|
+
FoundryKit registry.
|
|
50
5
|
|
|
51
6
|
## Commands
|
|
52
7
|
|
|
53
8
|
### `init`
|
|
54
9
|
|
|
55
|
-
|
|
10
|
+
Creates `foundrykit.config.json`, installs the utility helper, prepares target
|
|
11
|
+
directories, and updates package scripts for a Next.js project.
|
|
56
12
|
|
|
57
13
|
```bash
|
|
58
|
-
foundrykit init
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Options:**
|
|
62
|
-
- `-f, --force` - Overwrite existing files
|
|
63
|
-
- `--skip-install` - Skip installing dependencies
|
|
64
|
-
- `--skip-prompts` - Use default paths without prompting for customization
|
|
65
|
-
|
|
66
|
-
**What it does:**
|
|
67
|
-
1. Validates that you're in a React-based project (Next.js, Vite, Remix)
|
|
68
|
-
2. **Detects your project structure** and suggests smart default paths
|
|
69
|
-
3. **Prompts for custom paths** - you can customize where files and folders are created
|
|
70
|
-
4. Installs required dependencies (if not in a workspace)
|
|
71
|
-
5. Sets up Tailwind CSS v4 with FoundryKit styles
|
|
72
|
-
6. Creates component directories in your chosen locations
|
|
73
|
-
7. Creates utility files (`lib/utils.ts` or custom path)
|
|
74
|
-
8. Updates your layout/App file to import FoundryKit styles
|
|
75
|
-
9. Adds convenient scripts to package.json
|
|
76
|
-
|
|
77
|
-
**Path Customization:**
|
|
78
|
-
The init command now intelligently detects your project structure and offers to customize paths:
|
|
79
|
-
- Automatically detects if you use `src/` directory
|
|
80
|
-
- Finds existing `components/`, `lib/`, `styles/` directories
|
|
81
|
-
- Suggests appropriate defaults based on your framework (Next.js, Vite, Remix)
|
|
82
|
-
- Allows you to customize each path individually
|
|
83
|
-
|
|
84
|
-
Example prompts:
|
|
85
|
-
```
|
|
86
|
-
📂 Configure installation paths:
|
|
87
|
-
Press enter to use the default value shown in parentheses
|
|
88
|
-
|
|
89
|
-
? Utils file path: (./src/lib/utils.ts)
|
|
90
|
-
? Components directory: (./src/components/components)
|
|
91
|
-
? Primitives directory: (./src/components/primitives)
|
|
92
|
-
? Blocks directory: (./src/components/blocks)
|
|
93
|
-
? Hooks directory: (./src/hooks)
|
|
94
|
-
? Animations directory: (./src/components/animations)
|
|
95
|
-
? Global styles file: (./src/app/globals.css)
|
|
96
|
-
? Lib directory: (./src/lib)
|
|
14
|
+
foundrykit init
|
|
97
15
|
```
|
|
98
16
|
|
|
99
17
|
### `list`
|
|
100
18
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
foundrykit list [options]
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
**Options:**
|
|
108
|
-
- `-c, --category <category>` - Filter by category (primitives, components, blocks)
|
|
109
|
-
- `-s, --search <term>` - Search components by name or description
|
|
19
|
+
Lists available registry components.
|
|
110
20
|
|
|
111
|
-
**Examples:**
|
|
112
21
|
```bash
|
|
113
|
-
# List all components
|
|
114
22
|
foundrykit list
|
|
115
|
-
|
|
116
|
-
# List only blocks
|
|
117
|
-
foundrykit list -c blocks
|
|
118
|
-
|
|
119
|
-
# Search for button components
|
|
23
|
+
foundrykit list -c primitives
|
|
120
24
|
foundrykit list -s button
|
|
121
|
-
|
|
122
|
-
# Components are fetched from https://foundry.umiflow.com/registry
|
|
123
25
|
```
|
|
124
26
|
|
|
125
27
|
### `add`
|
|
126
28
|
|
|
127
|
-
|
|
29
|
+
Fetches a component from the registry, installs its files, installs any missing
|
|
30
|
+
package dependencies, and prints a usage hint.
|
|
128
31
|
|
|
129
32
|
```bash
|
|
130
|
-
foundrykit add <component-id> [options]
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**Options:**
|
|
134
|
-
- `-o, --overwrite` - Overwrite existing files
|
|
135
|
-
- `-p, --path <path>` - Custom installation path
|
|
136
|
-
|
|
137
|
-
**Examples:**
|
|
138
|
-
```bash
|
|
139
|
-
# Interactive mode - select from a list of all components
|
|
140
|
-
foundrykit add
|
|
141
|
-
|
|
142
|
-
# Add a specific component from the registry
|
|
143
33
|
foundrykit add hero-minimal
|
|
144
|
-
|
|
145
|
-
# Add a button component to a custom path
|
|
146
|
-
foundrykit add button -p components/custom
|
|
147
|
-
|
|
148
|
-
# Overwrite existing component
|
|
149
|
-
foundrykit add card -o
|
|
34
|
+
foundrykit add button -o
|
|
150
35
|
```
|
|
151
36
|
|
|
152
37
|
### `update`
|
|
153
38
|
|
|
154
|
-
|
|
39
|
+
Reinstalls a component with overwrite semantics using the same registry-backed
|
|
40
|
+
installation flow as `add`.
|
|
155
41
|
|
|
156
|
-
```bash
|
|
157
|
-
foundrykit update <component-id>
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
**Example:**
|
|
161
42
|
```bash
|
|
162
43
|
foundrykit update hero-minimal
|
|
163
44
|
```
|
|
164
45
|
|
|
165
46
|
### `doctor`
|
|
166
47
|
|
|
167
|
-
|
|
48
|
+
Validates that:
|
|
168
49
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
This command checks:
|
|
174
|
-
- Next.js installation
|
|
175
|
-
- FoundryKit dependencies
|
|
176
|
-
- Tailwind CSS v4 configuration
|
|
177
|
-
- Project structure
|
|
178
|
-
- Common issues and fixes
|
|
179
|
-
|
|
180
|
-
## Tailwind CSS v4 Support
|
|
181
|
-
|
|
182
|
-
FoundryKit CLI is built for Tailwind CSS v4, which uses CSS-based configuration instead of JavaScript config files. The CLI will:
|
|
183
|
-
|
|
184
|
-
1. Import FoundryKit's pre-configured Tailwind CSS v4 styles
|
|
185
|
-
2. Set up proper CSS variables for theming
|
|
186
|
-
3. Configure dark mode support
|
|
187
|
-
4. Include all necessary Tailwind directives
|
|
188
|
-
|
|
189
|
-
Your `globals.css` will be updated to include:
|
|
190
|
-
```css
|
|
191
|
-
@import "@foundrykit/tailwind/globals.css";
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
This provides:
|
|
195
|
-
- Complete Tailwind CSS v4 setup
|
|
196
|
-
- CSS variables for colors and theming
|
|
197
|
-
- Dark mode configuration
|
|
198
|
-
- Component-specific styles
|
|
199
|
-
- Proper content scanning for all FoundryKit packages
|
|
200
|
-
|
|
201
|
-
## Working in a Monorepo
|
|
202
|
-
|
|
203
|
-
If you're using FoundryKit in a monorepo with workspace packages (like pnpm workspaces), the CLI will:
|
|
204
|
-
|
|
205
|
-
1. Detect the workspace configuration
|
|
206
|
-
2. Skip installing dependencies (they're already linked via workspace)
|
|
207
|
-
3. Use the local workspace packages instead of npm registry
|
|
50
|
+
- `package.json` exists
|
|
51
|
+
- Next.js is detected
|
|
52
|
+
- `foundrykit.config.json` exists and has the expected shape
|
|
53
|
+
- the configured registry URL is reachable
|
|
208
54
|
|
|
209
|
-
## Package.json Scripts
|
|
210
|
-
|
|
211
|
-
After initialization, you'll have these convenient scripts:
|
|
212
|
-
|
|
213
|
-
```json
|
|
214
|
-
{
|
|
215
|
-
"scripts": {
|
|
216
|
-
"foundrykit": "foundrykit",
|
|
217
|
-
"fk": "foundrykit"
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
Use them like:
|
|
223
55
|
```bash
|
|
224
|
-
|
|
225
|
-
pnpm fk add hero-minimal
|
|
226
|
-
yarn fk doctor
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
## Project Structure
|
|
230
|
-
|
|
231
|
-
After initialization, your project will have:
|
|
232
|
-
|
|
233
|
-
```
|
|
234
|
-
your-nextjs-app/
|
|
235
|
-
├── app/
|
|
236
|
-
│ ├── layout.tsx # Updated with FoundryKit imports
|
|
237
|
-
│ └── globals.css # Tailwind CSS v4 with FoundryKit styles
|
|
238
|
-
├── components/
|
|
239
|
-
│ ├── ui/ # UI components
|
|
240
|
-
│ ├── blocks/ # Page blocks
|
|
241
|
-
│ └── providers.tsx # Theme provider setup
|
|
242
|
-
├── lib/
|
|
243
|
-
│ └── utils.ts # Utility functions (cn, etc.)
|
|
244
|
-
└── hooks/ # Custom React hooks
|
|
56
|
+
foundrykit doctor
|
|
245
57
|
```
|
|
246
58
|
|
|
247
|
-
##
|
|
248
|
-
|
|
249
|
-
- Node.js 18.0.0 or higher
|
|
250
|
-
- React 18 or 19
|
|
251
|
-
- One of the following frameworks:
|
|
252
|
-
- Next.js 14.0.0 or higher
|
|
253
|
-
- Vite 5.0.0 or higher
|
|
254
|
-
- Remix 2.0.0 or higher
|
|
255
|
-
- Tailwind CSS v4
|
|
59
|
+
## Registry Contract
|
|
256
60
|
|
|
257
|
-
|
|
61
|
+
The CLI uses the registry configured in `foundrykit.config.json`.
|
|
258
62
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
If you get `command not found: foundrykit` after global installation with pnpm:
|
|
262
|
-
|
|
263
|
-
1. Ensure your pnpm global bin directory is in your PATH:
|
|
264
|
-
```bash
|
|
265
|
-
export PATH="$PNPM_HOME:$PATH"
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
2. Or use the local installation method:
|
|
269
|
-
```bash
|
|
270
|
-
npx @foundrykit/cli [command]
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### Workspace Detection
|
|
274
|
-
|
|
275
|
-
If you're in a monorepo and the CLI tries to install packages from npm:
|
|
276
|
-
|
|
277
|
-
1. Ensure your `pnpm-workspace.yaml` is properly configured
|
|
278
|
-
2. Check that workspace packages use `workspace:*` protocol
|
|
279
|
-
3. Use `--skip-install` flag and link packages manually if needed
|
|
280
|
-
|
|
281
|
-
### Tailwind CSS v4
|
|
282
|
-
|
|
283
|
-
If you're migrating from Tailwind CSS v3:
|
|
284
|
-
|
|
285
|
-
1. Remove `tailwind.config.js` or `tailwind.config.ts`
|
|
286
|
-
2. Update your CSS imports to use `@import` directives
|
|
287
|
-
3. Run `foundrykit init --force` to set up v4 configuration
|
|
288
|
-
|
|
289
|
-
## Contributing
|
|
290
|
-
|
|
291
|
-
Contributions are welcome! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details.
|
|
292
|
-
|
|
293
|
-
## License
|
|
294
|
-
|
|
295
|
-
MIT © FoundryKit
|
|
296
|
-
|
|
297
|
-
## Registry
|
|
298
|
-
|
|
299
|
-
FoundryKit components are served from a live registry hosted at [foundry.umiflow.com](https://foundry.umiflow.com). The registry automatically updates when new components are released on GitHub.
|
|
300
|
-
|
|
301
|
-
### Registry Endpoints
|
|
302
|
-
|
|
303
|
-
- **Component List**: `https://foundry.umiflow.com/registry` - Returns all component metadata
|
|
304
|
-
- **Individual Component**: `https://foundry.umiflow.com/registry/[id]` - Returns full component data including files
|
|
305
|
-
- **Filtered List**: `https://foundry.umiflow.com/registry?category=primitives&search=button` - Supports filtering
|
|
306
|
-
|
|
307
|
-
### Custom Registry
|
|
308
|
-
|
|
309
|
-
To use a custom registry, set the environment variable:
|
|
310
|
-
|
|
311
|
-
```bash
|
|
312
|
-
export FOUNDRYKIT_REGISTRY_URL=https://your-registry.com
|
|
313
|
-
foundrykit list
|
|
314
|
-
```
|
|
63
|
+
Canonical endpoints:
|
|
315
64
|
|
|
316
|
-
|
|
65
|
+
- `GET {registry}/registry`
|
|
66
|
+
- `GET {registry}/registry/{id}`
|
|
317
67
|
|
|
318
|
-
|
|
68
|
+
Legacy `/api/components` endpoints may still exist on the host for
|
|
69
|
+
compatibility, but the CLI should be considered a `/registry` consumer.
|
|
319
70
|
|
|
320
|
-
##
|
|
71
|
+
## Notes
|
|
321
72
|
|
|
322
|
-
-
|
|
323
|
-
-
|
|
324
|
-
-
|
|
73
|
+
- The CLI currently targets Next.js projects.
|
|
74
|
+
- `test` runs in non-watch mode by default for CI friendliness.
|
|
75
|
+
- Installation paths are controlled by `foundrykit.config.json`.
|
package/dist/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ import { exec } from "child_process";
|
|
|
16
16
|
import { promisify } from "util";
|
|
17
17
|
|
|
18
18
|
// src/lib/constants.ts
|
|
19
|
-
var CLI_VERSION = "1.0.
|
|
19
|
+
var CLI_VERSION = "1.0.16";
|
|
20
20
|
var DEFAULT_REGISTRY_URL = "https://foundry.umiflow.com";
|
|
21
21
|
var CACHE_TTL = 24 * 60 * 60 * 1e3;
|
|
22
22
|
var CACHE_DIR = ".foundrykit";
|
|
@@ -760,6 +760,13 @@ Try again later or check your internet connection.`
|
|
|
760
760
|
if (this.isSpecialDependency(id)) {
|
|
761
761
|
return this.createSpecialDependency(id);
|
|
762
762
|
}
|
|
763
|
+
const cache = await this.loadCache();
|
|
764
|
+
const cachedComponent = cache?.componentData?.[id];
|
|
765
|
+
const hasValidCache = cache ? this.isCacheValid(cache) : false;
|
|
766
|
+
if (cachedComponent && hasValidCache) {
|
|
767
|
+
console.log(chalk2.gray(`Using cached data for component: ${id}`));
|
|
768
|
+
return cachedComponent;
|
|
769
|
+
}
|
|
763
770
|
try {
|
|
764
771
|
const url = `${this.config.registryUrl}/registry/${id}`;
|
|
765
772
|
console.log(chalk2.gray(`Fetching component: ${url}`));
|
|
@@ -776,10 +783,9 @@ Try again later or check your internet connection.`
|
|
|
776
783
|
await this.cacheComponent(component);
|
|
777
784
|
return component;
|
|
778
785
|
} catch (error) {
|
|
779
|
-
|
|
780
|
-
if (cache?.componentData?.[id]) {
|
|
786
|
+
if (cachedComponent) {
|
|
781
787
|
console.log(chalk2.yellow(`Using cached data for component: ${id}`));
|
|
782
|
-
return
|
|
788
|
+
return cachedComponent;
|
|
783
789
|
}
|
|
784
790
|
throw new Error(
|
|
785
791
|
`Failed to fetch component "${id}": ${error instanceof Error ? error.message : "Unknown error"}
|
|
@@ -913,10 +919,15 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
913
919
|
*/
|
|
914
920
|
async cacheComponent(component) {
|
|
915
921
|
try {
|
|
916
|
-
const cache = await this.loadCache()
|
|
917
|
-
|
|
922
|
+
const cache = await this.loadCache() ?? {
|
|
923
|
+
version: "1.0.0",
|
|
924
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
925
|
+
components: [],
|
|
926
|
+
componentData: {}
|
|
927
|
+
};
|
|
918
928
|
cache.componentData[component.id] = component;
|
|
919
929
|
cache.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
930
|
+
await fs2.ensureDir(this.config.cacheDir);
|
|
920
931
|
await fs2.writeJson(this.cacheFile, cache, { spaces: 2 });
|
|
921
932
|
} catch (error) {
|
|
922
933
|
console.log(chalk2.gray("Failed to cache component"));
|
|
@@ -1559,19 +1570,103 @@ function getImportPath(componentData, config) {
|
|
|
1559
1570
|
import { Command as Command4 } from "commander";
|
|
1560
1571
|
import chalk5 from "chalk";
|
|
1561
1572
|
function updateCommand() {
|
|
1562
|
-
return new Command4("update").description("Update an existing component or block").argument("<id>", "Component or block ID").action(async (id) => {
|
|
1563
|
-
|
|
1564
|
-
|
|
1573
|
+
return new Command4("update").description("Update an existing component or block").argument("<id>", "Component or block ID").option("-p, --path <path>", "Custom installation path").action(async (id, options) => {
|
|
1574
|
+
try {
|
|
1575
|
+
console.log(chalk5.blue(`\u{1F504} Updating ${id}...`));
|
|
1576
|
+
await addSingleComponent(id, {
|
|
1577
|
+
...options,
|
|
1578
|
+
overwrite: true
|
|
1579
|
+
});
|
|
1580
|
+
} catch (error) {
|
|
1581
|
+
console.error(chalk5.red(`\u274C Failed to update ${id}:`));
|
|
1582
|
+
console.error(
|
|
1583
|
+
chalk5.red(error instanceof Error ? error.message : String(error))
|
|
1584
|
+
);
|
|
1585
|
+
process.exit(1);
|
|
1586
|
+
}
|
|
1565
1587
|
});
|
|
1566
1588
|
}
|
|
1567
1589
|
|
|
1568
1590
|
// src/commands/doctor.ts
|
|
1569
1591
|
import { Command as Command5 } from "commander";
|
|
1570
1592
|
import chalk6 from "chalk";
|
|
1593
|
+
import fs4 from "fs-extra";
|
|
1594
|
+
import path4 from "path";
|
|
1571
1595
|
function doctorCommand() {
|
|
1572
1596
|
return new Command5("doctor").description("Check project health and configuration").action(async () => {
|
|
1573
1597
|
console.log(chalk6.blue("\u{1F50D} Checking project health..."));
|
|
1574
|
-
|
|
1598
|
+
const results = [];
|
|
1599
|
+
const packageJsonPath = path4.join(process.cwd(), "package.json");
|
|
1600
|
+
const hasPackageJson = await fs4.pathExists(packageJsonPath);
|
|
1601
|
+
results.push({
|
|
1602
|
+
label: "package.json",
|
|
1603
|
+
ok: hasPackageJson,
|
|
1604
|
+
detail: hasPackageJson ? "Project manifest found" : "Run this command in a project root"
|
|
1605
|
+
});
|
|
1606
|
+
let packageJson2 = null;
|
|
1607
|
+
if (hasPackageJson) {
|
|
1608
|
+
packageJson2 = await fs4.readJson(packageJsonPath);
|
|
1609
|
+
}
|
|
1610
|
+
const hasNext = !!packageJson2 && !!(packageJson2.dependencies?.next || packageJson2.devDependencies?.next);
|
|
1611
|
+
results.push({
|
|
1612
|
+
label: "Framework",
|
|
1613
|
+
ok: hasNext,
|
|
1614
|
+
detail: hasNext ? "Next.js dependency detected" : "FoundryKit currently expects a Next.js project"
|
|
1615
|
+
});
|
|
1616
|
+
const configPath = path4.join(process.cwd(), "foundrykit.config.json");
|
|
1617
|
+
const hasConfig = await fs4.pathExists(configPath);
|
|
1618
|
+
results.push({
|
|
1619
|
+
label: "FoundryKit config",
|
|
1620
|
+
ok: hasConfig,
|
|
1621
|
+
detail: hasConfig ? "foundrykit.config.json found" : 'Run "foundrykit init" to create the configuration file'
|
|
1622
|
+
});
|
|
1623
|
+
let config = null;
|
|
1624
|
+
if (hasConfig) {
|
|
1625
|
+
try {
|
|
1626
|
+
config = await loadConfig();
|
|
1627
|
+
const hasRequiredPaths = !!config.paths?.utils && !!config.paths?.primitives && !!config.paths?.components && !!config.paths?.blocks && !!config.paths?.animations;
|
|
1628
|
+
results.push({
|
|
1629
|
+
label: "Config shape",
|
|
1630
|
+
ok: hasRequiredPaths,
|
|
1631
|
+
detail: hasRequiredPaths ? "Required install paths are configured" : "Configuration is missing one or more required install paths"
|
|
1632
|
+
});
|
|
1633
|
+
const registryUrl = config.registry || DEFAULT_REGISTRY_URL;
|
|
1634
|
+
try {
|
|
1635
|
+
const response = await fetch(`${registryUrl}/registry`, {
|
|
1636
|
+
headers: { Accept: "application/json" }
|
|
1637
|
+
});
|
|
1638
|
+
results.push({
|
|
1639
|
+
label: "Registry",
|
|
1640
|
+
ok: response.ok,
|
|
1641
|
+
detail: response.ok ? `Registry reachable at ${registryUrl}` : `Registry returned ${response.status} ${response.statusText}`
|
|
1642
|
+
});
|
|
1643
|
+
} catch (error) {
|
|
1644
|
+
results.push({
|
|
1645
|
+
label: "Registry",
|
|
1646
|
+
ok: false,
|
|
1647
|
+
detail: `Unable to reach ${registryUrl}: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
} catch (error) {
|
|
1651
|
+
results.push({
|
|
1652
|
+
label: "Config shape",
|
|
1653
|
+
ok: false,
|
|
1654
|
+
detail: `Failed to read foundrykit.config.json: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
for (const result of results) {
|
|
1659
|
+
const icon = result.ok ? chalk6.green("\u2705") : chalk6.red("\u274C");
|
|
1660
|
+
console.log(`${icon} ${result.label}: ${result.detail}`);
|
|
1661
|
+
}
|
|
1662
|
+
const hasFailures = results.some((result) => !result.ok);
|
|
1663
|
+
if (hasFailures) {
|
|
1664
|
+
console.log(
|
|
1665
|
+
chalk6.yellow("\n\u26A0\uFE0F Found issues that should be resolved before continuing.")
|
|
1666
|
+
);
|
|
1667
|
+
process.exit(1);
|
|
1668
|
+
}
|
|
1669
|
+
console.log(chalk6.green("\n\u2705 All checks passed!"));
|
|
1575
1670
|
});
|
|
1576
1671
|
}
|
|
1577
1672
|
|