-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1286 from FlowFuse/contrib-node-sources
Loading 3rd party widgets
- Loading branch information
Showing
7 changed files
with
190 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "@me/node-red-dashboard-2-two-widgets", | ||
"version": "1.0.0", | ||
"description": "My dashboard 2 test node package", | ||
"node-red-dashboard-2": { | ||
"version": "1.0.0", | ||
"widgets": { | ||
"ui-widget-1": { | ||
"output": "ui-widget-1.js", | ||
"component": "ui-widget-1" | ||
}, | ||
"ui-widget-2": { | ||
"output": "ui-widget-2.js", | ||
"component": "ui-widget-2" | ||
} | ||
} | ||
}, | ||
"author": "Your Name", | ||
"license": "Apache-2.0" | ||
} |
16 changes: 16 additions & 0 deletions
16
.../nodes/fixtures/contrib-nodes/node_modules/@me/node-red-dashboard-2-widget-a/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
.../nodes/fixtures/contrib-nodes/node_modules/@me/node-red-dashboard-2-widget-b/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@me/my-2-widgets", | ||
"version": "1.0.0", | ||
"description": "My dashboard 2 test node", | ||
"dependencies": { | ||
"@me/node-red-dashboard-2-widget-a": "1.0.0", | ||
"@me/node-red-dashboard-2-widget-b": "1.0.0" | ||
}, | ||
"author": "Your Name", | ||
"license": "Apache-2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const should = require('should') // eslint-disable-line no-unused-vars | ||
|
||
const utils = require('../../nodes/utils/index.js') | ||
|
||
describe('utils', function () { | ||
describe('getThirdPartyWidgets', function () { | ||
it('should load single node package', function () { | ||
// this covers loading from a nodesDir source | ||
const widgets = utils.getThirdPartyWidgets('test/nodes/fixtures/contrib-node') | ||
widgets.should.be.an.Object() | ||
widgets.should.have.properties(['ui-widget-1', 'ui-widget-2']) | ||
widgets['ui-widget-1'].should.have.properties(['component', 'name', 'package', 'path', 'src']) | ||
widgets['ui-widget-1'].component.should.equal('ui-widget-1') | ||
widgets['ui-widget-1'].name.should.equal('ui-widget-1') | ||
widgets['ui-widget-1'].package.should.equal('@me/node-red-dashboard-2-two-widgets') | ||
widgets['ui-widget-1'].src.should.equal('ui-widget-1.js') | ||
|
||
widgets['ui-widget-2'].should.have.properties(['component', 'name', 'package', 'path', 'src']) | ||
widgets['ui-widget-2'].component.should.equal('ui-widget-2') | ||
widgets['ui-widget-2'].name.should.equal('ui-widget-2') | ||
widgets['ui-widget-2'].package.should.equal('@me/node-red-dashboard-2-two-widgets') | ||
widgets['ui-widget-2'].src.should.equal('ui-widget-2.js') | ||
}) | ||
it('should load nodes from a package dependencies', function () { | ||
// this covers loading from node-red src package and from userDir package | ||
const widgets = utils.getThirdPartyWidgets('test/nodes/fixtures/contrib-nodes') | ||
widgets.should.be.an.Object() | ||
widgets.should.have.properties(['widget-a', 'widget-b']) | ||
widgets['widget-a'].should.have.properties(['component', 'name', 'package', 'path', 'src']) | ||
widgets['widget-a'].component.should.equal('ui-widget-a') | ||
widgets['widget-a'].name.should.equal('widget-a') | ||
widgets['widget-a'].package.should.equal('@me/node-red-dashboard-2-widget-a') | ||
widgets['widget-a'].src.should.equal('ui-widget.js') | ||
|
||
widgets['widget-b'].should.have.properties(['component', 'name', 'package', 'path', 'src']) | ||
widgets['widget-b'].component.should.equal('ui-widget-b') | ||
widgets['widget-b'].name.should.equal('widget-b') | ||
widgets['widget-b'].package.should.equal('@me/node-red-dashboard-2-widget-b') | ||
widgets['widget-b'].src.should.equal('ui-widget.js') | ||
}) | ||
}) | ||
}) |