Skip to content

Commit e2023d1

Browse files
committed
chore(output): remove unused BottomBar stuff
BREAKING CHANGE: Remove `BottomBarOutputStrategy`
1 parent 3051ffe commit e2023d1

File tree

1 file changed

+0
-105
lines changed
  • packages/@ionic/cli-framework/src/lib

1 file changed

+0
-105
lines changed
Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import * as Debug from 'debug';
2-
import * as ζinquirer from 'inquirer';
31
import logUpdate = require('log-update');
42
import { LogUpdate } from 'log-update';
53

64
import { Colors, DEFAULT_COLORS } from './colors';
75
import { ICON_FAILURE, ICON_SUCCESS, Spinner, TaskChain } from './tasks';
86

9-
const debug = Debug('ionic:cli-framework:lib:output');
10-
117
export interface OutputStrategy {
128
readonly stream: NodeJS.WritableStream;
139
createTaskChain(): TaskChain;
@@ -105,104 +101,3 @@ export class LogUpdateOutputStrategy implements OutputStrategy, RedrawLine {
105101
return chain;
106102
}
107103
}
108-
109-
export interface BottomBarOutputStrategyOptions {
110-
readonly BottomBar: typeof ζinquirer.ui.BottomBar;
111-
readonly input?: NodeJS.ReadableStream;
112-
readonly output?: NodeJS.WritableStream;
113-
readonly colors?: Colors;
114-
}
115-
116-
export class BottomBarOutputStrategy implements OutputStrategy, RedrawLine {
117-
protected bottomBar?: ζinquirer.ui.BottomBar;
118-
119-
protected readonly BottomBar: typeof ζinquirer.ui.BottomBar;
120-
protected readonly rawinput: NodeJS.ReadableStream;
121-
protected readonly rawoutput: NodeJS.WritableStream;
122-
protected readonly colors: Colors;
123-
124-
constructor({ BottomBar, input = process.stdin, output = process.stdout, colors = DEFAULT_COLORS }: BottomBarOutputStrategyOptions) {
125-
this.BottomBar = BottomBar;
126-
this.rawinput = input;
127-
this.rawoutput = output;
128-
this.colors = colors;
129-
}
130-
131-
get stream(): NodeJS.WritableStream {
132-
const bottomBar = this.get();
133-
return bottomBar.log;
134-
}
135-
136-
redrawLine(msg = ''): void {
137-
const bottomBar = this.get();
138-
bottomBar.updateBottomBar(msg);
139-
}
140-
141-
get(): typeof ζinquirer.ui.BottomBar {
142-
if (!this.bottomBar) {
143-
this.bottomBar = new this.BottomBar({ input: this.rawinput, output: this.rawoutput } as any);
144-
145-
try {
146-
// the mute() call appears to be necessary, otherwise when answering
147-
// inquirer prompts upon pressing enter, a copy of the prompt is
148-
// printed to the screen and looks gross
149-
(this.bottomBar as any).rl.output.mute();
150-
} catch (e) {
151-
debug('Error while muting bottomBar output: %o', e);
152-
}
153-
}
154-
155-
return this.bottomBar;
156-
}
157-
158-
open(): void {
159-
this.get();
160-
}
161-
162-
close(): void {
163-
if (this.bottomBar) {
164-
// instantiating inquirer.ui.BottomBar hangs, so when close() is called,
165-
// close BottomBar streams
166-
this.bottomBar.close();
167-
this.bottomBar = undefined;
168-
}
169-
}
170-
171-
createTaskChain(): TaskChain {
172-
const { failure, strong, success } = this.colors;
173-
const chain = new TaskChain({ taskOptions: { tickInterval: 50 } });
174-
175-
this.open();
176-
177-
chain.on('next', task => {
178-
this.open();
179-
180-
task.on('success', () => {
181-
this.stream.write(`${success(ICON_SUCCESS)} ${task.msg} - done!`);
182-
});
183-
184-
task.on('failure', () => {
185-
this.stream.write(`${failure(ICON_FAILURE)} ${task.msg} - failed!`);
186-
});
187-
188-
const spinner = new Spinner();
189-
190-
task.on('tick', () => {
191-
const progress = task.progressRatio ? (task.progressRatio * 100).toFixed(2) : '';
192-
const frame = spinner.frame();
193-
194-
this.redrawLine(`${strong(frame)} ${task.msg}${progress ? ' (' + strong(String(progress) + '%') + ')' : ''} `);
195-
});
196-
197-
task.on('clear', () => {
198-
this.redrawLine('');
199-
});
200-
});
201-
202-
chain.on('end', () => {
203-
this.close();
204-
});
205-
206-
return chain;
207-
}
208-
}

0 commit comments

Comments
 (0)