88 "strings"
99 "time"
1010
11+ "errors"
12+
1113 "github.com/xeipuuv/gojsonschema"
1214)
1315
@@ -50,6 +52,7 @@ type ProjectConfig struct {
5052 Restart string `json:"restart,omitempty"`
5153 HealthCheck * HealthCheck `json:"health_check,omitempty"`
5254 Resources * Resources `json:"resources,omitempty"`
55+ Gpus string `json:"gpus,omitempty"`
5356}
5457
5558type HealthCheck struct {
@@ -145,9 +148,21 @@ func (cm *ConfigManager) Save(config *Config) error {
145148}
146149
147150func (cm * ConfigManager ) LoadProjectConfig (projectPath string ) (* ProjectConfig , error ) {
148- configPath := filepath .Join (projectPath , "devbox.json" )
149-
150- if _ , err := os .Stat (configPath ); os .IsNotExist (err ) {
151+ // Support multiple filenames for project config to avoid clashes with other tools
152+ candidates := []string {
153+ filepath .Join (projectPath , "devbox.json" ), // default
154+ filepath .Join (projectPath , "devbox.project.json" ), // alternative
155+ filepath .Join (projectPath , ".devbox.json" ), // dotfile style
156+ }
157+
158+ var configPath string
159+ for _ , p := range candidates {
160+ if _ , err := os .Stat (p ); err == nil {
161+ configPath = p
162+ break
163+ }
164+ }
165+ if configPath == "" {
151166 return nil , nil
152167 }
153168
@@ -165,7 +180,19 @@ func (cm *ConfigManager) LoadProjectConfig(projectPath string) (*ProjectConfig,
165180}
166181
167182func (cm * ConfigManager ) SaveProjectConfig (projectPath string , config * ProjectConfig ) error {
168- configPath := filepath .Join (projectPath , "devbox.json" )
183+ // If an existing config file with a supported name exists, write back to it; otherwise use default
184+ candidates := []string {
185+ filepath .Join (projectPath , "devbox.json" ),
186+ filepath .Join (projectPath , "devbox.project.json" ),
187+ filepath .Join (projectPath , ".devbox.json" ),
188+ }
189+ configPath := candidates [0 ]
190+ for _ , p := range candidates {
191+ if _ , err := os .Stat (p ); err == nil {
192+ configPath = p
193+ break
194+ }
195+ }
169196
170197 data , err := json .MarshalIndent (config , "" , " " )
171198 if err != nil {
@@ -199,7 +226,7 @@ func (cm *ConfigManager) ValidateProjectConfig(cfg *ProjectConfig) error {
199226 b .WriteString (e .String ())
200227 b .WriteString ("\n " )
201228 }
202- return fmt . Errorf (strings .TrimSpace (b .String ()))
229+ return errors . New (strings .TrimSpace (b .String ()))
203230 }
204231
205232 for _ , port := range cfg .Ports {
@@ -523,7 +550,8 @@ const ProjectConfigJSONSchema = `{
523550 "memory": {"type": "string"}
524551 },
525552 "additionalProperties": false
526- }
553+ },
554+ "gpus": {"type": "string"}
527555 },
528556 "additionalProperties": false
529557}`
0 commit comments