Skip to content

Conversation

@albert-mr
Copy link

@albert-mr albert-mr commented Nov 14, 2025

Updates genlayer new to download the latest boilerplate directly from genlayerlabs/genlayer-project-boilerplate instead of using a local copy in the templates/ directory.

Changes

  • Replace local template copying with giget for downloading from GitHub
  • Remove local templates/ directory (272KB saved)
  • Users now always get the most up-to-date template

Benefits

  • 2-3x faster scaffolding (2-5s vs 5-15s)
  • No Git installation required
  • Built-in caching for faster subsequent scaffolds
  • Template updates don't require CLI package updates

Fixes #263

Summary by CodeRabbit

  • New Features

    • Scaffolding now downloads project templates from a remote source for up-to-date starters.
  • Chores

    • Added a new runtime dependency to enable remote template downloads.
    • Default example template content and many bundled example files were removed or simplified, producing a leaner starter template.

✏️ Tip: You can customize this high-level summary in your review settings.

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
@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

Walkthrough

Replaces local scaffold templates with a remote download: adds giget dependency and updates the scaffold command to fetch github:genlayerlabs/genlayer-project-boilerplate; deletes the entire templates/default/ tree and switches project creation to downloadTemplate into the target path, with an overwrite pre-check.

Changes

Cohort / File(s) Summary
Dependency Addition
package.json
Added runtime dependency: giget (^2.0.0).
Scaffold Command Refactor
src/commands/scaffold/new.ts
Removed constructor/local template path logic; added templateSource constant; replaced local copy with await downloadTemplate(templateSource, targetPath) from giget; added pre-check to fail when target exists and overwrite is false; updated imports.
Template Directory Removal
Templates
templates/default/*, templates/default/app/**, templates/default/contracts/**, templates/default/tools/**, templates/default/test/**, templates/default/**/...
Deleted entire default project template tree: frontend app files (HTML, Vue components, package/configs, styles, Vite/Tailwind configs), Python contract football_bets.py and related tests, deploy script, tooling modules (calldata, request, transactions, types, response, structure, accounts), configs, docs, and requirements/package files.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Focus review on:
    • src/commands/scaffold/new.ts — async download flow, error handling, overwrite pre-check, and import changes.
    • package.json — dependency addition and any packaging impacts.
    • Codepaths or tooling that previously relied on templates/default/ (ensure no runtime assumptions remain).

Possibly related PRs

  • chore: updating boilerplate #223: Edits to templates/default/contracts/football_bets.py — related because this PR removes that contract and its tests; reconcile differences with the remote template.

Suggested reviewers

  • cristiam86

Poem

🐇
I hopped to fetch a template far away,
From local burrows to GitHub's bright day.
With giget I dug and pulled files free,
New project seeds sown — a carrot for me! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing local template copying with remote template downloading via giget.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from issue #263: downloading boilerplate from the genlayerlabs/genlayer-project-boilerplate repository instead of using local templates.
Out of Scope Changes check ✅ Passed The deletion of the entire templates/ directory is directly scoped to the PR objective of removing local templates in favor of remote downloads.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9e40693 and f234757.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

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.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 26ea482 and 22a204f.

⛔ Files ignored due to path filters (3)
  • package-lock.json is excluded by !**/package-lock.json
  • templates/default/app/public/favicon.png is excluded by !**/*.png
  • templates/default/package-lock.json is 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-boilerplate is 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.0 is the latest release, and there are no known security vulnerabilities for giget.

Comment on lines +21 to +26
await downloadTemplate(this.templateSource, {
dir: targetPath,
force: options.overwrite,
offline: false,
install: false,
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
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.

Copy link

@coderabbitai coderabbitai bot left a 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: Revisit offline: false to preserve caching/offline behavior.

Setting offline: false forces 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., --offline or --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: false indeed 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 templateSource to #v0.2.0—this avoids accidental breakage from default‑branch changes. Two small follow‑ups to consider:

  • Import BaseAction via 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 tag v0.2.0 and the stated behavior in docs/PR description are aligned.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22a204f and 9e40693.

⛔ Files ignored due to path filters (1)
  • package-lock.json is 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 BaseAction from src/lib/actions/BaseAction.ts which 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: Importing downloadTemplate from giget looks correct.

The import aligns with how downloadTemplate is used below; no issues here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"genlayer new" to download boilerplate from repo

2 participants