Skip to content

Commit

Permalink
Use extract / review commands
Browse files Browse the repository at this point in the history
  • Loading branch information
artfuldev committed Sep 10, 2024
1 parent 92b5af8 commit 9b8a02f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 9 deletions.
19 changes: 14 additions & 5 deletions bugs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ bun-ny tool to catch bugs, hence the name (Bugs Bunny, anyone?).

### Installation

You should be able to install `bugs` using `npm`, or related
package managers.
You need [bun](https://bun.sh) to run `bugs` at this time. Clone this repo, and
then run at repo root:

```sh
npm install -g bugs
cd bugs
bun link
bun link @artfuldev/bugs
```

### Usage
Expand All @@ -20,14 +22,21 @@ We can use bugs in 2 ways:

#### To collect suggestions for tests based on code

We use `bugs extract` which reads a `git diff` from `stdin` and outputs
extracted code and tests related to it via `stdout`.

```sh
bugs suggest -c code
git diff main..pr-71 | bugs extract
```

#### To review existing tests for a piece of code

We use `bugs review` with a diff directly via `stdin` and outputs recommendations
via `stdout`.

```sh
bugs review -c code - tests
git diff main..pr-71 | bugs review
git diff main..pr-71 | bugs extract | bugs review
```

### Building
Expand Down
Binary file modified bugs/bun.lockb
Binary file not shown.
14 changes: 11 additions & 3 deletions bugs/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
{
"name": "bugs",
"name": "@artfuldev/bugs",
"version": "0.0.5-0",
"module": "src/index.ts",
"type": "module",
"bin": {
"bugs": "src/index.ts"
},
"devDependencies": {
"@types/bun": "latest"
"@types/bun": "latest",
"@types/yargs": "^17.0.33"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"yargs": "^17.7.2"
}
}
}
34 changes: 33 additions & 1 deletion bugs/src/index.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
console.log("Hello via Bun!");
#! /usr/bin/env bun
import yargs from "yargs";
import { hideBin } from "yargs/helpers";

// Fix process name in commands
process.argv = process.argv.map((x, i) => (i === 0 ? "bugs" : x));

yargs(hideBin(process.argv))
.option("verbose", {
alias: "v",
type: "boolean",
description: "Run with verbose logging",
})
.command(
"extract",
"extract code and relevant tests from a git diff",
() => {},
(args) => {
if (args.verbose) console.log("diff provided:", args.diff);
console.log("Nothing extracted for now.");
}
)
.command(
"review",
"review relevant tests based on the code",
() => {},
(args) => {
console.log("No suggestions at the moment");
}
)
.strict()
.demandCommand(1)
.parse();

0 comments on commit 9b8a02f

Please sign in to comment.