Skip to content

Commit c66a8a9

Browse files
cowboydtaras
andauthored
Bring back the website into the Effection repo (#1040)
We brought it out because of tooling concerns. We're bringing it back in because it makes it so much easier to work on Co-authored-by: Taras Mankovski <[email protected]>
1 parent 2776f2e commit c66a8a9

File tree

110 files changed

+9065
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+9065
-18
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33

44
# Explicitly set line endings for text files
55
*.ts text eol=lf
6+
*.tsx text eol=lf
67
*.mjs text eol=lf
78
*.js text eol=lf
89
*.json text eol=lf
910
*.md text eol=lf
1011
*.yml text eol=lf
1112
*.yaml text eol=lf
13+
*.css text eol=lf
14+
*.svg text eol=lf
15+
*.html text eol=lf
1216

1317
# Binary files
1418
*.png binary

.github/workflows/verify.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ name: Verify
22

33
on:
44
push:
5-
branches: v[3-9]
5+
branches:
6+
- v[3-9]
67
pull_request:
7-
branches: v[3-9]
8+
branches:
9+
- v[3-9]
810

911
permissions:
1012
contents: read
@@ -40,7 +42,7 @@ jobs:
4042

4143
- name: test (Windows)
4244
if: runner.os == 'Windows'
43-
run: deno task test
45+
run: deno test --allow-run --allow-write --allow-read --allow-env --allow-ffi --ignore=www
4446
shell: cmd
4547

4648
- name: test (Unix)

.github/workflows/www.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: www
2+
on:
3+
workflow_dispatch: # Allows manual trigger
4+
schedule:
5+
- cron: "0 */8 * * *" # Runs every 8 hours
6+
pull_request:
7+
push:
8+
branches:
9+
- tm/import-www
10+
11+
jobs:
12+
www:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 15
15+
16+
permissions:
17+
id-token: write # Needed for auth with Deno Deploy
18+
contents: read # Needed to clone the repository
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Setup Deno
27+
uses: denoland/setup-deno@v2
28+
with:
29+
deno-version: v2.x
30+
31+
- name: Serve Website
32+
run: |
33+
deno task dev &
34+
until curl --output /dev/null --silent --head --fail http://127.0.0.1:8000; do
35+
printf '.'
36+
sleep 1
37+
done
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
JSR_API: ${{ secrets.JSR_API }}
41+
timeout-minutes: 5
42+
working-directory: ./www
43+
44+
- name: Download Staticalize
45+
run: |
46+
wget https://github.com/thefrontside/staticalize/releases/download/v0.2.2/staticalize-linux.tar.gz \
47+
-O /tmp/staticalize-linux.tar.gz
48+
tar -xzf /tmp/staticalize-linux.tar.gz -C /usr/local/bin
49+
chmod +x /usr/local/bin/staticalize-linux
50+
51+
- name: Staticalize
52+
run: |
53+
staticalize-linux \
54+
--site=http://127.0.0.1:8000 \
55+
--output=www/built \
56+
--base=https://effection-www.deno.dev/
57+
58+
- run: npx pagefind --site built
59+
working-directory: ./www
60+
61+
- name: Upload to Deno Deploy
62+
uses: denoland/deployctl@v1
63+
with:
64+
project: effection
65+
entrypoint: "jsr:@std/http/file-server"
66+
root: www/built

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33

44
# Local Netlify folder
55
.netlify
6-
/build/
6+
/build/
7+
node_modules

deno.json

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"lock": false,
99
"tasks": {
10-
"test": "deno test --allow-run --allow-ffi",
10+
"test": "deno test --allow-run --allow-write --allow-read --allow-env --allow-ffi",
1111
"test:node": "deno task build:npm 0.0.0 && node test/main/node.mjs hello world",
1212
"build:jsr": "deno run -A tasks/build-jsr.ts",
1313
"build:npm": "deno run -A tasks/build-npm.ts"
@@ -19,16 +19,15 @@
1919
"exclude": [
2020
"build",
2121
"website",
22-
"www",
23-
"packages",
24-
"docs/*.ts"
22+
"www/build",
23+
"packages"
2524
]
2625
},
2726
"fmt": {
2827
"exclude": [
2928
"build",
3029
"website",
31-
"www",
30+
"www/build",
3231
"packages",
3332
"CODE_OF_CONDUCT.md",
3433
"README.md"
@@ -48,11 +47,26 @@
4847
"dom.iterable"
4948
]
5049
},
50+
"deploy": {
51+
"org": "Frontside",
52+
"project": "effection-www",
53+
"entrypoint": "https://jsr.io/@std/http/1.0.20/file_server.ts",
54+
"root": "./www"
55+
},
56+
"nodeModulesDir": "auto",
57+
"workspace": [
58+
"./www"
59+
],
5160
"imports": {
52-
"@deno/dnt": "jsr:@deno/[email protected]",
53-
"ctrlc-windows": "npm:[email protected]",
54-
"@std/testing": "jsr:@std/testing@^1",
61+
"https://deno.land/x/[email protected]/index.ts": "npm:[email protected]",
62+
"@std/path/posix/basename": "jsr:@std/path@1/posix/basename",
63+
"remark-gfm": "npm:[email protected]",
64+
"rehype-prism-plus": "npm:[email protected]",
65+
"@mdx-js/mdx": "npm:@mdx-js/[email protected]",
66+
"@std/testing/bdd": "jsr:@std/testing@^1/bdd",
5567
"@std/expect": "jsr:@std/expect@^1",
56-
"ts-expect": "npm:[email protected]"
68+
"ts-expect": "npm:[email protected]",
69+
"ctrlc-windows": "npm:[email protected]",
70+
"@deno/dnt": "jsr:@deno/[email protected]"
5771
}
5872
}

docs/docs.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import {
88
} from "effection";
99
import structure from "./structure.json" with { type: "json" };
1010

11-
import { basename } from "https://deno.land/[email protected]/path/posix/basename.ts";
11+
import { basename } from "@std/path/posix/basename";
1212

13-
import remarkGfm from "npm:remark-gfm@3.0.1";
14-
import rehypePrismPlus from "npm:rehype-prism-plus@1.5.1";
13+
import remarkGfm from "remark-gfm";
14+
import rehypePrismPlus from "rehype-prism-plus";
1515

16-
import { evaluate } from "npm:@mdx-js/mdx@2.3.0";
16+
import { evaluate } from "@mdx-js/mdx";
1717

1818
import { Fragment, jsx, jsxs } from "revolution/jsx-runtime";
1919

lib/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function* withHost<T>(op: HostOperation<T>): Operation<T> {
175175
// @see https://github.com/iliakan/detect-node/blob/master/index.js
176176
} else if (
177177
Object.prototype.toString.call(
178-
typeof globalThis.process !== "undefined" ? globalThis.process : 0,
178+
typeof global.process !== "undefined" ? global.process : 0,
179179
) === "[object process]"
180180
) {
181181
return yield* op.node();

www/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/node_modules
2+
pagefind
3+
build
4+
built
5+
tailwind

www/README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
## Effection Website
2+
3+
The Effection website shows documentation and packages that it pulls from GIT
4+
repositories on GitHub.
5+
6+
## About Git Integration
7+
8+
The Effection website uses sophisticated GitHub integration to dynamically load
9+
and display documentation and packages from Effection repositories. This
10+
integration works through multiple layers:
11+
12+
### Repository Access
13+
14+
- **Dual Provider System**: Uses both Git commands (`git-provider.ts`) and
15+
GitHub's Octokit API (`octokit-provider.ts`) for redundant access to
16+
repository data
17+
- **Dynamic Remote Management**: Automatically adds and fetches GitHub remotes
18+
for repositories, enabling access to branches, tags, and file contents
19+
- **Branch & Tag Detection**: Intelligently determines whether references are
20+
branches or tags and normalizes them to proper Git reference formats
21+
22+
### Documentation Loading
23+
24+
- **Guides**: Pulls structured documentation from `docs/structure.json` and
25+
loads MDX files from the `docs/` directory in the
26+
[**thefrontside/effection**](https://github.com/thefrontside/effection)
27+
repository
28+
- **API Documentation**: Generates API documentation using Deno's documentation
29+
generator from TypeScript source files in the
30+
[**thefrontside/effection**](https://github.com/thefrontside/effection)
31+
repository (supports both v3 and v4 via tags like `effection-v3.*` and
32+
`effection-v4.*`)
33+
- **README Integration**: Loads and renders README.md files from package
34+
directories using MDX processing
35+
36+
### Package Discovery
37+
38+
- **Workspace Integration**: Reads `deno.json` files to discover packages and
39+
their configurations within:
40+
- [**thefrontside/effection**](https://github.com/thefrontside/effection) -
41+
Core Effection library packages
42+
- [**thefrontside/effectionx**](https://github.com/thefrontside/effectionx) -
43+
Extended Effection ecosystem packages
44+
- **Multi-Version Support**: Handles different versions of packages by working
45+
with Git tags and branches from both repositories
46+
- **Export Mapping**: Maps package exports to their corresponding source files
47+
for direct GitHub links
48+
49+
### Dynamic Content
50+
51+
- **Live Repository Data**: Fetches star counts, default branches, and
52+
repository metadata directly from GitHub
53+
- **Content Versioning**: Supports loading content from specific Git references
54+
(branches, tags, commits)
55+
- **Badge Integration**: Generates badges for JSR packages, npm packages, bundle
56+
sizes, and other metrics
57+
58+
This integration ensures that the website always reflects the current state of
59+
the Effection ecosystem by pulling data directly from the source repositories on
60+
GitHub.
61+
62+
## Deployment
63+
64+
The website is deployed to Deno Deploy using a static site generation process
65+
powered by the [Staticalize](https://github.com/thefrontside/staticalize)
66+
utility:
67+
68+
### Automated Deployment Process
69+
70+
- **Trigger**: Runs automatically every 8 hours via scheduled GitHub Action, on
71+
pushes to `main` branch, and can be manually triggered
72+
- **Static Generation**: The live website is crawled and converted to static
73+
files using Staticalize
74+
- **Search Integration**: Pagefind indexes the static content to enable
75+
client-side search functionality
76+
- **Deno Deploy**: Static files are uploaded to
77+
[Deno Deploy](https://deno.com/deploy) and served via their edge network
78+
79+
### Deployment Pipeline
80+
81+
1. **Server Startup**: Spins up the dynamic website locally using
82+
`deno task dev`
83+
2. **Content Crawling**: Staticalize crawls `http://127.0.0.1:8000` to generate
84+
static HTML/CSS/JS
85+
3. **Search Indexing**: Pagefind processes the static files to create search
86+
indexes
87+
4. **Upload**: Deploys the built static site to the `effection-www` project on
88+
Deno Deploy
89+
90+
This ensures the website stays current with repository changes while providing
91+
fast global delivery through static hosting.
92+
93+
## Troubleshooting
94+
95+
### "Bad credentials" Error from GitHub API
96+
97+
If you encounter an `HttpError: Bad credentials` error when running the website:
98+
99+
1. **Verify your GITHUB_TOKEN**: Ensure the `GITHUB_TOKEN` environment variable
100+
is set with a valid GitHub personal access token
101+
2. **Clear the cache**: Old cached data may contain requests made with an
102+
expired or invalid token. Run the clear-cache task:
103+
```bash
104+
deno task clear-cache
105+
```
106+
3. **Restart the server**: After clearing the cache, restart the development
107+
server
108+
109+
This error typically occurs when the cache contains authenticated requests from
110+
a previous token that is no longer valid.

www/assets/external-link.svg

Lines changed: 20 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)