node-red-admin
Advanced tools
Comparing version 0.1.5 to 0.1.8
@@ -26,6 +26,6 @@ /** | ||
} | ||
var options = { | ||
method: "GET", | ||
url: 'https://registry.npmjs.org/-/_view/byKeyword?startkey=["node-red"]&endkey=["node-red",{}]&group_level=3', | ||
url: 'https://flows.nodered.org/things?format=json&per_page=50&type=node&term='+module, | ||
headers: { | ||
@@ -38,13 +38,20 @@ 'Accept': 'application/json', | ||
if (!error && response.statusCode == 200) { | ||
var info = (JSON.parse(body)).rows; | ||
var filter = new RegExp(module); | ||
var found = false; | ||
for (var i = 0; i < info.length; i++) { | ||
var n = info[i]; | ||
if (!filter || filter.test(n.key[1]) || filter.test(n.key[2])) { | ||
result.log(n.key[1].cyan.bold + (" - " + n.key[2]).grey); | ||
found = true; | ||
var info = JSON.parse(body); | ||
var matches = []; | ||
if (info.data && info.data.length > 0) { | ||
for (var i = 0; i < info.data.length; i++) { | ||
var n = info.data[i]; | ||
var label = info.data[i].name.cyan.bold + (" - " + info.data[i].description).grey; | ||
var index = label.indexOf(module); | ||
matches.push({ | ||
label: label, | ||
index: index===-1?1000:index | ||
}); | ||
} | ||
} | ||
if (!found) { | ||
matches.sort(function(A,B) { return A.index - B.index; }); | ||
matches.forEach(function(m) { | ||
result.log(m.label); | ||
}); | ||
} else { | ||
result.log("No results found"); | ||
@@ -51,0 +58,0 @@ } |
@@ -47,12 +47,12 @@ #!/usr/bin/env node | ||
"Commands:\n".bold + | ||
" target\n" + | ||
" login\n" + | ||
" list\n" + | ||
" info\n" + | ||
" enable\n" + | ||
" disable\n" + | ||
" search\n" + | ||
" install\n" + | ||
" remove\n" + | ||
" hash-pw\n" | ||
" target (Set or view the target URL and port like http://localhost:1880)\n" + | ||
" login (Log user in to the target of the Node-RED admin API)\n" + | ||
" list (List all of the installed nodes)\n" + | ||
" info (Display more information about the module or node)\n" + | ||
" enable (Enable the specified module or node set)\n" + | ||
" disable (Disable the specified module or node set)\n" + | ||
" search (Search NPM for Node-RED modules by matching name, description or keywords with the term)\n" + | ||
" install (Install the module from NPM to Node-RED)\n" + | ||
" remove (Remove the NPM module from Node-RED)\n" + | ||
" hash-pw (creates a hash to use for Node-RED settings like \"adminAuth\")\n" | ||
; | ||
@@ -59,0 +59,0 @@ console.log(helpText); |
{ | ||
"name": "node-red-admin", | ||
"version": "0.1.5", | ||
"version": "0.1.8", | ||
"description": "The Node-RED admin command line interface", | ||
"homepage": "http://nodered.org", | ||
"bugs": { | ||
"url": "https://github.com/node-red/node-red-admin/issues/" | ||
}, | ||
"license": "Apache-2.0", | ||
@@ -23,7 +26,10 @@ "repository": { | ||
"preferGlobal": "true", | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha " | ||
}, | ||
"dependencies": { | ||
"bcryptjs": "^2.4.3", | ||
"cli-table": "^0.3.1", | ||
"colors": "^1.3.2", | ||
"minimist": "^1.2.0", | ||
"colors": "^1.4.0", | ||
"minimist": "^1.2.5", | ||
"read": "^1.0.7", | ||
@@ -34,7 +40,7 @@ "request": "^2.88.0", | ||
"devDependencies": { | ||
"grunt": "^1.0.3", | ||
"grunt": "^1.0.4", | ||
"grunt-cli": "^1.3.2", | ||
"grunt-contrib-jshint": "^2.0.0", | ||
"grunt-contrib-jshint": "^2.1.0", | ||
"grunt-simple-mocha": "^0.4.1", | ||
"mocha": "^5.2.0", | ||
"mocha": "^7.1.0", | ||
"should": "^13.2.3", | ||
@@ -44,7 +50,28 @@ "sinon": "^1.17.7" | ||
"optionalDependencies": { | ||
"bcrypt": "^3.0.1" | ||
"bcrypt": "^3.0.8" | ||
}, | ||
"bin": { | ||
"node-red-admin": "node-red-admin.js" | ||
}, | ||
"mocha": { | ||
"spec:": "test/**/*.spec.js", | ||
"diff": true, | ||
"extension": [ | ||
"js" | ||
], | ||
"opts": false, | ||
"package": "./package.json", | ||
"reporter": "spec", | ||
"slow": 75, | ||
"timeout": 2000, | ||
"ui": "bdd", | ||
"recursive": "true", | ||
"watch-files": [ | ||
"lib/**/*.js", | ||
"test/**/*.js" | ||
], | ||
"watch-ignore": [ | ||
"lib/vendor" | ||
] | ||
} | ||
} |
@@ -1,14 +0,19 @@ | ||
# Node-RED Command Line Tool | ||
# Node-RED Admin | ||
The Node-RED admin command line interface. | ||
[![Build Status](https://travis-ci.org/node-red/node-red-admin.svg?branch=master)](https://travis-ci.org/node-red/node-red-admin) [![Coverage Status](https://coveralls.io/repos/node-red/node-red-admin/badge.svg?branch=master)](https://coveralls.io/r/node-red/node-red-admin?branch=master) | ||
Install this globally to make the `node-red-admin` command available on | ||
your path: | ||
A command line tool for Node-RED administrations. | ||
Install this globally to make the `node-red-admin` command available on your path: | ||
npm install -g node-red-admin | ||
Note: you may need to run this with `sudo`, or from within an Administrator command shell. | ||
Note: you may need to run this with `sudo`, or from within an Administrator command shell. | ||
You may also need to add `--unsafe-perm` to the command if you hit permissions errors during install. | ||
## Usage | ||
@@ -23,11 +28,12 @@ | ||
Commands: | ||
target - Set or view the target URL | ||
login - Log user in to the targetted Node-RED admin api | ||
list - List all of the installed nodes | ||
info - Display more information about the module or node | ||
enable - Enable the specified module or node set | ||
target - Set or view the target URL and port like http://localhost:1880 | ||
login - Log user in to the target of the Node-RED admin API | ||
list - List all of the installed nodes | ||
info - Display more information about the module or node | ||
enable - Enable the specified module or node set | ||
disable - Disable the specified module or node set | ||
search - Search NPM for Node-RED modules relating to the search-term given | ||
search - Search NPM for Node-RED modules by matching name, description or keywords with the term | ||
install - Install the module from NPM | ||
remove - Remove the NPM module | ||
remove - Remove the NPM module | ||
hash-pw - creates a hash to use for Node-RED settings like "adminAuth" | ||
@@ -52,3 +52,3 @@ /** | ||
} | ||
result.logList.called.should.be.true; | ||
result.logList.called.should.be.true(); | ||
done(); | ||
@@ -60,5 +60,5 @@ }).otherwise(done); | ||
command({_:{}},result); | ||
result.help.called.should.be.true; | ||
result.help.called.should.be.true(); | ||
done(); | ||
}); | ||
}); |
@@ -52,3 +52,3 @@ /** | ||
} | ||
result.logList.called.should.be.true; | ||
result.logList.called.should.be.true(); | ||
done(); | ||
@@ -60,5 +60,5 @@ }).otherwise(done); | ||
command({_:{}},result); | ||
result.help.called.should.be.true; | ||
result.help.called.should.be.true(); | ||
done(); | ||
}); | ||
}); |
@@ -43,3 +43,3 @@ /** | ||
command({},result).then(function() { | ||
result.log.calledOnce.should.be.true; | ||
result.log.calledOnce.should.be.true(); | ||
var hash = result.log.firstCall.args[0]; | ||
@@ -58,3 +58,3 @@ bcrypt.compare("a-test-password",hash,function(err,match) { | ||
command({},result).then(function() { | ||
result.log.called.should.be.false; | ||
result.log.called.should.be.false(); | ||
done(); | ||
@@ -69,3 +69,3 @@ }); | ||
command({},result).then(function() { | ||
result.log.called.should.be.false; | ||
result.log.called.should.be.false(); | ||
done(); | ||
@@ -72,0 +72,0 @@ }); |
@@ -49,3 +49,3 @@ /** | ||
} | ||
result.logDetails.called.should.be.true; | ||
result.logDetails.called.should.be.true(); | ||
done(); | ||
@@ -70,4 +70,4 @@ }).otherwise(done); | ||
} | ||
result.logDetails.called.should.be.false; | ||
result.warn.called.should.be.true; | ||
result.logDetails.called.should.be.false(); | ||
result.warn.called.should.be.true(); | ||
result.warn.args[0][0].should.eql("error"); | ||
@@ -80,3 +80,3 @@ done(); | ||
command({_:{}},result); | ||
result.help.called.should.be.true; | ||
result.help.called.should.be.true(); | ||
done(); | ||
@@ -83,0 +83,0 @@ }); |
@@ -52,3 +52,3 @@ /** | ||
} | ||
result.logDetails.called.should.be.true; | ||
result.logDetails.called.should.be.true(); | ||
done(); | ||
@@ -60,5 +60,5 @@ }).otherwise(done); | ||
command({_:{}},result); | ||
result.help.called.should.be.true; | ||
result.help.called.should.be.true(); | ||
done(); | ||
}); | ||
}); |
@@ -47,3 +47,3 @@ /** | ||
} | ||
result.logNodeList.called.should.be.true; | ||
result.logNodeList.called.should.be.true(); | ||
done(); | ||
@@ -50,0 +50,0 @@ }).otherwise(done); |
@@ -57,3 +57,3 @@ /** | ||
command({},result).then(function() { | ||
requestStub.calledTwice.should.be.true; | ||
requestStub.calledTwice.should.be.true(); | ||
requestStub.args[0][0].should.eql("/auth/login"); | ||
@@ -67,7 +67,7 @@ requestStub.args[1][0].should.eql("/auth/token"); | ||
config.tokens.calledTwice.should.be.true; | ||
config.tokens.calledTwice.should.be.true(); | ||
should.not.exist(config.tokens.args[0][0]); | ||
config.tokens.args[1][0].should.eql({access_token:"12345"}); | ||
/Logged in/.test(result.log.args[0][0]).should.be.true; | ||
/Logged in/.test(result.log.args[0][0]).should.be.true(); | ||
@@ -83,5 +83,5 @@ done(); | ||
command({},result).then(function() { | ||
requestStub.calledOnce.should.be.true; | ||
requestStub.calledOnce.should.be.true(); | ||
requestStub.args[0][0].should.eql("/auth/login"); | ||
/Unsupported login type/.test(result.warn.args[0][0]).should.be.true; | ||
/Unsupported login type/.test(result.warn.args[0][0]).should.be.true(); | ||
done(); | ||
@@ -94,6 +94,6 @@ }).otherwise(done); | ||
command({},result).then(function() { | ||
requestStub.calledOnce.should.be.true; | ||
requestStub.calledOnce.should.be.true(); | ||
requestStub.args[0][0].should.eql("/auth/login"); | ||
result.log.called.should.be.false; | ||
result.warn.called.should.be.false; | ||
result.log.called.should.be.false(); | ||
result.warn.called.should.be.false(); | ||
done(); | ||
@@ -107,8 +107,8 @@ }).otherwise(done); | ||
command({},result).then(function() { | ||
config.tokens.calledOnce.should.be.true; | ||
config.tokens.calledOnce.should.be.true(); | ||
should.not.exist(config.tokens.args[0][0]); | ||
result.log.called.should.be.false; | ||
result.warn.called.should.be.true; | ||
/Login failed/.test(result.warn.args[0][0]).should.be.true; | ||
result.log.called.should.be.false(); | ||
result.warn.called.should.be.true(); | ||
/Login failed/.test(result.warn.args[0][0]).should.be.true(); | ||
done(); | ||
@@ -122,7 +122,7 @@ }).otherwise(done); | ||
command({},result).then(function() { | ||
config.tokens.calledOnce.should.be.true; | ||
config.tokens.calledOnce.should.be.true(); | ||
should.not.exist(config.tokens.args[0][0]); | ||
result.log.called.should.be.false; | ||
result.warn.called.should.be.true; | ||
/Login failed/.test(result.warn.args[0][0]).should.be.true; | ||
result.log.called.should.be.false(); | ||
result.warn.called.should.be.true(); | ||
/Login failed/.test(result.warn.args[0][0]).should.be.true(); | ||
done(); | ||
@@ -129,0 +129,0 @@ }).otherwise(done); |
@@ -51,3 +51,3 @@ /** | ||
} | ||
result.log.called.should.be.true; | ||
result.log.called.should.be.true(); | ||
done(); | ||
@@ -59,5 +59,5 @@ }).otherwise(done); | ||
command({_:{}},result); | ||
result.help.called.should.be.true; | ||
result.help.called.should.be.true(); | ||
done(); | ||
}); | ||
}); |
@@ -33,50 +33,52 @@ /** | ||
}); | ||
it('reports no results when none match',function(done) { | ||
sinon.stub(httpRequest,"get").yields(null,{statusCode:200},JSON.stringify({rows:[]})); | ||
sinon.stub(httpRequest,"get").yields(null,{statusCode:200},JSON.stringify({"data":[]} )); | ||
command({_:[null,"testnode"]},result).then(function() { | ||
result.log.called.should.be.true; | ||
result.log.called.should.be.true(); | ||
result.log.args[0][0].should.eql("No results found"); | ||
done(); | ||
}).otherwise(done); | ||
}); | ||
it('lists matched modules',function(done) { | ||
it('lists results ordered by relevance',function(done) { | ||
sinon.stub(httpRequest,"get").yields(null,{statusCode:200}, | ||
JSON.stringify({rows:[ | ||
{key:["node-red","testnode","a random node"]}, | ||
{key:["node-red","another","a testnode match"]}, | ||
{key:["node-red","not a match","not a match"]} | ||
]}) | ||
JSON.stringify({ | ||
"data":[ | ||
{ "name":"another-node", "description":"a testnode - THREE" }, | ||
{ "name":"testnode", "description":"a test node - ONE" }, | ||
{ "name":"@scoped/testnode", "description":"once more - TWO" } | ||
] | ||
}) | ||
); | ||
command({_:[null,"testnode"]},result).then(function() { | ||
result.log.calledTwice.should.be.true; | ||
/testnode/.test(result.log.args[0][0]).should.be.true; | ||
/testnode/.test(result.log.args[1][0]).should.be.true; | ||
result.log.args.length.should.equal(3); | ||
/ONE/.test(result.log.args[0][0]).should.be.true(); | ||
/TWO/.test(result.log.args[1][0]).should.be.true(); | ||
/THREE/.test(result.log.args[2][0]).should.be.true(); | ||
done(); | ||
}).otherwise(done); | ||
}); | ||
it('reports error response',function(done) { | ||
sinon.stub(httpRequest,"get").yields("testError",{statusCode:200},JSON.stringify({rows:[]})); | ||
command({_:[null,"testnode"]},result).then(function() { | ||
result.log.called.should.be.false; | ||
result.warn.called.should.be.true; | ||
result.log.called.should.be.false(); | ||
result.warn.called.should.be.true(); | ||
result.warn.args[0][0].should.eql("testError"); | ||
done(); | ||
}).otherwise(done); | ||
}); | ||
it('reports unexpected http response',function(done) { | ||
sinon.stub(httpRequest,"get").yields(null,{statusCode:101},"testError"); | ||
command({_:[null,"testnode"]},result).then(function() { | ||
result.log.called.should.be.false; | ||
result.warn.called.should.be.true; | ||
result.log.called.should.be.false(); | ||
result.warn.called.should.be.true(); | ||
result.warn.args[0][0].should.eql("101: testError"); | ||
@@ -86,9 +88,9 @@ done(); | ||
}); | ||
it('displays command help if node not specified', function(done) { | ||
command({_:{}},result); | ||
result.help.called.should.be.true; | ||
result.help.called.should.be.true(); | ||
done(); | ||
}); | ||
}); |
@@ -42,6 +42,6 @@ /** | ||
command({_:[]},result); | ||
config.target.called.should.be.true; | ||
config.target.called.should.be.true(); | ||
config.target.args[0].should.have.lengthOf(0); | ||
result.log.called.should.be.true; | ||
/http\:\/\/test\.example\.com/.test(result.log.args[0][0]).should.be.true; | ||
result.log.called.should.be.true(); | ||
/http\:\/\/test\.example\.com/.test(result.log.args[0][0]).should.be.true(); | ||
done(); | ||
@@ -52,6 +52,6 @@ }); | ||
command({_:[null,"http://newtarget.example.com"]},result); | ||
config.target.called.should.be.true; | ||
config.target.called.should.be.true(); | ||
config.target.args[0][0].should.eql("http://newtarget.example.com"); | ||
result.log.called.should.be.true; | ||
/http\:\/\/newtarget\.example\.com/.test(result.log.args[0][0]).should.be.true; | ||
result.log.called.should.be.true(); | ||
/http\:\/\/newtarget\.example\.com/.test(result.log.args[0][0]).should.be.true(); | ||
done(); | ||
@@ -62,4 +62,4 @@ }); | ||
command({_:[null,"ftp://newtarget.example.com"]},result); | ||
config.target.called.should.be.false; | ||
result.warn.called.should.be.true; | ||
config.target.called.should.be.false(); | ||
result.warn.called.should.be.true(); | ||
done(); | ||
@@ -69,3 +69,3 @@ }); | ||
command({_:[null,"http://newtarget.example.com/"]},result); | ||
config.target.called.should.be.true; | ||
config.target.called.should.be.true(); | ||
config.target.args[0][0].should.eql("http://newtarget.example.com"); | ||
@@ -72,0 +72,0 @@ done(); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
85414
39
1801
0
39
Updatedcolors@^1.4.0
Updatedminimist@^1.2.5