@iobroker/js-controller-cli
Advanced tools
Comparing version 4.0.0-alpha.25-20211211-1232a951 to 4.0.0-alpha.26-20211214-19e8d05e
20
index.js
module.exports = { | ||
success: require('./lib/cli/messages').success, | ||
warn: require('./lib/cli/messages').warn, | ||
error: require('./lib/cli/messages').error, | ||
tools: require('./lib/cli/cliTools'), | ||
success: require('./lib/cli/messages').success, | ||
warn: require('./lib/cli/messages').warn, | ||
error: require('./lib/cli/messages').error, | ||
tools: require('./lib/cli/cliTools'), | ||
command: { | ||
object: require('./lib/cli/cliObjects.js'), | ||
state: require('./lib/cli/cliStates.js'), | ||
object: require('./lib/cli/cliObjects.js'), | ||
state: require('./lib/cli/cliStates.js'), | ||
process: require('./lib/cli/cliProcess.js'), | ||
message: require('./lib/cli/cliMessage.js'), | ||
logs: require('./lib/cli/cliLogs.js'), | ||
host: require('./lib/cli/cliHost.js'), | ||
cert: require('./lib/cli/cliCert.js'), | ||
logs: require('./lib/cli/cliLogs.js'), | ||
host: require('./lib/cli/cliHost.js'), | ||
cert: require('./lib/cli/cliCert.js'), | ||
compact: require('./lib/cli/cliCompact.js'), | ||
debug: require('./lib/cli/cliDebug.js'), | ||
debug: require('./lib/cli/cliDebug.js'), | ||
plugin: require('./lib/cli/cliPlugin.js') | ||
@@ -17,0 +17,0 @@ }, |
@@ -9,3 +9,2 @@ 'use strict'; | ||
module.exports = class CLICert extends CLICommand { | ||
/** @param {import('./cliCommand.js').CLICommandOptions} options */ | ||
@@ -81,2 +80,2 @@ constructor(options) { | ||
} | ||
}; | ||
}; |
@@ -9,3 +9,2 @@ 'use strict'; | ||
module.exports = class CLICompact extends CLICommand { | ||
/** @param {import('./cliCommand.js').CLICommandOptions} options */ | ||
@@ -115,3 +114,5 @@ constructor(options) { | ||
if (!obj.common.compact) { | ||
console.log('This adapter does not support compact mode. The below settings will have no effect!'); | ||
console.log( | ||
'This adapter does not support compact mode. The below settings will have no effect!' | ||
); | ||
console.log(); | ||
@@ -122,3 +123,6 @@ } else { | ||
console.log('Compact mode enabled for instance: ' + !!obj.common.runAsCompactMode); | ||
console.log('Compact group: ' + (obj.common.compactGroup !== undefined ? obj.common.compactGroup : 1)); | ||
console.log( | ||
'Compact group: ' + | ||
(obj.common.compactGroup !== undefined ? obj.common.compactGroup : 1) | ||
); | ||
return void callback(); | ||
@@ -144,3 +148,5 @@ } else { | ||
if (!obj.common.compact) { | ||
console.log('This adapter does not support compact mode. The below settings will have no effect!'); | ||
console.log( | ||
'This adapter does not support compact mode. The below settings will have no effect!' | ||
); | ||
console.log(); | ||
@@ -165,4 +171,14 @@ } else { | ||
} | ||
console.log('Compact mode enabled for instance: ' + (newRunAsCompactMode !== undefined ? '--> ' + newRunAsCompactMode : !!obj.common.runAsCompactMode)); | ||
console.log('Compact group: ' + (newCompactGroup !== undefined && obj.common.compactGroup !== newCompactGroup ? '--> ' + newCompactGroup : obj.common.compactGroup)); | ||
console.log( | ||
'Compact mode enabled for instance: ' + | ||
(newRunAsCompactMode !== undefined | ||
? '--> ' + newRunAsCompactMode | ||
: !!obj.common.runAsCompactMode) | ||
); | ||
console.log( | ||
'Compact group: ' + | ||
(newCompactGroup !== undefined && obj.common.compactGroup !== newCompactGroup | ||
? '--> ' + newCompactGroup | ||
: obj.common.compactGroup) | ||
); | ||
if (newRunAsCompactMode !== undefined || newCompactGroup !== undefined) { | ||
@@ -196,3 +212,2 @@ if (newCompactGroup !== undefined) { | ||
} | ||
}; |
@@ -23,6 +23,3 @@ 'use strict'; | ||
if (!adapter) { | ||
CLI.error.requiredArgumentMissing( | ||
'adaptername', | ||
'debug <adaptername>' | ||
); | ||
CLI.error.requiredArgumentMissing('adaptername', 'debug <adaptername>'); | ||
return void callback(34); | ||
@@ -53,5 +50,3 @@ } | ||
// --inspect[-brk][=[ip]:[port]] | ||
`--inspect${params.wait ? '-brk' : ''}${ | ||
!!params.ip || !!params.port ? '=' : '' | ||
}${params.ip || ''}${ | ||
`--inspect${params.wait ? '-brk' : ''}${!!params.ip || !!params.port ? '=' : ''}${params.ip || ''}${ | ||
!!params.ip && !!params.port ? ':' : '' | ||
@@ -58,0 +53,0 @@ }${params.port || ''}` |
'use strict'; | ||
const CLI = require('./messages.js'); | ||
const CLICommand = require('./cliCommand.js'); | ||
const {enumHosts, enumObjects, getObjectFrom, enumInstances} = require('./cliTools'); | ||
const { enumHosts, enumObjects, getObjectFrom, enumInstances } = require('./cliTools'); | ||
const { tools } = require('@iobroker/js-controller-common'); | ||
@@ -11,3 +11,2 @@ const os = require('os'); | ||
module.exports = class CLIHost extends CLICommand { | ||
/** @param {import('./cliCommand').CLICommandOptions} options */ | ||
@@ -130,3 +129,2 @@ constructor(options) { | ||
return void callback(); | ||
} catch (err) { | ||
@@ -266,4 +264,4 @@ CLI.error.unknown(err.message); | ||
const instances = await enumInstances(objects); | ||
const instancesToRename = oldHostname === undefined ? instances | ||
: instances.filter(i => i.common.host === oldHostname); | ||
const instancesToRename = | ||
oldHostname === undefined ? instances : instances.filter(i => i.common.host === oldHostname); | ||
if (instancesToRename.length > 0) { | ||
@@ -278,3 +276,2 @@ for (const instance of instancesToRename) { | ||
return void callback(); | ||
} catch (err) { | ||
@@ -286,3 +283,2 @@ CLI.error.unknown(err.message); | ||
} | ||
}; | ||
@@ -303,3 +299,4 @@ | ||
// and save it | ||
objects.setObjectAsync(instance._id, instance) | ||
objects | ||
.setObjectAsync(instance._id, instance) | ||
.then(() => { | ||
@@ -306,0 +303,0 @@ CLI.success.instanceHostChanged(instance._id, oldInstanceHost, newHostname); |
@@ -13,3 +13,2 @@ 'use strict'; | ||
module.exports = class CLILogs extends CLICommand { | ||
/** @param {import('./cliCommand').CLICommandOptions} options */ | ||
@@ -28,3 +27,2 @@ constructor(options) { | ||
execute(args, params) { | ||
/** @type {string | undefined} */ | ||
@@ -65,6 +63,6 @@ const adapterName = args[0]; | ||
parts.pop(); | ||
chokidar.watch(`${parts.join('/')}/iobroker*`, {awaitWriteFinish: {stabilityThreshold: 500}}) | ||
chokidar | ||
.watch(`${parts.join('/')}/iobroker*`, { awaitWriteFinish: { stabilityThreshold: 500 } }) | ||
.on('all', this.watchHandler.bind(this, options)) | ||
.on('ready', () => this.isReady = true) | ||
; | ||
.on('ready', () => (this.isReady = true)); | ||
} | ||
@@ -92,8 +90,3 @@ } else { | ||
this.fileSizes.set(path, stats.size); | ||
if ( | ||
stats.size > 0 && ( | ||
this.isReady | ||
|| (options.complete && this.isTodaysLogfile(path)) | ||
) | ||
) { | ||
if (stats.size > 0 && (this.isReady || (options.complete && this.isTodaysLogfile(path)))) { | ||
this.streamChange(path, 0, options); | ||
@@ -140,4 +133,3 @@ } | ||
.pipe(es.mapSync(line => line + os.EOL)) | ||
.pipe(process.stdout) | ||
; | ||
.pipe(process.stdout); | ||
} else { | ||
@@ -149,2 +141,1 @@ // just pipe the input through | ||
}; | ||
@@ -9,3 +9,2 @@ 'use strict'; | ||
module.exports = class CLIMessage extends CLICommand { | ||
/** @param {import('./cliCommand').CLICommandOptions} options */ | ||
@@ -23,3 +22,3 @@ constructor(options) { | ||
/** @type {[string, string, any?]} */ | ||
let [adapter, command, message] = (args); | ||
let [adapter, command, message] = args; | ||
if (adapter === null || adapter === undefined) { | ||
@@ -41,7 +40,3 @@ CLI.error.requiredArgumentMissing('adapter'); | ||
// TODO: can we use the methods from cliObjects? | ||
if ( | ||
typeof message === 'string' | ||
&& message.startsWith('{') | ||
&& message.endsWith('}') | ||
) { | ||
if (typeof message === 'string' && message.startsWith('{') && message.endsWith('}')) { | ||
message = JSON.parse(message); | ||
@@ -73,8 +68,5 @@ } | ||
// Send the message to all targets | ||
const messagePromises = messageTargets.map( | ||
t => sendMessage(states, t, command, message) | ||
); | ||
const messagePromises = messageTargets.map(t => sendMessage(states, t, command, message)); | ||
await Promise.all(messagePromises); | ||
return void callback(); | ||
} catch (err) { | ||
@@ -81,0 +73,0 @@ CLI.error.unknown(err.message); |
@@ -9,3 +9,2 @@ 'use strict'; | ||
module.exports = class CLIObjects extends CLICommand { | ||
/** @param {import('./cliCommand').CLICommandOptions} options */ | ||
@@ -78,6 +77,10 @@ constructor(options) { | ||
dbConnect((objects, states) => { | ||
objects.chmodObject(pattern, { user: 'system.user.admin', object: modeObject, state: modeState }, (err, processed) => { | ||
// Print the new object rights | ||
this.printObjectList(objects, states, err, processed); | ||
}); | ||
objects.chmodObject( | ||
pattern, | ||
{ user: 'system.user.admin', object: modeObject, state: modeState }, | ||
(err, processed) => { | ||
// Print the new object rights | ||
this.printObjectList(objects, states, err, processed); | ||
} | ||
); | ||
}); | ||
@@ -93,3 +96,3 @@ } | ||
/** @type {[string, string, any]} */ | ||
let [user, group, pattern] = (args.slice(1)); | ||
let [user, group, pattern] = args.slice(1); | ||
@@ -116,6 +119,10 @@ if (!pattern) { | ||
dbConnect((objects, states) => { | ||
objects.chownObject(pattern, { user: 'system.user.admin', owner: user, ownerGroup: group }, (err, processed) => { | ||
// Print the new object rights | ||
this.printObjectList(objects, states, err, processed); | ||
}); | ||
objects.chownObject( | ||
pattern, | ||
{ user: 'system.user.admin', owner: user, ownerGroup: group }, | ||
(err, processed) => { | ||
// Print the new object rights | ||
this.printObjectList(objects, states, err, processed); | ||
} | ||
); | ||
}); | ||
@@ -138,3 +145,4 @@ } | ||
this.printObjectList( | ||
objects, states, | ||
objects, | ||
states, | ||
err, | ||
@@ -155,3 +163,3 @@ processed && processed.rows && processed.rows.map(r => r.value) | ||
/** @type {[string, string]} */ | ||
const [id, propPath] = (args.slice(1)); | ||
const [id, propPath] = args.slice(1); | ||
if (!id) { | ||
@@ -279,3 +287,3 @@ CLI.error.requiredArgumentMissing('id', 'object get id [propertypath]'); | ||
try { | ||
config = config || await objects.getObjectAsync('system.config'); | ||
config = config || (await objects.getObjectAsync('system.config')); | ||
res.native[prop] = tools.encrypt(config.native.secret, res.native[prop]); | ||
@@ -333,3 +341,16 @@ } catch (e) { | ||
async _collectObjects(objects, params, callback) { | ||
const types = ['state', 'channel', 'device', 'enum', 'instance', 'host', 'adapter', 'meta', 'config', 'group', 'user', 'script']; | ||
const types = [ | ||
'state', | ||
'channel', | ||
'device', | ||
'enum', | ||
'instance', | ||
'host', | ||
'adapter', | ||
'meta', | ||
'config', | ||
'group', | ||
'user', | ||
'script' | ||
]; | ||
const result = []; | ||
@@ -397,3 +418,3 @@ | ||
startkey: id.replace(/\*/g, ''), | ||
endkey: id.replace(/\*/g, '\u9999') | ||
endkey: id.replace(/\*/g, '\u9999') | ||
}; | ||
@@ -410,3 +431,3 @@ this._collectObjects(objects, params, result => { | ||
const rl = require('readline').createInterface({ | ||
input: process.stdin, | ||
input: process.stdin, | ||
output: process.stdout | ||
@@ -416,3 +437,10 @@ }); | ||
rl.close(); | ||
if (answer === 'y' || answer === 'yes' || answer === 'j' || answer === 'ja' || answer === 'да' || answer === 'д') { | ||
if ( | ||
answer === 'y' || | ||
answer === 'yes' || | ||
answer === 'j' || | ||
answer === 'ja' || | ||
answer === 'да' || | ||
answer === 'д' | ||
) { | ||
this._deleteObjects(objects, ids, callback); | ||
@@ -435,9 +463,12 @@ } else { | ||
} else { | ||
tools.removeIdFromAllEnums(objects, id).then(() => { | ||
CLI.success.objectDeleted(id); | ||
return void callback(); | ||
}).catch(e => { | ||
CLI.error.cannotDeleteObjectFromEnums(id, e.message); | ||
return void callback(3); | ||
}); | ||
tools | ||
.removeIdFromAllEnums(objects, id) | ||
.then(() => { | ||
CLI.success.objectDeleted(id); | ||
return void callback(); | ||
}) | ||
.catch(e => { | ||
CLI.error.cannotDeleteObjectFromEnums(id, e.message); | ||
return void callback(3); | ||
}); | ||
} | ||
@@ -444,0 +475,0 @@ }); |
@@ -52,6 +52,3 @@ 'use strict'; | ||
if (!pluginName) { | ||
CLI.error.requiredArgumentMissing( | ||
'pluginName', | ||
'plugin enable <pluginname>' | ||
); | ||
CLI.error.requiredArgumentMissing('pluginName', 'plugin enable <pluginname>'); | ||
return void callback(34); | ||
@@ -79,95 +76,78 @@ } | ||
dbConnect( | ||
async (objects, states, _isOffline, _dbType, iobrokerJson) => { | ||
try { | ||
// Check if the host or instance exists | ||
/** @type {string} */ let objectNamespace; | ||
if (hostname) { | ||
objectNamespace = `system.host.${hostname}`; | ||
const hostObject = await objects.getObject( | ||
objectNamespace | ||
); | ||
if (!hostObject) { | ||
CLI.error.hostDoesNotExist(hostname); | ||
return void callback(30); | ||
} | ||
} else { | ||
objectNamespace = `system.adapter.${instance}`; | ||
const instanceObject = await objects.getObject( | ||
objectNamespace | ||
); | ||
if (!instanceObject) { | ||
CLI.error.invalidInstance(instance); | ||
return void callback(30); | ||
} | ||
dbConnect(async (objects, states, _isOffline, _dbType, iobrokerJson) => { | ||
try { | ||
// Check if the host or instance exists | ||
/** @type {string} */ let objectNamespace; | ||
if (hostname) { | ||
objectNamespace = `system.host.${hostname}`; | ||
const hostObject = await objects.getObject(objectNamespace); | ||
if (!hostObject) { | ||
CLI.error.hostDoesNotExist(hostname); | ||
return void callback(30); | ||
} | ||
// Check if the plugin is defined | ||
if (!pluginExists(pluginName, iobrokerJson, instance)) { | ||
CLI.error.pluginNotDefined( | ||
pluginName, | ||
hostname, | ||
instance | ||
); | ||
} else { | ||
objectNamespace = `system.adapter.${instance}`; | ||
const instanceObject = await objects.getObject(objectNamespace); | ||
if (!instanceObject) { | ||
CLI.error.invalidInstance(instance); | ||
return void callback(30); | ||
} | ||
} | ||
// Create the plugin state if it does not exist | ||
const pluginsFolderId = `${objectNamespace}.plugins`; | ||
if (!(await objects.getObjectAsync(pluginsFolderId))) { | ||
await objects.setObject(pluginsFolderId, { | ||
type: 'folder', | ||
common: { | ||
name: `${ | ||
hostname ? 'host' : 'instance' | ||
}: plugin states` | ||
}, | ||
native: {} | ||
}); | ||
} | ||
const pluginFolderId = `${objectNamespace}.plugins.${pluginName}`; | ||
if (!(await objects.getObjectAsync(pluginFolderId))) { | ||
await objects.setObject(pluginFolderId, { | ||
type: 'folder', | ||
common: { | ||
name: `${pluginName}: plugin states` | ||
}, | ||
native: {} | ||
}); | ||
} | ||
const pluginEnabledId = `${pluginFolderId}.enabled`; | ||
if (!(await objects.getObjectAsync(pluginEnabledId))) { | ||
await objects.setObject(pluginEnabledId, { | ||
type: 'state', | ||
common: { | ||
name: 'Plugin enabled', | ||
type: 'boolean', | ||
read: true, | ||
write: true, | ||
role: 'value' | ||
}, | ||
native: {} | ||
}); | ||
} | ||
// Check if the plugin is defined | ||
if (!pluginExists(pluginName, iobrokerJson, instance)) { | ||
CLI.error.pluginNotDefined(pluginName, hostname, instance); | ||
return void callback(30); | ||
} | ||
// Update the state | ||
await states.setStateAsync(pluginEnabledId, { | ||
val: enabled, | ||
from: getObjectFrom() | ||
// Create the plugin state if it does not exist | ||
const pluginsFolderId = `${objectNamespace}.plugins`; | ||
if (!(await objects.getObjectAsync(pluginsFolderId))) { | ||
await objects.setObject(pluginsFolderId, { | ||
type: 'folder', | ||
common: { | ||
name: `${hostname ? 'host' : 'instance'}: plugin states` | ||
}, | ||
native: {} | ||
}); | ||
} | ||
const pluginFolderId = `${objectNamespace}.plugins.${pluginName}`; | ||
if (!(await objects.getObjectAsync(pluginFolderId))) { | ||
await objects.setObject(pluginFolderId, { | ||
type: 'folder', | ||
common: { | ||
name: `${pluginName}: plugin states` | ||
}, | ||
native: {} | ||
}); | ||
} | ||
const pluginEnabledId = `${pluginFolderId}.enabled`; | ||
if (!(await objects.getObjectAsync(pluginEnabledId))) { | ||
await objects.setObject(pluginEnabledId, { | ||
type: 'state', | ||
common: { | ||
name: 'Plugin enabled', | ||
type: 'boolean', | ||
read: true, | ||
write: true, | ||
role: 'value' | ||
}, | ||
native: {} | ||
}); | ||
} | ||
// Notify the user that we are done | ||
CLI.success.pluginEnabledOrDisabled( | ||
pluginName, | ||
hostname, | ||
instance, | ||
enabled | ||
); | ||
return void callback(); | ||
} catch (err) { | ||
CLI.error.unknown(err.message); | ||
return void callback(1); | ||
} | ||
// Update the state | ||
await states.setStateAsync(pluginEnabledId, { | ||
val: enabled, | ||
from: getObjectFrom() | ||
}); | ||
// Notify the user that we are done | ||
CLI.success.pluginEnabledOrDisabled(pluginName, hostname, instance, enabled); | ||
return void callback(); | ||
} catch (err) { | ||
CLI.error.unknown(err.message); | ||
return void callback(1); | ||
} | ||
); | ||
}); | ||
} | ||
@@ -184,6 +164,3 @@ | ||
if (!pluginName) { | ||
CLI.error.requiredArgumentMissing( | ||
'pluginName', | ||
'plugin status <pluginname>' | ||
); | ||
CLI.error.requiredArgumentMissing('pluginName', 'plugin status <pluginname>'); | ||
return void callback(34); | ||
@@ -211,71 +188,56 @@ } | ||
dbConnect( | ||
async (objects, states, _isOffline, _dbType, iobrokerJson) => { | ||
try { | ||
// Check if the host or instance exists | ||
/** @type {string} */ let objectNamespace; | ||
if (hostname) { | ||
objectNamespace = `system.host.${hostname}`; | ||
const hostObject = await objects.getObject( | ||
objectNamespace | ||
); | ||
if (!hostObject) { | ||
CLI.error.hostDoesNotExist(hostname); | ||
return void callback(30); | ||
} | ||
} else { | ||
objectNamespace = `system.adapter.${instance}`; | ||
const instanceObject = await objects.getObject( | ||
objectNamespace | ||
); | ||
if (!instanceObject) { | ||
CLI.error.invalidInstance(instance); | ||
return void callback(30); | ||
} | ||
dbConnect(async (objects, states, _isOffline, _dbType, iobrokerJson) => { | ||
try { | ||
// Check if the host or instance exists | ||
/** @type {string} */ let objectNamespace; | ||
if (hostname) { | ||
objectNamespace = `system.host.${hostname}`; | ||
const hostObject = await objects.getObject(objectNamespace); | ||
if (!hostObject) { | ||
CLI.error.hostDoesNotExist(hostname); | ||
return void callback(30); | ||
} | ||
// Check if the plugin is defined | ||
if (!pluginExists(pluginName, iobrokerJson, instance)) { | ||
CLI.error.pluginNotDefined( | ||
pluginName, | ||
hostname, | ||
instance | ||
); | ||
} else { | ||
objectNamespace = `system.adapter.${instance}`; | ||
const instanceObject = await objects.getObject(objectNamespace); | ||
if (!instanceObject) { | ||
CLI.error.invalidInstance(instance); | ||
return void callback(30); | ||
} | ||
} | ||
const pluginEnabledId = `${objectNamespace}.plugins.${pluginName}.enabled`; | ||
// Check if the plugin is defined | ||
if (!pluginExists(pluginName, iobrokerJson, instance)) { | ||
CLI.error.pluginNotDefined(pluginName, hostname, instance); | ||
return void callback(30); | ||
} | ||
// Read the state | ||
try { | ||
const { val } = await states.getStateAsync(pluginEnabledId); | ||
const pluginEnabledId = `${objectNamespace}.plugins.${pluginName}.enabled`; | ||
if (typeof val === 'boolean') { | ||
CLI.success.pluginStatus(pluginName, hostname, instance, val); | ||
return void callback(); | ||
} | ||
} catch { | ||
/* ignore */ | ||
// Read the state | ||
try { | ||
const { val } = await states.getStateAsync(pluginEnabledId); | ||
if (typeof val === 'boolean') { | ||
CLI.success.pluginStatus(pluginName, hostname, instance, val); | ||
return void callback(); | ||
} | ||
} catch { | ||
/* ignore */ | ||
} | ||
// If the state could not be read or had no value, fall back to the configuration | ||
const enabled = pluginEnabled( | ||
pluginName, | ||
instance, | ||
await objects.getObjectAsync('system.config'), | ||
iobrokerJson | ||
); | ||
CLI.success.pluginStatus( | ||
pluginName, | ||
hostname, | ||
instance, | ||
enabled | ||
); | ||
return void callback(); | ||
} catch (err) { | ||
CLI.error.unknown(err.message); | ||
return void callback(1); | ||
} | ||
// If the state could not be read or had no value, fall back to the configuration | ||
const enabled = pluginEnabled( | ||
pluginName, | ||
instance, | ||
await objects.getObjectAsync('system.config'), | ||
iobrokerJson | ||
); | ||
CLI.success.pluginStatus(pluginName, hostname, instance, enabled); | ||
return void callback(); | ||
} catch (err) { | ||
CLI.error.unknown(err.message); | ||
return void callback(1); | ||
} | ||
); | ||
}); | ||
} | ||
@@ -294,12 +256,5 @@ }; | ||
try { | ||
const ioPackPath = adapter | ||
? path.join(tools.getAdapterDir(adapter), 'io-package.json') | ||
: controllerIoPackPath; | ||
const ioPackPath = adapter ? path.join(tools.getAdapterDir(adapter), 'io-package.json') : controllerIoPackPath; | ||
const ioPack = JSON.parse(fs.readFileSync(ioPackPath, 'utf8')); | ||
if ( | ||
ioPack && | ||
ioPack.common && | ||
ioPack.common.plugins && | ||
pluginName in ioPack.common.plugins | ||
) { | ||
if (ioPack && ioPack.common && ioPack.common.plugins && pluginName in ioPack.common.plugins) { | ||
return true; | ||
@@ -312,7 +267,3 @@ } | ||
// 2. check if the plugin is defined in iobroker.json | ||
return ( | ||
iobrokerJson && | ||
iobrokerJson.plugins && | ||
pluginName in iobrokerJson.plugins | ||
); | ||
return iobrokerJson && iobrokerJson.plugins && pluginName in iobrokerJson.plugins; | ||
} | ||
@@ -329,7 +280,3 @@ | ||
// 1. check if diagnostics are disabled in ioBroker | ||
if ( | ||
systemConfig && | ||
systemConfig.common && | ||
systemConfig.common.diag === 'none' | ||
) { | ||
if (systemConfig && systemConfig.common && systemConfig.common.diag === 'none') { | ||
return false; | ||
@@ -341,5 +288,3 @@ } | ||
try { | ||
const ioPackPath = adapter | ||
? path.join(tools.getAdapterDir(adapter), 'io-package.json') | ||
: controllerIoPackPath; | ||
const ioPackPath = adapter ? path.join(tools.getAdapterDir(adapter), 'io-package.json') : controllerIoPackPath; | ||
const ioPack = JSON.parse(fs.readFileSync(ioPackPath, 'utf8')); | ||
@@ -346,0 +291,0 @@ if ( |
@@ -11,3 +11,3 @@ 'use strict'; | ||
const { getObjectFrom, getInstanceName, normalizeAdapterName, enumInstances} = require('./cliTools.js'); | ||
const { getObjectFrom, getInstanceName, normalizeAdapterName, enumInstances } = require('./cliTools.js'); | ||
@@ -19,3 +19,2 @@ // The root of this project. Change this when moving code to another directory | ||
module.exports = class CLIProcess extends CLICommand { | ||
/** @param {import('./cliCommand').CLICommandOptions} options */ | ||
@@ -67,3 +66,3 @@ constructor(options) { | ||
const adapterName = normalizeAdapterName(args[0]); | ||
if (adapterName === undefined ) { | ||
if (adapterName === undefined) { | ||
this.stopJSController(); | ||
@@ -105,3 +104,3 @@ } else if (adapterName === 'all') { | ||
setAdapterEnabled(adapter, enabled, restartIfRunning) { | ||
const {callback, dbConnect} = this.options; | ||
const { callback, dbConnect } = this.options; | ||
dbConnect(async objects => { | ||
@@ -115,3 +114,6 @@ // Due to the many return locations we cannot simply chain the promises here | ||
if (adapterInstances.length > 1) { | ||
CLI.error.specifyInstance(adapter, adapterInstances.map(obj => obj._id.substring('system.adapter.'.length))); | ||
CLI.error.specifyInstance( | ||
adapter, | ||
adapterInstances.map(obj => obj._id.substring('system.adapter.'.length)) | ||
); | ||
return void callback(EXIT_CODES.INVALID_ADAPTER_ID); | ||
@@ -176,4 +178,4 @@ } else if (adapterInstances.length === 0) { | ||
const child = require('child_process').spawn(killAllScriptPath, [], { windowsHide: true }); | ||
child.stdout.on('data', _data => data += _data.toString().replace(/\n/g, '')); | ||
child.stderr.on('data', _data => data += _data.toString().replace(/\n/g, '')); | ||
child.stdout.on('data', _data => (data += _data.toString().replace(/\n/g, ''))); | ||
child.stderr.on('data', _data => (data += _data.toString().replace(/\n/g, ''))); | ||
child.on('exit', exitCode => { | ||
@@ -194,5 +196,3 @@ console.log('Exit code for "killall.sh": ' + exitCode); | ||
const daemon = setupDaemonize(); | ||
daemon | ||
.on('stopped', () => daemon.start()) | ||
.on('notrunning', () => daemon.start()); | ||
daemon.on('stopped', () => daemon.start()).on('notrunning', () => daemon.start()); | ||
daemon.stop(); | ||
@@ -217,3 +217,6 @@ } | ||
console.log(); | ||
if (!dbTools.isLocalStatesDbServer(config.states.type, config.states.host) && !dbTools.isLocalObjectsDbServer(config.objects.type, config.objects.host)) { | ||
if ( | ||
!dbTools.isLocalStatesDbServer(config.states.type, config.states.host) && | ||
!dbTools.isLocalObjectsDbServer(config.objects.type, config.objects.host) | ||
) { | ||
CLI.success.systemStatus(!isOffline); | ||
@@ -243,3 +246,6 @@ } | ||
if (adapterInstances.length > 1) { | ||
CLI.error.specifyInstance(adapterName, adapterInstances.map(obj => obj._id.substring('system.adapter.'.length))); | ||
CLI.error.specifyInstance( | ||
adapterName, | ||
adapterInstances.map(obj => obj._id.substring('system.adapter.'.length)) | ||
); | ||
return void callback(EXIT_CODES.INVALID_ADAPTER_ID); | ||
@@ -353,3 +359,5 @@ } else if (adapterInstances.length === 0) { | ||
console.warn('Cannot read memoryLimitMB'); | ||
console.warn(`May be config file does not exist.\nPlease call "${tools.appName} setup first" to initialize the settings.`); | ||
console.warn( | ||
`May be config file does not exist.\nPlease call "${tools.appName} setup first" to initialize the settings.` | ||
); | ||
} | ||
@@ -356,0 +364,0 @@ const startObj = { |
'use strict'; | ||
const { tools } = require('@iobroker/js-controller-common'); | ||
const CLI = require('./messages.js'); | ||
const CLICommand = require('./cliCommand.js'); | ||
const {formatValue} = require('./cliTools'); | ||
const CLI = require('./messages.js'); | ||
const CLICommand = require('./cliCommand.js'); | ||
const { formatValue } = require('./cliTools'); | ||
const ALIAS_STARTS_WITH = 'alias.'; | ||
@@ -10,3 +10,2 @@ | ||
module.exports = class CLIStates extends CLICommand { | ||
/** @param {import('./cliCommand').CLICommandOptions} options */ | ||
@@ -37,9 +36,3 @@ constructor(options) { | ||
return [ | ||
obj.val, | ||
obj.ack, | ||
obj.from, | ||
obj.ts, | ||
obj.lc | ||
].map(line => formatValue(line)).join('\n'); | ||
return [obj.val, obj.ack, obj.from, obj.ts, obj.lc].map(line => formatValue(line)).join('\n'); | ||
}; | ||
@@ -49,3 +42,3 @@ return this.get_(args, resultTransform); | ||
case 'getvalue': | ||
resultTransform = obj => obj ? formatValue(obj.val, pretty) : 'null'; | ||
resultTransform = obj => (obj ? formatValue(obj.val, pretty) : 'null'); | ||
return this.get_(args, resultTransform); | ||
@@ -74,3 +67,3 @@ case 'set': | ||
get_(args, resultTransform) { | ||
const {callback, dbConnect} = this.options; | ||
const { callback, dbConnect } = this.options; | ||
const id = args[1]; | ||
@@ -83,3 +76,6 @@ | ||
if (targetObj && targetObj.common && targetObj.common.alias && targetObj.common.alias.id) { | ||
const aliasId = typeof targetObj.common.alias.id.read === 'string' ? targetObj.common.alias.id.read : targetObj.common.alias.id; | ||
const aliasId = | ||
typeof targetObj.common.alias.id.read === 'string' | ||
? targetObj.common.alias.id.read | ||
: targetObj.common.alias.id; | ||
objects.getObject(aliasId, (err, sourceObj) => { | ||
@@ -119,3 +115,3 @@ // write target | ||
set_(args) { | ||
const {callback, dbConnect, showHelp} = this.options; | ||
const { callback, dbConnect, showHelp } = this.options; | ||
// eslint-disable-next-line prefer-const | ||
@@ -136,3 +132,3 @@ let [id, val, ack] = /** @type {[string, any, any]} */ (args.slice(1)); | ||
dbConnect((objects, states) => { | ||
const newVal = ack === undefined ? {val, ack: false} : {val, ack: !!ack}; | ||
const newVal = ack === undefined ? { val, ack: false } : { val, ack: !!ack }; | ||
@@ -143,3 +139,6 @@ if (id.startsWith(ALIAS_STARTS_WITH)) { | ||
if (obj && obj.common && obj.common.alias && obj.common.alias.id) { | ||
const aliasId = typeof obj.common.alias.id.write === 'string' ? obj.common.alias.id.write : obj.common.alias.id; | ||
const aliasId = | ||
typeof obj.common.alias.id.write === 'string' | ||
? obj.common.alias.id.write | ||
: obj.common.alias.id; | ||
@@ -163,3 +162,7 @@ objects.getObject(aliasId, (err, targetObj) => { | ||
newVal.val = newVal.val.toString(); | ||
newVal.val = newVal.val === 'true' || newVal.val === '1' || newVal.val === 'ON' || newVal.val === 'on'; | ||
newVal.val = | ||
newVal.val === 'true' || | ||
newVal.val === '1' || | ||
newVal.val === 'ON' || | ||
newVal.val === 'on'; | ||
} | ||
@@ -169,11 +172,15 @@ } | ||
// write target | ||
states.setState(aliasId, tools.formatAliasValue(obj.common, targetObj.common, newVal, console, ''), err => { | ||
if (err) { | ||
CLI.error.unknown(err); | ||
return void callback(1); // ? | ||
} else { | ||
CLI.success.stateUpdated(id, val, !!ack); | ||
return void callback(); | ||
states.setState( | ||
aliasId, | ||
tools.formatAliasValue(obj.common, targetObj.common, newVal, console, ''), | ||
err => { | ||
if (err) { | ||
CLI.error.unknown(err); | ||
return void callback(1); // ? | ||
} else { | ||
CLI.success.stateUpdated(id, val, !!ack); | ||
return void callback(); | ||
} | ||
} | ||
}); | ||
); | ||
}); | ||
@@ -203,3 +210,7 @@ } else { | ||
newVal.val = newVal.val.toString(); | ||
newVal.val = newVal.val === 'true' || newVal.val === '1' || newVal.val === 'ON' || newVal.val === 'on'; | ||
newVal.val = | ||
newVal.val === 'true' || | ||
newVal.val === '1' || | ||
newVal.val === 'ON' || | ||
newVal.val === 'on'; | ||
} | ||
@@ -227,3 +238,3 @@ } | ||
delete(args) { | ||
const {callback, dbConnect} = this.options; | ||
const { callback, dbConnect } = this.options; | ||
/** @type {string} */ | ||
@@ -245,4 +256,5 @@ const id = args[1]; | ||
} | ||
})); | ||
}) | ||
); | ||
} | ||
}; |
@@ -12,5 +12,3 @@ 'use strict'; | ||
const needsStringify = tools.isObject(val) || tools.isArray(val); | ||
const output = !needsStringify ? val | ||
: pretty ? JSON.stringify(val, null, 2) | ||
: JSON.stringify(val); | ||
const output = !needsStringify ? val : pretty ? JSON.stringify(val, null, 2) : JSON.stringify(val); | ||
return output; | ||
@@ -112,3 +110,3 @@ } | ||
const endkey = startkey + '\u9999'; | ||
objects.getObjectView('system', type, {startkey, endkey}, null, (err, res) => { | ||
objects.getObjectView('system', type, { startkey, endkey }, null, (err, res) => { | ||
if (err) { | ||
@@ -115,0 +113,0 @@ return reject(err); |
@@ -5,45 +5,30 @@ 'use strict'; | ||
const errorMessages = Object.freeze({ | ||
stateNotFound: ( | ||
/** @type {string} */ stateID, | ||
/** @type {string?} */ error | ||
) => `The state ${stateID} was not found!` + (error ? ` Reason: ${error}` : ''), | ||
objectNotFound: ( | ||
/** @type {string} */ objectID, | ||
/** @type {string?} */ error | ||
) => `The object ${objectID} was not found!` + (error ? ` Reason: ${error}` : ''), | ||
cannotUpdateObject: ( | ||
/** @type {string} */ objectID, | ||
/** @type {string?} */ error | ||
) => `The object ${objectID} could not be updated!` + (error ? ` Reason: ${error}` : ''), | ||
cannotDeleteObject: ( | ||
/** @type {string} */ objectID, | ||
/** @type {string?} */ error | ||
) => `The object ${objectID} cannot be deleted!` + (error ? ` Reason: ${error}` : ''), | ||
cannotDeleteObjectFromEnums: ( | ||
/** @type {string} */ objectID, | ||
/** @type {string?} */ error | ||
) => `The object ${objectID} could not be deleted from enums!` + (error ? ` Reason: ${error}` : ''), | ||
cannotChangeObject: ( | ||
/** @type {string} */ objectID, | ||
/** @type {string?} */ error | ||
) => `The object ${objectID} cannot be changed!` + (error ? ` Reason: ${error}` : ''), | ||
objectPropertyNotFound: ( | ||
/** @type {string} */ objectID, | ||
/** @type {string} */ propPath | ||
) => `The requested property "${propPath}" or one of its parents was not found in the object "${objectID}"!`, | ||
stateNotFound: (/** @type {string} */ stateID, /** @type {string?} */ error) => | ||
`The state ${stateID} was not found!` + (error ? ` Reason: ${error}` : ''), | ||
objectNotFound: (/** @type {string} */ objectID, /** @type {string?} */ error) => | ||
`The object ${objectID} was not found!` + (error ? ` Reason: ${error}` : ''), | ||
cannotUpdateObject: (/** @type {string} */ objectID, /** @type {string?} */ error) => | ||
`The object ${objectID} could not be updated!` + (error ? ` Reason: ${error}` : ''), | ||
cannotDeleteObject: (/** @type {string} */ objectID, /** @type {string?} */ error) => | ||
`The object ${objectID} cannot be deleted!` + (error ? ` Reason: ${error}` : ''), | ||
cannotDeleteObjectFromEnums: (/** @type {string} */ objectID, /** @type {string?} */ error) => | ||
`The object ${objectID} could not be deleted from enums!` + (error ? ` Reason: ${error}` : ''), | ||
cannotChangeObject: (/** @type {string} */ objectID, /** @type {string?} */ error) => | ||
`The object ${objectID} cannot be changed!` + (error ? ` Reason: ${error}` : ''), | ||
objectPropertyNotFound: (/** @type {string} */ objectID, /** @type {string} */ propPath) => | ||
`The requested property "${propPath}" or one of its parents was not found in the object "${objectID}"!`, | ||
invalidPropertyOrValue: () => `The property path or value is not valid. Please make sure the value is valid JSON.`, | ||
invalidJSONValue: () => `The given value is not valid JSON.`, | ||
unknownCommand: ( | ||
/** @type {string} */ prefix, | ||
/** @type {string} */ command | ||
) => `Unknown command "${prefix} ${command}"!`, | ||
requiredArgumentMissing: ( | ||
/** @type {string} */ argName, | ||
/** @type {string?} */ exampleCommand | ||
) => `The required argument "${argName}" is missing!` + (exampleCommand ? ` Example: "${exampleCommand}"` : ''), | ||
unknownCommand: (/** @type {string} */ prefix, /** @type {string} */ command) => | ||
`Unknown command "${prefix} ${command}"!`, | ||
requiredArgumentMissing: (/** @type {string} */ argName, /** @type {string?} */ exampleCommand) => | ||
`The required argument "${argName}" is missing!` + (exampleCommand ? ` Example: "${exampleCommand}"` : ''), | ||
noInstancesFound: adapter => `Cannot find any instances of "${adapter}"!`, | ||
invalidInstance: instance => `The instance "${instance}" does not exist!`, | ||
specifyInstance: (/** @type {string} */ adapter, /** @type {Array<string>?} */adapterInstances) => `The adapter "${adapter}" has multiple instances! Please specify which one should be started: "${adapterInstances.join('", "')}".`, | ||
specifyInstance: (/** @type {string} */ adapter, /** @type {Array<string>?} */ adapterInstances) => | ||
`The adapter "${adapter}" has multiple instances! Please specify which one should be started: "${adapterInstances.join( | ||
'", "' | ||
)}".`, | ||
adapterDirNotFound: adapter => `Cannot find the installation dir for adapter "${adapter}"!`, | ||
@@ -57,4 +42,6 @@ mainFileNotFound: adapter => `Cannot find the main file for adapter "${adapter}"!`, | ||
/** @type {string?} */ correctPrefix | ||
) => `The command ${command} is not intended to be used with ${wrongPrefix}!` | ||
+ correctPrefix ? `Please use "${correctPrefix} ${command}" instead.` : '', | ||
) => | ||
`The command ${command} is not intended to be used with ${wrongPrefix}!` + correctPrefix | ||
? `Please use "${correctPrefix} ${command}" instead.` | ||
: '', | ||
unknown: err => `An unknown error occurred: ${err}`, | ||
@@ -68,3 +55,4 @@ | ||
pluginNotDefined: (pluginName, host, instance) => `The plugin "${pluginName}" does not exist for ${host ? `host "${host}"` : `instance "${instance}"`}!`, | ||
pluginNotDefined: (pluginName, host, instance) => | ||
`The plugin "${pluginName}" does not exist for ${host ? `host "${host}"` : `instance "${instance}"`}!`, | ||
@@ -77,7 +65,4 @@ cert: certName => `Certificate "${certName}" not found or error parsing certificate information.` | ||
objectDeleted: objectID => `The object "${objectID}" was deleted.`, | ||
stateUpdated: ( | ||
/** @type {string} */ stateID, | ||
/** @type {any} */ value, | ||
/** @type {boolean | undefined} */ ack | ||
) => `The state "${stateID}" was set to "${value}"${ack === undefined ? '' : ` with flag ack=${ack}`}`, | ||
stateUpdated: (/** @type {string} */ stateID, /** @type {any} */ value, /** @type {boolean | undefined} */ ack) => | ||
`The state "${stateID}" was set to "${value}"${ack === undefined ? '' : ` with flag ack=${ack}`}`, | ||
stateDeleted: stateID => `The state "${stateID}" was deleted.`, | ||
@@ -87,26 +72,26 @@ adapterStarted: adapter => `The adapter "${adapter}" was started.`, | ||
adapterRestarted: adapter => `The adapter "${adapter}" was restarted.`, | ||
systemStatus: isRunning => isRunning ? `At least one ${tools.appName} host is running.` : `No ${tools.appName} host is running.`, | ||
systemStatus: isRunning => | ||
isRunning ? `At least one ${tools.appName} host is running.` : `No ${tools.appName} host is running.`, | ||
controllerStatus: isRunning => `${tools.appName} is ${isRunning ? '' : 'not '}running on this host.`, | ||
messageSent: ( | ||
/** @type {string} */ adapter, | ||
/** @type {string} */ command, | ||
/** @type {any} */ message | ||
) => `The command "${command}" was sent to "${adapter}" with the message "${message}".`, | ||
hostRenamed: ( | ||
/** @type {string} */ from, | ||
/** @type {string} */ to | ||
) => `Host "${from}" successfully renamed to "${to}".`, | ||
instanceHostChanged: ( | ||
/** @type {string} */ instance, | ||
/** @type {string} */ from, | ||
/** @type {string} */ to | ||
) => `The host for instance "${instance}" was changed from "${from}" to "${to}".`, | ||
messageSent: (/** @type {string} */ adapter, /** @type {string} */ command, /** @type {any} */ message) => | ||
`The command "${command}" was sent to "${adapter}" with the message "${message}".`, | ||
hostRenamed: (/** @type {string} */ from, /** @type {string} */ to) => | ||
`Host "${from}" successfully renamed to "${to}".`, | ||
instanceHostChanged: (/** @type {string} */ instance, /** @type {string} */ from, /** @type {string} */ to) => | ||
`The host for instance "${instance}" was changed from "${from}" to "${to}".`, | ||
hostDeleted: hostname => `The host "${hostname}" was deleted.`, | ||
pluginEnabledOrDisabled: (pluginName, host, instance, status) => `The plugin "${pluginName}" was successfully ${status ? 'enabled' : 'disabled'} for ${host ? `host "${host}"` : `instance "${instance}"`}.`, | ||
pluginStatus: (pluginName, host, instance, status) => `The plugin "${pluginName}" is ${status ? 'enabled' : 'disabled'} for ${host ? `host "${host}"` : `instance "${instance}"`}.` | ||
pluginEnabledOrDisabled: (pluginName, host, instance, status) => | ||
`The plugin "${pluginName}" was successfully ${status ? 'enabled' : 'disabled'} for ${ | ||
host ? `host "${host}"` : `instance "${instance}"` | ||
}.`, | ||
pluginStatus: (pluginName, host, instance, status) => | ||
`The plugin "${pluginName}" is ${status ? 'enabled' : 'disabled'} for ${ | ||
host ? `host "${host}"` : `instance "${instance}"` | ||
}.` | ||
}); | ||
const warnings = Object.freeze({ | ||
noInstancesFoundOnHost: hostname => hostname ? `No instances found for host "${hostname}"!` : `No instances found!` | ||
noInstancesFoundOnHost: hostname => | ||
hostname ? `No instances found for host "${hostname}"!` : `No instances found!` | ||
}); | ||
@@ -113,0 +98,0 @@ |
@@ -18,6 +18,6 @@ /** | ||
if (!options.states) { | ||
if (!options.states) { | ||
throw new Error('Invalid Modified arguments: states is missing'); | ||
} | ||
if (!options.objects) { | ||
if (!options.objects) { | ||
throw new Error('Invalid arguments: objects is missing'); | ||
@@ -30,3 +30,3 @@ } | ||
const { tools } = require('@iobroker/js-controller-common'); | ||
const fs = require('fs-extra'); | ||
const fs = require('fs-extra'); | ||
const { EXIT_CODES } = require('@iobroker/js-controller-common'); | ||
@@ -36,5 +36,5 @@ | ||
const objects = options.objects; | ||
const states = options.states; | ||
const processExit = options.processExit; | ||
const objects = options.objects; | ||
const states = options.states; | ||
const processExit = options.processExit; | ||
@@ -44,13 +44,13 @@ function perm2str(perm) { | ||
// user | ||
result += (perm & 0x400) ? 'r' : '-'; | ||
result += (perm & 0x200) ? 'w' : '-'; | ||
result += (perm & 0x100) ? 'x' : '-'; | ||
result += perm & 0x400 ? 'r' : '-'; | ||
result += perm & 0x200 ? 'w' : '-'; | ||
result += perm & 0x100 ? 'x' : '-'; | ||
// group | ||
result += (perm & 0x040) ? 'r' : '-'; | ||
result += (perm & 0x020) ? 'w' : '-'; | ||
result += (perm & 0x010) ? 'x' : '-'; | ||
result += perm & 0x040 ? 'r' : '-'; | ||
result += perm & 0x020 ? 'w' : '-'; | ||
result += perm & 0x010 ? 'x' : '-'; | ||
// any | ||
result += (perm & 0x004) ? 'r' : '-'; | ||
result += (perm & 0x002) ? 'w' : '-'; | ||
result += (perm & 0x001) ? 'x' : '-'; | ||
result += perm & 0x004 ? 'r' : '-'; | ||
result += perm & 0x002 ? 'w' : '-'; | ||
result += perm & 0x001 ? 'x' : '-'; | ||
return result; | ||
@@ -79,3 +79,3 @@ } | ||
if (file.acl){ | ||
if (file.acl) { | ||
text += (file.isDir ? 'd' : '-') + perm2str(file.acl.permissions || 0); | ||
@@ -106,3 +106,3 @@ let owner = file.acl.owner; | ||
} | ||
let size = (file.stats && file.stats.size) ? file.stats.size.toString() : ''; | ||
let size = file.stats && file.stats.size ? file.stats.size.toString() : ''; | ||
if (size.length < 7) { | ||
@@ -112,3 +112,3 @@ size = new Array(7 - size.length).join(' ') + size; | ||
text += ' ' + size + ' ' + adapter + ((!path || path[0] === '/') ? '' : '/') + path + '/' + file.file; | ||
text += ' ' + size + ' ' + adapter + (!path || path[0] === '/' ? '' : '/') + path + '/' + file.file; | ||
if (file.isDir) { | ||
@@ -130,4 +130,7 @@ text += '/'; | ||
let text = ''; | ||
if (obj.acl){ | ||
text += perm2str(obj.acl.object || 0) + ' ' + ((obj.type === 'state') ? perm2str(obj.acl.state || 0) : ' '); | ||
if (obj.acl) { | ||
text += | ||
perm2str(obj.acl.object || 0) + | ||
' ' + | ||
(obj.type === 'state' ? perm2str(obj.acl.state || 0) : ' '); | ||
let owner = obj.acl.owner; | ||
@@ -154,3 +157,3 @@ if (owner) { | ||
} else { | ||
text += '?????????' + ((obj.type === 'state') ? ' ?????????' : ' ') + new Array(31).join(' '); | ||
text += '?????????' + (obj.type === 'state' ? ' ?????????' : ' ') + new Array(31).join(' '); | ||
} | ||
@@ -191,3 +194,3 @@ text += ' ' + obj._id; | ||
if (files[f].file === fname) { | ||
allFiles.push({adapter: adapter, path: path, file: files[f]}); | ||
allFiles.push({ adapter: adapter, path: path, file: files[f] }); | ||
break; | ||
@@ -208,3 +211,3 @@ } | ||
} | ||
allFiles.push({adapter: adapter, path: path, file: files[f]}); | ||
allFiles.push({ adapter: adapter, path: path, file: files[f] }); | ||
if (files[f].isDir) { | ||
@@ -226,3 +229,3 @@ count++; | ||
function sortFiles (a, b) { | ||
function sortFiles(a, b) { | ||
let a1 = a.path + a.file.file; | ||
@@ -257,3 +260,4 @@ if (a1[0] !== '/') { | ||
files.filter(f => !filter || (f.path + '/'+ f.file.file).startsWith(filter)) | ||
files | ||
.filter(f => !filter || (f.path + '/' + f.file.file).startsWith(filter)) | ||
.forEach(f => that.showFile(f.adapter, f.path, f.file)); | ||
@@ -264,3 +268,3 @@ | ||
} else { | ||
typeof callback === 'function' && callback (); | ||
typeof callback === 'function' && callback(); | ||
} | ||
@@ -296,12 +300,17 @@ }; | ||
for (let i = 0; i < objs.rows.length; i++) { | ||
let name = objs.rows[i].value && objs.rows[i].value.common && objs.rows[i].value.common.name; | ||
let name = | ||
objs.rows[i].value && objs.rows[i].value.common && objs.rows[i].value.common.name; | ||
if (typeof name === 'object') { | ||
name = name[lang] || name.en; | ||
} | ||
if (!reg || reg.test(objs.rows[i].value._id) || (objs.rows[i].value.common && reg.test(name))) { | ||
if ( | ||
!reg || | ||
reg.test(objs.rows[i].value._id) || | ||
(objs.rows[i].value.common && reg.test(name)) | ||
) { | ||
if (objs.rows[i].value.type) { | ||
let id = objs.rows[i].value._id; | ||
let type = objs.rows[i].value.type; | ||
if (id.length < 40) { | ||
id += new Array(40 - id.length).join(' '); | ||
if (id.length < 40) { | ||
id += new Array(40 - id.length).join(' '); | ||
} | ||
@@ -347,3 +356,13 @@ if (type.length < 10) { | ||
} | ||
console.log(id + ': from [' + from + '] (' + type + ') ' + (states[i].ack ? ' ack': 'not ack') + ' ' + JSON.stringify(states[i].val)); | ||
console.log( | ||
id + | ||
': from [' + | ||
from + | ||
'] (' + | ||
type + | ||
') ' + | ||
(states[i].ack ? ' ack' : 'not ack') + | ||
' ' + | ||
JSON.stringify(states[i].val) | ||
); | ||
} | ||
@@ -357,29 +376,35 @@ setTimeout(processExit, 1000, null); | ||
case 'a': | ||
objects.getObjectList({startkey: 'system.adapter.', endkey: 'system.adapter.\u9999'}, (err, objs) => { | ||
const reg = filter ? new RegExp(tools.pattern2RegEx('system.adapter.' + filter)) : null; | ||
for (let i = 0; i < objs.rows.length; i++) { | ||
if (objs.rows[i].value.type !== 'adapter') { | ||
continue; | ||
} | ||
if (!reg || reg.test(objs.rows[i].value._id) || (objs.rows[i].value.common && reg.test(objs.rows[i].value.common.name))) { | ||
let id = objs.rows[i].value._id; | ||
let name = objs.rows[i].value.common.name; | ||
if (typeof name === 'object') { | ||
name = name[lang] || name.en; | ||
objects.getObjectList( | ||
{ startkey: 'system.adapter.', endkey: 'system.adapter.\u9999' }, | ||
(err, objs) => { | ||
const reg = filter ? new RegExp(tools.pattern2RegEx('system.adapter.' + filter)) : null; | ||
for (let i = 0; i < objs.rows.length; i++) { | ||
if (objs.rows[i].value.type !== 'adapter') { | ||
continue; | ||
} | ||
if (id.length < 40) { | ||
id += new Array(40 - id.length).join(' '); | ||
} | ||
if (name.length < 15) { | ||
name += new Array(15 - name.length).join(' '); | ||
} | ||
if ( | ||
!reg || | ||
reg.test(objs.rows[i].value._id) || | ||
(objs.rows[i].value.common && reg.test(objs.rows[i].value.common.name)) | ||
) { | ||
let id = objs.rows[i].value._id; | ||
let name = objs.rows[i].value.common.name; | ||
if (typeof name === 'object') { | ||
name = name[lang] || name.en; | ||
} | ||
if (id.length < 40) { | ||
id += new Array(40 - id.length).join(' '); | ||
} | ||
if (name.length < 15) { | ||
name += new Array(15 - name.length).join(' '); | ||
} | ||
const text = id + ': ' + name + ' - v' + | ||
objs.rows[i].value.common.version; | ||
const text = id + ': ' + name + ' - v' + objs.rows[i].value.common.version; | ||
console.log(text); | ||
console.log(text); | ||
} | ||
} | ||
setTimeout(processExit, 1000, null); | ||
} | ||
setTimeout(processExit, 1000, null); | ||
}); | ||
); | ||
break; | ||
@@ -389,78 +414,95 @@ | ||
case 'i': | ||
objects.getObjectList({startkey: 'system.adapter.', endkey: 'system.adapter.\u9999'}, (err, objs) => { | ||
const reg = filter ? new RegExp(tools.pattern2RegEx('system.adapter.' + filter)) : null; | ||
objs.rows.sort((a, b) => { | ||
if (a.id > b.id) { | ||
return 1; | ||
} else if (a.id < b.id) { | ||
return -1; | ||
} | ||
return 0; | ||
}); | ||
const lines = []; | ||
for (const row of objs.rows) { | ||
if (row.value.type !== 'instance') { | ||
continue; | ||
} | ||
if (!reg || reg.test(row.value._id) || (row.value.common && reg.test(row.value.common.name))) { | ||
if (flags.enabled && !row.value.common.enabled) { | ||
continue; | ||
objects.getObjectList( | ||
{ startkey: 'system.adapter.', endkey: 'system.adapter.\u9999' }, | ||
(err, objs) => { | ||
const reg = filter ? new RegExp(tools.pattern2RegEx('system.adapter.' + filter)) : null; | ||
objs.rows.sort((a, b) => { | ||
if (a.id > b.id) { | ||
return 1; | ||
} else if (a.id < b.id) { | ||
return -1; | ||
} | ||
if (flags.disabled && row.value.common.enabled) { | ||
return 0; | ||
}); | ||
const lines = []; | ||
for (const row of objs.rows) { | ||
if (row.value.type !== 'instance') { | ||
continue; | ||
} | ||
if (flags.port && row.value.native.port === undefined) { | ||
continue; | ||
} | ||
if (flags.ssl && row.value.native.secure === undefined) { | ||
continue; | ||
} | ||
if (flags.ip && row.value.native.bind === undefined) { | ||
continue; | ||
} | ||
if ( | ||
!reg || | ||
reg.test(row.value._id) || | ||
(row.value.common && reg.test(row.value.common.name)) | ||
) { | ||
if (flags.enabled && !row.value.common.enabled) { | ||
continue; | ||
} | ||
if (flags.disabled && row.value.common.enabled) { | ||
continue; | ||
} | ||
if (flags.port && row.value.native.port === undefined) { | ||
continue; | ||
} | ||
if (flags.ssl && row.value.native.secure === undefined) { | ||
continue; | ||
} | ||
if (flags.ip && row.value.native.bind === undefined) { | ||
continue; | ||
} | ||
let id = row.value._id; | ||
let name = row.value.common.name; | ||
let host = row.value.common.host; | ||
if (typeof name === 'object') { | ||
name = name[lang] || name.en; | ||
} | ||
if (id.length < 40) { | ||
id = id.padEnd(40); | ||
} | ||
if (name && name.length < 22) { | ||
name = name.padEnd(22); | ||
} | ||
let id = row.value._id; | ||
let name = row.value.common.name; | ||
let host = row.value.common.host; | ||
if (typeof name === 'object') { | ||
name = name[lang] || name.en; | ||
} | ||
if (id.length < 40) { | ||
id = id.padEnd(40); | ||
} | ||
if (name && name.length < 22) { | ||
name = name.padEnd(22); | ||
} | ||
if (host && host.length < 40) { | ||
host = host.padEnd(40); | ||
} | ||
if (host && host.length < 40) { | ||
host = host.padEnd(40); | ||
} | ||
let text = `${id}: ${name || ''}: ${host} - ${row.value.common.enabled ? ' enabled' : 'disabled'}`; | ||
let text = `${id}: ${name || ''}: ${host} - ${ | ||
row.value.common.enabled ? ' enabled' : 'disabled' | ||
}`; | ||
if (this.config.system && this.config.system.compact && row.value.common.compact) { | ||
text += ', compact ' + (row.value.common.compact && row.value.common.runAsCompactMode ? 'enabled (group ' + (row.value.common.compactGroup !== undefined ? row.value.common.compactGroup : 1) + ')' : 'disabled'); | ||
} | ||
if (this.config.system && this.config.system.compact && row.value.common.compact) { | ||
text += | ||
', compact ' + | ||
(row.value.common.compact && row.value.common.runAsCompactMode | ||
? 'enabled (group ' + | ||
(row.value.common.compactGroup !== undefined | ||
? row.value.common.compactGroup | ||
: 1) + | ||
')' | ||
: 'disabled'); | ||
} | ||
if (row.value.native && row.value.native.port) { | ||
text += `, port: ${row.value.native.port}`; | ||
if (row.value.native && row.value.native.port) { | ||
text += `, port: ${row.value.native.port}`; | ||
} | ||
if (row.value.native && row.value.native.bind) { | ||
text += `, bind: ${row.value.native.bind}`; | ||
} | ||
if (row.value.native && row.value.native.secure) { | ||
text += ' (SSL)'; | ||
} | ||
if (row.value.native && row.value.native.defaultUser) { | ||
text += `, run as: ${row.value.native.defaultUser}`; | ||
} | ||
lines.push({ id: row.value._id, value: text }); | ||
} | ||
if (row.value.native && row.value.native.bind) { | ||
text += `, bind: ${row.value.native.bind}`; | ||
} | ||
if (row.value.native && row.value.native.secure) { | ||
text += ' (SSL)'; | ||
} | ||
if (row.value.native && row.value.native.defaultUser) { | ||
text += `, run as: ${row.value.native.defaultUser}`; | ||
} | ||
lines.push({id: row.value._id, value: text}); | ||
} | ||
readOnlineState(lines, flags, result => { | ||
console.log(result.join('\n')); | ||
console.log('\n+ instance is alive'); | ||
setTimeout(processExit, 1000, null); | ||
}); | ||
} | ||
readOnlineState(lines, flags, result => { | ||
console.log(result.join('\n')); | ||
console.log('\n+ instance is alive'); | ||
setTimeout(processExit, 1000, null); | ||
}); | ||
}); | ||
); | ||
break; | ||
@@ -470,39 +512,57 @@ | ||
case 'u': | ||
objects.getObjectList({startkey: 'system.user.', endkey: 'system.user.\u9999'}, (err, objs) => { | ||
objects.getObjectList({startkey: 'system.group.', endkey: 'system.group.\u9999'}, (err, groups) => { | ||
const reg = filter ? new RegExp(tools.pattern2RegEx('system.user.' + filter)) : null; | ||
console.log(' ID | Name | Active | Groups'); | ||
console.log('---------------------------------------+-------------+----------+--------------'); | ||
for (let i = 0; i < objs.rows.length; i++) { | ||
if (objs.rows[i].value.type !== 'user') { | ||
continue; | ||
} | ||
if (!reg || reg.test(objs.rows[i].value._id) || (objs.rows[i].value.common && reg.test(objs.rows[i].value.common.name))) { | ||
let id = objs.rows[i].value._id; | ||
let name = objs.rows[i].value.common.name; | ||
if (typeof name === 'object') { | ||
name = name[lang] || name.en; | ||
objects.getObjectList({ startkey: 'system.user.', endkey: 'system.user.\u9999' }, (err, objs) => { | ||
objects.getObjectList( | ||
{ startkey: 'system.group.', endkey: 'system.group.\u9999' }, | ||
(err, groups) => { | ||
const reg = filter ? new RegExp(tools.pattern2RegEx('system.user.' + filter)) : null; | ||
console.log(' ID | Name | Active | Groups'); | ||
console.log( | ||
'---------------------------------------+-------------+----------+--------------' | ||
); | ||
for (let i = 0; i < objs.rows.length; i++) { | ||
if (objs.rows[i].value.type !== 'user') { | ||
continue; | ||
} | ||
if (id.length < 40) { | ||
id += new Array(40 - id.length).join(' '); | ||
} | ||
if (name.length < 12) { | ||
name += new Array(12 - name.length).join(' '); | ||
} | ||
const text = id + '| ' + name + ' | ' + | ||
(objs.rows[i].value.common.enabled ? ' enabled' : 'disabled') + ' |'; | ||
const gs = []; | ||
// find all groups | ||
for (let g = 0; g < groups.rows.length; g++) { | ||
if (groups.rows[g].value.common.members && groups.rows[g].value.common.members.indexOf(objs.rows[i].value._id) !== -1) { | ||
gs.push(groups.rows[g].value._id.substring(13)); | ||
if ( | ||
!reg || | ||
reg.test(objs.rows[i].value._id) || | ||
(objs.rows[i].value.common && reg.test(objs.rows[i].value.common.name)) | ||
) { | ||
let id = objs.rows[i].value._id; | ||
let name = objs.rows[i].value.common.name; | ||
if (typeof name === 'object') { | ||
name = name[lang] || name.en; | ||
} | ||
if (id.length < 40) { | ||
id += new Array(40 - id.length).join(' '); | ||
} | ||
if (name.length < 12) { | ||
name += new Array(12 - name.length).join(' '); | ||
} | ||
const text = | ||
id + | ||
'| ' + | ||
name + | ||
' | ' + | ||
(objs.rows[i].value.common.enabled ? ' enabled' : 'disabled') + | ||
' |'; | ||
const gs = []; | ||
// find all groups | ||
for (let g = 0; g < groups.rows.length; g++) { | ||
if ( | ||
groups.rows[g].value.common.members && | ||
groups.rows[g].value.common.members.indexOf(objs.rows[i].value._id) !== | ||
-1 | ||
) { | ||
gs.push(groups.rows[g].value._id.substring(13)); | ||
} | ||
} | ||
console.log(text + ' ' + gs.join(', ')); | ||
} | ||
console.log(text + ' ' + gs.join(', ')); | ||
} | ||
setTimeout(processExit, 1000, null); | ||
} | ||
setTimeout(processExit, 1000, null); | ||
}); | ||
); | ||
}); | ||
@@ -513,8 +573,14 @@ break; | ||
case 'g': | ||
objects.getObjectList({startkey: 'system.group.', endkey: 'system.group.\u9999'}, (err, objs) => { | ||
objects.getObjectList({ startkey: 'system.group.', endkey: 'system.group.\u9999' }, (err, objs) => { | ||
const reg = filter ? new RegExp(tools.pattern2RegEx('system.group.' + filter)) : null; | ||
console.log(''); | ||
console.log(' system.group | object | state | file | user | others | users'); | ||
console.log(' | l r w d | l r w d | l r w c d | w c d | |'); | ||
console.log('--------------------+---------+---------+-----------+-------+------------------------+---------'); | ||
console.log( | ||
' system.group | object | state | file | user | others | users' | ||
); | ||
console.log( | ||
' | l r w d | l r w d | l r w c d | w c d | |' | ||
); | ||
console.log( | ||
'--------------------+---------+---------+-----------+-------+------------------------+---------' | ||
); | ||
for (let i = 0; i < objs.rows.length; i++) { | ||
@@ -524,4 +590,8 @@ if (objs.rows[i].value.type !== 'group') { | ||
} | ||
if (!reg || reg.test(objs.rows[i].value._id) || (objs.rows[i].value.common && reg.test(objs.rows[i].value.common.name))) { | ||
let id = objs.rows[i].value._id.substring(13); | ||
if ( | ||
!reg || | ||
reg.test(objs.rows[i].value._id) || | ||
(objs.rows[i].value.common && reg.test(objs.rows[i].value.common.name)) | ||
) { | ||
let id = objs.rows[i].value._id.substring(13); | ||
//let name = objs.rows[i].value.common.name; | ||
@@ -534,3 +604,3 @@ | ||
write: true, | ||
'delete': true, | ||
delete: true, | ||
create: true, | ||
@@ -542,3 +612,3 @@ list: true | ||
write: true, | ||
'delete': true, | ||
delete: true, | ||
list: true | ||
@@ -549,10 +619,10 @@ }, | ||
write: true, | ||
'delete': true, | ||
delete: true, | ||
create: true, | ||
list: true | ||
}, | ||
user: { | ||
user: { | ||
write: true, | ||
create: true, | ||
'delete': true | ||
delete: true | ||
}, | ||
@@ -573,6 +643,6 @@ other: { | ||
if (objs.rows[i].value.common.acl && objs.rows[i].value.common.acl.object) { | ||
text += (objs.rows[i].value.common.acl.object.list ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.object.read ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.object.write ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.object.delete ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.object.list ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.object.read ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.object.write ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.object.delete ? '+' : '-') + ' '; | ||
text += '|'; | ||
@@ -584,6 +654,6 @@ } else { | ||
text += ' '; | ||
text +=(objs.rows[i].value.common.acl.state.list ? '+': '-') + ' '; | ||
text +=(objs.rows[i].value.common.acl.state.read ? '+': '-') + ' '; | ||
text +=(objs.rows[i].value.common.acl.state.write ? '+': '-') + ' '; | ||
text +=(objs.rows[i].value.common.acl.state.delete ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.state.list ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.state.read ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.state.write ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.state.delete ? '+' : '-') + ' '; | ||
text += '|'; | ||
@@ -595,7 +665,7 @@ } else { | ||
text += ' '; | ||
text += (objs.rows[i].value.common.acl.file.list ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.file.read ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.file.write ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.file.create ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.file.delete ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.file.list ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.file.read ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.file.write ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.file.create ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.file.delete ? '+' : '-') + ' '; | ||
text += '|'; | ||
@@ -607,5 +677,5 @@ } else { | ||
text += ' '; | ||
text += (objs.rows[i].value.common.acl.users.write ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.users.create ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.users.delete ? '+': '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.users.write ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.users.create ? '+' : '-') + ' '; | ||
text += (objs.rows[i].value.common.acl.users.delete ? '+' : '-') + ' '; | ||
text += '|'; | ||
@@ -630,5 +700,6 @@ } else { | ||
//if (name.length < 30) name += new Array(30 - name.length).join(' '); | ||
if ( objs.rows[i].value.common.members) { | ||
if (objs.rows[i].value.common.members) { | ||
for (let m = 0; m < objs.rows[i].value.common.members.length; m++) { | ||
objs.rows[i].value.common.members[m] = objs.rows[i].value.common.members[m].substring(12); | ||
objs.rows[i].value.common.members[m] = | ||
objs.rows[i].value.common.members[m].substring(12); | ||
} | ||
@@ -642,3 +713,5 @@ text += ' ' + objs.rows[i].value.common.members.join(', '); | ||
console.log('--------------------+---------+---------+-----------+-------+------------------------+---------'); | ||
console.log( | ||
'--------------------+---------+---------+-----------+-------+------------------------+---------' | ||
); | ||
console.log('Legend: (l)ist, (r)ead, (w)rite, (c)reate, (d)elete'); | ||
@@ -651,3 +724,3 @@ setTimeout(processExit, 1000, null); | ||
case 'hosts': | ||
objects.getObjectList({startkey: 'system.host.', endkey: 'system.host.\u9999'}, (err, objs) => { | ||
objects.getObjectList({ startkey: 'system.host.', endkey: 'system.host.\u9999' }, (err, objs) => { | ||
states.getKeys('system.host.*', (err, keys) => { | ||
@@ -661,4 +734,8 @@ states.getStates(keys, (err, states) => { | ||
} | ||
if (!reg || reg.test(objs.rows[i].value._id) || (objs.rows[i].value.common && reg.test(objs.rows[i].value.common.name))) { | ||
let id = objs.rows[i].value._id.substring(12); | ||
if ( | ||
!reg || | ||
reg.test(objs.rows[i].value._id) || | ||
(objs.rows[i].value.common && reg.test(objs.rows[i].value.common.name)) | ||
) { | ||
let id = objs.rows[i].value._id.substring(12); | ||
let name = objs.rows[i].value.common.name; | ||
@@ -675,4 +752,4 @@ if (typeof name === 'object') { | ||
} | ||
const version = objs.rows[i].value.common.installedVersion; | ||
let alive = ''; | ||
const version = objs.rows[i].value.common.installedVersion; | ||
let alive = ''; | ||
let uptime = ''; | ||
@@ -687,3 +764,3 @@ for (let k = 0; k < keys.length; k++) { | ||
} | ||
alive = alive ? 'alive' : ' dead'; | ||
alive = alive ? 'alive' : ' dead'; | ||
//if (uptime.toString().length < 10) uptime = new Array(10 - uptime.toString().length).join(' ') + uptime.toString(); | ||
@@ -693,3 +770,15 @@ if (!uptime) { | ||
} | ||
const text = id + ' ' + name + ' (version: ' + version + ', hostname: ' + hostname + ', ' + alive + ', uptime: ' + uptime + ')'; | ||
const text = | ||
id + | ||
' ' + | ||
name + | ||
' (version: ' + | ||
version + | ||
', hostname: ' + | ||
hostname + | ||
', ' + | ||
alive + | ||
', uptime: ' + | ||
uptime + | ||
')'; | ||
// todo | ||
@@ -708,3 +797,3 @@ console.log(text); | ||
case 'e': | ||
objects.getObjectList({startkey: 'enum.', endkey: 'enum.\u9999'}, (err, objs) => { | ||
objects.getObjectList({ startkey: 'enum.', endkey: 'enum.\u9999' }, (err, objs) => { | ||
const reg = filter ? new RegExp(tools.pattern2RegEx('enum.' + filter)) : null; | ||
@@ -715,5 +804,11 @@ for (let i = 0; i < objs.rows.length; i++) { | ||
} | ||
if (!reg || reg.test(objs.rows[i].value._id) || (objs.rows[i].value.common && reg.test(objs.rows[i].value.common.name))) { | ||
console.log('\n====================================================================================='); | ||
let id = objs.rows[i].value._id.substring(5); | ||
if ( | ||
!reg || | ||
reg.test(objs.rows[i].value._id) || | ||
(objs.rows[i].value.common && reg.test(objs.rows[i].value.common.name)) | ||
) { | ||
console.log( | ||
'\n=====================================================================================' | ||
); | ||
let id = objs.rows[i].value._id.substring(5); | ||
let name = objs.rows[i].value.common.name; | ||
@@ -727,3 +822,5 @@ if (typeof name === 'object') { | ||
console.log(id + '(' + name + ')'); | ||
console.log('-------------------------------------------------------------------------------------'); | ||
console.log( | ||
'-------------------------------------------------------------------------------------' | ||
); | ||
@@ -741,3 +838,3 @@ if (objs.rows[i].value.common.members) { | ||
case 'f': | ||
objects.getObjectList({startkey: '', endkey: '\u9999'}, (err, objs) => { | ||
objects.getObjectList({ startkey: '', endkey: '\u9999' }, (err, objs) => { | ||
const adapter = filter || null; | ||
@@ -749,3 +846,13 @@ const names = filter ? filter.split('/') : null; | ||
const adapters = objs.rows.filter(row => row.value.type === 'meta' && !(adapter && row.value._id !== names[0] && !row.value._id.startsWith(`${names[0]}.`))).map(row => row.value._id); | ||
const adapters = objs.rows | ||
.filter( | ||
row => | ||
row.value.type === 'meta' && | ||
!( | ||
adapter && | ||
row.value._id !== names[0] && | ||
!row.value._id.startsWith(`${names[0]}.`) | ||
) | ||
) | ||
.map(row => row.value._id); | ||
@@ -755,3 +862,4 @@ names && names.shift(); | ||
that.listAdaptersFiles(adapters, names ? names.join('/') : null, () => | ||
setTimeout(processExit, 1000, null)); | ||
setTimeout(processExit, 1000, null) | ||
); | ||
}); | ||
@@ -765,3 +873,5 @@ break; | ||
} else { | ||
console.log('Please specify type: objects, states, instances, adapters, users, groups, enums, files'); | ||
console.log( | ||
'Please specify type: objects, states, instances, adapters, users, groups, enums, files' | ||
); | ||
processExit(); | ||
@@ -768,0 +878,0 @@ } |
{ | ||
"name": "@iobroker/js-controller-cli", | ||
"version": "4.0.0-alpha.25-20211211-1232a951", | ||
"version": "4.0.0-alpha.26-20211214-19e8d05e", | ||
"engines": { | ||
@@ -8,4 +8,4 @@ "node": ">=12.0.0" | ||
"dependencies": { | ||
"@iobroker/js-controller-common": "4.0.0-alpha.25-20211211-1232a951", | ||
"@iobroker/js-controller-common-db": "4.0.0-alpha.25-20211211-1232a951", | ||
"@iobroker/js-controller-common": "4.0.0-alpha.26-20211214-19e8d05e", | ||
"@iobroker/js-controller-common-db": "4.0.0-alpha.26-20211214-19e8d05e", | ||
"chokidar": "^3.5.2", | ||
@@ -41,3 +41,3 @@ "daemonize2": "^0.4.2", | ||
], | ||
"gitHead": "f1cdd329b8fd9a6c442ace4fd1c50a1e7f53d381" | ||
"gitHead": "b192169960992cc360b1f6c297a6ec0877e2558f" | ||
} |
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
149041
3330
+ Added@iobroker/db-base@4.0.0-alpha.26-20211214-19e8d05e(transitive)
+ Added@iobroker/db-objects-file@4.0.0-alpha.26-20211214-19e8d05e(transitive)
+ Added@iobroker/db-objects-jsonl@4.0.0-alpha.26-20211214-19e8d05e(transitive)
+ Added@iobroker/db-objects-redis@4.0.0-alpha.26-20211214-19e8d05e(transitive)
+ Added@iobroker/db-states-file@4.0.0-alpha.26-20211214-19e8d05e(transitive)
+ Added@iobroker/db-states-jsonl@4.0.0-alpha.26-20211214-19e8d05e(transitive)
+ Added@iobroker/db-states-redis@4.0.0-alpha.26-20211214-19e8d05e(transitive)
+ Added@iobroker/js-controller-common@4.0.0-alpha.26-20211214-19e8d05e(transitive)
+ Added@iobroker/js-controller-common-db@4.0.0-alpha.26-20211214-19e8d05e(transitive)
- Removed@iobroker/db-base@4.0.0-alpha.25-20211211-1232a951(transitive)
- Removed@iobroker/db-objects-file@4.0.0-alpha.25-20211211-1232a951(transitive)
- Removed@iobroker/db-objects-jsonl@4.0.0-alpha.25-20211211-1232a951(transitive)
- Removed@iobroker/db-objects-redis@4.0.0-alpha.25-20211211-1232a951(transitive)
- Removed@iobroker/db-states-file@4.0.0-alpha.25-20211211-1232a951(transitive)
- Removed@iobroker/db-states-jsonl@4.0.0-alpha.25-20211211-1232a951(transitive)
- Removed@iobroker/db-states-redis@4.0.0-alpha.25-20211211-1232a951(transitive)
- Removed@iobroker/js-controller-common@4.0.0-alpha.25-20211211-1232a951(transitive)
- Removed@iobroker/js-controller-common-db@4.0.0-alpha.25-20211211-1232a951(transitive)
Updated@iobroker/js-controller-common@4.0.0-alpha.26-20211214-19e8d05e
Updated@iobroker/js-controller-common-db@4.0.0-alpha.26-20211214-19e8d05e