@foundrykit/cli 2.0.11 → 3.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foundrykit/cli",
3
- "version": "2.0.11",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
@@ -9,6 +9,10 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
+ "files": [
13
+ "dist",
14
+ "schema.json"
15
+ ],
12
16
  "bin": {
13
17
  "foundrykit": "./dist/cli.js"
14
18
  },
@@ -19,29 +23,32 @@
19
23
  }
20
24
  },
21
25
  "dependencies": {
22
- "commander": "^12.0.0",
23
26
  "chalk": "^5.3.0",
27
+ "commander": "^12.0.0",
28
+ "diff": "^8.0.4",
24
29
  "fs-extra": "^11.2.0",
25
30
  "glob": "^10.3.10",
26
31
  "inquirer": "^9.2.15",
27
32
  "node-fetch": "^3.3.0",
28
- "@foundrykit/types": "2.0.6"
33
+ "@foundrykit/types": "3.0.0"
29
34
  },
30
35
  "devDependencies": {
31
- "@types/node": "^20.19.9",
32
36
  "@types/fs-extra": "^11.0.4",
33
37
  "@types/inquirer": "^9.0.7",
34
- "eslint": "^9.0.0",
38
+ "@types/node": "^20.19.9",
35
39
  "tsup": "^8.0.0",
36
40
  "typescript": "^5.9.2",
37
41
  "vitest": "^1.2.0",
38
- "@foundrykit/eslint-config": "1.0.5",
39
- "@foundrykit/typescript-config": "1.0.5"
42
+ "@foundrykit/typescript-config": "1.0.6"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/umi-labs/foundry.git",
47
+ "directory": "packages/cli"
40
48
  },
41
49
  "scripts": {
42
50
  "build": "tsup",
43
51
  "dev": "tsup --watch",
44
- "lint": "eslint . --max-warnings 0",
45
52
  "type-check": "tsc --noEmit",
46
53
  "test": "vitest run",
47
54
  "test:watch": "vitest --watch"
package/schema.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://unpkg.com/@foundrykit/cli@3/schema.json",
4
+ "title": "FoundryKit project settings",
5
+ "type": "object",
6
+ "required": [
7
+ "packageManager",
8
+ "typescript",
9
+ "framework",
10
+ "tailwind",
11
+ "aliases",
12
+ "paths"
13
+ ],
14
+ "additionalProperties": true,
15
+ "properties": {
16
+ "$schema": { "type": "string" },
17
+ "registry": { "type": "string" },
18
+ "packageManager": { "type": "string" },
19
+ "typescript": { "type": "boolean" },
20
+ "framework": { "type": "string" },
21
+ "tailwind": {
22
+ "type": "object",
23
+ "required": ["css"],
24
+ "properties": { "css": { "type": "string" } }
25
+ },
26
+ "aliases": {
27
+ "type": "object",
28
+ "required": ["@", "@/components", "@/lib", "@/hooks"],
29
+ "properties": {
30
+ "@": { "type": "string" },
31
+ "@/components": { "type": "string" },
32
+ "@/lib": { "type": "string" },
33
+ "@/hooks": { "type": "string" }
34
+ }
35
+ },
36
+ "paths": {
37
+ "type": "object",
38
+ "required": ["primitives", "components", "blocks", "animations", "utils"],
39
+ "properties": {
40
+ "primitives": { "type": "string" },
41
+ "components": { "type": "string" },
42
+ "blocks": { "type": "string" },
43
+ "animations": { "type": "string" },
44
+ "utils": { "type": "string" },
45
+ "hooks": { "type": "string" },
46
+ "maps": { "type": "string" }
47
+ }
48
+ },
49
+ "hub": {
50
+ "type": "object",
51
+ "properties": {
52
+ "project": {
53
+ "type": "string",
54
+ "pattern": "^[a-z0-9][a-z0-9-]*/[a-z0-9][a-z0-9-]*$"
55
+ },
56
+ "url": { "type": "string", "pattern": "^https?://" }
57
+ }
58
+ }
59
+ }
60
+ }
@@ -1,19 +0,0 @@
1
-
2
- > @foundrykit/cli@2.0.10 build /Users/isj/Desktop/work/projects/foundry/packages/cli
3
- > tsup
4
-
5
- CLI Building entry: {"index":"src/index.ts","cli":"src/index.ts"}
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.0
8
- CLI Using tsup config: /Users/isj/Desktop/work/projects/foundry/packages/cli/tsup.config.ts
9
- CLI Target: es2022
10
- CLI Cleaning output folder
11
- ESM Build start
12
- ESM dist/index.js 77.27 KB
13
- ESM dist/cli.js 77.27 KB
14
- ESM dist/index.js.map 146.30 KB
15
- ESM dist/cli.js.map 146.30 KB
16
- ESM ⚡️ Build success in 232ms
17
- DTS Build start
18
- DTS ⚡️ Build success in 1597ms
19
- DTS dist/index.d.ts 20.00 B
@@ -1,42 +0,0 @@
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
-
@@ -1,4 +0,0 @@
1
-
2
- > @foundrykit/cli@2.0.10 type-check /Users/isj/Desktop/work/projects/foundry/packages/cli
3
- > tsc --noEmit
4
-
package/CHANGELOG.md DELETED
@@ -1,245 +0,0 @@
1
- # @foundrykit/cli
2
-
3
- ## 2.0.11
4
-
5
- ### Patch Changes
6
-
7
- - feat(storybook, maps): massive updates to maps packages spliting and
8
- developing into full suites + storybook for easy of test
9
- - Updated dependencies
10
- - @foundrykit/types@2.0.6
11
-
12
- ## 2.0.10
13
-
14
- ### Patch Changes
15
-
16
- - update
17
- - Updated dependencies
18
- - @foundrykit/types@2.0.5
19
-
20
- ## 2.0.9
21
-
22
- ### Patch Changes
23
-
24
- - updates
25
- - Updated dependencies
26
- - @foundrykit/types@2.0.4
27
-
28
- ## 2.0.8
29
-
30
- ### Patch Changes
31
-
32
- - updates to add
33
-
34
- ## 2.0.7
35
-
36
- ### Patch Changes
37
-
38
- - updates
39
- - Updated dependencies
40
- - @foundrykit/types@2.0.3
41
-
42
- ## 2.0.6
43
-
44
- ### Patch Changes
45
-
46
- - updates
47
- - Updated dependencies
48
- - @foundrykit/types@2.0.2
49
-
50
- ## 2.0.5
51
-
52
- ### Patch Changes
53
-
54
- - updates and adding in new component
55
- - Updated dependencies
56
- - @foundrykit/types@2.0.1
57
-
58
- ## 2.0.4
59
-
60
- ### Patch Changes
61
-
62
- - fix: --opt and -o issue
63
-
64
- ## 2.0.3
65
-
66
- ### Patch Changes
67
-
68
- - updating the update cli to use the --force flag and adding in the -o option
69
-
70
- ## 2.0.2
71
-
72
- ### Patch Changes
73
-
74
- - update to allow for force to eliminate issues with cached components
75
-
76
- ## 2.0.1
77
-
78
- ### Patch Changes
79
-
80
- - changes to cli update logic for old repos
81
- - Updated dependencies
82
- - @foundrykit/types@2.0.0
83
-
84
- ## 2.0.0
85
-
86
- ### Major Changes
87
-
88
- - changes to how the cli works with updates
89
-
90
- ### Patch Changes
91
-
92
- - Updated dependencies
93
- - @foundrykit/types@1.1.0
94
-
95
- ## 1.1.0
96
-
97
- ### Minor Changes
98
-
99
- - c666749: mass update
100
-
101
- ## 1.0.16
102
-
103
- ### Patch Changes
104
-
105
- - Just a quick demo for Anvar
106
- - Updated dependencies
107
- - @foundrykit/types@1.0.9
108
-
109
- ## 1.0.15
110
-
111
- ### Patch Changes
112
-
113
- - updating the way results input works and how results render
114
-
115
- ## 1.0.14
116
-
117
- ### Patch Changes
118
-
119
- - Updated dependencies
120
- - @foundrykit/types@1.0.8
121
-
122
- ## 1.0.13
123
-
124
- ### Patch Changes
125
-
126
- - fix: update import paths in add.ts for consistency
127
- - Refactored import paths in transformImportsForConfig to remove leading '@/'
128
- and ensure a uniform structure.
129
- - Adjusted paths to align with the new component organization.
130
-
131
- ## 1.0.12
132
-
133
- ### Patch Changes
134
-
135
- - Updating import transformations in the paths for internal imports
136
-
137
- ## 1.0.11
138
-
139
- ### Patch Changes
140
-
141
- - Update to the transformation of imports and the toggle file path in its config
142
- - Updated dependencies
143
- - @foundrykit/types@1.0.7
144
-
145
- ## 1.0.10
146
-
147
- ### Patch Changes
148
-
149
- - Update to add command, import transformations and configs for many files
150
- - Updated dependencies
151
- - @foundrykit/types@1.0.6
152
-
153
- ## 1.0.9
154
-
155
- ### Patch Changes
156
-
157
- - Update to config version management and config paths
158
- - Updated dependencies
159
- - @foundrykit/types@1.0.5
160
-
161
- ## 1.0.8
162
-
163
- ### Patch Changes
164
-
165
- - refactoring for build errors
166
- - Updated dependencies
167
- - @foundrykit/types@1.0.4
168
-
169
- ## 1.0.7
170
-
171
- ### Patch Changes
172
-
173
- - Updating blocks config to have the correct dependencies as well as updating
174
- how the cli pulls them and the registry caches them
175
-
176
- ## 1.0.6
177
-
178
- ### Patch Changes
179
-
180
- - Updating the way the initialisation handles various repo structures
181
-
182
- ## 1.0.5
183
-
184
- ### Patch Changes
185
-
186
- - Updating registry data
187
- - Updated dependencies
188
- - @foundrykit/types@1.0.3
189
-
190
- ## 1.0.4
191
-
192
- ### Patch Changes
193
-
194
- - Refactor package dependency handling
195
- - Updated dependencies
196
- - @foundrykit/types@1.0.2
197
-
198
- ## 1.0.3
199
-
200
- ### Patch Changes
201
-
202
- - Add GitHub production registry fetching support
203
-
204
- ## 1.0.2
205
-
206
- ### Patch Changes
207
-
208
- - Updating to use live data
209
-
210
- ## 1.0.1
211
-
212
- ### Patch Changes
213
-
214
- - Updating the way the add commands installs and added external files and
215
- dependencies
216
- - Updated dependencies
217
- - @foundrykit/types@1.0.1
218
-
219
- ## 1.0.0
220
-
221
- ### Major Changes
222
-
223
- - Version alignment push
224
-
225
- ### Patch Changes
226
-
227
- - Updated dependencies
228
- - @foundrykit/types@1.0.0
229
-
230
- ## 0.1.2
231
-
232
- ### Patch Changes
233
-
234
- - 015ff5f: Updating the way the cli works and how it grabs data from the
235
- registry
236
- - Updating versions to ensure they are inline
237
- - Updated dependencies [015ff5f]
238
- - Updated dependencies
239
- - @foundrykit/types@0.1.2
240
-
241
- ## 0.1.1
242
-
243
- ### Patch Changes
244
-
245
- - basic test
@@ -1,201 +0,0 @@
1
- # Dependency Resolution in FoundryKit CLI
2
-
3
- ## Overview
4
-
5
- The FoundryKit CLI handles two types of dependencies when adding components:
6
-
7
- 1. **Registry Dependencies** - Other components or utilities from the registry
8
- that a component depends on
9
- 2. **Package Dependencies** - NPM packages that need to be installed
10
-
11
- ## How It Works
12
-
13
- ### Registry Dependencies
14
-
15
- When a component lists registry dependencies (e.g.,
16
- `registryDependencies: ['utils']`), the CLI:
17
-
18
- 1. **Checks if the dependency already exists** in the project
19
- 2. **Handles special dependencies** (like `utils`) with custom logic
20
- 3. **Fetches regular dependencies** from the registry as components
21
- 4. **Gracefully handles failures** - warns but continues installation
22
-
23
- ### Special Dependencies
24
-
25
- The following dependencies are handled specially:
26
-
27
- - `utils` - Creates a `lib/utils.ts` file with the `cn()` function for className
28
- merging
29
- - `lib` - Alias for `utils`
30
- - `helpers` - Alias for `utils`
31
- - `cn` - Alias for `utils`
32
-
33
- #### Utils Dependency
34
-
35
- When a component requires `utils`, the CLI:
36
-
37
- 1. Checks if `lib/utils.ts` already exists
38
- 2. If not, creates it with the standard `cn()` function:
39
-
40
- ```typescript
41
- import { type ClassValue, clsx } from 'clsx';
42
- import { twMerge } from 'tailwind-merge';
43
-
44
- export function cn(...inputs: ClassValue[]) {
45
- return twMerge(clsx(inputs));
46
- }
47
- ```
48
-
49
- 3. If it exists, preserves the existing file
50
- 4. Notifies about required NPM packages (`clsx`, `tailwind-merge`)
51
-
52
- ### Error Handling
53
-
54
- The dependency resolution system is designed to be resilient:
55
-
56
- - **Missing dependencies**: Logs a warning but continues installation
57
- - **Network failures**: Falls back to local generation for special dependencies
58
- - **Existing files**: Prompts user or skips based on `--overwrite` flag
59
-
60
- ## Examples
61
-
62
- ### Component with Utils Dependency
63
-
64
- ```json
65
- {
66
- "id": "button",
67
- "name": "Button",
68
- "registryDependencies": ["utils"],
69
- "packageDependencies": ["clsx", "tailwind-merge"],
70
- "files": [...]
71
- }
72
- ```
73
-
74
- When installing this component:
75
-
76
- ```bash
77
- foundrykit add button
78
- ```
79
-
80
- The CLI will:
81
-
82
- 1. Check/create `lib/utils.ts`
83
- 2. Install the button component files
84
- 3. Notify about required NPM packages
85
-
86
- ### Component with Multiple Dependencies
87
-
88
- ```json
89
- {
90
- "id": "data-table",
91
- "name": "DataTable",
92
- "registryDependencies": ["utils", "table", "pagination"],
93
- "packageDependencies": ["@tanstack/react-table"],
94
- "files": [...]
95
- }
96
- ```
97
-
98
- The CLI will:
99
-
100
- 1. Process each registry dependency in order
101
- 2. Skip already installed dependencies
102
- 3. Create special dependencies as needed
103
- 4. Fetch regular components from the registry
104
-
105
- ## Implementation Details
106
-
107
- ### Registry Service
108
-
109
- The `RegistryService` class handles dependency resolution:
110
-
111
- ```typescript
112
- // Check if it's a special dependency
113
- if (this.isSpecialDependency(id)) {
114
- return this.createSpecialDependency(id);
115
- }
116
-
117
- // Otherwise, fetch from registry
118
- const component = await registry.getComponent(id);
119
- ```
120
-
121
- ### Add Command
122
-
123
- The `add` command processes dependencies before installing the main component:
124
-
125
- ```typescript
126
- // Install registry dependencies first
127
- if (componentData.registryDependencies?.length) {
128
- for (const dep of componentData.registryDependencies) {
129
- try {
130
- // Special handling for utils
131
- if (dep === 'utils') {
132
- // Create utils file if needed
133
- } else {
134
- // Fetch and install as component
135
- }
136
- } catch (error) {
137
- // Log warning but continue
138
- }
139
- }
140
- }
141
- ```
142
-
143
- ## Testing
144
-
145
- Run the test script to verify dependency resolution:
146
-
147
- ```bash
148
- cd packages/cli
149
- node test-add-command.js
150
- ```
151
-
152
- This tests:
153
-
154
- 1. Utils file creation
155
- 2. Existing file preservation
156
- 3. Missing dependency handling
157
- 4. Error recovery
158
-
159
- ## Best Practices
160
-
161
- ### For Component Authors
162
-
163
- 1. **List all dependencies** in `registryDependencies`
164
- 2. **Use `utils` for className merging** instead of bundling your own
165
- 3. **Specify package dependencies** for NPM packages
166
-
167
- ### For CLI Users
168
-
169
- 1. **Install package dependencies** after adding components
170
- 2. **Use `--overwrite` carefully** to avoid losing customizations
171
- 3. **Check the output** for any warnings about failed dependencies
172
-
173
- ## Troubleshooting
174
-
175
- ### Component fails to install
176
-
177
- 1. Check network connection
178
- 2. Clear cache: `foundrykit cache clear`
179
- 3. Try with `--overwrite` flag if files exist
180
-
181
- ### Utils not found error
182
-
183
- 1. Ensure `lib/utils.ts` exists
184
- 2. Install required packages: `pnpm add clsx tailwind-merge`
185
- 3. Check import path matches: `@/lib/utils`
186
-
187
- ### Dependency not found in registry
188
-
189
- This is usually fine - special dependencies are created locally. The CLI will:
190
-
191
- 1. Log a warning
192
- 2. Create the dependency if it's special (like `utils`)
193
- 3. Continue with the installation
194
-
195
- ## Future Improvements
196
-
197
- - [ ] Dependency version management
198
- - [ ] Circular dependency detection
199
- - [ ] Batch dependency installation
200
- - [ ] Dependency tree visualization
201
- - [ ] Custom dependency handlers
package/eslint.config.js DELETED
@@ -1,4 +0,0 @@
1
- import { config } from "@foundrykit/eslint-config/react-internal"
2
-
3
- /** @type {import("eslint").Linter.Config} */
4
- export default config
@@ -1,6 +0,0 @@
1
- /** @type {import('postcss-load-config').Config} */
2
- const config = {
3
- plugins: { "@tailwindcss/postcss": {} },
4
- };
5
-
6
- export default config;