Skip to content

Ship the project templates in the packaged app - #116

Open
giovannimanzoni wants to merge 1 commit into
doctly:mainfrom
Axiumine:fix/templates-in-package
Open

giovannimanzoni wants to merge 1 commit into
doctly:mainfrom
Axiumine:fix/templates-in-package

Conversation

@giovannimanzoni

Copy link
Copy Markdown

Problem

In an installed build, Settings → Project Templates → Open Folder does nothing, and the bundled templates (customer, feature, research) never exist. Running from source works, which is why the tests did not show it.

Cause

  1. build.files does not list templates/, so the package has nothing to seed <data dir>/templates from. seedTemplates() returns false silently.
  2. Listing the files is not enough: fs.cpSync cannot read from app.asar. With Electron 41.0.3 it fails with ENOENT.
  3. The button calls open-path, gets { error: 'Not a folder' } and ignores it.

Fix

  • Add templates/**/* to build.files.
  • Seed with a small recursive copy that reads and writes each file. copyFileSync also works from the archive, but leaves the copies 0600.
  • Show the error when the folder cannot be opened.

Existing installs repair themselves: seeding runs as long as the folder is missing.

Testing

  • Two new tests: build.files lists the templates; seeding copies the whole tree without fs.cpSync.
  • Linux unpacked build (electron-builder --linux dir): listTemplates() run from the built app.asar seeds all three templates, nested files included, with normal permissions.
  • npm test on Linux: 533 of 541 pass. The 8 failures are the same ones, by name, as on unchanged main on this machine.
  • Not tried: macOS and Windows builds, and clicking the button in the running app.

🤖 Generated with Claude Code

In an installed build, Settings > Project Templates > Open Folder did
nothing and no template existed:

- build.files left out templates/, so there was nothing to seed from.
- fs.cpSync cannot read from app.asar, so adding the files alone would
  still fail with ENOENT. Copy by reading and writing each file instead.
- The button ignored the error from open-path. Show it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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