github-codeowners
Advanced tools
Comparing version 0.0.3 to 0.0.4-rc1
@@ -28,2 +28,3 @@ #!/usr/bin/env node | ||
const git_1 = require("./commands/git"); | ||
const logger_1 = require("./lib/logger"); | ||
const types_1 = require("./lib/types"); | ||
@@ -46,3 +47,3 @@ commander_1.default.command('audit') | ||
catch (error) { | ||
console.error(error); | ||
logger_1.log.error('failed to run audit command', error); | ||
process.exit(1); | ||
@@ -68,3 +69,3 @@ } | ||
catch (error) { | ||
console.error(error); | ||
logger_1.log.error('failed to run who command', error); | ||
process.exit(1); | ||
@@ -89,3 +90,3 @@ } | ||
catch (error) { | ||
console.error(error); | ||
logger_1.log.error('failed to run git command', error); | ||
process.exit(1); | ||
@@ -92,0 +93,0 @@ } |
@@ -20,2 +20,3 @@ "use strict"; | ||
const fs = __importStar(require("fs")); | ||
const logger_1 = require("./logger"); | ||
class OwnedFile { | ||
@@ -59,3 +60,3 @@ constructor(props) { | ||
.on('error', (e) => { | ||
console.error(`failed to read lines from file ${filePath}`, e); | ||
logger_1.log.error(`failed to read lines from file ${filePath}`, e); | ||
reject(e); | ||
@@ -62,0 +63,0 @@ }) |
@@ -15,2 +15,3 @@ "use strict"; | ||
const ignore_1 = __importDefault(require("ignore")); | ||
const logger_1 = require("./logger"); | ||
class OwnershipEngine { | ||
@@ -21,9 +22,9 @@ constructor(matchers) { | ||
calcFileOwnership(filePath) { | ||
const owners = new Set(); | ||
for (const matcher of this.matchers) { | ||
const matchers = [...this.matchers].reverse(); | ||
for (const matcher of matchers) { | ||
if (matcher.match(filePath)) { | ||
matcher.owners.forEach(owner => owners.add(owner)); | ||
return matcher.owners; | ||
} | ||
} | ||
return Array.from(owners.values()); | ||
return []; | ||
} | ||
@@ -43,3 +44,3 @@ static FromCodeownersFile(filePath) { | ||
catch (error) { | ||
console.error(`failed to load codeowners file from ${filePath}`, error); | ||
logger_1.log.error(`failed to load codeowners file from ${filePath}`, error); | ||
throw error; | ||
@@ -46,0 +47,0 @@ } |
@@ -18,2 +18,9 @@ "use strict"; | ||
exports.writeStats = (stats, options, stream) => { | ||
const orderedOwners = [...stats.owners].sort((a, b) => { | ||
if (a.owner < b.owner) | ||
return -1; | ||
if (a.owner > b.owner) | ||
return 1; | ||
return 0; | ||
}); | ||
switch (options.output) { | ||
@@ -28,3 +35,3 @@ case (types_1.OUTPUT_FORMAT.JSONL): | ||
stream.write(`unloved,${stats.unloved.files},${stats.unloved.lines}\n`); | ||
stats.owners.forEach((owner) => { | ||
orderedOwners.forEach((owner) => { | ||
stream.write(`${owner.owner},${owner.counters.files},${owner.counters.lines}\n`); | ||
@@ -39,3 +46,3 @@ }); | ||
stream.write('--- Owners ---\n'); | ||
const owners = stats.owners.map(owner => `${owner.owner}: ${owner.counters.files} files (${owner.counters.lines} lines)`).join('\n'); | ||
const owners = orderedOwners.map(owner => `${owner.owner}: ${owner.counters.files} files (${owner.counters.lines} lines)`).join('\n'); | ||
stream.write(`${owners}\n`); | ||
@@ -42,0 +49,0 @@ break; |
{ | ||
"name": "github-codeowners", | ||
"version": "0.0.3", | ||
"version": "0.0.4-rc1", | ||
"description": "Handy tool for working with file ownership using Githubs CODEOWNERS file", | ||
@@ -13,3 +13,9 @@ "main": "dist/cli.js", | ||
"cli": "ts-node src/cli.ts", | ||
"dist:cli": "tsc && node dist/cli.js" | ||
"cli:dist": "tsc && node dist/cli.js", | ||
"lint": "tslint -c tslint.json 'src/**/*.ts'", | ||
"test:unit": "jest", | ||
"test:unit:coverage": "npm run test:unit -- --coverage", | ||
"pretest:int": "rm -rf tests/scratch", | ||
"test:int": "env JEST_JUNIT_OUTPUT_DIR=./tests/reports/int jest --testMatch **/*.test.int.ts --ci", | ||
"coveralls": "coveralls" | ||
}, | ||
@@ -28,7 +34,14 @@ "author": "jjmschofield@googlemail.com", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.5", | ||
"@types/node": "^13.7.6", | ||
"@types/uuid": "^8.0.0", | ||
"coveralls": "^3.1.0", | ||
"jest": "^26.1.0", | ||
"jest-junit": "^11.0.1", | ||
"ts-jest": "^26.1.3", | ||
"ts-node": "^8.6.2", | ||
"tslint": "^6.0.0", | ||
"tslint-config-airbnb-base": "^0.3.0", | ||
"typescript": "^3.8.2" | ||
"typescript": "^3.8.2", | ||
"uuid": "^8.2.0" | ||
}, | ||
@@ -35,0 +48,0 @@ "bin": "dist/cli.js", |
# github-codeowners | ||
[![CircleCI](https://circleci.com/gh/jjmschofield/github-codeowners/tree/master.svg?style=shield)](https://circleci.com/gh/jjmschofield/github-codeowners/tree/master) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/jjmschofield/github-codeowners/badge.svg?targetFile=package.json)](https://snyk.io/test/github/jjmschofield/github-codeowners?targetFile=package.json) | ||
[![Coverage Status](https://coveralls.io/repos/github/jjmschofield/github-codeowners/badge.svg?branch=master)](https://coveralls.io/github/jjmschofield/github-codeowners?branch=master) | ||
A CLI tool for working with GitHub CODEOWNERS. | ||
@@ -3,0 +7,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
63032
58
756
170
12
4
2