From e057cb92f778ad4460ab298f2753aceb28c22b3f Mon Sep 17 00:00:00 2001 From: saucecodee Date: Sat, 14 Nov 2020 14:51:35 +0100 Subject: [PATCH 1/7] feat: add git and dep options to new cmd --- lib/cmd/new.js | 22 +++++++++++++--------- lib/utils/app.js | 5 ++++- package-lock.json | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/cmd/new.js b/lib/cmd/new.js index 033cd9f..06d6c91 100644 --- a/lib/cmd/new.js +++ b/lib/cmd/new.js @@ -90,15 +90,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 ✅")) - - // Initialize Git - console.log(chalk.bold("\nInitialising git...")) - runCommand("git", ["init"]) - console.log(chalk.cyan("Git initialised ✅")) + if(ARGS.dep){ + // Run npm install + console.log(chalk.bold("\nInstalling packages...")) + runCommand("npm", ["install"]) + console.log(chalk.cyan("Packages installed ✅")) + } + + 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")) diff --git a/lib/utils/app.js b/lib/utils/app.js index a3a2620..e4e8089 100644 --- a/lib/utils/app.js +++ b/lib/utils/app.js @@ -6,6 +6,9 @@ const help = require("./../cmd/help") const options = { new: { auth: true, + dep: true, + force: false, + git: true }, generate: { auth: false, @@ -20,7 +23,7 @@ const options = { root: false, route: true, service: true, - update: true, + update: true } } diff --git a/package-lock.json b/package-lock.json index ded1dc3..d44795f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bangajs", - "version": "0.0.0", + "version": "0.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { From 1678d484a8ea77d913fdcf60b06967e92abf26e3 Mon Sep 17 00:00:00 2001 From: saucecodee Date: Mon, 16 Nov 2020 01:06:20 +0100 Subject: [PATCH 2/7] chore: update new option help --- lib/cmd/help.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/cmd/help.js b/lib/cmd/help.js index 63c5f94..36ffc1a 100644 --- a/lib/cmd/help.js +++ b/lib/cmd/help.js @@ -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 ` From be7d7556688ad68a23e22ba1daa6ee080d9b1e04 Mon Sep 17 00:00:00 2001 From: saucecodee Date: Mon, 16 Nov 2020 01:07:04 +0100 Subject: [PATCH 3/7] chore: update project files --- lib/cmd/new.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cmd/new.js b/lib/cmd/new.js index 06d6c91..c172f73 100644 --- a/lib/cmd/new.js +++ b/lib/cmd/new.js @@ -43,9 +43,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 = []) { From 6550bcc4b20b909f658135af79577f4e5e4d3d0f Mon Sep 17 00:00:00 2001 From: saucecodee Date: Mon, 16 Nov 2020 02:17:26 +0100 Subject: [PATCH 4/7] =?UTF-8?q?chore:=20correct=20B=C3=A0ng=C3=A1=20=20nam?= =?UTF-8?q?e=20characters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cmd/help.js | 2 +- lib/cmd/version.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cmd/help.js b/lib/cmd/help.js index 36ffc1a..5000012 100644 --- a/lib/cmd/help.js +++ b/lib/cmd/help.js @@ -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: diff --git a/lib/cmd/version.js b/lib/cmd/version.js index 75b9bd1..e3664c7 100644 --- a/lib/cmd/version.js +++ b/lib/cmd/version.js @@ -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`) } \ No newline at end of file From 6fee0ce6a07cba5386c2cdfd5883deb0d232eac8 Mon Sep 17 00:00:00 2001 From: saucecodee Date: Mon, 16 Nov 2020 06:56:39 +0100 Subject: [PATCH 5/7] feat: add readme to project files --- lib/cmd/new.js | 1 + lib/templates/project/.readme.ejs | 38 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 lib/templates/project/.readme.ejs diff --git a/lib/cmd/new.js b/lib/cmd/new.js index c172f73..28cd31d 100644 --- a/lib/cmd/new.js +++ b/lib/cmd/new.js @@ -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: [] }, diff --git a/lib/templates/project/.readme.ejs b/lib/templates/project/.readme.ejs new file mode 100644 index 0000000..05f1411 --- /dev/null +++ b/lib/templates/project/.readme.ejs @@ -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 ` to generate a new file types. Visit [here](https://bangajs.netlify.app/#banga-generate) for more info. + +## Routes + +| Routes | Description | Auth roles | +| -----------------------------------------------------------------|----------------------------------------- | ------------------------------------- | +| [POST]   /api/auth/sign-up | Create a new account | none +| [POST]   /api/auth/sign-in | User sign in | none +| [POST]   /api/auth/request-email-verification | Resend verfication email | none +| [POST]   /api/auth/verify-email | Email verification | none +| [POST]   /api/auth/request-password-reset | Sends a request password email | none +| [POST]   /api/auth/reset-password | Reset password form handler | none +| [POST]   /api/users | Create a user | User +| [GET]   /api/users | Get all users | Admin +| [GET]   /api/users/:userId | Get a user | User +| [UPDATE]   /api/users/::userId | Update a user | User +| [DELETE]   /api/users/:userId | Delete a user | Admin From b748e6d2576682c97b17572d16ce374fb98d9064 Mon Sep 17 00:00:00 2001 From: saucecodee Date: Mon, 16 Nov 2020 06:57:53 +0100 Subject: [PATCH 6/7] chore: update gitignore files for envs --- lib/templates/project/.gitignore.ejs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/templates/project/.gitignore.ejs b/lib/templates/project/.gitignore.ejs index b23555a..02c22eb 100644 --- a/lib/templates/project/.gitignore.ejs +++ b/lib/templates/project/.gitignore.ejs @@ -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 \ No newline at end of file From 93315a337f6b6fa1ed67d5e0151f4f015d7a40ea Mon Sep 17 00:00:00 2001 From: saucecodee Date: Mon, 16 Nov 2020 06:58:39 +0100 Subject: [PATCH 7/7] chore: add app version to args --- lib/utils/app.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/utils/app.js b/lib/utils/app.js index e4e8089..f1ce920 100644 --- a/lib/utils/app.js +++ b/lib/utils/app.js @@ -2,6 +2,7 @@ const yargs = require("yargs-parser") const app = {} const { cmdAlias } = require("./../config") const help = require("./../cmd/help") +const package = require("./../../package.json") const options = { new: { @@ -35,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 } }