@the-grove/cli 0.1.0 → 0.1.2
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/dist/index.js +19 -12
- package/package.json +11 -3
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ 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";
|
|
12
13
|
var REGISTRY_BASE_URL = "https://raw.githubusercontent.com/matthewnaples/the-grove/main/packages/registry/registry";
|
|
13
14
|
async function add(components, options) {
|
|
14
15
|
if (!components || components.length === 0) {
|
|
@@ -43,15 +44,7 @@ async function add(components, options) {
|
|
|
43
44
|
}
|
|
44
45
|
spinner.start(`Adding ${componentName}...`);
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
const args = ["shadcn@latest", "add", shadcnUrl];
|
|
48
|
-
if (options.path) {
|
|
49
|
-
args.push("--path", options.path);
|
|
50
|
-
}
|
|
51
|
-
if (options.yes) {
|
|
52
|
-
args.push("--yes");
|
|
53
|
-
}
|
|
54
|
-
await execa("npx", args, { stdio: "inherit" });
|
|
47
|
+
await installComponent(registryEntry, options.path || "components/ui");
|
|
55
48
|
spinner.succeed(`Added ${componentName}`);
|
|
56
49
|
}
|
|
57
50
|
console.log(chalk.green("\n\u2705 All components added successfully!"));
|
|
@@ -116,11 +109,25 @@ async function checkDependencies(registryEntry, stack) {
|
|
|
116
109
|
}
|
|
117
110
|
return missing;
|
|
118
111
|
}
|
|
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, targetPath, path.basename(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
|
+
}
|
|
119
126
|
|
|
120
127
|
// src/commands/contribute.ts
|
|
121
128
|
import { Octokit } from "@octokit/rest";
|
|
122
129
|
import fs2 from "fs-extra";
|
|
123
|
-
import
|
|
130
|
+
import path2 from "path";
|
|
124
131
|
import prompts2 from "prompts";
|
|
125
132
|
import ora2 from "ora";
|
|
126
133
|
import chalk2 from "chalk";
|
|
@@ -140,7 +147,7 @@ async function contribute(filePaths) {
|
|
|
140
147
|
files.push({
|
|
141
148
|
localPath: fp,
|
|
142
149
|
content: await fs2.readFile(fp, "utf-8"),
|
|
143
|
-
componentName:
|
|
150
|
+
componentName: path2.basename(fp, path2.extname(fp))
|
|
144
151
|
});
|
|
145
152
|
}
|
|
146
153
|
const answers = await prompts2([
|
|
@@ -225,7 +232,7 @@ async function contribute(filePaths) {
|
|
|
225
232
|
}
|
|
226
233
|
function mapLocalPathToTemplate(localPath) {
|
|
227
234
|
const normalized = localPath.replace(/^\.\//, "").replace(/components\/ui\//, "components/").replace(/components\//, "");
|
|
228
|
-
const name =
|
|
235
|
+
const name = path2.basename(normalized, path2.extname(normalized));
|
|
229
236
|
return `packages/components/src/core/${name}/index.tsx`;
|
|
230
237
|
}
|
|
231
238
|
async function promptForToken() {
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@the-grove/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for the-grove component library",
|
|
6
6
|
"bin": {
|
|
7
7
|
"the-grove": "./dist/index.js"
|
|
8
8
|
},
|
|
9
|
-
"files": [
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
10
12
|
"scripts": {
|
|
11
13
|
"build": "tsup",
|
|
12
14
|
"dev": "tsup --watch",
|
|
@@ -28,5 +30,11 @@
|
|
|
28
30
|
"tsup": "^8.0.0",
|
|
29
31
|
"typescript": "^5.0.0"
|
|
30
32
|
},
|
|
31
|
-
"keywords": [
|
|
33
|
+
"keywords": [
|
|
34
|
+
"the-grove",
|
|
35
|
+
"components",
|
|
36
|
+
"cli",
|
|
37
|
+
"nextjs",
|
|
38
|
+
"react"
|
|
39
|
+
]
|
|
32
40
|
}
|