octoherd-script-validate-pr
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "octoherd-script-validate-pr", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "exports": "./script.js", |
@@ -5,3 +5,3 @@ # octoherd-script-valid-pr | ||
[](https://www.npmjs.com/package/) | ||
[](https://www.npmjs.com/package/octoherd-script-validate-pr) | ||
[](https://github.com/bdougie/octoherd-script-valid-pr/actions?query=workflow%3ATest+branch%3Amain) | ||
@@ -14,3 +14,3 @@ | ||
```js | ||
npx; | ||
npx octoherd-script-validate-pr; | ||
``` | ||
@@ -21,5 +21,5 @@ | ||
```js | ||
npx \ | ||
npx octoherd-script-good-pr \ | ||
-T ghp_0123456789abcdefghjklmnopqrstuvwxyzA \ | ||
-R "bdougie/*" | ||
-R "open-sauced/*" | ||
``` | ||
@@ -34,3 +34,6 @@ | ||
| `--octoherd-bypass-confirms` | boolean | Bypass prompts to confirm mutating requests | | ||
| `--label` | string | Label to apply to issues/pull-requests (default: `needs info`) | | ||
| `--text` | string | Forbidden text (default: `TODO`) to mark issues/pull-requests with label | | ||
## Contributing | ||
@@ -37,0 +40,0 @@ |
@@ -8,7 +8,10 @@ // @ts-check | ||
* @param {import('@octoherd/cli').Repository} repository | ||
* @param { {label?: string, text?: string} } options Custom user options passed to the CLI | ||
*/ | ||
export async function script(octokit, repository) { | ||
export async function script(octokit, repository, options) { | ||
const [repoOwner, repoName] = repository.full_name.split("/"); | ||
const label = options.label || "needs info"; | ||
const forbiddenText = options.text || "TODO"; | ||
const issues = await octokit.request('GET /repos/{owner}/{repo}/issues', { | ||
const issues = await octokit.paginate('GET /repos/{owner}/{repo}/issues', { | ||
owner: repoOwner, | ||
@@ -19,7 +22,6 @@ repo: repoName, | ||
try { | ||
for (let i = 0; i < issues.data.length; i++) { | ||
const {body} = issues.data[0]; | ||
for (let i = 0; i < issues.length; i++) { | ||
const {body} = issues[0]; | ||
// TODO: Pass this in as a argument | ||
const todoExists = body.includes("TODO"); | ||
const todoExists = body.includes(forbiddenText); | ||
@@ -31,4 +33,4 @@ if (todoExists) { | ||
repo: repoName, | ||
issue_number: issues.data[i].number, | ||
labels: ["needs info"] // TODO: make this label an argument | ||
issue_number: issues[i].number, | ||
labels: [label] | ||
}) | ||
@@ -35,0 +37,0 @@ } |
13788
37
46