Detect, inspect and extract build and deploy configuration from JavaScript frameworks and libraries
npm install annikel-test-framework
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
$3
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.
1. filterDescendantFolders: decides is descendant folders should be filtered (defaults to true).
1. customFrameworkDefinitions: use custom framework definitions as source for detection. Must be passed in as list of framework definitions.
1. 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)"]
}
]
`
4. 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);
}
`
$3
Formats the detected folders
Parameters:
1. folders: the folders to be formatted
$3
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 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:
`bash
npm run get-samples
`
It will download the samples in the test/samples folder.
Then you can run all the tests with:
`bash
npm run build && npm test
`
all tests in test/remote-detect.spec.js` require a valid PAT and repositories the PAT has access to