Development

Also see CONTRIBUTING.mdopen in new window.

Environment setup

Here are the steps to successfully setup your development environment to contribute to this project

Setup using the VS Code dev container

This will set up a docker container with all the required tools and dependencies to get started.

  1. Go to the Node-RED Home Assistantopen in new window repository and fork it.

  2. Clone your forked repository to your local machine.

    git clone https://github.com/<GITHUB_USER_NAME>/node-red-contrib-home-assistant-websocket
    
  3. Open the project in VS Code.

  4. Install the Remote - Containersopen in new window extension.

  5. Click the green button in the lower-left corner of the window that says "Reopen in Container".

  6. Wait for the container to build and start.

  7. Open a terminal in VS Code and run npm run dev to start the development server.

Setup locally

  1. Go to the Node-RED Home Assistantopen in new window repository and fork it.

  2. Clone your forked repository to your local machine.

    git clone https://github.com/zachowj/node-red-contrib-home-assistant-websocket
    
  3. create an npm link to your forked project. This will also build this project's dependencies.

    cd node-red-contrib-home-assistant-websocket
    npm link
    
  4. Installopen in new window Node-RED on localhost, assuming we install it on ~/dev directory (you can install it in another location as you wish)

    cd ~/dev/node-red
    npm install -g --unsafe-perm node-red
    
  5. Install your fork project into local Node-RED using npm link:

    cd ~/dev/node-red
    npm link node-red-contrib-home-assistant-websocket
    
  6. Starting Node-RED on localhost

    cd ~/dev/node_modules/node-red
    npm run dev
    

Accessing

After running npm run dev Node-RED will be running on ports 1880 and 3000. You can access the development server at http://localhost:1880 or http://localhost:3000 either port can be used. On port 3000 browser-sync is running and will reload the browser when changes are made to the editor source code.

Linting

This project uses ESLintopen in new window and Prettieropen in new window to lint and format the code. You can run npm run lint to lint the code.

Testing

  1. Run npm run test to run the tests.