Skip to content

Commit ca22362

Browse files
committed
style(start): make things prettier
1 parent 2c3ab98 commit ca22362

6 files changed

Lines changed: 72 additions & 33 deletions

File tree

packages/@ionic/cli-utils/src/lib/environment.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,6 @@ export class Environment implements IonicEnvironment {
106106
const inquirer = require('inquirer');
107107
this.bottomBar = new inquirer.ui.BottomBar();
108108
}
109-
110-
try {
111-
// the mute() call appears to be necessary, otherwise when answering
112-
// inquirer prompts upon pressing enter, a copy of the prompt is
113-
// printed to the screen and looks gross
114-
const bottomBarHack = <any>this.bottomBar;
115-
bottomBarHack.rl.output.mute();
116-
} catch (e) {
117-
process.stderr.write(`EXCEPTION DURING BOTTOMBAR OUTPUT MUTE: ${e}\n`);
118-
}
119109
}
120110

121111
this.log.outstream = typeof this.bottomBar === 'undefined' ? process.stdout : this.bottomBar.log;

packages/@ionic/cli-utils/src/lib/shell.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ export class Shell implements IShell {
5050

5151
try {
5252
await runcmd(command, args, options);
53-
54-
if (showCommand) {
55-
this.log.nl();
56-
}
5753
} catch (e) {
5854
if (e.code === 'ENOENT') {
5955
if (fatalOnNotFound) {

packages/@ionic/cli-utils/src/lib/start.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as path from 'path';
22

3+
import chalk from 'chalk';
4+
35
import {
46
ERROR_FILE_INVALID_JSON,
57
ERROR_FILE_NOT_FOUND,
@@ -9,6 +11,7 @@ import {
911

1012
import { IConfig, StarterList, StarterManifest, StarterTemplate } from '../definitions';
1113
import { isStarterManifest } from '../guards';
14+
import { emoji } from './utils/emoji';
1215
import { createRequest } from './http';
1316

1417
export const STARTER_BASE_URL = 'https://d2ql0qc7j8u4b2.cloudfront.net';
@@ -59,6 +62,32 @@ export async function updatePackageJsonForCli(projectRoot: string, appName: stri
5962
}
6063
}
6164

65+
const advertisementSeparator = '─';
66+
67+
export async function getIonicDevAppText() {
68+
const msg = `
69+
${chalk.bold(`${emoji('✨', '*')} IONIC DEVAPP ${emoji('✨', '*')}`)}\n
70+
Speed up development with the ${chalk.bold('Ionic DevApp')}, our fast, on-device testing mobile app\n
71+
- ${emoji('🔑', '')} Test on iOS and Android without Native SDKs
72+
- ${emoji('🚀', '')} LiveReload for instant style and JS updates\n
73+
--> Install DevApp: ${chalk.bold('https://bit.ly/ionic-dev-app')} <--
74+
`;
75+
76+
return `${msg}\n${advertisementSeparator.repeat(60)}\n\n`;
77+
}
78+
79+
export async function getIonicProText() {
80+
const msg = `
81+
${chalk.bold(`${emoji('🔥', '*')} IONIC PRO ${emoji('🔥', '*')}`)}\n
82+
Supercharge your Ionic development with the ${chalk.bold('Ionic Pro')} SDK\n
83+
- ${emoji('⚠️', '')} Track runtime errors in real-time, back to your original TypeScript
84+
- ${emoji('📲', '')} Push remote updates and skip the app store queue\n
85+
Learn more about Ionic Pro: ${chalk.bold('https://ionicframework.com/pro')}
86+
`;
87+
88+
return `${msg}\n${advertisementSeparator.repeat(60)}\n\n`;
89+
}
90+
6291
export async function getStarterList(config: IConfig, tag = 'latest'): Promise<StarterList> {
6392
const { req } = await createRequest(config, 'get', `${STARTER_BASE_URL}/${tag === 'latest' ? '' : `${tag}/`}starters.json`);
6493

packages/ionic/src/commands/start.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ ${chalk.cyan('[1]')}: ${chalk.bold('https://ionicframework.com/docs/cli/starters
276276

277277
async run(inputs: CommandLineInputs, options: CommandLineOptions): Promise<void> {
278278
const { pkgManagerArgs } = await import('@ionic/cli-utils/lib/utils/npm');
279+
const { getIonicDevAppText, getIonicProText } = await import('@ionic/cli-utils/lib/start');
279280
const config = await this.env.config.load();
280281
const { npmClient } = config;
281282

@@ -319,7 +320,7 @@ ${chalk.cyan('[1]')}: ${chalk.bold('https://ionicframework.com/docs/cli/starters
319320
// autogenerated when the CLI booted up. This has worked thus far?
320321
this.env.project = await getProject(projectDir, this.env);
321322

322-
const shellOptions = { cwd: projectDir };
323+
const shellOptions = { cwd: projectDir, stdio: ['inherit', 'ignore', 'ignore'] };
323324

324325
if (!clonedApp) {
325326
if (!options['cordova']) {
@@ -349,14 +350,7 @@ ${chalk.cyan('[1]')}: ${chalk.bold('https://ionicframework.com/docs/cli/starters
349350
if (options['deps']) {
350351
this.env.log.msg('Installing dependencies may take several minutes.');
351352

352-
this.env.log.nl();
353-
this.env.log.rawmsg(
354-
` ${chalk.bold(`${emoji('✨', '*')} IONIC DEVAPP ${emoji('✨', '*')}`)}\n\n` +
355-
` Speed up development with the ${chalk.bold('Ionic DevApp')}, our fast, on-device testing mobile app\n\n` +
356-
` - ${emoji('🔑', '')} Test on iOS and Android without Native SDKs\n` +
357-
` - ${emoji('🚀', '')} LiveReload for instant style and JS updates\n\n` +
358-
` ️--> Install DevApp: ${chalk.bold('https://bit.ly/ionic-dev-app')} <--\n\n`
359-
);
353+
this.env.log.rawmsg(await getIonicDevAppText());
360354

361355
const [ installer, ...installerArgs ] = await pkgManagerArgs({ npmClient, shell: this.env.shell }, { command: 'install' });
362356
await this.env.shell.run(installer, installerArgs, shellOptions);
@@ -368,14 +362,7 @@ ${chalk.cyan('[1]')}: ${chalk.bold('https://ionicframework.com/docs/cli/starters
368362
}
369363

370364
if (options['link'] && !linkConfirmed) {
371-
this.env.log.nl();
372-
this.env.log.rawmsg(
373-
` ${chalk.bold(`${emoji('🔥', '*')} IONIC PRO ${emoji('🔥', '*')}`)}\n\n` +
374-
` Supercharge your Ionic development with the ${chalk.bold('Ionic Pro')} SDK\n\n` +
375-
` - ${emoji('⚠️', '')} Track runtime errors in real-time, back to your original TypeScript\n` +
376-
` - ${emoji('📲', '')} Push remote updates and skip the app store queue\n\n` +
377-
` Learn more about Ionic Pro: ${chalk.bold('https://ionicframework.com/pro')}\n`
378-
);
365+
this.env.log.rawmsg(await getIonicProText());
379366

380367
const confirm = await this.env.prompt({
381368
type: 'confirm',
@@ -384,8 +371,6 @@ ${chalk.cyan('[1]')}: ${chalk.bold('https://ionicframework.com/docs/cli/starters
384371
noninteractiveValue: false,
385372
});
386373

387-
this.env.log.msg('\n-----------------------------------\n\n');
388-
389374
if (confirm) {
390375
linkConfirmed = true;
391376
}

types/boxen.d.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
declare module 'boxen' {
2+
function boxen(input: string, options?: boxen.BoxenOptions): string;
3+
4+
namespace boxen {
5+
interface TopRightBottomLeft {
6+
top?: number;
7+
right?: number;
8+
bottom?: number;
9+
left?: number;
10+
}
11+
12+
interface BoxenBorderStyle {
13+
topLeft: string;
14+
topRight: string;
15+
bottomLeft: string;
16+
bottomRight: string;
17+
horizontal: string;
18+
vertical: string;
19+
}
20+
21+
interface BoxenOptions {
22+
borderColor?: string;
23+
borderStyle?: 'single' | 'double' | 'round' | 'single-double' | 'double-single' | 'classic' | BoxenBorderStyle;
24+
dimBorder?: boolean;
25+
padding?: number | TopRightBottomLeft;
26+
margin?: number | TopRightBottomLeft;
27+
float?: 'right' | 'center' | 'left';
28+
backgroundColor?: 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white';
29+
align?: 'right' | 'center' | 'left';
30+
}
31+
}
32+
33+
export = boxen;
34+
}

types/widest-line.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module 'widest-line' {
2+
function widestLine(input: string): number;
3+
namespace widestLine {}
4+
export = widestLine;
5+
}

0 commit comments

Comments
 (0)