-
Notifications
You must be signed in to change notification settings - Fork 326
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
Adds command pp website weblink list
#6449
base: main
Are you sure you want to change the base?
Conversation
pp webiste weblink list
pp website weblink list
@ktskumar I added the |
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.
Hi @ktskumar,
Great work! I do have some comments, could you look at those and get back to me? Let me know if you have any questions!
import PowerPlatformCommand from '../../../base/PowerPlatformCommand.js'; | ||
import commands from '../../commands.js'; | ||
import { PpWebSiteOptions } from '../Website.js'; | ||
|
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.
Let's remove superfluous white lines
if (args.options.websiteId) { | ||
return args.options.websiteId; | ||
} | ||
const options: PpWebSiteOptions = { |
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.
Add a white line after an if-scope.
And also add a verbose logging line saying it will retrieve the website Id by name
responseType: 'json' | ||
}; | ||
|
||
if (options.name) { |
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.
What's this options.name doing here? I think you should not need to check if the website name has a value. Its an option set with websiteId, and we've already ascertained in the validation that a value should be there in one of the options.
return args.options.websiteId; | ||
} | ||
const options: PpWebSiteOptions = { | ||
environmentName: args.options.environmentName, |
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.
I think this options object is not really in use. So we can remove it. Further down you're referencing options.name, but it's more logical there to use args.options.websiteName
if (result.value.length === 0) { | ||
throw `The specified website '${args.options.websiteName}' does not exist.`; | ||
} | ||
return result.value[0].powerpagesiteid; |
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.
Let's add a white line after an if-scope
} | ||
|
||
private async getwebsitelinksets(dynamicsApiUrl: string, websiteId: string): Promise<any> { | ||
|
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.
Let's remove this linebreak
} | ||
} | ||
|
||
private async getwebsitelinksets(dynamicsApiUrl: string, websiteId: string): Promise<any> { |
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.
Let's move the two private functions to below the public commandAction function.
Also, I'd suggest a rename on this function:
getwebsitelinksets
> getWebLinkSets
return options; | ||
} | ||
|
||
private async getWebSiteId(dynamicsApiUrl: string, args: CommandArgs): Promise<any> { |
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.
private async getWebSiteId(dynamicsApiUrl: string, args: CommandArgs): Promise<any> { | |
private async getWebsiteId(dynamicsApiUrl: string, args: CommandArgs): Promise<any> { |
responseType: 'json' | ||
}; | ||
|
||
if (websiteId) { |
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.
This if-statement is superfluous I believe, as the websiteId parameter is not nullable.
try { | ||
const dynamicsApiUrl = await powerPlatform.getDynamicsInstanceApiUrl(args.options.environmentName, args.options.asAdmin); | ||
const websiteId = await this.getWebSiteId(dynamicsApiUrl, args); | ||
const weblinksets = await this.getwebsitelinksets(dynamicsApiUrl, websiteId); |
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.
const weblinksets = await this.getwebsitelinksets(dynamicsApiUrl, websiteId); | |
const weblinkSets = await this.getwebsitelinksets(dynamicsApiUrl, websiteId); |
Closes #6269
Added new command
pp website weblink list