Comparing version 0.1.4 to 0.1.5
@@ -20,86 +20,3 @@ #!/usr/bin/env node | ||
const installPackages = () => { | ||
console.log(chalk.white.bold('Installing Packages')); | ||
return new Promise((resolve, reject) => { | ||
let command; | ||
let args = ['install']; | ||
if (shouldUseYarn()) { | ||
command = 'yarn'; | ||
} else { | ||
command = 'npm'; | ||
} | ||
const child = spawn(command, args, { stdio: 'inherit' }); | ||
child.on('close', code => { | ||
if (code !== 0) { | ||
reject({ | ||
command: `${command} ${args.join(' ')}` | ||
}); | ||
return; | ||
} | ||
resolve(); | ||
}) | ||
}) | ||
} | ||
export const initCreate = () => { | ||
cp('-r', __dirname + '/../src/.', './'); | ||
console.log('----------------------------------------------------------'); | ||
figlet('FireFunctionsCli', function(err, data) { | ||
if (err) { | ||
return; | ||
} | ||
console.log(data); | ||
console.log('----------------------------------------------------------'); | ||
console.log(chalk.white.bold('Welcome to FireFunctionsCli')); | ||
console.log('----------------------------------------------------------'); | ||
installPackages().then(() => { | ||
console.log(chalk.white.bold('Let\'s get started')); | ||
console.log(chalk.green('Step 1: cd into the newly created '), chalk.green.bold(appName), chalk.green(' directory')); | ||
console.log('----------------------------------------------------------'); | ||
console.log(chalk.green('Step 2: run '), chalk.green.bold('yarn run deploy')); | ||
console.log('----------------------------------------------------------'); | ||
// add your own custom messages here. | ||
console.log('----------------------------------------------------------'); | ||
}) | ||
.catch(error => { | ||
console.log(chalk.red('An unexpected error occurred')) | ||
console.log(chalk.red(error)); | ||
}); | ||
}); | ||
} | ||
export const create = (appName) => { | ||
cp('-r', __dirname + '/../src/.', appName); | ||
console.log('----------------------------------------------------------'); | ||
figlet('FireFunctionsCli', function(err, data) { | ||
if (err) { | ||
return; | ||
} | ||
console.log(data); | ||
console.log('----------------------------------------------------------'); | ||
console.log(chalk.white.bold('Welcome to FireFunctionsCli')); | ||
console.log('----------------------------------------------------------'); | ||
cd(appName); | ||
installPackages().then(() => { | ||
console.log(chalk.white.bold('Let\'s setup firebase')); | ||
execSync('firebase init', { stdio: 'inherit' }).then(() => { | ||
console.log(chalk.white.bold('Let\'s get started')); | ||
console.log(chalk.green('Step 1: cd into the newly created '), chalk.green.bold(appName), chalk.green(' directory')); | ||
console.log('----------------------------------------------------------'); | ||
console.log(chalk.green('Step 2: run '), chalk.green.bold('yarn run deploy')); | ||
console.log('----------------------------------------------------------'); | ||
// add your own custom messages here. | ||
console.log('----------------------------------------------------------'); | ||
}) | ||
}) | ||
.catch(error => { | ||
console.log(chalk.red('An unexpected error occurred')) | ||
console.log(chalk.red(error)); | ||
}); | ||
}); | ||
} | ||
export const build = (deployState = false ) => { | ||
const build = (deployState = false ) => { | ||
let command; | ||
@@ -122,12 +39,2 @@ if (shouldUseYarn()) { | ||
export const deploy = () => { | ||
try { | ||
execSync('firebase deploy --only functions', { stdio: 'inherit' }); | ||
return true; | ||
} catch (e) { | ||
console.log(chalk.red('An unexpected error occurred')) | ||
return false; | ||
} | ||
} | ||
// module.exports = [initCreate,create,build, deploy] | ||
module.exports = build; |
@@ -9,2 +9,4 @@ #!/usr/bin/env node | ||
const build = require('./build'); | ||
const deploy = require('./deploy'); | ||
const create = require('./create'); | ||
@@ -19,3 +21,3 @@ program | ||
case "init": | ||
spawn(build.initCreate(program.args[1]), { | ||
spawn(initCreate(program.args[1]), { | ||
shell: true, | ||
@@ -27,3 +29,3 @@ stdio: 'inherit' | ||
if (program.args.length == 2) { | ||
spawn(build.create(program.args[1]), { | ||
spawn(create(program.args[1]), { | ||
shell: true, | ||
@@ -38,3 +40,3 @@ stdio: 'inherit' | ||
if (program.args.length == 2) { | ||
spawn(build.create(program.args[1]), { | ||
spawn(create(program.args[1]), { | ||
shell: true, | ||
@@ -48,3 +50,3 @@ stdio: 'inherit' | ||
case "build": | ||
spawn(build.build(), { | ||
spawn(build(), { | ||
shell: true, | ||
@@ -55,7 +57,7 @@ stdio: 'inherit' | ||
case "deploy": | ||
spawn(build.build(), { | ||
spawn(build(), { | ||
shell: true, | ||
stdio: 'inherit' | ||
}); | ||
spawn(build.deploy(), { | ||
spawn(deploy(), { | ||
shell: true, | ||
@@ -62,0 +64,0 @@ stdio: 'inherit' |
{ | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"main": "index.js", | ||
@@ -4,0 +4,0 @@ "bin": "bin/cli.js", |
24612
19
489
4
4