|
2 | 2 | import * as crypto from "crypto"; |
3 | 3 | import * as fs from "fs"; |
4 | 4 | import * as os from "os"; |
| 5 | +import { TreeItem } from "performant-array-to-tree"; |
5 | 6 | import { URL } from "url"; |
6 | 7 | import { TimeStampedDataPoint } from ".."; |
7 | 8 | import { IMindConnectConfiguration } from "./mindconnect-models"; |
@@ -326,7 +327,7 @@ export function addAndStoreConfiguration(configuration: any) { |
326 | 327 | (!configuration || !configuration.credentials) && throwError("invalid configuration!"); |
327 | 328 | configuration.credentials.forEach((element: credentialEntry) => { |
328 | 329 | element.gateway = isUrl(element.gateway) ? element.gateway : `https://gateway.${element.gateway}.mindsphere.io`; |
329 | | - newConfiguration.credentials.push(element.passkey ? encrypt(element) : ((element as unknown) as authJson)); |
| 330 | + newConfiguration.credentials.push(element.passkey ? encrypt(element) : (element as unknown as authJson)); |
330 | 331 | }); |
331 | 332 | checkList(newConfiguration.credentials); |
332 | 333 | storeAuth(newConfiguration); |
@@ -406,3 +407,13 @@ export function isGuid(x: string): boolean { |
406 | 407 | const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; |
407 | 408 | return guidRegex.test(x); |
408 | 409 | } |
| 410 | + |
| 411 | +export function printTree(treeItem: TreeItem, level: number, color: (x: string) => string) { |
| 412 | + const prefix = level == 0 ? "" : "│ ".repeat(level) + "├─"; |
| 413 | + |
| 414 | + console.log(`${prefix}[${color(treeItem.data.assetId)}] ${treeItem.data.name} [${treeItem.data.typeId}]`); |
| 415 | + |
| 416 | + treeItem.children.forEach((child: TreeItem) => { |
| 417 | + printTree(child, level + 1, color); |
| 418 | + }); |
| 419 | +} |
0 commit comments