@hallaxius/forge 0.1.2 → 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.
Files changed (50) hide show
  1. package/README.md +160 -158
  2. package/bin/forge.js +2 -2
  3. package/dist/cli.js +31602 -9895
  4. package/package.json +75 -72
  5. package/src/cli.ts +80 -78
  6. package/src/commands/account.ts +80 -0
  7. package/src/commands/alias.ts +66 -66
  8. package/src/commands/branch.ts +46 -46
  9. package/src/commands/ci.ts +28 -0
  10. package/src/commands/clone.ts +100 -100
  11. package/src/commands/commit.ts +88 -93
  12. package/src/commands/config.ts +47 -48
  13. package/src/commands/diff.ts +26 -26
  14. package/src/commands/fetch.ts +20 -20
  15. package/src/commands/help.ts +58 -58
  16. package/src/commands/init.ts +32 -37
  17. package/src/commands/issue.ts +63 -0
  18. package/src/commands/log.ts +29 -29
  19. package/src/commands/merge.ts +37 -37
  20. package/src/commands/pr.ts +65 -0
  21. package/src/commands/push.ts +35 -35
  22. package/src/commands/release.ts +26 -0
  23. package/src/commands/remote.ts +107 -107
  24. package/src/commands/reset.ts +30 -30
  25. package/src/commands/setup.ts +93 -95
  26. package/src/commands/stash.ts +44 -44
  27. package/src/commands/status.ts +74 -74
  28. package/src/commands/sync.ts +20 -20
  29. package/src/commands/tag.ts +41 -41
  30. package/src/commands/undo.ts +27 -27
  31. package/src/commands/version.ts +12 -12
  32. package/src/constants/colors.ts +7 -7
  33. package/src/constants/commit-types.ts +24 -24
  34. package/src/constants/messages.ts +13 -23
  35. package/src/lib/auth.ts +172 -95
  36. package/src/lib/config.ts +108 -99
  37. package/src/lib/git.ts +543 -382
  38. package/src/lib/github.ts +202 -0
  39. package/src/lib/logger.ts +18 -31
  40. package/src/lib/ui.ts +122 -156
  41. package/src/lib/validators.ts +16 -27
  42. package/src/templates/commit-types.json +9 -9
  43. package/src/utils/files.ts +21 -21
  44. package/src/utils/strings.ts +19 -19
  45. package/src/version.const.ts +1 -1
  46. package/src/commands/archive.ts +0 -35
  47. package/src/commands/bisect.ts +0 -102
  48. package/src/commands/cherry-pick.ts +0 -57
  49. package/src/commands/clean.ts +0 -76
  50. package/src/commands/worktree.ts +0 -92
@@ -1,74 +1,74 @@
1
- import type { Command } from "commander";
2
- import * as git from "../lib/git.js";
3
- import { info, newline, text } from "../lib/logger.js";
4
- import { createTable, showHeader, showSeparator } 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
- showHeader(`Branch: ${status.current}`);
30
- if (status.tracking) {
31
- info(`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
- info(`${ahead}${sep}${behind}`);
39
- }
40
-
41
- newline();
42
-
43
- if (status.files.length > 0) {
44
- info("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
- info("Working tree clean.");
53
- }
54
-
55
- newline();
56
- showSeparator();
57
- newline();
58
-
59
- if (status.recentCommits.length > 0) {
60
- info("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
- info(`Status: ${err instanceof Error ? err.message : String(err)}`);
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
+ }
@@ -1,20 +1,20 @@
1
- import type { Command } from "commander";
2
- import * as git from "../lib/git.js";
3
- import { error, success } 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
- success(`Sync complete: ${result}`);
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
+ }
@@ -1,41 +1,41 @@
1
- import type { Command } from "commander";
2
- import * as git from "../lib/git.js";
3
- import { error, info, success } 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
- info("No tags found.");
19
- return;
20
- }
21
-
22
- const rows = tags.map((t) => [t]);
23
- info("Tags:");
24
- console.log(createTable(["Name"], rows));
25
- return;
26
- }
27
-
28
- if (options.name) {
29
- const tagName = await git.tag(options.name, options.message);
30
- success(`Tag '${tagName}' created.`);
31
- return;
32
- }
33
-
34
- info("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
- }
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
+ }
@@ -1,27 +1,27 @@
1
- import type { Command } from "commander";
2
- import * as git from "../lib/git.js";
3
- import { error, info, success, 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
- info("Undo cancelled.");
16
- return;
17
- }
18
-
19
- const result = await git.undo();
20
- success(`Undo complete: ${result}`);
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
+ }
@@ -1,12 +1,12 @@
1
- import type { Command } from "commander";
2
- import { info } 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
- info(`Forge v${VERSION}`);
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
+ }
@@ -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 icons = {
2
- success: "\u2713",
3
- error: "\u2717",
4
- warning: "\u26A0",
5
- info: "\u25CB",
6
- highlight: "\u00BB",
7
- };
8
-
9
- export const formatting = {
10
- header: "\u2550".repeat(30),
11
- separator: "\u2500".repeat(25),
12
- indent: " ",
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;