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

A few more improvements before we go live #2

Merged
merged 13 commits into from
Jul 15, 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
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
Loading