<=> Having Build failing may be expected and a feature of this template ! See
./test/index.js
.
some template for nodejs module
-
Make a workable copy of this template by either:
-
Click on Use this template here or on the button shown on main page repository to create a new repository from imed-template (choose carefully your own "Repository name").
git clone https://github.com/<username>/<module-name>.git
-
or clone it then set remote to your own repository:
git clone https://github.com/jguillod/imed-template git remote set-url origin <your_url>
-
Now edit the project with your favorite editor and do : ...
-
Find/Replace "imed-template" with your own npm "module-name", e.g. in :
index.js
jsdoc.json
package.json
README.md
-
Find/Replace "@imed.ch" with your own npm "@scope", if you dont have a scope, replace "@imed.ch/" (suffixed with slash) with "", e.g. in :
jsdoc.json
package.json
README.md
-
Find/Replace "jguillod" with your own git "username", e.g. in :
package.json
README.md
IMPORTANT
Change the"author"
property in filepackage.json
according to your own data.
-
The following modules should be installed globally (my personal preference not to duplicate on disk for each new module) or locally:
npm i -g chai coveralls jsdoc minami mocha nyc open
Also, edit file
jsdoc.json
to settemplate
property to the correct path:-
when global install on OSX (tips: exec in shell
echo $NODE_PATH
to find globalnode_module
path):"template": "/usr/local/lib/node_modules/minami"
-
or locally:
"template": "./node_modules/minami",
-
-
Now code your module :
-
ALWAYS install dev dependencies with
npm i
-
Optionally install your dependencies modules with
npm i -S <some-module> ...
-
Edit
README.md
with your module specs and delete this section "Follow these steps".- Also, delete BACKERS and SPONSORS badges and sections when appropriate or configure your opencollective account.
- Either create a GITTER room for this module to chat with your module followers or delete the gitter badge.
-
Edit
index.js
and anysrc/
orlib/
javascript files (i.e. code your module). -
Write JSDoc comments to document your code.
-
Edit
test/
files (i.e. write Mocha tests with chai - expect(), assert() and should-style assertions).
-
-
Test your module :
npm test
It may fail because I wrote a failing test in order to prevent committing until it is fixed. This is a normal feature of git pre-commit hook (see module pre-commit for details). I'm willing to ensure a commit is not done too early. Anyway if you prefer to force the commit by passing the pre-commit hook use the
--no-verify
args in command below:git commit --no-verify -m "..."
-
Commit and push to your git repository.
-
Commit, push and publish your module :
git status git add package.json index.js src/ test/ etc.
then, either (A) or (B) :
(A) Safe way :
git commit -m "module first update" ## or to bypass the pre-commit hook : # git commit --no-verify -m "..." npm version patch -m "Patched to %s with corrections" git push origin master --tags npm publish --access public
(B) Fast way using using
--force
I sure hope you know what you are doing :npm version patch --force -m "Patched to %s with corrections" git push origin master --tags npm publish --access public
-
-
Build and coverage badges :
- Click on the build badge or open the link and configure Travis CI. Or, delete the build and coverage badges in README.md when appropriate.
Coverage is run automaticaly by Travis. You can also change the behavior by editing file
.travis.yml
. -
If you find this template helpfull, please consider to buy me some cups of coffee on :
TEMPLATE END HERE => REMOVE PART FROM START TO HERE, THEN EDIT YOU OWN DOCUMENTATION WITH/OUT THE DOCUMENTATION BELOW.
npm i -S @imed.ch/imed-template
TODO
Modules for testing should be installed globally or locally as dev dependencies with :
npm i -g chai coveralls mocha nyc # global install
npm i --save-dev chai coveralls mocha nyc # local to module
Execute tests with :
npm test
To generate documentation you should have some installed modules :
(A) Either globally allong side with one of JSDoc template :
(not to have duplicate local packages with any new module in development)
npm install -g jsdoc minami
npm install -g jsdoc better-docs
also update the "opts" property in jsdoc.json
file :
"opts": {
...,
"template": "/usr/local/lib/node_modules/minami"
}
where
-
minami
can be replaced by name of template your installed, likebetter-docs
. -
/usr/local/lib/node_modules/
is the global path to modules (OSX). You can find the correct path with :npm root -g # => /usr/local/lib/node_modules
npm install --save-dev jsdoc minami
Build documentation with :
npm run docs
It will generate the documentation and open its index.html
file. It's a shortcut of:
npm run generate-docs
npm run show-docs
Last command should open file ./docs/node-ifconfig.me/<version>/index.html
(e.g. ./docs/node-ifconfig.me/0.1.0/index.html
) in your browser.
- 0.4.0 changed author in package.json and for global access packages.
- 0.2.6 added support for pre-commit.
- 0.2.5 cleaning -- Sun Jul 28 10:33:51 CEST 2019
- 0.1.0 base template -- Wed Jul 17 19:33:38 CEST 2019
Find imed-template helpful? Become a backer and support imed-template with a monthly donation.
Use imed-template at Work? Ask your manager or marketing team if they'd help support our project. Your company's logo will also be displayed on npmjs.com and our GitHub repository.
Please, feel free to visit our personal website imed.ch and have a look to IoT projects for HealthCare we are involved in with eliiot technology.