Skip to content

Commit

Permalink
feat(cli): improve the cli meesages
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Oct 30, 2016
1 parent 6b1e330 commit 8b258d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'path';
import fs from 'fs';
import ncp from 'ncp';
import exists from 'command-exists';
import chalk from 'chalk';

export default async function(options) {
if (typeof options.name !== 'string') {
Expand All @@ -15,7 +16,7 @@ export default async function(options) {
throw new Error(`A folder named '${options.name}' already exits!`);
}

console.log('Copying template files');
console.log('📃 Copying template files');

await new Promise((resolve, reject) => {
ncp.ncp(path.join(__dirname, '../template/'), dir, err => {
Expand All @@ -31,23 +32,22 @@ export default async function(options) {
}

try {
console.log('Installing `react` and `react-dom`');
console.log(`🍭 Installing ${chalk.bold('react')} and ${chalk.bold('react-dom')}`);

if (status) {
execSync('yarn add react react-dom', { cwd: dir });
} else {
execSync('npm install -S react react-dom', { cwd: dir });
}

console.log('Adding `quik` as a `devDependency`');
console.log(`💎 Adding ${chalk.bold('quik')} as a devDependency`);

if (status) {
execSync('yarn add --dev quik', { cwd: dir });
} else {
execSync('npm install -D quik', { cwd: dir });
}

console.log('All done! Run `npm start` to start the project.');
resolve();
} catch (e) {
reject(e);
Expand Down
11 changes: 9 additions & 2 deletions src/quik-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ if (argv.init) {
root: process.cwd(),
name: argv.init,
})
.then(() => {
console.log(
`⭐ All done!\n\n` +
` - Run ${chalk.bold(chalk.yellow('npm start'))} to start the server\n` +
` - Run ${chalk.bold(chalk.yellow('npm run build'))} to build production ready bundle\n`
);
})
.catch(err => {
console.log(err.message);
process.exit(1);
Expand All @@ -91,7 +98,7 @@ if (argv.init) {
bundles.push(path.resolve(process.cwd(), Array.isArray(entry) ? entry[0] : entry));
}

console.log(`Bundle${bundles.length > 1 ? 's' : ''} generated at ${bundles.map(b => chalk.green(b)).join(', ')}`);
console.log(`Bundle${bundles.length > 1 ? 's' : ''} generated at ${bundles.map(b => chalk.bold(chalk.green(b))).join(', ')}`);
})
.catch(err => {
console.error(err);
Expand All @@ -107,7 +114,7 @@ if (argv.init) {
sourcemaps: argv.sourcemaps,
})
.then(file => {
console.log(`Sharable HTML generated at ${chalk.green(file)}`);
console.log(`Sharable HTML generated at ${chalk.bold(chalk.green(file))}`);
})
.catch(err => {
console.error(err);
Expand Down

0 comments on commit 8b258d8

Please sign in to comment.