@the-grove/cli 0.1.9 → 0.1.11
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/README.md +50 -4
- package/dist/index.js +25 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,14 +78,60 @@ Requires GITHUB_TOKEN environment variable or will prompt for token.
|
|
|
78
78
|
|
|
79
79
|
## Development
|
|
80
80
|
|
|
81
|
+
### Local Testing (Recommended)
|
|
82
|
+
|
|
83
|
+
From the repository root:
|
|
84
|
+
|
|
81
85
|
```bash
|
|
82
|
-
#
|
|
83
|
-
npm run
|
|
86
|
+
# Setup local development environment
|
|
87
|
+
npm run dev:link
|
|
84
88
|
|
|
85
|
-
#
|
|
89
|
+
# Test the CLI
|
|
90
|
+
the-grove add async-button
|
|
91
|
+
the-grove list
|
|
92
|
+
|
|
93
|
+
# Watch for changes (in separate terminal)
|
|
94
|
+
cd packages/cli
|
|
86
95
|
npm run dev
|
|
87
96
|
|
|
88
|
-
#
|
|
97
|
+
# Cleanup when done
|
|
98
|
+
cd ../..
|
|
99
|
+
npm run dev:unlink
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Manual Linking
|
|
103
|
+
|
|
104
|
+
If you prefer to link manually:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
cd packages/cli
|
|
108
|
+
|
|
109
|
+
# Build
|
|
110
|
+
npm run build
|
|
111
|
+
|
|
112
|
+
# Link globally
|
|
89
113
|
npm link
|
|
114
|
+
|
|
115
|
+
# Test
|
|
90
116
|
the-grove --help
|
|
117
|
+
|
|
118
|
+
# Unlink when done
|
|
119
|
+
npm unlink -g @the-grove/cli
|
|
91
120
|
```
|
|
121
|
+
|
|
122
|
+
### Quick Testing Without Linking
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# From repository root
|
|
126
|
+
./scripts/test-local.sh add async-button
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Watch Mode
|
|
130
|
+
|
|
131
|
+
For active development with auto-rebuild on file changes:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npm run dev
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
This runs tsup in watch mode - any changes to source files will automatically rebuild the dist folder.
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,11 @@ async function add(components, options) {
|
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
const spinner = ora();
|
|
21
|
+
const results = {
|
|
22
|
+
succeeded: [],
|
|
23
|
+
failed: [],
|
|
24
|
+
skipped: []
|
|
25
|
+
};
|
|
21
26
|
try {
|
|
22
27
|
const stack = await detectProjectStack();
|
|
23
28
|
for (const componentName of components) {
|
|
@@ -25,6 +30,7 @@ async function add(components, options) {
|
|
|
25
30
|
const registryUrl = await findComponentRegistry(componentName);
|
|
26
31
|
if (!registryUrl) {
|
|
27
32
|
spinner.fail(`Component '${componentName}' not found`);
|
|
33
|
+
results.failed.push(componentName);
|
|
28
34
|
continue;
|
|
29
35
|
}
|
|
30
36
|
const registryEntry = await fetchRegistryEntry(registryUrl);
|
|
@@ -39,6 +45,7 @@ async function add(components, options) {
|
|
|
39
45
|
});
|
|
40
46
|
if (!shouldContinue) {
|
|
41
47
|
console.log(chalk.gray(`Skipped ${componentName}`));
|
|
48
|
+
results.skipped.push(componentName);
|
|
42
49
|
continue;
|
|
43
50
|
}
|
|
44
51
|
spinner.start(`Adding ${componentName}...`);
|
|
@@ -59,12 +66,25 @@ async function add(components, options) {
|
|
|
59
66
|
try {
|
|
60
67
|
await execa("npx", args, { stdio: "inherit" });
|
|
61
68
|
console.log(chalk.green(`\u2713 Added ${componentName}`));
|
|
69
|
+
results.succeeded.push(componentName);
|
|
62
70
|
} catch (error) {
|
|
63
71
|
console.log(chalk.red(`\u2717 Failed to add ${componentName}`));
|
|
64
|
-
|
|
72
|
+
results.failed.push(componentName);
|
|
65
73
|
}
|
|
66
74
|
}
|
|
67
|
-
console.log(
|
|
75
|
+
console.log("");
|
|
76
|
+
if (results.succeeded.length > 0) {
|
|
77
|
+
console.log(chalk.green(`\u2705 Successfully added ${results.succeeded.length} component(s)`));
|
|
78
|
+
}
|
|
79
|
+
if (results.failed.length > 0) {
|
|
80
|
+
console.log(chalk.red(`\u2717 Failed to add ${results.failed.length} component(s): ${results.failed.join(", ")}`));
|
|
81
|
+
}
|
|
82
|
+
if (results.skipped.length > 0) {
|
|
83
|
+
console.log(chalk.gray(`\u229D Skipped ${results.skipped.length} component(s): ${results.skipped.join(", ")}`));
|
|
84
|
+
}
|
|
85
|
+
if (results.succeeded.length === 0 && (results.failed.length > 0 || results.skipped.length > 0)) {
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
68
88
|
} catch (error) {
|
|
69
89
|
spinner.stop();
|
|
70
90
|
console.error(chalk.red("\n\u2717 Failed to add component"));
|
|
@@ -293,7 +313,9 @@ ${category.toUpperCase()}:`));
|
|
|
293
313
|
async function fetchCategoryComponents(category) {
|
|
294
314
|
const indexUrl = `${REGISTRY_BASE_URL2}/${category}/index.json`;
|
|
295
315
|
try {
|
|
296
|
-
const response = await fetch(indexUrl
|
|
316
|
+
const response = await fetch(indexUrl, {
|
|
317
|
+
cache: "no-store"
|
|
318
|
+
});
|
|
297
319
|
if (!response.ok) return [];
|
|
298
320
|
return await response.json();
|
|
299
321
|
} catch {
|