@goodfellow-cms/github 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +16 -2
- package/dist/index.d.ts +121 -0
- package/dist/index.js +926 -0
- package/dist/testing.d.ts +126 -0
- package/dist/testing.js +520 -0
- package/package.json +51 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Goodfellow contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @goodfellow-cms/github
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Edit a Goodfellow site stored on GitHub, straight from the browser: sign-in with an access token, publishing as single commits, conflict checks and deploy status.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { github } from "@goodfellow-cms/github";
|
|
7
|
+
|
|
8
|
+
export default defineConfig({ blocks, backend: github({ repo: "your-name/your-site" }) });
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
[Goodfellow](https://github.com/goodfellow-cms/goodfellow-cms) is a website builder for people who aren't developers, with no server or database: pages are files in your own GitHub or GitLab repository, edited in a visual editor built on [Puck](https://puckeditor.com). To start a new site, run `npm create goodfellow@latest my-site`. See the [documentation](https://goodfellow-cms.github.io/goodfellow-cms/) for everything else.
|
|
12
|
+
|
|
13
|
+
More in the docs: [Hosts and business sites](https://goodfellow-cms.github.io/goodfellow-cms/docs/hosts).
|
|
14
|
+
|
|
15
|
+
## License
|
|
16
|
+
|
|
17
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ConnectDomainOptions, DeployStatus, DnsRecord, FileChange, FileVersion, GitBackend, GitHost, GitUser, HistoryOptions, OwnerAccess, PagesDomains, SetupHost, SiteEditors, SiteUpdates, StorageLike, TokenLink, WriteOptions } from "@goodfellow-cms/core";
|
|
2
|
+
//#region src/api.d.ts
|
|
3
|
+
interface ApiOptions {
|
|
4
|
+
apiUrl: string;
|
|
5
|
+
token: string;
|
|
6
|
+
fetch: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/backend.d.ts
|
|
10
|
+
interface GitHubBackendOptions {
|
|
11
|
+
api: ApiOptions;
|
|
12
|
+
repo: string;
|
|
13
|
+
branch: string;
|
|
14
|
+
user: GitUser;
|
|
15
|
+
onSignOut: () => void;
|
|
16
|
+
/** Where to create the owner token, which can change editors and GitHub Pages settings. */
|
|
17
|
+
ownerTokenLink: TokenLink;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The site's files on GitHub. Reads come from the commit `revision()` last
|
|
21
|
+
* returned; saves are single commits made with GraphQL's `createCommitOnBranch`,
|
|
22
|
+
* which fails if the branch has moved, so nothing is ever overwritten.
|
|
23
|
+
*/
|
|
24
|
+
export declare class GitHubBackend implements GitBackend {
|
|
25
|
+
readonly user: GitUser;
|
|
26
|
+
readonly pages: PagesDomains;
|
|
27
|
+
readonly editors: SiteEditors;
|
|
28
|
+
readonly ownerAccess: OwnerAccess;
|
|
29
|
+
readonly updates: SiteUpdates;
|
|
30
|
+
private readonly api;
|
|
31
|
+
private readonly repo;
|
|
32
|
+
private readonly branch;
|
|
33
|
+
private readonly onSignOut;
|
|
34
|
+
private pinned?;
|
|
35
|
+
private readonly trees;
|
|
36
|
+
private readonly blobs;
|
|
37
|
+
constructor(options: GitHubBackendOptions);
|
|
38
|
+
revision(): Promise<string>;
|
|
39
|
+
/** Path → blob id for every file at a commit. Commits never change, so this is cached. */
|
|
40
|
+
private tree;
|
|
41
|
+
private currentTree;
|
|
42
|
+
read(path: string): Promise<string | undefined>;
|
|
43
|
+
private readFrom;
|
|
44
|
+
readBytes(path: string): Promise<Uint8Array | undefined>;
|
|
45
|
+
list(dir: string): Promise<string[]>;
|
|
46
|
+
write(changes: FileChange[], { message, expectedRevision }: WriteOptions): Promise<{
|
|
47
|
+
revision: string;
|
|
48
|
+
}>;
|
|
49
|
+
history(path: string, { page, perPage }?: HistoryOptions): Promise<FileVersion[]>;
|
|
50
|
+
readAt(path: string, revision: string): Promise<string | undefined>;
|
|
51
|
+
changedPaths(from: string, to: string): Promise<string[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Reads the deployment GitHub Pages or Vercel created for a commit, and for
|
|
54
|
+
* GitHub Actions, the workflow run that builds it: a build that fails never
|
|
55
|
+
* creates a deployment. Before either exists, the site counts as building
|
|
56
|
+
* if it has ever been deployed.
|
|
57
|
+
*/
|
|
58
|
+
deployStatus(revision: string): Promise<DeployStatus>;
|
|
59
|
+
/** The site's deploy workflow run for a commit, or `undefined` if there's none or the token can't see Actions. */
|
|
60
|
+
private workflowRun;
|
|
61
|
+
/** Which step of a failed run failed. */
|
|
62
|
+
private runProblem;
|
|
63
|
+
signOut(): void;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/pages.d.ts
|
|
67
|
+
/** The records GitHub Pages needs: its addresses for an apex domain, or an alias of the owner's github.io. */
|
|
68
|
+
export declare function githubPagesRecords(repo: string, domain: string, { apex, www }: ConnectDomainOptions): DnsRecord[];
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/setup.d.ts
|
|
71
|
+
interface GitHubSetupOptions {
|
|
72
|
+
/** For GitHub Enterprise. Defaults to `https://api.github.com`. */
|
|
73
|
+
apiUrl?: string;
|
|
74
|
+
/** For GitHub Enterprise. Defaults to `https://github.com`. */
|
|
75
|
+
webUrl?: string;
|
|
76
|
+
/** For tests. */
|
|
77
|
+
fetch?: typeof fetch;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Links to GitHub's token pages with what creating a site needs: creating the
|
|
81
|
+
* repository (administration), writing its files and its build setup
|
|
82
|
+
* (contents and workflows), and turning on GitHub Pages (pages).
|
|
83
|
+
*/
|
|
84
|
+
export declare function githubSetupTokenLinks(webUrl?: string): {
|
|
85
|
+
fineGrained: string;
|
|
86
|
+
classic: string;
|
|
87
|
+
};
|
|
88
|
+
/** Signing in to GitHub to create a site's repository, with GitHub Pages if wanted. */
|
|
89
|
+
export declare function githubSetup(options?: GitHubSetupOptions): SetupHost;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/index.d.ts
|
|
92
|
+
export interface GitHubOptions {
|
|
93
|
+
/** The site's repository, as `owner/name`. */
|
|
94
|
+
repo: string;
|
|
95
|
+
/** The branch the live site is built from. Defaults to the repository's default branch. */
|
|
96
|
+
branch?: string;
|
|
97
|
+
/** For GitHub Enterprise. Defaults to `https://api.github.com`. */
|
|
98
|
+
apiUrl?: string;
|
|
99
|
+
/** For GitHub Enterprise. Defaults to `https://github.com`. */
|
|
100
|
+
webUrl?: string;
|
|
101
|
+
/** For tests. */
|
|
102
|
+
fetch?: typeof fetch;
|
|
103
|
+
/** For tests. */
|
|
104
|
+
storage?: {
|
|
105
|
+
local?: StorageLike;
|
|
106
|
+
session?: StorageLike;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Links to GitHub's token page with everything filled in except the
|
|
111
|
+
* repository, which GitHub doesn't let links choose.
|
|
112
|
+
*/
|
|
113
|
+
export declare function githubTokenLinks(repo: string, webUrl?: string): {
|
|
114
|
+
fineGrained: string;
|
|
115
|
+
classic: string;
|
|
116
|
+
owner: string;
|
|
117
|
+
};
|
|
118
|
+
/** Sign-in and storage for a site whose repository is on GitHub. */
|
|
119
|
+
export declare function github(options: GitHubOptions): GitHost;
|
|
120
|
+
//#endregion
|
|
121
|
+
export type { GitHubSetupOptions };
|