Skip to content

Commit 6677f60

Browse files
committed
feat(publish): add cloudflare pages target
1 parent c99ac47 commit 6677f60

12 files changed

Lines changed: 563 additions & 14 deletions

File tree

‎src/command/publish/account.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ export async function resolveAccount(
4949
let token: AccountToken | undefined;
5050

5151
// build list of account options
52-
let accounts = (await provider.accountTokens()).filter((account) => {
53-
if (account.server && target?.url) {
54-
return target.url.startsWith(account.server);
55-
} else {
56-
return true;
57-
}
58-
});
52+
let accounts = await provider.accountTokens();
53+
if (provider.filterAccountsByServer !== false) {
54+
accounts = accounts.filter((account) => {
55+
if (account.server && target?.url) {
56+
return target.url.startsWith(account.server);
57+
} else {
58+
return true;
59+
}
60+
});
61+
}
5962

6063
// if we aren't prompting then we need to have one at the ready
6164
if (prompt === "never") {

‎src/command/publish/cmd.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const publishCommand =
5151
" - GitHub Pages (gh-pages)\n" +
5252
" - Posit Connect (connect)\n" +
5353
" - Netlify (netlify)\n" +
54+
" - Cloudflare Pages (cloudflare-pages)\n" +
5455
" - Confluence (confluence)\n" +
5556
" - Hugging Face Spaces (huggingface)\n\n" +
5657
"Accounts are configured interactively during publishing.\n" +
@@ -97,6 +98,10 @@ export const publishCommand =
9798
"Publish project to Netlify",
9899
"quarto publish netlify",
99100
)
101+
.example(
102+
"Publish project to Cloudflare Pages",
103+
"quarto publish cloudflare-pages",
104+
)
100105
.example(
101106
"Publish with explicit target",
102107
"quarto publish netlify --id DA36416-F950-4647-815C-01A24233E294",

‎src/publish/README.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
The `quarto publish` command enables you to easily publish websites and documents to a variety of services, including [Netlify](https://www.netlify.com/), [GitHub Pages](https://pages.github.com/) and [Posit Connect](https://posit.co/products/enterprise/connect/) (more services will be added over time).
5+
The `quarto publish` command enables you to easily publish websites and documents to a variety of services, including [Netlify](https://www.netlify.com/), [GitHub Pages](https://pages.github.com/), [Cloudflare Pages](https://pages.cloudflare.com/) and [Posit Connect](https://posit.co/products/enterprise/connect/) (more services will be added over time).
66

77
To publish a website or book, just execute `quarto publish` from within the project directory:
88

@@ -46,6 +46,7 @@ As an alternative to providing account credentials interactively, you case use t
4646
| Service | Variables |
4747
| -------------- | -------------------------------------- |
4848
| Netlify | `NETLIFY_AUTH_TOKEN` |
49+
| Cloudflare Pages | `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` |
4950
| Postit Connect | `CONNECT_SERVER` and `CONNECT_API_KEY` |
5051

5152
Using an environment variable combined with a `_publish.yml` file that points to the requisite publishing destination is enough to enable the following command to perform a headless publish on CI:
@@ -56,18 +57,22 @@ quarto publish
5657

5758
GitHub Pages publishing requires no special environment variables (as it use the version of git available on your system or on the CI server).
5859

60+
Cloudflare Pages publishing uses the Wrangler CLI. Install Wrangler and provide a Cloudflare account ID and API token via environment variables or command line options.
61+
5962
### Command Line
6063

6164
As an alternative to using a `_publish.yml` file, you can also specify your publish destination explicilty on the command line using a provider name (e.g. `netlify` or `connect`) along with the `--id` option. For example:
6265

6366
```bash
6467
quarto publish netlify --id DDA36416-F950-4647-815C-01A24233E294
68+
quarto publish cloudflare-pages --id my-quarto-site
6569
```
6670

6771
If your credentials are not stored in an environment variable as described above, you can optionally provide them the command line. For example:
6872

6973
```bash
7074
quarto publish netlify --id DDA36416-F950-4647-815C-01A24233E294 --token 7C0947A852D8
75+
quarto publish cloudflare-pages --id my-quarto-site --server 0123456789abcdef --token CF_API_TOKEN
7176
```
7277

7378
When publishing to Posit Connect you should make sure that the server, token, and id are all available either via environment variables or the command line. For example:

0 commit comments

Comments
 (0)