@mbluemer_2/gittyup 0.1.2 → 0.1.8

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/dist/tmux.js DELETED
@@ -1,146 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildTmuxSessionName = buildTmuxSessionName;
4
- exports.isInsideTmux = isInsideTmux;
5
- exports.checkTmuxAvailable = checkTmuxAvailable;
6
- exports.checkFzfAvailable = checkFzfAvailable;
7
- exports.listTmuxSessions = listTmuxSessions;
8
- exports.tmuxSessionExists = tmuxSessionExists;
9
- exports.createDetachedTmuxSession = createDetachedTmuxSession;
10
- exports.attachTmuxSession = attachTmuxSession;
11
- exports.switchTmuxSession = switchTmuxSession;
12
- exports.launchTmuxSession = launchTmuxSession;
13
- exports.killTmuxSessionIfExists = killTmuxSessionIfExists;
14
- exports.pickTmuxSession = pickTmuxSession;
15
- const errors_1 = require("./errors");
16
- const process_1 = require("./process");
17
- function runTmux(args, options = {}) {
18
- return (0, process_1.runCommand)('tmux', args, options);
19
- }
20
- function toTmuxSessionTarget(name) {
21
- return `=${name}`;
22
- }
23
- function buildTmuxSessionName(project, alias) {
24
- return `${project}_${alias}`;
25
- }
26
- function isInsideTmux() {
27
- return Boolean(process.env.TMUX);
28
- }
29
- async function checkTmuxAvailable() {
30
- try {
31
- await runTmux(['-V']);
32
- }
33
- catch (error) {
34
- if (error instanceof errors_1.CliError) {
35
- throw new errors_1.CliError('tmux is not installed or not available in PATH. Please install tmux to use tmux session management.');
36
- }
37
- throw error;
38
- }
39
- }
40
- async function checkFzfAvailable() {
41
- try {
42
- await (0, process_1.runCommand)('fzf', ['--version']);
43
- }
44
- catch (error) {
45
- if (error instanceof errors_1.CliError) {
46
- throw new errors_1.CliError('fzf is not installed or not available in PATH. Please install fzf to use the tmux session picker.');
47
- }
48
- throw error;
49
- }
50
- }
51
- async function listTmuxSessions() {
52
- try {
53
- const output = await runTmux([
54
- 'list-sessions',
55
- '-F',
56
- '#{session_name}\t#{session_attached}',
57
- ]);
58
- if (!output.trim()) {
59
- return [];
60
- }
61
- return output
62
- .split('\n')
63
- .filter(Boolean)
64
- .map((line) => {
65
- const [name, attached] = line.split('\t');
66
- return {
67
- name: name ?? '',
68
- attached: attached === '1',
69
- };
70
- });
71
- }
72
- catch (error) {
73
- const message = error instanceof errors_1.CliError ? error.message : '';
74
- if (message.includes('no server running')) {
75
- return [];
76
- }
77
- throw error;
78
- }
79
- }
80
- async function tmuxSessionExists(name) {
81
- const sessions = await listTmuxSessions();
82
- return sessions.some((session) => session.name === name);
83
- }
84
- async function createDetachedTmuxSession(name, cwd) {
85
- await runTmux(['new-session', '-d', '-s', name, '-c', cwd]);
86
- }
87
- async function attachTmuxSession(name) {
88
- await runTmux(['attach-session', '-t', toTmuxSessionTarget(name)]);
89
- }
90
- async function switchTmuxSession(name) {
91
- await runTmux(['switch-client', '-t', toTmuxSessionTarget(name)]);
92
- }
93
- async function launchTmuxSession(name, cwd) {
94
- const exists = await tmuxSessionExists(name);
95
- if (isInsideTmux()) {
96
- if (!exists) {
97
- await createDetachedTmuxSession(name, cwd);
98
- }
99
- await switchTmuxSession(name);
100
- return;
101
- }
102
- if (exists) {
103
- await attachTmuxSession(name);
104
- return;
105
- }
106
- await runTmux(['new-session', '-s', name, '-c', cwd]);
107
- }
108
- async function killTmuxSessionIfExists(name) {
109
- try {
110
- await runTmux(['kill-session', '-t', toTmuxSessionTarget(name)]);
111
- return true;
112
- }
113
- catch (error) {
114
- const message = error instanceof errors_1.CliError ? error.message.toLowerCase() : '';
115
- if (message.includes('no server running') ||
116
- message.includes('failed to connect to server') ||
117
- message.includes("can't find session") ||
118
- message.includes('failed to run tmux')) {
119
- return false;
120
- }
121
- throw error;
122
- }
123
- }
124
- async function pickTmuxSession() {
125
- const sessions = await listTmuxSessions();
126
- if (sessions.length === 0) {
127
- throw new errors_1.CliError('No tmux sessions are currently open.');
128
- }
129
- try {
130
- const selection = await (0, process_1.runCommand)('fzf', ['--prompt', 'tmux session> '], {
131
- stdin: `${sessions.map((session) => session.name).join('\n')}\n`,
132
- });
133
- const trimmed = selection.trim();
134
- if (!trimmed) {
135
- throw new errors_1.CliError('No tmux session selected.');
136
- }
137
- return trimmed;
138
- }
139
- catch (error) {
140
- const message = error instanceof errors_1.CliError ? error.message : '';
141
- if (message.includes('exit code 130')) {
142
- throw new errors_1.CliError('No tmux session selected.');
143
- }
144
- throw error;
145
- }
146
- }
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });