@foundrykit/cli 2.0.12 → 3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foundrykit/cli",
3
- "version": "2.0.12",
3
+ "version": "3.1.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,18 +23,19 @@
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.7"
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",
38
+ "@types/node": "^20.19.9",
34
39
  "tsup": "^8.0.0",
35
40
  "typescript": "^5.9.2",
36
41
  "vitest": "^1.2.0",
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,4 +0,0 @@
1
-
2
- > @foundrykit/cli@2.0.12 type-check /home/runner/work/foundry/foundry/packages/cli
3
- > tsc --noEmit
4
-
package/CHANGELOG.md DELETED
@@ -1,254 +0,0 @@
1
- # @foundrykit/cli
2
-
3
- ## 2.0.12
4
-
5
- ### Patch Changes
6
-
7
- - [#43](https://github.com/umi-labs/foundry/pull/43) [`b6fc94d`](https://github.com/umi-labs/foundry/commit/b6fc94d3b0f172aa309388f61bd5306af6405fdf) Thanks [@sneddonisaac](https://github.com/sneddonisaac)! - Package metadata now points at the `umi-labs/foundry` monorepo, and releases publish through npm trusted publishing.
8
-
9
- - Updated dependencies [[`b6fc94d`](https://github.com/umi-labs/foundry/commit/b6fc94d3b0f172aa309388f61bd5306af6405fdf)]:
10
- - @foundrykit/types@2.0.7
11
-
12
- ## 2.0.11
13
-
14
- ### Patch Changes
15
-
16
- - feat(storybook, maps): massive updates to maps packages spliting and
17
- developing into full suites + storybook for easy of test
18
- - Updated dependencies
19
- - @foundrykit/types@2.0.6
20
-
21
- ## 2.0.10
22
-
23
- ### Patch Changes
24
-
25
- - update
26
- - Updated dependencies
27
- - @foundrykit/types@2.0.5
28
-
29
- ## 2.0.9
30
-
31
- ### Patch Changes
32
-
33
- - updates
34
- - Updated dependencies
35
- - @foundrykit/types@2.0.4
36
-
37
- ## 2.0.8
38
-
39
- ### Patch Changes
40
-
41
- - updates to add
42
-
43
- ## 2.0.7
44
-
45
- ### Patch Changes
46
-
47
- - updates
48
- - Updated dependencies
49
- - @foundrykit/types@2.0.3
50
-
51
- ## 2.0.6
52
-
53
- ### Patch Changes
54
-
55
- - updates
56
- - Updated dependencies
57
- - @foundrykit/types@2.0.2
58
-
59
- ## 2.0.5
60
-
61
- ### Patch Changes
62
-
63
- - updates and adding in new component
64
- - Updated dependencies
65
- - @foundrykit/types@2.0.1
66
-
67
- ## 2.0.4
68
-
69
- ### Patch Changes
70
-
71
- - fix: --opt and -o issue
72
-
73
- ## 2.0.3
74
-
75
- ### Patch Changes
76
-
77
- - updating the update cli to use the --force flag and adding in the -o option
78
-
79
- ## 2.0.2
80
-
81
- ### Patch Changes
82
-
83
- - update to allow for force to eliminate issues with cached components
84
-
85
- ## 2.0.1
86
-
87
- ### Patch Changes
88
-
89
- - changes to cli update logic for old repos
90
- - Updated dependencies
91
- - @foundrykit/types@2.0.0
92
-
93
- ## 2.0.0
94
-
95
- ### Major Changes
96
-
97
- - changes to how the cli works with updates
98
-
99
- ### Patch Changes
100
-
101
- - Updated dependencies
102
- - @foundrykit/types@1.1.0
103
-
104
- ## 1.1.0
105
-
106
- ### Minor Changes
107
-
108
- - c666749: mass update
109
-
110
- ## 1.0.16
111
-
112
- ### Patch Changes
113
-
114
- - Just a quick demo for Anvar
115
- - Updated dependencies
116
- - @foundrykit/types@1.0.9
117
-
118
- ## 1.0.15
119
-
120
- ### Patch Changes
121
-
122
- - updating the way results input works and how results render
123
-
124
- ## 1.0.14
125
-
126
- ### Patch Changes
127
-
128
- - Updated dependencies
129
- - @foundrykit/types@1.0.8
130
-
131
- ## 1.0.13
132
-
133
- ### Patch Changes
134
-
135
- - fix: update import paths in add.ts for consistency
136
- - Refactored import paths in transformImportsForConfig to remove leading '@/'
137
- and ensure a uniform structure.
138
- - Adjusted paths to align with the new component organization.
139
-
140
- ## 1.0.12
141
-
142
- ### Patch Changes
143
-
144
- - Updating import transformations in the paths for internal imports
145
-
146
- ## 1.0.11
147
-
148
- ### Patch Changes
149
-
150
- - Update to the transformation of imports and the toggle file path in its config
151
- - Updated dependencies
152
- - @foundrykit/types@1.0.7
153
-
154
- ## 1.0.10
155
-
156
- ### Patch Changes
157
-
158
- - Update to add command, import transformations and configs for many files
159
- - Updated dependencies
160
- - @foundrykit/types@1.0.6
161
-
162
- ## 1.0.9
163
-
164
- ### Patch Changes
165
-
166
- - Update to config version management and config paths
167
- - Updated dependencies
168
- - @foundrykit/types@1.0.5
169
-
170
- ## 1.0.8
171
-
172
- ### Patch Changes
173
-
174
- - refactoring for build errors
175
- - Updated dependencies
176
- - @foundrykit/types@1.0.4
177
-
178
- ## 1.0.7
179
-
180
- ### Patch Changes
181
-
182
- - Updating blocks config to have the correct dependencies as well as updating
183
- how the cli pulls them and the registry caches them
184
-
185
- ## 1.0.6
186
-
187
- ### Patch Changes
188
-
189
- - Updating the way the initialisation handles various repo structures
190
-
191
- ## 1.0.5
192
-
193
- ### Patch Changes
194
-
195
- - Updating registry data
196
- - Updated dependencies
197
- - @foundrykit/types@1.0.3
198
-
199
- ## 1.0.4
200
-
201
- ### Patch Changes
202
-
203
- - Refactor package dependency handling
204
- - Updated dependencies
205
- - @foundrykit/types@1.0.2
206
-
207
- ## 1.0.3
208
-
209
- ### Patch Changes
210
-
211
- - Add GitHub production registry fetching support
212
-
213
- ## 1.0.2
214
-
215
- ### Patch Changes
216
-
217
- - Updating to use live data
218
-
219
- ## 1.0.1
220
-
221
- ### Patch Changes
222
-
223
- - Updating the way the add commands installs and added external files and
224
- dependencies
225
- - Updated dependencies
226
- - @foundrykit/types@1.0.1
227
-
228
- ## 1.0.0
229
-
230
- ### Major Changes
231
-
232
- - Version alignment push
233
-
234
- ### Patch Changes
235
-
236
- - Updated dependencies
237
- - @foundrykit/types@1.0.0
238
-
239
- ## 0.1.2
240
-
241
- ### Patch Changes
242
-
243
- - 015ff5f: Updating the way the cli works and how it grabs data from the
244
- registry
245
- - Updating versions to ensure they are inline
246
- - Updated dependencies [015ff5f]
247
- - Updated dependencies
248
- - @foundrykit/types@0.1.2
249
-
250
- ## 0.1.1
251
-
252
- ### Patch Changes
253
-
254
- - 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
@@ -1,6 +0,0 @@
1
- /** @type {import('postcss-load-config').Config} */
2
- const config = {
3
- plugins: { '@tailwindcss/postcss': {} },
4
- };
5
-
6
- export default config;