-
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,17 +1,10 @@ | ||||||||||||||||||||||||
| import fs from "fs-extra"; | ||||||||||||||||||||||||
| import path from "path"; | ||||||||||||||||||||||||
| import { fileURLToPath } from "url"; | ||||||||||||||||||||||||
| import { downloadTemplate } from "giget"; | ||||||||||||||||||||||||
| import { BaseAction } from "../../lib/actions/BaseAction"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export class NewAction extends BaseAction { | ||||||||||||||||||||||||
| private templatePath: string; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| constructor() { | ||||||||||||||||||||||||
| super(); | ||||||||||||||||||||||||
| const __filename = fileURLToPath(import.meta.url); | ||||||||||||||||||||||||
| const basePath = path.resolve(path.dirname(__filename), ".."); | ||||||||||||||||||||||||
| this.templatePath = path.join(basePath, "templates", "default"); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| private readonly templateSource = "github:genlayerlabs/genlayer-project-boilerplate"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| async createProject(projectName: string, options: { path: string; overwrite: boolean }) { | ||||||||||||||||||||||||
| const targetPath = path.resolve(options.path, projectName); | ||||||||||||||||||||||||
|
|
@@ -25,7 +18,13 @@ export class NewAction extends BaseAction { | |||||||||||||||||||||||
| this.startSpinner(`Creating new GenLayer project: ${projectName}`); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| fs.copySync(this.templatePath, targetPath); | ||||||||||||||||||||||||
| await downloadTemplate(this.templateSource, { | ||||||||||||||||||||||||
| dir: targetPath, | ||||||||||||||||||||||||
| force: options.overwrite, | ||||||||||||||||||||||||
| offline: false, | ||||||||||||||||||||||||
| install: false, | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
Comment on lines
+21
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reconsider the hardcoded The PR description mentions "built-in caching for faster subsequent scaffolds" as a key benefit, but
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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| this.succeedSpinner(`Project "${projectName}" created successfully at ${targetPath}`); | ||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||
| this.failSpinner(`Error creating project "${projectName}"`, error); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.