-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PRO-16890 : Enforce required flags for provar:metadatacache #26
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0feaa17
PRO-16890 : Enforce required flags for provar:metadatacache
aa9e314
PRO-16890 : Implement review comments and add change log
dcebb32
PRO-16890 : Implement review comments
d0f175c
PRO-16890 : Implement review comments
4f68917
Merge branch 'development' into PRO-16890
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,24 @@ export default class MetadataCache extends SfdxCommand { | |
const connections: string = this.flags.connections; | ||
const connectionoverrides: string = this.flags.connectionoverrides; | ||
|
||
if ( | ||
!metadataLevel || !cachePath | ||
) { | ||
this.ux.error( | ||
"ERROR running provar:metadatacache : Please specify a cachepath and metadatalevel" | ||
); | ||
return {}; | ||
} | ||
|
||
if ( | ||
metadataLevel !== "Reload" && metadataLevel !== "Refresh" && metadataLevel !== "Reuse" | ||
) { | ||
this.ux.error( | ||
"ERROR running provar:metadatacache : Please specify a valid metadata level(-m flag). Valid levels are : 'Reuse', 'Refresh' and 'Reload'" | ||
); | ||
return {}; | ||
} | ||
|
||
const provarDxUtils: ProvarDXUtility = new ProvarDXUtility(); | ||
const isValid: boolean = provarDxUtils.validatePropertiesJson( | ||
propertyFile | ||
|
@@ -96,7 +114,7 @@ export default class MetadataCache extends SfdxCommand { | |
provarDxUtils.hasDuplicateConnectionOverride(propertiesInstance) | ||
) { | ||
this.ux.error( | ||
"Invalid property file. Run command sfdx provar:validate' to know the validation errors" | ||
"ERROR running provar:metadatacache : Please specify a valid property file. Run command sfdx provar:validate' to know the validation errors" | ||
); | ||
return {}; | ||
} | ||
|
@@ -117,26 +135,26 @@ export default class MetadataCache extends SfdxCommand { | |
const userInfo = await provarDxUtils.getDxUsersInfo( | ||
properties.connectionOverride | ||
); | ||
if (userInfo == null) { | ||
if (userInfo == null && !connections) { | ||
this.ux.error( | ||
'[ERROR] No valid user org found to download metadata. Terminating command.' | ||
); | ||
return {}; | ||
} | ||
|
||
const userInfoString = provarDxUtils.prepareRawProperties( | ||
const userInfoString = connections && userInfo == null ? "NA" : provarDxUtils.prepareRawProperties( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
JSON.stringify({ dxUsers: userInfo }) | ||
); | ||
const jarPath = properties.provarHome + '/provardx/provardx.jar'; | ||
execSync( | ||
'java -cp "' + | ||
jarPath + | ||
'" com.provar.provardx.DxCommandExecuter ' + | ||
updateProperties + | ||
' ' + | ||
userInfoString + | ||
' ' + | ||
'Metadata', | ||
jarPath + | ||
'" com.provar.provardx.DxCommandExecuter ' + | ||
updateProperties + | ||
' ' + | ||
userInfoString + | ||
' ' + | ||
'Metadata', | ||
{ stdio: 'inherit' } | ||
); | ||
return {}; | ||
|
@@ -167,15 +185,30 @@ export default class MetadataCache extends SfdxCommand { | |
properties: any, | ||
connectionOverride: string | ||
): void { | ||
if (!connectionOverride) { | ||
if (!connectionOverride && !properties.connectionName) { | ||
return; | ||
} | ||
const overrides = connectionOverride.split(','); | ||
const connOver = []; | ||
for (const override of overrides) { | ||
const v = override.split(':'); | ||
connOver.push({ connection: v[0], username: v[1] }); | ||
|
||
if (properties.connectionName && properties.connectionOverride) { | ||
const overrides = properties.connectionName.split(','); | ||
const connOver = []; | ||
for (const override of properties.connectionOverride) { | ||
if (overrides.indexOf(override.connection) != -1) { | ||
connOver.push(override); | ||
} | ||
} | ||
properties.connectionOverride = connOver; | ||
} | ||
|
||
if (connectionOverride) { | ||
const overrides = connectionOverride.split(','); | ||
for (const override of overrides) { | ||
const v = override.split(':'); | ||
const prop = properties.connectionOverride.find(f => f.connection === v[0]); | ||
if(prop){ | ||
prop.username = v[1]; | ||
} | ||
} | ||
} | ||
properties.connectionOverride = connOver; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change it to:
if (!["Reload", "Refresh", "Reuse"].includes(metadataLevel))