@smash-gift/impact_analyzer
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Impact Analyzer

A tool to identify impacts in typescript projects.


Motivation

Some of our projects mainly consists of a large monorepo with node + typescript + google functions/triggers. When we need to change something, it can sometimes be challenging to pinpoint where the change has impacted, especially for newcomers who may not be familiar with everything happening in the project.

That's why we created this tool to help identify potential impacts of a change.

Usage/Examples

Install

npm install -g impact_analyzer
# or
yarn add global impact_analyzer

# and after install:
impact_analyzer <dir> <file> <line> --output <type>

you can see more about outputs here: Output Types

Here's an example scenario:

function amazingEndpoint() {
	return someComplexDataFromDb()
}

function someComplexDataFromDb() {
	const data = db.getData()
	return someUtilFunc(data)
}

function someUtilFunc(data) {
	// modified code snippet here
	return {
		...data,
		id: 'newId',
	}
}

To get the impact of the modification within someUtilFunc, exec this command:

impact_analyzer /Users/myAccount/Desktop/project/src index.ts 11 --output json
# you can export the result for a file that way:
impact_analyzer /Users/myAccount/Desktop/project/src index.ts 11 --output json >> output.json

Sample Output:

{
	"name": "someUtilFunc",
	"path": "/Users/myAccount/Desktop/project/src",
	"relations": [
		{
			"name": "someComplexDataFromDb",
			"path": "/Users/myAccount/Desktop/project/src",
			"relations": [
				{
					"name": "amazingEndpoint",
					"path": "/Users/myAccount/Desktop/project/src",
					"relations": []
				}
			]
		}
	]
}

This output enables comprehensive traversal of all related references, facilitating a thorough understanding of the impact of changes made.

Next steps

  • [x] Find all places that implement a method or a global variable.
  • [x] Create a 'binary tree' starting from the change to the head.
  • [ ] Create a way to use output templates
  • [ ] Create a way to use input templates
  • [ ] Create npm package
  • [ ] Create an input template to get changes in a git diff
  • [ ] Create CLI tool
  • [ ] Improve file system to accept windows file system
  • [ ] Add rules to exclude directories and files(to exclude test files and this kind of stuffs)
  • [ ] Refine to be able to import Parser inside a project
  • [ ] Create types

Thanks

  • Sander Verweij and other people who collaborated on dependency-cruiser - an amazing library to validate and visualise dependencies that I got a lot of inspiration to create that project

Package Sidebar

Install

npm i @smash-gift/impact_analyzer

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

70.8 kB

Total Files

60

Last publish

Collaborators

  • thawanc