fix(cli): stop an explicit --wallet-provider being discarded in silence - #461
Conversation
Four templates cannot honour --wallet-provider, for two different reasons, and the difference was restated in four places that had drifted apart. Move the list and both reasons into utils/templates.ts and read it everywhere. The skip messages claimed every affected template "uses its own wallet components", which is false for x402 and ai-chat: they ship none, and that is precisely why the flag cannot be applied. minipay was missing from the forcing altogether. It writes connect-button.tsx and wallet-provider.tsx, the same filenames the thirdweb template writes, so `-t minipay --wallet-provider thirdweb` aborted with "File already exists", exited 1 and left a half-written project. Also align the thirdweb lib guard with its components guard. Closes celo-org#453 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fd514c8 to
5a6cb5b
Compare
GigaHierz
left a comment
There was a problem hiding this comment.
Items 1–3 are right and well-executed — the warning at the final resolution point, the per-template skip reasons, the shared list ending the four-way drift, and the spawnSync test harness are all exactly what #453 asked for. The minipay collision discovery is real too (verified the mechanics: on main, minipay is absent from the forcing, so an explicit thirdweb flag runs both component actions onto the same filenames and plop aborts).
But the chosen fix for it introduces a worse regression, verified by scaffolding from this branch:
tsx src/index.ts create mp-check -t minipay --skip-install -y
grep -E "rainbowkit|wagmi|viem|react-query" mp-check/apps/web/package.json
# → no matchesEvery default minipay scaffold now ships without its wallet stack. Putting minipay in the shared list makes ignoresWalletProvider force walletProvider = "none" — but minipay's own components are built on the rainbowkit/wagmi stack (wallet-provider.tsx imports RainbowKitProvider/WagmiProvider/QueryClientProvider, user-balance.tsx uses wagmi hooks), and the manifest template gates all four deps on walletProvider === "rainbowkit" (@rainbow-me/rainbowkit directly; viem/wagmi via the rainbowkit-or-farcaster guard from #450; react-query via #428's guard). With "none", none of them land, and the navbar also loses its connect-button import (its guard is rainbowkit-or-thirdweb), so minipay's own ConnectButton is never rendered. On main, minipay defaults to rainbowkit and all of this works — this branch breaks it.
Suggested shape: minipay isn't "ignores the flag → none"; it requires rainbowkit. Something like a third category in utils/templates.ts:
export const REQUIRES_WALLET: Record<string, string> = { "minipay": "rainbowkit" };
// forcing: REQUIRES_WALLET[t] ?? (SHIPS_NO_WALLET/farcaster → "none") ?? flag ?? default- Forcing minipay to
"rainbowkit"fixes the collision just as well: the rainbowkit components action already skips ontemplateType === "minipay", and the thirdweb actions skip onwalletProvider !== "thirdweb"— no same-filename writes, no crash. - The warning logic generalizes to "flag differs from the forced value" (warn for
--wallet-provider thirdweb, stay quiet for--wallet-provider rainbowkiton minipay, mirroring thenoneagreement case you already handle). walletOverrideReasonfor minipay can then say what's actually true: it ships its own rainbowkit-based components.
Test gap that let this through: the minipay fixture asserts its components exist and thirdweb's lib doesn't, but never asserts the manifest keeps the wallet deps. Please add e.g. expect(pkg.dependencies).toHaveProperty("@rainbow-me/rainbowkit") (and wagmi) to the minipay fixture — that assertion fails on this branch today and would have caught the regression.
Happy to re-verify as soon as it's revised — everything else in the PR is mergeable as-is.
Review on celo-org#461 found that the first fix for the minipay/thirdweb collision broke every default minipay scaffold. Putting minipay in the shared list forced walletProvider = "none", but minipay's own components are built on that stack — wallet-provider.tsx imports RainbowKitProvider, WagmiProvider and QueryClientProvider, and user-balance.tsx uses wagmi hooks — while the base manifest gates @rainbow-me/rainbowkit, wagmi, viem and @tanstack/react-query on walletProvider === "rainbowkit". The result was a project whose own components imported four packages it no longer declared. The list conflated two questions. They are now separate: what walletProvider must be (forcedWalletProvider) and which wallet-template files must not be written (skipsWalletTemplateFiles). minipay is in the second and takes "rainbowkit" from the first. Forcing rainbowkit closes the original collision just as well: the rainbowkit components action already skips on templateType === minipay, and both thirdweb actions skip on walletProvider !== thirdweb. The warning now fires when the flag differs from the forced value whatever that value is, so --wallet-provider rainbowkit on minipay is agreement and stays quiet, and the message names what is used instead. Adds the manifest assertion review asked for. It fails on the previous revision: reverting minipay to "none" turns 3 tests red. 28/28. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
You are right, and thank you for scaffolding it rather than reading it — I would not have found this from the diff. Revised in Reproduced your repro first, both sides: And confirmed the cause you named: The list was answering two questions at once. That is the actual defect, and your suggested shape separates them:
minipay is in the second and takes The original collision closes just as well, exactly as you predicted: the rainbowkit components action already skips on Warning generalised to "the flag differs from the forced value", and it now names the substitute: The test gap, closed the way you asked. Added Mutation-tested rather than assumed: reverting minipay to 28/28, The lesson I am taking is narrower than the bug. Every assertion in my minipay fixture was absence-shaped — thirdweb's lib is not here — with nothing asserting that what should be present still was. That is the same shape as two other misses this week, and it is now a rule I am applying rather than a note. |
|
Revision pushed in Flagging one piece of plumbing first: submitting On the fix. Your diagnosis was the right one and my original shape was wrong. I had collapsed two different questions into one list:
Putting minipay in one shared list answered both with "ignore the flag", and that is what stripped the stack. Restructured to your suggested shape: export const REQUIRES_WALLET: Record<string, string> = { minipay: "rainbowkit" };
export const SHIPS_OWN_WALLET = ["farcaster-miniapp", "minipay"];
export const SHIPS_NO_WALLET = ["ai-chat", "x402"];So minipay is now forced to rainbowkit rather than to Both sides verified by scaffolding, not by reading the diff: create mp-check -t minipay --skip-install -y
grep -E "rainbowkit|wagmi|viem|react-query" mp-check/apps/web/package.json # all four present
create mp-tw -t minipay --wallet-provider thirdweb --skip-install -y
# completes, warns that minipay requires rainbowkit, no "File already exists"Added the assertion you asked for, plus one you did not: a default-scaffold test asserting all four deps are in Ready for another look when you get to it. |
|
@GigaHierz — pinging because this one will not reach you otherwise. Submitting the The revision landed in Nothing needed from you beyond knowing it is there. |
GigaHierz
left a comment
There was a problem hiding this comment.
Re-verified the revision empirically: a default minipay scaffold now declares all four wallet packages its components import (@rainbow-me/rainbowkit, wagmi, viem, @tanstack/react-query — the regression from the first version is gone); -t minipay --wallet-provider thirdweb exits 0 with the correct warning ('ships its own rainbowkit-based wallet components. Using rainbowkit instead.'), no thirdweb lib lands, and the rainbowkit deps survive; agreement cases stay quiet. The forcedWalletProvider/skipsWalletTemplateFiles split is the right factoring — the two questions genuinely have different answers for minipay, and the file documents why. Full suite 28/28 on the branch. Nice turnaround.
Closes #453. All three items from that issue, plus a crash found while verifying item 3 that belongs with them.
1. The flag is discarded without a word
create app -t x402 --wallet-provider thirdwebexited 0 and produced a project with no thirdweb in it. The forcing is right — the plop guards skip the wallet actions regardless, so honouring the flag would only write a navbar importing a component nothing generates (#396) — but nothing told the user their flag did nothing.Now it warns, on stderr, naming the flag and the reason:
--wallet-provider nonestays quiet. That is what the forcing produces anyway, so it agrees rather than conflicts.2. The skip message was false for half the templates it covered
Skipping RainbowKit - This template uses its own wallet componentswas shown for x402 too, which ships none — which is exactly why the flag cannot be honoured there. The one explanation a user got pointed at a wallet layer that does not exist.The reason now depends on the template, and the list lives in
src/utils/templates.tsrather than being restated at each guard. That drift is the whole bug: the same fact was written in four places (the forcing, two comments beside it, and the strings) and the copies disagreed.3. The thirdweb lib guard did not match its components guard
Aligned, as the issue asks. Both now read the shared list.
The part that was not in the issue: minipay
Checking item 3 turned up a live crash rather than a latent one.
minipaywas absent from the forcing, and it writesconnect-button.tsxandwallet-provider.tsx— the same two filenames the thirdweb template writes. Nothing stopped both actions from running.On
main(666f51a):The project is left half on disk. Adding minipay to the shared list fixes it, and it is the same edit the other three items need, so separating it would mean touching these lines twice.
Flagging the scope explicitly in case you would rather I split it: the issue names farcaster-miniapp, ai-chat and x402, and this PR also changes behaviour for minipay.
Verification
Generated from this branch, with a control run each time so a guard that suppresses everything would not pass:
-t minipay --wallet-provider thirdweblib/client.ts, warns-t x402 --wallet-provider thirdweb-t basic --wallet-provider thirdweblib/client.tspresent, silent-t x402 --wallet-provider noneFour regression tests added to
template-wiring.test.ts, including the control. The helper moved fromexecFileSynctospawnSyncbecause the diagnostic is on stderr andexecFileSynconly returns stdout. 26/26 pass,tscclean,eslintclean apart from one pre-existing warning inscaffold-smoke.test.tsthat this branch does not touch.