-
Notifications
You must be signed in to change notification settings - Fork 3
feat: download boilerplate from repo instead of local template #264
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?
Conversation
Updates 'genlayer new' to download the latest boilerplate directly from genlayerlabs/genlayer-project-boilerplate instead of using a local copy. This ensures users always get the most up-to-date template. Fixes genlayerlabs#263
WalkthroughReplaces local scaffold templates with a remote download: adds Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant CLI
participant giget
participant GitHub
participant FS as "Filesystem"
User->>CLI: genlayer new <project-name>
CLI->>CLI: compute targetPath, check overwrite flag
alt target exists & no overwrite
CLI-->>User: error "target path exists"
else
CLI->>giget: downloadTemplate(templateSource, targetPath)
giget->>GitHub: fetch repository archive (github:genlayerlabs/genlayer-project-boilerplate)
GitHub-->>giget: return archive/files
giget->>FS: extract and write files to targetPath
FS-->>giget: write complete
giget-->>CLI: download complete
CLI-->>User: success "project created"
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. 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: 2
🧹 Nitpick comments (1)
src/commands/scaffold/new.ts (1)
29-31: Consider more specific error handling for common failure scenarios.The current generic error handling doesn't distinguish between different failure modes (network errors, rate limiting, repository not found, etc.), making it harder for users to troubleshoot issues.
} catch (error) { - this.failSpinner(`Error creating project "${projectName}"`, error); + const errorMessage = error instanceof Error ? error.message : String(error); + + if (errorMessage.includes('404') || errorMessage.includes('not found')) { + this.failSpinner(`Template repository not found. Please check your internet connection or try again later.`); + } else if (errorMessage.includes('rate limit')) { + this.failSpinner(`GitHub rate limit exceeded. Please try again later.`); + } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('network')) { + this.failSpinner(`Network error: Unable to download template. Check your internet connection.`); + } else { + this.failSpinner(`Error creating project "${projectName}"`, error); + } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
package-lock.jsonis excluded by!**/package-lock.jsontemplates/default/app/public/favicon.pngis excluded by!**/*.pngtemplates/default/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (35)
package.json(1 hunks)src/commands/scaffold/new.ts(2 hunks)templates/default/LICENSE(0 hunks)templates/default/README.md(0 hunks)templates/default/app/.env.example(0 hunks)templates/default/app/.gitignore(0 hunks)templates/default/app/.vscode/extensions.json(0 hunks)templates/default/app/README.md(0 hunks)templates/default/app/index.html(0 hunks)templates/default/app/package.json(0 hunks)templates/default/app/postcss.config.js(0 hunks)templates/default/app/src/App.vue(0 hunks)templates/default/app/src/components/Address.vue(0 hunks)templates/default/app/src/components/BetsScreen.vue(0 hunks)templates/default/app/src/logic/FootballBets.js(0 hunks)templates/default/app/src/main.js(0 hunks)templates/default/app/src/services/genlayer.js(0 hunks)templates/default/app/src/style.css(0 hunks)templates/default/app/tailwind.config.js(0 hunks)templates/default/app/vite.config.js(0 hunks)templates/default/config/genlayer_config.py(0 hunks)templates/default/contracts/football_bets.py(0 hunks)templates/default/deploy/deployScript.ts(0 hunks)templates/default/package.json(0 hunks)templates/default/requirements.txt(0 hunks)templates/default/test/football_bets_get_contract_schema_for_code.py(0 hunks)templates/default/test/test_football_bet.py(0 hunks)templates/default/tools/accounts.py(0 hunks)templates/default/tools/calldata.py(0 hunks)templates/default/tools/request.py(0 hunks)templates/default/tools/response.py(0 hunks)templates/default/tools/structure.py(0 hunks)templates/default/tools/transactions.py(0 hunks)templates/default/tools/types.py(0 hunks)templates/default/tsconfig.json(0 hunks)
💤 Files with no reviewable changes (33)
- templates/default/app/tailwind.config.js
- templates/default/app/.vscode/extensions.json
- templates/default/LICENSE
- templates/default/tools/structure.py
- templates/default/app/src/components/Address.vue
- templates/default/app/postcss.config.js
- templates/default/app/.env.example
- templates/default/app/src/services/genlayer.js
- templates/default/package.json
- templates/default/deploy/deployScript.ts
- templates/default/config/genlayer_config.py
- templates/default/tsconfig.json
- templates/default/tools/types.py
- templates/default/app/index.html
- templates/default/app/src/main.js
- templates/default/app/src/logic/FootballBets.js
- templates/default/app/README.md
- templates/default/tools/request.py
- templates/default/requirements.txt
- templates/default/contracts/football_bets.py
- templates/default/README.md
- templates/default/app/vite.config.js
- templates/default/tools/calldata.py
- templates/default/app/package.json
- templates/default/app/src/components/BetsScreen.vue
- templates/default/tools/accounts.py
- templates/default/app/.gitignore
- templates/default/tools/response.py
- templates/default/app/src/style.css
- templates/default/tools/transactions.py
- templates/default/test/test_football_bet.py
- templates/default/test/football_bets_get_contract_schema_for_code.py
- templates/default/app/src/App.vue
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-10T23:50:34.628Z
Learnt from: epsjunior
Repo: genlayerlabs/genlayer-cli PR: 239
File: package.json:60-66
Timestamp: 2025-07-10T23:50:34.628Z
Learning: In the genlayer-cli project, dotenv is used with manual parsing via dotenv.parse() rather than automatic loading via dotenv.config(), so warnings about implicit .env.local auto-loading changes in dotenv v17 are not applicable to this project.
Applied to files:
package.json
🧬 Code graph analysis (1)
src/commands/scaffold/new.ts (1)
src/lib/actions/BaseAction.ts (1)
BaseAction(14-236)
🔇 Additional comments (2)
src/commands/scaffold/new.ts (1)
7-7: Template repository verified as accessible and operational.The repository
genlayerlabs/genlayer-project-boilerplateis public, not archived, and actively maintained with the main branch available for scaffolding.package.json (1)
69-69: Dependency verification complete—no issues found.Version
^2.0.0is the latest release, and there are no known security vulnerabilities for giget.
| await downloadTemplate(this.templateSource, { | ||
| dir: targetPath, | ||
| force: options.overwrite, | ||
| offline: false, | ||
| install: false, | ||
| }); |
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.
Reconsider the hardcoded offline: false setting.
The PR description mentions "built-in caching for faster subsequent scaffolds" as a key benefit, but offline: false explicitly disables offline mode. This means:
- Users cannot scaffold projects without internet access
- Cached templates won't be used, contradicting the claimed caching benefit
- Network failures will always cause the operation to fail
Consider allowing giget to use its default offline behavior or make it configurable:
- await downloadTemplate(this.templateSource, {
- dir: targetPath,
- force: options.overwrite,
- offline: false,
- install: false,
- });
+ await downloadTemplate(this.templateSource, {
+ dir: targetPath,
+ force: options.overwrite,
+ // Let giget handle caching and offline fallback automatically
+ install: false,
+ });📝 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.
| await downloadTemplate(this.templateSource, { | |
| dir: targetPath, | |
| force: options.overwrite, | |
| offline: false, | |
| install: false, | |
| }); | |
| await downloadTemplate(this.templateSource, { | |
| dir: targetPath, | |
| force: options.overwrite, | |
| install: false, | |
| }); |
🤖 Prompt for AI Agents
In src/commands/scaffold/new.ts around lines 21 to 26 the call to
downloadTemplate hardcodes offline: false which disables giget's offline/caching
behavior and prevents scaffolding without network access; change this to respect
a passed-in option or omit the offline property so giget uses its default
behavior—either wire a new CLI flag (e.g., options.offline) and pass that value,
or remove the offline key entirely to allow giget to use its built-in
cache/offline mode, and update any docs/CLI help accordingly.
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: 0
♻️ Duplicate comments (1)
src/commands/scaffold/new.ts (1)
21-26: Revisitoffline: falseto preserve caching/offline behavior.Setting
offline: falseforces a network fetch every time and prevents using giget’s cached copy in offline scenarios, which undercuts the stated benefits (“built‑in caching”, offline scaffolding). Consider either:
- Letting giget use its default by omitting the flag, or
- Wiring this to a CLI/config option (e.g.,
--offlineor--no-offline) instead of hardcoding.For example:
- await downloadTemplate(this.templateSource, { - dir: targetPath, - force: options.overwrite, - offline: false, - install: false, - }); + await downloadTemplate(this.templateSource, { + dir: targetPath, + force: options.overwrite, + // Let giget manage cache/offline mode, or pass a user-controlled option + install: false, + });Since this relies on giget’s semantics, please confirm in the current giget docs that
offline: falseindeed disables cache/offline usage and that omitting it (or wiring to a flag) gives the desired behavior.
🧹 Nitpick comments (1)
src/commands/scaffold/new.ts (1)
4-8: Pinned template source is good for stability; consider alias import & configurability.Nice job pinning
templateSourceto#v0.2.0—this avoids accidental breakage from default‑branch changes. Two small follow‑ups to consider:
- Import
BaseActionvia the configured path alias for consistency with the guidelines:-import { BaseAction } from "../../lib/actions/BaseAction"; +import { BaseAction } from "@/lib/actions/BaseAction";
- Your PR description emphasizes “latest boilerplate” and “template updates do not require CLI package updates”; pinning to a tag gives stability but means template updates now require either changing this constant or making it configurable (e.g., via config/flag). You may want to either make the ref configurable or adjust docs/PR copy so expectations match behavior.
As per coding guidelines, imports under
src/*should use the@/*alias. Please also double‑check that the pinned tagv0.2.0and the stated behavior in docs/PR description are aligned.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
package.json(1 hunks)src/commands/scaffold/new.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- package.json
🧰 Additional context used
📓 Path-based instructions (2)
src/commands/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
All CLI action classes must extend
BaseActionfromsrc/lib/actions/BaseAction.tswhich provides GenLayer client initialization, keystore management, spinner/logging utilities, and user prompts
Files:
src/commands/scaffold/new.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use
@/*path alias to reference./src/*and@@/tests/*path alias to reference./tests/*in imports
Files:
src/commands/scaffold/new.ts
🧠 Learnings (1)
📚 Learning: 2025-12-03T23:03:32.323Z
Learnt from: CR
Repo: genlayerlabs/genlayer-cli PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T23:03:32.323Z
Learning: Applies to src/commands/**/*.ts : All CLI action classes must extend `BaseAction` from `src/lib/actions/BaseAction.ts` which provides GenLayer client initialization, keystore management, spinner/logging utilities, and user prompts
Applied to files:
src/commands/scaffold/new.ts
🧬 Code graph analysis (1)
src/commands/scaffold/new.ts (1)
src/lib/actions/BaseAction.ts (1)
BaseAction(48-295)
🔇 Additional comments (1)
src/commands/scaffold/new.ts (1)
3-3: ImportingdownloadTemplatefromgigetlooks correct.The import aligns with how
downloadTemplateis used below; no issues here.
Updates
genlayer newto download the latest boilerplate directly fromgenlayerlabs/genlayer-project-boilerplateinstead of using a local copy in thetemplates/directory.Changes
gigetfor downloading from GitHubtemplates/directory (272KB saved)Benefits
Fixes #263
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.