@hallaxius/forge 0.1.3 → 0.1.4
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 +160 -158
- package/bin/forge.js +2 -2
- package/dist/cli.js +12764 -13800
- package/package.json +75 -75
- package/src/cli.ts +80 -78
- package/src/commands/account.ts +80 -0
- package/src/commands/alias.ts +66 -66
- package/src/commands/branch.ts +46 -46
- package/src/commands/ci.ts +28 -28
- package/src/commands/clone.ts +100 -100
- package/src/commands/commit.ts +88 -88
- package/src/commands/config.ts +47 -48
- package/src/commands/diff.ts +26 -26
- package/src/commands/fetch.ts +20 -20
- package/src/commands/help.ts +58 -58
- package/src/commands/init.ts +32 -33
- package/src/commands/issue.ts +63 -63
- package/src/commands/log.ts +29 -29
- package/src/commands/merge.ts +37 -37
- package/src/commands/pr.ts +65 -65
- package/src/commands/push.ts +35 -35
- package/src/commands/release.ts +26 -26
- package/src/commands/remote.ts +107 -107
- package/src/commands/reset.ts +30 -30
- package/src/commands/setup.ts +93 -94
- package/src/commands/stash.ts +44 -44
- package/src/commands/status.ts +74 -74
- package/src/commands/sync.ts +20 -20
- package/src/commands/tag.ts +41 -41
- package/src/commands/undo.ts +27 -27
- package/src/commands/version.ts +12 -12
- package/src/constants/colors.ts +7 -7
- package/src/constants/commit-types.ts +24 -24
- package/src/constants/messages.ts +13 -23
- package/src/lib/auth.ts +172 -172
- package/src/lib/config.ts +108 -108
- package/src/lib/git.ts +543 -543
- package/src/lib/github.ts +202 -160
- package/src/lib/logger.ts +18 -31
- package/src/lib/ui.ts +122 -156
- package/src/lib/validators.ts +16 -16
- package/src/templates/commit-types.json +9 -9
- package/src/utils/files.ts +21 -21
- package/src/utils/strings.ts +19 -19
- package/src/version.const.ts +1 -1
package/src/commands/status.ts
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import type { Command } from "commander";
|
|
2
|
-
import * as git from "../lib/git.js";
|
|
3
|
-
import {
|
|
4
|
-
import { createTable
|
|
5
|
-
|
|
6
|
-
function statusIcon(code: string): string {
|
|
7
|
-
switch (code) {
|
|
8
|
-
case "M":
|
|
9
|
-
return "M";
|
|
10
|
-
case "A":
|
|
11
|
-
return "A";
|
|
12
|
-
case "D":
|
|
13
|
-
return "D";
|
|
14
|
-
case "?":
|
|
15
|
-
return "?";
|
|
16
|
-
default:
|
|
17
|
-
return " ";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default function register(program: Command): void {
|
|
22
|
-
program
|
|
23
|
-
.command("status")
|
|
24
|
-
.description("Show detailed repository status")
|
|
25
|
-
.action(async () => {
|
|
26
|
-
try {
|
|
27
|
-
const status = await git.getStatus();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (status.tracking) {
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (status.ahead > 0 || status.behind > 0) {
|
|
35
|
-
const ahead = status.ahead > 0 ? `${status.ahead} ahead` : "";
|
|
36
|
-
const behind = status.behind > 0 ? `${status.behind} behind` : "";
|
|
37
|
-
const sep = ahead && behind ? " | " : "";
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
newline();
|
|
42
|
-
|
|
43
|
-
if (status.files.length > 0) {
|
|
44
|
-
|
|
45
|
-
const fileRows = status.files.map((f) => [
|
|
46
|
-
f.path,
|
|
47
|
-
statusIcon(f.index),
|
|
48
|
-
statusIcon(f.working_dir),
|
|
49
|
-
]);
|
|
50
|
-
text(createTable(["File", "Index", "Working"], fileRows));
|
|
51
|
-
} else {
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
newline();
|
|
56
|
-
|
|
57
|
-
newline();
|
|
58
|
-
|
|
59
|
-
if (status.recentCommits.length > 0) {
|
|
60
|
-
|
|
61
|
-
const commitRows = status.recentCommits
|
|
62
|
-
.slice(0, 3)
|
|
63
|
-
.map((c) => [
|
|
64
|
-
c.hash.substring(0, 7),
|
|
65
|
-
c.date.substring(0, 10),
|
|
66
|
-
c.message.substring(0, 50),
|
|
67
|
-
]);
|
|
68
|
-
text(createTable(["Hash", "Date", "Message"], commitRows));
|
|
69
|
-
}
|
|
70
|
-
} catch (err) {
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import * as git from "../lib/git.js";
|
|
3
|
+
import { newline, text } from "../lib/logger.js";
|
|
4
|
+
import { createTable } from "../lib/ui.js";
|
|
5
|
+
|
|
6
|
+
function statusIcon(code: string): string {
|
|
7
|
+
switch (code) {
|
|
8
|
+
case "M":
|
|
9
|
+
return "M";
|
|
10
|
+
case "A":
|
|
11
|
+
return "A";
|
|
12
|
+
case "D":
|
|
13
|
+
return "D";
|
|
14
|
+
case "?":
|
|
15
|
+
return "?";
|
|
16
|
+
default:
|
|
17
|
+
return " ";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function register(program: Command): void {
|
|
22
|
+
program
|
|
23
|
+
.command("status")
|
|
24
|
+
.description("Show detailed repository status")
|
|
25
|
+
.action(async () => {
|
|
26
|
+
try {
|
|
27
|
+
const status = await git.getStatus();
|
|
28
|
+
|
|
29
|
+
text(`Branch: ${status.current}`);
|
|
30
|
+
if (status.tracking) {
|
|
31
|
+
text(`Tracking: ${status.tracking}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (status.ahead > 0 || status.behind > 0) {
|
|
35
|
+
const ahead = status.ahead > 0 ? `${status.ahead} ahead` : "";
|
|
36
|
+
const behind = status.behind > 0 ? `${status.behind} behind` : "";
|
|
37
|
+
const sep = ahead && behind ? " | " : "";
|
|
38
|
+
text(`${ahead}${sep}${behind}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
newline();
|
|
42
|
+
|
|
43
|
+
if (status.files.length > 0) {
|
|
44
|
+
text("Files:");
|
|
45
|
+
const fileRows = status.files.map((f) => [
|
|
46
|
+
f.path,
|
|
47
|
+
statusIcon(f.index),
|
|
48
|
+
statusIcon(f.working_dir),
|
|
49
|
+
]);
|
|
50
|
+
text(createTable(["File", "Index", "Working"], fileRows));
|
|
51
|
+
} else {
|
|
52
|
+
text("Working tree clean.");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
newline();
|
|
56
|
+
newline();
|
|
57
|
+
newline();
|
|
58
|
+
|
|
59
|
+
if (status.recentCommits.length > 0) {
|
|
60
|
+
text("Recent commits:");
|
|
61
|
+
const commitRows = status.recentCommits
|
|
62
|
+
.slice(0, 3)
|
|
63
|
+
.map((c) => [
|
|
64
|
+
c.hash.substring(0, 7),
|
|
65
|
+
c.date.substring(0, 10),
|
|
66
|
+
c.message.substring(0, 50),
|
|
67
|
+
]);
|
|
68
|
+
text(createTable(["Hash", "Date", "Message"], commitRows));
|
|
69
|
+
}
|
|
70
|
+
} catch (err) {
|
|
71
|
+
text(`Status: ${err instanceof Error ? err.message : String(err)}`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
package/src/commands/sync.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { Command } from "commander";
|
|
2
|
-
import * as git from "../lib/git.js";
|
|
3
|
-
import { error,
|
|
4
|
-
import { withSpinner } from "../lib/ui.js";
|
|
5
|
-
|
|
6
|
-
export default function register(program: Command): void {
|
|
7
|
-
program
|
|
8
|
-
.command("sync")
|
|
9
|
-
.description("Pull with rebase")
|
|
10
|
-
.action(async () => {
|
|
11
|
-
try {
|
|
12
|
-
const result = await withSpinner("Syncing...", () => git.pullRebase());
|
|
13
|
-
|
|
14
|
-
} catch (err) {
|
|
15
|
-
error(
|
|
16
|
-
`Sync failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import * as git from "../lib/git.js";
|
|
3
|
+
import { error, text } from "../lib/logger.js";
|
|
4
|
+
import { withSpinner } from "../lib/ui.js";
|
|
5
|
+
|
|
6
|
+
export default function register(program: Command): void {
|
|
7
|
+
program
|
|
8
|
+
.command("sync")
|
|
9
|
+
.description("Pull with rebase")
|
|
10
|
+
.action(async () => {
|
|
11
|
+
try {
|
|
12
|
+
const result = await withSpinner("Syncing...", () => git.pullRebase());
|
|
13
|
+
text(`Sync complete: ${result}`);
|
|
14
|
+
} catch (err) {
|
|
15
|
+
error(
|
|
16
|
+
`Sync failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
package/src/commands/tag.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import type { Command } from "commander";
|
|
2
|
-
import * as git from "../lib/git.js";
|
|
3
|
-
import { error,
|
|
4
|
-
import { createTable } from "../lib/ui.js";
|
|
5
|
-
|
|
6
|
-
export default function register(program: Command): void {
|
|
7
|
-
program
|
|
8
|
-
.command("tag")
|
|
9
|
-
.description("Manage tags")
|
|
10
|
-
.option("-n, --name <name>", "Create tag")
|
|
11
|
-
.option("-m, --message <message>", "Tag message")
|
|
12
|
-
.option("--list", "List tags")
|
|
13
|
-
.action(async (options) => {
|
|
14
|
-
try {
|
|
15
|
-
if (options.list) {
|
|
16
|
-
const tags = await git.tagList();
|
|
17
|
-
if (tags.length === 0) {
|
|
18
|
-
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const rows = tags.map((t) => [t]);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (options.name) {
|
|
29
|
-
const tagName = await git.tag(options.name, options.message);
|
|
30
|
-
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} catch (err) {
|
|
36
|
-
error(
|
|
37
|
-
`Tag operation failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import * as git from "../lib/git.js";
|
|
3
|
+
import { error, text } from "../lib/logger.js";
|
|
4
|
+
import { createTable } from "../lib/ui.js";
|
|
5
|
+
|
|
6
|
+
export default function register(program: Command): void {
|
|
7
|
+
program
|
|
8
|
+
.command("tag")
|
|
9
|
+
.description("Manage tags")
|
|
10
|
+
.option("-n, --name <name>", "Create tag")
|
|
11
|
+
.option("-m, --message <message>", "Tag message")
|
|
12
|
+
.option("--list", "List tags")
|
|
13
|
+
.action(async (options) => {
|
|
14
|
+
try {
|
|
15
|
+
if (options.list) {
|
|
16
|
+
const tags = await git.tagList();
|
|
17
|
+
if (tags.length === 0) {
|
|
18
|
+
text("No tags found.");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const rows = tags.map((t) => [t]);
|
|
23
|
+
text("Tags:");
|
|
24
|
+
text(createTable(["Name"], rows));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (options.name) {
|
|
29
|
+
const tagName = await git.tag(options.name, options.message);
|
|
30
|
+
text(`Tag '${tagName}' created.`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
text("Use --name to create a tag or --list to list tags.");
|
|
35
|
+
} catch (err) {
|
|
36
|
+
error(
|
|
37
|
+
`Tag operation failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
package/src/commands/undo.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import type { Command } from "commander";
|
|
2
|
-
import * as git from "../lib/git.js";
|
|
3
|
-
import { error,
|
|
4
|
-
import { confirm } from "../lib/ui.js";
|
|
5
|
-
|
|
6
|
-
export default function register(program: Command): void {
|
|
7
|
-
program
|
|
8
|
-
.command("undo")
|
|
9
|
-
.description("Undo last commit (soft reset)")
|
|
10
|
-
.action(async () => {
|
|
11
|
-
try {
|
|
12
|
-
warning("This will undo the last commit using a soft reset.");
|
|
13
|
-
const proceed = await confirm("Are you sure?");
|
|
14
|
-
if (!proceed) {
|
|
15
|
-
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const result = await git.undo();
|
|
20
|
-
|
|
21
|
-
} catch (err) {
|
|
22
|
-
error(
|
|
23
|
-
`Undo failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import * as git from "../lib/git.js";
|
|
3
|
+
import { error, text, warning } from "../lib/logger.js";
|
|
4
|
+
import { confirm } from "../lib/ui.js";
|
|
5
|
+
|
|
6
|
+
export default function register(program: Command): void {
|
|
7
|
+
program
|
|
8
|
+
.command("undo")
|
|
9
|
+
.description("Undo last commit (soft reset)")
|
|
10
|
+
.action(async () => {
|
|
11
|
+
try {
|
|
12
|
+
warning("This will undo the last commit using a soft reset.");
|
|
13
|
+
const proceed = await confirm("Are you sure?");
|
|
14
|
+
if (!proceed) {
|
|
15
|
+
text("Undo cancelled.");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const result = await git.undo();
|
|
20
|
+
text(`Undo complete: ${result}`);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
error(
|
|
23
|
+
`Undo failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
package/src/commands/version.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { Command } from "commander";
|
|
2
|
-
import {
|
|
3
|
-
import { VERSION } from "../version.const.js";
|
|
4
|
-
|
|
5
|
-
export default function register(program: Command): void {
|
|
6
|
-
program
|
|
7
|
-
.command("version")
|
|
8
|
-
.description("Show version")
|
|
9
|
-
.action(async () => {
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
}
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { text } from "../lib/logger.js";
|
|
3
|
+
import { VERSION } from "../version.const.js";
|
|
4
|
+
|
|
5
|
+
export default function register(program: Command): void {
|
|
6
|
+
program
|
|
7
|
+
.command("version")
|
|
8
|
+
.description("Show version")
|
|
9
|
+
.action(async () => {
|
|
10
|
+
text(`Forge v${VERSION}`);
|
|
11
|
+
});
|
|
12
|
+
}
|
package/src/constants/colors.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export const colors = {
|
|
2
|
-
success: "#00ff87",
|
|
3
|
-
warning: "#ffd700",
|
|
4
|
-
error: "#ff4444",
|
|
5
|
-
info: "#00d4ff",
|
|
6
|
-
highlight: "#ff6bff",
|
|
7
|
-
} as const;
|
|
1
|
+
export const colors = {
|
|
2
|
+
success: "#00ff87",
|
|
3
|
+
warning: "#ffd700",
|
|
4
|
+
error: "#ff4444",
|
|
5
|
+
info: "#00d4ff",
|
|
6
|
+
highlight: "#ff6bff",
|
|
7
|
+
} as const;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export const CommitType = {
|
|
2
|
-
FEAT: "feat",
|
|
3
|
-
FIX: "fix",
|
|
4
|
-
DOCS: "docs",
|
|
5
|
-
STYLE: "style",
|
|
6
|
-
REFACTOR: "refactor",
|
|
7
|
-
TEST: "test",
|
|
8
|
-
CHORE: "chore",
|
|
9
|
-
} as const;
|
|
10
|
-
|
|
11
|
-
export type CommitType = (typeof CommitType)[keyof typeof CommitType];
|
|
12
|
-
|
|
13
|
-
export const commitTypes: { value: CommitType; description: string }[] = [
|
|
14
|
-
{ value: CommitType.FEAT, description: "A new feature" },
|
|
15
|
-
{ value: CommitType.FIX, description: "A bug fix" },
|
|
16
|
-
{ value: CommitType.DOCS, description: "Documentation only changes" },
|
|
17
|
-
{
|
|
18
|
-
value: CommitType.STYLE,
|
|
19
|
-
description: "Code style changes (formatting, etc)",
|
|
20
|
-
},
|
|
21
|
-
{ value: CommitType.REFACTOR, description: "Code refactoring" },
|
|
22
|
-
{ value: CommitType.TEST, description: "Adding or fixing tests" },
|
|
23
|
-
{ value: CommitType.CHORE, description: "Build process or tool changes" },
|
|
24
|
-
];
|
|
1
|
+
export const CommitType = {
|
|
2
|
+
FEAT: "feat",
|
|
3
|
+
FIX: "fix",
|
|
4
|
+
DOCS: "docs",
|
|
5
|
+
STYLE: "style",
|
|
6
|
+
REFACTOR: "refactor",
|
|
7
|
+
TEST: "test",
|
|
8
|
+
CHORE: "chore",
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
export type CommitType = (typeof CommitType)[keyof typeof CommitType];
|
|
12
|
+
|
|
13
|
+
export const commitTypes: { value: CommitType; description: string }[] = [
|
|
14
|
+
{ value: CommitType.FEAT, description: "A new feature" },
|
|
15
|
+
{ value: CommitType.FIX, description: "A bug fix" },
|
|
16
|
+
{ value: CommitType.DOCS, description: "Documentation only changes" },
|
|
17
|
+
{
|
|
18
|
+
value: CommitType.STYLE,
|
|
19
|
+
description: "Code style changes (formatting, etc)",
|
|
20
|
+
},
|
|
21
|
+
{ value: CommitType.REFACTOR, description: "Code refactoring" },
|
|
22
|
+
{ value: CommitType.TEST, description: "Adding or fixing tests" },
|
|
23
|
+
{ value: CommitType.CHORE, description: "Build process or tool changes" },
|
|
24
|
+
];
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const commitTypes = [
|
|
16
|
-
{ value: "feat", description: "A new feature" },
|
|
17
|
-
{ value: "fix", description: "A bug fix" },
|
|
18
|
-
{ value: "docs", description: "Documentation only changes" },
|
|
19
|
-
{ value: "style", description: "Code style changes (formatting, etc)" },
|
|
20
|
-
{ value: "refactor", description: "Code refactoring" },
|
|
21
|
-
{ value: "test", description: "Adding or fixing tests" },
|
|
22
|
-
{ value: "chore", description: "Build process or tool changes" },
|
|
23
|
-
] as const;
|
|
1
|
+
export const formatting = {
|
|
2
|
+
indent: " ",
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export const commitTypes = [
|
|
6
|
+
{ value: "feat", description: "A new feature" },
|
|
7
|
+
{ value: "fix", description: "A bug fix" },
|
|
8
|
+
{ value: "docs", description: "Documentation only changes" },
|
|
9
|
+
{ value: "style", description: "Code style changes (formatting, etc)" },
|
|
10
|
+
{ value: "refactor", description: "Code refactoring" },
|
|
11
|
+
{ value: "test", description: "Adding or fixing tests" },
|
|
12
|
+
{ value: "chore", description: "Build process or tool changes" },
|
|
13
|
+
] as const;
|