Skip to content
André Fernando Araújo de Carvalho edited this page Oct 4, 2019 · 1 revision

General

To keep generic and easy way to up the Terrabrasilis environment, some utilities require to use. As docker to mount the environment and manage all services, we are using others ways like NPM modules to make more easy the install and setup Terrabrasilis webmap application.

The current modules to Terrabrasilis are located in: https://github.com/Terrabrasilis

To publish on NPM

To create and publish module on NPM repository, we did the follow steps:

  1. Need have Github, Gitlab or Bitbucket and create a public repository to manage the version of source-code;
  2. The README file need explain the concept and how use that module;
  3. Need have the LICENSE file to expose the license;
  4. Need have NPM account and in a terminal execute npm login to make login to be possible to publish later;
  5. To work in the source code and publish, it's need:
    • Create a local directory;
    • Inside it, execute npm init;
    • Fill all informations asked by the npm init wizard. This process will generate the package.json in the end;
    • Create a source module using javascript;
    • Add the GIT to manage this directory with:
      • git init;
      • git remote add origin "gitlab, github or bitbucket url repository";
      • git add .;
      • git commit -m "some message";
      • git push origin "branch";
    • To publish in the end of the release closed just execute npm publish --access=public;
    • (if want attach travis-ci to realize the CI, just create a account there, point to the repository, create into source-code directory a file called .travis.yml);
    • If want to tag a release use:
      • git tag "vx.x.x";
      • git push origin "branch";
  6. To see the package on the NPM repository access https://www.npmjs.com/package/"package_name";
  7. To install the module in the application execute npm i "module"@"version" --save (--save-dev) or npm i "module" --save (--save-dev);

Published modules

  1. https://www.npmjs.com/package/terrabrasilis-api
  2. https://www.npmjs.com/package/terrabrasilis-jsonix
  3. https://www.npmjs.com/package/terrabrasilis-util

To test the NPM module locally

  1. cd 'path to the npm module'
  2. execute npm pack the npm will package the module like when publish
  3. cd 'path to the project'
  4. npm install '/path/npm/module/file-version.tgz'

Use NPM link in developer environment

  1. Inside the npm module folder, execute: npm link. This command will create a global npm link to use;
  2. Go to the project folder and execute npm link <module_npm_link_name>. Done, it's working to require in the project;
  3. To remove the link, inside the project, use: npm unlink --no-save <module_npm_link_name>;
  4. To remove the global link, inside the module folder, execute: npm unlink;