Skip to content

Commit

Permalink
Implement version (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
kearfy authored May 16, 2024
1 parent 2d2a49d commit 5d5d444
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 191 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on: push

jobs:
build:
name: Attempt Build
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Install Node & NPM"
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
- name: "Install wasm-pack"
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Install jq
uses: dcarbone/[email protected]

- name: "Install NPM dependencies"
run: npm install
- name: "Build & Bundle"
run: npm run build
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- name: "Install wasm-pack"
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Install jq
uses: dcarbone/[email protected]

- name: "Install NPM dependencies"
run: npm install
- name: "Build & Bundle"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ Temporary Items

*.db
*.sw?
src/surrealdb-version
5 changes: 5 additions & 0 deletions extract-surrealdb-version.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

VERSION="$( cargo metadata --format-version=1 --no-deps | jq -c '.packages[0].dependencies[] | select( .name == "surrealdb" ) | .req | match("^\\^?(.*)"; "i") | .captures[0].string' | sed 's:^.\(.*\).$:\1:' )"

echo -n $VERSION > src/surrealdb-version
4 changes: 4 additions & 0 deletions lib-src/embedded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export function surrealdbWasmEngines(opts?: ConnectionOptions) {
this.emitter = emitter;
}

async version(): Promise<string> {
return Swe.version();
}

setStatus<T extends ConnectionStatus>(
status: T,
...args: EngineEvents[T]
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@
},
"scripts": {
"serve": "esbuild --bundle --servedir=.",
"build": "pnpm compile && pnpm build-literal && tsc",
"build": "pnpm extract-surrealdb-version && pnpm compile && pnpm build-literal && tsc",
"compile": "wasm-pack build --release --target deno --out-name index --out-dir compiled/embedded --no-default-features --features kv-indxdb,kv-mem",
"build-literal": "node build/index.js"
"build-literal": "node build/index.js",
"extract-surrealdb-version": "bash ./extract-surrealdb-version.bash"
},
"devDependencies": {
"esbuild": "^0.17.19",
"esbuild-plugin-copy-file": "^0.0.2",
"typescript": "^5.4.5"
},
"dependencies": {
"surrealdb.js": "^1.0.0-beta.5",
"surrealdb.js": "^1.0.0-beta.7",
"zod": "^3.22.5"
},
"peerDependencies": {
"surrealdb.js": "^1.0.0-beta.5"
"surrealdb.js": "^1.0.0-beta.7"
}
}
Loading

0 comments on commit 5d5d444

Please sign in to comment.