forked from knowbee/keza
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from knowbee/master
merging changes
- Loading branch information
Showing
22 changed files
with
350 additions
and
1,391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Igwaneza Bruce <[email protected]> | ||
Copyright (c) 2020 Igwaneza Bruce <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
[](https://github.com/ellerbrock/open-source-badge/) | ||
[](https://github.com/ellerbrock/open-source-badge/) | ||
|
||
Generate nodejs CI template files, Eslint config files, gitignore, docker and readme file from the command line when keza's CLI is installed globally | ||
Generate template files(babelrc, eslint, readme, etc...) from the command line | ||
|
||
## Install | ||
|
||
|
@@ -23,36 +23,62 @@ yarn global add keza | |
|
||
## Preview | ||
|
||
 | ||
<p> | ||
<img src="https://raw.githubusercontent.com/knowbee/hosting/master/assets/keza.PNG" width="400px" height="auto" hspace="10"/> | ||
</p> | ||
|
||
## Supported template files | ||
|
||
| Template file | ||
| ------------ |-- | ||
| ✔ .babelrc | | ||
| ✔ .travis.yml | | ||
| ✔ .dockerignore | | ||
| ✔ .eslintignore | | ||
| ✔ .eslintrc | | ||
| ✔ .hound.yml | | ||
| ✔ .sequerizerc | | ||
| ✔ Dockerfile | | ||
| ✔ Procfile | | ||
| ✔ README.md | | ||
| | ||
|
||
## Using Keza CLI | ||
|
||
#### Command Line | ||
|
||
```cli | ||
$ keza <options> | ||
$ keza | ||
``` | ||
|
||
## Options: | ||
|
||
- `-h` or `--help`: display helper screen. | ||
- `-b` or `--babel`: generate .babelrc. | ||
- `-d` or `--docker`: generate docker file. | ||
- `-e` or `--eslint`: generate .eslintrc and .eslintignore file. | ||
- `-g` or `--gitignore`: generate nodejs .gitignore. | ||
- `-ho` or `--hound`: generate hound yml file. | ||
- `-r` or `--readme`: generate readme file. | ||
- `-s` or `--sequelize`: generate .sequerizerc. | ||
- `-t` or `--travis`: generate travis yml file. | ||
- `--help`: display helper screen. | ||
|
||
## Contribution | ||
|
||
- Please before making a PR, read first this [Contributing Guideline](./CONTRIBUTING.md) | ||
Please before making a PR, read first this [Contributing Guideline](./CONTRIBUTING.md) | ||
|
||
## License | ||
|
||
MIT | ||
MIT License | ||
|
||
## Author | ||
Copyright (c) 2020 Igwaneza Bruce <[email protected]> | ||
|
||
Igwaneza Bruce | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,41 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require("fs"); | ||
const clear = require("clear"); | ||
const chalk = require("chalk"); | ||
const figlet = require("figlet"); | ||
const inquirer = require("inquirer"); | ||
const { templates, questions } = require("./lib/constants"); | ||
const { helper } = require("./lib/help"); | ||
const { generateTemplate } = require("./lib/generate"); | ||
const path = require("path"); | ||
const bar = require("cli-progress"); | ||
const cli = require("commander"); | ||
|
||
clear(); | ||
const keza = new cli.Command(); | ||
console.log(chalk.green(figlet.textSync("Keza", { horizontalLayout: "full" }))); | ||
const progress = new bar.SingleBar({ | ||
format: "Done |" + chalk.magenta("{bar}") + "| {percentage}%", | ||
barCompleteChar: "\u2588", | ||
hideCursor: true | ||
hideCursor: true, | ||
}); | ||
|
||
if (fs.existsSync("package.json")) { | ||
helper(); | ||
process.argv.slice(2).forEach(function(item) { | ||
if (item === "-b" || item === "--babel") { | ||
generate(__dirname + "/templates/" + ".babelrc", ".babelrc"); | ||
} else if (item === "-d" || item === "--docker") { | ||
generate(__dirname + "/templates/" + ".dockerignore", ".dockerignore"); | ||
generate(__dirname + "/templates/" + "Dockerfile", "Dockerfile"); | ||
} else if (item === "-e" || item === "--eslint") { | ||
generate(__dirname + "/templates/" + ".eslintrc", ".eslintrc"); | ||
generate(__dirname + "/templates/" + ".eslintignore", ".eslintignore"); | ||
} else if (item === "-g" || item === "--gitignore") { | ||
generate(__dirname + "/templates/" + "gitignore", ".gitignore"); | ||
} else if (item === "-ho" || item === "--hound") { | ||
generate(__dirname + "/templates/" + ".hound.yml", ".hound.yml"); | ||
} else if (item === "-r" || item === "--readme") { | ||
generate(__dirname + "/templates/" + "README.md", "README.md"); | ||
} else if (item === "-s" || item === "--sequelizerc") { | ||
generate(__dirname + "/templates/" + ".sequelizerc", ".sequelizerc"); | ||
} else if (item === "-t" || item === "--travis") { | ||
generate(__dirname + "/templates/" + ".travis.yml", ".travis.yml"); | ||
} | ||
}); | ||
if (process.argv.length == 2) { | ||
fs.readdir(__dirname + "/templates", function(err, filenames) { | ||
if (err) { | ||
return; | ||
} | ||
progress.start(filenames.length); | ||
filenames.forEach(file => { | ||
generate(__dirname + "/templates/" + file, file); | ||
progress.update(filenames.length); | ||
clear(); | ||
helper(); | ||
console.log( | ||
chalk.magenta(figlet.textSync("Keza", { horizontalLayout: "full" })) | ||
); | ||
console.log(chalk.green("generate template files very fast")); | ||
if (process.argv.length == 2) { | ||
inquirer.prompt(questions).then((answers) => { | ||
let choices = []; | ||
Object.keys(answers).forEach((a) => { | ||
Object.keys(templates).forEach((t) => { | ||
if (a === t && answers[a].length >= 1) { | ||
answers[a].map((file) => { | ||
choices = [...choices, templates[a][file]]; | ||
}); | ||
} | ||
}); | ||
progress.stop(); | ||
}); | ||
} | ||
function generate(from, to) { | ||
progress.start(to.length); | ||
fs.copyFile(from, to, err => { | ||
progress.update(100); | ||
if (err) throw err; | ||
progress.stop(); | ||
progress.start(choices.length); | ||
choices.forEach((choice) => { | ||
generateTemplate(choice, path.basename(choice)); | ||
}); | ||
} | ||
} else { | ||
helper(); | ||
console.log( | ||
chalk.magenta("You have to initialize your project with npm or yarn first") | ||
); | ||
|
||
process.exit(); | ||
} | ||
function helper() { | ||
keza | ||
.version("1.0.4") | ||
.option("-b, --babel", "generate babelrc") | ||
.option("-d, --docker", "generate docker file") | ||
.option("-e, --eslint", "generate eslintrc and eslintignore") | ||
.option("-g, --gitignore", "generate nodejs gitignore") | ||
.option("-ho, --hound", "generate hound file") | ||
.option("-r, --readme", "generate readme file") | ||
.option("-s, --sequelize", "generate sequerizerc") | ||
.option("-t, --travis", "generate travis") | ||
.parse(process.argv); | ||
keza.on("--help", function() { | ||
console.log("Examples:"); | ||
console.log(" $ keza --help"); | ||
console.log(" $ keza -h"); | ||
console.log(" $ keza -b -d -t"); | ||
progress.update(100); | ||
progress.stop(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const path = require("path") | ||
/** | ||
* only change this file if you want to add more template files | ||
*/ | ||
exports.templates = { | ||
ci: { | ||
travis: path.join(__dirname) + "\\templates\\.travis.yml", | ||
hound: path.join(__dirname) + "\\templates\\.hound.yml", | ||
}, | ||
docker: { | ||
dockerignore: path.join(__dirname) + "\\templates\\.dockerignore", | ||
dockerfile: path.join(__dirname) + "\\templates\\Dockerfile", | ||
}, | ||
lint: { | ||
eslintrc: path.join(__dirname) + "\\templates\\.eslintrc", | ||
eslintignore: path.join(__dirname) + "\\templates\\.eslintignore", | ||
}, | ||
babel: { | ||
babelrc: path.join(__dirname) + "\\templates\\.babelrc", | ||
}, | ||
database: { | ||
sequelizerc: path.join(__dirname) + "\\templates\\.sequelizerc", | ||
procfile:path.join(__dirname) + "\\templates\\Procfile" | ||
}, | ||
documentation: { | ||
readme: path.join(__dirname) + "\\templates\\README.md", | ||
} | ||
}; | ||
|
||
|
||
|
||
exports.questions = [ | ||
{ | ||
type: "checkbox", | ||
message: "CI\\CD", | ||
name: "ci", | ||
choices: ["travis", "hound"] | ||
}, | ||
{ | ||
type: "checkbox", | ||
message: "Dockerize", | ||
name: "docker", | ||
choices: ["dockerfile", "dockerignore"] | ||
}, | ||
{ | ||
type: "checkbox", | ||
message: "Linter", | ||
name: "lint", | ||
choices: ["eslintrc", "eslintignore"] | ||
}, | ||
{ | ||
type: "checkbox", | ||
message: "Database", | ||
name: "database", | ||
choices: ["sequelizerc", "procfile"] | ||
}, | ||
{ | ||
type: "checkbox", | ||
message: "Babel", | ||
name: "babel", | ||
choices: ["babelrc"] | ||
}, | ||
{ | ||
type: "checkbox", | ||
message: "Documentation", | ||
name: "documentation", | ||
choices: ["readme"] | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const fs = require("fs") | ||
const chalk = require("chalk"); | ||
exports.generateTemplate = (from, to) => { | ||
try { | ||
fs.copyFileSync(from, to); | ||
} catch (error) { | ||
console.log("\n"); | ||
console.log(chalk.yellow("oooh no! try again")); | ||
process.exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const cli = require("commander"); | ||
|
||
const keza = new cli.Command(); | ||
exports.helper = () => { | ||
keza | ||
.description("generate template files very fast") | ||
.version("1.0.9") | ||
.parse(process.argv); | ||
keza.on("--help", function () { | ||
console.log("Examples:"); | ||
console.log(" $ keza --help"); | ||
console.log(" $ keza -g"); | ||
}); | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by keza | ||
|
||
|
||
|
||
|
||
|
||
## Installation | ||
|
||
|
||
|
||
|
||
|
||
|
||
## Usage | ||
|
||
|
||
|
||
## Examples | ||
|
||
|
||
## Contribution | ||
|
||
|
||
|
||
## License |
Oops, something went wrong.