github-codeowners
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -29,3 +29,4 @@ #!/usr/bin/env node | ||
const logger_1 = require("./lib/logger"); | ||
const types_1 = require("./lib/types"); | ||
const types_1 = require("./lib/writers/types"); | ||
const validate_1 = require("./commands/validate"); | ||
commander_1.default.command('audit') | ||
@@ -54,2 +55,22 @@ .description('list the owners for all files') | ||
})); | ||
commander_1.default.command('validate') | ||
.description('Validates a CODOWNER file and files in dir') | ||
.option('-d, --dir <dirPath>', 'path to VCS directory', process.cwd()) | ||
.option('-c, --codeowners <filePath>', 'path to codeowners file (default: "<dir>/.github/CODEOWNERS")') | ||
.option('-r, --root <rootPath>', 'the root path to filter files by', '') | ||
.action((options) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
if (!options.codeowners) { | ||
options.codeowners = path.resolve(options.dir, '.github/CODEOWNERS'); | ||
} | ||
if (options.root) { | ||
options.dir = path.resolve(options.dir, options.root); | ||
} | ||
yield validate_1.validate(options); | ||
} | ||
catch (error) { | ||
logger_1.log.error('failed to run validate command', error); | ||
process.exit(1); | ||
} | ||
})); | ||
commander_1.default.command('who <file>') | ||
@@ -56,0 +77,0 @@ .description('lists owners of a specific file') |
@@ -1,2 +0,2 @@ | ||
import { OUTPUT_FORMAT } from '../lib/types'; | ||
import { OUTPUT_FORMAT } from '../lib/writers'; | ||
interface AuditOptions { | ||
@@ -3,0 +3,0 @@ codeowners: string; |
@@ -11,18 +11,8 @@ "use strict"; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path = __importStar(require("path")); | ||
const OwnershipEngine_1 = require("../lib/OwnershipEngine"); | ||
const OwnedFile_1 = require("../lib/OwnedFile"); | ||
const writers_1 = require("../lib/writers"); | ||
const stats_1 = require("../lib/stats"); | ||
const writers_1 = require("../lib/writers"); | ||
const dir_1 = require("../lib/dir"); | ||
const ownership_1 = require("../lib/ownership"); | ||
exports.audit = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
const files = yield getFilesWithOwnership(options); | ||
const files = yield ownership_1.getFileOwnership(options); | ||
if (options.stats) { | ||
@@ -44,15 +34,2 @@ const stats = stats_1.calcFileStats(files); | ||
}); | ||
const getFilesWithOwnership = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
const engine = OwnershipEngine_1.OwnershipEngine.FromCodeownersFile(options.codeowners); | ||
let filePaths = yield dir_1.readDirRecursively(options.dir, ['.git']); | ||
if (options.root) { | ||
filePaths = filePaths.map(filePath => path.join(options.root, filePath)); | ||
} | ||
filePaths.sort(); | ||
const files = []; | ||
for (const filePath of filePaths) { | ||
files.push(yield OwnedFile_1.OwnedFile.FromPath(filePath, engine)); | ||
} | ||
return files; | ||
}); | ||
//# sourceMappingURL=audit.js.map |
@@ -1,2 +0,2 @@ | ||
import { OUTPUT_FORMAT } from '../lib/types'; | ||
import { OUTPUT_FORMAT } from '../lib/writers'; | ||
interface GitOptions { | ||
@@ -3,0 +3,0 @@ dir: string; |
@@ -13,6 +13,5 @@ "use strict"; | ||
const child_process_1 = require("child_process"); | ||
const OwnedFile_1 = require("../lib/OwnedFile"); | ||
const OwnershipEngine_1 = require("../lib/OwnershipEngine"); | ||
const ownership_1 = require("../lib/ownership"); | ||
const writers_1 = require("../lib/writers"); | ||
const stats_1 = require("../lib/stats"); | ||
const writers_1 = require("../lib/writers"); | ||
exports.git = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -22,6 +21,6 @@ const gitCommand = calcGitCommand(options); | ||
const changedPaths = diff.split('\n').filter(path => path.length > 0); | ||
const engine = OwnershipEngine_1.OwnershipEngine.FromCodeownersFile(options.codeowners); | ||
const engine = ownership_1.OwnershipEngine.FromCodeownersFile(options.codeowners); | ||
const files = []; | ||
for (const filePath of changedPaths) { | ||
files.push(yield OwnedFile_1.OwnedFile.FromPath(filePath, engine, { countLines: false })); | ||
files.push(yield ownership_1.OwnedFile.FromPath(filePath, engine, { countLines: false })); | ||
} | ||
@@ -28,0 +27,0 @@ for (const file of files) { |
@@ -1,2 +0,2 @@ | ||
import { OUTPUT_FORMAT } from '../lib/types'; | ||
import { OUTPUT_FORMAT } from '../lib/writers'; | ||
interface WhoOptions { | ||
@@ -3,0 +3,0 @@ file: string; |
@@ -12,10 +12,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const OwnershipEngine_1 = require("../lib/OwnershipEngine"); | ||
const OwnedFile_1 = require("../lib/OwnedFile"); | ||
const ownership_1 = require("../lib/ownership"); | ||
const writers_1 = require("../lib/writers"); | ||
exports.who = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
const engine = OwnershipEngine_1.OwnershipEngine.FromCodeownersFile(options.codeowners); | ||
const file = yield OwnedFile_1.OwnedFile.FromPath(options.file, engine); | ||
const engine = ownership_1.OwnershipEngine.FromCodeownersFile(options.codeowners); | ||
const file = yield ownership_1.OwnedFile.FromPath(options.file, engine); | ||
writers_1.writeOwnedFile(file, options, process.stdout); | ||
}); | ||
//# sourceMappingURL=who.js.map |
{ | ||
"name": "github-codeowners", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Handy tool for working with file ownership using Githubs CODEOWNERS file", | ||
@@ -40,3 +40,3 @@ "main": "dist/cli.js", | ||
"ts-node": "^8.6.2", | ||
"tslint": "^6.0.0", | ||
"tslint": "^6.1.3", | ||
"tslint-config-airbnb-base": "^0.3.0", | ||
@@ -43,0 +43,0 @@ "typescript": "^3.8.2", |
@@ -9,8 +9,8 @@ # github-codeowners | ||
Things it does: | ||
* Output who owns each file in your repo (ignoring files listed in `.gitignore`) | ||
* Output who owns a single file | ||
* Output ownership information at a specific git commit | ||
* Output ownership information of staged files | ||
* Outputs lots of lovely stats | ||
* Outputs handy formats for integrations (CSV and JSONL) | ||
* Calculate ownership stats | ||
* Find out who owns each and every file (ignoring files listed in `.gitignore`) | ||
* Find out who owns a single file | ||
* Find out who owns your staged files | ||
* Outputs in a bunch of script friendly handy formats for integrations (CSV and JSONL) | ||
* Validates that your CODEOWNERS file is valid | ||
@@ -85,3 +85,3 @@ ## Installation | ||
Options: | ||
-d, --dir <dirPath> path to VCS directory (default: "/Users/jjmschofield/projects/github/github-codeowners") | ||
-d, --dir <dirPath> path to VCS directory (default: "<current working directory>") | ||
-c, --codeowners <filePath> path to codeowners file (default: "<dir>/.github/CODEOWNERS") | ||
@@ -156,2 +156,26 @@ -o, --output <outputFormat> how to output format eg: simple, jsonl, csv (default: "simple") | ||
### Validate | ||
Validates your CODEOWNERS file to find common mistakes, will throw on errors (such as malformed owners). | ||
```shell script | ||
$ cd <your awesome project> | ||
$ github-codeowners validate | ||
Found duplicate rules [ 'some/duplicate/rule @octocat' ] | ||
Found rules which did not match any files [ 'some/non-existent/path @octocat' ] | ||
... | ||
``` | ||
Full usage information: | ||
```shell script | ||
$ github-codeowners validate --help | ||
Usage: github-codeowners validate [options] | ||
Validates a CODOWNER file and files in dir | ||
Options: | ||
-d, --dir <dirPath> path to VCS directory (default: "<current working directory>") | ||
-c, --codeowners <filePath> path to codeowners file (default: "<dir>/.github/CODEOWNERS") | ||
-r, --root <rootPath> the root path to filter files by (default: "") | ||
-h, --help output usage information | ||
``` | ||
## Output Formats | ||
@@ -158,0 +182,0 @@ Check `github-codeowners <command> --help` for support for a given command, however generally the following outputs are supported: |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
118828
126
1383
192
6
6