engraftdev / engraft

https://engraft.dev
MIT License
36 stars 0 forks source link

Engraft

Engraft is an API that brings rich interactive tools into open-ended programming environments. Welcome!

Getting started

The easiest way to start using Engraft is Graft Garden, a hosted web-app where you can create and share programs.

Engraft also has a range of embeddings so that live & rich tools can be brought to where you are already working:

A few other demos can be found at engraft.dev.

Building on the Engraft API

Do you want to build a tool that can be embedded inside Engraft programs? See [TODO: component dev guide].

Do you want to make your application or programming environment extensible with Engraft tools? See [TODO: host dev guide].

Development

This section is about how to work in this repository.

Setup

First, install external prerequisites:

  1. node: Not sure which version range is supported but for the record v19.7.0 works fine. (We recommend nvm for managing node installations.)
  2. yarn 1.x: On Mac, brew install yarn will take care of this.

Next, from the base of the repository, run:

  1. yarn to install dependencies,
  2. yarn testbed:dev to start a testbed development server (after building necessary packages).

Codebase overview

Code is divided into separate packages located in the packages directory. Each will be (TODO!) hosted on the npm registry as @engraft/PACKAGE-NAME. Here's a quick (non-exhaustive) overview:

Build system overview

Most packages (including those defining Engraft components) are libraries. In their package.json files, they provide build-lib scripts which compile TypeScript from src into JavaScript in lib (with TypeScript declaration files and various source maps).

For a package to be compiled correctly, its dependencies must be compiled, and their dependencies, and so on. We use Lerna/nx to manage all of this automatically. To build a library and all its n-fold dependencies, run:

yarn lerna run build-lib --scope @engraft/PACKAGE-NAME

(This is admittedly a mouthful and we may make some shortcuts.)

Some packages define applications. For these, use build-app rather than build-lib. This will call Vite to bundle all our interdependent modules into JavaScript that can be loaded by the browser.

Testing & other checks

We have tests (run by Vitest) and a few other ways of checking that things are working (TypeScript, ESLint, depcheck). These should all be documented more (TODO!), but for now, just run

yarn all:checks

and make sure there aren't any errors.

Editors

Engraft has primarily been developed with VS Code, with the ESLint extension. With this setup, TypeScript language services and inline linting feedback work nicely.