Skip to content

Feature/upstream merge driver#25

Merged
tingeber merged 7 commits into
mainfrom
feature/upstream-merge-driver
May 12, 2026
Merged

Feature/upstream merge driver#25
tingeber merged 7 commits into
mainfrom
feature/upstream-merge-driver

Conversation

@tingeber

Copy link
Copy Markdown
Contributor

No description provided.

tingeber added 7 commits May 12, 2026 15:27
…stro

The recommended install path is npx create-astro --template, which starts
a fresh git history with no shared root with Scaffold. The first merge
from template/main needs --allow-unrelated-histories; every subsequent
merge works without it.
Wrap the merge workflow in a script so consumers can pull updates
with a single command. The script:

- Detects no-shared-history (post-create-astro) and adds
  --allow-unrelated-histories automatically on the first merge
- Resolves modify/delete conflicts in protected paths by re-applying
  the downstream deletion (Git's `merge=ours` driver can't handle
  modify/delete, only content conflicts)
- Reports new upstream files in protected paths at the end, without
  auto-pruning (a new section component shipped as demo may be
  genuinely useful)
- Bails if working tree is dirty or remote is unconfigured

Wired up as `npm run update-from-scaffold`. README and how-to-use.yaml
restructured to lead with the npm command; raw git remains documented
as a fallback for transparency.

Bootstrap path updated: existing forks now check out both the
.gitattributes and the script in a single command, run the script
directly via bash, then add the one-line npm shortcut themselves
(safer than overwriting their package.json).
Adds src/styles to the merge=ours path list and to the script's
PROTECTED array so downstream consumers' theme tokens, typography,
and component utilities are preserved on template updates the same
way content and assets are. Trade-off: Scaffold's own style
improvements won't auto-propagate — consumers port them manually
if they want them.
Move font declarations out of astro.config.mjs into a sibling
fonts.config.mjs at repo root. The CSS variables exposed to the
rest of the codebase are renamed from font-specific (--font-rubik,
--font-ibm-plex-serif, --font-jetbrains-mono) to generic slots
(--font-sans, --font-serif, --font-mono), so swapping fonts is
purely a name+weights change in fonts.config.mjs.

astro.config.mjs imports the fonts array and stays template-managed
(so consumers receive future astro/integration updates cleanly).
fonts.config.mjs is marked merge=ours in .gitattributes, so each
consumer's font choices survive `npm run update-from-scaffold`.

typography.css's old @theme aliasing block (--font-sans: var(--font-rubik))
is replaced with @theme inline. The Tailwind utilities resolve their
font-family from --font-sans/etc at runtime, picking up whatever value
Astro's Font feature injects into :root — verified by `npm run build`
producing correct font-family chains in the output CSS.

README and how-to-use.yaml gain a "Changing fonts" section explaining
Bunny Fonts as the provider, how to swap fonts via fonts.config.mjs,
and what not to rename. Both list fonts.config.mjs in the protected
paths.

Migration for existing consumers: pull this change, resolve the
astro.config.mjs conflict in favour of upstream, create their own
fonts.config.mjs with their custom fonts, update typography.css
@theme block to use @theme inline (or accept upstream version since
src/styles is protected, theirs stays).
Astro's fonts field expects `weights: [string | number, ...(string | number)[]]`
(non-empty tuple). When the literal [300, 400, ...] lived inline in
astro.config.mjs, TS inferred it as a tuple. Once moved to a separate
exported const, TS widened it to number[] — losing the at-least-one-element
guarantee.

Adding a JSDoc `@type {AstroUserConfig['fonts']}` annotation propagates the
expected type back into the literal, keeping the tuple inference.

Also adds `// @ts-check` to fonts.config.mjs so the annotation is enforced.

Verified: `npx astro check` errors dropped from 26 to 25 (only the SVG
class/className warnings from unplugin-icons remain, pre-existing).
Adds an 'Updating from upstream' section covering npm run update-from-scaffold,
what the wrapper does (--allow-unrelated-histories handling, modify/delete
re-deletion, new-file reporting), and the merge=ours protected paths list.

Adds a Fonts bullet under Architecture explaining the fonts.config.mjs split,
the three slot names (--font-sans/serif/mono), and the Bunny Fonts default.
Replace the "list new files for manual review" pattern with two
explicit behaviours:

1. New upstream files in src/content/, src/assets/, public/ are
   auto-removed during the merge — keeps demo content out of
   downstream production sites. src/styles/ is intentionally excluded
   from auto-removal since new stylesheets may be required by new
   components in the merge.

2. New directories under src/content/ (typically indicating a new
   content collection) trigger a single alert at the end of the run:

       ℹ There are new content collections on Scaffold — check out
         https://scaffold.org to see what's new

   The schema arrives via src/content.config.ts (not protected,
   merges normally); the demo files in the new collection are removed
   along with all other new files. Consumers visit scaffold.org to
   see what landed and opt in by adding their own content.

Internals: git merge now runs with --no-commit so the script can
modify the index (DU re-deletion, NEW file removal) before finalising.
BEFORE/MID file snapshots are deduped with sort -u to handle the
mid-merge "multiple index stages" state. The collection-alert prints
even when code-side conflicts halt the script, so the user doesn't
miss the heads-up while resolving conflicts.
@netlify

netlify Bot commented May 12, 2026

Copy link
Copy Markdown

Deploy Preview for draftlab-scaffold ready!

Name Link
🔨 Latest commit 589b333
🔍 Latest deploy log https://app.netlify.com/projects/draftlab-scaffold/deploys/6a033a445e9ab7000878354b
😎 Deploy Preview https://deploy-preview-25--draftlab-scaffold.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@tingeber tingeber merged commit 8117a47 into main May 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant