Skip to content
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

chore: add JSON schema for netlify.toml #4585

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

chore: add JSON schema for netlify.toml #4585

wants to merge 1 commit into from

Conversation

danez
Copy link
Contributor

@danez danez commented Oct 7, 2022

Summary

This PR adds a new JSON schema file for netlify.toml. A direct link to this file will be added to https://github.com/SchemaStore/schemastore. Most IDEs (vscode with extension, intellij) try to read schemas from this store.

In the future, the schema could even be used to validate the netlify.toml file in @netlify/config, as I saw right now we have some hardcoded validation in the code.

The new package is private for now, so even if we want to rename it later into maybe config-validation we can simply do this.

I added docs as reviewer, because I added a lot of links pointing to the docs and also copied most of the text from the docs.

Ref: https://github.com/netlify/pod-compute/issues/138

Kapture 2022-07-06 at 19 03 48

Screenshot 2022-07-06 at 19 16 12

Screenshot 2023-03-03 at 17 01 46

Screenshot 2023-03-03 at 17 07 39

A picture of a cute animal (not mandatory, but encouraged)

photo-1542736637-74169a802172

@lukasholzer
Copy link
Contributor

@danez any updates on this one? Would love having autocompletion for the toml 😂

@github-actions github-actions bot removed the stale label Feb 2, 2023
@danez danez changed the title chore: add JSON schema for netlify-toml WIP chore: add JSON schema for netlify.toml Mar 3, 2023
@danez danez self-assigned this Mar 3, 2023
@danez danez force-pushed the json-schema branch 2 times, most recently from 18e199e to 6847f55 Compare March 3, 2023 15:50
@danez danez requested a review from a team March 3, 2023 15:52
@danez danez marked this pull request as ready for review March 3, 2023 15:52
@danez danez requested a review from a team March 3, 2023 15:59
@danez danez force-pushed the json-schema branch 2 times, most recently from 98eb976 to 4a88be6 Compare March 3, 2023 16:12
Copy link

@codebyuma codebyuma left a comment

Choose a reason for hiding this comment

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

Hey @danez, sorry for the delay in reviewing this.

I know you copied all of these from the docs but I left a number of suggested edits to make some items more concise, clearer, or to just follow a more consistent format. Hopefully they should be quick and easy to apply but let me know if you have questions.

Since there are a bunch of edits, I'll go ahead and request changes here. But I'll keep an eye out to re-review this once you're ready.

packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Mar 30, 2023

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files. Consider converting them to TypeScript.
Thank you for converting JavaScript files to TypeScript 🎉"

codebyuma
codebyuma previously approved these changes Mar 30, 2023
Copy link

@codebyuma codebyuma left a comment

Choose a reason for hiding this comment

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

Hey @danez thanks for making these changes!

In this review, I spotted one typo that I missed last time and I tagged @klavavej to review the caching updates as I know the docs for EF caching are still a WIP. I just want to make sure we use the same language. I did leave some suggestions in the meantime.

I also checked all your links this time and can confirm they work as expected 👍

I don't see any blockers, so I'll approve. But it might be worth waiting for Kristen's approval too.

"definitions": {
"BasePath": {
"title": "Base path",
"description": "Directory to change to before starting a build. This is where we will look dependency management files such as `package.json` or `.nvmrc`. If not set, defaults to the root directory.",

Choose a reason for hiding this comment

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

Ah, I must have made a typo in my suggestion, sorry. We're missing a word here

Suggested change
"description": "Directory to change to before starting a build. This is where we will look dependency management files such as `package.json` or `.nvmrc`. If not set, defaults to the root directory.",
"description": "Directory to change to before starting a build. This is where we will look for dependency management files such as `package.json` or `.nvmrc`. If not set, defaults to the root directory.",

packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
klavavej
klavavej previously approved these changes Mar 30, 2023
Copy link
Contributor

@klavavej klavavej left a comment

Choose a reason for hiding this comment

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

Thanks for the ping @codebyuma ! I left a few notes but nothing blocking from me either so I will approve

Copy link
Contributor

@lukasholzer lukasholzer left a comment

Choose a reason for hiding this comment

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

I think the template field is missing on the root and the functions field on the build settings.

[build]
  # This is where we will look for your lambda functions
  functions = "project/functions/"

and for example:

# Set enviroment variable prompts for templates
[template.environment]
  YOUR_ENV_KEYS_NEEDED = "Enter in the ENV key here"
  # ref https://bit.ly/2wQ1mVk
  incoming-hooks = ["Service-1"]

@danez
Copy link
Contributor Author

danez commented Apr 14, 2023

and the functions field on the build settings

The docs though say it should be this:

[functions]
  directory = "my_functions"

maybe [build] -> functions is the old way of doing it?

@lukasholzer
Copy link
Contributor

and the functions field on the build settings

The docs though say it should be this:

[functions]
  directory = "my_functions"

maybe [build] -> functions is the old way of doing it?

mhm maybe @eduardoboucas can put some light on that?

@danez danez dismissed stale reviews from klavavej and codebyuma via a973943 April 14, 2023 14:29
codebyuma
codebyuma previously approved these changes Apr 14, 2023
Copy link

@codebyuma codebyuma left a comment

Choose a reason for hiding this comment

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

From a docs content POV, I think this is good to go. I just reviewed your latest commits and also reviewed against the suggestions Kristen left last 👍

I left three small suggested edits for the new content that was just added (templates, etc) but none of them are blocking, so you can decide whether to apply them or leave them as-is to finally get this merged 🙂

"title": "Publish path",
"description": "Setting to use if a project is detected incorrectly, flagged by multiple detectors, or requires a `command` and `targetPort`.",
"type": "string",
"enum": ["#auto", "#static", "#custom"],
Copy link
Contributor

Choose a reason for hiding this comment

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

should have a regular string here as well like next

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, it seems the docs need an update then too maybe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the enum and made it a simple string for now. LAter one we could make it an enum again, but generate it with all the framework names :)

"description": "Netlify Dev enables a local development environment without any additional setup and this includes using the functions directory setting to scaffold and serve your functions locally. You can use the `[dev]` section to configure this local development environment. \n\nNote that `[dev]` doesn't run in the Bash shell, so you won't be able to use Bash-compatible syntax with the command.",
"type": "object",
"additionalProperties": false,
"properties": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think some fields are still missing regarding the dev config from the CLI:
https://github.com/netlify/cli/blob/main/src/commands/dev/types.d.ts#L3-L22

like: staticServerPort or envFiles or functions and live

Copy link
Contributor Author

@danez danez Jun 9, 2023

Choose a reason for hiding this comment

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

live is only a cli option and is never read from the devConfig afaics. I added envFiles and staticServerPort as they make sense (we should add them to the docs too). functions though I do not think is useful, where would having a different functions directory locally help? I have a hunch that functions is only part of the devConfig because we needed a way to transmit the setting to different methods, here it was introduced So I did not add it.

codebyuma
codebyuma previously approved these changes Jun 12, 2023
Copy link

@codebyuma codebyuma left a comment

Choose a reason for hiding this comment

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

Left one small suggested edit but otherwise the latest updates look good to me 🤞

packages/config-schema/src/schema/netlify-toml.schema.json Outdated Show resolved Hide resolved
codebyuma
codebyuma previously approved these changes Jun 13, 2023
Copy link

@codebyuma codebyuma left a comment

Choose a reason for hiding this comment

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

Not sure if you still need another technical review but the copy looks good to me 🚢

Co-authored-by: Uma Chandran <codebyuma@users.noreply.github.com>
@danez danez requested a review from a team as a code owner July 6, 2023 10:44
@danez
Copy link
Contributor Author

danez commented Jul 14, 2023

The config for edge functions is currently incorrect in the schema:

  • excludePattern, excludePath and pattern are missing from the schema
  • path is currently only allowed to be a string, but it can also be an array of strings

@danez danez removed their assignment Aug 15, 2023
@github-actions github-actions bot added the stale label Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants