pnpm-dash 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 +24 -0
- package/README.md +14 -0
- package/dist/cli.js +22 -0
- package/dist/index.js +43 -0
- package/dist/runner.js +118 -0
- package/dist/types.js +1 -0
- package/dist/ui/dashboard.js +147 -0
- package/dist/ui/logview.js +51 -0
- package/dist/ui/sidebar.js +51 -0
- package/dist/ui/statusbar.js +23 -0
- package/dist/workspace.js +36 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# pnpm-dash
|
|
2
|
+
|
|
3
|
+
pnpm-dash is a terminal-based user interface (TUI) for pnpm, designed to provide a quick and interactive way to manage your pnpm workspace and packages.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm dlx pnpm-dash dev
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
- Navigate using arrow keys
|
|
12
|
+
- Select packages to inspect logs or stop/start task
|
|
13
|
+
- Press `CTRL+C` to quit
|
|
14
|
+
- Optional `-F` param allows filtering packages by name, use * for wildcard and ! for exclusions
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
export function parseCLI() {
|
|
3
|
+
const program = new Command();
|
|
4
|
+
program
|
|
5
|
+
.name('pnpm-dash')
|
|
6
|
+
.description('A TUI dashboard for pnpm workspaces - run scripts across packages with a split-pane interface')
|
|
7
|
+
.version('0.1.0')
|
|
8
|
+
.argument('<script>', 'Script name to run across workspace packages (e.g., dev, start)')
|
|
9
|
+
.option('-F, --filter <pattern...>', 'Filter packages by name pattern, supports * for wildcard and ! for exclusions')
|
|
10
|
+
.parse();
|
|
11
|
+
const scriptName = program.args[0];
|
|
12
|
+
const options = program.opts();
|
|
13
|
+
if (!scriptName) {
|
|
14
|
+
console.error('Error: Script name is required');
|
|
15
|
+
console.error('Usage: pnpm-dash <script> [options]');
|
|
16
|
+
console.error('Example: pnpm-dash dev');
|
|
17
|
+
console.error('Example: pnpm-dash dev -F "*abc"');
|
|
18
|
+
console.error('Example: pnpm-dash dev -F "!*def"');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
return { scriptName, options };
|
|
22
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseCLI } from './cli.js';
|
|
3
|
+
import { discoverWorkspace, filterPackages } from './workspace.js';
|
|
4
|
+
import { Runner } from './runner.js';
|
|
5
|
+
import { Dashboard } from './ui/dashboard.js';
|
|
6
|
+
async function main() {
|
|
7
|
+
const { scriptName, options } = parseCLI();
|
|
8
|
+
console.log(`Discovering pnpm workspace...`);
|
|
9
|
+
let root;
|
|
10
|
+
let packages;
|
|
11
|
+
try {
|
|
12
|
+
const workspace = await discoverWorkspace();
|
|
13
|
+
root = workspace.root;
|
|
14
|
+
packages = workspace.packages;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
console.error(error.message);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const filtered = filterPackages(packages, scriptName, options.filter);
|
|
21
|
+
if (filtered.length === 0) {
|
|
22
|
+
const filterInfo = options.filter?.length
|
|
23
|
+
? ` matching filters: ${options.filter.join(', ')}`
|
|
24
|
+
: '';
|
|
25
|
+
console.error(`No packages found with script "${scriptName}"${filterInfo}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
console.log(`Found ${filtered.length} package(s) with "${scriptName}" script:`);
|
|
29
|
+
for (const pkg of filtered) {
|
|
30
|
+
console.log(` - ${pkg.name}`);
|
|
31
|
+
}
|
|
32
|
+
console.log();
|
|
33
|
+
const runner = new Runner(scriptName);
|
|
34
|
+
const dashboard = new Dashboard(runner, filtered);
|
|
35
|
+
runner.start(filtered);
|
|
36
|
+
dashboard.start();
|
|
37
|
+
process.on('SIGINT', async () => await dashboard.quit());
|
|
38
|
+
process.on('SIGTERM', async () => await dashboard.quit());
|
|
39
|
+
}
|
|
40
|
+
main().catch((error) => {
|
|
41
|
+
console.error('Fatal error:', error);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
});
|
package/dist/runner.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
export class Runner extends EventEmitter {
|
|
4
|
+
states = new Map();
|
|
5
|
+
scriptName;
|
|
6
|
+
constructor(scriptName) {
|
|
7
|
+
super();
|
|
8
|
+
this.scriptName = scriptName;
|
|
9
|
+
}
|
|
10
|
+
getStates() {
|
|
11
|
+
return this.states;
|
|
12
|
+
}
|
|
13
|
+
start(packages) {
|
|
14
|
+
for (const pkg of packages) {
|
|
15
|
+
this.startPackage(pkg);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
startPackage(pkg) {
|
|
19
|
+
let state = this.states.get(pkg.name);
|
|
20
|
+
if (state) {
|
|
21
|
+
if (state.subprocess && state.subprocess.exitCode == null) {
|
|
22
|
+
console.error(`${pkg.name} subprocess is still running`, state.subprocess.pid);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
state.status = 'running';
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
state = {
|
|
29
|
+
package: pkg,
|
|
30
|
+
status: 'running',
|
|
31
|
+
subprocess: null,
|
|
32
|
+
logs: [],
|
|
33
|
+
};
|
|
34
|
+
this.states.set(pkg.name, state);
|
|
35
|
+
}
|
|
36
|
+
const subprocess = execa('pnpm', ['run', this.scriptName], {
|
|
37
|
+
cwd: pkg.path,
|
|
38
|
+
env: {
|
|
39
|
+
...process.env,
|
|
40
|
+
FORCE_COLOR: '1',
|
|
41
|
+
},
|
|
42
|
+
all: true,
|
|
43
|
+
buffer: false,
|
|
44
|
+
reject: false,
|
|
45
|
+
cleanup: false,
|
|
46
|
+
detached: true,
|
|
47
|
+
});
|
|
48
|
+
state.subprocess = subprocess;
|
|
49
|
+
this.emit('start', pkg.name);
|
|
50
|
+
subprocess.all.on('data', (data) => {
|
|
51
|
+
const lines = data.toString().split('\n');
|
|
52
|
+
for (const line of lines) {
|
|
53
|
+
if (line) {
|
|
54
|
+
state.logs.push(line);
|
|
55
|
+
this.emit('log', pkg.name, line);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
subprocess.then((result) => {
|
|
60
|
+
state.status = result.exitCode === 0 ? 'success' : 'error';
|
|
61
|
+
state.subprocess = null;
|
|
62
|
+
this.emit('exit', pkg.name, result.exitCode ?? null);
|
|
63
|
+
}).catch((error) => {
|
|
64
|
+
state.status = 'error';
|
|
65
|
+
state.logs.push(`Error: ${error.message}`);
|
|
66
|
+
state.subprocess = null;
|
|
67
|
+
this.emit('error', pkg.name, error);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
killProcessGroup(pid, force = false) {
|
|
71
|
+
const signal = force ? 'SIGKILL' : 'SIGTERM';
|
|
72
|
+
try {
|
|
73
|
+
process.kill(-pid, signal);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Negative pid will throw on windows, back to SIGTERM
|
|
77
|
+
try {
|
|
78
|
+
process.kill(pid, signal);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Ignore
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async restartPackage(packageName) {
|
|
86
|
+
const state = this.states.get(packageName);
|
|
87
|
+
if (!state)
|
|
88
|
+
return;
|
|
89
|
+
await this.stopPackage(packageName);
|
|
90
|
+
this.startPackage(state.package);
|
|
91
|
+
}
|
|
92
|
+
async restartAll() {
|
|
93
|
+
await this.stopAll();
|
|
94
|
+
for (const state of this.states.values()) {
|
|
95
|
+
this.startPackage(state.package);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async stopPackage(packageName) {
|
|
99
|
+
const state = this.states.get(packageName);
|
|
100
|
+
const subprocess = state?.subprocess;
|
|
101
|
+
if (!subprocess?.pid)
|
|
102
|
+
return;
|
|
103
|
+
const pid = subprocess.pid;
|
|
104
|
+
this.killProcessGroup(pid);
|
|
105
|
+
const forceKillTimeout = setTimeout(() => {
|
|
106
|
+
this.killProcessGroup(pid, true);
|
|
107
|
+
}, 2000);
|
|
108
|
+
try {
|
|
109
|
+
await subprocess;
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
clearTimeout(forceKillTimeout);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async stopAll() {
|
|
116
|
+
await Promise.all(Array.from(this.states.keys()).map((name) => this.stopPackage(name)));
|
|
117
|
+
}
|
|
118
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import blessed from 'reblessed';
|
|
2
|
+
import { createSidebar, updateSidebarItems } from './sidebar.js';
|
|
3
|
+
import { createLogView, updateLogView, appendLog, toggleLogAutoScroll } from './logview.js';
|
|
4
|
+
import { createStatusBar, updateStatusBar } from './statusbar.js';
|
|
5
|
+
export class Dashboard {
|
|
6
|
+
screen;
|
|
7
|
+
sidebar;
|
|
8
|
+
logView;
|
|
9
|
+
statusBar;
|
|
10
|
+
runner;
|
|
11
|
+
state;
|
|
12
|
+
packageNames = [];
|
|
13
|
+
constructor(runner, packages) {
|
|
14
|
+
this.runner = runner;
|
|
15
|
+
this.packageNames = packages.map((p) => p.name);
|
|
16
|
+
this.state = {
|
|
17
|
+
packages: runner.getStates(),
|
|
18
|
+
selectedIndex: 0,
|
|
19
|
+
autoScroll: true,
|
|
20
|
+
};
|
|
21
|
+
this.screen = blessed.screen({
|
|
22
|
+
smartCSR: true,
|
|
23
|
+
title: 'pnpm-dash',
|
|
24
|
+
fullUnicode: true,
|
|
25
|
+
});
|
|
26
|
+
this.sidebar = createSidebar(this.screen);
|
|
27
|
+
this.logView = createLogView(this.screen, this.state.autoScroll);
|
|
28
|
+
this.statusBar = createStatusBar(this.screen);
|
|
29
|
+
this.setupKeyBindings();
|
|
30
|
+
this.setupRunnerEvents();
|
|
31
|
+
}
|
|
32
|
+
setupKeyBindings() {
|
|
33
|
+
this.screen.key(['S-q', 'C-c'], () => {
|
|
34
|
+
this.quit();
|
|
35
|
+
});
|
|
36
|
+
this.screen.key(['q'], () => {
|
|
37
|
+
this.stopSelected();
|
|
38
|
+
});
|
|
39
|
+
this.screen.key(['j', 'down'], () => {
|
|
40
|
+
this.selectNext();
|
|
41
|
+
});
|
|
42
|
+
this.screen.key(['k', 'up'], () => {
|
|
43
|
+
this.selectPrev();
|
|
44
|
+
});
|
|
45
|
+
this.screen.key(['r'], () => {
|
|
46
|
+
this.restartSelected();
|
|
47
|
+
});
|
|
48
|
+
this.screen.key(['S-r'], () => {
|
|
49
|
+
this.restartAll();
|
|
50
|
+
});
|
|
51
|
+
this.screen.key(['s'], () => {
|
|
52
|
+
this.toggleAutoScroll();
|
|
53
|
+
});
|
|
54
|
+
this.screen.key(['c'], () => {
|
|
55
|
+
this.clearSelected();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
setupRunnerEvents() {
|
|
59
|
+
this.runner.on('start', (packageName) => {
|
|
60
|
+
this.refreshSidebar();
|
|
61
|
+
this.screen.render();
|
|
62
|
+
});
|
|
63
|
+
this.runner.on('log', (packageName, line) => {
|
|
64
|
+
appendLog(this.logView, this.getSelectedPackageName(), packageName, line);
|
|
65
|
+
});
|
|
66
|
+
this.runner.on('exit', (packageName, code) => {
|
|
67
|
+
this.refreshSidebar();
|
|
68
|
+
this.screen.render();
|
|
69
|
+
});
|
|
70
|
+
this.runner.on('error', (packageName, error) => {
|
|
71
|
+
this.refreshSidebar();
|
|
72
|
+
this.screen.render();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
getSelectedPackageName() {
|
|
76
|
+
return this.packageNames[this.state.selectedIndex];
|
|
77
|
+
}
|
|
78
|
+
getSelectedState() {
|
|
79
|
+
const name = this.getSelectedPackageName();
|
|
80
|
+
return name ? this.state.packages.get(name) : undefined;
|
|
81
|
+
}
|
|
82
|
+
selectNext() {
|
|
83
|
+
if (this.state.selectedIndex < this.packageNames.length - 1) {
|
|
84
|
+
this.state.selectedIndex++;
|
|
85
|
+
}
|
|
86
|
+
else if (this.packageNames.length > 1) {
|
|
87
|
+
this.state.selectedIndex = 0;
|
|
88
|
+
}
|
|
89
|
+
this.refreshSidebar();
|
|
90
|
+
this.refreshLogView();
|
|
91
|
+
}
|
|
92
|
+
selectPrev() {
|
|
93
|
+
if (this.state.selectedIndex > 0) {
|
|
94
|
+
this.state.selectedIndex--;
|
|
95
|
+
}
|
|
96
|
+
else if (this.packageNames.length > 1) {
|
|
97
|
+
this.state.selectedIndex = this.packageNames.length - 1;
|
|
98
|
+
}
|
|
99
|
+
this.refreshSidebar();
|
|
100
|
+
this.refreshLogView();
|
|
101
|
+
}
|
|
102
|
+
clearSelected() {
|
|
103
|
+
const state = this.getSelectedState();
|
|
104
|
+
if (state) {
|
|
105
|
+
state.logs = [];
|
|
106
|
+
this.refreshLogView();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
stopSelected() {
|
|
110
|
+
const name = this.getSelectedPackageName();
|
|
111
|
+
if (name) {
|
|
112
|
+
this.runner.stopPackage(name);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
restartSelected() {
|
|
116
|
+
const name = this.getSelectedPackageName();
|
|
117
|
+
if (name) {
|
|
118
|
+
this.runner.restartPackage(name);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
restartAll() {
|
|
122
|
+
this.runner.restartAll();
|
|
123
|
+
}
|
|
124
|
+
toggleAutoScroll() {
|
|
125
|
+
this.state.autoScroll = !this.state.autoScroll;
|
|
126
|
+
toggleLogAutoScroll(this.logView, this.state.autoScroll);
|
|
127
|
+
updateStatusBar(this.statusBar, this.state.autoScroll);
|
|
128
|
+
this.screen.render();
|
|
129
|
+
}
|
|
130
|
+
refreshSidebar() {
|
|
131
|
+
updateSidebarItems(this.sidebar, this.state.packages, this.state.selectedIndex);
|
|
132
|
+
}
|
|
133
|
+
refreshLogView() {
|
|
134
|
+
updateLogView(this.logView, this.getSelectedState());
|
|
135
|
+
}
|
|
136
|
+
async quit() {
|
|
137
|
+
await this.runner.stopAll();
|
|
138
|
+
this.screen.destroy();
|
|
139
|
+
process.exit(0);
|
|
140
|
+
}
|
|
141
|
+
start() {
|
|
142
|
+
this.refreshSidebar();
|
|
143
|
+
this.refreshLogView();
|
|
144
|
+
this.sidebar.focus();
|
|
145
|
+
this.screen.render();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import blessed from 'reblessed';
|
|
2
|
+
export function createLogView(screen, autoScroll) {
|
|
3
|
+
const logView = blessed.log({
|
|
4
|
+
parent: screen,
|
|
5
|
+
label: ' Logs ',
|
|
6
|
+
left: '25%',
|
|
7
|
+
top: 0,
|
|
8
|
+
width: '75%',
|
|
9
|
+
height: '100%-1',
|
|
10
|
+
border: {
|
|
11
|
+
type: 'line',
|
|
12
|
+
},
|
|
13
|
+
style: {
|
|
14
|
+
border: {
|
|
15
|
+
fg: 'blue',
|
|
16
|
+
},
|
|
17
|
+
label: {
|
|
18
|
+
fg: 'blue',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
mouse: true,
|
|
22
|
+
scrollbar: {
|
|
23
|
+
ch: '│',
|
|
24
|
+
},
|
|
25
|
+
scrollOnInput: autoScroll,
|
|
26
|
+
});
|
|
27
|
+
return logView;
|
|
28
|
+
}
|
|
29
|
+
export function updateLogView(logView, state) {
|
|
30
|
+
if (!state) {
|
|
31
|
+
logView.setLabel(' Logs ');
|
|
32
|
+
logView.setContent('');
|
|
33
|
+
logView.setScroll(0);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
logView.setLabel(` Logs - ${state.package.name} `);
|
|
37
|
+
logView.setContent(state.logs.join('\n'));
|
|
38
|
+
logView.setScroll(0);
|
|
39
|
+
}
|
|
40
|
+
export function appendLog(logView, currentPackage, packageName, line) {
|
|
41
|
+
if (currentPackage !== packageName) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
logView.add(line);
|
|
45
|
+
}
|
|
46
|
+
export function toggleLogAutoScroll(logView, autoScroll) {
|
|
47
|
+
logView.scrollOnInput = autoScroll;
|
|
48
|
+
if (autoScroll) {
|
|
49
|
+
logView.setScrollPerc(100);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import blessed from 'reblessed';
|
|
2
|
+
const STATUS_ICONS = {
|
|
3
|
+
idle: { icon: '○', color: 'gray' },
|
|
4
|
+
running: { icon: '●', color: 'green' },
|
|
5
|
+
success: { icon: '✓', color: 'blue' },
|
|
6
|
+
error: { icon: '✘', color: 'red' },
|
|
7
|
+
};
|
|
8
|
+
export function createSidebar(screen) {
|
|
9
|
+
const sidebar = blessed.list({
|
|
10
|
+
parent: screen,
|
|
11
|
+
label: ' Packages ',
|
|
12
|
+
left: 0,
|
|
13
|
+
top: 0,
|
|
14
|
+
width: '25%',
|
|
15
|
+
height: '100%-1',
|
|
16
|
+
border: {
|
|
17
|
+
type: 'line',
|
|
18
|
+
},
|
|
19
|
+
style: {
|
|
20
|
+
border: {
|
|
21
|
+
fg: 'blue',
|
|
22
|
+
},
|
|
23
|
+
selected: {
|
|
24
|
+
bg: 'blue',
|
|
25
|
+
fg: 'white',
|
|
26
|
+
},
|
|
27
|
+
item: {
|
|
28
|
+
fg: 'white',
|
|
29
|
+
},
|
|
30
|
+
label: {
|
|
31
|
+
fg: 'blue',
|
|
32
|
+
} // invalid type from @types/blessed :|
|
|
33
|
+
},
|
|
34
|
+
mouse: false,
|
|
35
|
+
scrollable: true,
|
|
36
|
+
scrollbar: {
|
|
37
|
+
ch: '│',
|
|
38
|
+
},
|
|
39
|
+
tags: true,
|
|
40
|
+
});
|
|
41
|
+
return sidebar;
|
|
42
|
+
}
|
|
43
|
+
export function updateSidebarItems(sidebar, states, selectedIndex) {
|
|
44
|
+
const items = [];
|
|
45
|
+
for (const [name, state] of states) {
|
|
46
|
+
const { icon, color } = STATUS_ICONS[state.status];
|
|
47
|
+
items.push(`{${color}-fg}${icon}{/${color}-fg} ${name}`);
|
|
48
|
+
}
|
|
49
|
+
sidebar.setItems(items);
|
|
50
|
+
sidebar.select(selectedIndex);
|
|
51
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import blessed from 'reblessed';
|
|
2
|
+
export function createStatusBar(screen) {
|
|
3
|
+
const statusBar = blessed.box({
|
|
4
|
+
parent: screen,
|
|
5
|
+
bottom: 0,
|
|
6
|
+
left: 0,
|
|
7
|
+
width: '100%',
|
|
8
|
+
height: 1,
|
|
9
|
+
style: {
|
|
10
|
+
bg: 'blue',
|
|
11
|
+
fg: 'white',
|
|
12
|
+
},
|
|
13
|
+
tags: true,
|
|
14
|
+
});
|
|
15
|
+
updateStatusBar(statusBar, true);
|
|
16
|
+
return statusBar;
|
|
17
|
+
}
|
|
18
|
+
export function updateStatusBar(statusBar, autoScroll) {
|
|
19
|
+
const scrollStatus = autoScroll ? 'ON' : 'OFF';
|
|
20
|
+
statusBar.setContent(` {bold}Q{/bold}:exit {bold}q{/bold}:quit task {bold}r{/bold}:restart task ` +
|
|
21
|
+
` {bold}R{/bold}:restart all {bold}j/k{/bold}:navigate {bold}c{/bold}:clear ` +
|
|
22
|
+
` {bold}s{/bold}:autoscroll [${scrollStatus}]`);
|
|
23
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { findWorkspaceDir } from '@pnpm/find-workspace-dir';
|
|
2
|
+
import { findWorkspacePackages } from '@pnpm/workspace.find-packages';
|
|
3
|
+
export async function discoverWorkspace(cwd = process.cwd()) {
|
|
4
|
+
const workspaceRoot = await findWorkspaceDir(cwd);
|
|
5
|
+
if (!workspaceRoot) {
|
|
6
|
+
throw new Error('No pnpm workspace found. Make sure you have a pnpm-workspace.yaml file in your project root.');
|
|
7
|
+
}
|
|
8
|
+
const projects = await findWorkspacePackages(workspaceRoot);
|
|
9
|
+
const packages = projects
|
|
10
|
+
.filter((project) => project.manifest.name && project.rootDir !== workspaceRoot)
|
|
11
|
+
.map((project) => ({
|
|
12
|
+
name: project.manifest.name,
|
|
13
|
+
path: project.rootDir,
|
|
14
|
+
scripts: project.manifest.scripts || {},
|
|
15
|
+
}));
|
|
16
|
+
return { root: workspaceRoot, packages };
|
|
17
|
+
}
|
|
18
|
+
function globMatch(name, pattern) {
|
|
19
|
+
const regex = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$');
|
|
20
|
+
return regex.test(name);
|
|
21
|
+
}
|
|
22
|
+
export function filterPackages(packages, scriptName, filterPatterns) {
|
|
23
|
+
let targetPgks = packages.filter((pkg) => pkg.scripts[scriptName]);
|
|
24
|
+
if (!filterPatterns?.length) {
|
|
25
|
+
return targetPgks;
|
|
26
|
+
}
|
|
27
|
+
const includePatterns = filterPatterns.filter((p) => !p.startsWith('!'));
|
|
28
|
+
const excludePatterns = filterPatterns.filter((p) => p.startsWith('!')).map((p) => p.slice(1));
|
|
29
|
+
if (includePatterns.length > 0) {
|
|
30
|
+
targetPgks = targetPgks.filter((pkg) => includePatterns.some((pattern) => globMatch(pkg.name, pattern)));
|
|
31
|
+
}
|
|
32
|
+
if (excludePatterns.length > 0) {
|
|
33
|
+
targetPgks = targetPgks.filter((pkg) => !excludePatterns.some((pattern) => globMatch(pkg.name, pattern)));
|
|
34
|
+
}
|
|
35
|
+
return targetPgks;
|
|
36
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pnpm-dash",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A TUI dashboard for pnpm workspaces - run scripts across packages with a split-pane interface",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"pnpm-dash": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"dev": "tsc --watch",
|
|
16
|
+
"start": "node ./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"pnpm",
|
|
20
|
+
"monorepo",
|
|
21
|
+
"workspace",
|
|
22
|
+
"tui",
|
|
23
|
+
"dashboard",
|
|
24
|
+
"terminal"
|
|
25
|
+
],
|
|
26
|
+
"author": "artygus",
|
|
27
|
+
"license": "UNLICENSED",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@pnpm/find-workspace-dir": "^7.0.2",
|
|
30
|
+
"@pnpm/workspace.find-packages": "^4.0.5",
|
|
31
|
+
"commander": "^13.1.0",
|
|
32
|
+
"execa": "^9.6.1",
|
|
33
|
+
"reblessed": "^0.2.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/blessed": "^0.1.25",
|
|
37
|
+
"@types/node": "^22.0.0",
|
|
38
|
+
"typescript": "^5.7.0"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18"
|
|
42
|
+
}
|
|
43
|
+
}
|