question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There are numerous occasions when we want to be able to ‘automatically’ edit the wrangler.toml file from withiin wrangler. Examples -

  • removing a deprecated field like type
  • renaming a deprecated field like build.upload.main to something like entry (todo)
  • adding durable object migrations based on some interactive flow (todo)

In rust land, we’d use a format preserving editor like toml-edit, but nothing like it exists in javascript land (that I know of). So this issue tracks the implementation of the thing.

We need to take a toml parser that given a toml string, returns an AST. We then apply edits to the AST directly, and convert it back to a toml string.

Potential code to learn from - https://github.com/ota-meshi/toml-eslint-parser

Sequencing / prioritisation: I think when we should first start simply logging the changes we want people to make directly to the terminal (for backward compat, migrations, whatever.) Once we have that in place, we can start working on this issue to automate the suggestions.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bd82commented, Jan 12, 2022

Hello.

I am the author of both Chevrotain and @toml-tools/parser.

Some questions:

  • Do I understand correctly that you need to make small modifications to an existing toml file, while honoring the existing formatting / style (no full document re-write on change)?

  • Do you have any future “true editor” requirements in regards to the wrangler.toml file? e.g:

    • A VSCode extension that supports some semantic validations and content assist for wrangler.toml files?

Cheers. Shahar.

0reactions
msujewcommented, Jan 14, 2022

Hey @bd82, thanks for the heads-up!

If it’s about editor support, I think Langium would be a good choice. Looking at the initial requirements, especially removing deprecated fields should be as simple as writing a validation and executing an associated code action (as in: Executing a quick fix provided by VSCode for unused imports for example).

Langium’s main use case is to build a language server, so its editing interfaces are tightly coupled to the LSP types. However, everything is also working in CLI/normal app server mode, so once you conform to the LSP types, stuff like executing code actions should also be working fine. Although, we mostly just use the parsing and validation capabilities of Langium when running CLIs. Thinking about it, you probably don’t even need to go through the LSP interfaces and can just work on the AST/CST itself, kind of mimicking how editors execute code actions.

It might be a bit tricky to get the toml grammar to work correctly in Langium (mostly about lexing, parsing shouldn’t be an issue, white space sensitive languages are always a bit difficult to deal with), but definitely possible, since it’s using Chevrotain under the hood. However, after that’s done, everything else should be straightforward, since semantic validations, content assist, tool-tips, etc. as mentioned by Shahar come out-of-the-box with minimal effort with Langium.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TOML - File Editors - W3schools.io
This tutorial covers toml file configuration Editors and IDES for creating and edit settings and configuration files files. Editors are useful to create...
Read more >
TOML File Extension - What is a .toml file and how do I open it?
A TOML file is a configuration file saved in the open source TOML (Tom's Obvious, Minimal Language) file format. It is used to...
Read more >
TOML Editor - Visual Studio Marketplace
Extension for Visual Studio - TOML language support for Visual Studio with syntax highlighting, validation, outlining, and more...
Read more >
The TOML Validator: TOML Lint
Validate and Verify your TOML files (Tom's obvious minimal language)
Read more >
Power TOML Editor on the Mac App Store
Power TOML Editor is a powerful TOML editor for developers can visualize toml file and edit toml file in a tree view. By...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found