Creating an extension is easy thanks to the Sourcegraph extension creator. It will ask you a series of questions about your extension, then create the file structure so you can start developing your extension immediately.
Once you have set up your development environment, you’re ready to go:
mkdir my-extension
cd my-extension
npm init @sourcegraph/extension
Your extension folder now contains the following.
├── README.md
├── node_modules
├── package-lock.json
├── package.json
├── src
│ └── {extension-name}.ts
├── tsconfig.json
└── tslint.json
The README.md
explains how to set up and use your extension.
The entry point for your extension code is src/{extension-name}.ts
.
The package.json
defines important commands used during development and publishing. To run them, prefix the command key with npm run
. For example, to lint and type check your code:
npm run lint
npm run typecheck
Other files such as tsconfig.json
and tslint.json
configure how your code is linted and compiled. They are fine as is but feel free to change them.
Noticed a bug? Any ideas for improving the extension creation process? File an issue.