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

fix: package manager feature #33

Merged

Conversation

shivankurchavan
Copy link

@shivankurchavan shivankurchavan commented Jun 19, 2024

Issue : #29

Functionality added : stencil new will check for installed package managers and then ask user to choose from only those which are installed.

Default case: it'll ask to install npm.

Does this PR introduce a breaking change?

[ ] Yes
[ ] No

Other information

Comment on lines 557 to 573
const installNpm = (): void => {
try {
const currentPlatform = platform();
if (currentPlatform === 'win32') {
// Windows installation command for npm via Node.js installer
console.log('Downloading and installing Node.js which includes npm...');
execSync('powershell -Command "Invoke-WebRequest -Uri https://nodejs.org/dist/v18.16.1/node-v18.16.1-x64.msi -OutFile nodejs.msi; Start-Process msiexec.exe -ArgumentList \'/i nodejs.msi /quiet\' -Wait; Remove-Item nodejs.msi"', { stdio: 'inherit' });
} else {
// Linux/macOS installation command for npm
execSync('curl -L https://www.npmjs.com/install.sh | sh', { stdio: 'inherit' });
}
console.log('npm has been installed.');
} catch (error) {
console.error('Failed to install npm:', error);
process.exit(1);
}
};
Copy link
Member

Choose a reason for hiding this comment

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

we don't need this.

Comment on lines 548 to 555
const checkIfPackageManagerIsAvailable = (cmd: string): boolean => {
try {
execSync(`command -v ${cmd}`, { stdio: 'ignore' });
return true;
} catch (error) {
return false;
}
};
Copy link
Member

Choose a reason for hiding this comment

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

move to npm specific command

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const checkIfPackageManagerIsAvailable = (cmd: string): boolean => {
try {
execSync(`command -v ${cmd}`, { stdio: 'ignore' });
return true;
} catch (error) {
return false;
}
};
execSync(`${cmd} -v`, { stdio: 'ignore' });

@techsavvyash techsavvyash merged commit 604fcf7 into SamagraX-Stencil:dev Jun 22, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: check for the installed package managers and list only those
2 participants