Skip to content

Commit 38f03df

Browse files
committed
Add basic support for Typescript scanning
1 parent 3ad4558 commit 38f03df

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Contained within this repository is a comprehensive and automated code graph ana
99
## ✨ Features
1010

1111
- Analyze static Java code structure as a graph
12+
- Also supports Typescript (experimental)
1213
- Fully automated [pipeline](./.github/workflows/code-structure-analysis.yml) from tool installation to report generation
1314
- More than 130 CSV reports for dependencies, metrics, cycles, annotations, algorithms and many more
1415
- Jupyter notebook reports for dependencies, metrics, visibility and many more
@@ -78,6 +79,13 @@ These tools are needed to run the graph visualization scripts of directory [grap
7879
- Add this line to your `~/.bashrc` file if you are using Anaconda3: `/c/ProgramData/Anaconda3/etc/profile.d/conda.sh`. Try to find a similar script for other conda package managers or versions.
7980
- Run `conda init` in the git bash opened as administrator. Running it in normal mode usually leads to an error message.
8081

82+
### Additional Prerequisites for analyzing Typescript
83+
84+
- Please follow the description on how to create a json file with the static code information
85+
of your Typescript project here: https://github.com/jqassistant-plugin/jqassistant-typescript-plugin
86+
- Example: Run `npx --yes @jqassistant/ts-lce` in your Typescript package.
87+
- Copy the resulting json file (e.g. `.reports/jqa/ts-output.json`) into the "artifacts" directory for your analysis work directory. Custom subdirectories within "artifacts" are also supported.
88+
8189
## 🚀 Getting Started
8290

8391
See [GETTING_STARTED.md](./GETTING_STARTED.md) on how to get started on your local machine.
@@ -92,7 +100,7 @@ The [Code Structure Analysis Pipeline](./.github/workflows/code-structure-analys
92100
- [Setup Python with Conda](https://github.com/conda-incubator/setup-miniconda) package manager [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge)
93101
- Download artifacts that contain the code to be analyzed [scripts/artifacts](./scripts/downloader/)
94102
- Setup [Neo4j](https://neo4j.com) Graph Database ([analysis.sh](./scripts/analysis/analyze.sh))
95-
- Setup [jQAssistant](https://jqassistant.org/get-started) for Java Analysis ([analysis.sh](./scripts/analysis/analyze.sh))
103+
- Setup [jQAssistant](https://jqassistant.org/get-started) for Java and [Typescript](https://github.com/jqassistant-plugin/jqassistant-typescript-plugin) analysis ([analysis.sh](./scripts/analysis/analyze.sh))
96104
- Start [Neo4j](https://neo4j.com) Graph Database ([analysis.sh](./scripts/analysis/analyze.sh))
97105
- Generate CSV Reports [scripts/reports](./scripts/reports) using the command line JSON parser [jq](https://jqlang.github.io/jq)
98106
- Generate [Jupyter Notebook](https://jupyter.org) reports using these libraries specified in the [environment.yml](./jupyter/environment.yml):
@@ -109,7 +117,7 @@ The [Code Structure Analysis Pipeline](./.github/workflows/code-structure-analys
109117
- [wordcloud](https://github.com/amueller/word_cloud)
110118
- [Graph Visualization](./graph-visualization/README.md) uses [node.js](https://nodejs.org/de) and the dependencies listed in [package.json](./graph-visualization/package.json).
111119

112-
**Big shout-out** 📣 to all the creators and contributors of these great libraries 👍. Projects like this wouldn't be possible without them. Feel free to [create an issue](https://github.com/JohT/code-graph-analysis-pipeline/issues/new/choose) if i've forgotten something in the list.
120+
**Big shout-out** 📣 to all the creators and contributors of these great libraries 👍. Projects like this wouldn't be possible without them. Feel free to [create an issue](https://github.com/JohT/code-graph-analysis-pipeline/issues/new/choose) if something is missing or wrong in the list.
113121

114122
## 🛠 Command Reference
115123

scripts/findTypescriptDataFiles.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
# Echoes a list of Typescript data files starting with "ts-" and having extension "json" in the artifacts directory of sub directories.
4+
# Each name will be prefixed by "typescript:project::"and separated by one space character.
5+
# This list is meant to be used after the "-f" line command option for the jQAssistant scan command to include Typescript data files.
6+
7+
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
8+
set -o errexit -o pipefail
9+
10+
ARTIFACTS_DIRECTORY=${ARTIFACTS_DIRECTORY:-"artifacts"}
11+
12+
# Check if the artifacts directory exists
13+
if [ ! -d "./${ARTIFACTS_DIRECTORY}" ] ; then
14+
echo "" # The artifact directory doesn't exist. There is no file at all.
15+
exit 0
16+
fi
17+
18+
find "./${ARTIFACTS_DIRECTORY}" -type f -name 'ts-*.json' -exec echo {} \; | sed 's/^/typescript:project::/' | tr '\n' ' '

scripts/resetAndScan.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# CAUTION: This script deletes all relationships and nodes in the Neo4j Graph Database.
66
# Note: The environment variable NEO4J_INITIAL_PASSWORD is required to login to Neo4j.
77

8+
# Requires findTypescriptDataFiles.sh
89

910
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
1011
set -o errexit -o pipefail
@@ -65,10 +66,12 @@ else
6566
echo "resetAndScan: jQAssistant configuration won't be changed since it already exists."
6667
fi
6768

69+
directoriesAndFilesToScan="${ARTIFACTS_DIRECTORY} $(source ${SCRIPTS_DIR}/findTypescriptDataFiles.sh)"
70+
6871
# Use jQAssistant to scan the downloaded artifacts and write the results into the separate, local Neo4j Graph Database
69-
echo "resetAndScan: Scanning ${ARTIFACTS_DIRECTORY} with jQAssistant CLI version ${JQASSISTANT_CLI_VERSION}"
72+
echo "resetAndScan: Using jQAssistant CLI version ${JQASSISTANT_CLI_VERSION} to scan: ${directoriesAndFilesToScan}"
7073

71-
"${JQASSISTANT_BIN}"/jqassistant.sh scan -f ./${ARTIFACTS_DIRECTORY}
74+
"${JQASSISTANT_BIN}"/jqassistant.sh scan -f ./${directoriesAndFilesToScan}
7275

7376
# Use jQAssistant to add dependencies between artifacts, package dependencies, artifact dependencies and the java version to the Neo4j Graph Database
7477
echo "resetAndScan: Analyzing ${ARTIFACTS_DIRECTORY} with jQAssistant CLI version ${JQASSISTANT_CLI_VERSION}"

0 commit comments

Comments
 (0)