Skip to content

Commit ef71af2

Browse files
Saurabh7019Adam-it
authored andcommitted
support for installing correct version of Node.js. Closes #437 (#438)
## 🎯 Aim Support installing correct version of Node.js ## 📷 Result ![image](https://github.com/user-attachments/assets/80f2be0e-e760-4a3d-a557-dfb28b7d7e5f) ## ✅ What was done - [X] provides a link to download and install Node.js - [X] provides common guidance to use NVM (based on users' current OS) or NVS ## 🔗 Related issue Closes: #437
1 parent a28c59d commit ef71af2

File tree

7 files changed

+35
-13
lines changed

7 files changed

+35
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ When running the extension for the first time it will present you a walkthrough
5858

5959
### 2️⃣ Set up your development environment
6060

61-
To ensure that you can develop SPFx solutions, you may use the **check dependencies** functionality.
61+
To ensure that you can develop SPFx solutions, you may use the **Validate local setup** functionality.
6262

6363
![Validate dependency](./assets/images/validate-dependency.png)
6464

assets/images/validate-dependency.png

-288 KB
Loading

assets/images/welcome-experience.png

-11.8 KB
Loading

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@
368368
{
369369
"id": "set-up-local-workspace",
370370
"title": "Validate your local workspace",
371-
"description": "Validate if your local workspace is ready for SharePoint Framework development by checking and installing the required dependencies. \n[Check dependencies](command:spfx-toolkit.checkDependencies)",
371+
"description": "Validate if your local workspace is ready for SharePoint Framework development by checking and installing the required dependencies. \n[Validate local setup](command:spfx-toolkit.checkDependencies)",
372372
"media": {
373373
"markdown": "assets/walkthrough/validate-local-setup.md"
374374
}
@@ -605,7 +605,7 @@
605605
"viewsWelcome": [
606606
{
607607
"view": "pnp-view-empty",
608-
"contents": "Welcome to SharePoint Framework Toolkit\n\n\nTo start create a new SharePoint Framework project. \n[Create a new project](command:spfx-toolkit.createProject)\n\n\n\n\n\nUse a sample to kick off a new project and boost your development.\n[View samples](command:spfx-toolkit.samplesGallery)\n\n\n\n\n\nYou can also open an existing app.\n[Open folder](command:vscode.openFolder)\n\n\n\n\n\nValidate your local workspace and check if you have the required dependencies.\n[Check dependencies](command:spfx-toolkit.checkDependencies)\n\n\n\n\n\nInstall the required dependencies.\n[Install dependencies](command:spfx-toolkit.installDependencies)\n\n\n\nLearn more about SharePoint Framework and this toolkit.\n[Walkthrough](command:spfx-toolkit.welcome)\n\n\n\nStart effortlessly with GitHub Copilot. Get SPFx tailored support in setting up your local workspace, creating a new project, or managing your tenant.\n[Use @SPFx in GitHib Copilot](command:spfx-toolkit.openCopilot) \n\n\n\n\n\nFor additional help or resources visit the [extension wiki](https://github.com/pnp/vscode-viva/wiki)."
608+
"contents": "Welcome to SharePoint Framework Toolkit\n\n\nTo start create a new SharePoint Framework project. \n[Create a new project](command:spfx-toolkit.createProject)\n\n\n\n\n\nUse a sample to kick off a new project and boost your development.\n[View samples](command:spfx-toolkit.samplesGallery)\n\n\n\n\n\nYou can also open an existing app.\n[Open folder](command:vscode.openFolder)\n\n\n\n\n\nValidate your local workspace and check if you have the required dependencies.\n[Validate local setup](command:spfx-toolkit.checkDependencies)\n\n\n\n\n\nInstall the required dependencies.\n[Install dependencies](command:spfx-toolkit.installDependencies)\n\n\n\nLearn more about SharePoint Framework and this toolkit.\n[Walkthrough](command:spfx-toolkit.welcome)\n\n\n\nStart effortlessly with GitHub Copilot. Get SPFx tailored support in setting up your local workspace, creating a new project, or managing your tenant.\n[Use @SPFx in GitHib Copilot](command:spfx-toolkit.openCopilot) \n\n\n\n\n\nFor additional help or resources visit the [extension wiki](https://github.com/pnp/vscode-viva/wiki)."
609609
}
610610
],
611611
"commands": [
@@ -616,7 +616,7 @@
616616
},
617617
{
618618
"command": "spfx-toolkit.checkDependencies",
619-
"title": "Check dependencies",
619+
"title": "Validate local setup",
620620
"category": "SharePoint Framework Toolkit"
621621
},
622622
{

src/chat/PromptHandlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class PromptHandlers {
183183
}
184184
return buttons;
185185
case 'setup':
186-
if (chatResponse.toLowerCase().includes('check dependencies')) {
186+
if (chatResponse.toLowerCase().includes('validate local setup')) {
187187
return [{
188188
command: Commands.checkDependencies,
189189
title: vscode.l10n.t('Check if my local workspace is ready'),

src/constants/Prompts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ SharePoint Framework development requires the following:
113113
- Yeoman SharePoint generator - The Yeoman SharePoint web part generator helps you quickly create a SharePoint client-side solution project with the right toolchain and project structure. To install the SharePoint Framework Yeoman generator globally, enter the following command: npm install @microsoft/generator-sharepoint --global
114114
- You should be using a modern web browser like Microsoft Edge, Google Chrome, or Firefox as the development browser.
115115
You will suggest running this single command to install all three of the following: npm install gulp-cli yo @microsoft/generator-sharepoint --global
116-
You will suggest using SPFx Toolkit 'Check dependencies' action which allows to validate if your local workspace meets the needed requirements in order to develop an SPFx project.
116+
You will suggest using SPFx Toolkit 'Validate local setup' action which allows to validate if your local workspace meets the needed requirements in order to develop an SPFx project.
117117
When asked about creating new project you will suggest running the /new command instead of the /setup command in GitHub Copilot Chat with @spfx or using SPFx Toolkit Create new project form or Sample Gallery.`;
118118

119119
// TODO: this is beta. We should add more correct context from current project and better grounding

src/services/actions/Dependencies.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Commands } from '../../constants/Commands';
22
import { Notifications } from '../dataType/Notifications';
33
import { execSync } from 'child_process';
4-
import { commands, ProgressLocation, window } from 'vscode';
4+
import { commands, ProgressLocation, window, Uri } from 'vscode';
5+
import * as os from 'os';
56
import { Logger } from '../dataType/Logger';
67
import { NpmLs, Subscription } from '../../models';
78
import { TerminalCommandExecuter } from '../executeWrappers/TerminalCommandExecuter';
@@ -33,28 +34,49 @@ export class Dependencies {
3334
await window.withProgress({
3435
location: ProgressLocation.Notification,
3536
cancellable: false,
36-
title: 'Checking dependencies',
37+
title: 'Validating local setup',
3738
}, async (progress) => {
3839
return new Promise((resolve) => {
3940
setTimeout(() => {
4041
try {
41-
progress.report({ message: 'Checking node version...' });
42+
progress.report({ message: 'Validating node version...' });
4243

4344
// Validate node
4445
const isNodeValid = Dependencies.isValidNodeJs();
4546
if (!isNodeValid) {
46-
Notifications.warning('Your Node.js version is not supported with SPFx development. Make sure you are using version: >=22.14.0 and <23.0.0');
47+
const installNodeJSOption = 'Install Node.js';
48+
const useNvmOption = os.platform() === 'win32' ? 'Use NVM for Windows' : 'Use NVM';
49+
const useNvsOption = 'Use NVS';
50+
51+
Notifications.warning(
52+
'Your Node.js version is not supported with SPFx development. Make sure you are using version: >=22.14.0 and <23.0.0',
53+
installNodeJSOption,
54+
useNvmOption,
55+
useNvsOption
56+
).then((selectedOption) => {
57+
if (selectedOption === installNodeJSOption) {
58+
commands.executeCommand('vscode.open', Uri.parse('https://nodejs.org/en/download/'));
59+
} else if (selectedOption === useNvmOption) {
60+
const nvmInstallUrl = os.platform() === 'win32'
61+
? 'https://github.com/coreybutler/nvm-windows?tab=readme-ov-file#overview'
62+
: 'https://github.com/nvm-sh/nvm?tab=readme-ov-file#intro';
63+
commands.executeCommand('vscode.open', Uri.parse(nvmInstallUrl));
64+
} else if (selectedOption === useNvsOption) {
65+
const nvsInstallUrl = 'https://github.com/jasongin/nvs?tab=readme-ov-file#nvs-node-version-switcher';
66+
commands.executeCommand('vscode.open', Uri.parse(nvsInstallUrl));
67+
}
68+
});
4769
resolve(null);
4870
return;
4971
}
5072

51-
progress.report({ message: 'Checking npm dependencies...' });
73+
progress.report({ message: 'Validating npm dependencies...' });
5274

5375
const command = 'npm list -g --json --silent';
5476
const result = execSync(command, { shell: TerminalCommandExecuter.shell, timeout: 15000 });
5577

5678
if (!result) {
57-
Notifications.error('Failed checking dependencies');
79+
Notifications.error('Failed validating local setup');
5880
}
5981

6082
// Check for missing dependencies
@@ -82,7 +104,7 @@ export class Dependencies {
82104
}
83105
resolve(null);
84106
} catch (e) {
85-
Notifications.error('Failed checking dependencies');
107+
Notifications.error('Failed validating local setup');
86108
Logger.error(`${(e as Error).message}`);
87109
resolve(null);
88110
}

0 commit comments

Comments
 (0)