npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@azure/web-apps-framework-detection

v0.1.0

Published

Detect, inspect and extract build and deploy configuration from JavaScript frameworks and libraries

Downloads

160

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:

  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.
  3. filterDescendantFolders: decides is descendant folders should be filtered (defaults to true).
  4. customFrameworkDefinitions: use custom framework definitions as source for detection. Must be passed in as list of framework definitions.
  5. 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)"]
}
]
  1. 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:

  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 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