Skip to content

Commit

Permalink
Merge pull request #13 from saucecodee/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
saucecodee authored Nov 16, 2020
2 parents cef0241 + 93315a3 commit 70da350
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 17 deletions.
4 changes: 3 additions & 1 deletion lib/cmd/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const help = {}

help.default =
`
Build ExpressJS applications with speed and efficiency with BangaJS
Build ExpressJS applications with speed and efficiency with BàngáJS
Usage:
Expand Down Expand Up @@ -71,6 +71,8 @@ Usage:
Options:
--force\t\tReplace file if it already exists
--no-auth\t\tDo not include User and authentication files
--no-dep\t\tDo not install packges
--no-git\t\tDo not initialize git
`


Expand Down
24 changes: 15 additions & 9 deletions lib/cmd/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const projectFiles = [
{ path: ".env", template: ".env", options: [] },
{ path: ".gitignore", template: ".gitignore", options: [] },
{ path: "package.json", template: ".package", options: [] },
{ path: "README.md", template: ".readme", options: [] },
{ path: "server.js", template: ".server", options: [] },

{ path: "src/config/env/dev.env.json", template: "config-env-dev", options: [] },
Expand Down Expand Up @@ -43,9 +44,10 @@ const projectFiles = [
{ path: "src/utils/multer.js", template: "uti-multer", options: [] },
{ path: "src/utils/response.js", template: "uti-response", options: [] },

{ path: "src/validators/", template: null, options: [] },

{ path: "public/", template: null, options: [] },
{ path: "uploads/", template: null, options: [] },
{ path: "views/", template: null, options: [] },
]

function runCommand(command = "banga", args = []) {
Expand Down Expand Up @@ -90,15 +92,19 @@ module.exports = async () => {
}
console.log(chalk.cyan("Created project files ✅"))

// Run npm install
console.log(chalk.bold("\nInstalling packages..."))
runCommand("npm", ["install"])
console.log(chalk.cyan("Packages installed ✅"))
if(ARGS.dep){
// Run npm install
console.log(chalk.bold("\nInstalling packages..."))
runCommand("npm", ["install"])
console.log(chalk.cyan("Packages installed ✅"))
}

// Initialize Git
console.log(chalk.bold("\nInitialising git..."))
runCommand("git", ["init"])
console.log(chalk.cyan("Git initialised ✅"))
if(ARGS.git){
// Initialize Git
console.log(chalk.bold("\nInitialising git..."))
runCommand("git", ["init"])
console.log(chalk.cyan("Git initialised ✅"))
}

// All set
console.log(chalk.cyan("\n\nYou're good to go! ✅\n"))
Expand Down
2 changes: 1 addition & 1 deletion lib/cmd/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ const chalk = require("chalk")
const package = require("../../package.json")

module.exports = () => {
console.log(`${chalk.yellowBright("\nBangaJS")} v${package.version}\n`)
console.log(`${chalk.yellowBright("\nBàngáJS")} v${package.version}\n`)
}
7 changes: 3 additions & 4 deletions lib/templates/project/.gitignore.ejs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
node_modules

# production env files
.env
src/config/config.json
src/config/env/prod.env.json

# exclude everything
# exclude files in uploads
uploads/*

# exception to the rule
!uploads/.gitkeep
38 changes: 38 additions & 0 deletions lib/templates/project/.readme.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# <%= $projectName %>

This project was generated with [BàngáJS](https://bangajs.netlify.app/) v<%= $version %>.

## Installation

1. Install dependencies - `npm install`

2. Create a new file `.env` if it doesn't exist and copy the contents of `env.dev` into it to be able to run your server on production environment.

3. Then you need to provide values for the configuration env files at the `src/config/env directory`.


## Running the server locally

1. Start up the server - Run `npm start` | `npm run dev`

2. Server should be running on http://localhost:2020/ by default

## Code scaffolding

Run `banga generate <type> <name>` to generate a new file types. Visit [here](https://bangajs.netlify.app/#banga-generate) for more info.

## Routes

| Routes | Description | Auth roles |
| -----------------------------------------------------------------|----------------------------------------- | ------------------------------------- |
| [POST] &nbsp; /api/auth/sign-up | Create a new account | none
| [POST] &nbsp; /api/auth/sign-in | User sign in | none
| [POST] &nbsp; /api/auth/request-email-verification | Resend verfication email | none
| [POST] &nbsp; /api/auth/verify-email | Email verification | none
| [POST] &nbsp; /api/auth/request-password-reset | Sends a request password email | none
| [POST] &nbsp; /api/auth/reset-password | Reset password form handler | none
| [POST] &nbsp; /api/users | Create a user | User
| [GET] &nbsp; /api/users | Get all users | Admin
| [GET] &nbsp; /api/users/:userId | Get a user | User
| [UPDATE] &nbsp; /api/users/::userId | Update a user | User
| [DELETE] &nbsp; /api/users/:userId | Delete a user | Admin
7 changes: 6 additions & 1 deletion lib/utils/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ const yargs = require("yargs-parser")
const app = {}
const { cmdAlias } = require("./../config")
const help = require("./../cmd/help")
const package = require("./../../package.json")

const options = {
new: {
auth: true,
dep: true,
force: false,
git: true
},
generate: {
auth: false,
Expand All @@ -20,7 +24,7 @@ const options = {
root: false,
route: true,
service: true,
update: true,
update: true
}
}

Expand All @@ -32,6 +36,7 @@ app.parse = () => {
if (!cmdAlias[cmd]) throw new Error(`banga: "${cmd}" is not a recognised command or alias`)

args.$cmd = cmdAlias[cmd]
args.$version = package.version

process.ARGS = { ...options[args.$cmd], ...args }
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 70da350

Please sign in to comment.