@kaynooo/cli-wt 0.1.2 → 0.1.7
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 +17 -10
- package/dist/cli-0gbs87r4.js +313 -0
- package/dist/cli-1nyesy1b.js +674 -0
- package/dist/cli-4g5ehhgn.js +251 -0
- package/dist/cli-6ybxw5sc.js +97 -0
- package/dist/cli-dmkfxdbr.js +153 -0
- package/dist/cli-dmzvmpge.js +106 -0
- package/dist/cli-e2h20nyy.js +36 -0
- package/dist/cli-j82fak6j.js +69 -0
- package/dist/cli-k4471y24.js +779 -0
- package/dist/cli-kek450vq.js +519 -0
- package/dist/cli-n5rt07v7.js +105 -0
- package/dist/cli-pkvw2k4x.js +37 -0
- package/dist/cli-w4w36hng.js +67 -0
- package/dist/cli.js +238 -2592
- package/dist/commands-jtnbchtb.js +222 -0
- package/dist/init-4ynjrztr.js +166 -0
- package/dist/list-js6drtvg.js +88 -0
- package/dist/print-q6qaqg22.js +77 -0
- package/dist/prompt-y71tp3f5.js +436 -0
- package/dist/prune-beweag7w.js +17 -0
- package/dist/run-7eayrqwy.js +18 -0
- package/dist/shell-xrgvqrpp.js +55 -0
- package/dist/stack-h3pgyx1e.js +20 -0
- package/dist/tools-4j56r47a.js +13 -0
- package/package.json +6 -6
- package/src/cli.ts +270 -76
- package/src/commands.ts +58 -42
- package/src/compose.ts +37 -14
- package/src/config.ts +8 -1
- package/src/errors.ts +31 -5
- package/src/files.ts +15 -23
- package/src/git.ts +53 -7
- package/src/index.ts +3 -2
- package/src/init.ts +56 -10
- package/src/jobs.ts +60 -19
- package/src/list.ts +26 -13
- package/src/print.ts +76 -0
- package/src/project.ts +134 -23
- package/src/proxy.ts +9 -9
- package/src/prune.ts +149 -0
- package/src/queue.ts +27 -3
- package/src/run.ts +82 -23
- package/src/shell.ts +34 -7
- package/src/stack.ts +10 -12
- package/src/sync.ts +28 -3
- package/src/tools.ts +91 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
table
|
|
4
|
+
} from "./cli-k4471y24.js";
|
|
5
|
+
import {
|
|
6
|
+
WtError
|
|
7
|
+
} from "./cli-kek450vq.js";
|
|
8
|
+
import {
|
|
9
|
+
devproxyArgv
|
|
10
|
+
} from "./cli-pkvw2k4x.js";
|
|
11
|
+
|
|
12
|
+
// src/tools.ts
|
|
13
|
+
var {$ } = globalThis.Bun;
|
|
14
|
+
function findDevproxy() {
|
|
15
|
+
return devproxyArgv().at(-1);
|
|
16
|
+
}
|
|
17
|
+
async function findCompose() {
|
|
18
|
+
const docker = Bun.which("docker");
|
|
19
|
+
if (docker === null)
|
|
20
|
+
return;
|
|
21
|
+
const version = await $`${docker} compose version --short`.quiet().nothrow();
|
|
22
|
+
return version.exitCode === 0 ? `${docker} compose ${version.text().trim()}` : undefined;
|
|
23
|
+
}
|
|
24
|
+
var TOOLS = [
|
|
25
|
+
{ name: "git", for: "checks the worktrees out", get: "the git package of the system", needs: "always" },
|
|
26
|
+
{ name: "docker", for: "reads the compose project, clones its volumes and runs the stacks", get: "https://docs.docker.com/engine/install/", needs: "always" },
|
|
27
|
+
{ name: "docker compose", for: "runs the stacks", get: "the docker compose plugin, https://docs.docker.com/compose/install/linux/", needs: "always", find: findCompose },
|
|
28
|
+
{ name: "mkcert", for: "issues the certificates of a project with `certs`", get: "https://github.com/FiloSottile/mkcert, then `mkcert -install`", needs: (project) => project.certs !== undefined },
|
|
29
|
+
{ name: "devproxy", for: "routes the subdomains", get: "installed with wt, else `bun add -g @kaynooo/devproxy`", needs: "optional", find: findDevproxy },
|
|
30
|
+
{ name: "notify-send", for: "tells a --bg job is over", get: "the libnotify package of the system", needs: "optional" }
|
|
31
|
+
];
|
|
32
|
+
function neededBy(tool, project) {
|
|
33
|
+
return typeof tool.needs === "function" ? tool.needs(project) : tool.needs === "always";
|
|
34
|
+
}
|
|
35
|
+
async function locateTool(tool) {
|
|
36
|
+
return tool.find ? tool.find() : Bun.which(tool.name) ?? undefined;
|
|
37
|
+
}
|
|
38
|
+
async function assertTools2(project) {
|
|
39
|
+
const needed = TOOLS.filter((tool) => neededBy(tool, project));
|
|
40
|
+
const found = await Promise.all(needed.map(locateTool));
|
|
41
|
+
const missing = needed.filter((_, index) => found[index] === undefined);
|
|
42
|
+
if (missing.length)
|
|
43
|
+
throw new WtError(`${missing.map((tool) => `${tool.name} is not on PATH, ${tool.get}`).join(`
|
|
44
|
+
`)}
|
|
45
|
+
wt needs it for ${project.name}`, "`wt doctor` lists every program");
|
|
46
|
+
}
|
|
47
|
+
async function doctor2(projects) {
|
|
48
|
+
const found = await Promise.all(TOOLS.map(locateTool));
|
|
49
|
+
let code = 0;
|
|
50
|
+
const rows = TOOLS.map((tool, index) => {
|
|
51
|
+
const at = found[index];
|
|
52
|
+
const by = projects.filter((project) => neededBy(tool, project)).map((project) => project.name);
|
|
53
|
+
const required = tool.needs === "always" || by.length > 0;
|
|
54
|
+
let use = tool.for;
|
|
55
|
+
if (typeof tool.needs === "function")
|
|
56
|
+
use += by.length ? ` (${by.join(", ")})` : ", no project has them";
|
|
57
|
+
if (at !== undefined)
|
|
58
|
+
return ["ok", tool.name, at, use];
|
|
59
|
+
if (required)
|
|
60
|
+
code = 1;
|
|
61
|
+
return [required ? "missing" : "absent", tool.name, tool.get, use];
|
|
62
|
+
});
|
|
63
|
+
console.log(table([["", "program", "where", "for"], ...rows], { header: true }));
|
|
64
|
+
return code;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { assertTools2, doctor2 };
|