0.0.2 • Published 1 year ago

annikel-testfd v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Framework Detect

This project is a framework detection tool. It detects the frameworks used in a project by analyzing code structure and dependencies.

  • Detect different root repositories
  • Detect used frameworks for remote repositories hosted on GitHub or Azure DevOps
  • Detect frameworks used on local projects
  • Detect if represented framework is app or API framework

Important Notes

If you have suggestions or you encounter issues, please report them or help us fix them. Your contributions are very much appreciated. 🙏

Working with the project

This project is the source for the npm package @azure/framework-detect

The files are organized as follows:

src/lib
|- detect.ts         The core framework detect logic 
|- frameworks        Framework definitions in JSON format and file helper
|- providers         Client logic to read data from GitHub, DevOps or Local files

Functions

detectProjectFolders

Detects and returns all framework represented in the repository

Parameters: 1. projectPath: the full path the project to be analyzed. This can either be a local path or a full url containing the provider host (e.g.https://github.com/{owner}/{repository}) 2. apiKey: PAT (Personal Access Token) with read access to the references repository. Only required in case of remote repository.

Example Usage

const { detectProjectFolders } = require("@azure/framework-detect");

async function detect(rootPath, apiToken) {
  const folders = await detectProjectFolders(rootPath, apiToken);
  return JSON.stringify(folders);
}

formatDetectedFolders

Formats the detected folders

Parameters: 1. folders: the folders to be formatted

printSupportedFrameworks

Returns all supported frameworks wit definition

Parameters: 1. showList: when set to true will console log the framework defintions

Contribute

To add missing frameworks or update existing ones simply edit the api.json or app.json file under src\lib\frameworks and create a pull requests. Framework Definition do not require a new npm package version since we point to the file hosted on GitHub. Objects added to app.json for framework detections follow the interface defined in /src/types.ts, function FrameworkDefinition.

Testing framework detection

Before running tests, you have to import projects samples generated by this repo.

Use the following command to import the samples:

npm run get-samples

It will download the samples in the test/samples folder.

Then you can run all the tests with:

npm run build && npm test

all tests in test/remote-detect.spec.js require a valid PAT and repositories the PAT has access to