Skip to content

fix(build): copy the language files into the demo again - #506

Merged
kevinchappell merged 1 commit into
mainfrom
fix/demo-language-files
Sep 28, 2026
Merged

kevinchappell merged 1 commit into
mainfrom
fix/demo-language-files

Conversation

@kevinchappell

Copy link
Copy Markdown
Collaborator

Problem

The deployed demo at https://draggable.github.io/formeo/assets/lang/ has no language files. That URL is the editor's default i18n.location, so every non-English locale 404s for every Formeo install on the default config, whatever its version.

Since @draggable/formeo-languages 3.5.1, the package ships its files in dist/lang/lang/. tools/copy-assets.mjs globbed dist/lang/*, so it matched only the lang directory and fs.copyFile threw EISDIR. The catch logged the error and carried on, so npm run build still exited 0. The gh-pages deploy on 2026-08-08 then removed all 48 files from assets/lang.

Changes

  • tools/copy-assets.mjs:
    • copies language files at any depth, flat by basename, and skips directories
    • a failed copy sets a non-zero exit code, so the build fails instead of shipping a broken demo
    • the other targets are unchanged (dist/*.js still leaves out the .cjs builds)
  • src/lib/js/copy-assets.test.mjs: unit tests for the copy helper, run against a temp dir and the installed package
  • publish.yaml and deploy.yaml: after the build, check that en-US.lang and de-DE.lang are in dist/demo/assets/lang before releasing or deploying

Verification

  • npm run build exits 0 with no "Error copying" line (before: one EISDIR line)
  • dist/demo/assets/lang has 48 files (24 .lang + 24 .json) and no subdirectory (before: 0 files)
  • dist/demo/assets/js has the same files as before
  • npm test 576/576, npm run lint clean, test:dist 5/5, Playwright 149 passed (3 skipped by test.skip in the suite)

Once merged, the release's deploy puts the language files back on gh-pages.

Since @draggable/formeo-languages 3.5.1 the package ships its files in
dist/lang/lang/. copy-assets globbed dist/lang/*, matched only the lang
directory, and fs.copyFile threw EISDIR. The catch logged the error and
carried on, so npm run build exited 0 and the 2026-08-08 gh-pages deploy
removed all 48 files from assets/lang. That URL is the editor's default
i18n.location, so every non-English locale 404s on the default config.

Copy language files at any depth, flat by basename, skipping
directories. A failed copy now sets a non-zero exit code, failing the
build. Publish and Deploy check that en-US.lang and de-DE.lang are in
the demo build before releasing or deploying. A unit test runs the
copy helper against a temp dir and the installed package.
Copilot AI lite review requested due to automatic review settings September 28, 2026 09:35
@kevinchappell
kevinchappell merged commit ff9d839 into main Sep 28, 2026
3 checks passed
@kevinchappell
kevinchappell deleted the fix/demo-language-files branch September 28, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Empty source matches can still allow an incomplete demo build to deploy.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Restores demo language asset copying after the package layout changed.

Changes:

  • Recursively copies language files flat by basename.
  • Adds copy-helper tests and propagates copy failures.
  • Validates required language files in publish and deploy workflows.
File Summary
tools/​copy-assets.mjs Updates recursive asset copying and failure handling; empty matches can still report success.
src/​lib/​js/​copy-assets.test.mjs Adds tests for copy behavior and error handling.
.github/​workflows/​publish.yaml Verifies language files before publishing.
.github/​workflows/​deploy.yaml Verifies language files before deployment.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tools/copy-assets.mjs
Comment on lines 39 to 46
async function copyFile(src, dest, rename = null) {
for await (const file of fs.glob(src)) {
if ((await fs.stat(file)).isDirectory()) continue
const destPath = rename ? join(dest, rename) : join(dest, basename(file))
await fs.mkdir(dirname(destPath), { recursive: true })
await fs.copyFile(file, destPath)
}
}
@kevinchappell

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 5.9.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants