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] Added proper installation support for various node package managers #765

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion npm/ci-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pushd ./codegens/csharp-restsharp &>/dev/null;
sudo apt-get install dotnet-sdk-6.0
dotnet new console -o testProject -f net6.0
pushd ./testProject &>/dev/null;
dotnet add package RestSharp --version 110.0.0
dotnet add package RestSharp --version 112.0.0
popd &>/dev/null;
popd &>/dev/null;

Expand Down
33 changes: 28 additions & 5 deletions npm/deepinstall.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var shell = require('shelljs'),
path = require('path'),
async = require('async'),
{ detect } = require('detect-package-manager'),
{ detect, getNpmVersion } = require('detect-package-manager'),
pm,
PRODUCTION_FLAG = '',
ver,
command,
getSubfolders,
fs = require('fs'),
pwd = shell.pwd();
Expand All @@ -24,12 +25,34 @@ async.series([
return next();
});
},
function (next) {
getNpmVersion(pm).then((res) => {
ver = res;
console.log('Detected ' + pm + ' version: ' + ver);
return next();
});
},
function (next) {
if (args[2] && args[2] === 'dev') {
console.log('Dev flag detected running ' + pm + ' install');
command = pm + ' install';
}
else {
PRODUCTION_FLAG = '--no-audit --production';
switch (pm) {
case 'yarn':
if (ver.startsWith('1')) {
command = 'yarn install --production --frozen-lockfile';
}
else {
command = 'touch yarn.lock && yarn workspaces focus --all --production'
}
break;
case 'pnpm':
command = 'pnpm install --prod';
break;
default:
command = pm + ' install --no-audit --production';
}
}

console.log('Running pre-package script');
Expand All @@ -51,8 +74,8 @@ async.series([

var commandOut;

console.log(codegen.name + ': ' + pm + ' install ' + PRODUCTION_FLAG);
commandOut = shell.exec(pm + ' install ' + PRODUCTION_FLAG, { silent: true });
console.log(codegen.name + ': ' + command);
commandOut = shell.exec(command, { silent: true });

if (commandOut.code !== 0) {
console.error('Failed to run ' + pm + ' install on codegen ' + codegen.name + ', here is the error:');
Expand Down
Loading