@foundrykit/cli 1.0.14 → 1.0.16
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/CHANGELOG.md +14 -0
- package/README.md +53 -20
- package/dist/cli.js +109 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -1
- package/docs/DEPENDENCY_RESOLUTION.md +11 -4
- package/package.json +4 -4
- package/src/commands/add.ts +6 -0
- package/src/lib/registry.ts +117 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @foundrykit/cli
|
|
2
2
|
|
|
3
|
+
## 1.0.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Just a quick demo for Anvar
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @foundrykit/types@1.0.9
|
|
10
|
+
|
|
11
|
+
## 1.0.15
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- updating the way results input works and how results render
|
|
16
|
+
|
|
3
17
|
## 1.0.14
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
# @foundrykit/cli
|
|
2
2
|
|
|
3
|
-
The official CLI for FoundryKit - a modern component library for Next.js
|
|
3
|
+
The official CLI for FoundryKit - a modern component library for Next.js
|
|
4
|
+
applications with Tailwind CSS v4 support.
|
|
4
5
|
|
|
5
6
|
## Features
|
|
6
7
|
|
|
7
|
-
- 🌐 **Live Registry** - Fetches components from the hosted registry at
|
|
8
|
-
|
|
9
|
-
-
|
|
8
|
+
- 🌐 **Live Registry** - Fetches components from the hosted registry at
|
|
9
|
+
[foundry.umiflow.com](https://foundry.umiflow.com)
|
|
10
|
+
- 🎨 **Interactive Selection** - Multi-select components with keyboard
|
|
11
|
+
navigation
|
|
12
|
+
- 📦 **Smart Dependencies** - Automatically installs required component
|
|
13
|
+
dependencies
|
|
10
14
|
- 🎯 **Tailwind CSS v4** - Full support for the latest Tailwind CSS version
|
|
11
|
-
- 🔄 **Auto-updates** - Registry automatically updates when new components are
|
|
15
|
+
- 🔄 **Auto-updates** - Registry automatically updates when new components are
|
|
16
|
+
released
|
|
12
17
|
|
|
13
18
|
## Installation
|
|
14
19
|
|
|
@@ -42,6 +47,7 @@ foundrykit init
|
|
|
42
47
|
```
|
|
43
48
|
|
|
44
49
|
This will:
|
|
50
|
+
|
|
45
51
|
- ✅ Detect your Next.js project
|
|
46
52
|
- ✅ Install required FoundryKit dependencies
|
|
47
53
|
- ✅ Set up Tailwind CSS v4 configuration
|
|
@@ -59,14 +65,17 @@ foundrykit init [options]
|
|
|
59
65
|
```
|
|
60
66
|
|
|
61
67
|
**Options:**
|
|
68
|
+
|
|
62
69
|
- `-f, --force` - Overwrite existing files
|
|
63
70
|
- `--skip-install` - Skip installing dependencies
|
|
64
71
|
- `--skip-prompts` - Use default paths without prompting for customization
|
|
65
72
|
|
|
66
73
|
**What it does:**
|
|
74
|
+
|
|
67
75
|
1. Validates that you're in a React-based project (Next.js, Vite, Remix)
|
|
68
76
|
2. **Detects your project structure** and suggests smart default paths
|
|
69
|
-
3. **Prompts for custom paths** - you can customize where files and folders are
|
|
77
|
+
3. **Prompts for custom paths** - you can customize where files and folders are
|
|
78
|
+
created
|
|
70
79
|
4. Installs required dependencies (if not in a workspace)
|
|
71
80
|
5. Sets up Tailwind CSS v4 with FoundryKit styles
|
|
72
81
|
6. Creates component directories in your chosen locations
|
|
@@ -74,14 +83,16 @@ foundrykit init [options]
|
|
|
74
83
|
8. Updates your layout/App file to import FoundryKit styles
|
|
75
84
|
9. Adds convenient scripts to package.json
|
|
76
85
|
|
|
77
|
-
**Path Customization:**
|
|
78
|
-
|
|
86
|
+
**Path Customization:** The init command now intelligently detects your project
|
|
87
|
+
structure and offers to customize paths:
|
|
88
|
+
|
|
79
89
|
- Automatically detects if you use `src/` directory
|
|
80
90
|
- Finds existing `components/`, `lib/`, `styles/` directories
|
|
81
91
|
- Suggests appropriate defaults based on your framework (Next.js, Vite, Remix)
|
|
82
92
|
- Allows you to customize each path individually
|
|
83
93
|
|
|
84
94
|
Example prompts:
|
|
95
|
+
|
|
85
96
|
```
|
|
86
97
|
📂 Configure installation paths:
|
|
87
98
|
Press enter to use the default value shown in parentheses
|
|
@@ -105,10 +116,13 @@ foundrykit list [options]
|
|
|
105
116
|
```
|
|
106
117
|
|
|
107
118
|
**Options:**
|
|
108
|
-
|
|
119
|
+
|
|
120
|
+
- `-c, --category <category>` - Filter by category (primitives, components,
|
|
121
|
+
blocks)
|
|
109
122
|
- `-s, --search <term>` - Search components by name or description
|
|
110
123
|
|
|
111
124
|
**Examples:**
|
|
125
|
+
|
|
112
126
|
```bash
|
|
113
127
|
# List all components
|
|
114
128
|
foundrykit list
|
|
@@ -124,17 +138,20 @@ foundrykit list -s button
|
|
|
124
138
|
|
|
125
139
|
### `add`
|
|
126
140
|
|
|
127
|
-
Add a component or block to your project. Components are fetched from the live
|
|
141
|
+
Add a component or block to your project. Components are fetched from the live
|
|
142
|
+
registry at [foundry.umiflow.com](https://foundry.umiflow.com).
|
|
128
143
|
|
|
129
144
|
```bash
|
|
130
145
|
foundrykit add <component-id> [options]
|
|
131
146
|
```
|
|
132
147
|
|
|
133
148
|
**Options:**
|
|
149
|
+
|
|
134
150
|
- `-o, --overwrite` - Overwrite existing files
|
|
135
151
|
- `-p, --path <path>` - Custom installation path
|
|
136
152
|
|
|
137
153
|
**Examples:**
|
|
154
|
+
|
|
138
155
|
```bash
|
|
139
156
|
# Interactive mode - select from a list of all components
|
|
140
157
|
foundrykit add
|
|
@@ -158,6 +175,7 @@ foundrykit update <component-id>
|
|
|
158
175
|
```
|
|
159
176
|
|
|
160
177
|
**Example:**
|
|
178
|
+
|
|
161
179
|
```bash
|
|
162
180
|
foundrykit update hero-minimal
|
|
163
181
|
```
|
|
@@ -171,6 +189,7 @@ foundrykit doctor
|
|
|
171
189
|
```
|
|
172
190
|
|
|
173
191
|
This command checks:
|
|
192
|
+
|
|
174
193
|
- Next.js installation
|
|
175
194
|
- FoundryKit dependencies
|
|
176
195
|
- Tailwind CSS v4 configuration
|
|
@@ -179,7 +198,8 @@ This command checks:
|
|
|
179
198
|
|
|
180
199
|
## Tailwind CSS v4 Support
|
|
181
200
|
|
|
182
|
-
FoundryKit CLI is built for Tailwind CSS v4, which uses CSS-based configuration
|
|
201
|
+
FoundryKit CLI is built for Tailwind CSS v4, which uses CSS-based configuration
|
|
202
|
+
instead of JavaScript config files. The CLI will:
|
|
183
203
|
|
|
184
204
|
1. Import FoundryKit's pre-configured Tailwind CSS v4 styles
|
|
185
205
|
2. Set up proper CSS variables for theming
|
|
@@ -187,11 +207,13 @@ FoundryKit CLI is built for Tailwind CSS v4, which uses CSS-based configuration
|
|
|
187
207
|
4. Include all necessary Tailwind directives
|
|
188
208
|
|
|
189
209
|
Your `globals.css` will be updated to include:
|
|
210
|
+
|
|
190
211
|
```css
|
|
191
|
-
@import
|
|
212
|
+
@import '@foundrykit/tailwind/globals.css';
|
|
192
213
|
```
|
|
193
214
|
|
|
194
215
|
This provides:
|
|
216
|
+
|
|
195
217
|
- Complete Tailwind CSS v4 setup
|
|
196
218
|
- CSS variables for colors and theming
|
|
197
219
|
- Dark mode configuration
|
|
@@ -200,7 +222,8 @@ This provides:
|
|
|
200
222
|
|
|
201
223
|
## Working in a Monorepo
|
|
202
224
|
|
|
203
|
-
If you're using FoundryKit in a monorepo with workspace packages (like pnpm
|
|
225
|
+
If you're using FoundryKit in a monorepo with workspace packages (like pnpm
|
|
226
|
+
workspaces), the CLI will:
|
|
204
227
|
|
|
205
228
|
1. Detect the workspace configuration
|
|
206
229
|
2. Skip installing dependencies (they're already linked via workspace)
|
|
@@ -220,6 +243,7 @@ After initialization, you'll have these convenient scripts:
|
|
|
220
243
|
```
|
|
221
244
|
|
|
222
245
|
Use them like:
|
|
246
|
+
|
|
223
247
|
```bash
|
|
224
248
|
npm run fk list
|
|
225
249
|
pnpm fk add hero-minimal
|
|
@@ -261,6 +285,7 @@ your-nextjs-app/
|
|
|
261
285
|
If you get `command not found: foundrykit` after global installation with pnpm:
|
|
262
286
|
|
|
263
287
|
1. Ensure your pnpm global bin directory is in your PATH:
|
|
288
|
+
|
|
264
289
|
```bash
|
|
265
290
|
export PATH="$PNPM_HOME:$PATH"
|
|
266
291
|
```
|
|
@@ -288,7 +313,8 @@ If you're migrating from Tailwind CSS v3:
|
|
|
288
313
|
|
|
289
314
|
## Contributing
|
|
290
315
|
|
|
291
|
-
Contributions are welcome! Please see our
|
|
316
|
+
Contributions are welcome! Please see our
|
|
317
|
+
[Contributing Guide](../../CONTRIBUTING.md) for details.
|
|
292
318
|
|
|
293
319
|
## License
|
|
294
320
|
|
|
@@ -296,13 +322,19 @@ MIT © FoundryKit
|
|
|
296
322
|
|
|
297
323
|
## Registry
|
|
298
324
|
|
|
299
|
-
FoundryKit components are served from a live registry hosted at
|
|
325
|
+
FoundryKit components are served from a live registry hosted at
|
|
326
|
+
[foundry.umiflow.com](https://foundry.umiflow.com). The registry automatically
|
|
327
|
+
updates when new components are released on GitHub.
|
|
300
328
|
|
|
301
329
|
### Registry Endpoints
|
|
302
330
|
|
|
303
|
-
- **Component List**: `https://foundry.umiflow.com/registry` - Returns all
|
|
304
|
-
|
|
305
|
-
- **
|
|
331
|
+
- **Component List**: `https://foundry.umiflow.com/registry` - Returns all
|
|
332
|
+
component metadata
|
|
333
|
+
- **Individual Component**: `https://foundry.umiflow.com/registry/[id]` -
|
|
334
|
+
Returns full component data including files
|
|
335
|
+
- **Filtered List**:
|
|
336
|
+
`https://foundry.umiflow.com/registry?category=primitives&search=button` -
|
|
337
|
+
Supports filtering
|
|
306
338
|
|
|
307
339
|
### Custom Registry
|
|
308
340
|
|
|
@@ -315,10 +347,11 @@ foundrykit list
|
|
|
315
347
|
|
|
316
348
|
### Offline Mode
|
|
317
349
|
|
|
318
|
-
If the registry is unavailable, the CLI will automatically fall back to a local
|
|
350
|
+
If the registry is unavailable, the CLI will automatically fall back to a local
|
|
351
|
+
component cache, ensuring you can always work offline.
|
|
319
352
|
|
|
320
353
|
## Support
|
|
321
354
|
|
|
322
355
|
- 📧 Email: support@foundrykit.dev
|
|
323
356
|
- 🐛 Issues: [GitHub Issues](https://github.com/foundrykit/foundrykit/issues)
|
|
324
|
-
- 📖 Docs: [https://foundrykit.dev](https://foundrykit.dev)
|
|
357
|
+
- 📖 Docs: [https://foundrykit.dev](https://foundrykit.dev)
|
package/dist/cli.js
CHANGED
|
@@ -757,6 +757,9 @@ Try again later or check your internet connection.`
|
|
|
757
757
|
* Fetch a specific component by ID
|
|
758
758
|
*/
|
|
759
759
|
async getComponent(id) {
|
|
760
|
+
if (this.isSpecialDependency(id)) {
|
|
761
|
+
return this.createSpecialDependency(id);
|
|
762
|
+
}
|
|
760
763
|
try {
|
|
761
764
|
const url = `${this.config.registryUrl}/registry/${id}`;
|
|
762
765
|
console.log(chalk2.gray(`Fetching component: ${url}`));
|
|
@@ -785,6 +788,108 @@ Try again later or check your internet connection.`
|
|
|
785
788
|
);
|
|
786
789
|
}
|
|
787
790
|
}
|
|
791
|
+
/**
|
|
792
|
+
* Check if a dependency ID is a special dependency that should be handled locally
|
|
793
|
+
*/
|
|
794
|
+
isSpecialDependency(id) {
|
|
795
|
+
const specialDependencies = [
|
|
796
|
+
"utils",
|
|
797
|
+
"lib",
|
|
798
|
+
"helpers",
|
|
799
|
+
"cn",
|
|
800
|
+
// Utils aliases
|
|
801
|
+
"hooks",
|
|
802
|
+
"types"
|
|
803
|
+
// Package dependencies
|
|
804
|
+
];
|
|
805
|
+
return specialDependencies.includes(id);
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Create a special dependency component data
|
|
809
|
+
*/
|
|
810
|
+
async createSpecialDependency(id) {
|
|
811
|
+
if (["utils", "lib", "helpers", "cn"].includes(id)) {
|
|
812
|
+
return {
|
|
813
|
+
id: "utils",
|
|
814
|
+
name: "Utils",
|
|
815
|
+
description: "Utility functions for className merging",
|
|
816
|
+
category: "primitives",
|
|
817
|
+
files: [
|
|
818
|
+
{
|
|
819
|
+
path: "lib/utils.ts",
|
|
820
|
+
content: `import { type ClassValue, clsx } from 'clsx';
|
|
821
|
+
import { twMerge } from 'tailwind-merge';
|
|
822
|
+
|
|
823
|
+
export function cn(...inputs: ClassValue[]) {
|
|
824
|
+
return twMerge(clsx(inputs));
|
|
825
|
+
}`,
|
|
826
|
+
type: "util"
|
|
827
|
+
}
|
|
828
|
+
],
|
|
829
|
+
registryDependencies: [],
|
|
830
|
+
packageDependencies: ["clsx", "tailwind-merge"]
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
if (id === "hooks") {
|
|
834
|
+
const isInstalled = await this.isPackageInstalled("@foundrykit/hooks");
|
|
835
|
+
if (isInstalled) {
|
|
836
|
+
return {
|
|
837
|
+
id: "hooks",
|
|
838
|
+
name: "Hooks",
|
|
839
|
+
description: "Custom React hooks package",
|
|
840
|
+
category: "primitives",
|
|
841
|
+
files: [],
|
|
842
|
+
// No files to install, it's a package
|
|
843
|
+
registryDependencies: [],
|
|
844
|
+
packageDependencies: ["@foundrykit/hooks"]
|
|
845
|
+
};
|
|
846
|
+
} else {
|
|
847
|
+
throw new Error(
|
|
848
|
+
'Package "@foundrykit/hooks" is not installed. Please install it first: pnpm add @foundrykit/hooks'
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (id === "types") {
|
|
853
|
+
const isInstalled = await this.isPackageInstalled("@foundrykit/types");
|
|
854
|
+
if (isInstalled) {
|
|
855
|
+
return {
|
|
856
|
+
id: "types",
|
|
857
|
+
name: "Types",
|
|
858
|
+
description: "TypeScript type definitions",
|
|
859
|
+
category: "primitives",
|
|
860
|
+
files: [],
|
|
861
|
+
// No files to install, it's a package
|
|
862
|
+
registryDependencies: [],
|
|
863
|
+
packageDependencies: ["@foundrykit/types"]
|
|
864
|
+
};
|
|
865
|
+
} else {
|
|
866
|
+
throw new Error(
|
|
867
|
+
'Package "@foundrykit/types" is not installed. Please install it first: pnpm add @foundrykit/types'
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
throw new Error(`Unknown special dependency: ${id}`);
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Check if a package is installed in the current project
|
|
875
|
+
*/
|
|
876
|
+
async isPackageInstalled(packageName) {
|
|
877
|
+
try {
|
|
878
|
+
const packageJsonPath = path2.join(process.cwd(), "package.json");
|
|
879
|
+
if (!await fs2.pathExists(packageJsonPath)) {
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
const packageJson2 = await fs2.readJson(packageJsonPath);
|
|
883
|
+
const allDeps = {
|
|
884
|
+
...packageJson2.dependencies,
|
|
885
|
+
...packageJson2.devDependencies,
|
|
886
|
+
...packageJson2.peerDependencies
|
|
887
|
+
};
|
|
888
|
+
return packageName in allDeps;
|
|
889
|
+
} catch (error) {
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
788
893
|
/**
|
|
789
894
|
* Update the local cache with new component list
|
|
790
895
|
*/
|
|
@@ -1138,6 +1243,10 @@ async function addSingleComponent(id, options) {
|
|
|
1138
1243
|
for (const dep of componentData.registryDependencies) {
|
|
1139
1244
|
try {
|
|
1140
1245
|
const depData = await registry.getComponent(dep);
|
|
1246
|
+
if (["hooks", "types"].includes(dep)) {
|
|
1247
|
+
console.log(chalk4.green(` \u2713 ${dep} package is available`));
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1141
1250
|
const hasExisting = await hasConflictingFiles(depData, options);
|
|
1142
1251
|
if (!hasExisting) {
|
|
1143
1252
|
await installComponentFiles(depData, options);
|