Skip to content

Commit a93d935

Browse files
authored
feat(typescript): export types for octoherd function (#38)
* test: export types for octoherd function * feat(typescript): export types for octoherd function
1 parent 0ffdca0 commit a93d935

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

index.d.ts

+22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1+
import { octoherd } from "./index.js";
12
import { components } from "@octokit/openapi-types";
23

34
export { Octokit } from "@octoherd/octokit";
45
export type Repository = components["schemas"]["repository"];
6+
7+
export type OctoherdOptions = {
8+
/** The Octoherd Script function */
9+
octoherdScript: Function;
10+
/** Personal Access Token: Requires the "public_repo" scope for public repositories, "repo" scope for private repositories. */
11+
octoherdToken: string;
12+
/** Array of repository names in the form of "repo-owner/repo-name". To match all repositories for an owner, pass "repo-owner/*" */
13+
octoherdRepos: string[];
14+
/** Cache responses for debugging */
15+
octoherdCache: boolean;
16+
/** Bypass confirmation prompts for mutating requests */
17+
octoherdBypassConfirms: boolean;
18+
19+
/** `octoherdScript` may accept its own options */
20+
[key: string]: unknown;
21+
};
22+
23+
/**
24+
* Find all releases in a GitHub repository or organization after a specified date
25+
*/
26+
export async function octoherd(options: OctoherdOptions): void;

index.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { requestConfirm } from "./lib/octokit-plugin-request-confirm.js";
1313
import { runScriptAgainstRepositories } from "./lib/run-script-against-repositories.js";
1414
import { VERSION } from "./version.js";
1515

16+
export { Octokit } from "@octoherd/octokit";
17+
1618
const levelColor = {
1719
debug: chalk.bgGray.black,
1820
info: chalk.bgGreen.black,
@@ -21,19 +23,12 @@ const levelColor = {
2123
};
2224

2325
/**
24-
* Find all releases in a GitHub repository or organization after a specified date
25-
*
26-
* @param {object} options
27-
* @param {function} options.octoherdScript Path to script to run against a repository
28-
* @param {string[]} options.octoherdRepos Cache responses for debugging
29-
* @param {string} options.octoherdToken Personal Access Token: Requires the "public_repo" scope for public repositories, "repo" scope for private repositories.
30-
* @param {boolean} options.octoherdCache Array of repository names in the form of "repo-owner/repo-name". To match all repositories for an owner, pass "repo-owner/*"
26+
* @param {import(".").OctoherdOptions} options
3127
*/
3228
export async function octoherd(options) {
3329
const {
3430
octoherdToken,
3531
octoherdCache = false,
36-
octoherdDebug,
3732
octoherdScript,
3833
octoherdRepos,
3934
octoherdBypassConfirms,
@@ -80,7 +75,6 @@ export async function octoherd(options) {
8075
...authOptions,
8176
userAgent: ["octoherd-cli", VERSION].join("/"),
8277
octoherd: {
83-
debug: octoherdDebug,
8478
cache: octoherdCache,
8579
bypassConfirms: octoherdBypassConfirms,
8680
onLogMessage(level, message, additionalData) {

tests/smoke.test.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { suite } from "uvu";
2+
import { equal } from "uvu/assert";
3+
4+
import * as CLI from "../index.js";
5+
6+
const smokeTest = suite("smoke");
7+
8+
smokeTest("exports octoherd function", () => {
9+
equal(typeof CLI.octoherd, "function");
10+
});
11+
12+
smokeTest("exports Octokit contructor", () => {
13+
equal(typeof CLI.Octokit, "function");
14+
});
15+
16+
smokeTest.run();

0 commit comments

Comments
 (0)