#### Info-RTU and JMap NG Lima works with Node.js 18.

#### The first time, install dependencies :

    npm i
    npm install -g validator

#### To run on windows, cross-env (https://www.npmjs.com/package/cross-env) can/must be used to set the environment variable

    npm install --save-dev cross-env

#### To start the application :

For Linux environment:

    npm start

For Windows:

    npm run wstart

The application is accessible at this location : https://localhost:8083?isFromInfoEx=true

When code is changed, it's automatically built and the web page refresh by its own (thanks webpack dev server).

#### Notes for running application :

~~When running in dev, copy file /build/env-config.js.example to /build/env-config.js and modify accordingly for dev or prod.~~

For dev, modify /resources/html/dev/index.html or public/dev/index.html to change the value of the REST API for the desired server, ex;

    restBaseUrl: "https://infortudev.info-ex.com/services/rest/v2.0",

The /resources/html/dev/index.html will be copied to /public automatically when running, BUT, once it is copied, it will not be overwritten,
so if the /resources file is updated you will need to delete the content of /public folder so that the new version of the file is copied.

#### webpack environment notes :

Two folders relate to webpack configuration and running process::

1. src/resources, which contains the initial source index.html files for dev and prod (only used for initial copy)
2. public/, the directory served by webpack web server which should contain the index.html files and application index.js files.

When the npm start commands is first executed, if the /public directory does not exist, the /dev files should be copied to /public directory (see buildfile.js).

Webpack will create and update the public/index.js file automatically, so the dev/index.html file should contain this file for source of Info-RTU extension

  <script defer type="text/javascript" src="/index.js"></script>

The index.html window.JMAP_OPTIONS restBaseUrl value can also be changed to connect to either the Info-Ex Dev JMap server or a local JMap server.

#### Install the following vs-code extensions :

    - "ESLint" extention
    - "Prettier - Code formatter" extention (Author : Esben Petersen)

#### Configure vscode

    - Create or edit app/.vscode/settings.json
    - Add the following content :

    {
      "javascript.format.enable": false,
      "typescript.format.enable": false,
      "eslint.format.enable": true,
      "eslint.lintTask.enable": true,
      "editor.codeActionsOnSave": {
        "source.fixAll.eslint": "explicit"
      },
      "eslint.workingDirectories": [
        {
          "mode": "auto"
        }
      ],
      "eslint.validate": ["javascript", "typescript", "javascriptreact", "typescriptreact"],
      "editor.formatOnSave": true,
      "editor.formatOnPaste": true,
      "editor.tabSize": 2,
      "editor.detectIndentation": false,
      "[typescript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode",
        "editor.codeActionsOnSave": {
          "source.organizeImports": "explicit"
        }
      },
      "[typescriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode",
        "editor.codeActionsOnSave": {
          "source.organizeImports": "explicit"
        }
      },
      "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
      },
      "[typescript][typescriptreact]": {
        "editor.codeActionsOnSave": {
          "source.organizeImports": "explicit"
        }
      }
    }

#### Publish new version to NPM

- If not logged to npm (use 1pass): npm login
- Update extension the version in package.json
- npm install
- rename /build/env-config.js to /build/\_env-config.js or change NODE_ENV to 'production'
- to publish, npm run build or for windows: npm run build-win
- to add tag to the version, use `npm dist-tag add <package-name>@<version> <tag>`, where the `<package-name>` is the name in package.json, `<version>` is the version in package.json and `<tag>` is the tag name, ex: v2-1. ex: `npm dist-tag add jmap-infortu-js@2.1.0 v2-1`
- once the tag is added, make sure to purge the npm cache. you can use the following website: `https://www.jsdelivr.com/tools/purge` and add the URL of package: `https://cdn.jsdelivr.net/npm/jmap-infortu-js@TAG` where the `TAG` is the tag name you added in the previous step.