@goodfellow-cms/gitlab 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 +138 -0
- package/dist/index.js +1026 -0
- package/dist/testing.d.ts +131 -0
- package/dist/testing.js +642 -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/gitlab
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Edit a Goodfellow site stored on GitLab, straight from the browser: sign-in with an access token, publishing as single commits, conflict checks and deploy status.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { gitlab } from "@goodfellow-cms/gitlab";
|
|
7
|
+
|
|
8
|
+
export default defineConfig({ blocks, backend: gitlab({ project: "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,138 @@
|
|
|
1
|
+
import { ConnectDomainOptions, DeployStatus, DnsRecord, FileChange, FileVersion, GitBackend, GitHost, GitUser, HistoryOptions, PagesDomains, SetupHost, SiteEditors, SiteUpdates, StorageLike, WriteOptions } from "@goodfellow-cms/core";
|
|
2
|
+
//#region src/api.d.ts
|
|
3
|
+
interface ApiOptions {
|
|
4
|
+
/** The API root, such as `https://gitlab.com/api/v4`. */
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
/** Returns a current access token, refreshing it if needed. */
|
|
7
|
+
token: (options?: {
|
|
8
|
+
refresh?: boolean;
|
|
9
|
+
}) => Promise<string>;
|
|
10
|
+
/** Whether the token can be refreshed after a 401. */
|
|
11
|
+
canRefresh: boolean;
|
|
12
|
+
fetch: typeof fetch;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/backend.d.ts
|
|
16
|
+
interface GitLabBackendOptions {
|
|
17
|
+
api: ApiOptions;
|
|
18
|
+
project: string;
|
|
19
|
+
branch: string;
|
|
20
|
+
user: GitUser;
|
|
21
|
+
onSignOut: () => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The site's files on GitLab. Reads come from the commit `revision()` last
|
|
25
|
+
* returned. Saves are single commits; each changed file carries the commit it
|
|
26
|
+
* was last changed in, so GitLab refuses to overwrite anyone else's edits.
|
|
27
|
+
*/
|
|
28
|
+
export declare class GitLabBackend implements GitBackend {
|
|
29
|
+
readonly user: GitUser;
|
|
30
|
+
readonly pages: PagesDomains;
|
|
31
|
+
readonly editors: SiteEditors;
|
|
32
|
+
readonly updates: SiteUpdates;
|
|
33
|
+
private readonly api;
|
|
34
|
+
private readonly project;
|
|
35
|
+
private readonly branch;
|
|
36
|
+
private readonly onSignOut;
|
|
37
|
+
private pinned?;
|
|
38
|
+
private readonly trees;
|
|
39
|
+
private readonly blobs;
|
|
40
|
+
constructor(options: GitLabBackendOptions);
|
|
41
|
+
private repo;
|
|
42
|
+
revision(): Promise<string>;
|
|
43
|
+
/** Every file in one folder at a commit, page by page. */
|
|
44
|
+
private listFolder;
|
|
45
|
+
/** Path → blob id for the editable files at a commit. Commits never change, so this is cached. */
|
|
46
|
+
private tree;
|
|
47
|
+
private currentTree;
|
|
48
|
+
read(path: string): Promise<string | undefined>;
|
|
49
|
+
readBytes(path: string): Promise<Uint8Array | undefined>;
|
|
50
|
+
list(dir: string): Promise<string[]>;
|
|
51
|
+
private lastCommitFor;
|
|
52
|
+
write(changes: FileChange[], { message, expectedRevision }: WriteOptions): Promise<{
|
|
53
|
+
revision: string;
|
|
54
|
+
}>;
|
|
55
|
+
history(path: string, { page, perPage }?: HistoryOptions): Promise<FileVersion[]>;
|
|
56
|
+
readAt(path: string, revision: string): Promise<string | undefined>;
|
|
57
|
+
changedPaths(from: string, to: string): Promise<string[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Reads the commit's pipeline and external statuses (GitLab Pages jobs, or
|
|
60
|
+
* Vercel). Before any exist, the site counts as building if it has pipelines.
|
|
61
|
+
*/
|
|
62
|
+
deployStatus(revision: string): Promise<DeployStatus>;
|
|
63
|
+
/** Why a commit's pipeline failed: the failed job's reason, and its log for which command failed and why. */
|
|
64
|
+
private jobProblem;
|
|
65
|
+
signOut(): void;
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/oauth.d.ts
|
|
69
|
+
/** The admin panel's address, with a trailing slash so it always matches the redirect URI registered with GitLab. */
|
|
70
|
+
export declare function redirectUri(href: string): string;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/pages.d.ts
|
|
73
|
+
/**
|
|
74
|
+
* The records GitLab Pages needs: its address for an apex domain, or an alias
|
|
75
|
+
* of the namespace's gitlab.io otherwise, and a TXT record per domain that
|
|
76
|
+
* proves it's the owner's, with the codes GitLab gave.
|
|
77
|
+
*/
|
|
78
|
+
export declare function gitlabPagesRecords(project: string, domain: string, options: ConnectDomainOptions, codes: Record<string, string>): DnsRecord[];
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/setup.d.ts
|
|
81
|
+
interface GitLabSetupOptions {
|
|
82
|
+
/** For self-managed GitLab. Defaults to `https://gitlab.com`. */
|
|
83
|
+
url?: string;
|
|
84
|
+
/**
|
|
85
|
+
* The Application ID of an OAuth application for the setup page (not
|
|
86
|
+
* confidential, scope `api`, redirect URI the page's address). Enables
|
|
87
|
+
* "Sign in with GitLab". Without it, people sign in with a token.
|
|
88
|
+
*/
|
|
89
|
+
clientId?: string;
|
|
90
|
+
/** For tests. */
|
|
91
|
+
fetch?: typeof fetch;
|
|
92
|
+
/** For tests. */
|
|
93
|
+
storage?: {
|
|
94
|
+
local?: StorageLike;
|
|
95
|
+
session?: StorageLike;
|
|
96
|
+
};
|
|
97
|
+
/** For tests. */
|
|
98
|
+
location?: BrowserLocation;
|
|
99
|
+
}
|
|
100
|
+
/** Signing in to GitLab to create a site's project, with GitLab Pages if wanted. */
|
|
101
|
+
export declare function gitlabSetup(options?: GitLabSetupOptions): SetupHost;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/index.d.ts
|
|
104
|
+
/** The page's address and how to change it. Replaceable in tests. */
|
|
105
|
+
export interface BrowserLocation {
|
|
106
|
+
href(): string;
|
|
107
|
+
/** Navigates away, for example to GitLab's sign-in page. */
|
|
108
|
+
assign(url: string): void;
|
|
109
|
+
/** Changes the address without reloading, for example to remove `?code=…` after signing in. */
|
|
110
|
+
replace(url: string): void;
|
|
111
|
+
}
|
|
112
|
+
export interface GitLabOptions {
|
|
113
|
+
/** The site's project path, such as `group/site` or `group/subgroup/site`. */
|
|
114
|
+
project: string;
|
|
115
|
+
/** The branch the live site is built from. Defaults to the project's default branch. */
|
|
116
|
+
branch?: string;
|
|
117
|
+
/** For self-managed GitLab. Defaults to `https://gitlab.com`. */
|
|
118
|
+
url?: string;
|
|
119
|
+
/**
|
|
120
|
+
* The Application ID of an OAuth application registered for the site (not
|
|
121
|
+
* confidential, scope `api`, redirect URI `https://your-site/admin/`). Enables
|
|
122
|
+
* one-click "Sign in with GitLab". Without it, people sign in with a token.
|
|
123
|
+
*/
|
|
124
|
+
clientId?: string;
|
|
125
|
+
/** For tests. */
|
|
126
|
+
fetch?: typeof fetch;
|
|
127
|
+
/** For tests. */
|
|
128
|
+
storage?: {
|
|
129
|
+
local?: StorageLike;
|
|
130
|
+
session?: StorageLike;
|
|
131
|
+
};
|
|
132
|
+
/** For tests. */
|
|
133
|
+
location?: BrowserLocation;
|
|
134
|
+
}
|
|
135
|
+
/** Sign-in and storage for a site whose repository is on GitLab. */
|
|
136
|
+
export declare function gitlab(options: GitLabOptions): GitHost;
|
|
137
|
+
//#endregion
|
|
138
|
+
export type { GitLabSetupOptions };
|