Skip to content

Add source config support for source-all-translations command - #149

Open
KallynGowdy wants to merge 2 commits into
mainfrom
claude/great-maxwell-hjr6w4
Open

KallynGowdy wants to merge 2 commits into
mainfrom
claude/great-maxwell-hjr6w4

Conversation

@KallynGowdy

Copy link
Copy Markdown
Collaborator

Summary

This PR adds configuration file support to the source-all-translations command, allowing users to define translation sources and their download directories in a JSON config file instead of passing them as command-line arguments.

Key Changes

  • New source-config.ts module: Provides types and functions for loading and validating source configuration files

    • SourceConfig interface defines the structure of the config file with sources, database path, ignorelist, and conversion settings
    • loadSourceConfig() loads and validates a JSON config file using Zod schema validation
    • getSourceAllTranslationsOptions() converts config into options for the sourceAllTranslations() function
    • sourceAllTranslationsFromConfig() is the main entry point that orchestrates config loading and translation sourcing
  • Updated source-all-translations command:

    • Made the <dir> argument optional (defaults to reading from ./source.config.json)
    • Added --config option to specify a custom config file path
    • When using a config, all arguments are treated as translation IDs rather than directories
    • Prevents conflicting options (e.g., --fetch-bible-dir) when using a config file
    • Maintains backward compatibility with direct directory-based usage
  • Enhanced sourceAllTranslations() function:

    • Added includeFetchBible option to make fetch.bible sourcing optional
    • Conditionally skips fetch.bible operations when not included in config
    • Updated logging to reflect which sources are being used
  • Improved findBibleMultiConverterJar() function:

    • Now accepts an optional providedPath parameter
    • Throws an error if provided path doesn't exist (prevents silent fallback on typos)
  • Added example config file (source.config.example.json) showing the expected format with all source types

Notable Implementation Details

  • Config validation uses Zod with custom refinements to ensure:

    • Exactly one eBible source is present (required)
    • At most one source of each type
    • fetch-bible-specific fields (manifestUrl, repo, ref) are only allowed on fetch-bible sources
  • Paths in the config are resolved relative to the config file's directory

  • Command-line options override config file settings where applicable

  • Ignorelists from config and command-line options are merged

Like sync, source-all-translations can now take a JSON config
(--config <path>, or ./source.config.json when no directory is given)
that sets the database used to track downloads and lists the sources
to download from (ebible, fetch-bible, osis, bsb) with the directory
for each. Sources left out of the config are skipped, which needed a
new includeFetchBible option on sourceAllTranslations().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019LsUS11s2PUsH7KW9gaLiP
The source config's bibleMultiConverterPath is now in the example
config and README. A BibleMultiConverter path that is given explicitly
(in a config or with --bible-multi-converter-path) but doesn't exist
is now an error instead of silently falling back to searching for
another copy and prompting, which would stall unattended runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019LsUS11s2PUsH7KW9gaLiP

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants