pnpm-dash 0.1.2 → 0.1.3

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/cli.js CHANGED
@@ -4,7 +4,7 @@ export function parseCLI() {
4
4
  program
5
5
  .name('pnpm-dash')
6
6
  .description('A TUI dashboard for pnpm workspaces - run scripts across packages with a split-pane interface')
7
- .version('0.1.2')
7
+ .version('0.1.3')
8
8
  .argument('<script>', 'Script name to run across workspace packages (e.g., dev, start)')
9
9
  .option('-F, --filter <pattern...>', 'Filter packages by name pattern, supports * for wildcard and ! for exclusions')
10
10
  .parse();
@@ -2,6 +2,7 @@ import blessed from 'reblessed';
2
2
  import { createSidebar, updateSidebarItems } from './sidebar.js';
3
3
  import { createLogView, updateLogView, appendLog, toggleLogAutoScroll, expandLogView, shrinkLogView } from './logview.js';
4
4
  import { createStatusBar, updateStatusBar } from './statusbar.js';
5
+ const RENDER_INTERVAL = 33;
5
6
  export class Dashboard {
6
7
  screen;
7
8
  sidebar;
@@ -10,6 +11,9 @@ export class Dashboard {
10
11
  runner;
11
12
  state;
12
13
  packageNames = [];
14
+ renderTimer = null;
15
+ needsRender = false;
16
+ pendingLogs = [];
13
17
  constructor(runner, packages) {
14
18
  this.runner = runner;
15
19
  this.packageNames = packages.map((p) => p.name);
@@ -62,20 +66,33 @@ export class Dashboard {
62
66
  setupRunnerEvents() {
63
67
  this.runner.on('start', (packageName) => {
64
68
  this.refreshSidebar();
65
- this.screen.render();
69
+ this.needsRender = true;
66
70
  });
67
71
  this.runner.on('log', (packageName, line) => {
68
- appendLog(this.logView, this.getSelectedPackageName(), packageName, line);
72
+ if (packageName === this.getSelectedPackageName()) {
73
+ this.pendingLogs.push(line);
74
+ this.needsRender = true;
75
+ }
69
76
  });
70
77
  this.runner.on('exit', (packageName, code) => {
71
78
  this.refreshSidebar();
72
- this.screen.render();
79
+ this.needsRender = true;
73
80
  });
74
81
  this.runner.on('error', (packageName, error) => {
75
82
  this.refreshSidebar();
76
- this.screen.render();
83
+ this.needsRender = true;
77
84
  });
78
85
  }
86
+ flushRender() {
87
+ if (this.pendingLogs.length > 0) {
88
+ appendLog(this.logView, this.pendingLogs);
89
+ this.pendingLogs = [];
90
+ }
91
+ if (this.needsRender) {
92
+ this.screen.render();
93
+ this.needsRender = false;
94
+ }
95
+ }
79
96
  getSelectedPackageName() {
80
97
  return this.packageNames[this.state.selectedIndex];
81
98
  }
@@ -92,6 +109,8 @@ export class Dashboard {
92
109
  }
93
110
  this.refreshSidebar();
94
111
  this.refreshLogView();
112
+ this.pendingLogs = [];
113
+ this.needsRender = true;
95
114
  }
96
115
  selectPrev() {
97
116
  if (this.state.selectedIndex > 0) {
@@ -102,12 +121,15 @@ export class Dashboard {
102
121
  }
103
122
  this.refreshSidebar();
104
123
  this.refreshLogView();
124
+ this.pendingLogs = [];
125
+ this.needsRender = true;
105
126
  }
106
127
  clearSelected() {
107
128
  const state = this.getSelectedState();
108
129
  if (state) {
109
130
  state.logs.clear();
110
131
  this.refreshLogView();
132
+ this.needsRender = true;
111
133
  }
112
134
  }
113
135
  stopSelected() {
@@ -129,7 +151,7 @@ export class Dashboard {
129
151
  this.state.autoScroll = !this.state.autoScroll;
130
152
  toggleLogAutoScroll(this.logView, this.state.autoScroll);
131
153
  updateStatusBar(this.statusBar, this.state.autoScroll);
132
- this.screen.render();
154
+ this.needsRender = true;
133
155
  }
134
156
  toggleSidebar() {
135
157
  this.state.sidebarHidden = !this.state.sidebarHidden;
@@ -142,7 +164,7 @@ export class Dashboard {
142
164
  shrinkLogView(this.logView);
143
165
  }
144
166
  updateStatusBar(this.statusBar, this.state.autoScroll);
145
- this.screen.render();
167
+ this.needsRender = true;
146
168
  }
147
169
  refreshSidebar() {
148
170
  updateSidebarItems(this.sidebar, this.state.packages, this.state.selectedIndex);
@@ -151,6 +173,10 @@ export class Dashboard {
151
173
  updateLogView(this.logView, this.getSelectedState());
152
174
  }
153
175
  async quit() {
176
+ if (this.renderTimer) {
177
+ clearInterval(this.renderTimer);
178
+ this.renderTimer = null;
179
+ }
154
180
  await this.runner.stopAll();
155
181
  this.screen.destroy();
156
182
  process.exit(0);
@@ -160,5 +186,6 @@ export class Dashboard {
160
186
  this.refreshLogView();
161
187
  this.logView.focus();
162
188
  this.screen.render();
189
+ this.renderTimer = setInterval(() => this.flushRender(), RENDER_INTERVAL);
163
190
  }
164
191
  }
@@ -39,11 +39,8 @@ export function updateLogView(logView, state) {
39
39
  logView.setContent(state.logs.toArray().join('\n'));
40
40
  logView.setScroll(0);
41
41
  }
42
- export function appendLog(logView, currentPackage, packageName, line) {
43
- if (currentPackage !== packageName) {
44
- return;
45
- }
46
- logView.add(line);
42
+ export function appendLog(logView, lines) {
43
+ logView.add(lines.join("\n"));
47
44
  }
48
45
  export function toggleLogAutoScroll(logView, autoScroll) {
49
46
  logView.scrollOnInput = autoScroll;
@@ -12,7 +12,6 @@ export function createStatusBar(screen) {
12
12
  },
13
13
  tags: true,
14
14
  });
15
- updateStatusBar(statusBar, true);
16
15
  return statusBar;
17
16
  }
18
17
  export function updateStatusBar(statusBar, autoScroll) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pnpm-dash",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A TUI dashboard for pnpm workspaces - run scripts across packages with a split-pane interface",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,6 +25,10 @@
25
25
  ],
26
26
  "author": "artygus",
27
27
  "license": "Unlicense",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/artygus/pnpm-dash.git"
31
+ },
28
32
  "dependencies": {
29
33
  "@pnpm/find-workspace-dir": "^7.0.2",
30
34
  "@pnpm/workspace.find-packages": "^4.0.5",