Comparing version 1.0.6 to 1.0.7
14
index.js
@@ -15,4 +15,5 @@ #!/usr/bin/env node | ||
.version(version) | ||
.usage('-g <giturl>') | ||
.usage('-g <giturl> -c <gitcheckout>') | ||
.option('-g, --gitUrl [url]', 'Git Url of the project you want complexity report for') | ||
.option('-c, --gitCheckout [branch/tag/checkout]', 'Branch / tag / checkout of the git project') | ||
.parse(process.argv) | ||
@@ -26,6 +27,9 @@ | ||
const gitUrl = Program.gitUrl | ||
const clonedRepoPath = util.getClonedRepoPath(gitUrl) | ||
const reportsPath = util.getReportsPath(gitUrl) | ||
clone(gitUrl, clonedRepoPath).then(function () { | ||
const gitCheckout = Program.gitCheckout || 'master' | ||
const clonedRepoPath = util.getClonedRepoPath(gitUrl, gitCheckout) | ||
const reportsPath = util.getReportsPath(gitUrl, gitCheckout) | ||
const cloneOptions = { | ||
checkout: gitCheckout | ||
} | ||
clone(gitUrl, clonedRepoPath, cloneOptions).then(function () { | ||
return getJsFiles(clonedRepoPath) | ||
@@ -32,0 +36,0 @@ }).then(function (jsfiles) { |
@@ -7,3 +7,3 @@ 'use strict' | ||
module.exports = function clone (gitUrl, path) { | ||
module.exports = function clone (gitUrl, path, options) { | ||
try { | ||
@@ -17,3 +17,3 @@ Fse.emptyDirSync(path) | ||
return new Promise(function (resolve, reject) { | ||
GitClone(gitUrl, path, {}, function (err, result) { | ||
GitClone(gitUrl, path, options, function (err, result) { | ||
if (err) { | ||
@@ -20,0 +20,0 @@ console.log('Error in cloning ' + gitUrl) |
@@ -8,4 +8,10 @@ 'use strict' | ||
var complexityReport = {} | ||
const jsonReport = JSON.parse(Fse.readFileSync(path, 'utf-8')) | ||
complexityReport.cyclomatic = +(jsonReport.cyclomatic.toFixed(2)) | ||
complexityReport.loc = +(jsonReport.loc.toFixed(2)) | ||
complexityReport.maintainability = +(jsonReport.maintainability.toFixed(2)) | ||
complexityReport.report = [] | ||
const jsonReport = JSON.parse(Fse.readFileSync(path, 'utf-8')) | ||
jsonReport.reports.forEach(function (report) { | ||
@@ -15,9 +21,7 @@ var rep = {} | ||
rep.cyclomatic = +(report.cyclomatic.toFixed(2)) | ||
rep.loc = +(report.loc.toFixed(2)) | ||
rep.loc = report.aggregate.sloc.physical | ||
rep.avglocPerMethod = +(report.loc.toFixed(2)) | ||
rep.maintainability = +(report.maintainability.toFixed(2)) | ||
complexityReport.report.push(rep) | ||
}) | ||
complexityReport.cyclomatic = +(jsonReport.cyclomatic.toFixed(2)) | ||
complexityReport.loc = +(jsonReport.loc.toFixed(2)) | ||
complexityReport.maintainability = +(jsonReport.maintainability.toFixed(2)) | ||
Fse.writeFileSync(Path.join(reportsPath, 'complexity-report.json'), JSON.stringify(complexityReport, null, 3)) | ||
@@ -24,0 +28,0 @@ console.log('Successfully wrote report at: ' + Path.join(reportsPath, 'complexity-report.json')) |
@@ -12,4 +12,4 @@ 'use strict' | ||
getReportsPath: function (gitUrl) { | ||
const reportsPath = Path.join(process.cwd(), 'reports', GitUrlParse(gitUrl).pathname) | ||
getReportsPath: function (gitUrl, gitCheckout) { | ||
const reportsPath = Path.join(process.cwd(), 'reports', GitUrlParse(gitUrl).pathname, gitCheckout) | ||
Fse.ensureDirSync(reportsPath) | ||
@@ -35,4 +35,8 @@ return reportsPath | ||
const hash = (git.hash === '' ? 'master' : git.hash) | ||
return git.protocol + '://' + git.resource + '/' + git.pathname + '/blob/' + hash + fileName | ||
let pathname = git.pathname | ||
const lastIndexOfGit = pathname.lastIndexOf('.git') | ||
pathname = pathname.slice(0, lastIndexOfGit) | ||
return 'https://' + git.resource + pathname + '/blob/' + hash + fileName | ||
} | ||
} |
{ | ||
"name": "complan", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "COMPLexity ANalyzer Tool For Javascript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
56561
19
452