Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support enterprise GitHub #27

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2.2.4
- uses: pnpm/action-setup@v4
with:
version: 6.12.0

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ The supported options are:
- `repo`: Your "org/repo" on GitHub
(automatically inferred from the `package.json` file)

- `github`: the github domain, default: github.com

- `nextVersion`: Title for unreleased commits
(e.g. `Unreleased`)

Expand Down
4 changes: 3 additions & 1 deletion src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getRootPath } from "./git";

export interface Configuration {
repo: string;
github?: string;
rootPath: string;
labels: { [key: string]: string };
ignoreCommitters: string[];
Expand Down Expand Up @@ -80,7 +81,7 @@ export function fromPath(rootPath: string, options: ConfigLoaderOptions = {}): C
}

// Step 2: fill partial config with defaults
let { repo, nextVersion, labels, cacheDir, ignoreCommitters, wildcardLabel } = config;
let { repo, nextVersion, labels, cacheDir, ignoreCommitters, wildcardLabel, github } = config;

const packages = getPackages(rootPath);

Expand Down Expand Up @@ -138,6 +139,7 @@ export function fromPath(rootPath: string, options: ConfigLoaderOptions = {}): C
cacheDir,
wildcardLabel,
packages,
github,
};
}

Expand Down
9 changes: 6 additions & 3 deletions src/github-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,33 @@ export interface Options {
repo: string;
rootPath: string;
cacheDir?: string;
github?: string;
}

export default class GithubAPI {
private cacheDir: string | undefined;
private auth: string;
private github: string;

constructor(config: Options) {
this.cacheDir = config.cacheDir && path.join(config.rootPath, config.cacheDir, "github");
this.github = config.github || "github.com";
this.auth = this.getAuthToken();
if (!this.auth) {
throw new ConfigurationError("Must provide GITHUB_AUTH");
}
}

public getBaseIssueUrl(repo: string): string {
return `https://github.com/${repo}/issues/`;
return `https://${this.github}/${repo}/issues/`;
}

public async getIssueData(repo: string, issue: string): Promise<GitHubIssueResponse> {
return this._fetch(`https://api.github.com/repos/${repo}/issues/${issue}`);
return this._fetch(`https://api.${this.github}/repos/${repo}/issues/${issue}`);
}

public async getUserData(login: string): Promise<GitHubUserResponse> {
return this._fetch(`https://api.github.com/users/${login}`);
return this._fetch(`https://api.${this.github}/users/${login}`);
}

private async _fetch(url: string): Promise<any> {
Expand Down
Loading