-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from amaanq/fixes
Misc. Fixes
- Loading branch information
Showing
23 changed files
with
428 additions
and
198 deletions.
There are no files selected for viewing
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,21 @@ | ||
module.exports = { | ||
'env': { | ||
'commonjs': true, | ||
'es2021': true, | ||
}, | ||
'extends': 'google', | ||
'overrides': [ | ||
], | ||
'parserOptions': { | ||
'ecmaVersion': 'latest', | ||
'sourceType': 'module', | ||
}, | ||
'rules': { | ||
'indent': ['error', 2, {'SwitchCase': 1}], | ||
'max-len': [ | ||
'error', | ||
{'code': 160, 'ignoreComments': true, 'ignoreUrls': true, 'ignoreStrings': true}, | ||
], | ||
'one-var': ['error', 'consecutive'], | ||
}, | ||
}; |
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,2 +1,6 @@ | ||
/src/** linguist-vendored | ||
/examples/* linguist-vendored | ||
|
||
src/grammar.json -diff | ||
src/node-types.json -diff | ||
src/parser.c -diff |
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,19 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install modules | ||
run: npm install | ||
- name: Run ESLint | ||
run: npm run lint |
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,103 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
branches: | ||
- master | ||
types: | ||
- completed | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get previous commit SHA | ||
id: get_previous_commit | ||
run: | | ||
LATEST_TAG=$(git describe --tags --abbrev=0) | ||
if [[ -z "$LATEST_TAG" ]]; then | ||
echo "No tag found. Failing..." | ||
exit 1 | ||
fi | ||
echo "latest_tag=${LATEST_TAG#v}" >> "$GITHUB_ENV" # Remove 'v' prefix from the tag | ||
- name: Check if version changed and is greater than the previous | ||
id: version_check | ||
run: | | ||
# Compare the current version with the version from the previous commit | ||
PREVIOUS_NPM_VERSION=${{ env.latest_tag }} | ||
CURRENT_NPM_VERSION=$(jq -r '.version' package.json) | ||
CURRENT_CARGO_VERSION=$(awk -F '"' '/^version/ {print $2}' Cargo.toml) | ||
if [[ "$CURRENT_NPM_VERSION" != "$CURRENT_CARGO_VERSION" ]]; then # Cargo.toml and package.json versions must match | ||
echo "Mismatch: NPM version ($CURRENT_NPM_VERSION) and Cargo.toml version ($CURRENT_CARGO_VERSION)" | ||
echo "version_changed=false" >> "$GITHUB_ENV" | ||
else | ||
if [[ "$PREVIOUS_NPM_VERSION" == "$CURRENT_NPM_VERSION" ]]; then | ||
echo "version_changed=" >> "$GITHUB_ENV" | ||
else | ||
IFS='.' read -ra PREVIOUS_VERSION_PARTS <<< "$PREVIOUS_NPM_VERSION" | ||
IFS='.' read -ra CURRENT_VERSION_PARTS <<< "$CURRENT_NPM_VERSION" | ||
VERSION_CHANGED=false | ||
for i in "${!PREVIOUS_VERSION_PARTS[@]}"; do | ||
if [[ ${CURRENT_VERSION_PARTS[i]} -gt ${PREVIOUS_VERSION_PARTS[i]} ]]; then | ||
VERSION_CHANGED=true | ||
break | ||
elif [[ ${CURRENT_VERSION_PARTS[i]} -lt ${PREVIOUS_VERSION_PARTS[i]} ]]; then | ||
break | ||
fi | ||
done | ||
echo "version_changed=$VERSION_CHANGED" >> "$GITHUB_ENV" | ||
echo "current_version=${CURRENT_NPM_VERSION}" >> "$GITHUB_ENV" | ||
fi | ||
fi | ||
- name: Display result | ||
run: | | ||
echo "Version bump detected: ${{ env.version_changed }}" | ||
- name: Fail if version is lower | ||
if: env.version_changed == 'false' | ||
run: exit 1 | ||
|
||
- name: Setup Node | ||
if: env.version_changed == 'true' | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
registry-url: "https://registry.npmjs.org" | ||
- name: Publish to NPM | ||
if: env.version_changed == 'true' | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
run: npm publish | ||
|
||
- name: Setup Rust | ||
if: env.version_changed == 'true' | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- name: Publish to Crates.io | ||
if: env.version_changed == 'true' | ||
uses: katyo/publish-crates@v2 | ||
with: | ||
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
|
||
- name: Tag versions | ||
if: env.version_changed == 'true' | ||
run: | | ||
git checkout master | ||
git config user.name github-actions[bot] | ||
git config user.email github-actions[bot]@users.noreply.github.com | ||
git tag -d "v${{ env.current_version }}" || true | ||
git push origin --delete "v${{ env.current_version }}" || true | ||
git tag -a "v${{ env.current_version }}" -m "Version ${{ env.current_version }}" | ||
git push origin "v${{ env.current_version }}" |
Empty file.
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 |
---|---|---|
|
@@ -3,8 +3,8 @@ name = "tree-sitter-go" | |
description = "Go grammar for the tree-sitter parsing library" | ||
version = "0.19.1" | ||
authors = [ | ||
"Max Brunsfeld <[email protected]>", | ||
"Douglas Creager <[email protected]>", | ||
"Max Brunsfeld <[email protected]>", | ||
"Douglas Creager <[email protected]>", | ||
] | ||
license = "MIT" | ||
readme = "bindings/rust/README.md" | ||
|
@@ -14,12 +14,7 @@ repository = "https://github.com/tree-sitter/tree-sitter-go" | |
edition = "2018" | ||
|
||
build = "bindings/rust/build.rs" | ||
include = [ | ||
"bindings/rust/*", | ||
"grammar.js", | ||
"queries/*", | ||
"src/*", | ||
] | ||
include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"] | ||
|
||
[lib] | ||
path = "bindings/rust/lib.rs" | ||
|
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
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,28 +1,30 @@ | ||
#include "nan.h" | ||
#include "tree_sitter/parser.h" | ||
#include <node.h> | ||
#include "nan.h" | ||
|
||
using namespace v8; | ||
|
||
extern "C" TSLanguage * tree_sitter_go(); | ||
extern "C" TSLanguage *tree_sitter_go(); | ||
|
||
namespace { | ||
|
||
NAN_METHOD(New) {} | ||
|
||
void Init(Local<Object> exports, Local<Object> module) { | ||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New); | ||
tpl->SetClassName(Nan::New("Language").ToLocalChecked()); | ||
tpl->InstanceTemplate()->SetInternalFieldCount(1); | ||
|
||
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked(); | ||
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked(); | ||
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_go()); | ||
|
||
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("go").ToLocalChecked()); | ||
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); | ||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New); | ||
tpl->SetClassName(Nan::New("Language").ToLocalChecked()); | ||
tpl->InstanceTemplate()->SetInternalFieldCount(1); | ||
|
||
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked(); | ||
Local<Object> instance = | ||
constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked(); | ||
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_go()); | ||
|
||
Nan::Set(instance, Nan::New("name").ToLocalChecked(), | ||
Nan::New("go").ToLocalChecked()); | ||
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); | ||
} | ||
|
||
NODE_MODULE(tree_sitter_go_binding, Init) | ||
|
||
} // namespace | ||
} // namespace |
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,19 +1,19 @@ | ||
try { | ||
module.exports = require("../../build/Release/tree_sitter_go_binding"); | ||
module.exports = require('../../build/Release/tree_sitter_go_binding'); | ||
} catch (error1) { | ||
if (error1.code !== 'MODULE_NOT_FOUND') { | ||
throw error1; | ||
} | ||
try { | ||
module.exports = require("../../build/Debug/tree_sitter_go_binding"); | ||
module.exports = require('../../build/Debug/tree_sitter_go_binding'); | ||
} catch (error2) { | ||
if (error2.code !== 'MODULE_NOT_FOUND') { | ||
throw error2; | ||
} | ||
throw error1 | ||
throw error1; | ||
} | ||
} | ||
|
||
try { | ||
module.exports.nodeTypeInfo = require("../../src/node-types.json"); | ||
module.exports.nodeTypeInfo = require('../../src/node-types.json'); | ||
} catch (_) {} |
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
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
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
Oops, something went wrong.