modules-client-server v1.0.15
modules-client-server
This package structure your project so you can have your client, server and modules in different places.
Default configuration
We make a separation bitween client, server and modules
┌── client
├── modules
└── serverEach module itself has a separation bitween client, server and common files
──┬ modules
└─┬ moduleXXX
├── client
├── common
└── serverFor a module, common files and directories are symlinked to client and server
──┬ modules
└─┬ moduleXXX
├─┬ client
| ├── clientFILE.js
| ├── clientDIR
| ├── commonFILE.js <=symlink=> ./common/commonFILE.js
| └── commonDIR <=symlink=> ./common/commonDIR
├─┬ common
| ├── commonFILE.js
| └── commonDIR
└─┬ server
├── serverFILE.js
├── serverDIR
├── commonFILE.js <=symlink=> ./common/commonFILE.js
└── commonDIR <=symlink=> ./common/commonDIRAnd finaly, client of the module is symlinked to the client source and server of the module is symlinked to the server source
┌─┬ client
| └─┬ src
| └── moduleXXX <=symlink=> modules/moduleXXX/client
├─┬ modules
| └─┬ moduleXXX
| ├── client
| ├── common
| └── server
└─┬ server
└─┬ src
└── moduleXXX <=symlink=> modules/moduleXXX/serverSo, at the end, we have
┌─┬ client
| └─┬ src
| └─┬ moduleXXX
| ├── clientFILE.js
| ├── clientDIR
| ├── commonFILE.js
| └── commonDIR
├── modules...
└─┬ server
└─┬ src
└─┬ moduleXXX
├── serverFILE.js
├── serverDIR
├── commonFILE.js
└── commonDIRHow to use by default
You can create a modules-client-server.conf.json file if you have other preferences. You have to execute a command in the same directory as the configuration file if it is defined.
Fist, install the package as global :
npm install -g modules-client-serverSo as a sample :
mkdir sampleProj
cd sampleProj
modules-client-server --init --add moduleXXX
cd modules\moduleXXX
echo // > client\clientFILE.js
mkdir client\clientDIR
echo // > server\serverFILE.js
mkdir server\serverDIR
echo // > common\commonFILE.js
mkdir common\commonDIREach time you add or remove common files or directories you have to sync them with client and server side :
modules-client-server --syncOr you can automate it :
modules-client-server --watchWhile watching, you can use an other console to add or remove modules.
NOTA BENE: for Windows, to --sync or --watch, if you have files in the root of your common module directory, your console MUST be executed as Administrator. Directories are OK.
Parameter file : modules-client-server.conf.js
The commands are to be done where is the parameter file.
You can change where client, server or common directories are on your system.
The --conf command show you the current configuration.
rootPath: used ifclientRootPath,serverRootPathormodulesRootPathhave relative pathsclientRootPath: root path of the client (can be relative torootPath)serverRootPath: root path of the server (can be relative torootPath)modulesRootPath: root path of the modules (can be relative torootPath)clientSrcPath: src path of the client (can be relative toclientRootPath)nodeModulesPath:node_modulespath of the modules (can be relative toclientRootPath)serverSrcPath: src path of the server (can be relative toserverRootPath)serverRootPathShouldExist: the server must exist before--initclientModulesName: name of the directory where all modules have to be underclientSrcPathif definedserverModulesName: name of the directory where all modules have to be underserverSrcPathif definedmoduleClientCommonName: name of the directory where all common ressources of each modules have to be for the client side if definedmoduleServerCommonName: name of the directory where all common ressources of each modules have to be for the server side if definedgitignore: the symlinks are included in.gitignorefiles of client, server and modules root directories (default to true)
If moduleClientCommonName and moduleServerCommonName are both used, you don't have to use --sync.
To have this configuration :
┌─┬ client
| └─┬ src
| └─┬ modulesS
| └─┬ moduleXXX
| ├── clientFILE.js
| ├── clientDIR
| ├── commonFILE.js
| └── commonDIR
├── modules...
└─┬ server
└─┬ src
└─┬ modulesC
└─┬ moduleXXX
├── serverFILE.js
├── serverDIR
├── commonFILE.js
└── commonDIRmodules-client-server.conf.js file :
{
"clientModulesName": "modulesS",
"serverModulesName": "modulesN"
}To have this configuration :
┌─┬ client
| └─┬ src
| └─┬ £
| └─┬ moduleXXX
| ├── clientFILE.js
| ├── clientDIR
| └─┬ #
| ├── commonFILE.js
| └── commonDIR
├── modules...
└─┬ server
└─┬ src
└─┬ modulesC
└─┬ moduleXXX
├── serverFILE.js
├── serverDIR
└─┬ $
├── commonFILE.js
└── commonDIRmodules-client-server.conf.js file :
{
"clientModulesName": "£",
"serverModulesName": "modulesC",
"moduleClientCommonName": "#",
"moduleServerCommonName": "$"
}