@the-grove/cli 0.1.5 → 0.1.8
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 +21 -0
- package/dist/index.js +25 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,27 @@ npx the-grove list
|
|
|
19
19
|
npx the-grove contribute ./components/my-component.tsx
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
## Shadcn Compatibility
|
|
23
|
+
|
|
24
|
+
the-grove registry is fully compatible with shadcn's CLI! You can use either:
|
|
25
|
+
|
|
26
|
+
**the-grove CLI** (recommended for ease of use):
|
|
27
|
+
```bash
|
|
28
|
+
npx the-grove add async-button
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**shadcn CLI** (if you prefer):
|
|
32
|
+
```bash
|
|
33
|
+
npx shadcn@latest add https://raw.githubusercontent.com/matthewnaples/the-grove/main/packages/registry/registry/core/async-button.json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Why Use the-grove CLI?
|
|
37
|
+
|
|
38
|
+
- Automatic component discovery (no need to know category)
|
|
39
|
+
- Stack detection (warns about missing Convex/Clerk dependencies)
|
|
40
|
+
- Browse components with `the-grove list`
|
|
41
|
+
- Same reliable installation (uses shadcn under the hood)
|
|
42
|
+
|
|
22
43
|
## Commands
|
|
23
44
|
|
|
24
45
|
### add
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import ora from "ora";
|
|
|
9
9
|
import chalk from "chalk";
|
|
10
10
|
import prompts from "prompts";
|
|
11
11
|
import fs from "fs-extra";
|
|
12
|
-
import path from "path";
|
|
13
12
|
var REGISTRY_BASE_URL = "https://raw.githubusercontent.com/matthewnaples/the-grove/main/packages/registry/registry";
|
|
14
13
|
async function add(components, options) {
|
|
15
14
|
if (!components || components.length === 0) {
|
|
@@ -44,13 +43,31 @@ async function add(components, options) {
|
|
|
44
43
|
}
|
|
45
44
|
spinner.start(`Adding ${componentName}...`);
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
spinner.stop();
|
|
47
|
+
console.log(chalk.gray(`Installing ${componentName} via shadcn...
|
|
48
|
+
`));
|
|
49
|
+
const args = ["shadcn@latest", "add", registryUrl];
|
|
50
|
+
if (options.yes) {
|
|
51
|
+
args.push("--yes");
|
|
52
|
+
}
|
|
53
|
+
if (options.path) {
|
|
54
|
+
args.push("--path", options.path);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
await execa("npx", args, { stdio: "inherit" });
|
|
58
|
+
console.log(chalk.green(`\u2713 Added ${componentName}`));
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.log(chalk.red(`\u2717 Failed to add ${componentName}`));
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
49
63
|
}
|
|
50
64
|
console.log(chalk.green("\n\u2705 All components added successfully!"));
|
|
51
65
|
} catch (error) {
|
|
52
|
-
spinner.
|
|
53
|
-
console.error(chalk.red(
|
|
66
|
+
spinner.stop();
|
|
67
|
+
console.error(chalk.red("\n\u2717 Failed to add component"));
|
|
68
|
+
if (error instanceof Error && error.message) {
|
|
69
|
+
console.error(chalk.red(error.message));
|
|
70
|
+
}
|
|
54
71
|
process.exit(1);
|
|
55
72
|
}
|
|
56
73
|
}
|
|
@@ -109,25 +126,11 @@ async function checkDependencies(registryEntry, stack) {
|
|
|
109
126
|
}
|
|
110
127
|
return missing;
|
|
111
128
|
}
|
|
112
|
-
async function installComponent(registryEntry, targetPath) {
|
|
113
|
-
const cwd = process.cwd();
|
|
114
|
-
if (registryEntry.dependencies && registryEntry.dependencies.length > 0) {
|
|
115
|
-
console.log(chalk.gray(`Installing dependencies: ${registryEntry.dependencies.join(", ")}`));
|
|
116
|
-
await execa("npm", ["install", ...registryEntry.dependencies], { cwd, stdio: "inherit" });
|
|
117
|
-
}
|
|
118
|
-
for (const file of registryEntry.files) {
|
|
119
|
-
const filePath = path.join(cwd, file.path);
|
|
120
|
-
const dir = path.dirname(filePath);
|
|
121
|
-
await fs.ensureDir(dir);
|
|
122
|
-
await fs.writeFile(filePath, file.content, "utf-8");
|
|
123
|
-
console.log(chalk.gray(` Created ${path.relative(cwd, filePath)}`));
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
129
|
|
|
127
130
|
// src/commands/contribute.ts
|
|
128
131
|
import { Octokit } from "@octokit/rest";
|
|
129
132
|
import fs2 from "fs-extra";
|
|
130
|
-
import
|
|
133
|
+
import path from "path";
|
|
131
134
|
import prompts2 from "prompts";
|
|
132
135
|
import ora2 from "ora";
|
|
133
136
|
import chalk2 from "chalk";
|
|
@@ -147,7 +150,7 @@ async function contribute(filePaths) {
|
|
|
147
150
|
files.push({
|
|
148
151
|
localPath: fp,
|
|
149
152
|
content: await fs2.readFile(fp, "utf-8"),
|
|
150
|
-
componentName:
|
|
153
|
+
componentName: path.basename(fp, path.extname(fp))
|
|
151
154
|
});
|
|
152
155
|
}
|
|
153
156
|
const answers = await prompts2([
|
|
@@ -232,7 +235,7 @@ async function contribute(filePaths) {
|
|
|
232
235
|
}
|
|
233
236
|
function mapLocalPathToTemplate(localPath) {
|
|
234
237
|
const normalized = localPath.replace(/^\.\//, "").replace(/components\/ui\//, "components/").replace(/components\//, "");
|
|
235
|
-
const name =
|
|
238
|
+
const name = path.basename(normalized, path.extname(normalized));
|
|
236
239
|
return `packages/components/src/core/${name}/index.tsx`;
|
|
237
240
|
}
|
|
238
241
|
async function promptForToken() {
|