Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for the custom nodes monorepo #77

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions custom_nodes/DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Developing in the Custom Nodes Monorepo

VisualBlocks maintains a monorepo of custom node packages that can be directly loaded in the web interface and supporting packages that help with developing custom nodes.
The monorepo is orchestrated by [Turborepo](https://turbo.build/repo/docs) with [Changesets](https://github.com/changesets/changesets) for versioning. Packages bundle with
[`tsup`](https://github.com/egoist/tsup) and / or [`esbuild`](https://esbuild.github.io/) and are distributed in the
[ESModules format](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) with `.js` extensions. We use [`eslint`](https://eslint.org/) and
[`prettier`](https://prettier.io/) for linting and formatting.

## Development Commands

It's recommended (but not required) to globally install turborepo with `npm i -g turbo`. These commands are also available in the `custom_nodes` package.json if you prefer not to.

Available commands:

```
$ turbo run

build
@visualblocks/custom-node-types, @visualblocks/gemini, @visualblocks/node-utils, @visualblocks/scripts and 1 more
clean
@visualblocks/custom-node-types, @visualblocks/gemini, @visualblocks/node-utils, @visualblocks/scripts and 1 more
lint
@visualblocks/gemini, @visualblocks/node-utils, @visualblocks/scripts, @visualblocks/utility-nodes
typecheck
@visualblocks/gemini, @visualblocks/node-utils, @visualblocks/utility-nodes
upload-to-gcp
@visualblocks/gemini, @visualblocks/scripts, @visualblocks/utility-nodes
bundle
@visualblocks/gemini, @visualblocks/utility-nodes
dev
@visualblocks/devserver
```

There's also a command for formatting with Prettier:

```sh
# custom_nodes/
npm run format
```

### Devserver

Run `turbo dev` to run an auto-updating devserver on port 8080. See [the devserver readme](custom_nodes/apps/devserver/README.md) for more.

## Updating a Package

1. Make your changes as you normally would, but don't commit yet.
2. Run `npm run lint`
3. Run `npm run format`
4. If your change would cause a version bump in any packages, run `npm changeset` in the `custom_nodes` directory to create
a changeset for your PR. Changeset should detect what packages you've changed.
5. Commit (possibly multiple times) and send a PR.

## Publishing

### Setup for GCP

1. Install `gsutil`
2. Run `gcloud auth login`
3. Run `gcloud config set project learnjs-174218` to set the project.

### Steps to Publish

1. Run `npm version-packages` in `custom_nodes/`. This will apply all pending changesets, adding their contents to the CHANGELOG and bumping package versions.
2. Commit the changes and get them merged into `main`.
3. Fetch `main` and run `npm publish-bundles-to-gcp`.
4. This is were we would publish to NPM, but we don't do that yet.
6 changes: 5 additions & 1 deletion custom_nodes/apps/devserver/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# `@visualblocks/devserver`
# Visualblocks Custom Nodes Devserver

## Serving Paths

The devserver serves all files in the `../../` directory (aka `visualblocks/custom_nodes/`). To load a custom node library, use a URL like `http://localhost:8080/packages/gemini/dist/bundle.js`.

## Development

Whenever a new custom node package is written, it should be added to the devserver's package.json so turborepo knows to restart the devserver when the package is changed. Packages that do not need to be served do not need to be added. Likewise, transitive dependencies do not need to be added (even if they need to be served), since Turborepo will need to recompile them to build their dependent package anyways.
4 changes: 1 addition & 3 deletions custom_nodes/apps/devserver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
"dev": "node server.js"
},
"dependencies": {
"@visualblocks/custom-node-types": "*",
"@visualblocks/gemini": "*",
"@visualblocks/node-utils": "*",
"@visualblocks/tsconfig": "*"
"@visualblocks/utility-nodes": "*"
},
"devDependencies": {
"express": "^4.19.2"
Expand Down