I am trying to get the current dependencies and devDependencies versions that are set in the package.json file so that when the MakeFile is run for a new user, it installs the versions listed there and not just the latest version. So for the example below, instead of just saying npm install @applitools/eyes-testcafe we would grab the version 1.16.1 from the package.json and interpolate it there in the MakeFile like ${eyes_version} or something like that.
Any idea on how to do this? Thanks!
"devDependencies": {
"@applitools/eyes-testcafe": "^1.16.1",
"testcafe": "^1.18.6",
"testcafe-reporter-xunit": "*"
}
install-testcafe: npm ffmpeg applitools testcafe
# Installs all dependencies necessary for testcafe and node to run.
npm:
npm install
# Installs the ffmpeg video recorder. This is recursive as sometimes it doesn't install automatically.
ffmpeg:
npm install @ffmpeg-installer/ffmpeg
# Installs the applitools dependency. This is recursive as sometimes it doesn't install automatically.
applitools:
npm install @applitools/eyes-testcafe
# Installs TestCafe globally. This is recursive as sometimes it doesn't install automatically.
testcafe:
sudo npm install -g testcafe
Since you are using jq,
jq '.devDependencies["@applitools/eyes-testcafe"]' package.json
I question the validity/usefulness of using a Make wrapper around NPM. You're wrapping a build tool in a build tool. Why? I'm guessing to make it more familiar to developers coming from a C/Make ecosystem. But mixing Make and NPM like this confuses Node/NPM developers, and NPM scripts can run CLI commands just like Make does.
Is npm i really more complicated than make npm? Seems like this information is better off in a README, and Make developers should be educated on how to use NPM (e.g. you can run CLI commands from inside NPM scripts). Adding Make scripts isn't adding any value here, but YMMV, maybe this is particularly useful inside your org.
Also don't use sudo when running npm.