@goodfellow-cms/github 0.2.0 → 0.4.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/dist/testing.d.ts CHANGED
@@ -4,6 +4,8 @@ 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;
9
11
  /** Whether the token may write `.github/workflows/`. Defaults to true. */
@@ -18,6 +20,8 @@ export interface FakeGitHubUser {
18
20
  actions?: boolean;
19
21
  /** Whether the token may run workflows, as owner tokens can. Defaults to the `administration` setting. */
20
22
  actionsWrite?: boolean;
23
+ /** Whether the token may set Actions secrets and add deploy keys. Defaults to true. */
24
+ secrets?: boolean;
21
25
  }
22
26
  /** A GitHub Actions workflow run, with its jobs and their steps. */
23
27
  export interface FakeRun {
@@ -30,6 +34,8 @@ export interface FakeRun {
30
34
  createdAt?: string;
31
35
  status: "queued" | "in_progress" | "completed";
32
36
  conclusion: "success" | "failure" | "startup_failure" | "cancelled" | null;
37
+ /** The workflow's file, `.github/workflows/deploy.yml` by default. */
38
+ path?: string;
33
39
  jobs: Array<{
34
40
  name: string;
35
41
  conclusion: string | null;
@@ -80,9 +86,43 @@ export interface FakeGitHubOptions {
80
86
  takenDomains?: string[];
81
87
  /** Other GitHub accounts that exist, which can be invited. Every token's user exists too. */
82
88
  accounts?: string[];
89
+ /** GitHub Apps, which the sign-in worker signs people in with. */
90
+ apps?: FakeGitHubApp[];
91
+ }
92
+ /** A GitHub App, as the sign-in worker uses one: its JWTs, installations, OAuth sign-in and tokens. */
93
+ export interface FakeGitHubApp {
94
+ id: string;
95
+ slug: string;
96
+ clientId: string;
97
+ clientSecret: string;
98
+ /** The app's public key, which its JWTs are checked against. Without it, any JWT naming the app is accepted. */
99
+ publicKey?: CryptoKey;
100
+ /** The most its tokens may be given, as GitHub names permissions. */
101
+ permissions: Record<string, "read" | "write">;
102
+ installations: FakeInstallation[];
103
+ }
104
+ /** An app installed on an account, for some or all of its repositories. */
105
+ export interface FakeInstallation {
106
+ id: number;
107
+ /** The account it's installed on. */
108
+ account: string;
109
+ accountType?: "User" | "Organization";
110
+ /** The repositories it can use, as `owner/name`, or `all` of the account's. */
111
+ repositories: string[] | "all";
112
+ }
113
+ /** A token an app's sign-in made: a person's own, or an installation's for some repositories. */
114
+ export interface FakeIssuedToken {
115
+ token: string;
116
+ kind: "user" | "installation";
117
+ app: string;
118
+ login?: string;
119
+ repositories?: string[];
120
+ permissions: Record<string, string>;
121
+ revoked?: boolean;
83
122
  }
84
123
  /** A repository created through the fake's API, as the setup page creates them. */
85
124
  export interface FakeCreatedRepo {
125
+ id: number;
86
126
  fullName: string;
87
127
  private: boolean;
88
128
  description?: string;
@@ -91,6 +131,18 @@ export interface FakeCreatedRepo {
91
131
  build_type: string;
92
132
  };
93
133
  rulesets: unknown[];
134
+ /** Deploy keys added to it, by their public key. */
135
+ deployKeys: Array<{
136
+ title: string;
137
+ key: string;
138
+ read_only: boolean;
139
+ }>;
140
+ /** Its Actions secrets, opened. */
141
+ secrets: Map<string, string>;
142
+ /** The key pair GitHub seals secrets with. */
143
+ secretKey?: CryptoKeyPair;
144
+ /** People's permission on it, by login, as `collaborators/{login}/permission` says; others have none. */
145
+ collaborators?: Map<string, "admin" | "write" | "read">;
94
146
  }
95
147
  interface Deployment {
96
148
  id: number;
@@ -100,8 +152,27 @@ interface Deployment {
100
152
  }
101
153
  export declare function fakeGitHub(options: FakeGitHubOptions): {
102
154
  repo: FakeRepo;
103
- /** Repositories created through the API, by `owner/name`. */
155
+ /** How many GraphQL requests read files, as `readFiles()` makes. */
156
+ readonly graphqlReads: number;
157
+ /** Tokens apps' sign-ins made, in order. */
158
+ issued: FakeIssuedToken[];
159
+ /** Who commits made through the REST API name as their author, by commit. */
160
+ commitAuthors: Map<string, {
161
+ name?: string;
162
+ email?: string;
163
+ }>;
164
+ authorize: (login: string, clientId: string) => string;
165
+ install: (slug: string, login: string, repositories: string[], account?: string) => {
166
+ code: string;
167
+ installation: number;
168
+ };
169
+ /** Repositories created through the API, or added with `addRepo()`, by `owner/name`. */
104
170
  created: Map<string, FakeCreatedRepo>;
171
+ addRepo: (fullName: string, repoOptions?: {
172
+ files?: Record<string, string>;
173
+ private?: boolean;
174
+ collaborators?: Record<string, "admin" | "write" | "read">;
175
+ }) => FakeCreatedRepo;
105
176
  /** The site's GitHub Pages settings, which tests can change, such as to issue the certificate. */
106
177
  pages: {
107
178
  current?: FakePages;
@@ -117,7 +188,7 @@ export declare function fakeGitHub(options: FakeGitHubOptions): {
117
188
  /** Every request received, for checking what the backend sent. */
118
189
  requests: Request[];
119
190
  /** Simulates someone else publishing. */
120
- commit: (changes: FileChange[], message: string, expectedHead?: string, author?: string) => string;
191
+ commit: (changes: FileChange[], message: string, expectedHead?: string, author?: string, branch?: string) => string;
121
192
  handle: (request: Request) => Promise<Response>;
122
193
  /** A `fetch` that answers from the fake instead of the network. */
123
194
  fetch: typeof fetch;