extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Add local extension generation CLI

Open Moshyfawn opened this issue 2 years ago • 0 comments

Local Extension Management/Installation CLI POC

What is this?

I've been playing around with Zed extensions a bit more, trying to figure out how to make the process of developing and testing the extensions less frictional. What I've come up with is a simple CLI tool that can be run to both generate grammars and install extensions from a local directory.

More words

I've cobbled together a quick CLI application that can ask for a few inputs like the name of the extension and the path to the extension grammar, and then generate the WASM grammar file for you, currently moving it to the extension directory inside extensioins.It will also ask you if you want to install the extension, and if you say yes, it will move the extension to the Zed extensions directory.

How to use

  1. Clone this repo
  2. Run npm install.
  3. cd cli && node index.js (it is important to run it from the cli directory as it uses relative paths to the extension directory).
  4. Follow the prompts.
  5. If you choose to install the extension, it will be moved to the Zed extensions directory and you can start using it in Zed.

https://github.com/zed-industries/extensions/assets/16290753/ae71e2ff-cf51-4dad-a991-549aa728225f

Current limitations

As I said, this is the most barebones POC because I'm not sure if this is the right direction to go in and I didn't want to spend too much time on it if it wasn't.

  • The script uses relative paths, so it needs to be run from the cli directory. I just wanted to get it working at this point.
  • Local extensions don't currently work as described in [this Discord message] (https://discord.com/channels/869392257814519848/873293828805771284/1208811412168638584).
  • The tooling check is barebones and there to demonstrate the idea of checking for the required tools before running the script.
  • The CLI flow is crude and could be improved.

The ideal way would be to refactor the already existing `package-extensions' file to export the existing functions to run during CLI execution. I have decided not to do this for this POC.

End notes

Let me know if you have any thoughts on this.

This may eliminate the need for additional installation steps and make it easier to develop and test extensions locally. The CLI can be published to npm and used by anyone who wants to develop extensions for Zed by running npx zed-extension-cli or something similar.

Moshyfawn avatar Feb 18 '24 19:02 Moshyfawn