Skip to content

Commit 50bdcbe

Browse files
riteshnaharMayank Nehrumayank.nehruProvarTesting
authored
Merging development in master for Release 0.3.0 (#28)
* PRO-16810: ProvarDX Incorrect Help messages (#23) - Updated help messages for runtests, validate commands displayed on running `sfdx provar --help` - Updated company name in LICENSE.md * PRO-16923: ProvarDX runtests fails to handle special characters in Scratch Org Passwords properly (#25) * PRO-16923: ProvarDX runtests fails to handle special characters in Scratch Org Passwords properly * PRO-16923: Special characters were causing issues on different OS so encoded the password * PRO-16897: ProvarDX: Runtests secrets flag override incorrectly documented * PRO-16897: ProvarDX: Runtests secrets flag override incorrectly documented * PRO-16890 : Enforce required flags for provar:metadatacache (#26) * PRO-16890 : Enforce required flags for provar:metadatacache The command started executing even when required flags were not given. Changed that to give error in typescript itself. Also made changes to make sure that the flags work correctly in tandem. * PRO-16890 : Implement review comments and add change log * PRO-16890 : Implement review comments Corrected conditional checks to use "===" & '!==' for comparison and renamed variables with self explanatory names * PRO-16890 : Implement review comments Co-authored-by: mayank.nehru <mayank.nehru@HP-Mayanknehru> * PRO-17213: ProvarDX 0.3.0 release (#27) Bumped version to 0.3.0 Co-authored-by: Mayank Nehru <mayank.nehru@provartesting.com> Co-authored-by: mayank.nehru <mayank.nehru@HP-Mayanknehru> Co-authored-by: ProvarTesting <6640365+ProvarTesting@users.noreply.github.com>
1 parent a5dad63 commit 50bdcbe

9 files changed

Lines changed: 123 additions & 26 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88
node_modules
99
/.circleci
1010
/.sfdx
11-
/.vscode

.vscode/launch.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "attach",
10+
"name": "Attach to Remote",
11+
"address": "127.0.0.1",
12+
"port": 9229
13+
},
14+
{
15+
"name": "Unit Tests",
16+
"type": "node",
17+
"request": "launch",
18+
"protocol": "inspector",
19+
"program": "${workspaceRoot}/node_modules/.bin/_mocha",
20+
"args": [
21+
"--require",
22+
"test/helpers/init.js",
23+
"--require",
24+
"ts-node/register",
25+
"--require",
26+
"source-map-support/register",
27+
"--recursive",
28+
"--reporter",
29+
"spec",
30+
"test/**/*.test.ts"
31+
],
32+
"cwd": "${workspaceRoot}"
33+
}
34+
]
35+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"Insert Copyright Header": {
3+
"prefix": "copyright",
4+
"body": [
5+
"/*",
6+
" * Copyright (c) 2020 Make Positive Provar Ltd",
7+
" * All rights reserved.",
8+
" * Licensed under the BSD 3-Clause license.",
9+
" * For full license text, see LICENSE.md file in the repo root or https://opensource.org/licenses/BSD-3-Clause",
10+
" */",
11+
"$0"
12+
],
13+
"description": "Insert the Provar copyright header"
14+
}
15+
}

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.3.0] - 2020-09-11
9+
10+
### Fixed
11+
12+
- ProvarDX runtests, metadatacache command fails in case we are having special characters in Scratch Org password
13+
- Enforced the required flags for ProvarDX metadatacache command
14+
- Fixed the working of flags for ProvarDX metadatacache command in tandem
15+
16+
### Changed
17+
18+
- ProvarDX trademark changes
19+
- Updated help messages for runtests
20+
21+
### Added
22+
23+
- Added .vscode folder containing
24+
- `launch.json`: debug configuration for vscode
25+
- `provardx-copyright.code-snippets`: used to add copyright tag on source files
26+
827
## [0.2.2] - 2020-08-04
928

1029
### Changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# provartesting/provardx
1+
# ProvarDX™
22

3-
ProvarDX is a Salesforce CLI Plugin for existing Provar customer to allow them to execute Provar Test Cases from the command line, leveraging the Salesforce CLI and SalesforceDX applications. This provides an alternative mechanism for running test cases than running under ANT.
3+
ProvarDX is a Salesforce CLI Plugin for existing Provar customer to allow them to execute Provar Test Cases from the command line, leveraging the Salesforce CLI and SalesforceDX applications. This provides an alternative mechanism for running test cases than running under ANT.
44
You must be a Provar customer with a valid paid license to write and maintain your test cases.
55

66
[![Version](https://img.shields.io/npm/v/@provartesting/provardx.svg)](https://npmjs.org/package/@provartesting/provardx)
@@ -126,7 +126,7 @@ OPTIONS
126126
must be in JSON format and conform to the provardx-properties
127127
JSON schema.
128128
129-
-s, --secrets=secrets Specify path to secrets file
129+
-s, --secrets=secrets Specify a secrets encryption key for accessing the chosen project/environment.
130130
131131
--json format output as json
132132

messages/runtests.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"connectionOverridefile": "Connection file in the format provardx-connection-schema.json providing a mapping between the Provar project Connection names and the target users to be used.",
66
"cachePathFlagDescription": "Specify relative or full file path for where a metadata cache has already been downloaded using either a VCS extract or metadata ProvarDX command.",
77
"metadataLevelFlagDescription": "Specify permitted values reload (get all metadata - default) | refresh (only download changes). This overrides any settings made in the propertyfile.",
8-
"secretsFlagDescription": "Specify path to secrets file",
8+
"secretsFlagDescription": "Specify a secrets encryption key for accessing the chosen project/environment.",
99
"loglevelFlagDescription": "Specify the level of feedback provided during the compilation (see above) and execution."
1010
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@provartesting/provardx",
33
"description": "A plugin for the Salesforce CLI to run provar testcases",
4-
"version": "0.2.2",
4+
"version": "0.3.0",
55
"author": "Provar",
66
"bugs": "https://github.com/ProvarTesting/provardx/issues",
77
"dependencies": {

src/commands/provar/metadatacache.ts

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,22 @@ export default class MetadataCache extends SfdxCommand {
8181
const connections: string = this.flags.connections;
8282
const connectionoverrides: string = this.flags.connectionoverrides;
8383

84+
if (
85+
!metadataLevel || !cachePath
86+
) {
87+
this.ux.error(
88+
"ERROR running provar:metadatacache : Please specify a cachepath and metadatalevel"
89+
);
90+
return {};
91+
}
92+
93+
if (!["Reload", "Refresh", "Reuse"].includes(metadataLevel)) {
94+
this.ux.error(
95+
"ERROR running provar:metadatacache : Please specify a valid metadata level(-m flag). Valid levels are : 'Reuse', 'Refresh' and 'Reload'"
96+
);
97+
return {};
98+
}
99+
84100
const provarDxUtils: ProvarDXUtility = new ProvarDXUtility();
85101
const isValid: boolean = provarDxUtils.validatePropertiesJson(
86102
propertyFile
@@ -96,7 +112,7 @@ export default class MetadataCache extends SfdxCommand {
96112
provarDxUtils.hasDuplicateConnectionOverride(propertiesInstance)
97113
) {
98114
this.ux.error(
99-
"Invalid property file. Run command sfdx provar:validate' to know the validation errors"
115+
"ERROR running provar:metadatacache : Please specify a valid property file. Run command sfdx provar:validate' to know the validation errors"
100116
);
101117
return {};
102118
}
@@ -117,26 +133,26 @@ export default class MetadataCache extends SfdxCommand {
117133
const userInfo = await provarDxUtils.getDxUsersInfo(
118134
properties.connectionOverride
119135
);
120-
if (userInfo == null) {
136+
if (userInfo === null && !connections) {
121137
this.ux.error(
122138
'[ERROR] No valid user org found to download metadata. Terminating command.'
123139
);
124140
return {};
125141
}
126142

127-
const userInfoString = provarDxUtils.prepareRawProperties(
143+
const userInfoString = connections && userInfo === null ? "NA" : provarDxUtils.prepareRawProperties(
128144
JSON.stringify({ dxUsers: userInfo })
129145
);
130146
const jarPath = properties.provarHome + '/provardx/provardx.jar';
131147
execSync(
132148
'java -cp "' +
133-
jarPath +
134-
'" com.provar.provardx.DxCommandExecuter ' +
135-
updateProperties +
136-
' ' +
137-
userInfoString +
138-
' ' +
139-
'Metadata',
149+
jarPath +
150+
'" com.provar.provardx.DxCommandExecuter ' +
151+
updateProperties +
152+
' ' +
153+
userInfoString +
154+
' ' +
155+
'Metadata',
140156
{ stdio: 'inherit' }
141157
);
142158
return {};
@@ -167,15 +183,30 @@ export default class MetadataCache extends SfdxCommand {
167183
properties: any,
168184
connectionOverride: string
169185
): void {
170-
if (!connectionOverride) {
186+
if (!connectionOverride && !properties.connectionName) {
171187
return;
172188
}
173-
const overrides = connectionOverride.split(',');
174-
const connOver = [];
175-
for (const override of overrides) {
176-
const v = override.split(':');
177-
connOver.push({ connection: v[0], username: v[1] });
189+
190+
if (properties.connectionName && properties.connectionOverride) {
191+
const overrides = properties.connectionName.split(',');
192+
const connOver = [];
193+
for (const override of properties.connectionOverride) {
194+
if (overrides.indexOf(override.connection) !== -1) {
195+
connOver.push(override);
196+
}
197+
}
198+
properties.connectionOverride = connOver;
199+
}
200+
201+
if (connectionOverride) {
202+
const overrides = connectionOverride.split(',');
203+
for (const override of overrides) {
204+
const overrideDetails = override.split(':');
205+
const prop = properties.connectionOverride.find(f => f.connection === overrideDetails[0]);
206+
if(prop){
207+
prop.username = overrideDetails[1];
208+
}
209+
}
178210
}
179-
properties.connectionOverride = connOver;
180211
}
181212
}

src/utilities/ProvarDXUtility.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ export default class ProvarDXUtility {
169169

170170
private handleSpecialCharacters(password: string): string {
171171
if (password) {
172-
password = password.split('&').join('"&"');
173-
password = password.split('|').join('"|"');
174-
password = password.split('^').join('"^"');
172+
password = encodeURIComponent(password);
175173
}
176174
return password;
177175
}

0 commit comments

Comments
 (0)