Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

How to create new extension

Théo edited this page Aug 30, 2023 · 2 revisions

Structure

Here is the structure of osmium. To create a new extension, you need to create a new folder in the wanted toolchain folder (ex: linter in the solidity folder)

It needs to respect the following structure:

.
├── libs
├── manager
├── packages
└── toolchains
    └── solidity
        └── linter -> Your new feature folder (linter in this case)
            ├── core
            │   ├── src
            │   └── package.json
            ├── extension
            │   ├── .vscode
            │   ├── src
            │   ├── .eslintrc.json
            │   ├── .vscodeignore
            │   ├── tsconfig.json
            │   └── package.json
            └── package.json

Core

This folder is where you will put all the core code of the extension.

For the proper work of the core, you need to implement some rule that can be called by the main script of the toolchain:

  • build - Build the core
  • test - Run the tests
  • lint - Run the linter

Extension

Install globally the libraries we'll use to generate the scaffold of our extension

yarn global add yo generator-code

Generate the scaffold of our extension

cd toolchains/solidity/linter
yo code .

# ? What type of extension do you want to create? New Extension (TypeScript)
# ? What's the name of your extension? HelloWorld
### Press <Enter> to choose default for all options below ###

# ? What's the identifier of your extension? solidity-linter
# ? What's the description of your extension? A basic description
# ? Initialize a git repository? No
# ? Bundle the source code with webpack? No
# ? Which package manager to use? yarn

# ? Do you want to open the new folder with Visual Studio Code? Open with `code`

Launch your extension

Inside the vscode editor, press F5. This will compile and run the extension in a new Extension Development Host window.

Scripts

The scaffold provides some scripts to help you develop your extension:

  • compile - Compile your code
  • watch - Watch your code and compile it on change
  • pretest - Run tests and lint
  • lint - Run eslint on your code
  • test - Run tests

For the proper work of the extension, you need to implement some rule that can be called by the main script of the toolchain:

  • build - Build the core
  • test - Run the tests
  • lint - Run the linter