-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate shopware project config schema automatically
- Loading branch information
Showing
5 changed files
with
556 additions
and
312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/FriendsOfShopware/shopware-cli/shop" | ||
"github.com/invopop/jsonschema" | ||
"os" | ||
) | ||
|
||
func generateProjectSchema() error { | ||
r := new(jsonschema.Reflector) | ||
r.FieldNameTag = "yaml" | ||
r.RequiredFromJSONSchemaTags = true | ||
|
||
if err := r.AddGoComments("github.com/FriendsOfShopware/shopware-cli", "./shop"); err != nil { | ||
return err | ||
} | ||
|
||
schema := r.Reflect(&shop.Config{}) | ||
|
||
bytes, err := json.MarshalIndent(schema, "", " ") | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := os.WriteFile("shop/shopware-project-schema.json", bytes, 0644); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func main() { | ||
Check failure on line 34 in schema.go GitHub Actions / ubuntu-latest
Check failure on line 34 in schema.go GitHub Actions / lint
Check failure on line 34 in schema.go GitHub Actions / run
Check failure on line 34 in schema.go GitHub Actions / macos-14
|
||
if err := generateProjectSchema(); err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.