@gitton-dev/cli 0.0.2 → 0.0.3
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 +73 -9
- package/package.json +8 -6
package/dist/index.js
CHANGED
|
@@ -136,11 +136,74 @@ async function list(options) {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
// src/commands/search.ts
|
|
140
|
+
import chalk3 from "chalk";
|
|
141
|
+
|
|
142
|
+
// src/generated/plugins.ts
|
|
143
|
+
var availablePlugins = [
|
|
144
|
+
{
|
|
145
|
+
"name": "@gitton-dev/plugin-dependency-graph",
|
|
146
|
+
"shortName": "dependency-graph",
|
|
147
|
+
"version": "0.0.3",
|
|
148
|
+
"description": "Visualize import/require dependencies between files",
|
|
149
|
+
"displayName": "Dependency Graph"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "@gitton-dev/plugin-git-hooks",
|
|
153
|
+
"shortName": "git-hooks",
|
|
154
|
+
"version": "0.0.3",
|
|
155
|
+
"description": "Manage Git hooks with a visual interface",
|
|
156
|
+
"displayName": "Git Hooks"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"name": "@gitton-dev/plugin-github-actions",
|
|
160
|
+
"shortName": "github-actions",
|
|
161
|
+
"version": "0.0.3",
|
|
162
|
+
"description": "View and trigger GitHub Actions workflows",
|
|
163
|
+
"displayName": "GitHub Actions"
|
|
164
|
+
}
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
// src/commands/search.ts
|
|
168
|
+
async function search(query) {
|
|
169
|
+
console.log(chalk3.blue("Available Gitton plugins:"));
|
|
170
|
+
console.log("");
|
|
171
|
+
let plugins = availablePlugins;
|
|
172
|
+
if (query) {
|
|
173
|
+
const q = query.toLowerCase();
|
|
174
|
+
plugins = plugins.filter(
|
|
175
|
+
(p) => p.shortName.toLowerCase().includes(q) || p.name.toLowerCase().includes(q) || p.description.toLowerCase().includes(q)
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
if (plugins.length === 0) {
|
|
179
|
+
console.log(chalk3.gray("No plugins found."));
|
|
180
|
+
if (query) {
|
|
181
|
+
console.log("");
|
|
182
|
+
console.log("Try searching without a query:");
|
|
183
|
+
console.log(chalk3.cyan(" gitton search"));
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
for (const plugin of plugins) {
|
|
188
|
+
console.log(chalk3.green(` ${plugin.shortName}`));
|
|
189
|
+
console.log(chalk3.gray(` ${plugin.name}@${plugin.version}`));
|
|
190
|
+
if (plugin.description) {
|
|
191
|
+
console.log(chalk3.gray(` ${plugin.description}`));
|
|
192
|
+
}
|
|
193
|
+
console.log("");
|
|
194
|
+
}
|
|
195
|
+
console.log("Install a plugin with:");
|
|
196
|
+
console.log(chalk3.cyan(" gitton install <plugin-name>"));
|
|
197
|
+
console.log("");
|
|
198
|
+
console.log("Example:");
|
|
199
|
+
console.log(chalk3.cyan(" gitton install github-actions"));
|
|
200
|
+
}
|
|
201
|
+
|
|
139
202
|
// src/commands/uninstall.ts
|
|
140
203
|
import path3 from "path";
|
|
141
204
|
import fs3 from "fs/promises";
|
|
142
205
|
import os3 from "os";
|
|
143
|
-
import
|
|
206
|
+
import chalk4 from "chalk";
|
|
144
207
|
function getPluginsDir3(isDev) {
|
|
145
208
|
const platform = os3.platform();
|
|
146
209
|
const homeDir = os3.homedir();
|
|
@@ -168,31 +231,31 @@ async function uninstall(packageName, options) {
|
|
|
168
231
|
const packageJsonPath = path3.join(pluginDir, "package.json");
|
|
169
232
|
const content = await fs3.readFile(packageJsonPath, "utf-8");
|
|
170
233
|
const pkg = JSON.parse(content);
|
|
171
|
-
console.log(
|
|
234
|
+
console.log(chalk4.blue(`Uninstalling ${pkg.gitton?.displayName || pkg.name}...`));
|
|
172
235
|
} catch {
|
|
173
|
-
console.log(
|
|
236
|
+
console.log(chalk4.blue(`Uninstalling ${searchName}...`));
|
|
174
237
|
}
|
|
175
238
|
await fs3.rm(pluginDir, { recursive: true, force: true });
|
|
176
|
-
console.log(
|
|
239
|
+
console.log(chalk4.green(`\u2713 Uninstalled ${searchName}`));
|
|
177
240
|
console.log("");
|
|
178
|
-
console.log(
|
|
241
|
+
console.log(chalk4.yellow("Note: Restart Gitton to apply changes."));
|
|
179
242
|
} catch (error) {
|
|
180
243
|
if (error.code === "ENOENT") {
|
|
181
|
-
console.error(
|
|
244
|
+
console.error(chalk4.red(`Error: Plugin "${packageName}" is not installed`));
|
|
182
245
|
console.log("");
|
|
183
246
|
console.log("Installed plugins:");
|
|
184
247
|
try {
|
|
185
248
|
const entries = await fs3.readdir(pluginsDir, { withFileTypes: true });
|
|
186
249
|
for (const entry of entries) {
|
|
187
250
|
if (entry.isDirectory() && !entry.name.startsWith(".")) {
|
|
188
|
-
console.log(
|
|
251
|
+
console.log(chalk4.gray(` - ${entry.name}`));
|
|
189
252
|
}
|
|
190
253
|
}
|
|
191
254
|
} catch {
|
|
192
|
-
console.log(
|
|
255
|
+
console.log(chalk4.gray(" (none)"));
|
|
193
256
|
}
|
|
194
257
|
} else {
|
|
195
|
-
console.error(
|
|
258
|
+
console.error(chalk4.red(`Error: ${error.message}`));
|
|
196
259
|
}
|
|
197
260
|
process.exit(1);
|
|
198
261
|
}
|
|
@@ -204,4 +267,5 @@ program.name("gitton").description("CLI tool for managing Gitton plugins").versi
|
|
|
204
267
|
program.command("install <package>").alias("i").description("Install a Gitton plugin from npm").option("--dev", "Install to development plugins directory").action(install);
|
|
205
268
|
program.command("uninstall <package>").alias("rm").description("Uninstall a Gitton plugin").option("--dev", "Uninstall from development plugins directory").action(uninstall);
|
|
206
269
|
program.command("list").alias("ls").description("List installed Gitton plugins").option("--dev", "List plugins from development directory").action(list);
|
|
270
|
+
program.command("search [query]").alias("s").description("Search available Gitton plugins on npm").action(search);
|
|
207
271
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitton-dev/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "CLI tool for managing Gitton plugins",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -26,19 +26,21 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://jsers.dev/service/gitton",
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"chalk": "^5.4.1",
|
|
29
30
|
"commander": "^13.1.0",
|
|
30
|
-
"pacote": "^21.0.0"
|
|
31
|
-
"chalk": "^5.4.1"
|
|
31
|
+
"pacote": "^21.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^22.13.4",
|
|
35
35
|
"@types/pacote": "^11.1.8",
|
|
36
36
|
"tsup": "^8.4.0",
|
|
37
|
+
"tsx": "^4.21.0",
|
|
37
38
|
"typescript": "^5.7.3"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
41
|
+
"generate": "tsx scripts/generate-plugin-list.ts",
|
|
42
|
+
"build": "pnpm generate && tsup src/index.ts --format esm --dts --clean",
|
|
43
|
+
"dev": "pnpm generate && tsup src/index.ts --format esm --watch",
|
|
44
|
+
"clean": "rm -rf dist src/generated"
|
|
43
45
|
}
|
|
44
46
|
}
|