Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ synmake --config=<path/to/your/config.yaml> --debug
An example configuration file might look like this:
```yaml
---
env:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- .env
- .env.local
targets:
targetA:
helpDescription: targetA just prints an output
Expand All @@ -60,6 +63,9 @@ templates:
minVersion: 0.1.0
```

### Env files
List all env files that should be used inside the Makefile
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be cool to improve the description by describing what this field does or what function it has in a Makefile.


### Targets
Each key under targets specifies a new target where you can specify 3 attributes:
- `helpDescription` -> This field describes the target and will be added above the target as documentation. If you have set
Expand Down
5 changes: 5 additions & 0 deletions internal/config/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ func (cm *ConfigManager) applyConfig(w io.StringWriter) error {
)
}

// -- Env files
cm.logger.Info("Inserting env file includes", zap.Strings("func", cm.Config.EnvFiles))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cm.logger.Info("Inserting env file includes", zap.Strings("func", cm.Config.EnvFiles))
cm.logger.Info("Inserting env file includes", zap.Strings("func", "applyConfig"))

content = content.addSuggar(assembleEnvFiles(cm.Config.EnvFiles))
cm.logger.Info("Env files included")

// --- VARIABLES
cm.logger.Info("Variables will be added", zap.String("func", "applyConfig"))
variables := []string{}
Expand Down
10 changes: 10 additions & 0 deletions internal/config/assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ func assemblePreflightTarget(commands []string) SuggarString {
return content
}

func assembleEnvFiles(envFiles []string) SuggarString {
var content SuggarString

for _, envFile := range envFiles {
content.appendString("-include").appendString(" ").appendString(envFile).lineBreak()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be cool, if the user could decide whether the include should be optional or not.

}

return content
}

func assembleTargets(targetMap map[string]Target, delimiter string) SuggarString {
var content SuggarString
for targetName, targetConfig := range targetMap {
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type OptionalTemplates struct {
}

type Config struct {
EnvFiles []string `yaml:"env"`
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
EnvFiles []string `yaml:"env"`
EnvFiles []string `yaml:"envFiles"`

Targets map[string]Target `yaml:"targets"`
Templates OptionalTemplates `yaml:"templates"`
}
Expand Down
4 changes: 3 additions & 1 deletion internal/config/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package config

import (
"bytes"
"gopkg.in/yaml.v3"
"io"

"gopkg.in/yaml.v3"

"go.uber.org/zap"
)

Expand All @@ -23,6 +24,7 @@ func GenerateExampleYamlConfig(logger *zap.Logger, w io.StringWriter) error {
}

config := Config{
EnvFiles: []string{},
Targets: map[string]Target{
"targetA": tA,
"targetB": tB,
Expand Down