Skip to content

[P1] Add declarative local and remote source acquisition #44

@KayleeWilliams

Description

@KayleeWilliams

Problem

The c15t example currently fetches source content manually:

  • apps/c15t-example/scripts/setup-source.ts clones https://github.com/c15t/c15t into .docs-src/c15t.
  • apps/c15t-example/scripts/generate-artifacts.ts then runs Leadtype against that local checkout with mounted docs directories.

This is directionally correct, but the source acquisition step lives outside Leadtype. Any project that wants docs from another repository has to recreate the same glue.

Proposal

Add declarative local and remote source acquisition to Leadtype.

Example:

export default defineDocsConfig({
  sources: {
    c15t: {
      repository: "https://github.com/c15t/c15t",
      ref: "main",
      cacheDir: ".docs-src/c15t",
      mounts: [
        { dir: "docs", path: "/docs" },
        { dir: "changelog", path: "/changelog" },
      ],
    },
  },
});

Leadtype should resolve remote sources to local files at build time, then run the existing artifact pipeline unchanged.

CLI Shape

Potential commands/flags:

leadtype sync
leadtype generate --sync
leadtype generate --refresh
leadtype generate --offline

Expected behavior:

  • sync clones/fetches configured sources.
  • generate uses already-present local sources by default.
  • --sync clones missing sources.
  • --refresh updates existing sources.
  • --offline fails if required sources are missing.

Framework Integration Notes

Source acquisition is core behavior, but each framework recipe should show where it runs:

  • Next.js: prebuild script or CI step.
  • Nuxt: package script or Nitro build hook.
  • SvelteKit: package prebuild script.
  • Astro: integration/build script.
  • TanStack/Vite: package prebuild script.

Runtime apps should not clone Git repositories on request.

Acceptance Criteria

  • c15t example no longer needs a custom clone script for the standard path.
  • Local sources and remote Git sources are both supported.
  • Missing remote sources produce a clear error unless sync is enabled.
  • Refresh/update behavior is explicit and deterministic.
  • --offline works for CI/reproducible builds.
  • Existing local-only generation remains compatible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions