@atomist/automation-client
Version:
Atomist API for software low-level client
51 lines (44 loc) • 1.33 kB
text/typescript
import {
MappedParameter,
MappedParameters,
Parameters,
Secret,
Secrets,
} from "../../../decorators";
import { GitHubRepoRef } from "../GitHubRepoRef";
import { ProjectOperationCredentials } from "../ProjectOperationCredentials";
import { TargetsParams } from "./TargetsParams";
/**
* Base parameters for working with GitHub repo(s).
* Allows use of regex.
*/
export abstract class GitHubTargetsParams extends TargetsParams {
public apiUrl: string;
get credentials(): ProjectOperationCredentials {
if (!!this.githubToken) {
return { token: this.githubToken };
} else {
return undefined;
}
}
/**
* Return a single RepoRef or undefined if we're not identifying a single repo
* @return {RepoRef}
*/
get repoRef(): GitHubRepoRef {
if (!this.owner || !this.repo || this.usesRegex) {
return undefined;
}
return GitHubRepoRef.from({
owner: this.owner,
repo: this.repo,
sha: this.sha,
branch: this.branch,
rawApiBase: this.apiUrl,
});
}
private readonly githubToken: string;
}