-
Notifications
You must be signed in to change notification settings - Fork 1
Add Env File Handling to Makefile Generation #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,9 @@ synmake --config=<path/to/your/config.yaml> --debug | |
| An example configuration file might look like this: | ||
| ```yaml | ||
| --- | ||
| env: | ||
| - .env | ||
| - .env.local | ||
| targets: | ||
| targetA: | ||
| helpDescription: targetA just prints an output | ||
|
|
@@ -60,6 +63,9 @@ templates: | |
| minVersion: 0.1.0 | ||
| ``` | ||
|
|
||
| ### Env files | ||
| List all env files that should be used inside the Makefile | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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)) | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 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{} | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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() | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,7 @@ type OptionalTemplates struct { | |||||
| } | ||||||
|
|
||||||
| type Config struct { | ||||||
| EnvFiles []string `yaml:"env"` | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Targets map[string]Target `yaml:"targets"` | ||||||
| Templates OptionalTemplates `yaml:"templates"` | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/RaphSku/synmake/pull/5/changes#r3215168639