Skip to content

Commit ad2950e

Browse files
committed
fix: yaml
1 parent 53d0d45 commit ad2950e

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

cmd/new.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,21 @@ func newList(title string, values []string) list.Model {
306306
return l
307307
}
308308

309+
func copyProjectYAML(srcPath, destDir string) error {
310+
if srcPath == "" {
311+
return nil // nothing to copy
312+
}
313+
314+
content, err := os.ReadFile(srcPath)
315+
if err != nil {
316+
return err
317+
}
318+
319+
destPath := filepath.Join(destDir, "project.yaml")
320+
321+
return os.WriteFile(destPath, content, 0644)
322+
}
323+
309324
func RunInteractiveWizard() (*ProjectInput, error) {
310325
p := tea.NewProgram(initialWizardModel())
311326
model, err := p.Run()
@@ -545,6 +560,11 @@ func createNewProject(projectName, projectRouter, template string, out io.Writer
545560
log.Fatalf("error occured while creating a new project %s: ", projectName)
546561
}
547562

563+
// ✅ COPY project.yaml if provided
564+
if err := copyProjectYAML(YAMLPath, projectName); err != nil {
565+
fmt.Fprintf(out, "warning: could not copy project.yaml: %v\n", err)
566+
}
567+
548568
// Prepare configs
549569

550570
var frameworkConfig framework.FrameworkConfig

project.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ project:
77
entities:
88
- user
99
- product
10-
- payments
10+
- payment

templates/common/project.yaml.tmpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
project:
2+
name: "{{ .ModuleName }}"
3+
port: {{ .Port }}
4+
router: "{{ .Router }}"
5+
postgres: "{{ .DBName }}"
6+
7+
entities:
8+
{{- range .Entities }}
9+
- {{ . }}
10+
{{- end }}

0 commit comments

Comments
 (0)