I’m developing a plugin for the nexus repository manager. In this case, I need to get the artifact name and the version request from various build tools on Maven, NPM, and Nuget repositories. I was able to get the name and version details for Maven and Nuget from the context object as below. But I’m unable to get name and version for NPM. Could you please guide me on how to get version details for NPM artifacts?
Nexus Plugin class
@Named
@Singleton
public class MyRequestHandler extends ConditionalRequestHandler {
@Nonnull
@Override
public Response handle(@Nonnull Context context) throws Exception {
//Get artifact version But Not working for NPM artifacts
State state = (State)context.getAttributes().require(State.class);
String packageName = (String)state.getTokens().get("packageName");
String version = (String)state.getTokens().get("packageVersion");
}
I request artifact from NodeJs Project using “npm install” . Below is the package.json file
{
"name": "nexus-test-nodejs-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"i18n": "0.9.1",
"winston-console-formatter": "0.1.0",
"logback": "1.0.16",
"parse-server": "4.4.0",
"harp": "0.33.0",
"react-native-webview": "10.10.2"
}
}