diff --git a/lib/cmd/help.js b/lib/cmd/help.js index 63c5f94..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: @@ -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 ` diff --git a/lib/cmd/new.js b/lib/cmd/new.js index 033cd9f..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: [] }, @@ -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 = []) { @@ -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")) 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 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 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 diff --git a/lib/utils/app.js b/lib/utils/app.js index a3a2620..f1ce920 100644 --- a/lib/utils/app.js +++ b/lib/utils/app.js @@ -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, @@ -20,7 +24,7 @@ const options = { root: false, route: true, service: true, - update: true, + update: true } } @@ -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 } } 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": {