Skip to content

Commit 9b3958b

Browse files
committed
Adds first batch of fixups
1 parent d6cbe35 commit 9b3958b

File tree

5 files changed

+24
-27
lines changed

5 files changed

+24
-27
lines changed

src/m365/spfx/commands/SpfxCompatibilityMatrix.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ export const versions: { [version: string]: SpfxVersionPrerequisites } = {
573573
fix: 'npm i -g gulp-cli@3'
574574
},
575575
node: {
576-
range: '>=22.14.0 < 23.0.0',
577-
fix: 'Install Node.js >=22.14.0 < 23.0.0'
576+
range: '>=22.14.0 <23.0.0',
577+
fix: 'Install Node.js >=22.14.0 <23.0.0'
578578
},
579579
sp: SharePointVersion.SPO,
580580
yo: {
@@ -588,8 +588,8 @@ export const versions: { [version: string]: SpfxVersionPrerequisites } = {
588588
fix: 'npm i -g gulp-cli@3'
589589
},
590590
node: {
591-
range: '>=22.14.0 < 23.0.0',
592-
fix: 'Install Node.js >=22.14.0 < 23.0.0'
591+
range: '>=22.14.0 <23.0.0',
592+
fix: 'Install Node.js >=22.14.0 <23.0.0'
593593
},
594594
sp: SharePointVersion.SPO,
595595
yo: {
@@ -599,8 +599,8 @@ export const versions: { [version: string]: SpfxVersionPrerequisites } = {
599599
},
600600
'1.22.0-beta.1': {
601601
node: {
602-
range: '>=22.14.0 < 23.0.0',
603-
fix: 'Install Node.js >=22.14.0 < 23.0.0'
602+
range: '>=22.14.0 <23.0.0',
603+
fix: 'Install Node.js >=22.14.0 <23.0.0'
604604
},
605605
sp: SharePointVersion.SPO,
606606
yo: {

src/m365/spfx/commands/project/project-azuredevops-pipeline-add.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe(commands.PROJECT_AZUREDEVOPS_PIPELINE_ADD, () => {
2323
before(() => {
2424
sinon.stub(telemetry, 'trackEvent').resolves();
2525
sinon.stub(pid, 'getProcessName').callsFake(() => '');
26-
sinon.stub(spfx, 'getHighestNodeVersion').callsFake(() => '22.0.x');
26+
sinon.stub(spfx, 'getHighestNodeVersion').returns('22.0.x');
2727
sinon.stub(session, 'getId').callsFake(() => '');
2828
commandInfo = cli.getCommandInfo(command);
2929
});
@@ -185,10 +185,10 @@ describe(commands.PROJECT_AZUREDEVOPS_PIPELINE_ADD, () => {
185185

186186
sinon.stub(command as any, 'getProjectVersion').returns('');
187187

188-
sinon.stub(fs, 'writeFileSync').callsFake(() => { throw 'error'; });
188+
sinon.stub(fs, 'writeFileSync').throws('error');
189189

190190
await assert.rejects(command.action(logger, { options: {} } as any),
191-
new CommandError(`Unable to determine the version of the current SharePoint Framework project`, undefined));
191+
new CommandError(`Unable to determine the version of the current SharePoint Framework project`));
192192
});
193193

194194
it('handles error with not found node version', async () => {
@@ -215,10 +215,10 @@ describe(commands.PROJECT_AZUREDEVOPS_PIPELINE_ADD, () => {
215215

216216
sinon.stub(command as any, 'getProjectVersion').returns('99.99.99');
217217

218-
sinon.stub(fs, 'writeFileSync').callsFake(() => { throw 'error'; });
218+
sinon.stub(fs, 'writeFileSync').throws('error');
219219

220220
await assert.rejects(command.action(logger, { options: {} } as any),
221-
new CommandError(`Could not find Node version for 99.99.99 of SharePoint Framework`, undefined));
221+
new CommandError(`Could not find Node version for 99.99.99 of SharePoint Framework`));
222222
});
223223

224224
it('handles unexpected error', async () => {

src/m365/spfx/commands/project/project-azuredevops-pipeline-add.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,18 @@ class SpfxProjectAzureDevOpsPipelineAddCommand extends BaseProjectCommand {
160160
const version = this.getProjectVersion();
161161

162162
if (!version) {
163-
throw 'Unable to determine the version of the current SharePoint Framework project';
163+
throw 'Unable to determine the version of the current SharePoint Framework project. Could not find the correct version based on @microsoft/generator-sharepoint property in the .yo-rc.json file.';
164164
}
165165

166166
const versionRequirements = versions[version];
167167

168168
if (!versionRequirements) {
169-
throw `Could not find Node version for ${version} of SharePoint Framework`;
169+
throw `Could not find Node version for version '${version}' of SharePoint Framework.`;
170170
}
171171

172172
const nodeVersion: string = spfx.getHighestNodeVersion(versionRequirements.node.range);
173173

174-
if (nodeVersion) {
175-
this.assignPipelineVariables(pipeline, 'NodeVersion', nodeVersion);
176-
}
174+
this.assignPipelineVariables(pipeline, 'NodeVersion', nodeVersion);
177175

178176
const script = this.getScriptAction(pipeline);
179177
if (script.script) {

src/m365/spfx/commands/project/project-github-workflow-add.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe(commands.PROJECT_GITHUB_WORKFLOW_ADD, () => {
2323
before(() => {
2424
sinon.stub(telemetry, 'trackEvent').resolves();
2525
sinon.stub(pid, 'getProcessName').callsFake(() => '');
26-
sinon.stub(spfx, 'getHighestNodeVersion').callsFake(() => '22.0.x');
26+
sinon.stub(spfx, 'getHighestNodeVersion').returns('22.0.x');
2727
sinon.stub(session, 'getId').callsFake(() => '');
2828
commandInfo = cli.getCommandInfo(command);
2929
});
@@ -186,10 +186,11 @@ describe(commands.PROJECT_GITHUB_WORKFLOW_ADD, () => {
186186

187187
sinon.stub(command as any, 'getProjectVersion').returns(undefined);
188188

189-
sinon.stub(fs, 'writeFileSync').callsFake(() => { throw 'error'; });
189+
sinon.stub(fs, 'writeFileSync').throws('error');
190+
191+
await assert.rejects(command.action(logger, { options: {} }),
192+
new CommandError(`Unable to determine the version of the current SharePoint Framework project`));
190193

191-
await assert.rejects(command.action(logger, { options: {} } as any),
192-
new CommandError(`Unable to determine the version of the current SharePoint Framework project`, undefined));
193194
});
194195

195196
it('handles error with not found node version', async () => {
@@ -216,10 +217,10 @@ describe(commands.PROJECT_GITHUB_WORKFLOW_ADD, () => {
216217

217218
sinon.stub(command as any, 'getProjectVersion').returns('99.99.99');
218219

219-
sinon.stub(fs, 'writeFileSync').callsFake(() => { throw 'error'; });
220+
sinon.stub(fs, 'writeFileSync').throws('error');
220221

221-
await assert.rejects(command.action(logger, { options: {} } as any),
222-
new CommandError(`Could not find Node version for 99.99.99 of SharePoint Framework`, undefined));
222+
await assert.rejects(command.action(logger, { options: {} }),
223+
new CommandError(`Could not find Node version for 99.99.99 of SharePoint Framework`));
223224
});
224225

225226
it('handles unexpected error', async () => {

src/m365/spfx/commands/project/project-github-workflow-add.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class SpfxProjectGithubWorkflowAddCommand extends BaseProjectCommand {
160160
const version = this.getProjectVersion();
161161

162162
if (!version) {
163-
throw 'Unable to determine the version of the current SharePoint Framework project';
163+
throw 'Unable to determine the version of the current SharePoint Framework project. Could not find the correct version based on @microsoft/generator-sharepoint property in the .yo-rc.json file.';
164164
}
165165

166166
const versionRequirements = versions[version];
@@ -171,9 +171,7 @@ class SpfxProjectGithubWorkflowAddCommand extends BaseProjectCommand {
171171

172172
const nodeVersion: string = spfx.getHighestNodeVersion(versionRequirements.node.range);
173173

174-
if (nodeVersion) {
175-
this.assignNodeVersion(workflow, nodeVersion);
176-
}
174+
this.assignNodeVersion(workflow, nodeVersion);
177175

178176
if (options.manuallyTrigger) {
179177
// eslint-disable-next-line camelcase

0 commit comments

Comments
 (0)