@@ -10,8 +10,8 @@ import (
1010 "strings"
1111
1212 "github.com/indaco/tempo/internal/app"
13+ "github.com/indaco/tempo/internal/apperrors"
1314 "github.com/indaco/tempo/internal/config"
14- "github.com/indaco/tempo/internal/errors"
1515 "github.com/indaco/tempo/internal/helpers"
1616 "github.com/indaco/tempo/internal/utils"
1717 "github.com/urfave/cli/v3"
@@ -75,10 +75,10 @@ func runInitCommand(cmdCtx *app.AppContext) func(ctx context.Context, cmd *cli.C
7575 cmdCtx .Logger .Info ("Generating" , tempoConfigPath )
7676 cfg , err := prepareConfig (cmdCtx .CWD , tempoRoot , templatesDir , actionsDir )
7777 if err != nil {
78- return errors .Wrap ("Failed to prepare the configuration file" , err )
78+ return apperrors .Wrap ("Failed to prepare the configuration file" , err )
7979 }
8080 if err := writeConfigFile (tempoConfigPath , cfg ); err != nil {
81- return errors .Wrap ("Failed to write the configuration file" , err , tempoConfigPath )
81+ return apperrors .Wrap ("Failed to write the configuration file" , err , tempoConfigPath )
8282 }
8383
8484 // Step 5: Log the successful initialization
@@ -100,25 +100,25 @@ func runInitCommand(cmdCtx *app.AppContext) func(ctx context.Context, cmd *cli.C
100100func validateInitPrerequisites (workingDir , configFilePath string ) error {
101101 goModPath := filepath .Join (workingDir , "go.mod" )
102102 if _ , err := os .Stat (goModPath ); os .IsNotExist (err ) {
103- return errors .Wrap ("missing go.mod file. Run 'go mod init' to create one" )
103+ return apperrors .Wrap ("missing go.mod file. Run 'go mod init' to create one" )
104104 } else if err != nil {
105- return errors .Wrap ("error checking go.mod file" , err )
105+ return apperrors .Wrap ("error checking go.mod file" , err )
106106 }
107107
108108 exists , err := utils .FileExistsFunc (configFilePath )
109109 if err != nil {
110- return errors .Wrap ("Error checking configuration file" , err )
110+ return apperrors .Wrap ("Error checking configuration file" , err )
111111 }
112112 if exists {
113113 // Check if the file is writable
114114 file , err := os .OpenFile (configFilePath , os .O_WRONLY , 0644 )
115115 if err != nil {
116- return errors .Wrap ("Failed to write the configuration file" , err )
116+ return apperrors .Wrap ("Failed to write the configuration file" , err )
117117 }
118118 if err := file .Close (); err != nil {
119- return errors .Wrap ("Failed to close the configuration file" , err )
119+ return apperrors .Wrap ("Failed to close the configuration file" , err )
120120 }
121- return errors .Wrap ("Configuration file already exists" , configFilePath )
121+ return apperrors .Wrap ("Configuration file already exists" , configFilePath )
122122 }
123123 return nil
124124}
@@ -163,32 +163,32 @@ func writeConfigFile(filePath string, cfg *config.Config) error {
163163 sb .WriteString ("# Tempo CLI configuration file\n " )
164164 sb .WriteString ("# Documentation & source code: https://github.com/indaco/tempo\n \n " )
165165 sb .WriteString ("# The root folder for tempo files\n " )
166- sb . WriteString ( fmt .Sprintf ( "tempo_root: %s\n \n " , cfg .TempoRoot ) )
166+ fmt .Fprintf ( & sb , "tempo_root: %s\n \n " , cfg .TempoRoot )
167167
168168 // Write app-specific configuration
169169 sb .WriteString ("app:\n " )
170170 sb .WriteString (" # The name of the Go module being worked on.\n " )
171- sb . WriteString ( fmt .Sprintf ( " go_module: %s\n \n " , cfg .App .GoModule ) )
171+ fmt .Fprintf ( & sb , " go_module: %s\n \n " , cfg .App .GoModule )
172172 sb .WriteString (" # The Go package name where components will be organized and generated.\n " )
173- sb . WriteString ( fmt .Sprintf ( " go_package: %s\n \n " , cfg .App .GoPackage ) )
173+ fmt .Fprintf ( & sb , " go_package: %s\n \n " , cfg .App .GoPackage )
174174 sb .WriteString (" # The directory where asset files (CSS, JS) will be generated.\n " )
175- sb . WriteString ( fmt .Sprintf ( " assets_dir: %s\n \n " , cfg .App .AssetsDir ) )
175+ fmt .Fprintf ( & sb , " assets_dir: %s\n \n " , cfg .App .AssetsDir )
176176 sb .WriteString (" # Indicates whether JavaScript is required for the component.\n " )
177- sb . WriteString ( fmt .Sprintf ( " # with_js: %s\n \n " , strconv .FormatBool (cfg .App .WithJs ) ))
177+ fmt .Fprintf ( & sb , " # with_js: %s\n \n " , strconv .FormatBool (cfg .App .WithJs ))
178178 sb .WriteString (" # The name of the CSS layer to associate with component styles.\n " )
179- sb . WriteString ( fmt .Sprintf ( " # css_layer: %s\n \n " , cfg .App .CssLayer ) )
179+ fmt .Fprintf ( & sb , " # css_layer: %s\n \n " , cfg .App .CssLayer )
180180
181181 // Write processor configuration
182182 sb .WriteString ("# processor:\n " )
183183 sb .WriteString (" # Number of concurrent workers (numCPUs * 2).\n " )
184- sb . WriteString ( fmt .Sprintf ( " # workers: %d\n \n " , cfg .Processor .Workers ) )
184+ fmt .Fprintf ( & sb , " # workers: %d\n \n " , cfg .Processor .Workers )
185185 sb .WriteString (" # Summary format: compact, long, json, none.\n " )
186- sb . WriteString ( fmt .Sprintf ( " # summary_format: %s\n \n " , cfg .Processor .SummaryFormat ) )
186+ fmt .Fprintf ( & sb , " # summary_format: %s\n \n " , cfg .Processor .SummaryFormat )
187187
188188 // Write templates configuration
189189 sb .WriteString ("# templates:\n " )
190190 sb .WriteString (" # A placeholder in template files indicating auto-generated sections.\n " )
191- sb . WriteString ( fmt .Sprintf ( " # guard_marker: %s\n \n " , cfg .Templates .GuardMarker ) )
191+ fmt .Fprintf ( & sb , " # guard_marker: %s\n \n " , cfg .Templates .GuardMarker )
192192 sb .WriteString (" # File extensions used for template files.\n " )
193193 sb .WriteString (" # extensions:\n " )
194194
@@ -198,7 +198,7 @@ func writeConfigFile(filePath string, cfg *config.Config) error {
198198 }
199199
200200 for _ , ext := range extensions {
201- sb . WriteString ( fmt .Sprintf ( " # - %s\n " , ext ) )
201+ fmt .Fprintf ( & sb , " # - %s\n " , ext )
202202 }
203203
204204 // Add user data section
0 commit comments