Skip to content

Commit

Permalink
create gitignore file on init step
Browse files Browse the repository at this point in the history
  • Loading branch information
ksckaan1 committed Sep 15, 2024
1 parent 4fac4c3 commit 66e02c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/domain/core/service/project/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logs/
14 changes: 14 additions & 0 deletions internal/domain/core/service/project/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ func (*Project) createHexagoConfigs(projectPath string) error {
return nil
}

func (*Project) addGitignore(projectPath string) error {
configContent, err := assets.ReadFile("assets/.gitignore")
if err != nil {
return fmt.Errorf("assets: read file: %w", err)
}

err = os.WriteFile(filepath.Join(projectPath, ".gitignore"), configContent, 0o644)
if err != nil {
return fmt.Errorf("os: write file: %w", err)
}

return nil
}

func (*Project) createProjectSubDirs() error {
dirs := []string{
"cmd",
Expand Down
5 changes: 5 additions & 0 deletions internal/domain/core/service/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func (p *Project) InitNewProject(ctx context.Context, params dto.InitNewProjectP
return fmt.Errorf("create hexago configs: %w", err)
}

err = p.addGitignore(projectPath)
if err != nil {
return fmt.Errorf("add gitignore: %w", err)
}

if params.CreateModule {
err = p.initGoModule(ctx, params.ModuleName)
if err != nil {
Expand Down

0 comments on commit 66e02c4

Please sign in to comment.