Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Find function-level association impacts of code changes

NotificationsYou must be signed in to change notification settings

CocaColf/coderfly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English |中文

coderfly

Find function-level association impacts of code changes.

Background

When you modify the code of a large project, it may not be very clear whether it will have an impact on the functionality.Our self-test may not be enough, and we need to search a lot of related code to determine the impact of the change. Wouldn't it save a lot of time and improve the quality of self-testing if there was a tool that could identify your changes and automatically find out what you affected by the change?

That's the problem this project is trying to solve.

It can analyze the changes of the function by the changes of the file.

function change

Then we analyze the impact of this function from the whole project. From the picture blow(a part of the result), we can see that this function is called byjumpToAppStore and affects the click event bound to a dom node ofheader.vue.

result

You can checkhow it works from here.

Install

This project is still under development and has not been published to the npm yet. So you can use the built files for now.

  • clone this project
  • yarn install
  • yarn build

Usage

Using the command line

coderfly check <folder path>

Options:

  • alias: Set path alias, alias and path should be linked with acolon. eg:coderfly check ./src -alias src:./src static:./public

  • t ortree: Export the file tree to a file, the file defaults tofile_tree.json. eg:coderfly check ./src -t

Configuration file:

You can also write configuration file named.coderflyrc.js, mainly to simplify alias.

// .coderflyrc.jsconstpath=require('path');module.exports={'src':path.resolve(process.cwd(),'test'),// ...}

The results are written to the impact_report.json file in the directory where the command was executed

command line

Using the API

see theAPI orExample.

API

coderfly

The API for the complete process is included, use this for a one-step process if you don't need control the process yourself.

Params

  • srcPath: string. It's source code folder path

diff

Get the changes of the function by the changes of the file.

If you changedtest/a.js, you can get the following result by diff.

{file:'test/a.js',changed:['getSum'],added:[],deleted:['getData'],total:['getSum','getData']}

getAllFiles

Get all files from source code, filter by default for non-.vue.js.ts files.

Params

  • folderPath: string. It's source code folder path.

getFuncTree

Analyze the project and build a 「file tree」.

Params

  • files: string[]. All the files from folder path
  • options: Options
interfaceOptions{alias?:{[aliasName:string]:string// alias name and path};}

getImpacts**

Get the impact of changes.

Params

  • treeData: FileInfoTree. It's file tree.
  • funcInfo: ImpactReason. It's the entry function that we get by diff.
interfaceImpactReason{filePath:string;name:string;}

matchVueVersion

Since the use ofvue-template-compiler must be consistent with thevue version, otherwise an error will be reported, you must keep them both consistent before usingcoderfly. You can either manually install the corresponding version ofvue-template-compiler in your project yourself, or you can use the API to do this in your code. Note that this operation needs to be called before using the other APIs.

Example

Easy to use

// if necessaryconst{ matchVueVersion}=require('coderfly/dist/match_version');matchVueVersion();const{ coderfly}=require('coderfly');coderfly('./src');

If you want you control the process yourself

// if necessaryconst{ matchVueVersion}=require('coderfly/dist/match_version');matchVueVersion();const{ diff, getAllFiles, getFuncTree, getImpacts}=require('coderfly');// diffconstfunctionDiffInfo=diff();// get all filesconstfiles=getAllFiles(path.resolve(process.cwd(),targetDir));// build file treeconsttree=getFuncTree(files,{alias:{src:path.resolve(process.cwd(),'./demo/vue')}});// get impacts// here is just a example, in the real word the second argument needs constructed using the result of diff()letimpacts=getImpacts(tree,{filePath:'src/utils/a.js',name:'getSum'});console.log(impacts);

Support

  • JavaScript
  • Vue2
  • TypeScript
  • Vue3

how it works

how it works

License

MIT License

About

Find function-level association impacts of code changes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp