From c73772a885052cc40a534ff3084b9f69ace83f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?h=CE=B1rsh=20v=CE=B1ir=CE=B1gi?= Date: Tue, 1 Oct 2024 13:55:11 +0530 Subject: [PATCH] sifting to version 1.1.2 is cool. - `style.css` file is shifted to `public/style.css` - `nets` file is shifted to `netface` - github `readme` file is shifted to `docs` folder. - `.gitignore` has been added. --- docs/changelogs.md | 7 +++ docs/documentation.md | 86 ----------------------------- docs/index.md | 5 +- README.md => docs/readme.md | 30 ++++++---- package-lock.json | 4 +- template/.gitignore | 15 +++++ template/app.js | 16 ++++-- template/package.json | 2 +- template/public/{ => css}/style.css | 0 template/utils/netface.js | 20 +++++++ template/utils/nets.js | 22 -------- template/views/home.ejs | 2 +- 12 files changed, 78 insertions(+), 131 deletions(-) delete mode 100644 docs/documentation.md rename README.md => docs/readme.md (72%) create mode 100644 template/.gitignore rename template/public/{ => css}/style.css (100%) create mode 100644 template/utils/netface.js delete mode 100644 template/utils/nets.js diff --git a/docs/changelogs.md b/docs/changelogs.md index b84d07a..6a288a6 100644 --- a/docs/changelogs.md +++ b/docs/changelogs.md @@ -1,6 +1,13 @@ # Changelogs You can check most latest changlogs at [commits](https://github.com/OurCodeBase/gen3-express/commits/main/) or [versions](https://github.com/OurCodeBase/gen3-express/releases) sections in github. +## Changelogs 1.1.2 +boilerplate has been optimised, enhanced and documented. +- `style.css` file is shifted to `public/style.css` +- `nets` file is shifted to `netface` +- github `readme` file is shifted to `docs` folder. +- `.gitignore` has been added. + ## Changelogs 1.1.1 generator published at npmjs. - docs updated diff --git a/docs/documentation.md b/docs/documentation.md deleted file mode 100644 index 6224c27..0000000 --- a/docs/documentation.md +++ /dev/null @@ -1,86 +0,0 @@ -# Gen3 Express -A gen3 tool to generate express app boilerplate. - -## Changelogs 1.1.1 -generator published at npmjs. -- docs updated -- package updated -- npm ignore file updated - -## Acknowledgements -You need to know atleast basics about these things. - - [NodeJS](https://nodejs.org/docs/latest/api/) - - [ExpressJS](https://expressjs.com/en/5x/api.html) - - [Embedded JS](https://ejs.co/) - -## Installation -You can install and generate an express app using this tool in two approaches. Here I'm generating an app with name `my-app`, you can name to it anything you like. - -### 1. node package extecutor -This method is highly recommended to generate an express app. -```bash -npx gen3-express my-app -``` - -### 2. node package manager -Generation of an express app is not recommended through npm. -```bash -npm install -g gen3-express -``` -```bash -gen3-express my-app -``` - -## Documentation -To install all dev dependencies goto the folder and hit `npm install` command. -```bash -cd my-app -npm install -``` -To start a dev server to preview page use `server` word. -- Keep in mind that -- The below command does not include EJS live reloading. - -```bash -npm run server -``` -To start a dev server to live preview EJS page use `sync` word. -```bash -npm run sync -``` -If you want to run all these servers together then you should to use this below command, this command will provide you hot reloadings in every place. -```bash -npm run server & npm run sync -``` - -## File Cases -To know about the product or project structure read about files included in this code block. - -```bash -. -├── app.js # this core file handles express functions and server. -├── package.json # package file handles dependencies, and details about the product. -├── public # this folder contains public data like fonts, css and multimedia. -│   ├── fonts -│   │   └── sans.woff -│   └── style.css -├── sync.js # this file is needed to configure hot reloadings in ejs and static files. -├── utils -│   └── nets.js # this file provides functions to display available ip addresses on your network. -└── views # this folder contains ejs or html files to render contents. - └── home.ejs # this file is the landing page of the product. -``` - -## Roadmap - -- Custom name in `package.json` file ✅ -- Excellent terminal user interface ✅ -- Prompt `package.json` file's details from user. ⏩ -- Post this project to npmjs website. ✅ -- Custom local template feature ⏩ - -## Authors -- [@OurCodeBase](https://www.github.com/OurCodeBase) - -## Contributing -Contributions are always welcome! diff --git a/docs/index.md b/docs/index.md index 7c9d13c..b9180d6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -11,7 +11,7 @@ hero: actions: - theme: brand text: Get Started - link: /documentation + link: /readme - theme: alt text: View on GitHub link: https://github.com/OurCodeBase/gen3-express @@ -29,7 +29,4 @@ features: - icon: ⚔ title: Cross Platform details: You can use this tool on any platform like Linux, MacOS, Windows (WSL) and also on Android (Termux). - - icon: 🥙 - title: NPX Usable - details: You don't neet to install a separate tool to generate express apps. You can just simply use npx to fetch files and dependencies temporarily. --- diff --git a/README.md b/docs/readme.md similarity index 72% rename from README.md rename to docs/readme.md index 4f1e7f9..c02459d 100644 --- a/README.md +++ b/docs/readme.md @@ -1,6 +1,15 @@ # Gen3 Express A gen3 tool to generate express app boilerplate. +> [!IMPORTANT] +> ### 1.1.2 is released +> boilerplate has been optimised, enhanced and documented. +> - `style.css` file is shifted to `public/style.css` +> - `nets` file is shifted to `netface` +> - github `readme` file is shifted to `docs` folder. +> - `.gitignore` has been added. + + ## Acknowledgements You need to know atleast basics about these things. - [NodeJS](https://nodejs.org/docs/latest/api/) @@ -52,17 +61,18 @@ To know about the product or project structure read about files included in this ```bash . -├── app.js # this core file handles express functions and server. -├── package.json # package file handles dependencies, and details about the product. -├── public # this folder contains public data like fonts, css and multimedia. -│   ├── fonts -│   │   └── sans.woff -│   └── style.css -├── sync.js # this file is needed to configure hot reloadings in ejs and static files. +├── app.js +├── package.json +├── public +│   ├── css +│   │   └── style.css +│   └── fonts +│   └── sans.woff +├── sync.js # configuration for hot reloadings in ejs and static files. ├── utils -│   └── nets.js # this file provides functions to display available ip addresses on your network. -└── views # this folder contains ejs or html files to render contents. - └── home.ejs # this file is the landing page of the product. +│   └── netface.js # contains functions to show available ipv4 addresses. +└── views + └── home.ejs ``` ## Roadmap diff --git a/package-lock.json b/package-lock.json index e52869b..bbb9d5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gen3-express", - "version": "1.0.0", + "version": "1.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gen3-express", - "version": "1.0.0", + "version": "1.1.1", "license": "ISC", "dependencies": { "commander": "^12.1.0", diff --git a/template/.gitignore b/template/.gitignore new file mode 100644 index 0000000..c55a527 --- /dev/null +++ b/template/.gitignore @@ -0,0 +1,15 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules + +# env variables +.env.local +.env.development.local +.env.test.local +.env.production.local + +# error and debug files +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/template/app.js b/template/app.js index f0c6790..27e1ac9 100644 --- a/template/app.js +++ b/template/app.js @@ -2,7 +2,7 @@ const path = require('path') const express = require('express') const app = express() -const PORT = 3000 +const port = 3000 app.set('view engine', 'ejs') app.use(express.static('public')) @@ -17,8 +17,14 @@ app.use('/colors', express.static( app.get('/', (req, res) => res.render('home')) -app.listen(PORT, () => { - const nets = require('./utils/nets') - console.log('Server has been started on...'); - nets.showAvailableNetworks(PORT) +app.listen(port, () => { + /** + * The above code is exclusivly for dev purpose. + * You can replace this function. + */ + const netface = require('./utils/netface') + const linkfaces = netface.ipv4s() + linkfaces.forEach((face) => { + console.info(`http://${face}:${port}`) + }) }) diff --git a/template/package.json b/template/package.json index a2dc851..521f9d2 100644 --- a/template/package.json +++ b/template/package.json @@ -8,7 +8,7 @@ }, "dependencies": { "ejs": "^3.1.10", - "express": "^4.19.2", + "express": "^4.20.0", "material-dynamic-colors": "^1.1.2" }, "devDependencies": { diff --git a/template/public/style.css b/template/public/css/style.css similarity index 100% rename from template/public/style.css rename to template/public/css/style.css diff --git a/template/utils/netface.js b/template/utils/netface.js new file mode 100644 index 0000000..79a63de --- /dev/null +++ b/template/utils/netface.js @@ -0,0 +1,20 @@ +const os = require('os') + +/** + * This contains all available ipv4 ip address. + * @returns {Object[]} netfaces - All ipv4 ip address. + * */ +const ipv4s = () => { + const netfaces = [] + const interfaces = os.networkInterfaces() + for (const key of Object.keys(interfaces)) { + for (const interface of interfaces[key]) { + if (interface.family == 'IPv4'){ + netfaces.push(interface.address) + } + } + } + return netfaces +} + +module.exports = { ipv4s } diff --git a/template/utils/nets.js b/template/utils/nets.js deleted file mode 100644 index 2c8a642..0000000 --- a/template/utils/nets.js +++ /dev/null @@ -1,22 +0,0 @@ -const os = require('os') - -function availableNetworks() { - const networkInterfaces = os.networkInterfaces() - const networkAddresses = [] - for (const networkInterface of Object.keys(networkInterfaces)) { - for (const interface of networkInterfaces[networkInterface]) { - if (interface.family == 'IPv4'){ - networkAddresses.push(interface.address) - } - } - } - return networkAddresses -} - -function showAvailableNetworks(PORT) { - for (const avnetwork of availableNetworks()) { - console.log(`http://${avnetwork}:${PORT}/`) - } -} - -module.exports = { availableNetworks, showAvailableNetworks } diff --git a/template/views/home.ejs b/template/views/home.ejs index 4fffbb8..d2e247f 100644 --- a/template/views/home.ejs +++ b/template/views/home.ejs @@ -4,7 +4,7 @@ - +

Hello World!