-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afef40f
commit 7112e85
Showing
49 changed files
with
10,081 additions
and
593 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: JS CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
rust: | ||
- stable | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/[email protected] | ||
|
||
- name: Setup Deno | ||
uses: denoland/[email protected] | ||
|
||
- name: NPM install with caching | ||
run: npm install | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Node Test | ||
run: npm run test | ||
|
||
- name: Deno Test | ||
run: deno test -A ./tests/mod.test.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,130 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb | ||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"printWidth": 120, | ||
"trailingComma": "all", | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
{ | ||
"rust-analyzer.linkedProjects": [ | ||
|
||
"deno.enable": true, | ||
"deno.lint": true, | ||
"deno.unstable": true, | ||
"deno.enablePaths": [ | ||
"./src/deno/mod.ts", | ||
"./examples/deno.ts", | ||
"./tests/mod.test.ts" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.PHONY: test | ||
|
||
prepare: | ||
npm install | ||
|
||
build: | ||
npm run build | ||
|
||
test: prepare | ||
npm run test | ||
deno test -A .\tests\mod.test.ts | ||
|
||
clean: | ||
echo "No clean implemented" | ||
|
||
publish: clean prepare build | ||
npm publish | ||
|
||
format: | ||
npx prettier --write src | ||
|
||
lint: | ||
npx prettier --check src | ||
|
||
docs: | ||
npx typedoc --out doc src | ||
|
||
show-docs: docs | ||
open doc/index.html | ||
|
||
update-kernel: | ||
node update-kernel.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
# pg_extism | ||
An Extism sample showing how you can run Extism plugins from PostgreSQl using pgrx! | ||
|
||
## Run Examples: | ||
|
||
``` | ||
npm run build | ||
node --experimental-wasi-unstable-preview1 ./examples/node.js wasm/config.wasm | ||
deno run -A ./examples/deno.js ./wasm/config.wasm | ||
bun run ./examples/node.js wasm/config.wasm | ||
``` | ||
|
||
## Update `extism-kernel.wasm`: | ||
We are shipping an embedded kernel in base64 form in plugin.ts. To update it, you can run these commands: | ||
``` | ||
cargo pgx run pg14 | ||
make update-kernel | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const { build } = require("esbuild"); | ||
const { peerDependencies } = require('./package.json') | ||
const { readFile, writeFile } = require('fs').promises | ||
const { render } = require('ejs'); | ||
|
||
async function main() { | ||
const sharedConfig = { | ||
bundle: true, | ||
minify: false, | ||
drop: [], // preseve debugger statements | ||
external: Object.keys(peerDependencies || {}), | ||
}; | ||
|
||
const path = "dist/index.js"; | ||
|
||
// NodeJS CSJ | ||
await build({ | ||
...sharedConfig, | ||
entryPoints: ["src/index.ts"], | ||
platform: 'browser', // for CJS | ||
format: "cjs", | ||
outfile: path, | ||
external: [] | ||
}); | ||
|
||
// remove `module.exports = __toCommonJS(src_exports);` | ||
const file = await readFile(path, 'utf8'); | ||
const content = file.replace(/module\.exports = __toCommonJS\(src_exports\);/g, ''); | ||
await writeFile(path, content); | ||
|
||
const template = await readFile('template.sql', 'utf8'); | ||
const sql = render(template, { content: indent(content, 1) }); | ||
|
||
await writeFile('dist/index.sql', sql, 'utf8'); | ||
} | ||
|
||
function indent(text, depth) { | ||
let output = ''; | ||
for (const line of text.split("\n")) { | ||
if (output != '') { // don't indent first line | ||
for (let i = 0; i < depth; i++) { | ||
output += ' '; | ||
} | ||
} | ||
|
||
output += line + '\n'; | ||
} | ||
|
||
return output; | ||
} | ||
|
||
main() |
Oops, something went wrong.