Skip to content

Framework

framework

Framework detection for the gold-standard checker.

Mirror of axm_audit.core.framework (kept local so the two packages stay independent — a future refactor could host this in axm-ingot and have both import it). Decides which set of check_* functions CheckEngine runs.

node is the JS/TS base layer; svelte and react are UI-framework specializations that inherit it (see :func:resolve_frameworks).

Framework

Bases: StrEnum

Ecosystem a project is scaffolded/checked against.

Source code in packages/axm-init/src/axm_init/core/framework.py
Python
class Framework(StrEnum):
    """Ecosystem a project is scaffolded/checked against."""

    PYTHON = "python"
    NODE = "node"
    SVELTE = "svelte"
    REACT = "react"

detect_framework(project_path)

Detect the framework of project_path from its manifest markers.

package.json + svelte → svelte; + react → react; alone → node; otherwise → python (conservative default).

Parameters:

Name Type Description Default
project_path Path

Project root directory.

required

Returns:

Type Description
Framework

The detected :class:Framework.

Source code in packages/axm-init/src/axm_init/core/framework.py
Python
def detect_framework(project_path: Path) -> Framework:
    """Detect the framework of *project_path* from its manifest markers.

    ``package.json`` + svelte → ``svelte``; + react → ``react``; alone →
    ``node``; otherwise → ``python`` (conservative default).

    Args:
        project_path: Project root directory.

    Returns:
        The detected :class:`Framework`.
    """
    if not (project_path / "package.json").is_file():
        return Framework.PYTHON
    # A package.json is present → node project even if the manifest is unparsable
    # (we just can't read its UI marker then).
    data = _read_package_json(project_path) or {}
    if _has_svelte_marker(project_path, data):
        return Framework.SVELTE
    if _has_dependency(data, "react"):
        return Framework.REACT
    return Framework.NODE

resolve_frameworks(framework)

Expand a framework to the chain of check-sets it should run.

A UI framework (svelte, react) runs the shared node checks first, then its own delta. node and python run only their own.

Parameters:

Name Type Description Default
framework Framework

The leaf framework to resolve.

required

Returns:

Type Description
tuple[Framework, ...]

Tuple of frameworks whose checks apply, base first.

Source code in packages/axm-init/src/axm_init/core/framework.py
Python
def resolve_frameworks(framework: Framework) -> tuple[Framework, ...]:
    """Expand a framework to the chain of check-sets it should run.

    A UI framework (``svelte``, ``react``) runs the shared ``node`` checks
    first, then its own delta. ``node`` and ``python`` run only their own.

    Args:
        framework: The leaf framework to resolve.

    Returns:
        Tuple of frameworks whose checks apply, base first.
    """
    if framework in _NODE_UI_FRAMEWORKS:
        return (Framework.NODE, framework)
    return (framework,)