Skip to content

Commit 35ed592

Browse files
authored
Merge pull request #327 from FirefoxCSS-Store/improve-automation
Improve automation
2 parents 1ae483a + 93b7f42 commit 35ed592

123 files changed

Lines changed: 4557 additions & 4414 deletions

File tree

Some content is hidden

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

.devcontainer/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
3+
{
4+
"name": "Node.js",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/javascript-node:4-24-trixie",
7+
"features": {
8+
"ghcr.io/devcontainers-extra/features/npm-package:1": {}
9+
},
10+
11+
// Features to add to the dev container. More info: https://containers.dev/features.
12+
// "features": {},
13+
14+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
15+
// "forwardPorts": [],
16+
17+
// Use 'postCreateCommand' to run commands after the container is created.
18+
"postCreateCommand": "bash .devcontainer/post-create.sh",
19+
20+
// Configure tool-specific properties.
21+
// "customizations": {},
22+
23+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
24+
// "remoteUser": "root"
25+
}

.devcontainer/post-create.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if ! command -v jq >/dev/null 2>&1; then
5+
sudo apt-get update
6+
sudo apt-get install -y jq
7+
fi
8+
9+
if ! command -v nu >/dev/null 2>&1; then
10+
npm install -g nushell
11+
fi
12+
13+
npm ci

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

.github/workflows/build.yml

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,57 @@
1-
name: Build
1+
name: Build And Publish Docs
22

33
on:
4-
workflow_dispatch
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'dev/**'
9+
- 'images/**'
10+
- 'themes.json'
11+
- 'gulpfile.js'
12+
- 'gulpconfig.js'
13+
- 'package.json'
14+
- 'package-lock.json'
15+
- 'dev/config/**'
16+
workflow_dispatch:
17+
18+
env:
19+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
20+
21+
permissions:
22+
contents: write
23+
24+
concurrency:
25+
group: build-and-publish-${{ github.ref }}
26+
cancel-in-progress: true
527

628
jobs:
729
build:
830
runs-on: ubuntu-latest
931
steps:
10-
- uses: actions/checkout@v2
32+
- uses: actions/checkout@v6
1133
with:
12-
persist-credentials: false
1334
fetch-depth: 0
14-
- uses: actions/setup-node@v1
35+
36+
- uses: actions/setup-node@v6
1537
with:
16-
node-version: 14
17-
- run: npm i
38+
node-version: 24
39+
cache: npm
40+
41+
- run: npm ci
42+
- run: npm test
1843
- run: npm run build
19-
- name: Commit files
44+
45+
- name: Commit generated docs
46+
shell: bash
2047
run: |
48+
if git diff --quiet -- docs; then
49+
echo "No generated docs changes to commit."
50+
exit 0
51+
fi
52+
2153
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
2254
git config --local user.name "github-actions[bot]"
23-
git add .
24-
git commit -m "ci(build): compile and deploy" -a
25-
- name: Push changes
26-
uses: ad-m/github-push-action@master
27-
with:
28-
github_token: ${{ secrets.GITHUB_TOKEN }}
29-
branch: ${{ github.ref }}
55+
git add docs
56+
git commit -m "ci(build): compile and deploy"
57+
git push

.github/workflows/check-themes.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
1-
name: Check themes.json
1+
name: Validate Site
22

33
on:
44
pull_request:
55
branches: [ main ]
66
paths:
7+
- 'dev/**'
8+
- 'images/**'
79
- 'themes.json'
10+
- 'gulpfile.js'
11+
- 'gulpconfig.js'
12+
- 'package.json'
13+
- 'package-lock.json'
14+
- 'dev/config/**'
15+
- '.github/workflows/**'
16+
17+
env:
18+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
819

920
jobs:
10-
test_pull_requests:
21+
validate_pull_requests:
1122
runs-on: ubuntu-latest
1223
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v1
24+
- uses: actions/checkout@v6
25+
26+
- uses: actions/setup-node@v6
1527
with:
16-
node-version: 14
17-
- run: npm i
28+
node-version: 24
29+
cache: npm
30+
31+
- run: npm ci
1832
- run: npm test
33+
- run: npm run build

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Icon?
4242
# JetBrains IDEs
4343
.idea/
4444

45+
# Codex local workspace data
46+
.codex
47+
4548
# Build output
4649
/dist/
4750
/build/
@@ -60,4 +63,3 @@ coverage/
6063
# Misc
6164
*.sublime-workspace
6265
*.sublime-project
63-

AGENTS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# AGENTS
2+
3+
This repository uses this file as the entry point for future coding agents.
4+
5+
Before starting work:
6+
7+
1. Read [MEMORY.md](./MEMORY.md).
8+
2. Use that file as persistent project context across conversations.
9+
3. Keep `MEMORY.md` updated manually after any relevant change, decision, blocker, or workflow update.
10+
11+
Operational notes:
12+
13+
- Prefer minimal, reversible changes.
14+
- Validate with `npm test` for `themes.json` checks.
15+
- Use `npm run build` when touching generated site assets or source files under `dev/`.
16+
- When automation changes are introduced, document the intent and impact in `MEMORY.md`.
17+
- Use English for repository-facing output by default, including code, comments, commit messages, pull request text, documentation, workflow messages, and user-facing project strings unless the repository already requires another language in a specific place.
18+
- In chat, always reply in the same language used by the user.
19+
- After implementing relevant changes or new functionality, create a commit and push it so work remains traceable and easy to roll back if needed.
20+
- Never perform a merge without explicit user authorization.
21+
- Never take actions that could affect the repository's production main branch without explicit user authorization.

MEMORY.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Persistent Memory
2+
3+
This file stores durable project context so future conversations can resume work with less re-discovery.
4+
5+
## Project Summary
6+
7+
- Repository: `FirefoxCSS-Store.github.io`
8+
- Purpose: static site that catalogs Firefox `userChrome.css` themes
9+
- Main data source: `themes.json`
10+
- Site source: `dev/`
11+
- Generated site output: `docs/`
12+
13+
## Tooling And Validation
14+
15+
- Package manager: `npm`
16+
- Build command: `npm run build`
17+
- Test command: `npm test`
18+
- Build system: `gulp`
19+
- Theme validation script: `tests/themes.check.js`
20+
- Theme metadata refresh script: `scripts/sort_themes.nu`
21+
- Dev container config: `.devcontainer/devcontainer.json`
22+
- Devcontainer bootstrap script: `.devcontainer/post-create.sh`
23+
- Devcontainer automation now runs `.devcontainer/post-create.sh` from `postCreateCommand` to ensure `jq`, `nu`, and project dependencies are installed after container creation/rebuild
24+
- The build toolchain now runs cleanly on Node 24 with `gulp@5`, `gulp-sass@6`, `gulp-terser`, and a custom `sharp`-based WebP conversion step
25+
- `npm audit` is currently clean after adding targeted `overrides` for `markdown-it` and `@parcel/watcher` transitive dependencies
26+
27+
## Automation Context
28+
29+
- Active working branch created for automation improvements: `improve-automation`
30+
- Existing GitHub Actions:
31+
- `.github/workflows/build.yml`
32+
- `.github/workflows/check-themes.yml`
33+
- CI now uses current `actions/checkout@v4` and `actions/setup-node@v4` on Node 24
34+
- CI workflows now opt into Node 24 for JavaScript actions explicitly and use `actions/checkout@v6` plus `actions/setup-node@v6`
35+
- Build workflow now runs automatically on pushes to `main` that affect site/build inputs and commits regenerated `docs/` output back to the branch
36+
- PR validation now runs `npm test` and `npm run build` for site-related changes instead of only checking `themes.json`
37+
- The build workflow syntax also requires `workflow_dispatch:` with a trailing colon; missing it makes GitHub mark the workflow file as invalid even if other checks still pass
38+
39+
## Repo Notes
40+
41+
- Local `.codex` file is ignored in `.gitignore`
42+
- Build workflow currently commits generated files back to the branch after `npm run build`
43+
- Pull requests touching `themes.json` trigger validation via `npm test`
44+
- Site pages are generated from Pug in `dev/pug/`
45+
- Client behavior is implemented in `dev/js/main.js`
46+
- Styles are authored in SCSS under `dev/scss/`
47+
- Published site assets live in committed `docs/`
48+
- Local containerized development is configured to install Node, npm, `jq`, and Nushell
49+
- The devcontainer also runs `npm ci` automatically, so rebuilds recreate `node_modules` without manual setup
50+
- `gulpfile.js` now lazy-loads ESM-only Gulp plugins and skips optional directories like `dev/fonts/` when they are absent
51+
- Hidden config generation now filters non-`.txt` files explicitly so builds do not create stray files like `docs/.robots`
52+
- Theme entries that depended on fragile remote screenshots have been localized into `images/themes/remote-*` and now build into committed assets under `docs/assets/img/themes/`
53+
- Binary copies for static images now use `fs.promises.copyFile` instead of `gulp.src().pipe(dest())` because the stream path was corrupting some `.webp` assets in `docs/`
54+
- Project-facing text should be written in English by default; chat replies should mirror the user's language
55+
56+
## Architecture Snapshot
57+
58+
- `themes.json` is the single catalog source used by the client and copied to `docs/themes.json` during build
59+
- The frontend is a mostly static site with a small client-side app that fetches `themes.json`, sorts, filters, and renders cards in the browser
60+
- Gulp handles Pug compilation, SCSS compilation, Babel transpilation, JS minification with Terser, image conversion/copy with Sharp, and config file copying
61+
- Images from `images/` are emitted to `docs/assets/img/`; many local screenshots are converted to WebP
62+
- `scripts/sort_themes.nu` enriches theme entries with `pushed_at`, `stargazers_count`, and `avatar` using GitHub/GitLab/Codeberg APIs or git cloning fallback
63+
64+
## Known Technical Risks
65+
66+
- Theme rendering is intentionally throttled with `444ms` per card, which scales poorly for a catalog of 100+ entries
67+
- Search/filter logic depends on client-side fetch and has no visible loading or error handling
68+
- Test coverage is narrow: `tests/themes.check.js` validates only basic key order/types and not richer schema or link/image integrity
69+
70+
## Working Agreement For Future Sessions
71+
72+
- Read this file before making assumptions about project state
73+
- Update this file manually when there are relevant decisions, branch changes, automation updates, or persistent blockers
74+
- Keep entries concise and durable; avoid transient noise
75+
- Future agents should create a commit and push after implementing relevant changes or new functionality so work stays traceable and reversible
76+
- Future agents must not merge without explicit user authorization
77+
- Future agents must not take actions that could affect the production main branch without explicit user authorization

dev/config/robots.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
User-agent: *
2-
Disallow: /
2+
Allow: /

dev/js/main.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,19 @@ class Card {
5353
}
5454

5555

56-
const removeLightbox = () => document.body.getElementsById('lightbox').remove()
56+
function removeLightbox () {
57+
58+
const lightbox = document.getElementById('lightbox')
59+
60+
if (lightbox)
61+
lightbox.remove()
62+
63+
}
5764

5865
function createLightbox (id) {
5966

67+
removeLightbox()
68+
6069
const card = document.getElementById(`theme-${id}`)
6170
const themeTitle = card.querySelector('h3')
6271
const img = card.querySelector('img')
@@ -65,7 +74,7 @@ function createLightbox (id) {
6574
<div id="lightbox" onclick="this.remove()">
6675
<h2>${themeTitle.innerText}</h2>
6776
<img src="${img.src}">
68-
<button type="button" class="btn btn-close-lightbox" onClick="removeLightbox"><i class="fas fa-times-circle"></i> Close</button>
77+
<button type="button" class="btn btn-close-lightbox" onClick="removeLightbox()"><i class="fas fa-times-circle"></i> Close</button>
6978
</div>
7079
`
7180

0 commit comments

Comments
 (0)