Skip to content
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

New Command pp website webfile get #6424

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

ktskumar
Copy link
Contributor

Closes #6273

Added new command pp website webfile get

@milanholemans
Copy link
Contributor

Hi @ktskumar thank you for creating yet another PR, we're truly grateful for that.
However, I've noticed that you are creating new commands using our old approach. For about 2 months, we switched the structure for commands. Since then, we have required all new commands to implement ZOD instead of using the old approach with option interfaces. Please, keep in mind next time that new commands should use a ZOD scheme.
You can find some examples at: login, flow recyclebinitem list, flow recyclebinitem restore, spo site get, spo site sharingpermission set, ...

@Adam-it Adam-it added the hacktoberfest-accepted Accept for hacktoberfest, will merge later label Oct 29, 2024
@Adam-it
Copy link
Member

Adam-it commented Oct 29, 2024

@ktskumar I added the hacktoberfest-accepted label to this PR which means that this PR will count as done for the Hacktoberfest event. So if you participate in this event it will get you unblocked and it allows us to merge this PR later when we catch up 👍
Thanks for your support and awesome contribution 👏 You Rock 🤩

@martinlingstuyl martinlingstuyl self-assigned this Nov 19, 2024
Copy link
Contributor

@martinlingstuyl martinlingstuyl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ktskumar, I went through your PR. Let's get some things fixed before we merge this.

}

class PpWebSiteWebFileGetCommand extends PowerPlatformCommand {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this superfluous white line

);
}

#initValidators(): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we setup Zod here as well? Just like you already did on website weblink list? Do let me know!

);
}

private async getWebSiteId(dynamicsApiUrl: string, args: CommandArgs): Promise<any> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Website is a single word. Let's cjamge the casing to reflect that:

Suggested change
private async getWebSiteId(dynamicsApiUrl: string, args: CommandArgs): Promise<any> {
private async getWebsiteId(dynamicsApiUrl: string, args: CommandArgs): Promise<any> {

}
);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move private functions to below the commandAction function....

if (args.options.websiteId) {
return args.options.websiteId;
}
const options: PpWebSiteOptions = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this options object is not really used. Let's remove it.

responseType: 'json'
};

if (options.name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use args.options.websiteName... But also let's remove this if-statement.
We know for certain that args.options.websiteName should be filled at this point. Otherwise the validator would throw.

We can use args.options.websiteName! to reflect that certainty where we need to use the parameter.

}
}

private async getWebSiteWebFile(dynamicsApiUrl: string, websiteId: string, options: Options): Promise<any> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private async getWebSiteWebFile(dynamicsApiUrl: string, websiteId: string, options: Options): Promise<any> {
private async getWebFile(dynamicsApiUrl: string, websiteId: string, options: Options): Promise<any> {

Also, Let's use a type instead of any.

responseType: 'json'
};

// let webfileitem: any | null = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove these comments.




// requestOptions.url = `${dynamicsApiUrl}/api/data/v9.1/websitewebfiles?$filter=name eq '${options.name}'`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove unnecessary white lines and comments.

@martinlingstuyl martinlingstuyl marked this pull request as draft November 19, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Accept for hacktoberfest, will merge later
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New command: m365 pp website webfile get
4 participants