@sebastianstoll/spup 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sebastian Stoll
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # spup (Spin Up)
2
+
3
+ Holistic Laravel process manager with a tabbed TUI. One command to start everything (schedulers, queues, vite, and whatever you want).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g spup
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Initialize
14
+
15
+ ```bash
16
+ cd ~/projects/my-laravel-app
17
+ spup init
18
+ ```
19
+
20
+ Creates a `spup.json` with Laravel defaults (configure as needed):
21
+
22
+ ```json
23
+ {
24
+ "name": "my-laravel-app",
25
+ "processes": [
26
+ { "name": "serve", "command": "php artisan serve" },
27
+ { "name": "vite", "command": "npm run dev" },
28
+ { "name": "queue", "command": "php artisan queue:work" },
29
+ { "name": "logs", "command": "tail -f storage/logs/laravel.log" },
30
+ { "name": "schedule", "command": "php artisan schedule:work" }
31
+ ]
32
+ }
33
+ ```
34
+
35
+ ### Start
36
+
37
+ ```bash
38
+ spup start
39
+ ```
40
+
41
+ Opens a full-screen tabbed UI where each process has its own tab with dedicated output.
42
+
43
+ ### Navigation
44
+
45
+ | Key | Action |
46
+ |-----|--------|
47
+ | `1`-`9` | Switch to tab by number |
48
+ | `Tab` | Next tab |
49
+ | `Shift+Tab` | Previous tab |
50
+ | `↑` / `↓` | Scroll output |
51
+ | `PgUp` / `PgDn` | Scroll by page |
52
+ | `q` / `Ctrl+C` | Quit all processes |
53
+
54
+ ## Configuration
55
+
56
+ Edit `spup.json` to customize. Each process supports:
57
+
58
+ - `name` — Tab label
59
+ - `command` — The command to run
60
+ - `cwd` — Working directory (optional)
61
+ - `env` — Environment variables (optional)
62
+
63
+ ## License
64
+
65
+ MIT
package/bin/spup.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { run } from '../src/cli.js';
4
+
5
+ run(process.argv.slice(2));
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@sebastianstoll/spup",
3
+ "version": "0.1.0",
4
+ "description": "Laravel process manager with a tabbed TUI.",
5
+ "type": "module",
6
+ "bin": {
7
+ "spup": "bin/spup.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "src"
12
+ ],
13
+ "keywords": [
14
+ "cli",
15
+ "laravel",
16
+ "process-manager",
17
+ "tui",
18
+ "dev"
19
+ ],
20
+ "license": "MIT",
21
+ "engines": {
22
+ "node": ">=18"
23
+ }
24
+ }
package/src/cli.js ADDED
@@ -0,0 +1,42 @@
1
+ import { init } from './commands/init.js';
2
+ import { start } from './commands/start.js';
3
+
4
+ const HELP = `
5
+ spup - Laravel process manager with a tabbed TUI.
6
+
7
+ Usage:
8
+ spup init Initialize spup.json with Laravel defaults
9
+ spup start Start all processes in a tabbed terminal UI
10
+ spup help Show this help message
11
+
12
+ Examples:
13
+ spup init
14
+ spup start
15
+
16
+ Navigation (during spup start):
17
+ 1-9 Switch to tab by number
18
+ Tab Next tab
19
+ Shift+Tab Previous tab
20
+ q / Ctrl+C Quit
21
+ `;
22
+
23
+ export function run(args) {
24
+ const command = args[0];
25
+
26
+ switch (command) {
27
+ case 'init':
28
+ return init();
29
+ case 'start':
30
+ return start();
31
+ case 'help':
32
+ case '--help':
33
+ case '-h':
34
+ case undefined:
35
+ console.log(HELP);
36
+ break;
37
+ default:
38
+ console.error(`Unknown command: ${command}`);
39
+ console.log('Run "spup help" for usage.');
40
+ process.exit(1);
41
+ }
42
+ }
package/src/colors.js ADDED
@@ -0,0 +1,14 @@
1
+ // Minimal ANSI color helpers — zero dependencies
2
+
3
+ const esc = (code) => (str) => `\x1b[${code}m${str}\x1b[0m`;
4
+
5
+ export const colors = {
6
+ red: esc('31'),
7
+ green: esc('32'),
8
+ yellow: esc('33'),
9
+ blue: esc('34'),
10
+ magenta: esc('35'),
11
+ cyan: esc('36'),
12
+ dim: esc('2'),
13
+ bold: esc('1'),
14
+ };
@@ -0,0 +1,45 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { colors } from '../colors.js';
4
+
5
+ const DEFAULT_PROCESSES = [
6
+ { name: 'serve', command: 'php artisan serve' },
7
+ { name: 'vite', command: 'npm run dev' },
8
+ { name: 'queue', command: 'php artisan queue:work' },
9
+ { name: 'logs', command: 'tail -f storage/logs/laravel.log' },
10
+ { name: 'schedule', command: 'php artisan schedule:work' },
11
+ ];
12
+
13
+ export function init() {
14
+ const targetPath = path.join(process.cwd(), 'spup.json');
15
+
16
+ if (fs.existsSync(targetPath)) {
17
+ console.error(colors.yellow('spup.json already exists in this directory.'));
18
+ console.log('Delete it first if you want to re-initialize.');
19
+ process.exit(1);
20
+ }
21
+
22
+ // Check if this looks like a Laravel project
23
+ const artisanExists = fs.existsSync(path.join(process.cwd(), 'artisan'));
24
+ if (!artisanExists) {
25
+ console.error(colors.yellow('Warning: No artisan file found. Are you in a Laravel project?'));
26
+ }
27
+
28
+ const projectName = path.basename(process.cwd());
29
+
30
+ const config = {
31
+ name: projectName,
32
+ processes: DEFAULT_PROCESSES,
33
+ };
34
+
35
+ fs.writeFileSync(targetPath, JSON.stringify(config, null, 2) + '\n');
36
+
37
+ console.log(colors.green('Initialized spup.json'));
38
+ console.log('');
39
+ console.log('Processes:');
40
+ for (const proc of config.processes) {
41
+ console.log(` ${colors.cyan(proc.name.padEnd(12))} ${proc.command}`);
42
+ }
43
+ console.log('');
44
+ console.log(`Edit spup.json to add/remove processes, then run ${colors.bold('spup start')}.`);
45
+ }
@@ -0,0 +1,86 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { spawn } from 'node:child_process';
4
+ import { TUI } from '../tui.js';
5
+
6
+ export function start() {
7
+ const configPath = path.join(process.cwd(), 'spup.json');
8
+
9
+ if (!fs.existsSync(configPath)) {
10
+ console.error('No spup.json found. Run "spup init" first.');
11
+ process.exit(1);
12
+ }
13
+
14
+ let config;
15
+ try {
16
+ config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
17
+ } catch {
18
+ console.error('Failed to parse spup.json.');
19
+ process.exit(1);
20
+ }
21
+
22
+ if (!config.processes || config.processes.length === 0) {
23
+ console.error('No processes defined in spup.json.');
24
+ process.exit(1);
25
+ }
26
+
27
+ const tabs = config.processes.map((proc) => ({
28
+ name: proc.name,
29
+ command: proc.command,
30
+ buffer: [],
31
+ status: 'starting',
32
+ }));
33
+
34
+ const tui = new TUI(tabs);
35
+ const children = [];
36
+
37
+ for (let i = 0; i < config.processes.length; i++) {
38
+ const proc = config.processes[i];
39
+
40
+ const child = spawn(proc.command, {
41
+ shell: true,
42
+ stdio: ['ignore', 'pipe', 'pipe'],
43
+ cwd: proc.cwd ? path.resolve(proc.cwd) : process.cwd(),
44
+ env: { ...process.env, ...(proc.env || {}), FORCE_COLOR: '1' },
45
+ });
46
+
47
+ const handleData = (data) => {
48
+ tui.appendToTab(i, data.toString());
49
+ };
50
+
51
+ child.stdout.on('data', handleData);
52
+ child.stderr.on('data', handleData);
53
+
54
+ child.on('spawn', () => {
55
+ tui.setTabStatus(i, 'running');
56
+ });
57
+
58
+ child.on('error', (err) => {
59
+ tui.appendToTab(i, `Error: ${err.message}`);
60
+ tui.setTabStatus(i, 'stopped');
61
+ });
62
+
63
+ child.on('exit', (code) => {
64
+ tui.appendToTab(i, code === 0 ? 'Process exited.' : `Process exited with code ${code}.`);
65
+ tui.setTabStatus(i, 'stopped');
66
+ });
67
+
68
+ children.push(child);
69
+ }
70
+
71
+ const shutdown = () => {
72
+ tui.stop();
73
+ for (const child of children) {
74
+ if (child.exitCode === null) {
75
+ child.kill('SIGTERM');
76
+ }
77
+ }
78
+ setTimeout(() => process.exit(0), 2000);
79
+ };
80
+
81
+ tui.onQuit = shutdown;
82
+ process.on('SIGINT', shutdown);
83
+ process.on('SIGTERM', shutdown);
84
+
85
+ tui.start();
86
+ }
package/src/tui.js ADDED
@@ -0,0 +1,243 @@
1
+ const ESC = '\x1b[';
2
+
3
+ const ansi = {
4
+ enterAlt: '\x1b[?1049h',
5
+ leaveAlt: '\x1b[?1049l',
6
+ clearScreen: `${ESC}2J`,
7
+ hideCursor: `${ESC}?25l`,
8
+ showCursor: `${ESC}?25h`,
9
+ moveTo: (row, col) => `${ESC}${row};${col}H`,
10
+ clearLine: `${ESC}K`,
11
+ reset: `${ESC}0m`,
12
+ bold: `${ESC}1m`,
13
+ dim: `${ESC}2m`,
14
+ inverse: `${ESC}7m`,
15
+ fg: {
16
+ black: `${ESC}30m`,
17
+ white: `${ESC}37m`,
18
+ cyan: `${ESC}36m`,
19
+ yellow: `${ESC}33m`,
20
+ green: `${ESC}32m`,
21
+ red: `${ESC}31m`,
22
+ gray: `${ESC}90m`,
23
+ },
24
+ bg: {
25
+ black: `${ESC}40m`,
26
+ white: `${ESC}47m`,
27
+ cyan: `${ESC}46m`,
28
+ gray: `${ESC}100m`,
29
+ },
30
+ };
31
+
32
+ export class TUI {
33
+ constructor(tabs) {
34
+ this.tabs = tabs; // [{ name, buffer: string[] }]
35
+ this.activeTab = 0;
36
+ this.scrollOffset = 0; // lines from bottom (0 = follow tail)
37
+ this.cols = process.stdout.columns || 80;
38
+ this.rows = process.stdout.rows || 24;
39
+ }
40
+
41
+ start() {
42
+ process.stdout.write(ansi.enterAlt + ansi.hideCursor + ansi.clearScreen);
43
+
44
+ process.stdin.setRawMode(true);
45
+ process.stdin.resume();
46
+ process.stdin.on('data', (data) => this.handleInput(data));
47
+
48
+ process.stdout.on('resize', () => {
49
+ this.cols = process.stdout.columns;
50
+ this.rows = process.stdout.rows;
51
+ this.render();
52
+ });
53
+
54
+ this.render();
55
+ }
56
+
57
+ stop() {
58
+ process.stdout.write(ansi.showCursor + ansi.leaveAlt);
59
+ process.stdin.setRawMode(false);
60
+ process.stdin.pause();
61
+ }
62
+
63
+ appendToTab(index, text) {
64
+ const lines = text.split('\n');
65
+ for (const line of lines) {
66
+ if (line !== '') {
67
+ this.tabs[index].buffer.push(line);
68
+ // Keep buffer at a reasonable size
69
+ if (this.tabs[index].buffer.length > 5000) {
70
+ this.tabs[index].buffer.splice(0, 1000);
71
+ }
72
+ }
73
+ }
74
+ if (index === this.activeTab) {
75
+ this.render();
76
+ }
77
+ }
78
+
79
+ setTabStatus(index, status) {
80
+ this.tabs[index].status = status;
81
+ this.render();
82
+ }
83
+
84
+ handleInput(data) {
85
+ const key = data.toString();
86
+
87
+ // Ctrl+C or q
88
+ if (key === '\x03' || key === 'q') {
89
+ this.onQuit?.();
90
+ return;
91
+ }
92
+
93
+ // Tab key
94
+ if (key === '\t') {
95
+ this.activeTab = (this.activeTab + 1) % this.tabs.length;
96
+ this.scrollOffset = 0;
97
+ this.render();
98
+ return;
99
+ }
100
+
101
+ // Shift+Tab
102
+ if (key === '\x1b[Z') {
103
+ this.activeTab = (this.activeTab - 1 + this.tabs.length) % this.tabs.length;
104
+ this.scrollOffset = 0;
105
+ this.render();
106
+ return;
107
+ }
108
+
109
+ // Number keys 1-9
110
+ const num = parseInt(key);
111
+ if (num >= 1 && num <= this.tabs.length) {
112
+ this.activeTab = num - 1;
113
+ this.scrollOffset = 0;
114
+ this.render();
115
+ return;
116
+ }
117
+
118
+ // Arrow up / scroll up
119
+ if (key === '\x1b[A' || key === 'k') {
120
+ const tab = this.tabs[this.activeTab];
121
+ const contentHeight = this.rows - 4; // tab bar + status bar + borders
122
+ const maxScroll = Math.max(0, tab.buffer.length - contentHeight);
123
+ this.scrollOffset = Math.min(this.scrollOffset + 1, maxScroll);
124
+ this.render();
125
+ return;
126
+ }
127
+
128
+ // Arrow down / scroll down
129
+ if (key === '\x1b[B' || key === 'j') {
130
+ this.scrollOffset = Math.max(0, this.scrollOffset - 1);
131
+ this.render();
132
+ return;
133
+ }
134
+
135
+ // Page up
136
+ if (key === '\x1b[5~') {
137
+ const tab = this.tabs[this.activeTab];
138
+ const contentHeight = this.rows - 4;
139
+ const maxScroll = Math.max(0, tab.buffer.length - contentHeight);
140
+ this.scrollOffset = Math.min(this.scrollOffset + contentHeight, maxScroll);
141
+ this.render();
142
+ return;
143
+ }
144
+
145
+ // Page down
146
+ if (key === '\x1b[6~') {
147
+ const contentHeight = this.rows - 4;
148
+ this.scrollOffset = Math.max(0, this.scrollOffset - contentHeight);
149
+ this.render();
150
+ return;
151
+ }
152
+
153
+ // Home — scroll to top
154
+ if (key === '\x1b[H' || key === 'g') {
155
+ const tab = this.tabs[this.activeTab];
156
+ const contentHeight = this.rows - 4;
157
+ this.scrollOffset = Math.max(0, tab.buffer.length - contentHeight);
158
+ this.render();
159
+ return;
160
+ }
161
+
162
+ // End — scroll to bottom
163
+ if (key === '\x1b[F' || key === 'G') {
164
+ this.scrollOffset = 0;
165
+ this.render();
166
+ return;
167
+ }
168
+ }
169
+
170
+ render() {
171
+ const out = [];
172
+ out.push(ansi.moveTo(1, 1));
173
+
174
+ // Tab bar
175
+ out.push(this.renderTabBar());
176
+
177
+ // Separator
178
+ out.push(ansi.moveTo(2, 1));
179
+ out.push(ansi.fg.gray + '─'.repeat(this.cols) + ansi.reset);
180
+
181
+ // Content area
182
+ const contentHeight = this.rows - 4;
183
+ const tab = this.tabs[this.activeTab];
184
+ const buffer = tab.buffer;
185
+
186
+ const end = buffer.length - this.scrollOffset;
187
+ const start = Math.max(0, end - contentHeight);
188
+ const visible = buffer.slice(start, end);
189
+
190
+ for (let i = 0; i < contentHeight; i++) {
191
+ out.push(ansi.moveTo(i + 3, 1));
192
+ out.push(ansi.clearLine);
193
+ if (i < visible.length) {
194
+ const line = visible[i];
195
+ // Truncate to terminal width (accounting for ANSI codes is hard, so just cap it)
196
+ out.push(line.length > this.cols ? line.substring(0, this.cols) : line);
197
+ }
198
+ }
199
+
200
+ // Bottom separator
201
+ out.push(ansi.moveTo(this.rows - 1, 1));
202
+ out.push(ansi.fg.gray + '─'.repeat(this.cols) + ansi.reset);
203
+
204
+ // Status bar
205
+ out.push(ansi.moveTo(this.rows, 1));
206
+ out.push(ansi.clearLine);
207
+ out.push(this.renderStatusBar());
208
+
209
+ process.stdout.write(out.join(''));
210
+ }
211
+
212
+ renderTabBar() {
213
+ let bar = '';
214
+ for (let i = 0; i < this.tabs.length; i++) {
215
+ const tab = this.tabs[i];
216
+ const label = ` ${i + 1}:${tab.name} `;
217
+
218
+ if (i === this.activeTab) {
219
+ bar += `${ansi.bold}${ansi.inverse}${label}${ansi.reset}`;
220
+ } else {
221
+ const statusColor = tab.status === 'running' ? ansi.fg.green
222
+ : tab.status === 'stopped' ? ansi.fg.red
223
+ : ansi.fg.gray;
224
+ bar += `${statusColor}${label}${ansi.reset}`;
225
+ }
226
+ bar += ' ';
227
+ }
228
+ return bar + ansi.clearLine;
229
+ }
230
+
231
+ renderStatusBar() {
232
+ const tab = this.tabs[this.activeTab];
233
+ const status = tab.status || 'starting';
234
+ const statusColor = status === 'running' ? ansi.fg.green
235
+ : status === 'stopped' ? ansi.fg.red
236
+ : ansi.fg.yellow;
237
+
238
+ const left = `${statusColor}● ${status}${ansi.reset} ${ansi.dim}${tab.command}${ansi.reset}`;
239
+ const right = `${ansi.dim}Tab/1-${this.tabs.length}: switch ↑↓: scroll q: quit${ansi.reset}`;
240
+
241
+ return left + ansi.clearLine + ansi.moveTo(this.rows, Math.max(1, this.cols - 45)) + right;
242
+ }
243
+ }