Skip to content

Commit

Permalink
A few more improvements before we go live (#2)
Browse files Browse the repository at this point in the history
* these we for example and we do not support yet

* Support 1d array property and params

* only render when empty

* Remove go stuff, setup test

* remove output dir

* cleanup comment

* move tests to directory

* whitespace, fix ghaction

* move dummy file

* update readme

* change test schema

* move more to xtp-bindgen
  • Loading branch information
bhelx authored Jul 15, 2024
1 parent 7ce2a5d commit 314decf
Show file tree
Hide file tree
Showing 30 changed files with 217 additions and 1,119 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run Tests

on:
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Extism and XTP
run: |
curl -O https://raw.githubusercontent.com/extism/js-pdk/main/install.sh
sh install.sh
curl https://static.dylibso.com/cli/install.sh | sh
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '21'

- name: Build
run: |
npm i
npm run build
- name: Run test script
run: |
cd tests && ./test.sh
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
node_modules
dist
bundle.zip
bundle
tests/output
output
myplugin
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
# XTP Plugin Bindgen

> *Warning*: This is very experimental and is still in the prototyping phase.
> *Warning*: This is experimental and is still in the alpha phase.
> Changes will be made without warning. Please wait before you start writing new bindgens.
This repository houses the prototype for bingden for typescript plug-ins in XTP.
It's based on the [XTP Schema](https://docs.xtp.dylibso.com/docs/host-usage/xtp-schema)
as the driving document. This document will be used to generate code and documentation
for plug-in systems and is specifically tailored to [Extism](https://extism.org/) at the moment.

When this is integrated into CLI, usage will look something like:
## Building

```bash
xtp gen --template @dylibso/xtp-typescript-bindgen --path ~/my-plugin
An XTP gen template is distributed as a zip file with a `plugin.wasm`, `config.yaml`, and a `templates`
directory of template files. To build this "bundle" run the `bundle.sh` command:

```
./bundle.sh
```

This will grab the `bundle.zip` which contains the plugin and templates from the [latest release](https://github.com/dylibso/xtp-typescript-bindgen/releases/latest).
To test you can use the XTP CLI and `plugin init`. You just need to point it at
a valid [XTP Schema](https://docs.xtp.dylibso.com/docs/host-usage/xtp-schema) file:

```
xtp plugin init --schema-file ./tests/schemas/fruit.yaml --template ./bundle --path myplugin -y
```

[Here is my initial document](DESIGN.md) stating the design of the system. However things are changing as I'm implementing.
This codebase contains a mix of go code and typescript code in order to bootstrap the system. But
eventually all Go code will be genericized and moved into the XTP CLI. A generator will only be
an Extism (usually TypeScript) plugin with some templates and a config file.
> *Note*: If you have not installed the xtp cli:
> curl https://static.dylibso.com/cli/install.sh | sudo sh
4 changes: 3 additions & 1 deletion bundle.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env bash
set -e

npm run build

rm -rf bundle
mkdir bundle
cp -R template/ bundle/template
cp dist/plugin.wasm bundle
cp config.yaml bundle

zip -r bundle.zip bundle/
rm -rf bundle
1 change: 0 additions & 1 deletion dummy.js

This file was deleted.

2 changes: 1 addition & 1 deletion esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ esbuild
name: 'stub-ejs-deps',
setup(build) {
build.onResolve({ filter: dummyResolves }, args => {
return { path: require.resolve('./dummy.js') }
return { path: require.resolve('./src/dummy.js') }
});
},
},
Expand Down
9 changes: 0 additions & 9 deletions go.mod

This file was deleted.

6 changes: 0 additions & 6 deletions go.sum

This file was deleted.

Loading

0 comments on commit 314decf

Please sign in to comment.