Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github-codeowners

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-codeowners - npm Package Compare versions

Comparing version 0.0.4 to 0.1.0

dist/commands/__fixtures__/default/index.d.ts

2

dist/cli.js

@@ -76,3 +76,3 @@ #!/usr/bin/env node

.option('-o, --output <outputFormat>', `how to output format eg: ${Object.values(types_1.OUTPUT_FORMAT).join(', ')}`, types_1.OUTPUT_FORMAT.SIMPLE)
.option('-s, --stats', 'output stats', false)
.option('-s, --stats', 'output stats, note: line counts are not available for this command', false)
.action((shaA, shaB, options) => __awaiter(void 0, void 0, void 0, function* () {

@@ -79,0 +79,0 @@ try {

@@ -16,3 +16,4 @@ "use strict";

const uuid_1 = require("uuid");
const project_fixture_1 = require("./__fixtures__/project.fixture");
const default_1 = __importDefault(require("./__fixtures__/default"));
const project_builder_test_helper_1 = require("./__fixtures__/project-builder.test.helper");
const util_1 = __importDefault(require("util"));

@@ -22,9 +23,9 @@ const exec = util_1.default.promisify(require('child_process').exec);

const testId = uuid_1.v4();
let workingDir = 'not set';
let testDir = 'not set';
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
workingDir = yield project_fixture_1.generateProject(testId);
console.log(`test scratch dir: ${workingDir}`);
testDir = yield project_builder_test_helper_1.generateProject(testId, default_1.default);
console.log(`test scratch dir: ${testDir}`);
}));
const runCli = (args) => __awaiter(void 0, void 0, void 0, function* () {
return exec(`node ../../../dist/cli.js ${args}`, { cwd: workingDir });
return exec(`node ../../../dist/cli.js ${args}`, { cwd: testDir });
});

@@ -31,0 +32,0 @@ const outputs = ['simple', 'jsonl', 'csv'];

@@ -18,3 +18,3 @@ "use strict";

exports.git = (options) => __awaiter(void 0, void 0, void 0, function* () {
const gitCommand = `git diff --name-only ${options.shaA ? options.shaA : '--cached'} ${options.shaB ? options.shaB : 'HEAD'}`;
const gitCommand = calcGitCommand(options);
const diff = child_process_1.execSync(gitCommand).toString();

@@ -25,3 +25,3 @@ const changedPaths = diff.split('\n').filter(path => path.length > 0);

for (const filePath of changedPaths) {
files.push(yield OwnedFile_1.OwnedFile.FromPath(filePath, engine));
files.push(yield OwnedFile_1.OwnedFile.FromPath(filePath, engine, { countLines: false }));
}

@@ -36,2 +36,11 @@ for (const file of files) {

});
const calcGitCommand = (options) => {
if (options.shaA && options.shaB) {
return `git diff --name-only ${options.shaA} ${options.shaB}`;
}
if (options.shaA) {
return `git ls-tree --full-tree -r --name-only ${options.shaA}`;
}
return 'git diff --name-only --cached HEAD';
};
//# sourceMappingURL=git.js.map

@@ -14,16 +14,7 @@ "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 ignore_1 = __importDefault(require("ignore"));
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const readdir = require('recursive-readdir');
const recursive_readdir_1 = __importDefault(require("recursive-readdir"));
const gitignore_1 = require("./gitignore");
exports.getFilteredFilePaths = (dir, root) => __awaiter(void 0, void 0, void 0, function* () {
const filePaths = yield readdir(dir, ['.git']);
const filePaths = yield recursive_readdir_1.default(dir, ['.git']);
const trimmedFilePaths = filePaths.map((filePath) => {

@@ -34,23 +25,6 @@ return filePath.replace(`${dir}/`, '');

.filter((file) => file.startsWith(root))
.filter(gitIgnoreFilter(dir));
.filter(yield gitignore_1.createGitIgnoreFilter(dir));
filteredFilePaths.sort();
return filteredFilePaths;
});
const gitIgnoreFilter = (dir) => {
const ignored = createIgnore(dir);
return ignored.createFilter();
};
const createIgnore = (dir) => {
const ignored = ignore_1.default();
const gitignore = path.resolve(dir, '.gitignore');
if (fs.existsSync(gitignore)) {
const lines = fs.readFileSync(gitignore).toString().split('\n');
for (const line of lines) {
if (!line || line.startsWith('#'))
continue;
ignored.add(line);
}
}
return ignored;
};
//# sourceMappingURL=dir.js.map

@@ -14,4 +14,6 @@ import { OwnershipEngine } from './OwnershipEngine';

toTsv(): string;
static FromPath: (filePath: string, engine: OwnershipEngine) => Promise<OwnedFile>;
static FromPath: (filePath: string, engine: OwnershipEngine, opts?: {
countLines: boolean;
}) => Promise<OwnedFile>;
}
//# sourceMappingURL=OwnedFile.d.ts.map

@@ -46,6 +46,6 @@ "use strict";

exports.OwnedFile = OwnedFile;
OwnedFile.FromPath = (filePath, engine) => __awaiter(void 0, void 0, void 0, function* () {
OwnedFile.FromPath = (filePath, engine, opts = { countLines: true }) => __awaiter(void 0, void 0, void 0, function* () {
return new OwnedFile({
path: filePath,
lines: yield countLinesInFile(filePath),
lines: opts.countLines ? yield countLinesInFile(filePath) : 0,
owners: engine.calcFileOwnership(filePath),

@@ -52,0 +52,0 @@ });

{
"name": "github-codeowners",
"version": "0.0.4",
"version": "0.1.0",
"description": "Handy tool for working with file ownership using Githubs CODEOWNERS file",

@@ -35,2 +35,3 @@ "main": "dist/cli.js",

"@types/node": "^13.7.6",
"@types/recursive-readdir": "^2.2.0",
"@types/uuid": "^8.0.0",

@@ -37,0 +38,0 @@ "coveralls": "^3.1.0",

@@ -11,8 +11,10 @@ # github-codeowners

* Output who owns a single file
* Output who owns files based on a `git diff`
* Outputs in CSV and JSONL
* 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)
## Installation
Install via npm globally then run
```shell script

@@ -62,3 +64,3 @@ $ npm i -g github-codeowners

Output to in JSONL:
Output in JSONL:
```shell script

@@ -98,3 +100,3 @@ $ github-codeowners audit -o jsonl

$ github-codeowners who <file>
@some/team
<file> @some/team
```

@@ -119,16 +121,14 @@

The stats option here can be super useful to help you understand if other people will have a lot of work in reviewing your PR.
Owners of unstaged changes:
Ownership of all files staged for commit:
```shell script
$ cd <your awesome project>
$ github-codeowners git
```
Diff between a single commit and HEAD:
Ownership of files existing at a specific commit:
```shell script
$ cd <your awesome project>
$ github-codeowners git <commit sha>
```
Diff between two commits:
Ownership of files changed between two commits:
```shell script

@@ -154,3 +154,3 @@ $ github-codeowners git <commit sha> <commit sha>

-o, --output <outputFormat> how to output format eg: simple, jsonl, csv (default: "simple")
-s, --stats output stats (default: false)
-s, --stats output stats, note line counts are not available for this command (default: false)
-h, --help output usage information

@@ -168,8 +168,6 @@ ```

* It is not optimized
* It has 0 test coverage (there will be be bugs)
* It's not tested in the wild (YMMV based on OS and node versions etc)
* The output interface might change
* Some code could be better generalized (command setup, writers)
* Command syntax might change
## Shout outs
Inspired by [codeowners](https://github.com/beaugunderson/codeowners#readme) but implemented in Typescript with extra bells and whistles.

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc