Skip to content

Commit 98ac0e4

Browse files
committed
v0.0.7
1 parent db05cac commit 98ac0e4

File tree

7 files changed

+57
-35
lines changed

7 files changed

+57
-35
lines changed

.github/workflows/publish-release.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ jobs:
2424
node:
2525
- 14
2626
- 16
27-
include:
28-
- os: macos-m1
29-
node: 16
30-
host: arm64
31-
target: arm64
27+
- 18
28+
# include:
29+
# - os: macos-m1
30+
# node: 16
31+
# host: arm64
32+
# target: arm64
3233
name: ${{ matrix.os }} (node=${{ matrix.node }}, host=${{ matrix.host }}, target=${{ matrix.target }})
3334
steps:
3435
- uses: actions/checkout@v3
@@ -56,16 +57,8 @@ jobs:
5657
- name: Package prebuilt binaries
5758
run: npx node-pre-gyp package --target_arch=${{ matrix.target }}
5859

59-
- name: Upload binaries to commit artifacts
60-
uses: actions/upload-artifact@v3
61-
if: matrix.node == 16
62-
with:
63-
name: prebuilt-binaries
64-
path: build/stage/*/*
65-
retention-days: 7
66-
6760
- name: Upload binaries to GitHub Release
6861
run: node ./scripts/ghPublish.mjs
69-
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/')
62+
if: startsWith(github.ref, 'refs/tags/')
7063
env:
7164
NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }}

bindings/node/apex.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require("./index").apex;
1+
module.exports = require("./index").then((val) => val.apex);

bindings/node/index.js

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,50 @@
1+
let exportedValues = {};
12
try {
2-
module.exports = require("../../build/Release/tree_sitter_sfapex_binding");
3-
} catch (error1) {
4-
if (error1.code !== "MODULE_NOT_FOUND") {
5-
throw error1;
6-
}
3+
exportedValues = require("node-gyp-build")(__dirname + "/../../");
4+
} catch (errorA) {
75
try {
8-
module.exports = require("../../build/Debug/tree_sitter_sfapex_binding");
9-
} catch (error2) {
10-
if (error2.code !== "MODULE_NOT_FOUND") {
11-
throw error2;
6+
exportedValues = require("../../build/Release/tree_sitter_sfapex_binding");
7+
} catch (errorB) {
8+
if (errorB.code !== "MODULE_NOT_FOUND") {
9+
throw errorB;
10+
}
11+
try {
12+
exportedValues = require("../../build/Debug/tree_sitter_sfapex_binding");
13+
} catch (errorC) {
14+
if (errorC.code !== "MODULE_NOT_FOUND") {
15+
throw errorC;
16+
}
17+
// TODO: load WASM instead?? Not sure how to make it hot-swappable
18+
// but leaving it async load to leave the door open
19+
// exportedValues = getWasmModules();
20+
throw errorA;
1221
}
13-
throw error1;
1422
}
1523
}
1624

17-
try {
18-
module.exports.apex.nodeTypeInfo = require("../../apex/src/node-types.json");
19-
module.exports.soql.nodeTypeInfo = require("../../soql/src/node-types.json");
20-
module.exports.sosl.nodeTypeInfo = require("../../sosl/src/node-types.json");
21-
} catch (_) {}
25+
// Eventually, should be able to load the WASM module as a direct swap for the native... life goal
26+
async function getWasmModules() {
27+
const TreeSitter = require(__dirname +
28+
"/../../prebuilds/wasm/tree-sitter.js");
29+
await TreeSitter.init();
30+
return {
31+
apex: await TreeSitter.Language.load(
32+
__dirname + "/../../prebuilds/wasm/tree-sitter-apex.wasm"
33+
),
34+
soql: await TreeSitter.Language.load(
35+
__dirname + "/../../prebuilds/wasm/tree-sitter-soql.wasm"
36+
),
37+
sosl: await TreeSitter.Language.load(
38+
__dirname + "/../../prebuilds/wasm/tree-sitter-sosl.wasm"
39+
),
40+
};
41+
}
42+
43+
module.exports = Promise.resolve(exportedValues).then((mod) => {
44+
try {
45+
mod.apex.nodeTypeInfo = require("../../apex/src/node-types.json");
46+
mod.soql.nodeTypeInfo = require("../../soql/src/node-types.json");
47+
mod.sosl.nodeTypeInfo = require("../../sosl/src/node-types.json");
48+
} catch (_) {}
49+
return mod;
50+
});

bindings/node/soql.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require("./index").soql;
1+
module.exports = require("./index").then((val) => val.soql);

bindings/node/sosl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require("./index").sosl;
1+
module.exports = require("./index").then((val) => val.sosl);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"build-apex": "cd apex && npx tree-sitter generate --no-bindings",
2929
"build-soql": "cd soql && npx tree-sitter generate --no-bindings",
3030
"build-sosl": "cd sosl && npx tree-sitter generate --no-bindings",
31-
"test-load": "node -e \"console.log(require('./apex').name, require('./soql').name, require('./sosl').name)\"",
31+
"test-load": "node -e \"require('./apex').then(apex => console.log(apex.name)), require('./soql').then(soql => console.log(soql.name)), require('./sosl').then(sosl => console.log(sosl.name))\"",
3232
"test": "npm run test-apex && npm run test-soql && npm run test-sosl && npm run test-load",
3333
"test-apex": "cd apex && npx tree-sitter test",
3434
"test-soql": "cd soql && npx tree-sitter test",

0 commit comments

Comments
 (0)