cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

Refactor codebase to async/await

Open martinlingstuyl opened this issue 1 year ago • 33 comments

We're currently using promise chains everywhere In the code. Refactoring to Async/await would be helpful as it gives better insight in how the code is organized, it's a less verbose and indented way to write code.

This epic is meant to track the work.

We've decided to do a max of 10 commands per PR.

  • [x] #3430

Refactor promise/then to async/await.

AAD

  • [x] #4933
  • [x] #4936
  • [x] #4938
  • [x] #4942
  • [x] #4944
  • [x] #4946
  • [x] #4948

Adaptivecard + App + Booking

  • [x] #4955

Base

  • [x] #4957

File

  • [x] #4974

Flow

  • [x] #4980
  • [x] #4982

Graph

  • [x] #4984

OneDrive

  • [x] #4986

Outlook

  • [x] #4988

PA

  • [x] #5000

PP

  • [x] #4992
  • [x] #4994
  • [x] #4990

Planner

  • [x] #5002
  • [x] #5003
  • [x] #5004

Purview

  • [x] #4996
  • [x] #4998

Search + Skype + SPFx

  • [x] #5010
  • [x] #5152

SPO

  • [x] #5011
  • [x] #5015
  • [x] #5023
  • [x] #5022
  • [x] #5021
  • [x] #5020
  • [x] #5042
  • [x] #5043
  • [x] #5044
  • [x] #5045
  • [x] #5046
  • [x] #5047
  • [x] #5048
  • [x] #5049
  • [x] #5050
  • [x] #5051
  • [x] #5097
  • [x] #5098
  • [x] #5099
  • [x] #5100
  • [x] #5101
  • [x] #5102
  • [x] #5103
  • [x] #5104
  • [x] #5105
  • [x] #5106
  • [x] #5107
  • [x] #5108
  • [x] #5109
  • [x] #5110
  • [x] #5111
  • [x] #5112
  • [x] #5113
  • [x] #5114
  • [x] #5115
  • [x] #5116
  • [x] #5117
  • [x] #5118

Src files

  • [ ] #5147

CLI

  • [x] #5146

Auth

  • [x] #5145

Util

  • [x] #5144
  • [x] #5079

martinlingstuyl avatar Aug 28 '22 18:08 martinlingstuyl

Added the needs discussion label to indicate that we need to decide how we want to split the refactoring work to allow multiple people to help out and speed up the refactoring process.

waldekmastykarz avatar Aug 29 '22 07:08 waldekmastykarz

Hi @pnp/cli-for-microsoft-365-maintainers, Time for some discussion, as @milanholemans PR is almost merged by @waldekmastykarz 😉.

We have like 560 commands. I was planning on splitting the work into 5 issues, each with a nice task list of 112 commands.

martinlingstuyl avatar Sep 20 '22 19:09 martinlingstuyl

Big fan of splitting the work!

Jwaegebaert avatar Sep 20 '22 19:09 Jwaegebaert

Hi @pnp/cli-for-microsoft-365-maintainers, Time for some discussion, as @milanholemans PR is almost merged by @waldekmastykarz 😉.

We have like 560 commands. I was planning on splitting the work into 5 issues, each with a nice task list of 112 commands.

Shouldn't we divide the workload in command groups? Will be more clear if your task is just to refactor all aad, planner and pp commands for example in one go. This would also be easier to describe in the release notes. If you just split it by a fixed number of commands it is possible that for example you have to refactor all aad, planner and few pp commands. This might be a bit unclear and is harder to document in the release notes. "Refactored add, planner and some pp commands" looks a bit weird in the release notes imo 🙂

However the group spo will be a tough one to refactor in one go 🙂

milanholemans avatar Sep 20 '22 22:09 milanholemans

However the group spo will be a tough one to refactor in one go 🙂

That's why I did it like this. But let me check if I can make a more logical split.

martinlingstuyl avatar Sep 21 '22 04:09 martinlingstuyl

Ok, I updated it. SPO is a bit big. What do you think about splitting it in three?

martinlingstuyl avatar Sep 21 '22 14:09 martinlingstuyl

Ok, I updated it. SPO is a bit big. What do you think about splitting it in three?

The proposed chunks are looking good to me. I think we can definitely split spo in smaller chunks, else no one will volunteer for that one 😄

milanholemans avatar Sep 21 '22 14:09 milanholemans

Refactoring some commands will be more work than others. My first thought was to split the work per command but that might make a mess of our issue list so perhaps we should look at slightly bigger chunks but definitely smaller than a whole workload. Also, don't underestimate the time needed to review each change and ensure there are no breaking changes in the commands behavior.

waldekmastykarz avatar Sep 21 '22 17:09 waldekmastykarz

Ok, so you would say split it in smaller chunks than I did? like 10-20 commands each or something?

spo is a very big task, with a lot of huge commands. But some other workloads (based on the ms graph) are relatively simple.

How about we split it per subsection?

martinlingstuyl avatar Sep 21 '22 18:09 martinlingstuyl

That all are good comments and for sure we may try to divide in smaller parts in order to share the workload 👍. Just a small comment from my side is not to try to find the perfect balance and now check every comment to make perfectly equal chunks 😉. I guess I have no problem in doing something smaller then others 😅. Only joking. can't wait to try to help out 😉

Adam-it avatar Sep 22 '22 07:09 Adam-it

After some discussion: putting this issue on hold until v6 is shipped.

milanholemans avatar Sep 22 '22 09:09 milanholemans

When we start working on it, let's split it up indeed in small chunks with a few commands each so that the workload is reasonable and people don't get stuck for weeks working on it.

waldekmastykarz avatar Sep 23 '22 18:09 waldekmastykarz

v6 is shipped, are we going to proceed with this? If so, let's discuss the chunk size of the amount of commands per issue.

milanholemans avatar Dec 10 '22 23:12 milanholemans

We shouldn't have chunk sizes bigger than 10 commands. Anything more will extend the refactoring work, leading to tons of merge conflicts, and a lot of work to merge these PRs.

waldekmastykarz avatar Dec 11 '22 08:12 waldekmastykarz

Will we open this up for everybody? If so, it could be nice to have one chunk ready as an example. A bit like we did with adding the responses to all our command docs.

Jwaegebaert avatar Dec 11 '22 19:12 Jwaegebaert

Do you mean an example PR how to refactor it? Because we have plenty of commands that use async/await already.

milanholemans avatar Dec 11 '22 22:12 milanholemans

Do you mean an example PR how to refactor it? Because we have plenty of commands that use async/await already.

In that case, let's link one as a reference for everyone to use and which we'll use when reviewing PRs.

waldekmastykarz avatar Dec 14 '22 18:12 waldekmastykarz

Hi,

I would be very interested with helping refactoring this. Could I get started on this? I'd suggest that we start with the smallerish command groups, and work up that way.

MathijsVerbeeck avatar May 25 '23 21:05 MathijsVerbeeck

Hi @MathijsVerbeeck, it would be great if you could help with this. We need to update the specs though. We've determined to take 10 commands max in every PR.

If you want to start already, just create a new issue with a checklist of 10 commands, and work through them. Reference the issue here, I'll add it to the specs.

martinlingstuyl avatar May 26 '23 18:05 martinlingstuyl

Perfect, thanks for the feedback @martinlingstuyl

MathijsVerbeeck avatar May 26 '23 18:05 MathijsVerbeeck

@martinlingstuyl I've just created the first issue + PR #4933 for the issue, #4934 for the PR

If you have any feedback regarding naming, ... shoot!

MathijsVerbeeck avatar May 26 '23 23:05 MathijsVerbeeck

@martinlingstuyl I've just created the first issue + PR #4933 for the issue, #4934 for the PR

If you have any feedback regarding naming, ... shoot!

Added it, thx!

milanholemans avatar May 26 '23 23:05 milanholemans

Nice @MathijsVerbeeck!

martinlingstuyl avatar May 27 '23 07:05 martinlingstuyl

I think we should add a complete list of commands with checkboxes here, and check the ones that are PR'ed, to keep track of covered commands.

martinlingstuyl avatar May 27 '23 07:05 martinlingstuyl

I think we should add a complete list of commands with checkboxes here, and check the ones that are PR'ed, to keep track of covered commands.

Those are referenced in the other issue. Otherwise this one would become massive!

MathijsVerbeeck avatar May 27 '23 08:05 MathijsVerbeeck

Yes, but we need one overview, I think it will become unclear otherwise which ones have not been picked up...

martinlingstuyl avatar May 27 '23 08:05 martinlingstuyl

Yes, but we need one overview, I think it will become unclear otherwise which ones have not been picked up...

Hi @MathijsVerbeeck, looking at it, this actually looks quite neat. Let's keep it like this 👍

martinlingstuyl avatar May 31 '23 19:05 martinlingstuyl

Can I help on this one?

nicodecleyre avatar Jun 05 '23 19:06 nicodecleyre

Can I help on this one?

I don't see any reason why not 😄 We'd just need to align who picks up which set of commands I guess, so no more me just creating issues and instantly creating the PR's 😭

I'm currently busy with the m365 pa commands. If it would be handy for you, I could give you a brief summary of what you should certainly check for when reviewing the commands.

MathijsVerbeeck avatar Jun 05 '23 19:06 MathijsVerbeeck

I'm currently busy with the m365 pa commands. If it would be handy for you, I could give you a brief summary of what you should certainly check for when reviewing the commands.

I can start with m365 pp if that is good for you? I propose we create the issue before we start doing the work, that case we don't overlap each other and we have a clear view on who is doing what, is that ok for you?

nicodecleyre avatar Jun 05 '23 19:06 nicodecleyre