Updates ci-cd commands to set node version based on SPFx project version. Closes #6717#6766
Updates ci-cd commands to set node version based on SPFx project version. Closes #6717#6766
Conversation
milanholemans
left a comment
There was a problem hiding this comment.
Really cool enhancement @Adam-it! This will improve the command a lot.
However, while reviewing, I found a few things we should take a look at first.
src/m365/spfx/commands/project/project-github-workflow-add.spec.ts
Outdated
Show resolved
Hide resolved
src/m365/spfx/commands/project/project-github-workflow-add.spec.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
This pull request updates CI/CD workflow commands to dynamically determine the Node.js version based on the SharePoint Framework (SPFx) project version rather than using a hardcoded version. The PR refactors shared compatibility data into a separate module and adds logic to compute the appropriate Node.js version from version ranges.
- Extracts SPFx version compatibility matrix to a shared module
- Adds utility function to parse version ranges and determine highest compatible Node.js version
- Updates GitHub workflow and Azure DevOps pipeline commands to set Node.js version dynamically
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/spfx.ts | Added utility function to extract highest Node version from semver range |
| src/utils/spfx.spec.ts | Added test coverage for the new utility function |
| src/m365/spfx/commands/spfx-doctor.ts | Removed duplicate compatibility matrix, now imports from shared module |
| src/m365/spfx/commands/project/project-github-workflow-add.ts | Added logic to determine and set Node version based on SPFx project version |
| src/m365/spfx/commands/project/project-github-workflow-add.spec.ts | Added test coverage for version determination and error handling |
| src/m365/spfx/commands/project/project-azuredevops-pipeline-add.ts | Added logic to determine and set Node version based on SPFx project version |
| src/m365/spfx/commands/project/project-azuredevops-pipeline-add.spec.ts | Added test coverage for version determination and error handling |
| src/m365/spfx/commands/project/DeployWorkflow.ts | Changed default Node version from hardcoded "22.x" to empty string |
| src/m365/spfx/commands/SpfxCompatibilityMatrix.ts | New shared module containing SPFx compatibility matrix data |
47d9054 to
d6cbe35
Compare
|
@milanholemans I added the first batch of fixes to your comments that I could do without thinking 😁. |
ebb5e21 to
136ddf6
Compare
|
@milanholemans it took a while, and I do apologize for that. Lately, I have more tasks/work in a day than I can simply manage within 24 hours |
|
Hi @Adam-it, seems like we ran into merge conflicts again. Could you have a look? I'll try to get it merged ASAP. |
I will but after we merge the spfx update commands PR done by Waldek as it will also touch the |
136ddf6 to
e418c6e
Compare
|
@milanholemans, |
milanholemans
left a comment
There was a problem hiding this comment.
I've had another look, and I think we should recheck a few things before we merge it.
src/m365/spfx/commands/project/project-github-workflow-add.spec.ts
Outdated
Show resolved
Hide resolved
src/m365/spfx/commands/project/project-github-workflow-add.spec.ts
Outdated
Show resolved
Hide resolved
74284fb to
eb49673
Compare
|
ready for another round |
src/m365/spfx/commands/project/project-azuredevops-pipeline-add.spec.ts
Outdated
Show resolved
Hide resolved
milanholemans
left a comment
There was a problem hiding this comment.
We have some progress, but I feel we need to recheck a few things first.
src/m365/spfx/commands/project/project-github-workflow-add.spec.ts
Outdated
Show resolved
Hide resolved
src/m365/spfx/commands/project/project-github-workflow-add.spec.ts
Outdated
Show resolved
Hide resolved
src/m365/spfx/commands/project/project-github-workflow-add.spec.ts
Outdated
Show resolved
Hide resolved
| await assert.rejects(command.action(logger, { options: {} } as any), | ||
| new CommandError('writeFileSync failed')); |
There was a problem hiding this comment.
Why do we expect this to fail? SPFx v1.21.1 is valid, right?
There was a problem hiding this comment.
Here we simulate failure in saving the file not SPFx version validation
src/m365/spfx/commands/project/project-github-workflow-add.spec.ts
Outdated
Show resolved
Hide resolved
| sinon.stub(fs, 'writeFileSync').throws(new Error('writeFileSync failed')); | ||
|
|
||
| await assert.rejects(command.action(logger, { options: {} } as any), | ||
| new CommandError('writeFileSync failed')); |
There was a problem hiding this comment.
Also here, I find it weird that this test should fail. v1.21.1 is a valid SPFx version, right?
There was a problem hiding this comment.
Yes it is valid. This tests checks how the command will behave when we simulate and unexpected error in the writeFileSync, so at the very end when we update the pipeline after retrieving the SPFx version and related changes and we want to finish of with saving the file
src/m365/spfx/commands/project/project-azuredevops-pipeline-add.spec.ts
Outdated
Show resolved
Hide resolved
992b640 to
833fa4b
Compare
|
@milanholemans I hope this time I got everything right. Sorry for such a long PR, and thanks for handling all this. |
Closes #6717