Comparing version 0.1.1 to 0.1.2
@@ -45,4 +45,4 @@ #!/usr/bin/env node | ||
const build = (appName) => { | ||
cp('-r', __dirname + '/../src/.', appName); | ||
const initCreate = () => { | ||
cp('-r', __dirname + '/../src/.', './'); | ||
console.log('----------------------------------------------------------'); | ||
@@ -57,6 +57,5 @@ figlet('FireFunctionsCli', function(err, data) { | ||
console.log('----------------------------------------------------------'); | ||
cd(appName); | ||
installPackages().then(() => { | ||
console.log(chalk.white.bold('Let\'s get started')); | ||
console.log(chalk.green('Step 1: cd into the newly created ' + appName + ' directory')); | ||
console.log(chalk.green('Step 1: cd into the newly created '), chalk.green.bold(appName), chalk.green(' directory')); | ||
console.log('----------------------------------------------------------'); | ||
@@ -75,2 +74,64 @@ console.log(chalk.green('Step 2: run '), chalk.green.bold('yarn run deploy')); | ||
module.exports = build; | ||
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)); | ||
}); | ||
}); | ||
} | ||
const build = (deployState = false ) => { | ||
let command; | ||
if (shouldUseYarn()) { | ||
command = 'yarn'; | ||
} else { | ||
command = 'npm'; | ||
} | ||
try { | ||
execSync('cp -r ./package.json ./functions/ && tsc && cd functions && ' + command, { stdio: 'ignore' }); | ||
console.log(chalk.green('Build Successful!')); | ||
return true; | ||
} catch (e) { | ||
console.log(chalk.red('An unexpected error occurred')) | ||
return false; | ||
} | ||
} | ||
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; | ||
module.exports = create; | ||
module.exports = build; | ||
module.exports = deploy; |
@@ -17,5 +17,11 @@ #!/usr/bin/env node | ||
switch (program.args[0]) { | ||
case "init": | ||
spawn(initCreate(program.args[1]), { | ||
shell: true, | ||
stdio: 'inherit' | ||
}); | ||
break; | ||
case "new": | ||
if (program.args.length == 2) { | ||
spawn(build(program.args[1]), { | ||
spawn(create(program.args[1]), { | ||
shell: true, | ||
@@ -30,3 +36,3 @@ stdio: 'inherit' | ||
if (program.args.length == 2) { | ||
spawn(build(program.args[1]), { | ||
spawn(create(program.args[1]), { | ||
shell: true, | ||
@@ -39,2 +45,18 @@ stdio: 'inherit' | ||
break; | ||
case "build": | ||
spawn(build(), { | ||
shell: true, | ||
stdio: 'inherit' | ||
}); | ||
break; | ||
case "deploy": | ||
spawn(build(), { | ||
shell: true, | ||
stdio: 'inherit' | ||
}); | ||
spawn(deploy(), { | ||
shell: true, | ||
stdio: 'inherit' | ||
}); | ||
break; | ||
case "v": | ||
@@ -41,0 +63,0 @@ console.log(chalk.green(package.version)); |
{ | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"main": "index.js", | ||
@@ -4,0 +4,0 @@ "bin": "bin/cli.js", |
23718
457