Skip to content

Commit fd87415

Browse files
committed
Publish Spacefast WordPress plugin
0 parents  commit fd87415

17 files changed

Lines changed: 2266 additions & 0 deletions

‎.github/workflows/ci.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Install runtime dependencies
18+
run: sudo apt-get update && sudo apt-get install --yes php-cli zip unzip
19+
- name: Test
20+
run: ./bin/test.sh

‎.github/workflows/release.yml‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Install runtime dependencies
17+
run: sudo apt-get update && sudo apt-get install --yes php-cli zip unzip
18+
- name: Test and package
19+
run: ./bin/test.sh
20+
- name: Publish release
21+
env:
22+
GH_TOKEN: ${{ github.token }}
23+
run: gh release create "$GITHUB_REF_NAME" dist/spacefast-wordpress.zip --generate-notes --verify-tag

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist/

‎LICENSE‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Spacefast for WordPress is free software: you can redistribute it and/or modify
2+
it under the terms of the GNU General Public License as published by the Free
3+
Software Foundation, either version 2 of the License, or (at your option) any
4+
later version.
5+
6+
This program is distributed in the hope that it will be useful, but WITHOUT ANY
7+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
8+
PARTICULAR PURPOSE. See https://www.gnu.org/licenses/old-licenses/gpl-2.0.html.

‎README.md‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Spacefast for WordPress
2+
3+
One WordPress plugin, two ways to publish a static site to Spacefast:
4+
5+
- **Static WordPress** uses the free [Simply Static](https://wordpress.org/plugins/simply-static/)
6+
plugin to generate HTML, CSS, JavaScript, and assets. Spacefast publishes the
7+
generated directory as an exact snapshot.
8+
- **Headless CMS** treats WordPress as a public content source. Content changes
9+
rebuild the connected Astro or other repository project on Spacefast.
10+
11+
## Install
12+
13+
1. In Spacefast, open the Space's WordPress data-source setup and choose
14+
**Connect WordPress**.
15+
2. Download [`spacefast-wordpress.zip`](https://github.com/spacefast/wordpress/releases/latest/download/spacefast-wordpress.zip)
16+
and create the one-time connection.
17+
3. In WordPress, upload and activate the ZIP, then open **Settings → Spacefast**.
18+
4. Paste the complete connection, choose a publishing mode, and test it.
19+
20+
The generated credential is scoped to one Space. It can trigger that Space's
21+
production repository, publish static files to it, and read its version status.
22+
It cannot edit WordPress, change Space settings, manage domains, or access
23+
another Space. The secret is stored in a non-autoloaded WordPress option and is
24+
never displayed after save. A managed host can instead define
25+
`SPACEFAST_WORDPRESS_API_URL`, `SPACEFAST_WORDPRESS_SPACE_ID`, and
26+
`SPACEFAST_WORDPRESS_TOKEN` in `wp-config.php`.
27+
28+
## Static WordPress
29+
30+
Install and activate Simply Static, then select **Static WordPress** in
31+
**Settings → Spacefast**. **Export and publish** starts a full Simply Static
32+
export. Starting an export from Simply Static's own screen works too.
33+
34+
Spacefast adds a delivery step after Simply Static has generated and delivered
35+
its files but before cleanup. The step hashes the generated bytes, declares a
36+
full export as an exact snapshot through Spacefast's normal version API,
37+
uploads only the files Spacefast requests, waits for activation, and records
38+
whether that version became live. Partial, update, build, and 404-only exports
39+
are additive so they cannot accidentally delete omitted site files; run a full
40+
export after deleting content. Upload transfer is paged and processed one file
41+
per Simply Static background step so a large upload does not become one
42+
unbounded WordPress request.
43+
44+
Simply Static remains responsible for crawling WordPress and rewriting URLs.
45+
Spacefast never reads drafts, WordPress credentials, or the database. Dynamic
46+
WordPress features still need a static-compatible replacement.
47+
48+
## Headless CMS
49+
50+
Select **Headless CMS** when an Astro or other repository project reads the
51+
WordPress REST API during its build. Publishing, updating, unpublishing, or
52+
deleting public REST-visible post types, taxonomy changes, navigation changes,
53+
media changes, and public user changes schedule a production build. Autosaves,
54+
revisions, and draft-only transitions are ignored. Multiple hooks in one
55+
request collapse into one generation.
56+
57+
Delivery uses WP-Cron with a stable idempotency key. Network failures, timeouts,
58+
rate limits, and server errors retry with bounded exponential backoff. A change
59+
arriving while a delivery runs remains pending and schedules one successor.
60+
**Build now** uses the same path immediately. The generic **Build now** action
61+
in the Spacefast dashboard triggers the same connected production repository.
62+
63+
The plugin sends no post content, title, author, or other WordPress data to
64+
Spacefast. It sends only the configured public WordPress origin and a request
65+
to run the server-owned repository settings.
66+
67+
## Operate and remove
68+
69+
The settings page shows the active mode, pending work, delivery status, and the
70+
last build or version ID. It also provides a connection test and appears in
71+
Site Health.
72+
73+
**Disconnect** removes the local secret and pending work. Revoke the matching
74+
WordPress key in Spacefast Developer settings. Uninstall removes all plugin
75+
options, cron events, locks, notices, and interrupted static-publish state; it
76+
never deletes WordPress content or Simply Static exports.
77+
78+
## Development
79+
80+
From this directory:
81+
82+
```bash
83+
./bin/test.sh
84+
```
85+
86+
This lints every runtime PHP file, runs dependency-free behavioral tests, builds
87+
the deterministic installable ZIP in `dist/`, checks the archive, and proves a
88+
second build produces identical bytes.
89+
90+
Private beta supports WordPress 6.5+, PHP 8.1+, and Simply Static 3.8+ for direct
91+
static publishing. Activate it per site; network activation is intentionally
92+
rejected so a credential can never be silently shared across a multisite
93+
network.

‎bin/build-zip.sh‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
plugin_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
stage="$(mktemp -d)"
6+
trap 'rm -rf "${stage}"' EXIT
7+
8+
mkdir -p "${stage}/spacefast-wordpress" "${plugin_root}/dist"
9+
cp "${plugin_root}/spacefast-wordpress.php" "${plugin_root}/uninstall.php" \
10+
"${plugin_root}/readme.txt" "${plugin_root}/README.md" "${plugin_root}/LICENSE" \
11+
"${stage}/spacefast-wordpress/"
12+
cp -R "${plugin_root}/includes" "${stage}/spacefast-wordpress/includes"
13+
14+
find "${stage}/spacefast-wordpress" -type f -exec chmod 0644 {} +
15+
find "${stage}/spacefast-wordpress" -exec touch -t 202601010000 {} +
16+
(
17+
cd "${stage}"
18+
archive="${stage}/spacefast-wordpress.zip"
19+
# Store entries without deflate so different zip/zlib builds produce the
20+
# same release artifact from the same normalized files.
21+
find spacefast-wordpress -type f -print | LC_ALL=C sort | zip -0 -X -q \
22+
"${archive}" -@
23+
cp "${archive}" "${plugin_root}/dist/spacefast-wordpress.zip"
24+
)
25+
26+
unzip -tq "${plugin_root}/dist/spacefast-wordpress.zip"
27+
printf 'Built %s\n' "${plugin_root}/dist/spacefast-wordpress.zip"

‎bin/test.sh‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
plugin_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
6+
find "${plugin_root}" -name '*.php' -not -path '*/tests/*' -print0 |
7+
xargs -0 -n1 php -l
8+
php "${plugin_root}/tests/behavior.php"
9+
"${plugin_root}/bin/build-zip.sh"
10+
first_archive="$(mktemp)"
11+
trap 'rm -f "${first_archive}"' EXIT
12+
cp "${plugin_root}/dist/spacefast-wordpress.zip" "${first_archive}"
13+
"${plugin_root}/bin/build-zip.sh"
14+
cmp "${first_archive}" "${plugin_root}/dist/spacefast-wordpress.zip"

0 commit comments

Comments
 (0)