kick-init
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -5,6 +5,9 @@ 'use strict'; | ||
const path = require('path'); | ||
const pj = ('./package.json'); | ||
const pj = require('./package.json'); | ||
//configuration path | ||
const configPath = path.join((process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE), '/.kickconfig.json'); | ||
const configPath = path.join( | ||
(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE), | ||
'/.kickconfig.json' | ||
); | ||
@@ -36,5 +39,6 @@ //check for config file. Use default if none found | ||
-h, --help print help menu | ||
-l, --list list starter repo options | ||
-l, --list print starter repo options | ||
-r, --remote create a remote repo for this project | ||
-v, --version get current version of kick-init package | ||
-v, --version print current version of kick-init package | ||
-V, --verbose print out each command being executed | ||
@@ -54,5 +58,6 @@ [repo] specify the repo to clone, defaults to first one | ||
let info = { | ||
clone: repoList.repos.a, | ||
clone: repoList.repos[Object.keys(repoList.repos)[0]], | ||
local: process.cwd(), | ||
remote: false | ||
remote: false, | ||
verbose: false | ||
}; | ||
@@ -73,2 +78,4 @@ | ||
switch (arg) { | ||
//Log kick-init version | ||
case '-v': | ||
@@ -78,2 +85,4 @@ console.log(pj.version); | ||
break; | ||
//Log kick-init version | ||
case '--version': | ||
@@ -83,2 +92,14 @@ console.log(pj.version); | ||
break; | ||
//print out each command being run | ||
case '-V': | ||
info.verbose = true; | ||
break; | ||
//print out each command being run | ||
case '--verbose': | ||
info.verbose = true; | ||
break; | ||
//Log out repo list | ||
case '-l': | ||
@@ -88,2 +109,4 @@ console.log(repos); | ||
break; | ||
//Log out repo list | ||
case '--list': | ||
@@ -93,8 +116,14 @@ console.log(repos); | ||
break; | ||
//user set repo to clone. Expected as next argument | ||
case '-c': | ||
info.clone = args[i + 1]; | ||
break; | ||
//user set repo to clone. Expected as next argument | ||
case '--clone': | ||
info.clone = args[1]; | ||
info.clone = args[i + 1]; | ||
break; | ||
//Log the help menu | ||
case '-h': | ||
@@ -104,2 +133,4 @@ console.log(help); | ||
break; | ||
//Log the help menu | ||
case '--help': | ||
@@ -109,5 +140,9 @@ console.log(help); | ||
break; | ||
//user called for remote repository to be created | ||
case '-r': | ||
info.remote = true; | ||
break; | ||
//user called for remote repository to be created | ||
case '--remote': | ||
@@ -117,6 +152,15 @@ info.remote = true; | ||
default: | ||
//check if argument exist in config file | ||
if (repoList.repos[arg]) { | ||
//since it does set it to be cloned | ||
info.clone = repoList.repos[arg]; | ||
} | ||
//check if file path or url | ||
else if (!arg.includes('://')) { | ||
//if you made it to here you should be | ||
//a file path or url and you are not | ||
console.log(`ERROR: ${arg} is not valid argument.`); | ||
@@ -127,3 +171,3 @@ throw new Error; | ||
}); | ||
console.log(info); | ||
return info; | ||
@@ -130,0 +174,0 @@ }; |
#!/usr/bin/env node | ||
'use strict'; | ||
console.log("keyyyyaaaaaa!!"); | ||
const kickInit = require('.'); | ||
kickInit(process.argv.slice(2)); |
26
git.js
@@ -11,21 +11,19 @@ 'use strict'; | ||
//path to config file | ||
const configPath = path.join((process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE), '/.kickconfig.json'); | ||
const configPath = path.join( | ||
(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE), | ||
'/.kickconfig.json' | ||
); | ||
module.exports = (info) => { | ||
let github = null; | ||
let args = [bin, info.clone, info.local, info.remote, info.verbose]; | ||
//pull token out of json object | ||
if (fs.existsSync(configPath)) { | ||
const token = JSON.parse(fs.readFileSync(configPath)); | ||
if (info.remote && fs.existsSync(configPath) && (github = require(configPath).github)) { | ||
args.push(github.token, github.username); | ||
} | ||
//spin up child process to run gitbash script | ||
const child = spawn(`sh`, [bin, info.clone, info.local, info.remote, token.github.token, token.github.username], {stdio:'inherit'}).on('close', () => { | ||
console.log('all done!!'); | ||
}); | ||
} else { | ||
//spin up child process to run gitbash script | ||
const child = spawn(`sh`, args, {stdio:'inherit'}).on('close', () => console.log('All done!!')); | ||
//spin up child process to run gitbash script | ||
const child = spawn(`sh`, [bin, info.clone, info.local, info.remote], {stdio:'inherit'}).on('close', () => { | ||
console.log('all done!!'); | ||
}); | ||
} | ||
}; |
{ | ||
"name": "kick-init", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "cli tool for getting your new project a kick start!", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -28,2 +28,3 @@ | ||
- push up all files to new remote repo (with `-r` flag) | ||
- make you a better person (Beta) | ||
@@ -51,7 +52,8 @@ | ||
Options: | ||
-c, --clone specify a repo URL to clone | ||
-c, --clone specify a random repo to clone | ||
-h, --help print help menu | ||
-l, --list list starter repo options | ||
-l, --list print starter repo options | ||
-r, --remote create a remote repo for this project | ||
-v, --version get current version of kick-init package | ||
-v, --version print current version of kick-init package | ||
-V, --verbose print out each command being executed | ||
@@ -62,11 +64,14 @@ [repo] specify the repo to clone, defaults to first in list | ||
Examples | ||
$ kick | ||
will run kick-init with first repo listed in config and no remote repo | ||
$ kick -r | ||
project a with remote repo | ||
will run kick-init with first repo listed in config with remote repo | ||
$ kick b | ||
project b with no remote repo | ||
will run kick-init with b and no remote | ||
$ kick -c https://github.com/davidicus/myboilerplate.git | ||
will run kick-init with the myboilerplate repo | ||
will run kick-init with the myboilerplate repo and no remote | ||
``` | ||
##Config | ||
@@ -80,2 +85,4 @@ | ||
//a, b, z below can be named anything you want to identify the repo | ||
{ | ||
@@ -96,5 +103,8 @@ "repos": { | ||
##Coming Soon! | ||
- Support for github enterprise | ||
## License | ||
MIT © [David Conner](http://david-conner.com) |
Sorry, the diff of this file is not supported yet
12182
170
106
12