@@ -13,31 +13,31 @@ import (
1313)
1414
1515func validateStorefrontSnippets (context * ValidationContext ) {
16- rootDir := context .Extension .GetRootDir ()
16+ // rootDir := context.Extension.GetRootDir()
1717
18- for _ , val := range context .Extension .GetResourcesDirs () {
19- storefrontFolder := path .Join (val , "snippet" )
18+ // for _, val := range context.Extension.GetResourcesDirs() {
19+ // storefrontFolder := path.Join(val, "snippet")
2020
21- if err := validateStorefrontSnippetsByPath (storefrontFolder , rootDir , context ); err != nil {
22- return
23- }
24- }
21+ // if err := validateStorefrontSnippetsByPath(storefrontFolder, rootDir, context); err != nil {
22+ // return
23+ // }
24+ // }
2525
26- for _ , extraBundle := range context .Extension .GetExtensionConfig ().Build .ExtraBundles {
27- bundlePath := rootDir
26+ // for _, extraBundle := range context.Extension.GetExtensionConfig().Build.ExtraBundles {
27+ // bundlePath := rootDir
2828
29- if extraBundle .Path != "" {
30- bundlePath = path .Join (bundlePath , extraBundle .Path )
31- } else {
32- bundlePath = path .Join (bundlePath , extraBundle .Name )
33- }
29+ // if extraBundle.Path != "" {
30+ // bundlePath = path.Join(bundlePath, extraBundle.Path)
31+ // } else {
32+ // bundlePath = path.Join(bundlePath, extraBundle.Name)
33+ // }
3434
35- storefrontFolder := path .Join (bundlePath , "Resources" , "snippet" )
35+ // storefrontFolder := path.Join(bundlePath, "Resources", "snippet")
3636
37- if err := validateStorefrontSnippetsByPath (storefrontFolder , rootDir , context ); err != nil {
38- return
39- }
40- }
37+ // if err := validateStorefrontSnippetsByPath(storefrontFolder, rootDir, context); err != nil {
38+ // return
39+ // }
40+ // }
4141}
4242
4343func validateStorefrontSnippetsByPath (snippetFolder , rootDir string , context * ValidationContext ) error {
@@ -106,7 +106,7 @@ func validateStorefrontSnippetsByPath(snippetFolder, rootDir string, context *Va
106106 continue
107107 }
108108
109- compareSnippets (mainFileContent , file , context , rootDir )
109+ compareSnippets (mainFileContent , mainFile , file , context , rootDir )
110110 }
111111 }
112112
@@ -190,7 +190,7 @@ func validateAdministrationByPath(adminFolder, rootDir string, context *Validati
190190 }
191191
192192 if len (mainFile ) == 0 {
193- context .AddWarning ("snippet.validator" , fmt .Sprintf ("No en-GB.json file found in %s, using %s" , folder , files [0 ]))
193+ context .AddWarning ("snippet.validator" , fmt .Sprintf ("No en-GB.json file found in %s, using %s" , strings . ReplaceAll ( folder , rootDir + "/" , "" ), strings . ReplaceAll ( files [0 ], rootDir + "/" , "" ) ))
194194 mainFile = files [0 ]
195195 }
196196
@@ -211,14 +211,14 @@ func validateAdministrationByPath(adminFolder, rootDir string, context *Validati
211211 continue
212212 }
213213
214- compareSnippets (mainFileContent , file , context , rootDir )
214+ compareSnippets (mainFileContent , mainFile , file , context , rootDir )
215215 }
216216 }
217217
218218 return nil
219219}
220220
221- func compareSnippets (mainFile []byte , file string , context * ValidationContext , extensionRoot string ) {
221+ func compareSnippets (mainFile []byte , mainFilePath , file string , context * ValidationContext , extensionRoot string ) {
222222 checkFile , err := os .ReadFile (file )
223223 if err != nil {
224224 context .AddError ("snippet.validator" , fmt .Sprintf ("Cannot read file '%s', due '%s'" , file , err ))
@@ -239,6 +239,8 @@ func compareSnippets(mainFile []byte, file string, context *ValidationContext, e
239239 return
240240 }
241241
242+ normalizedMainFilePath := strings .ReplaceAll (mainFilePath , extensionRoot + "/" , "" )
243+
242244 for _ , diff := range compare {
243245 normalizedPath := strings .ReplaceAll (file , extensionRoot + "/" , "" )
244246
@@ -248,7 +250,7 @@ func compareSnippets(mainFile []byte, file string, context *ValidationContext, e
248250 }
249251
250252 if diff .Type == jsondiff .OperationAdd {
251- context .AddWarning ("snippet.validator" , fmt .Sprintf ("Snippet file: %s, missing key \" %s\" in this snippet file, but defined in the main language (\" %s \" )" , normalizedPath , diff .Path , mainFile ))
253+ context .AddWarning ("snippet.validator" , fmt .Sprintf ("Snippet file: %s, missing key \" %s\" in this snippet file, but defined in the main language (%s )" , normalizedPath , diff .Path , normalizedMainFilePath ))
252254 continue
253255 }
254256
0 commit comments