README
Xray Javascript Client
Xray Javascript Client is a Javascript library, which wraps some of the REST APIs exposed by JFrog Xray.
Getting started
Add xray-client-js as a dependency to your package.json file:
"dependencies": {
"xray-client-js": "^1.0.0"
}
APIs
Setting up Xray client
let xrayClient = new XrayClient({
serverUrl: 'ArtifactoryUrl',
username: 'username',
password: 'password',
proxy: {host: '<organization>-xray.jfrog.io', port: 80, protocol: 'https'},
headers: { 'key1': 'value1', 'key2': 'value2' };
});
Pinging Xray
xrayClient.system().ping()
.then(result => {
console.log(result);
})
.catch(error => {
console.error(error);
});
Getting Xray version
xrayClient.system().version()
.then(result => {
console.log(result);
})
.catch(error => {
console.error(error);
});
Scanning bulk of dependencies
let express = new ComponentDetails('npm://express:4.0.0');
let request = new ComponentDetails('npm://request:2.0.0');
xrayClient.summary().component({
component_details: [express, request]
})
.then(result => {
console.log(JSON.stringify(result));
})
.catch(error => {
console.error(error);
});
Building and testing the sources
To build the plugin sources, please follow these steps:
Clone the code from git.
Install and pack the xray-client-js dependency locally, by running the following npm commands:
npm i && npm pack
If you'd like run the xray-client-js integration tests, follow these steps:
- Make sure your Xray instance is up and running.
- Set the CLIENTTESTS_XRAY_URL, CLIENTTESTS_XRAY_USERNAME and CLIENTTESTS_XRAY_PASSWORD environment variables with your Xray URL, username and password.
- Run the following command:
npm t
Important: The tests use port 9090 to set up an HTTP proxy server. If this port is already used on the machines which runs the tests, please replace it in the tests code with a different port.
Pull requests
We welcome pull requests from the community.
Guidelines
- Before creating your first pull request, please join our contributors community by signing JFrog's CLA.
- If the existing tests do not already cover your changes, please add tests.
- Pull requests should be created on the dev branch.
- Please run
npm run format
for formatting the code before submitting the pull request.