mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Documentation updates for node-red and runtime modules
This commit is contained in:
parent
bc02c9573c
commit
0b5e4f2dd7
@ -430,7 +430,11 @@ module.exports = function(grunt) {
|
|||||||
},
|
},
|
||||||
jsdoc : {
|
jsdoc : {
|
||||||
runtimeAPI: {
|
runtimeAPI: {
|
||||||
src: 'packages/node_modules/@node-red/runtime/lib/api/*.js',
|
src: [
|
||||||
|
'packages/node_modules/node-red/lib/red.js',
|
||||||
|
'packages/node_modules/@node-red/runtime/lib/index.js',
|
||||||
|
'packages/node_modules/@node-red/runtime/lib/api/*.js',
|
||||||
|
],
|
||||||
options: {
|
options: {
|
||||||
destination: 'docs',
|
destination: 'docs',
|
||||||
configure: './jsdoc.json'
|
configure: './jsdoc.json'
|
||||||
@ -449,7 +453,8 @@ module.exports = function(grunt) {
|
|||||||
options: {
|
options: {
|
||||||
separators: true
|
separators: true
|
||||||
},
|
},
|
||||||
src: 'packages/node_modules/@node-red/runtime/lib/api/*.js',
|
src: ['packages/node_modules/@node-red/runtime/lib/index.js',
|
||||||
|
'packages/node_modules/@node-red/runtime/lib/api/*.js'],
|
||||||
dest: 'packages/node_modules/@node-red/runtime/docs/api.md'
|
dest: 'packages/node_modules/@node-red/runtime/docs/api.md'
|
||||||
},
|
},
|
||||||
nodeREDUtil: {
|
nodeREDUtil: {
|
||||||
|
@ -28,7 +28,7 @@ var adminApp;
|
|||||||
var server;
|
var server;
|
||||||
var editor;
|
var editor;
|
||||||
|
|
||||||
function init(_server,settings,storage,runtimeAPI) {
|
function init(settings,_server,storage,runtimeAPI) {
|
||||||
server = _server;
|
server = _server;
|
||||||
if (settings.httpAdminRoot !== false) {
|
if (settings.httpAdminRoot !== false) {
|
||||||
adminApp = express();
|
adminApp = express();
|
||||||
@ -100,6 +100,5 @@ module.exports = {
|
|||||||
auth: {
|
auth: {
|
||||||
needsPermission: auth.needsPermission
|
needsPermission: auth.needsPermission
|
||||||
},
|
},
|
||||||
get adminApp() { return adminApp; },
|
get adminApp() { return adminApp; }
|
||||||
get server() { return server; }
|
|
||||||
};
|
};
|
||||||
|
@ -98,7 +98,9 @@ function createNodeApi(node) {
|
|||||||
register: function(type) {
|
register: function(type) {
|
||||||
return runtime.library.register(node.id,type);
|
return runtime.library.register(node.id,type);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
httpNode: runtime.nodeApp,
|
||||||
|
server: runtime.server
|
||||||
}
|
}
|
||||||
copyObjectProperties(runtime.nodes,red.nodes,["createNode","getNode","eachNode","addCredentials","getCredentials","deleteCredentials" ]);
|
copyObjectProperties(runtime.nodes,red.nodes,["createNode","getNode","eachNode","addCredentials","getCredentials","deleteCredentials" ]);
|
||||||
red.nodes.registerType = function(type,constructor,opts) {
|
red.nodes.registerType = function(type,constructor,opts) {
|
||||||
@ -109,8 +111,6 @@ function createNodeApi(node) {
|
|||||||
if (runtime.adminApi) {
|
if (runtime.adminApi) {
|
||||||
red.auth = runtime.adminApi.auth;
|
red.auth = runtime.adminApi.auth;
|
||||||
red.httpAdmin = runtime.adminApi.adminApp;
|
red.httpAdmin = runtime.adminApi.adminApp;
|
||||||
red.httpNode = runtime.nodeApp;
|
|
||||||
red.server = runtime.server;
|
|
||||||
} else {
|
} else {
|
||||||
//TODO: runtime.adminApi is always stubbed if not enabled, so this block
|
//TODO: runtime.adminApi is always stubbed if not enabled, so this block
|
||||||
// is unused - but may be needed for the unit tests
|
// is unused - but may be needed for the unit tests
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace RED.comms
|
* This is the comms subsystem of the runtime.
|
||||||
|
* @mixin @node-red/runtime_comms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,7 +90,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {CommsConnection} opts.client - the client connection
|
* @param {CommsConnection} opts.client - the client connection
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.comms
|
* @memberof @node-red/runtime_comms
|
||||||
*/
|
*/
|
||||||
addConnection: function(opts) {
|
addConnection: function(opts) {
|
||||||
connections.push(opts.client);
|
connections.push(opts.client);
|
||||||
@ -102,7 +103,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {CommsConnection} opts.client - the client connection
|
* @param {CommsConnection} opts.client - the client connection
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.comms
|
* @memberof @node-red/runtime_comms
|
||||||
*/
|
*/
|
||||||
removeConnection: function(opts) {
|
removeConnection: function(opts) {
|
||||||
for (var i=0;i<connections.length;i++) {
|
for (var i=0;i<connections.length;i++) {
|
||||||
@ -123,7 +124,7 @@ var api = module.exports = {
|
|||||||
* @param {CommsConnection} opts.client - the client connection
|
* @param {CommsConnection} opts.client - the client connection
|
||||||
* @param {String} opts.topic - the topic to subscribe to
|
* @param {String} opts.topic - the topic to subscribe to
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.comms
|
* @memberof @node-red/runtime_comms
|
||||||
*/
|
*/
|
||||||
subscribe: function(opts) {
|
subscribe: function(opts) {
|
||||||
var re = new RegExp("^"+opts.topic.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g,"\\$1").replace(/\+/g,"[^/]+").replace(/\/#$/,"(\/.*)?")+"$");
|
var re = new RegExp("^"+opts.topic.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g,"\\$1").replace(/\+/g,"[^/]+").replace(/\/#$/,"(\/.*)?")+"$");
|
||||||
@ -142,7 +143,7 @@ var api = module.exports = {
|
|||||||
* @param {CommsConnection} opts.client - the client connection
|
* @param {CommsConnection} opts.client - the client connection
|
||||||
* @param {String} opts.topic - the topic to unsubscribe from
|
* @param {String} opts.topic - the topic to unsubscribe from
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.comms
|
* @memberof @node-red/runtime_comms
|
||||||
*/
|
*/
|
||||||
unsubscribe: function(opts) {}
|
unsubscribe: function(opts) {}
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace RED.context
|
* @mixin @node-red/runtime_context
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var runtime;
|
var runtime;
|
||||||
@ -69,7 +69,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.key - the context key
|
* @param {String} opts.key - the context key
|
||||||
|
|
||||||
* @return {Promise} - the node information
|
* @return {Promise} - the node information
|
||||||
* @memberof RED.context
|
* @memberof @node-red/runtime_context
|
||||||
*/
|
*/
|
||||||
getValue: function(opts) {
|
getValue: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -163,7 +163,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.key - the context key
|
* @param {String} opts.key - the context key
|
||||||
|
|
||||||
* @return {Promise} - the node information
|
* @return {Promise} - the node information
|
||||||
* @memberof RED.context
|
* @memberof @node-red/runtime_context
|
||||||
*/
|
*/
|
||||||
delete: function(opts) {
|
delete: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace RED.flows
|
* @mixin @node-red/runtime_flows
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +44,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @return {Promise<Flows>} - the active flow configuration
|
* @return {Promise<Flows>} - the active flow configuration
|
||||||
* @memberof RED.flows
|
* @memberof @node-red/runtime_flows
|
||||||
*/
|
*/
|
||||||
getFlows: function(opts) {
|
getFlows: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -57,7 +57,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @return {Promise<Flows>} - the active flow configuration
|
* @return {Promise<Flows>} - the active flow configuration
|
||||||
* @memberof RED.flows
|
* @memberof @node-red/runtime_flows
|
||||||
*/
|
*/
|
||||||
setFlows: function(opts) {
|
setFlows: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -99,7 +99,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {Object} opts.flow - the flow to add
|
* @param {Object} opts.flow - the flow to add
|
||||||
* @return {Promise<String>} - the id of the added flow
|
* @return {Promise<String>} - the id of the added flow
|
||||||
* @memberof RED.flows
|
* @memberof @node-red/runtime_flows
|
||||||
*/
|
*/
|
||||||
addFlow: function(opts) {
|
addFlow: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -123,7 +123,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {Object} opts.id - the id of the flow to retrieve
|
* @param {Object} opts.id - the id of the flow to retrieve
|
||||||
* @return {Promise<Flow>} - the active flow configuration
|
* @return {Promise<Flow>} - the active flow configuration
|
||||||
* @memberof RED.flows
|
* @memberof @node-red/runtime_flows
|
||||||
*/
|
*/
|
||||||
getFlow: function(opts) {
|
getFlow: function(opts) {
|
||||||
return new Promise(function (resolve,reject) {
|
return new Promise(function (resolve,reject) {
|
||||||
@ -148,7 +148,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts.id - the id of the flow to update
|
* @param {Object} opts.id - the id of the flow to update
|
||||||
* @param {Object} opts.flow - the flow configuration
|
* @param {Object} opts.flow - the flow configuration
|
||||||
* @return {Promise<String>} - the id of the updated flow
|
* @return {Promise<String>} - the id of the updated flow
|
||||||
* @memberof RED.flows
|
* @memberof @node-red/runtime_flows
|
||||||
*/
|
*/
|
||||||
updateFlow: function(opts) {
|
updateFlow: function(opts) {
|
||||||
return new Promise(function (resolve,reject) {
|
return new Promise(function (resolve,reject) {
|
||||||
@ -185,7 +185,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {Object} opts.id - the id of the flow to delete
|
* @param {Object} opts.id - the id of the flow to delete
|
||||||
* @return {Promise} - resolves if successful
|
* @return {Promise} - resolves if successful
|
||||||
* @memberof RED.flows
|
* @memberof @node-red/runtime_flows
|
||||||
*/
|
*/
|
||||||
deleteFlow: function(opts) {
|
deleteFlow: function(opts) {
|
||||||
return new Promise(function (resolve,reject) {
|
return new Promise(function (resolve,reject) {
|
||||||
@ -222,7 +222,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.type - the node type to return the credential information for
|
* @param {String} opts.type - the node type to return the credential information for
|
||||||
* @param {String} opts.id - the node id
|
* @param {String} opts.id - the node id
|
||||||
* @return {Promise<Object>} - the safe credentials
|
* @return {Promise<Object>} - the safe credentials
|
||||||
* @memberof RED.flows
|
* @memberof @node-red/runtime_flows
|
||||||
*/
|
*/
|
||||||
getNodeCredentials: function(opts) {
|
getNodeCredentials: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
|
@ -17,13 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
var runtime;
|
var runtime;
|
||||||
/**
|
|
||||||
* This module provides the core runtime component of Node-RED.
|
|
||||||
* It does *not* include the Node-RED editor. All interaction with
|
|
||||||
* this module is done using the api provided.
|
|
||||||
*
|
|
||||||
* @namespace RED
|
|
||||||
*/
|
|
||||||
var api = module.exports = {
|
var api = module.exports = {
|
||||||
init: function(_runtime) {
|
init: function(_runtime) {
|
||||||
runtime = _runtime;
|
runtime = _runtime;
|
||||||
@ -44,31 +38,10 @@ var api = module.exports = {
|
|||||||
projects: require("./projects"),
|
projects: require("./projects"),
|
||||||
context: require("./context"),
|
context: require("./context"),
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the runtime is started
|
|
||||||
* @param {Object} opts
|
|
||||||
* @param {User} opts.user - the user calling the api
|
|
||||||
* @return {Promise<Boolean>} - whether the runtime is started
|
|
||||||
* @memberof RED
|
|
||||||
*/
|
|
||||||
isStarted: function(opts) {
|
isStarted: function(opts) {
|
||||||
return Promise.resolve(runtime.isStarted());
|
return Promise.resolve(runtime.isStarted());
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns version number of the runtime
|
|
||||||
* @param {Object} opts
|
|
||||||
* @param {User} opts.user - the user calling the api
|
|
||||||
* @return {Promise<String>} - the runtime version number
|
|
||||||
* @memberof RED
|
|
||||||
*/
|
|
||||||
version: function(opts) {
|
version: function(opts) {
|
||||||
return Promise.resolve(runtime.version());
|
return Promise.resolve(runtime.version());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A user accessing the API
|
|
||||||
* @typedef User
|
|
||||||
* @type {object}
|
|
||||||
*/
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace RED.library
|
* @mixin @node-red/runtime_library
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var runtime;
|
var runtime;
|
||||||
@ -32,7 +32,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.type - the type of entry
|
* @param {String} opts.type - the type of entry
|
||||||
* @param {String} opts.path - the path of the entry
|
* @param {String} opts.path - the path of the entry
|
||||||
* @return {Promise<String|Object>} - resolves when complete
|
* @return {Promise<String|Object>} - resolves when complete
|
||||||
* @memberof RED.library
|
* @memberof @node-red/runtime_library
|
||||||
*/
|
*/
|
||||||
getEntry: function(opts) {
|
getEntry: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -71,7 +71,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts.meta - any meta data associated with the entry
|
* @param {Object} opts.meta - any meta data associated with the entry
|
||||||
* @param {String} opts.body - the body of the entry
|
* @param {String} opts.body - the body of the entry
|
||||||
* @return {Promise} - resolves when complete
|
* @return {Promise} - resolves when complete
|
||||||
* @memberof RED.library
|
* @memberof @node-red/runtime_library
|
||||||
*/
|
*/
|
||||||
saveEntry: function(opts) {
|
saveEntry: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -98,7 +98,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.type - the type of entry
|
* @param {String} opts.type - the type of entry
|
||||||
* @return {Promise<Object>} - the entry listing
|
* @return {Promise<Object>} - the entry listing
|
||||||
* @memberof RED.library
|
* @memberof @node-red/runtime_library
|
||||||
*/
|
*/
|
||||||
getEntries: function(opts) {
|
getEntries: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace RED.nodes
|
* @mixin @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
@ -49,7 +49,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.id - the id of the node set to return
|
* @param {String} opts.id - the id of the node set to return
|
||||||
* @return {Promise<NodeInfo>} - the node information
|
* @return {Promise<NodeInfo>} - the node information
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
getNodeInfo: function(opts) {
|
getNodeInfo: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -74,7 +74,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @return {Promise<NodeList>} - the list of node modules
|
* @return {Promise<NodeList>} - the list of node modules
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
getNodeList: function(opts) {
|
getNodeList: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -90,7 +90,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the node set to return
|
* @param {String} opts.id - the id of the node set to return
|
||||||
* @param {String} opts.lang - the locale language to return
|
* @param {String} opts.lang - the locale language to return
|
||||||
* @return {Promise<String>} - the node html content
|
* @return {Promise<String>} - the node html content
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
getNodeConfig: function(opts) {
|
getNodeConfig: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -115,7 +115,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.lang - the locale language to return
|
* @param {String} opts.lang - the locale language to return
|
||||||
* @return {Promise<String>} - the node html content
|
* @return {Promise<String>} - the node html content
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
getNodeConfigs: function(opts) {
|
getNodeConfigs: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -130,7 +130,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.module - the id of the module to return
|
* @param {String} opts.module - the id of the module to return
|
||||||
* @return {Promise<ModuleInfo>} - the node module info
|
* @return {Promise<ModuleInfo>} - the node module info
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
getModuleInfo: function(opts) {
|
getModuleInfo: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -155,7 +155,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.module - the id of the module to install
|
* @param {String} opts.module - the id of the module to install
|
||||||
* @param {String} opts.version - (optional) the version of the module to install
|
* @param {String} opts.version - (optional) the version of the module to install
|
||||||
* @return {Promise<ModuleInfo>} - the node module info
|
* @return {Promise<ModuleInfo>} - the node module info
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
addModule: function(opts) {
|
addModule: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -210,7 +210,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.module - the id of the module to remove
|
* @param {String} opts.module - the id of the module to remove
|
||||||
* @return {Promise} - resolves when complete
|
* @return {Promise} - resolves when complete
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
removeModule: function(opts) {
|
removeModule: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -253,7 +253,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.module - the id of the module to enable or disable
|
* @param {String} opts.module - the id of the module to enable or disable
|
||||||
* @param {String} opts.enabled - whether the module should be enabled or disabled
|
* @param {String} opts.enabled - whether the module should be enabled or disabled
|
||||||
* @return {Promise<ModuleInfo>} - the module info object
|
* @return {Promise<ModuleInfo>} - the module info object
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
setModuleState: function(opts) {
|
setModuleState: function(opts) {
|
||||||
var mod = opts.module;
|
var mod = opts.module;
|
||||||
@ -301,7 +301,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the node-set to enable or disable
|
* @param {String} opts.id - the id of the node-set to enable or disable
|
||||||
* @param {String} opts.enabled - whether the module should be enabled or disabled
|
* @param {String} opts.enabled - whether the module should be enabled or disabled
|
||||||
* @return {Promise<ModuleInfo>} - the module info object
|
* @return {Promise<ModuleInfo>} - the module info object
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
setNodeSetState: function(opts) {
|
setNodeSetState: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -348,7 +348,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {User} opts.lang - the i18n language to return. If not set, uses runtime default (en-US)
|
* @param {User} opts.lang - the i18n language to return. If not set, uses runtime default (en-US)
|
||||||
* @return {Promise<Object>} - the message catalogs
|
* @return {Promise<Object>} - the message catalogs
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
getModuleCatalogs: function(opts) {
|
getModuleCatalogs: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -377,7 +377,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.module - the module
|
* @param {User} opts.module - the module
|
||||||
* @param {User} opts.lang - the i18n language to return. If not set, uses runtime default (en-US)
|
* @param {User} opts.lang - the i18n language to return. If not set, uses runtime default (en-US)
|
||||||
* @return {Promise<Object>} - the message catalog
|
* @return {Promise<Object>} - the message catalog
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
getModuleCatalog: function(opts) {
|
getModuleCatalog: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -398,7 +398,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @return {Promise<IconList>} - the list of all icons
|
* @return {Promise<IconList>} - the list of all icons
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
getIconList: function(opts) {
|
getIconList: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -414,7 +414,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.module - the id of the module requesting the icon
|
* @param {String} opts.module - the id of the module requesting the icon
|
||||||
* @param {String} opts.icon - the name of the icon
|
* @param {String} opts.icon - the name of the icon
|
||||||
* @return {Promise<Buffer>} - the icon file as a Buffer or null if no icon available
|
* @return {Promise<Buffer>} - the icon file as a Buffer or null if no icon available
|
||||||
* @memberof RED.nodes
|
* @memberof @node-red/runtime_nodes
|
||||||
*/
|
*/
|
||||||
getIcon: function(opts) {
|
getIcon: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace RED.projects
|
* @mixin @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var runtime;
|
var runtime;
|
||||||
@ -33,7 +33,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
listProjects: function(opts) {
|
listProjects: function(opts) {
|
||||||
return runtime.storage.projects.listProjects(opts.user).then(function(list) {
|
return runtime.storage.projects.listProjects(opts.user).then(function(list) {
|
||||||
@ -57,7 +57,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {Object} opts.project - the project information
|
* @param {Object} opts.project - the project information
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
createProject: function(opts) {
|
createProject: function(opts) {
|
||||||
return runtime.storage.projects.createProject(opts.user, opts.project)
|
return runtime.storage.projects.createProject(opts.user, opts.project)
|
||||||
@ -70,7 +70,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project to initialise
|
* @param {String} opts.id - the id of the project to initialise
|
||||||
* @param {Object} opts.project - the project information
|
* @param {Object} opts.project - the project information
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
initialiseProject: function(opts) {
|
initialiseProject: function(opts) {
|
||||||
// Initialised set when creating default files for an empty repo
|
// Initialised set when creating default files for an empty repo
|
||||||
@ -82,7 +82,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @return {Promise<Object>} - the active project
|
* @return {Promise<Object>} - the active project
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getActiveProject: function(opts) {
|
getActiveProject: function(opts) {
|
||||||
return Promise.resolve(runtime.storage.projects.getActiveProject(opts.user));
|
return Promise.resolve(runtime.storage.projects.getActiveProject(opts.user));
|
||||||
@ -94,7 +94,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.id - the id of the project to activate
|
* @param {String} opts.id - the id of the project to activate
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
setActiveProject: function(opts) {
|
setActiveProject: function(opts) {
|
||||||
var currentProject = runtime.storage.projects.getActiveProject(opts.user);
|
var currentProject = runtime.storage.projects.getActiveProject(opts.user);
|
||||||
@ -111,7 +111,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.id - the id of the project to get
|
* @param {String} opts.id - the id of the project to get
|
||||||
* @return {Promise<Object>} - the project metadata
|
* @return {Promise<Object>} - the project metadata
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getProject: function(opts) {
|
getProject: function(opts) {
|
||||||
return runtime.storage.projects.getProject(opts.user, opts.id)
|
return runtime.storage.projects.getProject(opts.user, opts.id)
|
||||||
@ -124,7 +124,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project to update
|
* @param {String} opts.id - the id of the project to update
|
||||||
* @param {Object} opts.project - the project information
|
* @param {Object} opts.project - the project information
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
updateProject: function(opts) {
|
updateProject: function(opts) {
|
||||||
return runtime.storage.projects.updateProject(opts.user, opts.id, opts.project);
|
return runtime.storage.projects.updateProject(opts.user, opts.id, opts.project);
|
||||||
@ -136,7 +136,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.id - the id of the project to update
|
* @param {String} opts.id - the id of the project to update
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
deleteProject: function(opts) {
|
deleteProject: function(opts) {
|
||||||
return runtime.storage.projects.deleteProject(opts.user, opts.id);
|
return runtime.storage.projects.deleteProject(opts.user, opts.id);
|
||||||
@ -149,7 +149,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @param {Boolean} opts.remote - whether to include status of remote repos
|
* @param {Boolean} opts.remote - whether to include status of remote repos
|
||||||
* @return {Promise<Object>} - the project status
|
* @return {Promise<Object>} - the project status
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getStatus: function(opts) {
|
getStatus: function(opts) {
|
||||||
return runtime.storage.projects.getStatus(opts.user, opts.id, opts.remote)
|
return runtime.storage.projects.getStatus(opts.user, opts.id, opts.remote)
|
||||||
@ -162,7 +162,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @param {Boolean} opts.remote - whether to return remote branches (true) or local (false)
|
* @param {Boolean} opts.remote - whether to return remote branches (true) or local (false)
|
||||||
* @return {Promise<Object>} - a list of the local branches
|
* @return {Promise<Object>} - a list of the local branches
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getBranches: function(opts) {
|
getBranches: function(opts) {
|
||||||
return runtime.storage.projects.getBranches(opts.user, opts.id, opts.remote);
|
return runtime.storage.projects.getBranches(opts.user, opts.id, opts.remote);
|
||||||
@ -175,7 +175,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @param {String} opts.branch - the name of the branch
|
* @param {String} opts.branch - the name of the branch
|
||||||
* @return {Promise<Object>} - the status of the branch
|
* @return {Promise<Object>} - the status of the branch
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getBranchStatus: function(opts) {
|
getBranchStatus: function(opts) {
|
||||||
return runtime.storage.projects.getBranchStatus(opts.user, opts.id, opts.branch);
|
return runtime.storage.projects.getBranchStatus(opts.user, opts.id, opts.branch);
|
||||||
@ -189,7 +189,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.branch - the name of the branch
|
* @param {String} opts.branch - the name of the branch
|
||||||
* @param {Boolean} opts.create - whether to create the branch if it doesn't exist
|
* @param {Boolean} opts.create - whether to create the branch if it doesn't exist
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
setBranch: function(opts) {
|
setBranch: function(opts) {
|
||||||
return runtime.storage.projects.setBranch(opts.user, opts.id, opts.branch, opts.create)
|
return runtime.storage.projects.setBranch(opts.user, opts.id, opts.branch, opts.create)
|
||||||
@ -203,7 +203,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.branch - the name of the branch
|
* @param {String} opts.branch - the name of the branch
|
||||||
* @param {Boolean} opts.force - whether to force delete
|
* @param {Boolean} opts.force - whether to force delete
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
deleteBranch: function(opts) {
|
deleteBranch: function(opts) {
|
||||||
return runtime.storage.projects.deleteBranch(opts.user, opts.id, opts.branch, false, opts.force);
|
return runtime.storage.projects.deleteBranch(opts.user, opts.id, opts.branch, false, opts.force);
|
||||||
@ -216,7 +216,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @param {String} opts.message - the message to associate with the commit
|
* @param {String} opts.message - the message to associate with the commit
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
commit: function(opts) {
|
commit: function(opts) {
|
||||||
return runtime.storage.projects.commit(opts.user, opts.id,{message: opts.message});
|
return runtime.storage.projects.commit(opts.user, opts.id,{message: opts.message});
|
||||||
@ -229,7 +229,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @param {String} opts.sha - the sha of the commit to return
|
* @param {String} opts.sha - the sha of the commit to return
|
||||||
* @return {Promise<Object>} - the commit details
|
* @return {Promise<Object>} - the commit details
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getCommit: function(opts) {
|
getCommit: function(opts) {
|
||||||
return runtime.storage.projects.getCommit(opts.user, opts.id, opts.sha);
|
return runtime.storage.projects.getCommit(opts.user, opts.id, opts.sha);
|
||||||
@ -243,7 +243,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.limit - limit how many to return
|
* @param {String} opts.limit - limit how many to return
|
||||||
* @param {String} opts.before - id of the commit to work back from
|
* @param {String} opts.before - id of the commit to work back from
|
||||||
* @return {Promise<Array>} - an array of commits
|
* @return {Promise<Array>} - an array of commits
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getCommits: function(opts) {
|
getCommits: function(opts) {
|
||||||
return runtime.storage.projects.getCommits(opts.user, opts.id, {
|
return runtime.storage.projects.getCommits(opts.user, opts.id, {
|
||||||
@ -258,7 +258,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
abortMerge: function(opts) {
|
abortMerge: function(opts) {
|
||||||
return runtime.storage.projects.abortMerge(opts.user, opts.id);
|
return runtime.storage.projects.abortMerge(opts.user, opts.id);
|
||||||
@ -272,7 +272,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.path - the path of the file being merged
|
* @param {String} opts.path - the path of the file being merged
|
||||||
* @param {String} opts.resolutions - how to resolve the merge conflict
|
* @param {String} opts.resolutions - how to resolve the merge conflict
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
resolveMerge: function(opts) {
|
resolveMerge: function(opts) {
|
||||||
return runtime.storage.projects.resolveMerge(opts.user, opts.id, opts.path, opts.resolution);
|
return runtime.storage.projects.resolveMerge(opts.user, opts.id, opts.path, opts.resolution);
|
||||||
@ -284,7 +284,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @return {Promise<Object>} - the file listing
|
* @return {Promise<Object>} - the file listing
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getFiles: function(opts) {
|
getFiles: function(opts) {
|
||||||
return runtime.storage.projects.getFiles(opts.user, opts.id);
|
return runtime.storage.projects.getFiles(opts.user, opts.id);
|
||||||
@ -298,7 +298,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.path - the path of the file
|
* @param {String} opts.path - the path of the file
|
||||||
* @param {String} opts.tree - the version control tree to use
|
* @param {String} opts.tree - the version control tree to use
|
||||||
* @return {Promise<String>} - the content of the file
|
* @return {Promise<String>} - the content of the file
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getFile: function(opts) {
|
getFile: function(opts) {
|
||||||
return runtime.storage.projects.getFile(opts.user, opts.id,opts.path,opts.tree);
|
return runtime.storage.projects.getFile(opts.user, opts.id,opts.path,opts.tree);
|
||||||
@ -311,7 +311,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @param {String|Array} opts.path - the path of the file, or an array of paths
|
* @param {String|Array} opts.path - the path of the file, or an array of paths
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
stageFile: function(opts) {
|
stageFile: function(opts) {
|
||||||
return runtime.storage.projects.stageFile(opts.user, opts.id, opts.path);
|
return runtime.storage.projects.stageFile(opts.user, opts.id, opts.path);
|
||||||
@ -324,7 +324,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @param {String} opts.path - the path of the file. If not set, all staged files are unstaged
|
* @param {String} opts.path - the path of the file. If not set, all staged files are unstaged
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
unstageFile: function(opts) {
|
unstageFile: function(opts) {
|
||||||
return runtime.storage.projects.unstageFile(opts.user, opts.id, opts.path);
|
return runtime.storage.projects.unstageFile(opts.user, opts.id, opts.path);
|
||||||
@ -337,7 +337,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @param {String} opts.path - the path of the file
|
* @param {String} opts.path - the path of the file
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
revertFile: function(opts) {
|
revertFile: function(opts) {
|
||||||
return runtime.storage.projects.revertFile(opts.user, opts.id,opts.path)
|
return runtime.storage.projects.revertFile(opts.user, opts.id,opts.path)
|
||||||
@ -351,7 +351,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.path - the path of the file
|
* @param {String} opts.path - the path of the file
|
||||||
* @param {String} opts.type - the type of diff
|
* @param {String} opts.type - the type of diff
|
||||||
* @return {Promise<Object>} - the requested diff
|
* @return {Promise<Object>} - the requested diff
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getFileDiff: function(opts) {
|
getFileDiff: function(opts) {
|
||||||
return runtime.storage.projects.getFileDiff(opts.user, opts.id, opts.path, opts.type);
|
return runtime.storage.projects.getFileDiff(opts.user, opts.id, opts.path, opts.type);
|
||||||
@ -363,7 +363,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @return {Promise<Object>} - a list of project remotes
|
* @return {Promise<Object>} - a list of project remotes
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
getRemotes: function(opts) {
|
getRemotes: function(opts) {
|
||||||
return runtime.storage.projects.getRemotes(opts.user, opts.id);
|
return runtime.storage.projects.getRemotes(opts.user, opts.id);
|
||||||
@ -379,7 +379,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.remote.name - the name of the remote
|
* @param {String} opts.remote.name - the name of the remote
|
||||||
* @param {String} opts.remote.url - the url of the remote
|
* @param {String} opts.remote.url - the url of the remote
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
addRemote: function(opts) {
|
addRemote: function(opts) {
|
||||||
return runtime.storage.projects.addRemote(opts.user, opts.id, opts.remote)
|
return runtime.storage.projects.addRemote(opts.user, opts.id, opts.remote)
|
||||||
@ -392,7 +392,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.id - the id of the project
|
* @param {String} opts.id - the id of the project
|
||||||
* @param {String} opts.remote - the name of the remote
|
* @param {String} opts.remote - the name of the remote
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
removeRemote: function(opts) {
|
removeRemote: function(opts) {
|
||||||
return runtime.storage.projects.removeRemote(opts.user, opts.id, opts.remote);
|
return runtime.storage.projects.removeRemote(opts.user, opts.id, opts.remote);
|
||||||
@ -406,7 +406,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts.remote - the remote metadata
|
* @param {Object} opts.remote - the remote metadata
|
||||||
* @param {String} opts.remote.name - the name of the remote
|
* @param {String} opts.remote.name - the name of the remote
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
updateRemote: function(opts) {
|
updateRemote: function(opts) {
|
||||||
return runtime.storage.projects.updateRemote(opts.user, opts.id, opts.remote.name, opts.remote)
|
return runtime.storage.projects.updateRemote(opts.user, opts.id, opts.remote.name, opts.remote)
|
||||||
@ -417,7 +417,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
pull: function(opts) {
|
pull: function(opts) {
|
||||||
return runtime.storage.projects.pull(opts.user, opts.id, opts.remote, opts.track, opts.allowUnrelatedHistories);
|
return runtime.storage.projects.pull(opts.user, opts.id, opts.remote, opts.track, opts.allowUnrelatedHistories);
|
||||||
@ -431,7 +431,7 @@ var api = module.exports = {
|
|||||||
* @param {String} opts.remote - the name of the remote
|
* @param {String} opts.remote - the name of the remote
|
||||||
* @param {String} opts.track - whether to set the remote as the upstream
|
* @param {String} opts.track - whether to set the remote as the upstream
|
||||||
* @return {Promise<Object>} - resolves when complete
|
* @return {Promise<Object>} - resolves when complete
|
||||||
* @memberof RED.projects
|
* @memberof @node-red/runtime_projects
|
||||||
*/
|
*/
|
||||||
push: function(opts) {
|
push: function(opts) {
|
||||||
return runtime.storage.projects.push(opts.user, opts.id, opts.remote, opts.track);
|
return runtime.storage.projects.push(opts.user, opts.id, opts.remote, opts.track);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace RED.settings
|
* @mixin @node-red/runtime_settings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var util = require("util");
|
var util = require("util");
|
||||||
@ -61,7 +61,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @return {Promise<Object>} - the runtime settings
|
* @return {Promise<Object>} - the runtime settings
|
||||||
* @memberof RED.settings
|
* @memberof @node-red/runtime_settings
|
||||||
*/
|
*/
|
||||||
getRuntimeSettings: function(opts) {
|
getRuntimeSettings: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -126,7 +126,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @return {Promise<Object>} - the user settings
|
* @return {Promise<Object>} - the user settings
|
||||||
* @memberof RED.settings
|
* @memberof @node-red/runtime_settings
|
||||||
*/
|
*/
|
||||||
getUserSettings: function(opts) {
|
getUserSettings: function(opts) {
|
||||||
var username;
|
var username;
|
||||||
@ -144,7 +144,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {Object} opts.settings - the updates to the user settings
|
* @param {Object} opts.settings - the updates to the user settings
|
||||||
* @return {Promise<Object>} - the user settings
|
* @return {Promise<Object>} - the user settings
|
||||||
* @memberof RED.settings
|
* @memberof @node-red/runtime_settings
|
||||||
*/
|
*/
|
||||||
updateUserSettings: function(opts) {
|
updateUserSettings: function(opts) {
|
||||||
var username;
|
var username;
|
||||||
@ -179,7 +179,7 @@ var api = module.exports = {
|
|||||||
* @param {Object} opts
|
* @param {Object} opts
|
||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @return {Promise<Object>} - the user's ssh keys
|
* @return {Promise<Object>} - the user's ssh keys
|
||||||
* @memberof RED.settings
|
* @memberof @node-red/runtime_settings
|
||||||
*/
|
*/
|
||||||
getUserKeys: function(opts) {
|
getUserKeys: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -199,7 +199,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {User} opts.id - the id of the key to return
|
* @param {User} opts.id - the id of the key to return
|
||||||
* @return {Promise<String>} - the user's ssh public key
|
* @return {Promise<String>} - the user's ssh public key
|
||||||
* @memberof RED.settings
|
* @memberof @node-red/runtime_settings
|
||||||
*/
|
*/
|
||||||
getUserKey: function(opts) {
|
getUserKey: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -230,7 +230,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.comment - (option) a comment to associate with the key pair
|
* @param {User} opts.comment - (option) a comment to associate with the key pair
|
||||||
* @param {User} opts.size - (optional) the size of the key. Default: 2048
|
* @param {User} opts.size - (optional) the size of the key. Default: 2048
|
||||||
* @return {Promise<String>} - the id of the generated key
|
* @return {Promise<String>} - the id of the generated key
|
||||||
* @memberof RED.settings
|
* @memberof @node-red/runtime_settings
|
||||||
*/
|
*/
|
||||||
generateUserKey: function(opts) {
|
generateUserKey: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
@ -250,7 +250,7 @@ var api = module.exports = {
|
|||||||
* @param {User} opts.user - the user calling the api
|
* @param {User} opts.user - the user calling the api
|
||||||
* @param {User} opts.id - the id of the key to delete
|
* @param {User} opts.id - the id of the key to delete
|
||||||
* @return {Promise} - resolves when deleted
|
* @return {Promise} - resolves when deleted
|
||||||
* @memberof RED.settings
|
* @memberof @node-red/runtime_settings
|
||||||
*/
|
*/
|
||||||
removeUserKey: function(opts) {
|
removeUserKey: function(opts) {
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
|
105
packages/node_modules/@node-red/runtime/lib/index.js
vendored
105
packages/node_modules/@node-red/runtime/lib/index.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*!
|
||||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -31,8 +31,8 @@ var fs = require("fs");
|
|||||||
var os = require("os");
|
var os = require("os");
|
||||||
|
|
||||||
var redUtil = require("@node-red/util");
|
var redUtil = require("@node-red/util");
|
||||||
var log;
|
var log = redUtil.log;
|
||||||
var i18n;
|
var i18n = redUtil.i18n;
|
||||||
|
|
||||||
var runtimeMetricInterval = null;
|
var runtimeMetricInterval = null;
|
||||||
|
|
||||||
@ -48,18 +48,24 @@ var adminApi = {
|
|||||||
auth: {
|
auth: {
|
||||||
needsPermission: function() {}
|
needsPermission: function() {}
|
||||||
},
|
},
|
||||||
comms: {
|
|
||||||
publish: function() {}
|
|
||||||
},
|
|
||||||
adminApp: stubbedExpressApp,
|
adminApp: stubbedExpressApp,
|
||||||
server: {}
|
server: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
var nodeApp;
|
var nodeApp;
|
||||||
|
var server;
|
||||||
|
|
||||||
function init(userSettings,_adminApi) {
|
|
||||||
log = redUtil.log;
|
/**
|
||||||
i18n = redUtil.i18n;
|
* Initialise the runtime module.
|
||||||
|
* @param {Object} settings - the runtime settings object
|
||||||
|
* @param {HTTPServer} server - the http server instance for the server to use
|
||||||
|
* @param {AdminAPI} adminApi - an instance of @node-red/editor-api. <B>TODO</B>: This needs to be
|
||||||
|
* better abstracted.
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
*/
|
||||||
|
function init(userSettings,httpServer,_adminApi) {
|
||||||
|
server = httpServer;
|
||||||
userSettings.version = getVersion();
|
userSettings.version = getVersion();
|
||||||
settings.init(userSettings);
|
settings.init(userSettings);
|
||||||
|
|
||||||
@ -90,6 +96,12 @@ function getVersion() {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the runtime.
|
||||||
|
* @return {Promise} - resolves when the runtime is started. This does not mean the
|
||||||
|
* flows will be running as they are started asynchronously.
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
*/
|
||||||
function start() {
|
function start() {
|
||||||
|
|
||||||
return i18n.registerMessageCatalog("runtime",path.resolve(path.join(__dirname,"..","locales")),"runtime.json")
|
return i18n.registerMessageCatalog("runtime",path.resolve(path.join(__dirname,"..","locales")),"runtime.json")
|
||||||
@ -225,6 +237,11 @@ function reportMetrics() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the runtime.
|
||||||
|
* @return {Promise} - resolves when the runtime is stopped.
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
*/
|
||||||
function stop() {
|
function stop() {
|
||||||
if (runtimeMetricInterval) {
|
if (runtimeMetricInterval) {
|
||||||
clearInterval(runtimeMetricInterval);
|
clearInterval(runtimeMetricInterval);
|
||||||
@ -253,27 +270,89 @@ var runtime = {
|
|||||||
util: require("@node-red/util").util,
|
util: require("@node-red/util").util,
|
||||||
get adminApi() { return adminApi },
|
get adminApi() { return adminApi },
|
||||||
get nodeApp() { return nodeApp },
|
get nodeApp() { return nodeApp },
|
||||||
|
get server() { return server },
|
||||||
isStarted: function() {
|
isStarted: function() {
|
||||||
return started;
|
return started;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module provides the core runtime component of Node-RED.
|
||||||
|
* It does *not* include the Node-RED editor. All interaction with
|
||||||
|
* this module is done using the api provided.
|
||||||
|
*
|
||||||
|
* @namespace @node-red/runtime
|
||||||
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init: init,
|
init: init,
|
||||||
start: start,
|
start: start,
|
||||||
stop: stop,
|
stop: stop,
|
||||||
|
|
||||||
"_": runtime,
|
/**
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
* @mixes @node-red/runtime_comms
|
||||||
|
*/
|
||||||
comms: externalAPI.comms,
|
comms: externalAPI.comms,
|
||||||
|
/**
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
* @mixes @node-red/runtime_flows
|
||||||
|
*/
|
||||||
flows: externalAPI.flows,
|
flows: externalAPI.flows,
|
||||||
|
/**
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
* @mixes @node-red/runtime_library
|
||||||
|
*/
|
||||||
library: externalAPI.library,
|
library: externalAPI.library,
|
||||||
|
/**
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
* @mixes @node-red/runtime_nodes
|
||||||
|
*/
|
||||||
nodes: externalAPI.nodes,
|
nodes: externalAPI.nodes,
|
||||||
|
/**
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
* @mixes @node-red/runtime_settings
|
||||||
|
*/
|
||||||
settings: externalAPI.settings,
|
settings: externalAPI.settings,
|
||||||
|
/**
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
* @mixes @node-red/runtime_projects
|
||||||
|
*/
|
||||||
projects: externalAPI.projects,
|
projects: externalAPI.projects,
|
||||||
|
/**
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
* @mixes @node-red/runtime_context
|
||||||
|
*/
|
||||||
context: externalAPI.context,
|
context: externalAPI.context,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the runtime is started
|
||||||
|
* @param {Object} opts
|
||||||
|
* @param {User} opts.user - the user calling the api
|
||||||
|
* @return {Promise<Boolean>} - whether the runtime is started
|
||||||
|
* @function
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
*/
|
||||||
isStarted: externalAPI.isStarted,
|
isStarted: externalAPI.isStarted,
|
||||||
version: externalAPI.version
|
|
||||||
|
/**
|
||||||
|
* Returns version number of the runtime
|
||||||
|
* @param {Object} opts
|
||||||
|
* @param {User} opts.user - the user calling the api
|
||||||
|
* @return {Promise<String>} - the runtime version number
|
||||||
|
* @function
|
||||||
|
* @memberof @node-red/runtime
|
||||||
|
*/
|
||||||
|
version: externalAPI.version,
|
||||||
|
|
||||||
|
storage: storage,
|
||||||
|
events: events,
|
||||||
|
get httpNode() { return nodeApp },
|
||||||
|
get server() { return server }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A user accessing the API
|
||||||
|
* @typedef User
|
||||||
|
* @type {object}
|
||||||
|
*/
|
||||||
|
@ -26,7 +26,7 @@ var defaultFileSet = require("./defaultFileSet");
|
|||||||
var sshKeys = require("./ssh");
|
var sshKeys = require("./ssh");
|
||||||
var settings;
|
var settings;
|
||||||
var runtime;
|
var runtime;
|
||||||
var log;
|
var log = require("@node-red/util").log;
|
||||||
|
|
||||||
var projectsDir;
|
var projectsDir;
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ Project.prototype.initialise = function(user,data) {
|
|||||||
if (defaultFileSet.hasOwnProperty(file)) {
|
if (defaultFileSet.hasOwnProperty(file)) {
|
||||||
var path = fspath.join(project.path,file);
|
var path = fspath.join(project.path,file);
|
||||||
if (!fs.existsSync(path)) {
|
if (!fs.existsSync(path)) {
|
||||||
promises.push(util.writeFile(path,defaultFileSet[file](project, runtime)));
|
promises.push(util.writeFile(path,defaultFileSet[file](project)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -858,7 +858,7 @@ function createDefaultProject(user, project) {
|
|||||||
}
|
}
|
||||||
for (var file in defaultFileSet) {
|
for (var file in defaultFileSet) {
|
||||||
if (defaultFileSet.hasOwnProperty(file)) {
|
if (defaultFileSet.hasOwnProperty(file)) {
|
||||||
promises.push(util.writeFile(fspath.join(projectPath,file),defaultFileSet[file](project, runtime)));
|
promises.push(util.writeFile(fspath.join(projectPath,file),defaultFileSet[file](project)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -992,7 +992,6 @@ function loadProject(projectPath) {
|
|||||||
function init(_settings, _runtime) {
|
function init(_settings, _runtime) {
|
||||||
settings = _settings;
|
settings = _settings;
|
||||||
runtime = _runtime;
|
runtime = _runtime;
|
||||||
log = runtime.log;
|
|
||||||
projectsDir = fspath.join(settings.userDir,"projects");
|
projectsDir = fspath.join(settings.userDir,"projects");
|
||||||
authCache.init();
|
authCache.init();
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
var i18n = require("@node-red/util").i18n;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"package.json": function(project, runtime) {
|
"package.json": function(project) {
|
||||||
var i18n = runtime.i18n;
|
|
||||||
var package = {
|
var package = {
|
||||||
"name": project.name,
|
"name": project.name,
|
||||||
"description": project.summary||i18n._("storage.localfilesystem.projects.summary"),
|
"description": project.summary||i18n._("storage.localfilesystem.projects.summary"),
|
||||||
@ -35,8 +36,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
return JSON.stringify(package,"",4);
|
return JSON.stringify(package,"",4);
|
||||||
},
|
},
|
||||||
"README.md": function(project, runtime) {
|
"README.md": function(project) {
|
||||||
var i18n = runtime.i18n;
|
|
||||||
var content = project.name+"\n"+("=".repeat(project.name.length))+"\n\n";
|
var content = project.name+"\n"+("=".repeat(project.name.length))+"\n\n";
|
||||||
if (project.summary) {
|
if (project.summary) {
|
||||||
content += project.summary+"\n\n";
|
content += project.summary+"\n\n";
|
||||||
|
@ -25,7 +25,7 @@ var path = require("path");
|
|||||||
|
|
||||||
var gitCommand = "git";
|
var gitCommand = "git";
|
||||||
var gitVersion;
|
var gitVersion;
|
||||||
var log;
|
var log = require("@node-red/util").log;
|
||||||
|
|
||||||
function runGitCommand(args,cwd,env,emit) {
|
function runGitCommand(args,cwd,env,emit) {
|
||||||
log.trace(gitCommand + JSON.stringify(args));
|
log.trace(gitCommand + JSON.stringify(args));
|
||||||
@ -382,8 +382,7 @@ function removeRemote(cwd,name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init: function(_settings,_runtime) {
|
init: function(_settings) {
|
||||||
log = _runtime.log
|
|
||||||
return new Promise(function(resolve,reject) {
|
return new Promise(function(resolve,reject) {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
runGitCommand(["--version"]),
|
runGitCommand(["--version"]),
|
||||||
|
@ -29,7 +29,7 @@ var Projects = require("./Project");
|
|||||||
|
|
||||||
var settings;
|
var settings;
|
||||||
var runtime;
|
var runtime;
|
||||||
var log;
|
var log = require("@node-red/util").log;
|
||||||
|
|
||||||
var projectsEnabled = false;
|
var projectsEnabled = false;
|
||||||
var projectLogMessages = [];
|
var projectLogMessages = [];
|
||||||
@ -42,7 +42,6 @@ var globalGitUser = false;
|
|||||||
function init(_settings, _runtime) {
|
function init(_settings, _runtime) {
|
||||||
settings = _settings;
|
settings = _settings;
|
||||||
runtime = _runtime;
|
runtime = _runtime;
|
||||||
log = runtime.log;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (settings.editorTheme.projects.enabled === true) {
|
if (settings.editorTheme.projects.enabled === true) {
|
||||||
@ -90,7 +89,7 @@ function init(_settings, _runtime) {
|
|||||||
|
|
||||||
if (projectsEnabled) {
|
if (projectsEnabled) {
|
||||||
return sshTools.init(settings,runtime).then(function() {
|
return sshTools.init(settings,runtime).then(function() {
|
||||||
gitTools.init(_settings, _runtime).then(function(gitConfig) {
|
gitTools.init(_settings).then(function(gitConfig) {
|
||||||
if (!gitConfig || /^1\./.test(gitConfig.version)) {
|
if (!gitConfig || /^1\./.test(gitConfig.version)) {
|
||||||
if (!gitConfig) {
|
if (!gitConfig) {
|
||||||
projectLogMessages.push(log._("storage.localfilesystem.projects.git-not-found"))
|
projectLogMessages.push(log._("storage.localfilesystem.projects.git-not-found"))
|
||||||
@ -109,7 +108,7 @@ function init(_settings, _runtime) {
|
|||||||
} else {
|
} else {
|
||||||
globalGitUser = gitConfig.user;
|
globalGitUser = gitConfig.user;
|
||||||
Projects.init(settings,runtime);
|
Projects.init(settings,runtime);
|
||||||
sshTools.init(settings,runtime);
|
sshTools.init(settings);
|
||||||
projectsDir = fspath.join(settings.userDir,"projects");
|
projectsDir = fspath.join(settings.userDir,"projects");
|
||||||
if (!settings.readOnly) {
|
if (!settings.readOnly) {
|
||||||
return fs.ensureDir(projectsDir)
|
return fs.ensureDir(projectsDir)
|
||||||
|
@ -20,15 +20,12 @@ var fspath = require("path");
|
|||||||
var keygen = require("./keygen");
|
var keygen = require("./keygen");
|
||||||
|
|
||||||
var settings;
|
var settings;
|
||||||
var runtime;
|
var log = require("@node-red/util").log;
|
||||||
var log;
|
|
||||||
var sshkeyDir;
|
var sshkeyDir;
|
||||||
var userSSHKeyDir;
|
var userSSHKeyDir;
|
||||||
|
|
||||||
function init(_settings, _runtime) {
|
function init(_settings) {
|
||||||
settings = _settings;
|
settings = _settings;
|
||||||
runtime = _runtime;
|
|
||||||
log = runtime.log;
|
|
||||||
sshkeyDir = fspath.resolve(fspath.join(settings.userDir, "projects", ".sshkeys"));
|
sshkeyDir = fspath.resolve(fspath.join(settings.userDir, "projects", ".sshkeys"));
|
||||||
userSSHKeyDir = fspath.join(process.env.HOME || process.env.USERPROFILE || process.env.HOMEPATH, ".ssh");
|
userSSHKeyDir = fspath.join(process.env.HOME || process.env.USERPROFILE || process.env.HOMEPATH, ".ssh");
|
||||||
// console.log('sshkeys.init()');
|
// console.log('sshkeys.init()');
|
||||||
|
@ -18,7 +18,7 @@ var child_process = require('child_process');
|
|||||||
|
|
||||||
var sshkeygenCommand = "ssh-keygen";
|
var sshkeygenCommand = "ssh-keygen";
|
||||||
|
|
||||||
var log;
|
var log = require("@node-red/util").log;
|
||||||
|
|
||||||
function runSshKeygenCommand(args,cwd,env) {
|
function runSshKeygenCommand(args,cwd,env) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
@ -54,10 +54,6 @@ function runSshKeygenCommand(args,cwd,env) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function init(_settings, _runtime) {
|
|
||||||
log = _runtime.log;
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateKey(options) {
|
function generateKey(options) {
|
||||||
var args = ['-q', '-t', 'rsa'];
|
var args = ['-q', '-t', 'rsa'];
|
||||||
var err;
|
var err;
|
||||||
@ -90,6 +86,5 @@ function generateKey(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init: init,
|
generateKey: generateKey
|
||||||
generateKey: generateKey,
|
|
||||||
};
|
};
|
||||||
|
98
packages/node_modules/node-red/lib/red.js
vendored
98
packages/node_modules/node-red/lib/red.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*!
|
||||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -22,8 +22,6 @@ var redUtil = require("@node-red/util");
|
|||||||
|
|
||||||
var api = require("@node-red/editor-api");
|
var api = require("@node-red/editor-api");
|
||||||
|
|
||||||
var nodeApp = null;
|
|
||||||
var adminApp = null;
|
|
||||||
var server = null;
|
var server = null;
|
||||||
var apiEnabled = false;
|
var apiEnabled = false;
|
||||||
|
|
||||||
@ -37,8 +35,19 @@ function checkVersion(userSettings) {
|
|||||||
userSettings.UNSUPPORTED_VERSION = process.version;
|
userSettings.UNSUPPORTED_VERSION = process.version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This module provides the full Node-RED application, with both the runtime
|
||||||
|
* and editor components built in.
|
||||||
|
*
|
||||||
|
* @namespace node-red
|
||||||
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
/**
|
||||||
|
* Initialise the Node-RED application.
|
||||||
|
* @param {server} httpServer - the HTTP server object to use
|
||||||
|
* @param {Object} userSettings - an object containing the runtime settings
|
||||||
|
* @memberof node-red
|
||||||
|
*/
|
||||||
init: function(httpServer, userSettings) {
|
init: function(httpServer, userSettings) {
|
||||||
if (!userSettings) {
|
if (!userSettings) {
|
||||||
userSettings = httpServer;
|
userSettings = httpServer;
|
||||||
@ -54,27 +63,26 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
redUtil.init(userSettings);
|
redUtil.init(userSettings);
|
||||||
if (userSettings.httpAdminRoot !== false) {
|
if (userSettings.httpAdminRoot !== false) {
|
||||||
runtime.init(userSettings,api);
|
runtime.init(userSettings,httpServer,api);
|
||||||
api.init(httpServer,userSettings,runtime._.storage,runtime);
|
api.init(userSettings,httpServer,runtime.storage,runtime);
|
||||||
|
|
||||||
apiEnabled = true;
|
apiEnabled = true;
|
||||||
server = runtime._.adminApi.server;
|
server = httpServer;
|
||||||
runtime._.server = runtime._.adminApi.server;
|
|
||||||
} else {
|
} else {
|
||||||
runtime.init(userSettings);
|
runtime.init(userSettings);
|
||||||
apiEnabled = false;
|
apiEnabled = false;
|
||||||
if (httpServer) {
|
if (httpServer) {
|
||||||
server = httpServer;
|
server = httpServer;
|
||||||
runtime._.server = httpServer;
|
|
||||||
} else {
|
} else {
|
||||||
server = runtime._.adminApi.server;
|
server = null;
|
||||||
runtime._.server = runtime._.adminApi.server; // useless at this point, but at least harmless.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
adminApp = runtime._.adminApi.adminApp;
|
|
||||||
nodeApp = runtime._.nodeApp;
|
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Start the Node-RED application.
|
||||||
|
* @return {Promise} - resolves when complete
|
||||||
|
* @memberof node-red
|
||||||
|
*/
|
||||||
start: function() {
|
start: function() {
|
||||||
return runtime.start().then(function() {
|
return runtime.start().then(function() {
|
||||||
if (apiEnabled) {
|
if (apiEnabled) {
|
||||||
@ -82,6 +90,11 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Stop the Node-RED application.
|
||||||
|
* @return {Promise} - resolves when complete
|
||||||
|
* @memberof node-red
|
||||||
|
*/
|
||||||
stop: function() {
|
stop: function() {
|
||||||
return runtime.stop().then(function() {
|
return runtime.stop().then(function() {
|
||||||
if (apiEnabled) {
|
if (apiEnabled) {
|
||||||
@ -89,30 +102,37 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
nodes: runtime._.nodes,
|
|
||||||
log: redUtil.log,
|
|
||||||
settings:runtime._.settings,
|
|
||||||
util: runtime._.util,
|
|
||||||
version: runtime._.version,
|
|
||||||
events: runtime._.events,
|
|
||||||
comms: {
|
|
||||||
publish: function(topic,data,retain) {
|
|
||||||
runtime._.events.emit("comms",{
|
|
||||||
topic: topic,
|
|
||||||
data: data,
|
|
||||||
retain: retain
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
library: {
|
|
||||||
register: function(type) {
|
|
||||||
return runtime._.library.register(null,type);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
auth: api.auth,
|
|
||||||
|
|
||||||
get app() { console.log("Deprecated use of RED.app - use RED.httpAdmin instead"); return runtime._.app },
|
log: redUtil.log,
|
||||||
get httpAdmin() { return adminApp },
|
util: redUtil.util,
|
||||||
get httpNode() { return nodeApp },
|
|
||||||
get server() { return server }
|
get nodes() { console.log("Deprecated use of RED.nodes - refer to API documentation on RED.runtime.nodes"); return runtime._.nodes },
|
||||||
|
get settings() { console.log("Deprecated use of RED.settings - refer to API documentation on RED.runtime.settings"); return runtime._.settings },
|
||||||
|
get version() { console.log("Deprecated use of RED.version - refer to API documentation on RED.runtime.version"); return runtime._.version },
|
||||||
|
get events() { console.log("Deprecated use of RED.events - refer to API documentation on RED.runtime.events"); return runtime.events },
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The express application for the Editor Admin API
|
||||||
|
* @memberof node-red
|
||||||
|
*/
|
||||||
|
get httpAdmin() { return api.adminApp },
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The express application for HTTP Nodes
|
||||||
|
* @memberof node-red
|
||||||
|
*/
|
||||||
|
get httpNode() { return runtime.httpNode },
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The HTTP Server used by the runtime
|
||||||
|
* @memberof node-red
|
||||||
|
*/
|
||||||
|
get server() { return server },
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The runtime api
|
||||||
|
* @see @node-red/runtime
|
||||||
|
* @memberof node-red
|
||||||
|
*/
|
||||||
|
runtime: runtime
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user