Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 0ecad51

Browse files
author
Hendrik van Antwerpen
authored
Merge pull request #164 from github/release-tree-sitter-stack-graphs-typescript
Release tree-sitter-stack-graphs-typescript v0.1.0
2 parents 3286f81 + 78ea5e8 commit 0ecad51

File tree

6 files changed

+143
-19
lines changed

6 files changed

+143
-19
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish tree-sitter-stack-graphs-typescript release
2+
3+
on:
4+
push:
5+
tags:
6+
- tree-sitter-stack-graphs-typescript-v*
7+
8+
jobs:
9+
publish-crate:
10+
runs-on: ubuntu-latest
11+
env:
12+
CARGO_TERM_COLOR: always
13+
CARGO_INCREMENTAL: 0
14+
CRATE_DIR: './languages/tree-sitter-stack-graphs-typescript'
15+
steps:
16+
- name: Install Rust environment
17+
uses: hecrj/setup-rust-action@v1
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
# TODO Verify the crate version matches the tag
21+
- name: Test crate
22+
run: cargo test --all-features
23+
working-directory: ${{ env.CRATE_DIR }}
24+
- name: Verify publish crate
25+
run: cargo publish --dry-run
26+
working-directory: ${{ env.CRATE_DIR }}
27+
- name: Publish crate
28+
run: cargo publish
29+
working-directory: ${{ env.CRATE_DIR }}
30+
env:
31+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
32+
create-release:
33+
needs: publish-crate
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: write
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v3
40+
- name: Create GitHub release
41+
uses: ncipollo/release-action@v1
42+
with:
43+
body: |
44+
Find more info on all releases at https://crates.io/crates/tree-sitter-stack-graphs-typescript.
45+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## Unreleased
9+
10+
### Added
11+
12+
- Stack graph rules, tests, and basic `tsconfig.json` and `package.json` analysis.

languages/tree-sitter-stack-graphs-typescript/Cargo.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ edition = "2018"
1111
[[bin]]
1212
name = "tree-sitter-stack-graphs-typescript"
1313
path = "rust/bin.rs"
14+
required-features = ["cli"]
1415

1516
[lib]
1617
path = "rust/lib.rs"
@@ -20,14 +21,20 @@ test = false
2021
name = "test"
2122
path = "rust/test.rs"
2223
harness = false
24+
required-features = ["test"] # should be a forced feature, but Cargo does not support those
25+
26+
[features]
27+
default = ["test"] # test is enabled by default because we cannot specify it as a forced featured for [[test]] above
28+
cli = ["anyhow", "clap", "tree-sitter-stack-graphs/cli"]
29+
test = ["anyhow", "tree-sitter-stack-graphs/cli"]
2330

2431
[dependencies]
25-
anyhow = "1.0"
26-
clap = "3"
32+
anyhow = { version = "1.0", optional = true }
33+
clap = { version = "3", optional = true }
2734
glob = "0.3"
2835
serde = { version = "1.0", features = ["derive"] }
2936
serde_json = "1.0"
3037
stack-graphs = { version = "0.10", path = "../../stack-graphs" }
31-
tree-sitter-stack-graphs = { version = "0.6", path = "../../tree-sitter-stack-graphs", features=["cli"] }
32-
tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev="082da44a5263599186dadafd2c974c19f3a73d28" }
38+
tree-sitter-stack-graphs = { version = "0.6", path = "../../tree-sitter-stack-graphs" }
39+
tree-sitter-typescript = "0.20.2"
3340
tsconfig = "0.1.0"
Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,98 @@
11
# tree-sitter-stack-graphs definition for TypeScript
22

3-
This project defines tree-sitter-stack-graphs rules for TypeScript using the [tree-sitter-typescript](https://www.npmjs.com/package/tree-sitter-typescript) grammar.
3+
This project defines tree-sitter-stack-graphs rules for TypeScript using the [tree-sitter-typescript][] grammar.
4+
5+
[tree-sitter-typescript]: https://crates.io/crates/tree-sitter-typescript
6+
7+
## Usage
8+
9+
To use this library, add the following to your `Cargo.toml`:
10+
11+
``` toml
12+
[dependencies]
13+
tree-sitter-stack-graphs-typescript = "0.1"
14+
```
15+
16+
Check out our [documentation](https://docs.rs/tree-sitter-stack-graphs-typescript/*/) for
17+
more details on how to use this library.
18+
19+
## Command-line Program
20+
21+
The command-line program for `tree-sitter-stack-graphs-typescript` lets you do
22+
stack graph based analysis and lookup from the command line.
23+
24+
Install the program using `cargo install` as follows:
25+
26+
``` sh
27+
$ cargo install --features cli tree-sitter-stack-graphs-typescript
28+
$ tree-sitter-stack-graphs-typescript --help
29+
```
430

531
## Development
632

33+
The project is written in Rust, and requires a recent version installed.
34+
Rust can be installed and updated using [rustup][].
35+
36+
[rustup]: https://rustup.rs/
37+
38+
739
The project is organized as follows:
840

941
- The stack graph rules are defined in `src/stack-graphs.tsg`.
1042
- Builtins sources and configuration are defined in `src/builtins.ts` and `builtins.cfg` respectively.
1143
- Tests are put into the `test` directory.
1244

13-
Make sure all development dependencies are installed by running:
45+
Build the project by running:
1446

15-
npm install
47+
``` sh
48+
$ cargo build
49+
```
1650

17-
Run all tests in the project by executing the following:
51+
Run the tests as follows:
1852

19-
npm test
53+
``` sh
54+
$ cargo test
55+
```
2056

21-
Parse and test a single file by executing the following commands:
57+
The project consists of a library and a CLI.
58+
By default, running `cargo` only applies to the library.
59+
To run `cargo` commands on the CLI as well, add `--features cli` or `--all-features`.
2260

23-
npm run parse-file test/test.ts
24-
npm run test-file test/test.ts
61+
Run the CLI from source as follows:
2562

26-
Additional flags can be passed to these commands as well. For example, to generate a visualization for the test, execute:
63+
``` sh
64+
$ cargo run --features cli -- ARGS
65+
```
2766

28-
npm run test-file -- -V test/test.ts
67+
Sources are formatted using the standard Rust formatted, which is applied by running:
2968

30-
To generate the visualization regardless of test outcome, execute:
69+
``` sh
70+
$ cargo fmt
71+
```
72+
73+
The stack graph rules are written in [tree-sitter-graph][], which provides a VSCode
74+
extension for syntax highlighting.
75+
76+
[tree-sitter-graph]: https://github.com/tree-sitter/tree-sitter-graph
3177

32-
npm run test-file -- -V --output-mode=always test/test.ts
78+
Parse and test a single file by executing the following commands:
79+
80+
``` sh
81+
$ cargo run --features cli -- parse FILES...
82+
$ cargo run --features cli -- test TESTFILES...
83+
```
84+
85+
Additional flags can be passed to these commands as well. For example, to generate
86+
a visualization for the test, execute:
3387

34-
These commands should be enough for regular development. If necessary, the `tree-sitter-stack-graphs` command can be invoked directly as well, by executing:
88+
``` sh
89+
$ cargo run --features cli -- test -V TESTFILES...
90+
```
91+
92+
To generate the visualization regardless of test outcome, execute:
3593

36-
npx tree-sitter-stack-graphs
94+
``` sh
95+
$ cargo run --features cli -- test -V --output-mode=always TESTFILES...
96+
```
3797

3898
Go to https://crates.io/crates/tree-sitter-stack-graphs for links to examples and documentation.

languages/tree-sitter-stack-graphs-typescript/test/projects/package-dependency-with-nested-source-root.ts renamed to languages/tree-sitter-stack-graphs-typescript/test/projects/package-dependency-with-nested-source-root.ts.skip

File renamed without changes.

stack-graphs/src/cycles.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl HasPathKey for PartialPath {
8484
}
8585
}
8686

87-
const MAX_SIMILAR_PATH_COUNT: usize = 12;
87+
const MAX_SIMILAR_PATH_COUNT: usize = 7;
8888

8989
impl<P> CycleDetector<P>
9090
where

0 commit comments

Comments
 (0)