@jhorst11/wt 1.0.0
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 +104 -0
- package/bin/wt.js +86 -0
- package/package.json +45 -0
- package/shell/wt.sh +66 -0
- package/src/commands.js +736 -0
- package/src/git.js +351 -0
- package/src/setup.js +256 -0
- package/src/ui.js +141 -0
package/src/ui.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import gradient from 'gradient-string';
|
|
3
|
+
import figures from 'figures';
|
|
4
|
+
|
|
5
|
+
// Custom gradient for the logo
|
|
6
|
+
const wtGradient = gradient(['#00d4ff', '#7c3aed', '#f472b6']);
|
|
7
|
+
const successGradient = gradient(['#10b981', '#34d399']);
|
|
8
|
+
const warningGradient = gradient(['#f59e0b', '#fbbf24']);
|
|
9
|
+
|
|
10
|
+
export const icons = {
|
|
11
|
+
tree: 'đŗ',
|
|
12
|
+
branch: 'đŋ',
|
|
13
|
+
rocket: 'đ',
|
|
14
|
+
sparkles: 'â¨',
|
|
15
|
+
folder: 'đ',
|
|
16
|
+
trash: 'đī¸',
|
|
17
|
+
home: 'đ ',
|
|
18
|
+
check: figures.tick,
|
|
19
|
+
cross: figures.cross,
|
|
20
|
+
pointer: figures.pointer,
|
|
21
|
+
arrowRight: figures.arrowRight,
|
|
22
|
+
bullet: figures.bullet,
|
|
23
|
+
star: 'â',
|
|
24
|
+
git: 'ķ°ĸ',
|
|
25
|
+
plus: 'â',
|
|
26
|
+
warning: 'â ī¸',
|
|
27
|
+
info: 'âšī¸',
|
|
28
|
+
remote: 'âī¸',
|
|
29
|
+
local: 'đģ',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const colors = {
|
|
33
|
+
primary: chalk.hex('#7c3aed'),
|
|
34
|
+
secondary: chalk.hex('#00d4ff'),
|
|
35
|
+
success: chalk.hex('#10b981'),
|
|
36
|
+
warning: chalk.hex('#f59e0b'),
|
|
37
|
+
error: chalk.hex('#ef4444'),
|
|
38
|
+
muted: chalk.gray,
|
|
39
|
+
highlight: chalk.hex('#f472b6'),
|
|
40
|
+
branch: chalk.hex('#34d399'),
|
|
41
|
+
path: chalk.hex('#60a5fa'),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export function showLogo() {
|
|
45
|
+
const logo = `
|
|
46
|
+
${wtGradient('âĻ âĻââââĻâââĻââââĻââĻââââââââ')}
|
|
47
|
+
${wtGradient('ââââ ââ âĻââ âŠâ â â âĻâââŖ ââŖ ')}
|
|
48
|
+
${wtGradient('ââŠâââââŠââ⊠⊠⊠âŠââââââââ')}
|
|
49
|
+
${chalk.gray(' Git Worktree Manager')}
|
|
50
|
+
`;
|
|
51
|
+
console.log(logo);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function showMiniLogo() {
|
|
55
|
+
console.log(`\n ${icons.tree} ${wtGradient('worktree')} ${colors.muted('v1.0.0')}\n`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function success(message) {
|
|
59
|
+
console.log(` ${colors.success(icons.check)} ${message}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function error(message) {
|
|
63
|
+
console.log(` ${colors.error(icons.cross)} ${message}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function warning(message) {
|
|
67
|
+
console.log(` ${colors.warning(icons.warning)} ${message}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function info(message) {
|
|
71
|
+
console.log(` ${colors.secondary(icons.info)} ${message}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function heading(text) {
|
|
75
|
+
console.log(`\n ${colors.primary.bold(text)}\n`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function subheading(text) {
|
|
79
|
+
console.log(` ${colors.muted(text)}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function listItem(text, indent = 2) {
|
|
83
|
+
const spaces = ' '.repeat(indent);
|
|
84
|
+
console.log(`${spaces}${colors.secondary(icons.bullet)} ${text}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function branchItem(name, isCurrent = false, isRemote = false) {
|
|
88
|
+
const icon = isRemote ? icons.remote : icons.local;
|
|
89
|
+
const prefix = isCurrent ? colors.success(icons.pointer) : ' ';
|
|
90
|
+
const branchName = isCurrent ? colors.success.bold(name) : colors.branch(name);
|
|
91
|
+
const typeLabel = isRemote ? colors.muted(' (remote)') : '';
|
|
92
|
+
console.log(` ${prefix} ${icon} ${branchName}${typeLabel}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function worktreeItem(name, path, isCurrent = false) {
|
|
96
|
+
const prefix = isCurrent ? colors.success(icons.pointer) : ' ';
|
|
97
|
+
const nameDisplay = isCurrent ? colors.success.bold(name) : colors.highlight(name);
|
|
98
|
+
console.log(` ${prefix} ${icons.folder} ${nameDisplay}`);
|
|
99
|
+
console.log(` ${colors.muted(path)}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function divider() {
|
|
103
|
+
console.log(colors.muted(' â'.repeat(20)));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function spacer() {
|
|
107
|
+
console.log('');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function formatBranchChoice(branch, type = 'local') {
|
|
111
|
+
const icon = type === 'remote' ? icons.remote : icons.local;
|
|
112
|
+
const typeLabel = type === 'remote' ? chalk.dim(' (remote)') : '';
|
|
113
|
+
return `${icon} ${branch}${typeLabel}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function formatWorktreeChoice(wt) {
|
|
117
|
+
return `${icons.folder} ${colors.highlight(wt.name)} ${colors.muted(`â ${wt.branch}`)}`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function showHelp() {
|
|
121
|
+
showLogo();
|
|
122
|
+
|
|
123
|
+
console.log(colors.primary.bold(' Commands:\n'));
|
|
124
|
+
|
|
125
|
+
const commands = [
|
|
126
|
+
['wt', 'Interactive menu to manage worktrees'],
|
|
127
|
+
['wt new', 'Create a new worktree interactively'],
|
|
128
|
+
['wt list', 'List all worktrees for current repo'],
|
|
129
|
+
['wt remove', 'Remove a worktree interactively'],
|
|
130
|
+
['wt home', 'Jump back to the main repository'],
|
|
131
|
+
['wt go <name>', 'Jump to a specific worktree'],
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
commands.forEach(([cmd, desc]) => {
|
|
135
|
+
console.log(` ${colors.secondary(cmd.padEnd(18))} ${colors.muted(desc)}`);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
spacer();
|
|
139
|
+
console.log(colors.muted(' Run any command without arguments for interactive mode'));
|
|
140
|
+
spacer();
|
|
141
|
+
}
|