diff --git a/messages/org.json b/messages/org.json deleted file mode 100644 index b5c9eec..0000000 --- a/messages/org.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "commandDescription": "print a greeting and your org IDs", - "nameFlagDescription": "name to print", - "forceFlagDescription": "example boolean flag", - "errorNoOrgResults": "No results found for the org '%s'." -} diff --git a/package.json b/package.json index ab80821..d38744a 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,17 @@ { - "name": "flowhealthcheck-cli", - "version": "0.0.0", + "name": "lightningflowscan-cli", + "version": "0.0.3", "author": "Ruben", - "bugs": "https://github.com/IdeaProjects/flowhealthcheck-cli/issues", - "type": "module", + "bugs": "https://github.com/Force-Config-Control/lightningflowscan-cli/issues", "dependencies": { "@oclif/command": "^1", "@oclif/config": "^1", "@oclif/errors": "^1", "@salesforce/command": "^2", "@salesforce/core": "^2", + "@sinonjs/fake-timers": "6", + "@types/sinonjs__fake-timers": "6", "lightningflowscan-core": "^1.1.1", - "mz": "^2.7.0", "tslib": "^1", "xml2js": "^0.4.23" }, @@ -21,8 +21,8 @@ "@oclif/test": "^1", "@salesforce/dev-config": "1.4.1", "@types/chai": "^4", + "@types/jsforce": "^1.9.30", "@types/mocha": "^5", - "@types/node": "^10", "chai": "^4", "globby": "^8", "mocha": "^5", @@ -39,7 +39,7 @@ "/npm-shrinkwrap.json", "/oclif.manifest.json" ], - "homepage": "https://github.com/IdeaProjects/flowhealthcheck-cli", + "homepage": "https://github.com/Force-Config-Control/lightningflowscan-cli/", "keywords": [ "sfdx-plugin" ], @@ -56,7 +56,7 @@ "@oclif/plugin-help" ] }, - "repository": "https://github.com/IdeaProjects/flowhealthcheck-cli", + "repository": "https://github.com/Force-Config-Control/lightningflowscan-cli.git", "scripts": { "lint": "tslint --project . --config tslint.json --format stylish", "postpack": "rm -f oclif.manifest.json", diff --git a/src/commands/scan/flowscan.ts b/src/commands/scan/flowscan.ts index 1906cf7..336552f 100644 --- a/src/commands/scan/flowscan.ts +++ b/src/commands/scan/flowscan.ts @@ -4,13 +4,13 @@ import {AnyJson} from '@salesforce/ts-types'; import * as core from 'lightningflowscan-core/out'; import {Flow} from 'lightningflowscan-core/out/main/models/Flow'; import {ScanResult} from 'lightningflowscan-core/out/main/models/ScanResult'; -import { Violation } from '../../models/Violation'; +import {Violation} from '../../models/Violation'; import {FindFlows} from "../../libs/FindFlows"; import {ParseFlows} from "../../libs/ParseFlows"; Messages.importMessagesDirectory(__dirname); -const messages = Messages.loadMessages('flowhealthcheck-cli', 'command'); +const messages = Messages.loadMessages('lightningflowscan-cli', 'command'); export default class flowscan extends SfdxCommand { @@ -24,6 +24,7 @@ export default class flowscan extends SfdxCommand { const path = await SfdxProject.resolveProjectPath(); const flowFiles = FindFlows(path); + // todo check for flow ignore file const parsedFlows: Flow[] = await ParseFlows(flowFiles); const scanResults: ScanResult[] = core.scan(parsedFlows); const lintResults: Violation[] = []; @@ -41,15 +42,12 @@ export default class flowscan extends SfdxCommand { } } } - if (lintResults.length > 0) { - const warnings : string[] = []; - for(const lintResult of lintResults){ - warnings.push('in Flow \'' + lintResult.label + '\', Rule:\''+lintResult.ruleLabel +'\' is violated ' + lintResult.numberOfViolations + ' times'); + const warnings: string[] = []; + for (const lintResult of lintResults) { + warnings.push('in Flow \'' + lintResult.label + '\', Rule:\'' + lintResult.ruleLabel + '\' is violated ' + lintResult.numberOfViolations + ' times'); } - - throw new SfdxError(messages.getMessage('commandDescription'), 'results', - warnings, 1); + throw new SfdxError(messages.getMessage('commandDescription'), 'results', warnings, 1); } // If there are no lintresults return 0; diff --git a/src/commands/scan/main-example.json b/src/commands/scan/main-example.json deleted file mode 100644 index 9b39940..0000000 --- a/src/commands/scan/main-example.json +++ /dev/null @@ -1,343 +0,0 @@ -{ - "Flow": { - "$": { - "xmlns": "http://soap.sforce.com/2006/04/metadata" - }, - "actionCalls": [ - { - "name": [ - "makenote" - ], - "label": [ - "makenote" - ], - "locationX": [ - "843" - ], - "locationY": [ - "532" - ], - "actionName": [ - "NewNote" - ], - "actionType": [ - "quickAction" - ], - "inputParameters": [ - { - "name": [ - "Title" - ], - "value": [ - { - "stringValue": [ - "{!incvar} items on {!$Flow.CurrentDateTime}" - ] - } - ] - } - ] - } - ], - "assignments": [ - { - "name": [ - "count" - ], - "label": [ - "count" - ], - "locationX": [ - "642" - ], - "locationY": [ - "534" - ], - "assignmentItems": [ - { - "assignToReference": [ - "somecount" - ], - "operator": [ - "Assign" - ], - "value": [ - { - "elementReference": [ - "incvar" - ] - } - ] - } - ], - "connector": [ - { - "targetReference": [ - "makenote" - ] - } - ] - } - ], - "decisions": [ - { - "name": [ - "valueint" - ], - "label": [ - "valueint" - ], - "locationX": [ - "300" - ], - "locationY": [ - "371" - ], - "defaultConnector": [ - { - "targetReference": [ - "count" - ] - } - ], - "defaultConnectorLabel": [ - "Default Outcome" - ], - "rules": [ - { - "name": [ - "notzero" - ], - "conditionLogic": [ - "and" - ], - "conditions": [ - { - "leftValueReference": [ - "incvar" - ], - "operator": [ - "GreaterThan" - ], - "rightValue": [ - { - "numberValue": [ - "0.0" - ] - } - ] - }, - { - "leftValueReference": [ - "incvar" - ], - "operator": [ - "LessThanOrEqualTo" - ], - "rightValue": [ - { - "numberValue": [ - "50.0" - ] - } - ] - } - ], - "label": [ - "notzero" - ] - }, - { - "name": [ - "morethan50" - ], - "conditionLogic": [ - "and" - ], - "conditions": [ - { - "leftValueReference": [ - "incvar" - ], - "operator": [ - "GreaterThan" - ], - "rightValue": [ - { - "numberValue": [ - "50.0" - ] - } - ] - } - ], - "connector": [ - { - "targetReference": [ - "count" - ] - } - ], - "label": [ - "morethan50" - ] - } - ] - } - ], - "description": [ - "main flow" - ], - "interviewLabel": [ - "main {!$Flow.CurrentDateTime}" - ], - "label": [ - "main" - ], - "processMetadataValues": [ - { - "name": [ - "BuilderType" - ], - "value": [ - { - "stringValue": [ - "LightningFlowBuilder" - ] - } - ] - }, - { - "name": [ - "OriginBuilderType" - ], - "value": [ - { - "stringValue": [ - "LightningFlowBuilder" - ] - } - ] - } - ], - "processType": [ - "AutoLaunchedFlow" - ], - "start": [ - { - "locationX": [ - "50" - ], - "locationY": [ - "310" - ], - "connector": [ - { - "targetReference": [ - "valueint" - ] - } - ] - } - ], - "status": [ - "Active" - ], - "variables": [ - { - "name": [ - "incvar" - ], - "dataType": [ - "Number" - ], - "isCollection": [ - "false" - ], - "isInput": [ - "true" - ], - "isOutput": [ - "false" - ], - "scale": [ - "2" - ], - "value": [ - { - "numberValue": [ - "10.0" - ] - } - ] - }, - { - "name": [ - "int" - ], - "dataType": [ - "Number" - ], - "isCollection": [ - "false" - ], - "isInput": [ - "false" - ], - "isOutput": [ - "false" - ], - "scale": [ - "2" - ] - }, - { - "name": [ - "intlist" - ], - "dataType": [ - "Number" - ], - "isCollection": [ - "true" - ], - "isInput": [ - "false" - ], - "isOutput": [ - "false" - ], - "scale": [ - "2" - ] - }, - { - "name": [ - "somecount" - ], - "dataType": [ - "Number" - ], - "isCollection": [ - "false" - ], - "isInput": [ - "false" - ], - "isOutput": [ - "false" - ], - "scale": [ - "2" - ], - "value": [ - { - "numberValue": [ - "0.0" - ] - } - ] - } - ] - } -} \ No newline at end of file diff --git a/src/libs/ParseFlows.ts b/src/libs/ParseFlows.ts index 7bccf53..2104096 100644 --- a/src/libs/ParseFlows.ts +++ b/src/libs/ParseFlows.ts @@ -1,7 +1,7 @@ -import * as fs from 'mz/fs'; import path = require('path'); import {Flow} from 'lightningflowscan-core/out/main/models/Flow'; import {XMLParser} from './XMLParser'; +import { fs } from '@salesforce/core/lib/util/fs'; export async function ParseFlows(selectedUris: any) { diff --git a/yarn.lock b/yarn.lock index eaceeb2..0537818 100644 --- a/yarn.lock +++ b/yarn.lock @@ -329,6 +329,13 @@ dependencies: type-detect "4.0.8" +"@sinonjs/fake-timers@6": + version "6.0.1" + resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz#293674fccb3262ac782c7aadfdeca86b10c75c40" + integrity sha512-MZPUxrmFubI36XS1DI3qmI0YdN1gks62JtFZvxR67ljjSNCeK6U08Zx4msEWOXuofgqUt6zPHSi1H9fbjR/NRA== + dependencies: + "@sinonjs/commons" "^1.7.0" + "@sinonjs/fake-timers@^7.1.0": version "7.1.2" resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz#2524eae70c4910edccf99b2f4e6efc5894aff7b5" @@ -356,7 +363,7 @@ dependencies: "@types/node" "*" -"@types/jsforce@^1.9.29": +"@types/jsforce@^1.9.29", "@types/jsforce@^1.9.30": version "1.9.30" resolved "https://registry.yarnpkg.com/@types/jsforce/-/jsforce-1.9.30.tgz#725cba4175ddc17cf9902b6e647f2ed4a9614b50" integrity sha512-T0fgAfa99sx13gkClPkJsQRHzTcJ0Rgj7//6XEY9Qq6VRQH0U+cxlM1fqAsQ8rhAfAzyGhQk+j1nR1cWkp06NQ== @@ -390,11 +397,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.5.tgz#9a78318a45d75c9523d2396131bd3cca54b2d185" integrity sha512-se3yX7UHv5Bscf8f1ERKvQOD6sTyycH3hdaoozvaLxgUiY5lIGEeH37AD0G0Qi9kPqihPn0HOfd2yaIEN9VwEg== -"@types/node@^10": - version "10.17.60" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" - integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw== - "@types/sinon@*": version "10.0.2" resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-10.0.2.tgz#f360d2f189c0fd433d14aeb97b9d705d7e4cc0e4" @@ -402,6 +404,11 @@ dependencies: "@sinonjs/fake-timers" "^7.1.0" +"@types/sinonjs__fake-timers@6": + version "6.0.2" + resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.2.tgz#3a84cf5ec3249439015e14049bd3161419bf9eae" + integrity sha512-dIPoZ3g5gcx9zZEszaxLSVTvMReD3xxyyDnQUjA6IYDG9Ba2AV0otMPs+77sG9ojB4Qr2N2Vk5RnKeuA0X/0bg== + ajv@^6.12.3: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" @@ -458,11 +465,6 @@ ansicolors@~0.3.2: resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979" integrity sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk= -any-promise@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" - integrity sha1-q8av7tzqUugJzcA3au0845Y10X8= - append-transform@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-1.0.0.tgz#046a52ae582a228bd72f58acfbe2967c678759ab" @@ -2543,15 +2545,6 @@ mv@~2: ncp "~2.0.0" rimraf "~2.4.0" -mz@^2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" - integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q== - dependencies: - any-promise "^1.0.0" - object-assign "^4.0.1" - thenify-all "^1.0.0" - nan@^2.0.8: version "2.14.2" resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19" @@ -2667,11 +2660,6 @@ oauth-sign@~0.9.0: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== -object-assign@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - object-copy@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" @@ -3524,20 +3512,6 @@ test-exclude@^5.2.3: read-pkg-up "^4.0.0" require-main-filename "^2.0.0" -thenify-all@^1.0.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" - integrity sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY= - dependencies: - thenify ">= 3.1.0 < 4" - -"thenify@>= 3.1.0 < 4": - version "3.3.1" - resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f" - integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw== - dependencies: - any-promise "^1.0.0" - tmp@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.1.0.tgz#ee434a4e22543082e294ba6201dcc6eafefa2877"