#! /usr/bin/env node const { resolve } = require('path'); const Listr = require('listr'); const execa = require('execa'); const ora = require('ora'); const symbols = require('log-symbols'); const mkdirp = require('mkdirp-promise'); const meow = require('meow'); const cli = meow(` Usage: $ booted Options: --version, -v Print package version Examples: booted Boots new project in current directory booted /my/path/to/folder Creates directory at provided path and boots project in it `, { alias: { v: 'version', }, }); const spinner = ora(); const dir = resolve('.', cli.input[0] || '.'); const tasks = new Listr([{ title: 'Copying code...', task: () => mkdirp(dir) .then(() => execa('cp', ['-a', `${resolve(__dirname, '../source/')}/.`, dir])), }, { title: 'Initiating Git repository...', task: () => execa('git', ['init'], { cwd: dir }), }, { title: 'Installing packages with Yarn...', task: () => execa('yarn', { cwd: dir }) .then(() => execa('yarn', ['add', 'husky', '--dev'], { cwd: dir })), }]); tasks.run() .then(() => { spinner.text = 'Booted.'; spinner.stopAndPersist(` ${symbols.success}`); }) .catch(err => { spinner.text = err && err.message || 'Got error.'; spinner.stopAndPersist(` ${symbols.error}`); });