@@ -12,6 +12,7 @@ import (
1212 "github.com/keboola/keboola-as-code/internal/pkg/llm/twinformat/writer"
1313 "github.com/keboola/keboola-as-code/internal/pkg/log"
1414 "github.com/keboola/keboola-as-code/internal/pkg/utils/errors"
15+ "github.com/keboola/keboola-as-code/internal/pkg/utils/strhelper"
1516 "github.com/keboola/keboola-as-code/internal/pkg/utils/timeutils"
1617)
1718
@@ -387,7 +388,7 @@ func (g *Generator) buildTransformationIndex(data *ProcessedData) map[string]any
387388// generateTransformationMetadata generates a transformation metadata.json file.
388389func (g * Generator ) generateTransformationMetadata (ctx context.Context , transform * ProcessedTransformation ) error {
389390 // Create transformation directory with sanitized name for filesystem safety.
390- transformDir := filesystem .Join (g .outputDir , "transformations" , sanitizeFilename (transform .Name ))
391+ transformDir := filesystem .Join (g .outputDir , "transformations" , strhelper . SanitizeFilename (transform .Name ))
391392 if err := g .fs .Mkdir (ctx , transformDir ); err != nil {
392393 return errors .Errorf ("failed to create transformation directory %s: %w" , transformDir , err )
393394 }
@@ -484,7 +485,7 @@ func (g *Generator) generateTransformationCode(ctx context.Context, transformDir
484485 blockNum ++
485486 // Create filename: 01-block-name.sql
486487 ext := languageToExtension (block .Language )
487- filename := fmt .Sprintf ("%02d-%s%s" , blockNum , sanitizeFilename (code .Name ), ext )
488+ filename := fmt .Sprintf ("%02d-%s%s" , blockNum , strhelper . SanitizeFilename (code .Name ), ext )
488489 filePath := filesystem .Join (codeDir , filename )
489490
490491 if err := g .mdWriter .Write (ctx , filePath , code .Script ); err != nil {
@@ -529,25 +530,6 @@ func buildJobExecutionMap(exec *JobExecution) map[string]any {
529530 return result
530531}
531532
532- // sanitizeFilename removes or replaces characters that are not safe for filenames.
533- // Returns "unnamed" if the result would be empty.
534- func sanitizeFilename (name string ) string {
535- // Replace spaces and special characters with hyphens
536- result := make ([]byte , 0 , len (name ))
537- for i := range len (name ) {
538- c := name [i ]
539- if (c >= 'a' && c <= 'z' ) || (c >= 'A' && c <= 'Z' ) || (c >= '0' && c <= '9' ) || c == '-' || c == '_' {
540- result = append (result , c )
541- } else if c == ' ' {
542- result = append (result , '-' )
543- }
544- }
545- if len (result ) == 0 {
546- return "unnamed"
547- }
548- return string (result )
549- }
550-
551533// generateJobs generates jobs/index.json and job detail files.
552534func (g * Generator ) generateJobs (ctx context.Context , data * ProcessedData ) error {
553535 g .logger .Debugf (ctx , "Generating jobs index and details" )
0 commit comments