checks

Phase 1: Prerequisites Validation

Before creating repositories, configuring environments, or running builds, we validate that all required tools exist and are properly configured. This fail-fast approach prevents partial initialization states that leave projects in limbo.

The checks fall into three categories: command availability (is the tool installed?), authentication state (can we talk to GitHub?), and user metadata (who is creating this project?).

Prerequisite Validation

The validation orchestrator: check every required tool, verify GitHub authentication, and gather user information for project metadata. Returns a dictionary of user info if all checks pass; exits immediately if anything fails.


source

check_prereqs

 check_prereqs ()

Validate all prerequisites and gather system info. Returns dict with user info or exits on failure.

Design Decisions

Why check commands individually? We want to report all missing tools at once, not fail on the first missing one. The user sees the complete list of what needs installing, rather than playing whack-a-mole across multiple runs.

Why validate nbdev_new specifically? There’s no nbdev command—it’s a collection of subcommands like nbdev_new, nbdev_export, nbdev_prepare. Checking for a non-existent parent command would pass even when nbdev isn’t installed.

Why separate GitHub auth check? Authentication is stateful and can expire. We verify it explicitly with gh auth status rather than letting a later gh repo create fail cryptically.

Why gather user info here? Git and GitHub metadata (author name, email, username) are needed for project scaffolding. Collecting them during checks means we fail early if git isn’t configured, and we have the data ready when needed later.

Default values for missing config: If user.name or user.email aren’t set, we provide placeholder strings. nbdev_new will use these values, and the user can fix them later in settings.ini. Better than blocking on missing config.

The function returns a dictionary rather than printing values because the caller (init_nbdev) needs to pass this data to subsequent setup steps. Returning structured data keeps concerns separated: checks validate, initialization consumes.