Skip to content

* Modify the Taskfiles to allow control of frontend package manager u…#5126

Merged
leaanthony merged 3 commits into
wailsapp:masterfrom
symball:package_management
May 15, 2026
Merged

* Modify the Taskfiles to allow control of frontend package manager u…#5126
leaanthony merged 3 commits into
wailsapp:masterfrom
symball:package_management

Conversation

@symball

@symball symball commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

See #5125 for more information

Description

Change to the root Taskfile adding an extra var option and the common Taskfile for frontend management tasks.

The defaults keep execution flow as is and if accepted, i will happily add a note to the documentation site on how to control

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

I have tested new projects on MacOS with npm, pnpm, and bun. I haven't tested with yarn although the code should work fine. I can do some further testing on windows and linux in the morning and will update accordingly

Summary by CodeRabbit

  • New Features

    • Frontend tasks now support bun, pnpm, and yarn (install, run, dev) in addition to npm.
    • New package-manager-specific tasks ensure installs and scripts use the selected runner.
  • Refactor

    • Build and dev tasks delegate to wrapper tasks that compute and run the correct script.
    • Template interpolation and quoting standardized; template helper variables added for safer, OS-scoped templating and a configurable dev port.

@coderabbitai

coderabbitai Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 08d636ab-1d71-49f5-83ca-7b96e1654759

📥 Commits

Reviewing files that changed from the base of the PR and between d93a6b9 and ee7f4ee.

📒 Files selected for processing (1)
  • v3/internal/commands/build_assets/Taskfile.tmpl.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • v3/internal/commands/build_assets/Taskfile.tmpl.yml

Walkthrough

Taskfile templates and generation now support selecting a frontend package manager (npm, yarn, pnpm, bun) via PACKAGE_MANAGER with manager-specific install/run/dev tasks, and template data is enriched with Opn/Cls helpers so generated Taskfiles can emit nested template tags safely.

Changes

Frontend Taskfile changes

Layer / File(s) Summary
Task delegation & package-manager variable
v3/internal/commands/build_assets/Taskfile.tmpl.yml
install:frontend:deps and dev:frontend now delegate to install:frontend:deps:{{.Opn}}.PACKAGE_MANAGER{{.Cls}} / frontend:dev:{{.Opn}}.PACKAGE_MANAGER{{.Cls}} rather than calling a single manager.
Manager-specific dependency install tasks
v3/internal/commands/build_assets/Taskfile.tmpl.yml
Added install:frontend:deps:{bun,pnpm,yarn} tasks with appropriate sources (lockfiles), preconditions (tool availability checks), and install commands (bun install, pnpm install, yarn install).
Run wrapper and manager-specific run/dev tasks
v3/internal/commands/build_assets/Taskfile.tmpl.yml
Introduced frontend:run (computes SCRIPT/PRODUCTION) plus frontend:run:{npm,yarn,pnpm,bun} that execute the computed SCRIPT; added frontend:dev:{npm,yarn,pnpm,bun} to start dev servers with --port {{.VITE_PORT}} --strictPort.
Build label / script wiring
v3/internal/commands/build_assets/Taskfile.tmpl.yml
build:frontend refactored to delegate to frontend:run and compute script/label interpolation using .DEV and selected PACKAGE_MANAGER.

Common template vars & Taskfile quoting

Layer / File(s) Summary
Common vars and OS-scoped templating
v3/internal/templates/_common/Taskfile.tmpl.yml
Added PACKAGE_MANAGER and moved VITE_PORT into OS-scoped, quoted vars; switched OS-specific task dispatch to use {{.Opn}}...{{.Cls}} interpolation for OS/port/var values across tasks.
Task command argument quoting updates
v3/internal/templates/_common/Taskfile.tmpl.yml, v3/internal/commands/build_assets/Taskfile.tmpl.yml
Replaced nested escaped templates with direct {{.Opn}}.<VAR>{{.Cls}} usage in command args and labels (e.g., build, dev, docker, generate:bindings).

Template engine & build-assets Go changes

Layer / File(s) Summary
Template options fields
v3/internal/templates/templates.go
Added exported Opn and Cls fields to TemplateOptions and initialize them ("{{", "}}") when preparing template data.
Enrichment embedded into build/update configs
v3/internal/commands/build-assets.go
Added TemplateEnrichment type (Opn, Cls) and embedded it into BuildConfig and UpdateConfig; set config.Opn/config.Cls before template extraction.
Minor getter refactor
v3/internal/commands/build-assets.go
Small body refactor for GetCFBundleIconName() (no behavioral change).

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • wailsapp/wails#4023: Overlaps on Taskfile templating for passing BUILD_FLAGS/PRODUCTION into binding generation.
  • wailsapp/wails#3748: Related Taskfile dispatch and OS-scoped task refactor.

Suggested labels

Enhancement, size:XL

Suggested reviewers

  • leaanthony

Poem

🐰 I hopped through templates, tags in tow,
Opn and Cls to make things flow,
npm, yarn, pnpm, bun—choose a way,
Tasks now route and dev servers play,
A carrot-cheer for builds today!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete. Critical sections are missing: issue reference, type of change checkboxes are incomplete, testing details are vague, and the required checklist items are mostly unchecked. Add proper issue reference (Fixes #5125), complete the checklist with meaningful details about testing, and document how the changes were verified.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is partially related to the changeset. It describes control of the frontend package manager, which is a main change, but is truncated and incomplete. Complete the title to show the full intent: 'Modify Taskfiles to allow control of frontend package manager via PACKAGE_MANAGER variable' or similar.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch package_management

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@symball

symball commented Apr 10, 2026

Copy link
Copy Markdown
Contributor Author

Hmm, Now I get to review the full changes, I can see that my editor has attempted to auto cleanup some stuff it possibly shouldn't have. I'll check this in the morning whilst testing on Windows and Linux

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
v3/internal/commands/build_assets/Taskfile.tmpl.yml (1)

12-13: Validate PACKAGE_MANAGER before dispatching.

These dispatchers build task names dynamically from PACKAGE_MANAGER. Adding requires.vars.enum here would make unsupported values fail fast with a clear validation error instead of falling through to dynamic task lookup. Task supports enum validation specifically for string vars. (taskfile.dev)

🧭 Suggested guard
   install:frontend:deps:
     summary: Install frontend dependencies
+    requires:
+      vars:
+        - name: PACKAGE_MANAGER
+          enum: [npm, yarn, pnpm, bun]
     cmds:
       - task: install:frontend:deps:{{.PACKAGE_MANAGER}}

Apply the same guard to frontend:run and dev:frontend.

Also applies to: 92-94, 197-197

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@v3/internal/commands/build_assets/Taskfile.tmpl.yml` around lines 12 - 13,
Validate PACKAGE_MANAGER in the Taskfile template by adding requires.vars.enum
entries for the tasks that dynamically use it (the task entries that call
install:frontend:deps:{{.PACKAGE_MANAGER}}, frontend:run:{{.PACKAGE_MANAGER}}
and dev:frontend:{{.PACKAGE_MANAGER}}) so unsupported values fail fast; update
the Taskfile.tmpl.yml task definitions around the dynamic dispatch points to
include requires.vars.enum with the allowed string options (e.g., "npm", "yarn",
"pnpm") and apply the same guard for the other occurrences referenced (lines
around the install:frontend:deps, frontend:run and dev:frontend dispatchers).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@v3/internal/commands/build_assets/Taskfile.tmpl.yml`:
- Around line 28-39: The install:frontend:deps:bun task only lists bun.lockb as
a source, so dependency changes in Bun's text lockfile (bun.lock) won't
retrigger installs; update the Taskfile.tmpl.yml task named
install:frontend:deps:bun to include both "bun.lock" and "bun.lockb" in the
sources array (in addition to package.json) so the freshness detection watches
either lockfile and re-runs bun install when either changes.
- Around line 54-65: The task install:frontend:deps:yarn currently lists
generates: node_modules which fails with Yarn PnP; update the task to remove or
replace generates and add a status check that succeeds if either the PnP runtime
file exists or node_modules exists (e.g. a shell status like "sh: test -f
.pnp.cjs || test -f .pnp.js || test -d node_modules") so Taskfile freshness is
correct for both Yarn v2+ PnP and classic linkers; keep the existing dir,
sources and cmds and only change the generates -> status portion in the
install:frontend:deps:yarn task.

In `@v3/internal/templates/_common/Taskfile.tmpl.yml`:
- Line 4: Replace the hardcoded APP_NAME value ("wails3app") with the template
variable that injects the generated project name so downstream tasks (wails3
update build-assets, server binary naming, and Docker tag defaults) use the
actual project name; update the APP_NAME entry in Taskfile.tmpl to reference the
project-name template placeholder used elsewhere (the same placeholder used for
binary/Docker naming) so generated projects get their correct name.

---

Nitpick comments:
In `@v3/internal/commands/build_assets/Taskfile.tmpl.yml`:
- Around line 12-13: Validate PACKAGE_MANAGER in the Taskfile template by adding
requires.vars.enum entries for the tasks that dynamically use it (the task
entries that call install:frontend:deps:{{.PACKAGE_MANAGER}},
frontend:run:{{.PACKAGE_MANAGER}} and dev:frontend:{{.PACKAGE_MANAGER}}) so
unsupported values fail fast; update the Taskfile.tmpl.yml task definitions
around the dynamic dispatch points to include requires.vars.enum with the
allowed string options (e.g., "npm", "yarn", "pnpm") and apply the same guard
for the other occurrences referenced (lines around the install:frontend:deps,
frontend:run and dev:frontend dispatchers).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 41df8685-585a-4e54-b34b-f887afddbdeb

📥 Commits

Reviewing files that changed from the base of the PR and between bb4fbf9 and 52355af.

📒 Files selected for processing (2)
  • v3/internal/commands/build_assets/Taskfile.tmpl.yml
  • v3/internal/templates/_common/Taskfile.tmpl.yml

Comment thread v3/internal/commands/build_assets/Taskfile.tmpl.yml
Comment thread v3/internal/commands/build_assets/Taskfile.tmpl.yml
Comment thread v3/internal/templates/_common/Taskfile.tmpl.yml Outdated
@symball symball force-pushed the package_management branch from 52355af to 2178aaf Compare April 12, 2026 00:18
@symball

symball commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

This PR now extends the template data to include {{.Opn}} and {{.Cls}} to make writing out template tags within the template more reliable

@symball symball force-pushed the package_management branch from 2178aaf to dd482b1 Compare April 12, 2026 00:23

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@v3/internal/commands/build_assets/Taskfile.tmpl.yml`:
- Line 326: The log line contains a duplicated echo token ("echo echo \"Building
for device: UDID={{.Opn}}.UDID{{.Cls}} SCHEME={{.Opn}}.SCHEME{{.Cls}}
PROJECT={{.Opn}}.PROJECT{{.Cls}}\""); remove the extra leading "echo" so the
command is a single echo that prints the template string—locate the template
line containing the duplicated echo and edit it to use one echo while keeping
the {{.Opn}} and {{.Cls}} placeholders intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c0e8cd2d-5e29-49e7-8678-5962b25a3f56

📥 Commits

Reviewing files that changed from the base of the PR and between 52355af and 2178aaf.

📒 Files selected for processing (4)
  • v3/internal/commands/build-assets.go
  • v3/internal/commands/build_assets/Taskfile.tmpl.yml
  • v3/internal/templates/_common/Taskfile.tmpl.yml
  • v3/internal/templates/templates.go

Comment thread v3/internal/commands/build_assets/Taskfile.tmpl.yml Outdated
…sed via `PACKAGE_MANAGER` option

* Enrich template data with `{{.Opn}}` and `{{.Cls}}` to make writing Taskfile templates more predictable
@symball symball force-pushed the package_management branch from dd482b1 to d93a6b9 Compare April 12, 2026 00:25

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@v3/internal/commands/build_assets/Taskfile.tmpl.yml`:
- Around line 12-13: The task dispatchers in Taskfile.tmpl.yml use
{{.PACKAGE_MANAGER}} without a fallback, causing unresolved task names for
projects whose root Taskfile doesn't define PACKAGE_MANAGER; update each
dispatcher occurrence (e.g., the dispatch strings used by
install:frontend:deps:{{.Opn}}.PACKAGE_MANAGER{{.Cls}},
frontend:run:{{.Opn}}.PACKAGE_MANAGER{{.Cls}}, and
frontend:dev:{{.Opn}}.PACKAGE_MANAGER{{.Cls}}) to include an inline default
fallback (| default "npm") so the generated dispatch becomes
install:frontend:deps:{{.Opn}}.PACKAGE_MANAGER | default "npm"{{.Cls}} (and
similarly for the other two dispatchers) to preserve backward compatibility.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 50b138a1-8cea-426f-9c4d-84b385177af0

📥 Commits

Reviewing files that changed from the base of the PR and between 2178aaf and d93a6b9.

📒 Files selected for processing (5)
  • v3/UNRELEASED_CHANGELOG.md
  • v3/internal/commands/build-assets.go
  • v3/internal/commands/build_assets/Taskfile.tmpl.yml
  • v3/internal/templates/_common/Taskfile.tmpl.yml
  • v3/internal/templates/templates.go
✅ Files skipped from review due to trivial changes (1)
  • v3/UNRELEASED_CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • v3/internal/commands/build-assets.go

Comment thread v3/internal/commands/build_assets/Taskfile.tmpl.yml
@leaanthony leaanthony changed the base branch from v3-alpha to master April 29, 2026 13:08
@leaanthony

Copy link
Copy Markdown
Member

Triaged by Wails PR Reviewer

This PR has been reviewed and accepted. Test sub-issues have been created for all platforms.

Head Ref OID: d93a6b984e7ded649cc677e7a42ddf2c7bc62863


This comment serves as a signature that this PR has been triaged. Future runs will skip this PR based on the headRefOid.

@taliesin-ai

Copy link
Copy Markdown
Collaborator

CI failure root cause: -clean=true-ts flag concatenation

All TypeScript template variants are failing with:

Error: invalid boolean value "true-ts" for -clean: parse error

The problem is in v3/internal/commands/build_assets/Taskfile.tmpl.yml. The {{- trim-left dash strips the whitespace before the action, causing -ts to be appended directly onto -clean=true:

# Current (broken for -ts templates):
- wails3 generate bindings -f '{{.Opn}}.BUILD_FLAGS{{.Cls}}' -clean=true {{- if .Typescript}}-ts{{end}}
#                                                                                  ^^ trim dash eats the space

Fix — move the space inside the {{if}} block and drop the trim dash:

-      - wails3 generate bindings -f '{{.Opn}}.BUILD_FLAGS{{.Cls}}' -clean=true {{- if .Typescript}}-ts{{end}}
+      - wails3 generate bindings -f '{{.Opn}}.BUILD_FLAGS{{.Cls}}' -clean=true{{if .Typescript}} -ts{{end}}

This gives:

  • TypeScript templates: -clean=true -ts
  • Non-TypeScript templates: -clean=true

Non-TypeScript templates pass today because the {{if}} block is skipped entirely, leaving -clean=true intact. This is a one-line fix in v3/internal/commands/build_assets/Taskfile.tmpl.yml.


Taliesin is an AI agent. CC @leaanthony

The `{{- if .Typescript}}` trim-left dash strips the whitespace before
the action, so moving `-ts` outside the `{{if}}` block (and dropping the
trim dash) keeps `-clean=true` and ` -ts` separated. Without this,
TypeScript templates produced `-clean=true-ts`, which fails parsing.
# Conflicts:
#	v3/internal/commands/build-assets.go
#	v3/internal/commands/build_assets/Taskfile.tmpl.yml
@leaanthony leaanthony enabled auto-merge (squash) May 15, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants