fabric8-analytics-lsp-server
Advanced tools
Comparing version 0.1.53 to 0.1.54
@@ -60,17 +60,24 @@ /* -------------------------------------------------------------------------------------------- | ||
class NaivePyParser { | ||
constructor(objSam) { | ||
this.dependencies = []; | ||
this.isDependency = false; | ||
this.objSam = objSam; | ||
this.parser = this.createPyParser(); | ||
constructor(contents) { | ||
this.dependencies = NaivePyParser.parseDependencies(contents); | ||
} | ||
createPyParser() { | ||
let deps = this.dependencies; | ||
this.objSam.forEach(function (obj) { | ||
let entry = new json_1.KeyValueEntry(obj["pkgName"], { line: 0, column: 0 }); | ||
entry.value = new json_1.Variant(json_1.ValueType.String, obj["version"]); | ||
entry.value_position = { line: obj["line"], column: obj["column"] }; | ||
let dep = new Dependency(entry); | ||
deps.push(dep); | ||
}); | ||
static parseDependencies(contents) { | ||
const requirements = contents.split("\n"); | ||
return requirements.reduce((dependencies, req, index) => { | ||
// skip any text after # | ||
if (req.includes('#')) { | ||
req = req.split('#')[0]; | ||
} | ||
const parsedRequirement = req.split(/[==,>=,<=]+/); | ||
const pkgName = (parsedRequirement[0] || '').trim(); | ||
// skip empty lines | ||
if (pkgName.length > 0) { | ||
const version = (parsedRequirement[1] || '').trim(); | ||
const entry = new json_1.KeyValueEntry(pkgName, { line: 0, column: 0 }); | ||
entry.value = new json_1.Variant(json_1.ValueType.String, version); | ||
entry.value_position = { line: index + 1, column: req.indexOf(version) + 1 }; | ||
dependencies.push(new Dependency(entry)); | ||
} | ||
return dependencies; | ||
}, []); | ||
} | ||
@@ -81,28 +88,2 @@ parse() { | ||
} | ||
let toObject = (arr) => { | ||
let rv = []; | ||
for (let i = 0; i < arr.length; ++i) { | ||
if (arr[i] !== undefined) { | ||
// let line: string = arr[i].replace(/\s/g,''); | ||
let line = arr[i]; | ||
let lineArr; | ||
let lineStr; | ||
if (line.indexOf('#') !== -1) { | ||
lineArr = line.split("#"); | ||
lineStr = lineArr[0]; | ||
} | ||
else { | ||
lineStr = line; | ||
} | ||
let subArr = lineStr.split(/[==,>=,<=]+/); | ||
let subObj = {}; | ||
subObj["pkgName"] = subArr[0]; | ||
subObj["version"] = subArr[1] || ""; | ||
subObj["line"] = i + 1; | ||
subObj["column"] = subArr[0].length + 3; | ||
rv.push(subObj); | ||
} | ||
} | ||
return rv; | ||
}; | ||
/* Process entries found in the txt files and collect all dependency | ||
@@ -116,7 +97,4 @@ * related information */ | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let tempArr = contents.split("\n"); | ||
let objSam = toObject(tempArr); | ||
let parser = new NaivePyParser(objSam); | ||
let dependencies = parser.parse(); | ||
return dependencies; | ||
let parser = new NaivePyParser(contents); | ||
return parser.parse(); | ||
}); | ||
@@ -123,0 +101,0 @@ } |
@@ -1,1 +0,1 @@ | ||
{"name":"fabric8-analytics-lsp-server","description":"LSP Server for Dependency Analytics","version":"0.1.53","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.54","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":{"@krux/condition-jenkins":"1.0.1","@types/chai":"^4.1.7","@types/mocha":"^5.2.7","@types/node":"^6.0.52","chai":"^4.2.0","mocha":"^6.2.0","nyc":"^14.1.1","semantic-release":"8.2.0","ts-node":"^8.3.0","typescript":"^2.9.2"},"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/","test":"nyc mocha","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"},"nyc":{"include":["src/**/*.ts"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["text","html"],"sourceMap":true,"instrument":true},"release":{"branch":"master","debug":false,"verifyConditions":{"path":"./node_modules/@krux/condition-jenkins"}}} |
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
74948
10
838