fabric8-analytics-lsp-server
Advanced tools
Comparing version 0.1.47 to 0.1.48
@@ -1,1 +0,1 @@ | ||
{"name":"fabric8-analytics-lsp-server","description":"LSP Server for Dependency Analytics","version":"0.1.47","author":"Pavel Odvody","contributors":[{"name":"Michal Srb","email":"michal@redhat.com"},{"name":"Jyasveer Gotta","email":"jgotta@redhat.com"},{"name":"Jaivardhan Kumar","email":"jakumar@redhat.com"}],"license":"Apache-2.0","engines":{"node":"*"},"keywords":["fabric8-analytics","LSP"],"repository":{"type":"git","url":"https://github.com/fabric8-analytics/fabric8-analytics-lsp-server.git"},"dependencies":{"request":"^2.79.0","stream-json":"0.4.2","vscode-languageserver":"^4.1.3","winston":"2.3.1","xml2object":"0.1.2"},"devDependencies":{"@types/node":"^6.0.52","@krux/condition-jenkins":"1.0.1","semantic-release":"8.2.0","typescript":"^2.1.4"},"scripts":{"build":"npm run clean && node node_modules/typescript/bin/tsc -p . && cp LICENSE package.json README.md output && npm run dist","clean":"rm -Rf ca-lsp-server.tar output/","dist":"cp -r node_modules output/ && cp ./package.json output/ && node -p -e \"require('./package.json').version\" > output/VERSION && rm -rf output/node_modules/typescript/ && tar cvjf ca-lsp-server.tar -C output/ .","semantic-release":"semantic-release pre && npm run build && cp -r .git output && npm publish output/ && semantic-release post"},"release":{"branch":"master","debug":false,"verifyConditions":{"path":"./node_modules/@krux/condition-jenkins"}}} | ||
{"name":"fabric8-analytics-lsp-server","description":"LSP Server for Dependency Analytics","version":"0.1.48","author":"Pavel Odvody","contributors":[{"name":"Michal Srb","email":"michal@redhat.com"},{"name":"Jyasveer Gotta","email":"jgotta@redhat.com"},{"name":"Jaivardhan Kumar","email":"jakumar@redhat.com"}],"license":"Apache-2.0","engines":{"node":"*"},"keywords":["fabric8-analytics","LSP"],"repository":{"type":"git","url":"https://github.com/fabric8-analytics/fabric8-analytics-lsp-server.git"},"dependencies":{"request":"^2.79.0","stream-json":"0.4.2","vscode-languageserver":"^4.1.3","winston":"2.3.1","xml2object":"0.1.2"},"devDependencies":{"@types/node":"^6.0.52","@krux/condition-jenkins":"1.0.1","semantic-release":"8.2.0","typescript":"^2.1.4"},"scripts":{"build":"npm run clean && node node_modules/typescript/bin/tsc -p . && cp LICENSE package.json README.md output && npm run dist","clean":"rm -Rf ca-lsp-server.tar output/","dist":"cp -r node_modules output/ && cp ./package.json output/ && node -p -e \"require('./package.json').version\" > output/VERSION && rm -rf output/node_modules/typescript/ && tar cvjf ca-lsp-server.tar -C output/ .","semantic-release":"semantic-release pre && npm run build && cp -r .git output && npm publish output/ && semantic-release post"},"release":{"branch":"master","debug":false,"verifyConditions":{"path":"./node_modules/@krux/condition-jenkins"}}} |
143
server.js
@@ -6,2 +6,10 @@ /* -------------------------------------------------------------------------------------------- | ||
'use strict'; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -193,2 +201,82 @@ const path = require("path"); | ||
}; | ||
const bulkComponentAnalysis = function (reqData) { | ||
return new Promise((resolve, reject) => { | ||
const options = {}; | ||
options['url'] = config.server_url; | ||
if (config.three_scale_user_token) { | ||
options['url'] += `/component-analyses/?user_key=${config.three_scale_user_token}`; | ||
} | ||
else { | ||
options['url'] += `/component-analyses`; | ||
} | ||
options['headers'] = { | ||
'Content-Type': 'application/json', | ||
'Authorization': 'Bearer ' + config.api_token, | ||
}; | ||
options['body'] = reqData; | ||
request.post(options, (err, httpResponse, body) => { | ||
if (err) { | ||
console.log('error', err); | ||
reject(err); | ||
} | ||
else { | ||
console.log('response Post ' + body); | ||
if ((httpResponse.statusCode === 200 || httpResponse.statusCode === 202)) { | ||
let resp = JSON.parse(body); | ||
resolve(resp); | ||
} | ||
else if (httpResponse.statusCode === 401) { | ||
reject(httpResponse.statusCode); | ||
} | ||
else if (httpResponse.statusCode === 429 || httpResponse.statusCode === 403) { | ||
reject(httpResponse.statusCode); | ||
} | ||
else if (httpResponse.statusCode === 400) { | ||
reject(httpResponse.statusCode); | ||
} | ||
else { | ||
reject(httpResponse.statusCode); | ||
} | ||
} | ||
}); | ||
}); | ||
}; | ||
const constructPayload = function (ecosystem, packages) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield new Promise((resolve) => { | ||
const regexVersion = new RegExp(/^(\d+\.)?(\d+\.)?(\d+)$/); | ||
let request_payload = []; | ||
for (let pck of packages) { | ||
if (pck.name.value && pck.version.value && regexVersion.test(pck.version.value)) { | ||
request_payload.push({ | ||
"ecosystem": ecosystem, | ||
"package": pck.name.value, | ||
"version": pck.version.value | ||
}); | ||
} | ||
} | ||
resolve(request_payload); | ||
}); | ||
}); | ||
}; | ||
let getComponentsInfo = function (request_payload, aggregator, components, diagnostics) { | ||
for (let i = 0; i < request_payload.length; i += 10) { | ||
let pck = request_payload.slice(i, i + 10); | ||
let req_data = JSON.stringify(pck); | ||
bulkComponentAnalysis(req_data).then((response) => { | ||
let componentAnalysisResponse; | ||
componentAnalysisResponse = response; | ||
for (let r of componentAnalysisResponse) { | ||
for (let com of components) { | ||
if (r.result.data[0].version.pname[0] === com.name.value && r.result.data[0].version.version[0] === com.version.value) { | ||
let pipeline = new consumers_1.DiagnosticsPipeline(DiagnosticsEngines, com, config, diagnostics); | ||
pipeline.run(r); | ||
} | ||
aggregator.aggregate(com); | ||
} | ||
} | ||
}) | ||
.catch(err => console.log(err)); | ||
} | ||
}; | ||
files.on(EventStream.Diagnostics, "^package\\.json$", (uri, name, contents) => { | ||
@@ -212,17 +300,5 @@ /* Convert from readable stream into string */ | ||
}); | ||
const regexVersion = new RegExp(/^(\d+\.)?(\d+\.)?(\d+)$/); | ||
for (let dependency of deps) { | ||
if (dependency.name.value && dependency.version.value && regexVersion.test(dependency.version.value)) { | ||
get_metadata('npm', dependency.name.value, dependency.version.value, (response) => { | ||
if (response != null) { | ||
let pipeline = new consumers_1.DiagnosticsPipeline(DiagnosticsEngines, dependency, config, diagnostics); | ||
pipeline.run(response); | ||
} | ||
aggregator.aggregate(dependency); | ||
}); | ||
} | ||
else { | ||
aggregator.aggregate(dependency); | ||
} | ||
} | ||
constructPayload('npm', deps).then((payload) => { | ||
getComponentsInfo(payload, aggregator, deps, diagnostics); | ||
}); | ||
}); | ||
@@ -248,17 +324,5 @@ }); | ||
}); | ||
const regexVersion = /^((\d+|[A-Za-z]+)[-.])*((\d+|[A-Za-z]+))$/; | ||
for (let dependency of deps) { | ||
if (dependency.name.value && dependency.version.value && regexVersion.test(dependency.version.value)) { | ||
get_metadata('maven', dependency.name.value, dependency.version.value, (response) => { | ||
if (response != null) { | ||
let pipeline = new consumers_1.DiagnosticsPipeline(DiagnosticsEngines, dependency, config, diagnostics); | ||
pipeline.run(response); | ||
} | ||
aggregator.aggregate(dependency); | ||
}); | ||
} | ||
else { | ||
aggregator.aggregate(dependency); | ||
} | ||
} | ||
constructPayload('maven', deps).then((payload) => { | ||
getComponentsInfo(payload, aggregator, deps, diagnostics); | ||
}); | ||
}); | ||
@@ -282,18 +346,5 @@ }); | ||
}); | ||
const regexVersion = new RegExp(/^(\d+\.)?(\d+\.)?(\d+)$/); | ||
for (let dependency of deps) { | ||
winston.info('python cmp name' + dependency.name.value); | ||
if (dependency.name.value && dependency.version.value && regexVersion.test(dependency.version.value.trim())) { | ||
get_metadata('pypi', dependency.name.value.trim(), dependency.version.value.trim(), (response) => { | ||
if (response != null) { | ||
let pipeline = new consumers_1.DiagnosticsPipeline(DiagnosticsEngines, dependency, config, diagnostics); | ||
pipeline.run(response); | ||
} | ||
aggregator.aggregate(dependency); | ||
}); | ||
} | ||
else { | ||
aggregator.aggregate(dependency); | ||
} | ||
} | ||
constructPayload('pypi', deps).then((payload) => { | ||
getComponentsInfo(payload, aggregator, deps, diagnostics); | ||
}); | ||
}); | ||
@@ -300,0 +351,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78783
900