devbox icon indicating copy to clipboard operation
devbox copied to clipboard

[Feature]: Publish a json schema for devbox.json

Open bbugh opened this issue 2 years ago • 3 comments

Thanks for devbox, it's so great.

Is your feature request related to a problem you're trying to solve? Please describe.

Yes, having a schema allows for easy command line/CI verification to catch runtime errors before getting to CI, and editors can offer auto complete.

Describe the solution you'd like I'd love to see an official JSON schema published for the devbox.json configuration.

Describe alternatives you've considered Not having one 😢

Additional context

A good example of how to do this is devcontainers/spec. They publish here https://github.com/devcontainers/spec/blob/main/schemas/devContainer.schema.json

and you can reference it in as the schema using the github raw file:

{ 
  "$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json"
}

In the case of devbox, you could also do it by tag so it's tracked alongside the same version of devbox

{
  "$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/0.7.1/schemas/devbox-config.schema.json",
  "packages": [
    "[email protected]",
  ],
}

bbugh avatar Oct 20 '23 15:10 bbugh

Hey @bbugh that's a great suggestion. I'll bring it up with the team and put it in our feature roadmap.

mohsenari avatar Oct 20 '23 16:10 mohsenari

btw this works right now:

{
  "$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/main/.schema/devbox.schema.json",
  "packages": {
    "nodejs": "18",
    "go": "1.21.3"
  }
}

👍🏻

airtonix avatar Nov 12 '23 03:11 airtonix

@airtonix awesome, I'm adding the schema validation to devbox's vscode extension so that even without the $schema field, it should validate if extension is installed.

mohsenari avatar Nov 13 '23 16:11 mohsenari