-
Notifications
You must be signed in to change notification settings - Fork 603
Stylus CLI updates #8235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stylus CLI updates #8235
Conversation
🦋 Changeset detectedLatest commit: c779bcf The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for GitHub.
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
WalkthroughAdds two new Stylus CLI project templates: Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant C as Stylus CLI (create)
participant G as Git (remote template repos)
U->>C: Choose projectType
alt projectType in (erc20, erc721, other-existing)
C->>G: git clone existing template repo
G-->>C: repo cloned
C-->>U: Success message
else projectType == zk-erc20
Note over C: New template branch
C->>G: git clone zk-erc20 template
G-->>C: repo cloned
C-->>U: Success message
else projectType == zk-erc721
Note over C: New template branch
C->>G: git clone zk-erc721 template
G-->>C: repo cloned
C-->>U: Success message
end
opt error
C-->>U: Error message
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/thirdweb/src/cli/commands/stylus/create.ts (1)
124-136
: Logic is correct; consider refactoring for maintainability.The new conditional branches correctly handle the ZK template types and follow the established pattern. The implementation is sound.
For future maintainability, consider refactoring the if-else chain to use a map-based approach to reduce duplication:
+const templateConfigs = { + erc20: { repo: "stylus-erc20-template", label: "ERC20" }, + erc721: { repo: "stylus-erc721-template", label: "ERC721" }, + erc1155: { repo: "stylus-erc1155-template", label: "ERC1155" }, + airdrop20: { repo: "stylus-airdrop-erc20-template", label: "Airdrop ERC20" }, + airdrop721: { repo: "stylus-airdrop-erc721-template", label: "Airdrop ERC721" }, + airdrop1155: { repo: "stylus-airdrop-erc1155-template", label: "Airdrop ERC1155" }, + "zk-erc721": { repo: "stylus-zk-erc721", label: "ZK ERC721" }, + "zk-erc20": { repo: "stylus-zk-erc20", label: "ZK ERC20" }, +}; + if (projectType === "default") { spinner.start(`Creating new Stylus project: ${projectName}...`); newProject = spawnSync("cargo", ["stylus", "new", projectName], { stdio: "inherit", }); -} else if (projectType === "erc20") { - const repoUrl = "git@github.com:thirdweb-example/stylus-erc20-template.git"; - spinner.start(`Creating new ERC20 Stylus project: ${projectName}...`); - newProject = spawnSync("git", ["clone", repoUrl, projectName], { - stdio: "inherit", - }); -} // ... similar branches for other types +} else { + const config = templateConfigs[projectType]; + if (!config) { + spinner.fail(`Unknown project type: ${projectType}`); + process.exit(1); + } + const repoUrl = `git@github.com:thirdweb-example/${config.repo}.git`; + spinner.start(`Creating new ${config.label} Stylus project: ${projectName}...`); + newProject = spawnSync("git", ["clone", repoUrl, projectName], { + stdio: "inherit", + }); }This also adds a safeguard for unexpected
projectType
values.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/thirdweb/src/cli/commands/stylus/create.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}
: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/types
or localtypes.ts
barrels
Prefer type aliases over interface except for nominal shapes
Avoidany
andunknown
unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial
,Pick
, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}
: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/types
where applicable
Prefertype
aliases overinterface
except for nominal shapes
Avoidany
andunknown
unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
packages/thirdweb/src/cli/commands/stylus/create.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
packages/thirdweb/src/cli/commands/stylus/create.ts
packages/thirdweb/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/thirdweb/**/*.{ts,tsx}
: Every public symbol must have comprehensive TSDoc with at least one compiling@example
and a custom tag (@beta
,@internal
,@experimental
, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g.,const { jsPDF } = await import("jspdf")
)
Files:
packages/thirdweb/src/cli/commands/stylus/create.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: Size
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Unit Tests
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Lint Packages
- GitHub Check: Build Packages
- GitHub Check: Analyze (javascript)
size-limit report 📦
|
PR-Codex overview
This PR introduces updates to the CLI for
stylus
, adding new project templates for zero-knowledge (ZK) ERC721 and ERC20 projects.Detailed summary
ZK ERC721
andZK ERC20
in the CLI commandcreateStylusProject
.Summary by CodeRabbit
New Features
UX Improvements