mvccreate
v2.0.8
Published
A module script to create a default MVC pattern folder and file structure.
Downloads
12
Readme
MVC Create - An MVC Structure Builder
PURPOSE
INSTALL
npm i mvccreate
Recommended Usage
Most Basic install.js File:
const mvcCreate=require("mvccreate");
mvcCreate.mvcCreate();
Note: This will create all of the folders and files, with the option of creating a package.json. Here is what the default tree will look like:
- controllers
- - homeController.js
- models
- - homeModel.js
- public
- - css
- - images
- - js
- views
- - index.html
- main.js
- routes.js
- package.json (you will be provided an option to customize or skip)
- README.md
- .gitignore
Hint
npm i mvccreate
echo const mvcCreate=require("mvccreate"); >install.js
echo mvcCreate.mvcCreate(); >>install.js
node install.js
CUSTOMIZATION
What if you want to build a slightly different MVC pattern or even another structure? No problem. Version 2.0+ allows you to add your own patterns. If you want to use your own package.json, just skip the creation step. Just define the pattern you want as follows:
const mvcCreate=require("mvccreate");
//Define dev-dependencies as an object (if you are not using your own package.json):
userDevDepsObj={
"mvccreate": "*",
"nodemon": "^2.0.4"
}
//Define regular dependencies as an object (if you are not using your own package.json):
userDepsObj={
"express": "^4.16.3",
"express-es6-template-engine": "^2.2.3"
}
//Define a folder structure:
userDirs=[
"config",
"public",
"public/images",
"public/js",
"public/css",
"funny",
"views",
"controllers",
"models"
];
//Define files matching the folder structure:
userFiles=[
"main.js",
"router.js",
"weird.js",
"funny/iJustWantThisOneOkay.js",
"views/index.html",
"models/homeModel.js",
"controllers/homeController.js",
"README.md",
".gitignore"
];
//Feed these to mvcCreate for breakfast:
mvcCreate.mvcCreate(userDevDepsObj, userDepsObj, userDirs, userFiles);
userFiles=[
"main.js",
"router.js",
"utils.js",
"weird.js",
"funny/iJustWantThisOneOkay.js",
"views/index.html",
"models/homeModel.js",
"controllers/homeController.js",
"README.md",
".gitignore"
];
mvcCreate.mvcCreate("", "", "", userFiles);
PROMPT
NPM VERSIONS npmjs.com
1.0.6 - This version was an early development of the process.
2.0.0 - This version enables user defined patterns and a package.json creation process similar to 'npm init' but with more features.
NPM Listing: https://www.npmjs.com/package/mvccreate