Socket
Socket
Sign inDemoInstall

kick-init

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.2.1

__test__/argsParser.test.js

126

argsParser.js

@@ -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
};

@@ -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!!")
);
};

@@ -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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc