Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the standard linter #7

Merged
merged 1 commit into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions bin/create-probot-app.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/usr/bin/env node

'use strict';
'use strict'

const path = require('path');
const inquirer = require('inquirer');
const program = require('commander');
const {scaffold} = require('egad');
const kebabCase = require('lodash.kebabcase');
const chalk = require('chalk');
const spawn = require('cross-spawn');
const stringifyAuthor = require('stringify-author');
const {guessEmail, guessAuthor, guessGitHubUsername} = require('conjecture');
const path = require('path')
const inquirer = require('inquirer')
const program = require('commander')
const {scaffold} = require('egad')
const kebabCase = require('lodash.kebabcase')
const chalk = require('chalk')
const spawn = require('cross-spawn')
const stringifyAuthor = require('stringify-author')
const {guessEmail, guessAuthor, guessGitHubUsername} = require('conjecture')

const TEMPLATE_REPO_URL = 'https://github.com/probot/template.git';
const TEMPLATE_REPO_URL = 'https://github.com/probot/template.git'

program
.usage('[options] [destination]')
Expand All @@ -28,45 +28,45 @@ program
.option('--overwrite', 'Overwrite existing files', false)
.option('--template <template-url>', 'URL of custom template',
TEMPLATE_REPO_URL)
.parse(process.argv);
.parse(process.argv)

const destination = program.args.length ?
path.resolve(process.cwd(), program.args.shift()) :
process.cwd();
const destination = program.args.length
? path.resolve(process.cwd(), program.args.shift())
: process.cwd()

const prompts = [
{
type: 'input',
name: 'name',
default(answers) {
return answers.repo || kebabCase(path.basename(destination));
default (answers) {
return answers.repo || kebabCase(path.basename(destination))
},
message: 'Package name:',
when: !program.pkgname
},
{
type: 'input',
name: 'desc',
default() {
return 'A Probot app';
default () {
return 'A Probot app'
},
message: 'Description of app:',
when: !program.desc
},
{
type: 'input',
name: 'author',
default() {
return guessAuthor();
default () {
return guessAuthor()
},
message: 'Author\'s full name:',
when: !program.author
},
{
type: 'input',
name: 'email',
default() {
return guessEmail();
default () {
return guessEmail()
},
message: 'Author\'s email address:',
when: !program.email
Expand All @@ -80,51 +80,51 @@ const prompts = [
{
type: 'input',
name: 'owner',
default(answers) {
return guessGitHubUsername(answers.email);
default (answers) {
return guessGitHubUsername(answers.email)
},
message: 'GitHub user or org name:',
when: !program.user
},
{
type: 'input',
name: 'repo',
default(answers) {
return answers.pkgname || kebabCase(path.basename(destination));
default (answers) {
return answers.pkgname || kebabCase(path.basename(destination))
},
message: 'Repository name:',
when: !program.repo
}
];
]

console.log(chalk.blue('Let\'s create a Probot app!'));
console.log(chalk.blue('Let\'s create a Probot app!'))

inquirer.prompt(prompts)
.then(answers => {
answers.author = stringifyAuthor({
name: answers.author,
email: answers.email,
url: answers.homepage
});
})
return scaffold(program.template, destination, answers, {
overwrite: Boolean(program.overwrite)
});
})
})
.then(results => {
results.forEach(fileinfo => {
console.log(`${fileinfo.skipped ? chalk.yellow('skipped existing file') :
chalk.green('created file')}: ${fileinfo.path}`);
});
return console.log(chalk.blue('Finished scaffolding files!'));
console.log(`${fileinfo.skipped ? chalk.yellow('skipped existing file')
: chalk.green('created file')}: ${fileinfo.path}`)
})
return console.log(chalk.blue('Finished scaffolding files!'))
})
.then(() => {
console.log(chalk.blue('\nInstalling Node dependencies!'));
const child = spawn('npm', ['install', '--prefix', destination], {stdio: 'inherit'});
console.log(chalk.blue('\nInstalling Node dependencies!'))
const child = spawn('npm', ['install', '--prefix', destination], {stdio: 'inherit'})
child.on('close', code => {
if (code !== 0) {
console.log(chalk.red(`Could not install npm dependencies. Try running ${chalk.bold('npm install')} yourself.`));
return;
console.log(chalk.red(`Could not install npm dependencies. Try running ${chalk.bold('npm install')} yourself.`))
return
}
console.log(chalk.blue('\nDone! Enjoy building your Probot app!'));
});
});
console.log(chalk.blue('\nDone! Enjoy building your Probot app!'))
})
})
Loading