Skip to content

Commit fa16a64

Browse files
committed
package up protogen
1 parent 1355247 commit fa16a64

File tree

6 files changed

+501
-142
lines changed

6 files changed

+501
-142
lines changed

.github/workflows/build-wasm-linux.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Wasm Linux 🧪
1+
name: Build Wasm 🛠
22

33
on:
44
workflow_dispatch:
@@ -16,16 +16,34 @@ jobs:
1616
node-version: '20.x'
1717
cache: 'yarn'
1818

19-
- name: Install Linux Deps 🧶
19+
- name: Cache Emscripten 📇
20+
uses: actions/cache@v2
21+
with:
22+
path: |
23+
emsdk/upstream
24+
emsdk/node
25+
key: ${{ runner.os }}-emsdk-${{ hashFiles('emsdk/emsdk_manifest.json') }}
26+
restore-keys: |
27+
${{ runner.os }}-emsdk-
28+
29+
- name: Install Emscripten ✍🏻
30+
if: steps.cache-emsdk.outputs.cache-hit != 'true'
2031
run: |
2132
sudo apt-get update
22-
sudo apt-get install -y make
33+
sudo apt-get install cmake python3 python3-pip
34+
git clone --branch 3.1.59 --depth 1 https://github.com/emscripten-core/emsdk.git
35+
cd emsdk
36+
./emsdk install 3.1.59
37+
./emsdk activate 3.1.59
38+
source ./emsdk_env.sh
2339
24-
- name: Install Dependencies 🧶
40+
- name: Build with Emscripten
2541
run: |
26-
yarn
42+
source ./emsdk/emsdk_env.sh
43+
emmake make
2744
28-
- name: Test 🔍
29-
run: |
30-
yarn make:wasm
31-
yarn make build:wasm
45+
- name: Archive production artifacts
46+
uses: actions/upload-artifact@v2
47+
with:
48+
name: compiled-files
49+
path: wasm

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,39 @@
3030
}
3131
},
3232
"scripts": {
33-
"protogen": "node ./script/codegen.js 16-latest",
33+
"protogen": "node ./script/protogen.js 16-latest",
3434
"clean": "rimraf build",
3535
"configure": "node-pre-gyp configure",
3636
"install": "node-pre-gyp install --fallback-to-build --loglevel verbose",
3737
"rebuild": "node-pre-gyp rebuild --loglevel verbose",
38-
"make:wasm": "docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk emmake make",
39-
"build:wasm": "yarn make:wasm build",
40-
"rebuild:wasm": "yarn make:wasm rebuild",
41-
"clean:wasm": "yarn make:wasm clean",
42-
"clean-cache:wasm": "yarn make:wasm clean-cache",
38+
"wasm:make": "docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk emmake make",
39+
"wasm:build": "npm run wasm:make build",
40+
"wasm:rebuild": "npm run wasm:make rebuild",
41+
"wasm:clean": "npm run wasm:make clean",
42+
"wasm:clean-cache": "npm run wasm:make clean-cache",
4343
"test": "mocha --timeout 5000",
4444
"binary:build": "node-pre-gyp rebuild package",
45-
"binary:publish": "AWS_PROFILE=supabase-dev node-pre-gyp publish"
46-
},
45+
"binary:publish": "AWS_PROFILE=supabase-dev node-pre-gyp publish",
46+
"clean:all": "npm run clean && npm run wasm:clean && npm run wasm:clean-cache"
47+
},
4748
"author": "Dan Lynch <[email protected]> (http://github.com/pyramation)",
4849
"license": "LICENSE IN LICENSE",
4950
"repository": {
5051
"type": "git",
5152
"url": "git://github.com/launchql/libpg-query-node.git"
5253
},
5354
"devDependencies": {
54-
"rimraf": "5.0.0",
55+
"@launchql/proto-cli": "1.25.0",
5556
"chai": "^3.5.0",
5657
"emnapi": "^0.43.1",
5758
"lodash": "^4.17.15",
5859
"mocha": "^5.2.0",
59-
"@pgsql/protobufjs-cli": "1.1.5"
60+
"rimraf": "5.0.0"
6061
},
6162
"dependencies": {
6263
"@emnapi/runtime": "^0.43.1",
64+
"@launchql/protobufjs": "7.2.6",
6365
"@mapbox/node-pre-gyp": "^1.0.8",
64-
"@pgsql/protobufjs": "7.2.6",
6566
"node-addon-api": "^7.0.0",
6667
"node-gyp": "^10.0.1"
6768
},
@@ -80,4 +81,4 @@
8081
"host": "https://supabase-public-artifacts-bucket.s3.amazonaws.com",
8182
"remote_path": "./libpg-query-node/"
8283
}
83-
}
84+
}

proto.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
(function(global, factory) { /* global define, require, module */
33

44
/* AMD */ if (typeof define === 'function' && define.amd)
5-
define(["@pgsql/protobufjs/minimal"], factory);
5+
define(["@launchql/protobufjs/minimal"], factory);
66

77
/* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports)
8-
module.exports = factory(require("@pgsql/protobufjs/minimal"));
8+
module.exports = factory(require("@launchql/protobufjs/minimal"));
99

1010
})(this, function($protobuf) {
1111
"use strict";

script/codegen.js

Lines changed: 0 additions & 77 deletions
This file was deleted.

script/protogen.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const https = require('https');
2+
const fs = require('fs');
3+
const { exec } = require('child_process');
4+
5+
if (typeof process.argv[2] !== 'string') {
6+
throw new Error('branchName not provided');
7+
}
8+
9+
// Configuration Variables
10+
const branchName = process.argv[2];
11+
const protoUrl = `https://raw.githubusercontent.com/pganalyze/libpg_query/${branchName}/protobuf/pg_query.proto`;
12+
const inFile = 'libpg_query/protobuf/pg_query.proto';
13+
const outFile = 'proto.js';
14+
15+
const protogenCmd = [
16+
'pg-proto-parser',
17+
'protogen',
18+
'--protoUrl',
19+
protoUrl,
20+
'--inFile',
21+
inFile,
22+
'--outFile',
23+
outFile,
24+
'--originalPackageName',
25+
'protobufjs/minimal',
26+
'--newPackageName',
27+
'@launchql/protobufjs/minimal'
28+
];
29+
30+
// Step 2: Generate proto.js using pbjs (Assuming pbjs is installed and accessible)
31+
function generateProtoJS(callback) {
32+
exec(protogenCmd.join(' '), (error, stdout, stderr) => {
33+
if (error) {
34+
console.error(`Error during code generation: ${error.message}`);
35+
return;
36+
}
37+
console.log('Generated proto.js from proto file.');
38+
callback();
39+
});
40+
}
41+
42+
generateProtoJS(() => {
43+
console.log('all done 🎉');
44+
});

0 commit comments

Comments
 (0)