@bomb.sh/tab 0.0.3 → 0.0.5
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 +153 -167
- package/dist/bin/cli.d.ts +1 -1
- package/dist/bin/cli.js +3 -486
- package/dist/cac-NlDEuVbb.js +1 -0
- package/dist/{src/cac.d.ts → cac.d.ts} +2 -3
- package/dist/cac.js +1 -0
- package/dist/{src/citty.d.ts → citty.d.ts} +2 -3
- package/dist/citty.js +1 -0
- package/dist/{src/commander.d.ts → commander.d.ts} +1 -2
- package/dist/commander.js +1 -0
- package/dist/shared-BkI4Wff4.d.ts +10 -0
- package/dist/shared-CDiJt0Dj.js +1 -0
- package/dist/{t-Zhhzaib1.js → t-BDEAdEmc.js} +117 -461
- package/dist/t-xAUxUB2j.d.ts +67 -0
- package/dist/t.d.ts +2 -0
- package/dist/t.js +1 -0
- package/package.json +23 -7
- package/README.2.md +0 -108
- package/dist/cac-DEQnX2V4.js +0 -89
- package/dist/citty-BJEnxM_0.js +0 -525
- package/dist/commander-gLSiUyHX.js +0 -103
- package/dist/consola.36c0034f-CftISWio.js +0 -832
- package/dist/dist-QXQoOtHE.js +0 -487
- package/dist/examples/demo.cac.d.ts +0 -1
- package/dist/examples/demo.cac.js +0 -63
- package/dist/examples/demo.citty.d.ts +0 -1
- package/dist/examples/demo.citty.js +0 -173
- package/dist/examples/demo.commander.d.ts +0 -1
- package/dist/examples/demo.commander.js +0 -3035
- package/dist/examples/demo.t.d.ts +0 -1
- package/dist/examples/demo.t.js +0 -78
- package/dist/prompt-BeRRtcd8.js +0 -758
- package/dist/shared-BGWjvggn.js +0 -12
- package/dist/shared.d-B8B93rZW.d.ts +0 -11
- package/dist/src/cac.js +0 -5
- package/dist/src/citty.js +0 -6
- package/dist/src/commander.js +0 -5
- package/dist/src/t.d.ts +0 -3
- package/dist/src/t.js +0 -3
- package/dist/t.d-keC1Qwmr.d.ts +0 -68
package/dist/bin/cli.js
CHANGED
|
@@ -1,487 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { RootCommand, script } from "../t-Zhhzaib1.js";
|
|
4
|
-
|
|
5
|
-
import { tab } from "../cac-DEQnX2V4.js";
|
|
6
|
-
import { readFileSync } from "fs";
|
|
7
|
-
import { execSync } from "child_process";
|
|
8
|
-
|
|
9
|
-
//#region bin/completion-handlers.ts
|
|
10
|
-
function getPackageJsonScripts() {
|
|
11
|
-
try {
|
|
12
|
-
const packageJson = JSON.parse(readFileSync("package.json", "utf8"));
|
|
13
|
-
return Object.keys(packageJson.scripts || {});
|
|
14
|
-
} catch {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function getPackageJsonDependencies() {
|
|
19
|
-
try {
|
|
20
|
-
const packageJson = JSON.parse(readFileSync("package.json", "utf8"));
|
|
21
|
-
const deps = {
|
|
22
|
-
...packageJson.dependencies,
|
|
23
|
-
...packageJson.devDependencies,
|
|
24
|
-
...packageJson.peerDependencies,
|
|
25
|
-
...packageJson.optionalDependencies
|
|
26
|
-
};
|
|
27
|
-
return Object.keys(deps);
|
|
28
|
-
} catch {
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const scriptCompletion = async (complete) => {
|
|
33
|
-
const scripts = getPackageJsonScripts();
|
|
34
|
-
scripts.forEach((script$1) => complete(script$1, `Run ${script$1} script`));
|
|
35
|
-
};
|
|
36
|
-
const dependencyCompletion = async (complete) => {
|
|
37
|
-
const deps = getPackageJsonDependencies();
|
|
38
|
-
deps.forEach((dep) => complete(dep, ""));
|
|
39
|
-
};
|
|
40
|
-
function setupCompletionForPackageManager(packageManager, completion) {
|
|
41
|
-
if (packageManager === "pnpm") setupPnpmCompletions(completion);
|
|
42
|
-
else if (packageManager === "npm") setupNpmCompletions(completion);
|
|
43
|
-
else if (packageManager === "yarn") setupYarnCompletions(completion);
|
|
44
|
-
else if (packageManager === "bun") setupBunCompletions(completion);
|
|
45
|
-
}
|
|
46
|
-
function setupPnpmCompletions(completion) {
|
|
47
|
-
const addCmd = completion.command("add", "Install packages");
|
|
48
|
-
addCmd.option("save-dev", "Save to devDependencies", "D");
|
|
49
|
-
addCmd.option("save-optional", "Save to optionalDependencies", "O");
|
|
50
|
-
addCmd.option("save-exact", "Save exact version", "E");
|
|
51
|
-
addCmd.option("global", "Install globally", "g");
|
|
52
|
-
addCmd.option("workspace", "Install to workspace");
|
|
53
|
-
addCmd.option("filter", "Filter packages");
|
|
54
|
-
const removeCmd = completion.command("remove", "Remove packages");
|
|
55
|
-
removeCmd.argument("package", dependencyCompletion);
|
|
56
|
-
removeCmd.option("global", "Remove globally", "g");
|
|
57
|
-
const installCmd = completion.command("install", "Install dependencies");
|
|
58
|
-
installCmd.option("frozen-lockfile", "Install with frozen lockfile");
|
|
59
|
-
installCmd.option("prefer-frozen-lockfile", "Prefer frozen lockfile");
|
|
60
|
-
installCmd.option("production", "Install production dependencies only");
|
|
61
|
-
installCmd.option("dev", "Install dev dependencies only");
|
|
62
|
-
installCmd.option("optional", "Include optional dependencies");
|
|
63
|
-
installCmd.option("filter", "Filter packages");
|
|
64
|
-
const updateCmd = completion.command("update", "Update dependencies");
|
|
65
|
-
updateCmd.argument("package", dependencyCompletion);
|
|
66
|
-
updateCmd.option("latest", "Update to latest versions");
|
|
67
|
-
updateCmd.option("global", "Update global packages", "g");
|
|
68
|
-
updateCmd.option("interactive", "Interactive update", "i");
|
|
69
|
-
const runCmd = completion.command("run", "Run scripts");
|
|
70
|
-
runCmd.argument("script", scriptCompletion, true);
|
|
71
|
-
runCmd.option("parallel", "Run scripts in parallel");
|
|
72
|
-
runCmd.option("stream", "Stream output");
|
|
73
|
-
runCmd.option("filter", "Filter packages");
|
|
74
|
-
const execCmd = completion.command("exec", "Execute commands");
|
|
75
|
-
execCmd.option("filter", "Filter packages");
|
|
76
|
-
execCmd.option("parallel", "Run in parallel");
|
|
77
|
-
execCmd.option("stream", "Stream output");
|
|
78
|
-
completion.command("dlx", "Run package without installing");
|
|
79
|
-
completion.command("create", "Create new project");
|
|
80
|
-
completion.command("init", "Initialize project");
|
|
81
|
-
const publishCmd = completion.command("publish", "Publish package");
|
|
82
|
-
publishCmd.option("tag", "Publish with tag");
|
|
83
|
-
publishCmd.option("access", "Set access level");
|
|
84
|
-
publishCmd.option("otp", "One-time password");
|
|
85
|
-
publishCmd.option("dry-run", "Dry run");
|
|
86
|
-
const packCmd = completion.command("pack", "Create tarball");
|
|
87
|
-
packCmd.option("pack-destination", "Destination directory");
|
|
88
|
-
const linkCmd = completion.command("link", "Link packages");
|
|
89
|
-
linkCmd.option("global", "Link globally", "g");
|
|
90
|
-
const unlinkCmd = completion.command("unlink", "Unlink packages");
|
|
91
|
-
unlinkCmd.option("global", "Unlink globally", "g");
|
|
92
|
-
const listCmd = completion.command("list", "List packages");
|
|
93
|
-
listCmd.option("depth", "Max depth");
|
|
94
|
-
listCmd.option("global", "List global packages", "g");
|
|
95
|
-
listCmd.option("long", "Show extended information");
|
|
96
|
-
listCmd.option("parseable", "Parseable output");
|
|
97
|
-
listCmd.option("json", "JSON output");
|
|
98
|
-
const outdatedCmd = completion.command("outdated", "Check outdated packages");
|
|
99
|
-
outdatedCmd.option("global", "Check global packages", "g");
|
|
100
|
-
outdatedCmd.option("long", "Show extended information");
|
|
101
|
-
const auditCmd = completion.command("audit", "Security audit");
|
|
102
|
-
auditCmd.option("fix", "Automatically fix vulnerabilities");
|
|
103
|
-
auditCmd.option("json", "JSON output");
|
|
104
|
-
completion.command("workspace", "Workspace commands");
|
|
105
|
-
completion.command("store", "Store management");
|
|
106
|
-
completion.command("store status", "Store status");
|
|
107
|
-
completion.command("store prune", "Prune store");
|
|
108
|
-
completion.command("store path", "Store path");
|
|
109
|
-
completion.command("config", "Configuration");
|
|
110
|
-
completion.command("config get", "Get config value");
|
|
111
|
-
completion.command("config set", "Set config value");
|
|
112
|
-
completion.command("config delete", "Delete config value");
|
|
113
|
-
completion.command("config list", "List config");
|
|
114
|
-
completion.command("why", "Explain why package is installed");
|
|
115
|
-
completion.command("rebuild", "Rebuild packages");
|
|
116
|
-
completion.command("root", "Print root directory");
|
|
117
|
-
completion.command("bin", "Print bin directory");
|
|
118
|
-
completion.command("start", "Run start script");
|
|
119
|
-
completion.command("test", "Run test script");
|
|
120
|
-
completion.command("restart", "Run restart script");
|
|
121
|
-
completion.command("stop", "Run stop script");
|
|
122
|
-
}
|
|
123
|
-
function setupNpmCompletions(completion) {
|
|
124
|
-
const installCmd = completion.command("install", "Install packages");
|
|
125
|
-
installCmd.option("save", "Save to dependencies", "S");
|
|
126
|
-
installCmd.option("save-dev", "Save to devDependencies", "D");
|
|
127
|
-
installCmd.option("save-optional", "Save to optionalDependencies", "O");
|
|
128
|
-
installCmd.option("save-exact", "Save exact version", "E");
|
|
129
|
-
installCmd.option("global", "Install globally", "g");
|
|
130
|
-
installCmd.option("production", "Production install");
|
|
131
|
-
installCmd.option("only", "Install only specific dependencies");
|
|
132
|
-
const uninstallCmd = completion.command("uninstall", "Remove packages");
|
|
133
|
-
uninstallCmd.argument("package", dependencyCompletion);
|
|
134
|
-
uninstallCmd.option("save", "Remove from dependencies", "S");
|
|
135
|
-
uninstallCmd.option("save-dev", "Remove from devDependencies", "D");
|
|
136
|
-
uninstallCmd.option("global", "Remove globally", "g");
|
|
137
|
-
const updateCmd = completion.command("update", "Update packages");
|
|
138
|
-
updateCmd.argument("package", dependencyCompletion);
|
|
139
|
-
updateCmd.option("global", "Update global packages", "g");
|
|
140
|
-
const runCmd = completion.command("run", "Run scripts");
|
|
141
|
-
runCmd.argument("script", scriptCompletion, true);
|
|
142
|
-
const runScriptCmd = completion.command("run-script", "Run scripts");
|
|
143
|
-
runScriptCmd.argument("script", scriptCompletion, true);
|
|
144
|
-
completion.command("exec", "Execute command");
|
|
145
|
-
const initCmd = completion.command("init", "Initialize project");
|
|
146
|
-
initCmd.option("yes", "Use defaults", "y");
|
|
147
|
-
initCmd.option("scope", "Set scope");
|
|
148
|
-
const publishCmd = completion.command("publish", "Publish package");
|
|
149
|
-
publishCmd.option("tag", "Publish with tag");
|
|
150
|
-
publishCmd.option("access", "Set access level");
|
|
151
|
-
publishCmd.option("otp", "One-time password");
|
|
152
|
-
publishCmd.option("dry-run", "Dry run");
|
|
153
|
-
completion.command("pack", "Create tarball");
|
|
154
|
-
completion.command("link", "Link packages");
|
|
155
|
-
completion.command("unlink", "Unlink packages");
|
|
156
|
-
const listCmd = completion.command("list", "List packages");
|
|
157
|
-
listCmd.option("depth", "Max depth");
|
|
158
|
-
listCmd.option("global", "List global packages", "g");
|
|
159
|
-
listCmd.option("long", "Show extended information");
|
|
160
|
-
listCmd.option("parseable", "Parseable output");
|
|
161
|
-
listCmd.option("json", "JSON output");
|
|
162
|
-
const lsCmd = completion.command("ls", "List packages (alias)");
|
|
163
|
-
lsCmd.option("depth", "Max depth");
|
|
164
|
-
lsCmd.option("global", "List global packages", "g");
|
|
165
|
-
const outdatedCmd = completion.command("outdated", "Check outdated packages");
|
|
166
|
-
outdatedCmd.option("global", "Check global packages", "g");
|
|
167
|
-
const auditCmd = completion.command("audit", "Security audit");
|
|
168
|
-
auditCmd.option("fix", "Fix vulnerabilities");
|
|
169
|
-
auditCmd.option("json", "JSON output");
|
|
170
|
-
completion.command("config", "Configuration");
|
|
171
|
-
completion.command("config get", "Get config value");
|
|
172
|
-
completion.command("config set", "Set config value");
|
|
173
|
-
completion.command("config delete", "Delete config value");
|
|
174
|
-
completion.command("config list", "List config");
|
|
175
|
-
completion.command("version", "Bump version");
|
|
176
|
-
completion.command("view", "View package info");
|
|
177
|
-
completion.command("search", "Search packages");
|
|
178
|
-
completion.command("whoami", "Display username");
|
|
179
|
-
completion.command("login", "Login to registry");
|
|
180
|
-
completion.command("logout", "Logout from registry");
|
|
181
|
-
completion.command("adduser", "Add user");
|
|
182
|
-
completion.command("owner", "Manage package owners");
|
|
183
|
-
completion.command("deprecate", "Deprecate package");
|
|
184
|
-
completion.command("dist-tag", "Manage distribution tags");
|
|
185
|
-
completion.command("cache", "Manage cache");
|
|
186
|
-
completion.command("completion", "Tab completion");
|
|
187
|
-
completion.command("explore", "Browse package");
|
|
188
|
-
completion.command("docs", "Open documentation");
|
|
189
|
-
completion.command("repo", "Open repository");
|
|
190
|
-
completion.command("bugs", "Open bug tracker");
|
|
191
|
-
completion.command("help", "Get help");
|
|
192
|
-
completion.command("root", "Print root directory");
|
|
193
|
-
completion.command("prefix", "Print prefix");
|
|
194
|
-
completion.command("bin", "Print bin directory");
|
|
195
|
-
completion.command("fund", "Fund packages");
|
|
196
|
-
completion.command("find-dupes", "Find duplicate packages");
|
|
197
|
-
completion.command("dedupe", "Deduplicate packages");
|
|
198
|
-
completion.command("prune", "Remove extraneous packages");
|
|
199
|
-
completion.command("rebuild", "Rebuild packages");
|
|
200
|
-
completion.command("start", "Run start script");
|
|
201
|
-
completion.command("stop", "Run stop script");
|
|
202
|
-
completion.command("test", "Run test script");
|
|
203
|
-
completion.command("restart", "Run restart script");
|
|
204
|
-
}
|
|
205
|
-
function setupYarnCompletions(completion) {
|
|
206
|
-
const addCmd = completion.command("add", "Add packages");
|
|
207
|
-
addCmd.option("dev", "Add to devDependencies", "D");
|
|
208
|
-
addCmd.option("peer", "Add to peerDependencies", "P");
|
|
209
|
-
addCmd.option("optional", "Add to optionalDependencies", "O");
|
|
210
|
-
addCmd.option("exact", "Add exact version", "E");
|
|
211
|
-
addCmd.option("tilde", "Add with tilde range", "T");
|
|
212
|
-
const removeCmd = completion.command("remove", "Remove packages");
|
|
213
|
-
removeCmd.argument("package", dependencyCompletion);
|
|
214
|
-
const installCmd = completion.command("install", "Install dependencies");
|
|
215
|
-
installCmd.option("frozen-lockfile", "Install with frozen lockfile");
|
|
216
|
-
installCmd.option("prefer-offline", "Prefer offline");
|
|
217
|
-
installCmd.option("production", "Production install");
|
|
218
|
-
installCmd.option("pure-lockfile", "Pure lockfile");
|
|
219
|
-
installCmd.option("focus", "Focus install");
|
|
220
|
-
installCmd.option("har", "Save HAR file");
|
|
221
|
-
const upgradeCmd = completion.command("upgrade", "Upgrade packages");
|
|
222
|
-
upgradeCmd.argument("package", dependencyCompletion);
|
|
223
|
-
upgradeCmd.option("latest", "Upgrade to latest");
|
|
224
|
-
upgradeCmd.option("pattern", "Upgrade pattern");
|
|
225
|
-
upgradeCmd.option("scope", "Upgrade scope");
|
|
226
|
-
const upgradeInteractiveCmd = completion.command("upgrade-interactive", "Interactive upgrade");
|
|
227
|
-
upgradeInteractiveCmd.option("latest", "Show latest versions");
|
|
228
|
-
const runCmd = completion.command("run", "Run scripts");
|
|
229
|
-
runCmd.argument("script", scriptCompletion, true);
|
|
230
|
-
completion.command("exec", "Execute command");
|
|
231
|
-
completion.command("create", "Create new project");
|
|
232
|
-
const initCmd = completion.command("init", "Initialize project");
|
|
233
|
-
initCmd.option("yes", "Use defaults", "y");
|
|
234
|
-
initCmd.option("private", "Create private package", "p");
|
|
235
|
-
const publishCmd = completion.command("publish", "Publish package");
|
|
236
|
-
publishCmd.option("tag", "Publish with tag");
|
|
237
|
-
publishCmd.option("access", "Set access level");
|
|
238
|
-
publishCmd.option("new-version", "Set new version");
|
|
239
|
-
const packCmd = completion.command("pack", "Create tarball");
|
|
240
|
-
packCmd.option("filename", "Output filename");
|
|
241
|
-
completion.command("link", "Link packages");
|
|
242
|
-
completion.command("unlink", "Unlink packages");
|
|
243
|
-
const listCmd = completion.command("list", "List packages");
|
|
244
|
-
listCmd.option("depth", "Max depth");
|
|
245
|
-
listCmd.option("pattern", "Filter pattern");
|
|
246
|
-
completion.command("info", "Show package info");
|
|
247
|
-
completion.command("outdated", "Check outdated packages");
|
|
248
|
-
const auditCmd = completion.command("audit", "Security audit");
|
|
249
|
-
auditCmd.option("level", "Minimum severity level");
|
|
250
|
-
completion.command("workspace", "Workspace commands");
|
|
251
|
-
completion.command("workspaces", "Workspaces commands");
|
|
252
|
-
completion.command("workspaces info", "Workspace info");
|
|
253
|
-
completion.command("workspaces run", "Run in workspaces");
|
|
254
|
-
completion.command("config", "Configuration");
|
|
255
|
-
completion.command("config get", "Get config value");
|
|
256
|
-
completion.command("config set", "Set config value");
|
|
257
|
-
completion.command("config delete", "Delete config value");
|
|
258
|
-
completion.command("config list", "List config");
|
|
259
|
-
completion.command("cache", "Cache management");
|
|
260
|
-
completion.command("cache list", "List cache");
|
|
261
|
-
completion.command("cache dir", "Cache directory");
|
|
262
|
-
completion.command("cache clean", "Clean cache");
|
|
263
|
-
completion.command("version", "Show version");
|
|
264
|
-
completion.command("versions", "Show all versions");
|
|
265
|
-
completion.command("why", "Explain installation");
|
|
266
|
-
completion.command("owner", "Manage owners");
|
|
267
|
-
completion.command("team", "Manage teams");
|
|
268
|
-
completion.command("login", "Login to registry");
|
|
269
|
-
completion.command("logout", "Logout from registry");
|
|
270
|
-
completion.command("tag", "Manage tags");
|
|
271
|
-
completion.command("global", "Global packages");
|
|
272
|
-
completion.command("bin", "Print bin directory");
|
|
273
|
-
completion.command("dir", "Print modules directory");
|
|
274
|
-
completion.command("licenses", "List licenses");
|
|
275
|
-
completion.command("generate-lock-entry", "Generate lock entry");
|
|
276
|
-
completion.command("check", "Verify package tree");
|
|
277
|
-
completion.command("import", "Import from npm");
|
|
278
|
-
completion.command("install-peerdeps", "Install peer dependencies");
|
|
279
|
-
completion.command("autoclean", "Clean unnecessary files");
|
|
280
|
-
completion.command("policies", "Policies");
|
|
281
|
-
completion.command("start", "Run start script");
|
|
282
|
-
completion.command("test", "Run test script");
|
|
283
|
-
completion.command("node", "Run node");
|
|
284
|
-
}
|
|
285
|
-
function setupBunCompletions(completion) {
|
|
286
|
-
const addCmd = completion.command("add", "Add packages");
|
|
287
|
-
addCmd.option("development", "Add to devDependencies", "d");
|
|
288
|
-
addCmd.option("optional", "Add to optionalDependencies");
|
|
289
|
-
addCmd.option("exact", "Add exact version", "E");
|
|
290
|
-
addCmd.option("global", "Install globally", "g");
|
|
291
|
-
const removeCmd = completion.command("remove", "Remove packages");
|
|
292
|
-
removeCmd.argument("package", dependencyCompletion);
|
|
293
|
-
removeCmd.option("global", "Remove globally", "g");
|
|
294
|
-
const installCmd = completion.command("install", "Install dependencies");
|
|
295
|
-
installCmd.option("production", "Production install");
|
|
296
|
-
installCmd.option("frozen-lockfile", "Use frozen lockfile");
|
|
297
|
-
installCmd.option("dry-run", "Dry run");
|
|
298
|
-
installCmd.option("force", "Force install");
|
|
299
|
-
installCmd.option("silent", "Silent install");
|
|
300
|
-
const updateCmd = completion.command("update", "Update packages");
|
|
301
|
-
updateCmd.argument("package", dependencyCompletion);
|
|
302
|
-
updateCmd.option("global", "Update global packages", "g");
|
|
303
|
-
const runCmd = completion.command("run", "Run scripts");
|
|
304
|
-
runCmd.argument("script", scriptCompletion, true);
|
|
305
|
-
runCmd.option("silent", "Silent output");
|
|
306
|
-
runCmd.option("bun", "Use bun runtime");
|
|
307
|
-
const xCmd = completion.command("x", "Execute packages");
|
|
308
|
-
xCmd.option("bun", "Use bun runtime");
|
|
309
|
-
completion.command("dev", "Development server");
|
|
310
|
-
completion.command("build", "Build project");
|
|
311
|
-
completion.command("test", "Run tests");
|
|
312
|
-
completion.command("create", "Create new project");
|
|
313
|
-
const initCmd = completion.command("init", "Initialize project");
|
|
314
|
-
initCmd.option("yes", "Use defaults", "y");
|
|
315
|
-
const publishCmd = completion.command("publish", "Publish package");
|
|
316
|
-
publishCmd.option("tag", "Publish with tag");
|
|
317
|
-
publishCmd.option("access", "Set access level");
|
|
318
|
-
publishCmd.option("otp", "One-time password");
|
|
319
|
-
completion.command("pack", "Create tarball");
|
|
320
|
-
completion.command("link", "Link packages");
|
|
321
|
-
completion.command("unlink", "Unlink packages");
|
|
322
|
-
const listCmd = completion.command("list", "List packages");
|
|
323
|
-
listCmd.option("global", "List global packages", "g");
|
|
324
|
-
completion.command("outdated", "Check outdated packages");
|
|
325
|
-
completion.command("audit", "Security audit");
|
|
326
|
-
completion.command("config", "Configuration");
|
|
327
|
-
completion.command("bun", "Run with Bun runtime");
|
|
328
|
-
completion.command("node", "Node.js compatibility");
|
|
329
|
-
completion.command("upgrade", "Upgrade Bun");
|
|
330
|
-
completion.command("completions", "Generate completions");
|
|
331
|
-
completion.command("discord", "Open Discord");
|
|
332
|
-
completion.command("help", "Show help");
|
|
333
|
-
completion.command("install.cache", "Cache operations");
|
|
334
|
-
completion.command("pm", "Package manager operations");
|
|
335
|
-
completion.command("start", "Run start script");
|
|
336
|
-
completion.command("stop", "Run stop script");
|
|
337
|
-
completion.command("restart", "Run restart script");
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
//#endregion
|
|
341
|
-
//#region bin/package-manager-completion.ts
|
|
342
|
-
function debugLog(...args) {
|
|
343
|
-
if (process.env.DEBUG) console.error("[DEBUG]", ...args);
|
|
344
|
-
}
|
|
345
|
-
async function checkCliHasCompletions(cliName, packageManager) {
|
|
346
|
-
try {
|
|
347
|
-
debugLog(`Checking if ${cliName} has completions via ${packageManager}`);
|
|
348
|
-
const command = `${packageManager} ${cliName} complete --`;
|
|
349
|
-
const result = execSync(command, {
|
|
350
|
-
encoding: "utf8",
|
|
351
|
-
stdio: [
|
|
352
|
-
"pipe",
|
|
353
|
-
"pipe",
|
|
354
|
-
"ignore"
|
|
355
|
-
],
|
|
356
|
-
timeout: 1e3
|
|
357
|
-
});
|
|
358
|
-
const hasCompletions = !!result.trim();
|
|
359
|
-
debugLog(`${cliName} supports completions: ${hasCompletions}`);
|
|
360
|
-
return hasCompletions;
|
|
361
|
-
} catch (error) {
|
|
362
|
-
debugLog(`Error checking completions for ${cliName}:`, error);
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
async function getCliCompletions(cliName, packageManager, args) {
|
|
367
|
-
try {
|
|
368
|
-
const completeArgs = args.map((arg) => arg.includes(" ") ? `"${arg}"` : arg);
|
|
369
|
-
const completeCommand = `${packageManager} ${cliName} complete -- ${completeArgs.join(" ")}`;
|
|
370
|
-
debugLog(`Getting completions with command: ${completeCommand}`);
|
|
371
|
-
const result = execSync(completeCommand, {
|
|
372
|
-
encoding: "utf8",
|
|
373
|
-
stdio: [
|
|
374
|
-
"pipe",
|
|
375
|
-
"pipe",
|
|
376
|
-
"ignore"
|
|
377
|
-
],
|
|
378
|
-
timeout: 1e3
|
|
379
|
-
});
|
|
380
|
-
const completions = result.trim().split("\n").filter(Boolean);
|
|
381
|
-
debugLog(`Got ${completions.length} completions from ${cliName}`);
|
|
382
|
-
return completions;
|
|
383
|
-
} catch (error) {
|
|
384
|
-
debugLog(`Error getting completions from ${cliName}:`, error);
|
|
385
|
-
return [];
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Package Manager Completion Wrapper
|
|
390
|
-
*
|
|
391
|
-
* This extends RootCommand and adds package manager-specific logic.
|
|
392
|
-
* It acts as a layer on top of the core tab library.
|
|
393
|
-
*/
|
|
394
|
-
var PackageManagerCompletion = class extends RootCommand {
|
|
395
|
-
packageManager;
|
|
396
|
-
constructor(packageManager) {
|
|
397
|
-
super();
|
|
398
|
-
this.packageManager = packageManager;
|
|
399
|
-
}
|
|
400
|
-
async parse(args) {
|
|
401
|
-
if (args.length >= 1 && args[0].trim() !== "") {
|
|
402
|
-
const potentialCliName = args[0];
|
|
403
|
-
const knownCommands = [...this.commands.keys()];
|
|
404
|
-
if (!knownCommands.includes(potentialCliName)) {
|
|
405
|
-
const hasCompletions = await checkCliHasCompletions(potentialCliName, this.packageManager);
|
|
406
|
-
if (hasCompletions) {
|
|
407
|
-
const cliArgs = args.slice(1);
|
|
408
|
-
const suggestions = await getCliCompletions(potentialCliName, this.packageManager, cliArgs);
|
|
409
|
-
if (suggestions.length > 0) {
|
|
410
|
-
for (const suggestion of suggestions) {
|
|
411
|
-
if (suggestion.startsWith(":")) continue;
|
|
412
|
-
if (suggestion.includes(" ")) {
|
|
413
|
-
const [value, description] = suggestion.split(" ");
|
|
414
|
-
console.log(`${value}\t${description}`);
|
|
415
|
-
} else console.log(suggestion);
|
|
416
|
-
}
|
|
417
|
-
console.log(":4");
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
return super.parse(args);
|
|
424
|
-
}
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region bin/cli.ts
|
|
429
|
-
const packageManagers = [
|
|
430
|
-
"npm",
|
|
431
|
-
"pnpm",
|
|
432
|
-
"yarn",
|
|
433
|
-
"bun"
|
|
434
|
-
];
|
|
435
|
-
const shells = [
|
|
436
|
-
"zsh",
|
|
437
|
-
"bash",
|
|
438
|
-
"fish",
|
|
439
|
-
"powershell"
|
|
440
|
-
];
|
|
441
|
-
async function main() {
|
|
442
|
-
const cli = dist_default("tab");
|
|
443
|
-
const args = process.argv.slice(2);
|
|
444
|
-
if (args.length >= 2 && args[1] === "complete") {
|
|
445
|
-
const packageManager = args[0];
|
|
446
|
-
if (!packageManagers.includes(packageManager)) {
|
|
447
|
-
console.error(`Error: Unsupported package manager "${packageManager}"`);
|
|
448
|
-
console.error(`Supported package managers: ${packageManagers.join(", ")}`);
|
|
449
|
-
process.exit(1);
|
|
450
|
-
}
|
|
451
|
-
const dashIndex = process.argv.indexOf("--");
|
|
452
|
-
if (dashIndex !== -1) {
|
|
453
|
-
const completion = new PackageManagerCompletion(packageManager);
|
|
454
|
-
setupCompletionForPackageManager(packageManager, completion);
|
|
455
|
-
const toComplete = process.argv.slice(dashIndex + 1);
|
|
456
|
-
await completion.parse(toComplete);
|
|
457
|
-
process.exit(0);
|
|
458
|
-
} else {
|
|
459
|
-
console.error(`Error: Expected '--' followed by command to complete`);
|
|
460
|
-
console.error(`Example: ${packageManager} exec @bomb.sh/tab ${packageManager} complete -- command-to-complete`);
|
|
461
|
-
process.exit(1);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
cli.command("<packageManager> <shell>", "Generate shell completion script for a package manager").action(async (packageManager, shell) => {
|
|
465
|
-
if (!packageManagers.includes(packageManager)) {
|
|
466
|
-
console.error(`Error: Unsupported package manager "${packageManager}"`);
|
|
467
|
-
console.error(`Supported package managers: ${packageManagers.join(", ")}`);
|
|
468
|
-
process.exit(1);
|
|
469
|
-
}
|
|
470
|
-
if (!shells.includes(shell)) {
|
|
471
|
-
console.error(`Error: Unsupported shell "${shell}"`);
|
|
472
|
-
console.error(`Supported shells: ${shells.join(", ")}`);
|
|
473
|
-
process.exit(1);
|
|
474
|
-
}
|
|
475
|
-
generateCompletionScript(packageManager, shell);
|
|
476
|
-
});
|
|
477
|
-
tab(cli);
|
|
478
|
-
cli.parse();
|
|
479
|
-
}
|
|
480
|
-
function generateCompletionScript(packageManager, shell) {
|
|
481
|
-
const name = packageManager;
|
|
482
|
-
const executable = `node ${process.argv[1]} ${packageManager}`;
|
|
483
|
-
script(shell, name, executable);
|
|
484
|
-
}
|
|
485
|
-
main().catch(console.error);
|
|
486
|
-
|
|
487
|
-
//#endregion
|
|
2
|
+
import{RootCommand as e,script as t}from"../t-BDEAdEmc.js";import"../shared-CDiJt0Dj.js";import{tab as n}from"../cac-NlDEuVbb.js";import r from"cac";import{readFileSync as i}from"node:fs";import{promisify as a}from"node:util";import o from"node:child_process";import{readFileSync as s}from"fs";import{execSync as c}from"child_process";function l(){try{let e;try{e=i(`pnpm-workspace.yaml`,`utf8`)}catch{e=i(`pnpm-workspace.yml`,`utf8`)}let t=e.match(/packages:\s*\n((?:\s*-\s*.+\n?)*)/);return t?t[1].split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(e=>e.startsWith(`-`)).map(e=>e.substring(1).trim()).filter(e=>e&&!e.startsWith(`#`)):[]}catch{return[]}}function ee(){try{let e=JSON.parse(s(`package.json`,`utf8`));return Object.keys(e.scripts||{})}catch{return[]}}function te(){try{let e=JSON.parse(s(`package.json`,`utf8`)),t={...e.dependencies,...e.devDependencies,...e.peerDependencies,...e.optionalDependencies};return Object.keys(t)}catch{return[]}}const ne=async e=>{ee().forEach(t=>{let n=t.replace(/:/g,`\\:`);e(n,` `)})},u=async e=>{te().forEach(t=>e(t,``))},re=a(o.exec),{execSync:ie}=o,d={workspace(e){l().forEach(t=>e(t,`Workspace pattern: ${t}`))}};function f(e,t,n,r){e._lazyCommand=t,e._optionsLoaded=!1;let i=e.options;e.optionsRaw=i,Object.defineProperty(e,`options`,{get(){return this._optionsLoaded||(this._optionsLoaded=!0,r(this,this._lazyCommand)),i},configurable:!0})}function p(e,t,n){[`remove`,`rm`,`uninstall`,`un`,`update`,`up`].includes(t)&&e.argument(`package`,u),[`run`,`run-script`].includes(t)&&e.argument(`script`,ne,!0)}async function m(e,t={}){try{let{stdout:n}=await re(e,{encoding:`utf8`,timeout:500,maxBuffer:4*1024*1024,...t});return n}catch(e){return e instanceof Error&&`stdout`in e?e.stdout:``}}function h(e,t={}){try{return ie(e,{encoding:`utf8`,timeout:500,...t})}catch(e){return e?.stdout?e.stdout:``}}function g(e){return t=>e.forEach(e=>t(e,` `))}const ae=/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,_=/^\s+([a-z][a-z\s,-]*?)\s{2,}(\S.*)$/i,v=/^\s*(?:-(?<short>[A-Za-z]),\s*)?--(?<long>[a-z0-9-]+)(?<val>\s+(?:<[^>]+>|\[[^\]]+\]))?\s{2,}(?<desc>\S.*)$/i,oe=/^\s*(?:-[A-Za-z],\s*)?--[a-z0-9-]+/i,y=e=>e.replace(ae,``),b=e=>(e.match(/^\s*/)||[``])[0].length,x=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),se=/^\s*Options:/i,ce=/(?:levels?|options?|values?)[^:]*:\s*([^.]+)/i,le=/\r?\n/,ue=/[,\s]+/,S=/^\s*(?:-\w,?\s*)?--(\w+(?:-\w+)*)\s+(\w+(?:-\w+)*)\s+(.+)$/,C=/^\s*-\w,?\s*--\w+(?:,\s*--(\w+(?:-\w+)*)\s+(\w+(?:-\w+)*))?\s+(.+)$/,w=/^\s{20,}/,T=/^\s*[A-Z][^:]*:\s*$/;function E(e){return y(e).split(le)}function de(e){let t=1/0;for(let n of e){let e=n.match(_);if(!e)continue;let r=n.indexOf(e[2]);r>=0&&r<t&&(t=r)}return t}function fe(e,t){let n=1/0;for(let r of e){let e=r.match(v);if(!e||t&&e.groups?.val)continue;let i=r.indexOf(e.groups.desc);i>=0&&i<n&&(n=i)}return n}function D(e,t){let n=E(e),r=[];for(let e=0;e<n.length;e++){let i=n[e],a=i.match(S);if(a){let[,i,o,s]=a;if(i===t){let t=s.trim(),i=e+1;for(;i<n.length;){let e=n[i],r=w.test(e),a=S.test(e)||C.test(e),o=!e.trim()||T.test(e);if(r&&!a&&!o)t+=` `+e.trim(),i++;else break}r.push({value:o,desc:t})}}let o=i.match(C);if(o){let[,i,a,s]=o;if(i===t&&a){let t=s.trim(),i=e+1;for(;i<n.length;){let e=n[i],r=w.test(e),a=S.test(e)||C.test(e),o=!e.trim()||T.test(e);if(r&&!a&&!o)t+=` `+e.trim(),i++;else break}r.push({value:a,desc:t})}}}if(r.length)return r;for(let e=0;e<n.length;e++){let r=n[e];if(r.includes(`--${t}`)||r.includes(`${t}:`))for(let t=e;t<Math.min(e+3,n.length);t++){let e=n[t].match(ce);if(e)return e[1].split(ue).map(e=>e.trim()).filter(e=>e&&!e.includes(`(`)&&!e.includes(`)`)).map(e=>({value:e,desc:`Log level: ${e}`}))}}return[]}const O={...d,loglevel(e){let t=D(h(`pnpm install --help`),`loglevel`);t.length?t.forEach(({value:t,desc:n})=>e(t,n)):g([`debug`,`info`,`warn`,`error`,`silent`])(e)},reporter(e){let t=D(h(`pnpm install --help`),`reporter`);t.length?t.forEach(({value:t,desc:n})=>e(t,n)):g([`default`,`append-only`,`ndjson`,`silent`])(e)},filter(e){e(`.`,`Current working directory`),e(`!<selector>`,`Exclude packages matching selector`),l().forEach(t=>{e(t,`Workspace pattern: ${t}`),e(`${t}...`,`Include dependencies of ${t}`)}),e(`@*/*`,`All scoped packages`),e(`...<pattern>`,`Include dependencies of pattern`),e(`<pattern>...`,`Include dependents of pattern`)}};function pe(e){let t=E(e),n=de(t);if(!Number.isFinite(n))return{};let r=null,i=new Map,a=()=>{if(!r)return;let e=r.desc.trim();for(let t of r.names)i.set(t,e);r=null};for(let e of t){if(se.test(e))break;let t=e.match(_);if(t){a(),r={names:x(t[1]),desc:t[2].trim()};continue}r&&b(e)>=n&&e.trim()&&(r.desc+=` `+e.trim())}return a(),Object.fromEntries(i)}async function k(){let e=await m(`pnpm --help`);return e?pe(e):{}}function A(e,{flagsOnly:t=!0}={}){let n=E(e),r=fe(n,t);if(!Number.isFinite(r))return[];let i=[],a=null,o=()=>{a&&=(a.desc=a.desc.trim(),i.push(a),null)};for(let e of n){let n=e.match(v);if(n){if(t&&n.groups?.val)continue;o(),a={short:n.groups?.short||void 0,long:n.groups.long,desc:n.groups.desc.trim()};continue}if(a){let t=b(e),n=oe.test(e);t>=r&&e.trim()&&!n&&(a.desc+=` `+e.trim())}}return o(),i}function j(e,t){let n=h(`pnpm ${t} --help`);if(!n)return;let r=A(n,{flagsOnly:!1});for(let{long:t,short:n,desc:i}of r){if(e.optionsRaw?.get?.(t))continue;let r=O[t];r?e.option(t,i,r,n):e.option(t,i,n)}for(let[t,r]of Object.entries(O))e.optionsRaw?.get?.(t)||D(n,t).length>0&&e.option(t,` `,r)}async function M(e){try{let t=await k();for(let[n,r]of Object.entries(t)){let t=e.command(n,r);p(t,n,`pnpm`),f(t,n,`pnpm`,j)}}catch{}}const N=/^All commands:\s*$/i,P=/^Options:\s*$/i,F=/^(aliases|run|more)/i,I=/^[a-z][a-z0-9-]*$/,L=/(?:\[)?(?:-([a-z])\|)?--([a-z][a-z0-9-]+)(?:\s+<[^>]+>)?(?:\])?/gi,R=/<[^>]+>/,z=/^\s/;function B(e){return y(e).split(/\r?\n/)}function me(e,t){let n=e.findIndex(e=>t.test(e.trim()));if(n===-1)return``;let r=``;for(let t=n+1;t<e.length;t++){let n=e[t];if(!z.test(n)&&n.trim()&&!n.includes(`,`))break;z.test(n)&&(r+=` `+n.trim())}return r}const V=(e,t=()=>` `)=>n=>e.forEach(e=>n(e,t(e))),he={...d,loglevel:g([`silent`,`error`,`warn`,`notice`,`http`,`info`,`verbose`,`silly`]),"install-strategy":V([`hoisted`,`nested`,`shallow`,`linked`],()=>` `),omit:V([`dev`,`optional`,`peer`],()=>` `),include:V([`prod`,`dev`,`optional`,`peer`],()=>` `)};function ge(e){let t=B(e),n=me(t,N);if(!n)return{};let r={};return n.split(`,`).map(e=>e.trim()).filter(e=>e&&I.test(e)).forEach(e=>{r[e]=` `}),r.run=` `,r}async function _e(){let e=await m(`npm --help`);return e?ge(e):{}}function ve(e,{flagsOnly:t=!0}={}){let n=B(e),r=n.findIndex(e=>P.test(e.trim()));if(r===-1)return[];let i=[];for(let e of n.slice(r+1)){let n=e.trim();if(F.test(n))break;let r=e.matchAll(L);for(let e of r){let n=e[1]||void 0,r=e[2],a=R.test(e[0]);if(t&&a)continue;i.push({short:n,long:r,desc:` `})}}return i}function ye(e,t){let n=h(`npm ${t} --help`);if(!n)return;let r=ve(n,{flagsOnly:!1});for(let{long:t,short:n,desc:i}of r){if(e.optionsRaw?.get?.(t))continue;let r=he[t];r?e.option(t,i,r,n):e.option(t,i,n)}}async function be(e){try{let t=await _e();for(let[n,r]of Object.entries(t)){let t=e.command(n,r);p(t,n,`npm`),f(t,n,`npm`,ye)}}catch{}}const xe=/^\s*Options:\s*$/i,Se=/^\s*Commands:\s*$/i,H=/^(Run `yarn help|Visit https:\/\/)/i,Ce=/\r?\n/,we=/^\s*(?:-([a-zA-Z]),?\s*)?--([a-z][a-z0-9-]*)(?:\s+<[^>]+>|\s+\[[^\]]+\])?\s+(.+)$/,Te=/^\s*-\s+([a-z][a-z0-9-]*(?:\s*\/\s*[a-z][a-zA-Z]*)*)/;function U(e){return y(e).split(Ce)}function W(e,t){for(let n=0;n<e.length;n++)if(t.test(e[n].trim()))return n+1;return-1}const Ee={...d,emoji(e){e(`true`,` `),e(`false`,` `)},production(e){e(`true`,` `),e(`false`,` `)},"scripts-prepend-node-path"(e){e(`true`,` `),e(`false`,` `)}};function De(e){let t=U(e),n={},r=W(t,Se);if(r===-1)return n;for(let e=r;e<t.length;e++){let r=t[e];if(H.test(r))break;if(!r.trim())continue;let i=r.match(Te);if(i){let[,e]=i,t=e.split(/\s*\/\s*/),r=t[0].trim();if(r){n[r]=``;for(let e=1;e<t.length;e++){let r=t[e].trim();r&&(n[r]=``)}}}}return n}async function Oe(){let e=await m(`yarn --help`);return e?De(e):{}}function ke(e,{flagsOnly:t=!0}={}){let n=U(e),r=[],i=W(n,xe);if(i===-1)return r;for(let e=i;e<n.length;e++){let i=n[e];if(H.test(i.trim()))break;let a=i.match(we);if(!a)continue;let[,o,s,c]=a,l=i.includes(`<`)||i.includes(`[`);t&&l||r.push({short:o||void 0,long:s,desc:c.trim()})}return r}function Ae(e,t){let n=h(`yarn ${t} --help`);if(!n)return;let r=ke(n,{flagsOnly:!1});for(let{long:t,short:n,desc:i}of r){if(e.optionsRaw?.get?.(t))continue;let r=Ee[t];r?e.option(t,i,r,n):e.option(t,i,n)}}async function je(e){try{let t=await Oe();for(let[n,r]of Object.entries(t)){let t=e.command(n,r);p(t,n,`yarn`),f(t,n,`yarn`,Ae)}}catch{}}const Me=/^Commands:\s*$/i,G=/^Flags:\s*$/i,Ne=/^(Examples|Full documentation|Learn more)/i,K=/^[a-z][a-z0-9-]*$/,Pe=/^\s*(?:-([a-zA-Z]),?\s*)?--([a-z][a-z0-9-]*)(?:=<[^>]+>)?\s+(.+)$/,Fe=/^ ([a-z][a-z0-9-]*)\s+(.+)$/,Ie=/^\s{12,}([a-z][a-z0-9-]*)\s+(.+)$/,Le=/^\s+[a-z]/,Re=/\s{2,}/,q=/^[A-Z]/,ze=/\r?\n/;function J(e){return y(e).split(ze)}function Y(e,t){for(let n=0;n<e.length;n++)if(t.test(e[n].trim()))return n+1;return-1}const Be={...d,backend(e){e(`clonefile`,` `),e(`hardlink`,` `),e(`symlink`,` `),e(`copyfile`,` `)},linker(e){e(`isolated`,` `),e(`hoisted`,` `)},omit(e){e(`dev`,` `),e(`optional`,` `),e(`peer`,` `)},shell(e){e(`bun`,` `),e(`system`,` `)},"unhandled-rejections"(e){e(`strict`,` `),e(`throw`,` `),e(`warn`,` `),e(`none`,` `),e(`warn-with-error-code`,` `)}};function Ve(e){let t=J(e),n=Y(t,Me);if(n===-1)return{};let r={};for(let e=n;e<t.length;e++){let n=t[e];if(G.test(n.trim())||n.trim()===``&&e+1<t.length&&!t[e+1].match(Le))break;if(!n.trim())continue;let i=n.match(Fe);if(i){let[,e,t]=i;if(K.test(e)){let n=t.split(Re),i=n[n.length-1];if(i&&q.test(i))r[e]=i.trim();else if(n.length>1){for(let t of n)if(q.test(t)){r[e]=t.trim();break}}}}let a=n.match(Ie);if(a){let[,e,t]=a;K.test(e)&&(r[e]=t.trim())}}return r}async function He(){let e=await m(`bun --help`);return e?Ve(e):{}}function Ue(e,{flagsOnly:t=!0}={}){let n=J(e),r=[],i=Y(n,G);if(i===-1)return r;for(let e=i;e<n.length;e++){let i=n[e];if(Ne.test(i.trim()))break;let a=i.match(Pe);if(!a)continue;let[,o,s,c]=a,l=i.includes(`=<`);t&&l||r.push({short:o||void 0,long:s,desc:c.trim()})}return r}function We(e,t){let n=h(`bun ${t} --help`);if(!n)return;let r=Ue(n,{flagsOnly:!1});for(let{long:t,short:n,desc:i}of r){if(e.optionsRaw?.get?.(t))continue;let r=Be[t];r?e.option(t,i,r,n):e.option(t,i,n)}}async function X(e){try{let t=await He();for(let[n,r]of Object.entries(t)){let t=e.command(n,r);p(t,n,`bun`),f(t,n,`bun`,We)}}catch{}}async function Ge(e,t){switch(e){case`pnpm`:await M(t);break;case`npm`:await be(t);break;case`yarn`:await je(t);break;case`bun`:await X(t);break;default:break}}function Z(...e){process.env.DEBUG&&console.error(`[DEBUG]`,...e)}async function Ke(e,t){try{Z(`Checking if ${e} has completions via ${t}`);let n=`${t} ${e} complete --`,r=!!c(n,{encoding:`utf8`,stdio:[`pipe`,`pipe`,`ignore`],timeout:1e3}).trim();return Z(`${e} supports completions: ${r}`),r}catch(t){return Z(`Error checking completions for ${e}:`,t),!1}}async function qe(e,t,n){try{let r=n.map(e=>e.includes(` `)?`"${e}"`:e),i=`${t} ${e} complete -- ${r.join(` `)}`;Z(`Getting completions with command: ${i}`);let a=c(i,{encoding:`utf8`,stdio:[`pipe`,`pipe`,`ignore`],timeout:1e3}).trim().split(`
|
|
4
|
+
`).filter(Boolean);return Z(`Got ${a.length} completions from ${e}`),a}catch(t){return Z(`Error getting completions from ${e}:`,t),[]}}var Je=class extends e{packageManager;constructor(e){super(),this.packageManager=e}async parse(e){if(e.length>=1&&e[0].trim()!==``){let t=e[0];if(![...this.commands.keys()].includes(t)&&await Ke(t,this.packageManager)){let n=e.slice(1),r=await qe(t,this.packageManager,n);if(r.length>0){for(let e of r){if(e.startsWith(`:`))continue;if(e.includes(` `)){let[t,n]=e.split(` `);console.log(`${t}\t${n}`)}else console.log(e)}console.log(`:4`);return}}}return super.parse(e)}};const Q=[`npm`,`pnpm`,`yarn`,`bun`],$=[`zsh`,`bash`,`fish`,`powershell`];async function Ye(){let e=r(`tab`),t=process.argv.slice(2);if(t.length>=2&&t[1]===`complete`){let e=t[0];Q.includes(e)||(console.error(`Error: Unsupported package manager "${e}"`),console.error(`Supported package managers: ${Q.join(`, `)}`),process.exit(1));let n=process.argv.indexOf(`--`);if(n!==-1){let t=new Je(e);await Ge(e,t);let r=process.argv.slice(n+1);await t.parse(r),process.exit(0)}else console.error(`Error: Expected '--' followed by command to complete`),console.error(`Example: ${e} exec @bomb.sh/tab ${e} complete -- command-to-complete`),process.exit(1)}e.command(`<packageManager> <shell>`,`Generate shell completion script for a package manager`).action(async(e,t)=>{Q.includes(e)||(console.error(`Error: Unsupported package manager "${e}"`),console.error(`Supported package managers: ${Q.join(`, `)}`),process.exit(1)),$.includes(t)||(console.error(`Error: Unsupported shell "${t}"`),console.error(`Supported shells: ${$.join(`, `)}`),process.exit(1)),Xe(e,t)}),n(e),e.parse()}function Xe(e,n){let r=e,i=`node ${process.argv[1]} ${e}`;t(n,r,i)}Ye().catch(console.error);export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{generate as e,generate$1 as t,generate$2 as n,generate$3 as r,t_default as i}from"./t-BDEAdEmc.js";import{assertDoubleDashes as a}from"./shared-CDiJt0Dj.js";const o=process.execPath,s=process.argv.slice(1),c=p(o),l=s.map(p),u=process.execArgv.map(p),d=`${c} ${u.join(` `)} ${l[0]}`,f=/<[^>]+>|\[[^\]]+\]/;function p(e){return e.includes(` `)?`'${e}'`:e}async function m(c,l){for(let e of[c.globalCommand,...c.commands]){if(e.name===`complete`)continue;let t=(e.rawName.match(/\[.*?\]|<.*?>/g)||[]).map(e=>e.startsWith(`[`)),n=e.name===`@@global@@`,r=n?l:l?.subCommands?.[e.name],a=n?``:e.name,o=n?i:i.command(a,e.description||``);if(o){let n=(e.rawName.match(/<([^>]+)>|\[\.\.\.([^\]]+)\]/g)||[]).map(e=>e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1):e.startsWith(`[...`)&&e.endsWith(`]`)?e.slice(4,-1):e);t.forEach((e,t)=>{let i=n[t]||`arg${t}`,a=r?.args?.[i];a?o.argument(i,a,e):o.argument(i,void 0,e)})}for(let t of[...c.globalCommand.options,...e.options]){let e=t.rawName.match(/^-([a-zA-Z]), --/)?.[1],a=t.name,s=n?i:o;if(s){let n=r?.options?.[a],i=t.required||f.test(t.rawName);n?e?s.option(a,t.description||``,n,e):s.option(a,t.description||``,n):i?e?s.option(a,t.description||``,async()=>[],e):s.option(a,t.description||``,async()=>[]):e?s.option(a,t.description||``,e):s.option(a,t.description||``)}}}return c.command(`complete [shell]`).action(async(l,u)=>{switch(l){case`zsh`:{let e=r(c.name,d);console.log(e);break}case`bash`:{let e=n(c.name,d);console.log(e);break}case`fish`:{let e=t(c.name,d);console.log(e);break}case`powershell`:{let t=e(c.name,d);console.log(t);break}default:{a(c.name);let e=u[`--`]||[];return c.showHelpOnExit=!1,c.unsetMatchedCommand(),c.parse([o,s[0],...e],{run:!1}),i.parse(e)}}}),i}export{m as tab};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { RootCommand
|
|
2
|
-
import { CompletionConfig } from "
|
|
1
|
+
import { RootCommand } from "./t-xAUxUB2j.js";
|
|
2
|
+
import { CompletionConfig } from "./shared-BkI4Wff4.js";
|
|
3
3
|
import { CAC } from "cac";
|
|
4
4
|
|
|
5
5
|
//#region src/cac.d.ts
|
|
6
6
|
declare function tab(instance: CAC, completionConfig?: CompletionConfig): Promise<RootCommand>;
|
|
7
|
-
|
|
8
7
|
//#endregion
|
|
9
8
|
export { tab as default };
|
package/dist/cac.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./t-BDEAdEmc.js";import"./shared-CDiJt0Dj.js";import{tab as e}from"./cac-NlDEuVbb.js";export{e as default};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { RootCommand
|
|
2
|
-
import { CompletionConfig } from "
|
|
1
|
+
import { RootCommand } from "./t-xAUxUB2j.js";
|
|
2
|
+
import { CompletionConfig } from "./shared-BkI4Wff4.js";
|
|
3
3
|
import { ArgsDef, CommandDef } from "citty";
|
|
4
4
|
|
|
5
5
|
//#region src/citty.d.ts
|
|
6
6
|
declare function tab<TArgs extends ArgsDef>(instance: CommandDef<TArgs>, completionConfig?: CompletionConfig): Promise<RootCommand>;
|
|
7
|
-
|
|
8
7
|
//#endregion
|
|
9
8
|
export { tab as default };
|
package/dist/citty.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{generate as e,generate$1 as t,generate$2 as n,generate$3 as r,t_default as i}from"./t-BDEAdEmc.js";import{assertDoubleDashes as a}from"./shared-CDiJt0Dj.js";import{defineCommand as o}from"citty";async function s(e){let t=[],n=[];for(let[r,i]of Object.entries(e))if(i.type===`positional`){let e=i;n.push({name:r,description:e.description,isOptional:!e.required,isVariadic:r.startsWith(`[...`)||r.startsWith(`<...`)})}else{let e={name:`--${r}`,description:i.description||``,isRequired:i.required};`alias`in i&&i.alias&&(Array.isArray(i.alias)?i.alias:[i.alias]).forEach(n=>{t.push({...e,name:`-${n}`})}),t.push(e)}return{options:t,args:n}}async function c(e,t=``){let n=await Promise.resolve(e.meta),r=await Promise.resolve(e.subCommands);if(!n||!n.name)throw Error(`Command meta or name is missing`);let i={name:t?`${t} ${n.name}`:n.name,description:n.description||``};if(e.args){let t=await Promise.resolve(e.args),{options:n,args:r}=await s(t);n.length>0&&(i.options=n),r.length>0&&(i.args=r)}return r&&(i.subcommands=await Promise.all(Object.entries(r).map(async([e,t])=>{let n=await Promise.resolve(t);return c(n,i.name)}))),i}async function l(e){let t=await c(e);return JSON.stringify(t,null,2)}function u(e){return e.includes(` `)?`'${e}'`:e}const d=process.execPath,f=process.argv.slice(1),p=u(d),m=f.map(u),h=process.execArgv.map(u),g=`${p} ${h.join(` `)} ${m[0]}`;function _(e){return e.args&&Object.values(e.args).some(e=>e.type===`positional`)}async function v(e,t,n){for(let[r,a]of Object.entries(e)){let e=await b(a),o=await b(e.meta),s=await b(e.subCommands),c=n?.[r];if(!o||typeof o?.description!=`string`)throw Error(`Invalid meta or missing description.`);let l=_(e),u=t?`${t} ${r}`:r,d=i.command(u,o.description);if(l&&e.args)for(let[t,n]of Object.entries(e.args)){let e=n;if(e.type===`positional`){let n=e.required===!1,r=c?.args?.[t];r?d.argument(t,r,n):d.argument(t,void 0,n)}}if(s&&await v(s,u,c?.subCommands),e.args)for(let[t,n]of Object.entries(e.args)){let e=n,r=typeof e==`object`&&`alias`in e?Array.isArray(e.alias)?e.alias[0]:e.alias:void 0,i=c?.options?.[t];i?r?d.option(t,e.description??``,i,r):d.option(t,e.description??``,i):r?d.option(t,e.description??``,r):d.option(t,e.description??``)}}}async function y(s,c){let u=await b(s.meta);if(!u)throw Error(`Invalid meta.`);let d=u.name;if(!d)throw Error(`Invalid meta or missing name.`);let f=await b(s.subCommands);if(!f)throw Error(`Invalid or missing subCommands.`);if(_(s)&&s.args)for(let[e,t]of Object.entries(s.args)){let n=t;if(n.type===`positional`){let t=n.required===!1,r=c?.args?.[e];r?i.argument(e,r,t):i.argument(e,void 0,t)}}if(await v(f,void 0,c?.subCommands),s.args)for(let[e,t]of Object.entries(s.args)){let n=t,r=typeof n==`object`&&`alias`in n?Array.isArray(n.alias)?n.alias[0]:n.alias:void 0,a=c?.options?.[e];a?r?i.option(e,n.description??``,a,r):i.option(e,n.description??``,a):r?i.option(e,n.description??``,r):i.option(e,n.description??``)}return f.complete=o({meta:{name:`complete`,description:`Generate shell completion scripts`},args:{shell:{type:`positional`,description:`Shell type (zsh, bash, fish, powershell, fig)`,required:!1}},async run(o){let c=o.rawArgs[0];switch(c===`--`&&(c=void 0),c){case`zsh`:{let e=r(d,g);console.log(e);break}case`bash`:{let e=n(d,g);console.log(e);break}case`fish`:{let e=t(d,g);console.log(e);break}case`powershell`:{let t=e(d,g);console.log(t);break}case`fig`:{let e=await l(s);console.log(e);break}default:{a(d);let e=o.rawArgs.slice(o.rawArgs.indexOf(`--`)+1);return i.parse(e)}}}}),i}async function b(e){return e instanceof Function?await e():await e}export{y as default};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { RootCommand
|
|
1
|
+
import { RootCommand } from "./t-xAUxUB2j.js";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
|
|
4
4
|
//#region src/commander.d.ts
|
|
5
5
|
declare function tab(instance: Command): RootCommand;
|
|
6
|
-
|
|
7
6
|
//#endregion
|
|
8
7
|
export { tab as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{generate as e,generate$1 as t,generate$2 as n,generate$3 as r,t_default as i}from"./t-BDEAdEmc.js";import{assertDoubleDashes as a}from"./shared-CDiJt0Dj.js";const o=process.execPath,s=process.argv.slice(1),c=f(o),l=s.map(f),u=process.execArgv.map(f),d=`${c} ${u.join(` `)} ${l[0]}`;function f(e){return e.includes(` `)?`'${e}'`:e}function p(o){let s=o.name();m(o,s),h(o,s),o.command(`complete [shell]`).description(`Generate shell completion scripts`).action(async i=>{switch(i){case`zsh`:{let e=r(s,d);console.log(e);break}case`bash`:{let e=n(s,d);console.log(e);break}case`fish`:{let e=t(s,d);console.log(e);break}case`powershell`:{let t=e(s,d);console.log(t);break}case`debug`:{let e=new Map;g(o,``,e),console.log(`Collected commands:`);for(let[t,n]of e.entries())console.log(`- ${t||`<root>`}: ${n.description()||`No description`}`);break}default:console.error(`Unknown shell: ${i}`),console.error(`Supported shells: zsh, bash, fish, powershell`),process.exit(1)}});let c=o.parse.bind(o);return o.parse=function(e,t){let n=e||process.argv,r=n.findIndex(e=>e===`complete`),l=n.findIndex(e=>e===`--`);if(r!==-1&&l!==-1&&l>r){let e=n.slice(l+1);return a(s),i.parse(e),o}return c(e,t)},i}function m(e,t){for(let t of e.options){let e=t.flags,n=e.match(/^-([a-zA-Z]), --/)?.[1],r=e.match(/--([a-zA-Z0-9-]+)/)?.[1];r&&(n?i.option(r,t.description||``,n):i.option(r,t.description||``))}}function h(e,t){let n=new Map;g(e,``,n);for(let[e,t]of n.entries()){if(e===``)continue;let n=i.command(e,t.description()||``);for(let e of t.options){let t=e.flags,r=t.match(/^-([a-zA-Z]), --/)?.[1],i=t.match(/--([a-zA-Z0-9-]+)/)?.[1];i&&(r?n.option(i,e.description||``,r):n.option(i,e.description||``))}}}function g(e,t,n){n.set(t,e);for(let r of e.commands){if(r.name()===`complete`)continue;let e=t?`${t} ${r.name()}`:r.name();g(r,e,n)}}export{p as default};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ArgumentHandler, OptionHandler } from "./t-xAUxUB2j.js";
|
|
2
|
+
|
|
3
|
+
//#region src/shared.d.ts
|
|
4
|
+
interface CompletionConfig {
|
|
5
|
+
subCommands?: Record<string, CompletionConfig>;
|
|
6
|
+
options?: Record<string, OptionHandler>;
|
|
7
|
+
args?: Record<string, ArgumentHandler>;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { CompletionConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e=`cli`){if(process.argv.indexOf(`--`)===-1){let t=`Error: You need to use -- to separate completion arguments.\nExample: ${e} complete -- <args>`;console.error(t),process.exit(1)}}export{e as assertDoubleDashes};
|