-
Notifications
You must be signed in to change notification settings - Fork 559
Stylus CLI updates #7502
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
base: main
Are you sure you want to change the base?
Stylus CLI updates #7502
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe code introduces an "ERC721" project template option to the CLI's project creation flow. It adds logic to handle this new type by cloning a specific repository, consolidates project creation into a single variable, and unifies error handling after all project types are attempted. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant GitRepo
User->>CLI: Select project type (ERC20, ERC721, etc.)
CLI->>CLI: Assign newProject via spawnSync (based on type)
alt type is ERC721
CLI->>GitRepo: Clone ERC721 template repo
else type is other
CLI->>GitRepo: Clone/copy corresponding template
end
CLI->>CLI: Check newProject status
alt Success
CLI->>User: Project created
else Failure
CLI->>User: Show error and exit
end
Possibly related PRs
Suggested labels
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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. |
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: 2
🧹 Nitpick comments (1)
packages/thirdweb/src/cli/commands/stylus/create.ts (1)
66-72
: Consider refactoring to reduce code duplication.The ERC721 branch is nearly identical to the ERC20 branch, differing only in the repository URL and spinner message. Consider extracting the common logic into a helper function.
+ const cloneTemplate = (templateType: string, repoUrl: string, projectName: string) => { + spinner.start(`Creating new ${templateType} Stylus project: ${projectName}...`); + return spawnSync("git", ["clone", repoUrl, 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", - }); + newProject = cloneTemplate("ERC20", "git@github.com:thirdweb-example/stylus-erc20-template.git", projectName); } else if (projectType === "erc721") { - const repoUrl = "git@github.com:thirdweb-example/stylus-erc721-template.git"; - spinner.start(`Creating new ERC721 Stylus project: ${projectName}...`); - newProject = spawnSync("git", ["clone", repoUrl, projectName], { - stdio: "inherit", - }); + newProject = cloneTemplate("ERC721", "git@github.com:thirdweb-example/stylus-erc721-template.git", projectName);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/thirdweb/src/cli/commands/stylus/create.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{ts,tsx}`: Write idiomatic TypeScript with explicit function declarations ...
**/*.{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
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
📄 Source: CodeRabbit Inference Engine (CLAUDE.md)
List of files the instruction was applied to:
packages/thirdweb/src/cli/commands/stylus/create.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T10:25:29.488Z
Learning: Surface breaking changes prominently in PR descriptions
Learnt from: MananTank
PR: thirdweb-dev/js#7315
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/form.ts:25-42
Timestamp: 2025-06-10T00:46:00.514Z
Learning: In NFT creation functions, the setClaimConditions function signatures are intentionally different between ERC721 and ERC1155. ERC721 setClaimConditions accepts the full CreateNFTFormValues, while ERC1155 setClaimConditions accepts a custom object with nftCollectionInfo and nftBatch parameters because it processes batches differently than the entire form data.
packages/thirdweb/src/cli/commands/stylus/create.ts (1)
Learnt from: MananTank
PR: thirdweb-dev/js#7434
File: apps/dashboard/src/app/(app)/team/~/~/contract/[chain]/[contractAddress]/components/project-selector.tsx:62-76
Timestamp: 2025-06-24T21:38:03.155Z
Learning: In the project-selector.tsx component for contract imports, the addToProject.mutate() call is intentionally not awaited (fire-and-forget pattern) to allow immediate navigation to the contract page while the import happens in the background. This is a deliberate design choice to prioritize user experience.
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: Unit Tests
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Size
- GitHub Check: Build Packages
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Lint Packages
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/thirdweb/src/cli/commands/stylus/create.ts (1)
46-46
: LGTM: ERC721 template option added correctly.The new ERC721 template option follows the existing pattern and integrates well with the project type selection.
], | ||
message: "Select a template:", | ||
name: "projectType", | ||
type: "select", | ||
}); | ||
|
||
// Step 5: Create the project | ||
let newProject; |
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.
Add explicit type annotation to comply with coding guidelines.
The variable declaration violates the coding guidelines which require explicit types and avoiding any
. The implicit any
type should be replaced with the proper return type.
- let newProject;
+ let newProject: ReturnType<typeof spawnSync>;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
let newProject; | |
let newProject: ReturnType<typeof spawnSync>; |
🤖 Prompt for AI Agents
In packages/thirdweb/src/cli/commands/stylus/create.ts at line 54, the variable
newProject is declared without an explicit type, causing an implicit any type
violation. Add an explicit type annotation to newProject that matches the
expected return type of the value it will hold, ensuring compliance with coding
guidelines that forbid implicit any types.
if (!newProject?.status || newProject.status !== 0) { | ||
spinner.fail("Failed to create Stylus project."); | ||
process.exit(1); | ||
} |
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.
🛠️ Refactor suggestion
Add explicit handling for unexpected project types.
The unified error handling is good, but if projectType
doesn't match any known values, newProject
remains undefined and triggers the error condition. Consider adding an explicit else clause or validation.
+ } else {
+ spinner.fail(`Unknown project type: ${projectType}`);
+ process.exit(1);
+ }
+
- if (!newProject?.status || newProject.status !== 0) {
+ if (!newProject || newProject.status !== 0) {
This makes the error handling more explicit and removes the need for optional chaining since newProject
will always be defined at this point.
🤖 Prompt for AI Agents
In packages/thirdweb/src/cli/commands/stylus/create.ts around lines 74 to 77,
add explicit validation for the projectType before creating newProject to ensure
it matches known values. Include an else clause that handles unexpected
projectType values by setting newProject to a defined error state or throwing an
error. This will guarantee newProject is always defined, allowing you to remove
optional chaining and make error handling more explicit and clear.
size-limit report 📦
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7502 +/- ##
==========================================
+ Coverage 51.93% 51.96% +0.03%
==========================================
Files 950 952 +2
Lines 64163 64224 +61
Branches 4229 4237 +8
==========================================
+ Hits 33326 33377 +51
- Misses 30731 30740 +9
- Partials 106 107 +1
🚀 New features to boost your workflow:
|
PR-Codex overview
This PR focuses on enhancing the
Stylus
extension in thethirdweb
SDK by adding new functionalities for contract deployment and event handling, including thestylus_constructor
anddeploy
methods, along with their respective event definitions.Detailed summary
stylus_constructor
function inIStylusConstructor.json
.deploy
function andContractDeployed
event inIStylusDeployer.json
.contractDeployedEvent
inIStylusDeployer/events/ContractDeployed.ts
.isStylus_constructorSupported
andstylus_constructor
functions instylus_constructor.ts
.deployContract
logic to handleStylus
deployment.isDeploySupported
andencodeDeployParams
functions inIStylusDeployer/write/deploy.ts
.createStylusProject
command to support multiple project types.Summary by CodeRabbit
New Features
Improvements