Skip to content

Added json schema for 0.8 version #1617

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

Merged
merged 4 commits into from
Nov 11, 2023
Merged

Added json schema for 0.8 version #1617

merged 4 commits into from
Nov 11, 2023

Conversation

mohsenari
Copy link
Collaborator

@mohsenari mohsenari commented Nov 10, 2023

Summary

Title says it.

I put the file in .schema/ directory so that in future if we change the schema we can align it with version. Meaning, we can add new schema files with version numbers and enforce the schema based on the version of devbox a user has installed. Putting it in root of this repository would make the root too crowded especially if we add more schema files.

I'm going to host our schema in this repository and subsequently send a PR to https://github.com/SchemaStore/schemastore/ with a link to the schema file in our repo to register our repo in https://schemastore.org

afterwards, I can update the vscode extension to reference the schemastore.org link and enforce our defined schema on files that are named devbox.json

How was it tested?

validated schema and examples of devbox.json in https://www.jsonschemavalidator.net/

Comment on lines 79 to 87
"required": [
"init_hook"
]
}
},
"required": [
"packages",
"shell"
]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I put these fields as required, If they're wrong or missing something lmk.

Copy link
Collaborator

@gcurtis gcurtis left a comment

Choose a reason for hiding this comment

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

Awesome! I've been wanting this for a while. I left some wording suggestions, but feel free to take them or leave them as you see fit.

Question about the schema versioning - could we have a single schema.json and just link to specific commits in GitHub? For example, https://github.com/jetpack-io/devbox/blob/0.8.1/.schema/0.8.schema.json would return the schema as of devbox 0.8.1.

"type": "object",
"properties": {
"packages": {
"description": "A specification of packages to be installed via devbox.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"description": "A specification of packages to be installed via devbox.",
"description": "Collection of packages to install",

"patternProperties": {
".*": {
"type": "string",
"description": "Version number of the package in this object."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"description": "Version number of the package in this object."
"description": "Version of the package to install."

"patternProperties": {
".*": {
"type": "object",
"description": "Version number of the specified package in {\"version\": \"1.2.3\"} formmat.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This object can contain a few more fields. I think they are:

  • version
  • platforms - only install the package on these Nix systems (e.g., aarch64-darwin, x86_64-linux, etc.)
  • excluded_platforms - don't install the package on these Nix systems.
  • glibc_patch - apply the glibc-patch feature to this package's binaries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gcurtis can you send me an example of devbox.json with these parameters included?
Also a list of all possible values for platforms/excluded_platforms.
Side note: If I remember correctly, platforms and excluded_platforms can not co-exist right?

"patternProperties": {
".*": {
"type": "object",
"description": "Version number of the specified package in {\"version\": \"1.2.3\"} formmat.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"description": "Version number of the specified package in {\"version\": \"1.2.3\"} formmat.",
"description": "Version number of the specified package in {\"version\": \"1.2.3\"} format.",

]
},
"env": {
"description": "List of additional environment variables to be set in devbox shell. Values can contain $PATH and $PWD.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"description": "List of additional environment variables to be set in devbox shell. Values can contain $PATH and $PWD.",
"description": "List of additional environment variables to be set in the Devbox environment. Values containing $PATH or $PWD will be expanded. No other variable expansion or command substitution will occur.",

"description": "Definitions of scripts and actions to take when in devbox shell.",
"type": "object",
"properties": {
"init_hook": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can also be a single string.

}
},
"scripts": {
"description": "List of commads/scripts definitions to run with `devbox run <script_name>` command.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"description": "List of commads/scripts definitions to run with `devbox run <script_name>` command.",
"description": "List of command/script definitions to run with `devbox run <script_name>`.",

"init_hook": {
"type": "array",
"items": {
"description": "list of shell commands/scripts to run right after devbox shell starts.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"description": "list of shell commands/scripts to run right after devbox shell starts.",
"description": "List of shell commands/scripts to run right after devbox shell starts.",

],
"items": {
"type": "string",
"description": "command/script to run as part of a list of commands defined here."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"description": "command/script to run as part of a list of commands defined here."
"description": "The script's shell commands."

Comment on lines 79 to 87
"required": [
"init_hook"
]
}
},
"required": [
"packages",
"shell"
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these required? I thought an empty devbox.json object was valid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually don't know. I'll test it out and if they weren't I'll remove.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seems like empty devbox shell is accepted. I'll remove the required fields

@mohsenari
Copy link
Collaborator Author

mohsenari commented Nov 10, 2023

Awesome! I've been wanting this for a while. I left some wording suggestions, but feel free to take them or leave them as you see fit.

Question about the schema versioning - could we have a single schema.json and just link to specific commits in GitHub? For example, https://github.com/jetpack-io/devbox/blob/0.8.1/.schema/0.8.schema.json would return the schema as of devbox 0.8.1.

@gcurtis
The link we provide has to point to the raw file content. If we can have the link to that within multiple versions then we can have a single file, otherwise we gotta keep a separate file per version

@gcurtis
Copy link
Collaborator

gcurtis commented Nov 10, 2023

@mohsenari it should be possible to get the raw content. For example, https://raw.githubusercontent.com/jetpack-io/devbox/ab2e606cc3c71b9f84d92d1d22441b6b400bf959/.schema/0.8.schema.json

@mohsenari mohsenari merged commit e93a2f0 into main Nov 11, 2023
@mohsenari mohsenari deleted the mohsen--json-schema branch November 11, 2023 05:03
Comment on lines +40 to +41
"platform": {},
"excluded_platform": {},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these should be platforms and excluded_platforms (note the s for plural)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants