Skip to content

Commit

Permalink
Merge pull request #21 from jaebradley/better-messaging
Browse files Browse the repository at this point in the history
Better messaging
  • Loading branch information
jaebradley authored Apr 25, 2018
2 parents f6cca26 + 885539d commit e3cfad9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"dependencies": {
"@babel/runtime": "^7.0.0-beta.42",
"@octokit/rest": "^15.2.6",
"chalk": "^2.4.0",
"child-process-promise": "^2.2.1",
"commander": "^2.15.1",
"deepmerge": "^2.1.0",
Expand Down
27 changes: 21 additions & 6 deletions src/executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { spawn } from 'child-process-promise';
import normalizePackageData from 'normalize-package-data';
import sortPackageJSON from 'sort-package-json';
import isOnline from 'is-online';
import chalk from 'chalk';

import {
PACKAGE_TYPES,
Expand All @@ -23,7 +24,7 @@ const executor = async () => {
const online = await isOnline();

if (!online) {
console.log("📡 You don't seem to be online 😞");
console.log(chalk.bold.redBright("⛔ 📡 You don't seem to be online"));
return;
}

Expand Down Expand Up @@ -92,16 +93,30 @@ const executor = async () => {
normalizePackageData(packageJSON);
fse.writeJsonSync(packageJSONLocation, sortPackageJSON(packageJSON), 'utf8');

console.log('⌛ 🤞 Installing packages');
console.log(chalk.bold.cyanBright('⌛ 🤞 Installing packages'));
await spawn('npm', ['install'], { cwd: destinationDirectory, stdio: 'inherit' });
await spawn('git', ['init'], { cwd: destinationDirectory, stdio: 'inherit' });

console.log('🥝 🍋 🍐 🍓 🍊 🍍 🍰 Installation complete! 🍒 🍈 🍇 🍉 🍏 🍎 🍌');
console.log('🔥 "npm run test" runs the jest tests');
console.log('🏗️ "npm run build" will build your modules');
console.log(chalk.bold.magentaBright('🥝 🍋 🍐 🍓 🍊 🍍 🍰 Installation complete! 🍒 🍈 🍇 🍉 🍏 🍎 🍌'));
console.log();

console.log(`🎭 ${chalk.bold.magentaBright('Run')} ${chalk.bold.blueBright('jest')} ${chalk.bold.magentaBright('tests')}: ${chalk.bold.cyanBright('npm run test')} `);
console.log(`🏗️ ${chalk.bold.magentaBright('Build')} ${chalk.bold.blueBright('rollup.js')} ${chalk.bold.magentaBright('library')}: ${chalk.bold.cyanBright('npm run build')}`);
console.log(`👕 ${chalk.bold.magentaBright('Run')} ${chalk.bold.blueBright('eslint')}: ${chalk.bold.cyanBright('npm run lint')}`);

if (isReact) {
console.log('📖 "npm run storybook" starts Storybook!');
console.log(`📖 ${chalk.bold.magentaBright('Run')} ${chalk.bold.blueBright('Storybook')}: ${chalk.bold.cyanBright('npm run storybook')}`);
}

console.log();
console.log(chalk.bold.yellowBright("⚠️ Don't forget to... ⚠️"));
console.log(chalk.bold.cyanBright('✅ Add a license'));
console.log(chalk.bold.cyanBright('✅ Add keywords to package.json'));
console.log(chalk.bold.cyanBright('✅ Create GitHub repository'));
console.log(chalk.bold.cyanBright('✅ Setup Travis CI for repository'));

if (isSemanticRelease) {
console.log(chalk.bold.cyanBright('✅ Execute semantic-release-cli setup command'));
}
};

Expand Down
25 changes: 13 additions & 12 deletions src/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import inquirer from 'inquirer';
import emailValidator from 'email-validator';
import validateNpmPackageName from 'validate-npm-package-name';
import isSemver from 'is-semver';
import chalk from 'chalk';

import isGitHubUsernameValid from './isGitHubUsernameValid';
import {
Expand All @@ -13,7 +14,7 @@ const prompts = async () => (
inquirer.prompt([
{
name: 'packageType',
message: 'Select a package type',
message: chalk.bold.magentaBright('📦 Select a package type'),
type: 'list',
choices: [
PACKAGE_TYPES.NODE,
Expand All @@ -22,7 +23,7 @@ const prompts = async () => (
},
{
name: 'packageFeatures',
message: 'Select package Features',
message: chalk.bold.cyanBright('✅ Select package features'),
type: 'checkbox',
choices: [
PACKAGE_FEATURES.COMMITLINT,
Expand All @@ -31,44 +32,44 @@ const prompts = async () => (
},
{
name: 'packageName',
message: 'Input a package name',
message: chalk.bold.greenBright('📛 Input a package name'),
type: 'input',
validate: packageName => validateNpmPackageName(packageName).validForNewPackages || `${packageName} is an invalid package name`,
validate: packageName => validateNpmPackageName(packageName).validForNewPackages || chalk.bold.redBright(`😞 ${packageName} is an invalid package name`),
},
{
name: 'packageDescription',
message: 'Input a package description',
message: chalk.bold.redBright('🏷️ Input a package description'),
type: 'input',
validate: answer => answer && answer.length > 0,
},
{
name: 'packageVersion',
message: 'Input an initial package version',
message: chalk.bold.yellowBright('🌱 Input an initial package version'),
type: 'input',
validate: answer => isSemver(answer) || `${answer} is an invalid package version`,
validate: answer => isSemver(answer) || chalk.bold.redBright(`😞 ${answer} is an invalid package version`),
},
{
name: 'targetDirectory',
message: 'Input the relative package location',
message: chalk.bold.magentaBright('📍 Input the relative package location'),
type: 'input',
validate: answer => answer && answer.length > 0,
},
{
name: 'authorEmailAddress',
message: 'Input your email address',
message: chalk.bold.cyanBright('📥 Input your email address'),
type: 'input',
validate: emailAddress => emailValidator.validate(emailAddress) || `${emailAddress} is an invalid email address`,
validate: emailAddress => emailValidator.validate(emailAddress) || chalk.bold.redBright(`😞 ${emailAddress} is an invalid email address`),
},
{
name: 'gitHubUsername',
message: 'Input your GitHub username',
message: chalk.bold.greenBright('👤 Input your GitHub username'),
type: 'input',
validate: async (username) => {
if (await isGitHubUsernameValid(username)) {
return true;
}

return `${username} is an invalid GitHub username`;
return chalk.bold.redBright(`😞 ${username} is an invalid GitHub username`);
},
},
])
Expand Down

0 comments on commit e3cfad9

Please sign in to comment.