question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Best practice for automating UI Builder dependency installation?

See original GitHub issue

We’re using docker to run Node-RED. Currently we have uibuilder getting installed automatically by providing a package.json to Node-RED, per these instructions https://nodered.org/docs/getting-started/docker:

# Copy package.json to the WORKDIR so npm builds all
# of your added nodes modules for Node-RED
COPY package.json .
RUN npm install --unsafe-perm --no-update-notifier --no-fund --only=production

This gets us halfway there with node-red’s dependencies, but then we still need to manually install uibuilder dependencies (vue, etc.) through the admin interface after starting Node-RED.

I did some testing and it seems like we can provide a minimal /data/uibuilder/package.json file and run an npm install in the Dockerfile and everything works for the most part. (“PACKAGE vue NOT FOUND” error if we provide package.json but don’t run an npm install before starting)


Dockerfile which installs uibuilder and its dependencies, sets up minimal index.html for testing:

FROM nodered/node-red:3.0.1

# Install node-red dependencies (uibuilder)
COPY package.json .
RUN npm install --unsafe-perm --no-update-notifier --no-fund --only=production

COPY flows.json /data/flows.json

# Prepare uibuilder directory
RUN mkdir -p /data/uibuilder/ui/src
RUN echo "Hello from /ui/" > /data/uibuilder/ui/src/index.html

# Install uibuilder's dependencies (vue)
COPY uib-package.json /data/uibuilder/package.json

USER 0
RUN chown -R node-red:node-red /data
USER node-red

WORKDIR /data/uibuilder
RUN npm install

WORKDIR /usr/src/node-red

Minimal test flows.json:

[
    {
        "id": "f6f2187d.f17ca8",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "32a328ad2c36f043",
        "type": "uibuilder",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "topic": "",
        "url": "ui",
        "fwdInMessages": false,
        "allowScripts": false,
        "allowStyles": false,
        "copyIndex": true,
        "templateFolder": "blank",
        "extTemplate": "",
        "showfolder": false,
        "reload": false,
        "sourceFolder": "src",
        "deployedVersion": "5.1.1",
        "x": 530,
        "y": 340,
        "wires": [
            [],
            []
        ]
    }
]

Node-RED package.json:

{
  "name": "uib-dependencies-test",
  "description": "Node-RED dependencies",
  "scripts": {
    "start": "node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS"
  },
  "dependencies": {
    "node-red": "^2.2.2",
    "node-red-contrib-uibuilder": "^5.0.2"
  }
}

Minimal uib-package.json:

{
  "name": "uib_root",
  "version": "5.1.1",
  "description": "Root configuration and data folder for uibuilder",
  "scripts": {},
  "dependencies": {
    "vue": "^2.7.8"
  }
}

The only issues I see doing it this way is that UI Builder isn’t updating the package.json’s uibuilder.packages, only creating an empty stub:

uib-package.json after starting Node-RED:

{
  "name": "uib_root",
  "version": "5.1.1",
  "description": "Root configuration and data folder for uibuilder",
  "scripts": {},
  "dependencies": {
    "vue": "^2.7.8"
  },
  "uibuilder": {
    "packages": {}  // <- this gets added, but not populated
  }
}

which results in an incorrect/missing “Est. link” in the admin interface:

image

This isn’t really an issue though since our actual index.html already has the correct paths for the dependencies so this is just a small visual issue as far as I can tell. The file itself is still available where it should be at http://localhost:1880/uibuilder/vendor/vue/dist/vue.js, and no errors are logged.


So I guess my question is, is this the most correct/reliable way to be doing this?

  1. Provide only a minimal package.json to uibuilder
  2. Run npm install at the build stage from the Dockerfile
  3. Just deal with the empty uibuilder.packages entry in package.json as it seems to only cause visual issues and no actual errors?

I don’t really like the idea of providing a package.json with a pre-populated uibuilder.packages, since that seems like something that may change over time (like it just did in the last major release!) and should be handled internally by uibuilder instead so we don’t have to keep up with changes to the structure of this file. Are there any hidden issues I may have missed that could be introduced by installing uibuilder dependencies this way? Or any planned changes to uibuilder that may break this in the future?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:27 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
TotallyInformationcommented, Nov 26, 2022

Confirmed that manually installed packages in your uibRoot folder correctly populate all of the metadata after node-red is restarted.

1reaction
dczyszcommented, Sep 19, 2022

I can try your v6 branch tomorrow so we’re on the same page, just been a bit distracted with other stuff today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best Practices in Large UI Test Automation Projects - YouTube
Automating UI testing can be challenging, especially on projects with a significant number of objects. In this webinar, you'll learn best ...
Read more >
Top 10 Test Automation Strategies and Best Practices
This article summarizes the best practices and strategies for doing test automation. ... Good Automation means good manual test case; #6.
Read more >
Test Automation Best Practices - SmartBear
These test automation best practices a successful foundation to start improving your software quality. Thorough testing is crucial to the success of a ......
Read more >
16 Selenium Best Practices For Efficient Test Automation
Discover the top 16 Selenium automation best practices that will help you become a top notch automated testing specialist. Learn more.
Read more >
Top 17 Automated Testing Best Practices (Supported By Data)
But it is a large problem with acceptance UI automation. Here's an example: Open UltimateQA.com home page; Assert that the page opened; Assert ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found