kick-init
Advanced tools
Comparing version 1.1.0 to 1.2.1
@@ -1,23 +0,28 @@ | ||
'use strict'; | ||
"use strict"; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const pj = require('./package.json'); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const pj = require("./package.json"); | ||
//configuration path | ||
const configPath = path.join( | ||
(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE), | ||
'/.kickconfig.json' | ||
process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE, | ||
"/.kickconfig.json" | ||
); | ||
//check for config file. Use default if none found | ||
const repoList = (fs.existsSync(configPath)) ? require(configPath) : require('./repoInfo.json'); | ||
const repoList = fs.existsSync(configPath) | ||
? require(configPath) | ||
: require("./repoInfo.json"); | ||
//check package version | ||
const version = require("./package.json").version; | ||
const version = pj.version; | ||
//get repo urls with property name | ||
const rawRepos = Object.keys(repoList.repos).map(repo => { | ||
return `${repo}. ${repoList.repos[repo]}`; | ||
}).toString().replace(/,/g, "\n "); | ||
const rawRepos = Object.keys(repoList.repos) | ||
.map(repo => { | ||
return `${repo}. ${repoList.repos[repo]}`; | ||
}) | ||
.toString() | ||
.replace(/,/g, "\n "); | ||
@@ -28,3 +33,3 @@ //output for list flag | ||
${rawRepos} | ||
` | ||
`; | ||
@@ -51,9 +56,6 @@ //output for help flag | ||
//regex checking for "-r" | ||
const regex = /^-r/g; | ||
const argsParser = (args) => { | ||
const argsParser = args => { | ||
//define the default info object | ||
let info = { | ||
configPath, | ||
clone: repoList.repos[Object.keys(repoList.repos)[0]], | ||
@@ -76,61 +78,47 @@ local: process.cwd(), | ||
args.map((arg, i) => { | ||
// if argument is passed serve up appropriate object | ||
switch (arg) { | ||
//use enterprise instance | ||
case '-e': | ||
case "-e": | ||
case "--enterprise": | ||
info.enterprise = true; | ||
break; | ||
//use enterprise instance | ||
case '--enterprise': | ||
info.enterprise = true; | ||
break; | ||
//Log kick-init version | ||
case '-v': | ||
console.log(pj.version); | ||
case "-v": | ||
case "--version": | ||
console.log("\x1b[1m\x1b[37m%s\x1b[0m", version); | ||
info = null; | ||
break; | ||
//Log kick-init version | ||
case '--version': | ||
console.log(pj.version); | ||
info = null; | ||
break; | ||
//print out each command being run | ||
case '-V': | ||
case "-V": | ||
case "--verbose": | ||
info.verbose = true; | ||
break; | ||
//print out each command being run | ||
case '--verbose': | ||
info.verbose = true; | ||
break; | ||
//Log out repo list | ||
case '-l': | ||
console.log(repos); | ||
case "-l": | ||
case "--list": | ||
console.log("\x1b[1m\x1b[37m%s\x1b[0m", repos); | ||
info = null; | ||
break; | ||
//Log out repo list | ||
case '--list': | ||
console.log(repos); | ||
info = null; | ||
break; | ||
//user set repo to clone. Expected as next argument | ||
case '-c': | ||
info.clone = args[i + 1]; | ||
case "-c": | ||
case "--clone": | ||
if (typeof args[i + 1] == "string" && args[i + 1].includes(".git")) { | ||
info.clone = args[i + 1]; | ||
} else { | ||
console.error( | ||
"\x1b[31m%s\x1b[0m", | ||
`ERROR: ${args[i + 1]} is not valid argument following ${arg}.` | ||
); | ||
throw new Error(); | ||
} | ||
break; | ||
//user set repo to clone. Expected as next argument | ||
case '--clone': | ||
info.clone = args[i + 1]; | ||
break; | ||
//Log the help menu | ||
case '-h': | ||
case "-h": | ||
case "--help": | ||
console.log(help); | ||
@@ -140,22 +128,11 @@ info = null; | ||
//Log the help menu | ||
case '--help': | ||
console.log(help); | ||
info = null; | ||
break; | ||
//user called for remote repository to be created | ||
case '-r': | ||
case "-r": | ||
case "--remote": | ||
info.remote = true; | ||
break; | ||
//user called for remote repository to be created | ||
case '--remote': | ||
info.remote = true; | ||
break; | ||
default: | ||
//check if argument exist in config file | ||
if (repoList.repos[arg]) { | ||
//since it does set it to be cloned | ||
@@ -166,8 +143,10 @@ info.clone = repoList.repos[arg]; | ||
//check if file path or url | ||
else if (!arg.includes('://')) { | ||
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.`); | ||
throw new Error; | ||
console.error( | ||
"\x1b[31m%s\x1b[0m", | ||
`ERROR: ${arg} is not valid argument.` | ||
); | ||
throw new Error(); | ||
} | ||
@@ -180,2 +159,5 @@ } | ||
module.exports = argsParser; | ||
module.exports = { | ||
argsParser, | ||
repoList | ||
}; |
38
git.js
@@ -1,23 +0,26 @@ | ||
'use strict'; | ||
"use strict"; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { spawn } = require('child_process'); | ||
const fs = require("fs"); | ||
const { spawn } = require("child_process"); | ||
//path to gitbash script | ||
const bin = (__filename).replace(/git.js/i, 'gitbash.sh'); | ||
const bin = __filename.replace(/git.js/i, "gitbash.sh"); | ||
//path to config file | ||
const configPath = path.join( | ||
(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE), | ||
'/.kickconfig.json' | ||
); | ||
module.exports = (info) => { | ||
module.exports = info => { | ||
let github = null; | ||
let args = [bin, info.clone, info.local, info.remote, info.verbose, info.enterprise]; | ||
let args = [ | ||
bin, | ||
info.clone, | ||
info.local, | ||
info.remote, | ||
info.verbose, | ||
info.enterprise | ||
]; | ||
//check if remote and if so if github property is present | ||
if (info.remote && fs.existsSync(configPath) && (github = require(configPath).github)) { | ||
if ( | ||
info.remote && | ||
fs.existsSync(info.configPath) && | ||
(github = require(info.configPath).github) | ||
) { | ||
if (info.enterprise) { | ||
@@ -31,4 +34,5 @@ args.push(github.ent_token, github.ent_username, github.ent_hostname); | ||
//spin up child process to run gitbash script | ||
const child = spawn(`sh`, args, {stdio:'inherit'}).on('close', () => console.log('All done!!')); | ||
spawn(`sh`, args, { stdio: "inherit" }).on("close", () => | ||
console.log("All done!!") | ||
); | ||
}; |
16
index.js
@@ -1,16 +0,12 @@ | ||
'use strict'; | ||
"use strict"; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const argsParser = require("./argsParser").argsParser; | ||
const git = require("./git"); | ||
const argsParser = require('./argsParser'); | ||
const git = require('./git'); | ||
module.exports = (args) => { | ||
module.exports = args => { | ||
//parse arguments and pass to git.js | ||
let info = argsParser(args); | ||
if (info) { | ||
git(info); | ||
} | ||
git(info); | ||
} | ||
}; |
{ | ||
"name": "kick-init", | ||
"version": "1.1.0", | ||
"version": "1.2.1", | ||
"description": "cli tool for getting your new project a kick start!", | ||
"license": "MIT", | ||
"repository": "davidicus/kick-init.git", | ||
"keywords": [ | ||
"boilerplate", | ||
"project-starter", | ||
"project-generator", | ||
"generator" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/davidicus/kick-init/issues" | ||
}, | ||
"homepage": "https://github.com/davidicus/kick-init#readme", | ||
"author": "David Conner <david@david-conner.com> (http://david-conner.com)", | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"main": "index.js", | ||
"repository": "https://github.com/davidicus/kick-init.git", | ||
"author": { | ||
"name": "David Conner", | ||
"email": "david@david-conner.com", | ||
"url": "https://github.com/davidicus/" | ||
"scripts": { | ||
"test": "jest --silent" | ||
}, | ||
@@ -15,6 +28,6 @@ "bin": { | ||
}, | ||
"engines": { | ||
"node": ">=7" | ||
}, | ||
"license": "MIT" | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"jest": "^23.6.0" | ||
} | ||
} |
@@ -1,17 +0,15 @@ | ||
<div align="center"> | ||
![chuck](https://s3-us-west-2.amazonaws.com/s.cdpn.io/65463/chuck.png) ![chuck](https://s3-us-west-2.amazonaws.com/s.cdpn.io/65463/chuck.png) | ||
![chuck](https://s3-us-west-2.amazonaws.com/s.cdpn.io/65463/chuck.png) ![chuck](https://s3-us-west-2.amazonaws.com/s.cdpn.io/65463/chuck.png) | ||
</div> | ||
# kick-init | ||
# kick-init [![Build Status](https://travis-ci.org/davidicus/kick-init.svg?branch=master)](https://travis-ci.org/davidicus/kick-init) [![npm](https://img.shields.io/npm/dt/kick-init.svg)]() | ||
> Give your new project a kick! | ||
Drastically reduce the time it take to spin up a new project. Even with a starter boilerplate the time you spend setting it up for a new project can add up. With kick-init a single command will have your starter project up and running in a matter of minutes. | ||
*When used to full potential kick-init will:* | ||
_When used to full potential kick-init will:_ | ||
- clone starter repo into current directory | ||
@@ -28,3 +26,2 @@ - delete old .git history | ||
## Install | ||
@@ -36,3 +33,2 @@ | ||
## CLI | ||
@@ -43,3 +39,2 @@ | ||
``` | ||
$ kick --help | ||
@@ -53,2 +48,3 @@ | ||
-c, --clone specify a random repo to clone | ||
-e, --enterprise use enterprise github instance | ||
-h, --help print help menu | ||
@@ -72,6 +68,5 @@ -l, --list print starter repo options | ||
will run kick-init with the myboilerplate repo and no remote | ||
``` | ||
##Config | ||
## Config | ||
@@ -82,6 +77,5 @@ In order to get the full benefits of kick-init add a .kickconfig.json file to your root directory. Without the config file you will not be able to create a remote repo but can still start a local project. | ||
Check out how to get a personal access token [here](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). Now, get ta kickin! | ||
Check out how to get a personal access token [here](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/). Now, get ta kickin! | ||
``` | ||
//.kickconfig.json | ||
@@ -105,9 +99,6 @@ | ||
} | ||
``` | ||
## License | ||
MIT © [David Conner](http://david-conner.com) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
17903
11
284
1
0
11
1
98
2