annikel-test-framework
v0.0.19
Published
Detect, inspect and extract build and deploy configuration from JavaScript frameworks and libraries
Downloads
36
Maintainers
Readme
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:
- 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})
- apiKey: PAT (Personal Access Token) with read access to the references repository. Only required in case of remote repository.
- filterDescendantFolders: decides is descendant folders should be filtered (defaults to true).
- customFrameworkDefinitions: use custom framework definitions as source for detection. Must be passed in as list of framework definitions.
- customFrameworkDefinitionsUrl: use custom framework definitions url as source for detection. Must be passed in as valid URL.
Sample:
[
{
"id": "custom",
"name": "Custom Name",
"kind": "app",
"config": {
"outputLocation": "."
},
"files": ["@(index.htm|default.htm)?(l)"]
}
]
- customFrameworkDefinitionsUrl: use custom framework definitions as source of truth for detection. Url must link to plain JSON containing list of framework definitions.
Sample: https://raw.githubusercontent.com/annikel/additional-framework-definitions/main/frameworks.json
Example Usage
const { detectProjectFolders } = require("@azure/framework-detect");
async function detect(rootPath, apiToken, additionalFrameworks, additionalFrameworksUrl) {
const folders = await detectProjectFolders(rootPath, apiToken, additionalFrameworks, additionalFrameworksUrl);
return JSON.stringify(folders);
}
formatDetectedFolders
Formats the detected folders
Parameters:
- folders: the folders to be formatted
printSupportedFrameworks
Returns all supported frameworks wit definition
Parameters:
- showList: when set to true will console log the framework defintions
Contribute
To add missing frameworks or update existing ones simply edit the frameworks.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