-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathstatus.ts
More file actions
43 lines (37 loc) · 1.37 KB
/
status.ts
File metadata and controls
43 lines (37 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Command } from "@cliffy/command";
import { colors } from "@cliffy/ansi/colors";
import { FIRST_VERSION_NUMBER } from "~/consts.ts";
import { doWithSpinner } from "~/cmd/utils.ts";
import VTClient from "~/vt/vt/VTClient.ts";
import { findVtRoot } from "~/vt/vt/utils.ts";
import { displayFileStateChanges } from "~/cmd/lib/utils/displayFileStatus.ts";
import { displayVersionRange } from "~/cmd/lib/utils/displayVersionRange.ts";
import { getBranch } from "~/sdk.ts";
export const statusCmd = new Command()
.name("status")
.description("Show the working tree status")
.action(() => {
doWithSpinner("Checking status...", async (spinner) => {
const vt = VTClient.from(await findVtRoot(Deno.cwd()));
const vtState = await vt.getMeta().loadVtState();
const currentBranch = await getBranch(
vtState.val.id,
vtState.branch.id,
);
const versionStr = displayVersionRange(
FIRST_VERSION_NUMBER,
vtState.branch.version,
currentBranch.version,
);
spinner.stop();
console.log(
`On branch ${colors.cyan(currentBranch.name)}@${versionStr}`,
);
console.log();
console.log(displayFileStateChanges(await vt.status(), {
headerText: "Local Changes:",
emptyMessage: "No changes locally to push.",
summaryText: "Changes to be pushed:",
}));
});
});