@goodfellow-cms/github 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +114 -6
- package/dist/index.js +1352 -47
- package/dist/testing.d.ts +133 -1
- package/dist/testing.js +798 -15
- package/package.json +5 -5
package/dist/testing.d.ts
CHANGED
|
@@ -4,8 +4,56 @@ import { FakeRepo } from "@goodfellow-cms/core/testing";
|
|
|
4
4
|
export interface FakeGitHubUser {
|
|
5
5
|
login: string;
|
|
6
6
|
name?: string;
|
|
7
|
+
/** GitHub's number for the account. Defaults to one worked out from the login. */
|
|
8
|
+
id?: number;
|
|
7
9
|
/** Whether the user may publish. Defaults to true. */
|
|
8
10
|
push?: boolean;
|
|
11
|
+
/** Whether the token may write `.github/workflows/`. Defaults to true. */
|
|
12
|
+
workflow?: boolean;
|
|
13
|
+
/** Whether the token may change GitHub Pages settings. Defaults to true. */
|
|
14
|
+
pages?: boolean;
|
|
15
|
+
/** Whether the user is an owner (admin) of the site's repository. Defaults to false. */
|
|
16
|
+
admin?: boolean;
|
|
17
|
+
/** Whether the token has GitHub's Administration permission, which changing collaborators needs. Defaults to false. */
|
|
18
|
+
administration?: boolean;
|
|
19
|
+
/** Whether the token may read GitHub Actions. Defaults to true. */
|
|
20
|
+
actions?: boolean;
|
|
21
|
+
/** Whether the token may run workflows, as owner tokens can. Defaults to the `administration` setting. */
|
|
22
|
+
actionsWrite?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** A GitHub Actions workflow run, with its jobs and their steps. */
|
|
25
|
+
export interface FakeRun {
|
|
26
|
+
id: number;
|
|
27
|
+
sha: string;
|
|
28
|
+
/** What started it: `push` (the default), `schedule` or `workflow_dispatch`. */
|
|
29
|
+
event?: string;
|
|
30
|
+
/** For `workflow_dispatch`, the inputs it was given. */
|
|
31
|
+
inputs?: Record<string, string>;
|
|
32
|
+
createdAt?: string;
|
|
33
|
+
status: "queued" | "in_progress" | "completed";
|
|
34
|
+
conclusion: "success" | "failure" | "startup_failure" | "cancelled" | null;
|
|
35
|
+
jobs: Array<{
|
|
36
|
+
name: string;
|
|
37
|
+
conclusion: string | null;
|
|
38
|
+
steps: Array<{
|
|
39
|
+
name: string;
|
|
40
|
+
conclusion: string | null;
|
|
41
|
+
}>;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
/** A repository invitation that hasn't been accepted yet. */
|
|
45
|
+
export interface FakeInvitation {
|
|
46
|
+
id: number;
|
|
47
|
+
login: string;
|
|
48
|
+
permission: "admin" | "write";
|
|
49
|
+
}
|
|
50
|
+
/** The site's GitHub Pages settings, as `GET /repos/{repo}/pages` reports them. */
|
|
51
|
+
export interface FakePages {
|
|
52
|
+
html_url: string;
|
|
53
|
+
cname: string | null;
|
|
54
|
+
https_enforced: boolean;
|
|
55
|
+
/** The certificate's state, such as `new` while it's being issued and `approved` once it's ready. */
|
|
56
|
+
certificate?: string;
|
|
9
57
|
}
|
|
10
58
|
export interface FakeDeploymentStatus {
|
|
11
59
|
state: "queued" | "in_progress" | "success" | "failure" | "error" | "inactive";
|
|
@@ -22,6 +70,63 @@ export interface FakeGitHubOptions {
|
|
|
22
70
|
* reports success after being checked this many times. Off by default.
|
|
23
71
|
*/
|
|
24
72
|
deployAfterChecks?: number;
|
|
73
|
+
/** Organizations the users belong to, which new repositories can be created in. */
|
|
74
|
+
orgs?: string[];
|
|
75
|
+
/** The default branch of repositories created through the API, as an account's settings choose. Defaults to `main`. */
|
|
76
|
+
newRepoBranch?: string;
|
|
77
|
+
/** Whether private repositories can have GitHub Pages and rules, as on paid plans. Off by default, as on the free plan. */
|
|
78
|
+
paidPlan?: boolean;
|
|
79
|
+
/** Publishes the site with GitHub Pages, at `https://<owner>.github.io/<name>/`. Off by default. */
|
|
80
|
+
pages?: boolean;
|
|
81
|
+
/** Domains another GitHub Pages site already uses. */
|
|
82
|
+
takenDomains?: string[];
|
|
83
|
+
/** Other GitHub accounts that exist, which can be invited. Every token's user exists too. */
|
|
84
|
+
accounts?: string[];
|
|
85
|
+
/** GitHub Apps, which the sign-in worker signs people in with. */
|
|
86
|
+
apps?: FakeGitHubApp[];
|
|
87
|
+
}
|
|
88
|
+
/** A GitHub App, as the sign-in worker uses one: its JWTs, installations, OAuth sign-in and tokens. */
|
|
89
|
+
export interface FakeGitHubApp {
|
|
90
|
+
id: string;
|
|
91
|
+
slug: string;
|
|
92
|
+
clientId: string;
|
|
93
|
+
clientSecret: string;
|
|
94
|
+
/** The app's public key, which its JWTs are checked against. Without it, any JWT naming the app is accepted. */
|
|
95
|
+
publicKey?: CryptoKey;
|
|
96
|
+
/** The most its tokens may be given, as GitHub names permissions. */
|
|
97
|
+
permissions: Record<string, "read" | "write">;
|
|
98
|
+
installations: FakeInstallation[];
|
|
99
|
+
}
|
|
100
|
+
/** An app installed on an account, for some or all of its repositories. */
|
|
101
|
+
export interface FakeInstallation {
|
|
102
|
+
id: number;
|
|
103
|
+
/** The account it's installed on. */
|
|
104
|
+
account: string;
|
|
105
|
+
accountType?: "User" | "Organization";
|
|
106
|
+
/** The repositories it can use, as `owner/name`, or `all` of the account's. */
|
|
107
|
+
repositories: string[] | "all";
|
|
108
|
+
}
|
|
109
|
+
/** A token an app's sign-in made: a person's own, or an installation's for some repositories. */
|
|
110
|
+
export interface FakeIssuedToken {
|
|
111
|
+
token: string;
|
|
112
|
+
kind: "user" | "installation";
|
|
113
|
+
app: string;
|
|
114
|
+
login?: string;
|
|
115
|
+
repositories?: string[];
|
|
116
|
+
permissions: Record<string, string>;
|
|
117
|
+
revoked?: boolean;
|
|
118
|
+
}
|
|
119
|
+
/** A repository created through the fake's API, as the setup page creates them. */
|
|
120
|
+
export interface FakeCreatedRepo {
|
|
121
|
+
id: number;
|
|
122
|
+
fullName: string;
|
|
123
|
+
private: boolean;
|
|
124
|
+
description?: string;
|
|
125
|
+
repo: FakeRepo;
|
|
126
|
+
pages?: {
|
|
127
|
+
build_type: string;
|
|
128
|
+
};
|
|
129
|
+
rulesets: unknown[];
|
|
25
130
|
}
|
|
26
131
|
interface Deployment {
|
|
27
132
|
id: number;
|
|
@@ -31,11 +136,38 @@ interface Deployment {
|
|
|
31
136
|
}
|
|
32
137
|
export declare function fakeGitHub(options: FakeGitHubOptions): {
|
|
33
138
|
repo: FakeRepo;
|
|
139
|
+
/** How many GraphQL requests read files, as `readFiles()` makes. */
|
|
140
|
+
readonly graphqlReads: number;
|
|
141
|
+
/** Tokens apps' sign-ins made, in order. */
|
|
142
|
+
issued: FakeIssuedToken[];
|
|
143
|
+
/** Who commits made through the REST API name as their author, by commit. */
|
|
144
|
+
commitAuthors: Map<string, {
|
|
145
|
+
name?: string;
|
|
146
|
+
email?: string;
|
|
147
|
+
}>;
|
|
148
|
+
authorize: (login: string, clientId: string) => string;
|
|
149
|
+
install: (slug: string, login: string, repositories: string[], account?: string) => {
|
|
150
|
+
code: string;
|
|
151
|
+
installation: number;
|
|
152
|
+
};
|
|
153
|
+
/** Repositories created through the API, by `owner/name`. */
|
|
154
|
+
created: Map<string, FakeCreatedRepo>;
|
|
155
|
+
/** The site's GitHub Pages settings, which tests can change, such as to issue the certificate. */
|
|
156
|
+
pages: {
|
|
157
|
+
current?: FakePages;
|
|
158
|
+
};
|
|
159
|
+
/** The repository's collaborators, by login, and invitations waiting to be accepted. */
|
|
160
|
+
collaborators: Map<string, "admin" | "push" | "read">;
|
|
161
|
+
invitations: FakeInvitation[];
|
|
162
|
+
accept: (login: string) => void;
|
|
34
163
|
deployments: Deployment[];
|
|
164
|
+
/** GitHub Actions workflow runs, which tests add with `failBuild()`. */
|
|
165
|
+
runs: FakeRun[];
|
|
166
|
+
failBuild: (sha: string, step?: string, job?: string) => FakeRun;
|
|
35
167
|
/** Every request received, for checking what the backend sent. */
|
|
36
168
|
requests: Request[];
|
|
37
169
|
/** Simulates someone else publishing. */
|
|
38
|
-
commit: (changes: FileChange[], message: string, expectedHead?: string) => string;
|
|
170
|
+
commit: (changes: FileChange[], message: string, expectedHead?: string, author?: string, branch?: string) => string;
|
|
39
171
|
handle: (request: Request) => Promise<Response>;
|
|
40
172
|
/** A `fetch` that answers from the fake instead of the network. */
|
|
41
173
|
fetch: typeof fetch;
|