Decompose launcher/config.ts into focused domain parser and CLI normalization modules to reduce refactor risk while preserving command behavior. Align Jellyfin launcher config with session-based auth by dropping config token/userId dependency.
4.7 KiB
id, title, status, assignee, created_date, updated_date, labels, dependencies, priority
| id | title | status | assignee | created_date | updated_date | labels | dependencies | priority | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| TASK-104 | Split launcher config.ts into domain parsers and CLI builder | Done |
|
2026-02-22 07:13 | 2026-02-22 19:56 |
|
|
medium |
Description
launcher/config.ts is still a large multi-responsibility file (~700 LOC) combining:
- config file reading/parsing for multiple domains,
- plugin runtime config parsing,
- CLI command tree construction,
- root/subcommand arg normalization.
This file remains a cleanup hotspot and makes contract changes (like Jellyfin session migration) expensive to land safely.
Action Steps
- Extract launcher config-file readers into domain loaders (YouTube/Jimaku, Jellyfin, plugin runtime).
- Extract Commander command-tree setup into a dedicated CLI builder module.
- Extract post-parse normalization into focused argument-normalization helpers.
- Remove stale Jellyfin config auth field assumptions from launcher config readers.
- Add focused tests per extracted module while preserving existing
launcher/config.test.tsbehavior expectations. - Keep
parseArgsAPI stable for launcher call sites.
Acceptance Criteria
- #1
launcher/config.tsis reduced to thin orchestration over extracted modules. - #2 Each extracted module has focused tests that assert current behavior.
- #3 Launcher still passes
bun run test:launcherwithout CLI behavior regressions. - #4 Launcher config readers align with current Jellyfin session contract (no config token/userId dependency).
Implementation Plan
Plan recorded at docs/plans/2026-02-22-task-104-launcher-config-domain-parsers-cli-builder.md.
Execution phases:
- Extract shared config readers and domain parser modules (
launcher/config/shared-config-reader.ts,launcher/config/youtube-subgen-config.ts,launcher/config/jellyfin-config.ts) and reducelauncher/config.tsto orchestration. - Extract plugin runtime parser into
launcher/config/plugin-runtime-config.tswith focused behavior tests. - Extract CLI parser builder/normalization into
launcher/config/cli-parser-builder.ts,launcher/config/parse-helpers.ts, andlauncher/config/args-normalizer.ts; keepparseArgsAPI unchanged. - Align Jellyfin config contract by removing launcher config token/userId dependence and update caller/type wiring.
- Verify with
bun run test:launcherandbun run test:fast, then finalize TASK-104 evidence (AC/DoD checks + summary).
Validation-first loop per phase: add/expand focused tests, run targeted launcher tests, implement minimal refactor to pass, then run full required suites.
Implementation Notes
Implemented launcher config decomposition by extracting domain-focused modules under launcher/config/ (shared-config-reader, youtube-subgen-config, jellyfin-config, plugin-runtime-config, cli-parser-builder, args-normalizer) and reducing launcher/config.ts to an orchestration facade with unchanged exported API.
Aligned launcher Jellyfin config contract by removing accessToken/userId from LauncherJellyfinConfig and parser output; launcher Jellyfin play now requires SUBMINER_JELLYFIN_ACCESS_TOKEN + SUBMINER_JELLYFIN_USER_ID env session values instead of config fields.
Added focused parser regression tests in launcher/config-domain-parsers.test.ts (youtube domain normalization, jellyfin legacy token/userId omission, plugin socket parsing) and expanded launcher/parse-args.test.ts branch coverage for jellyfin/config/mpv command mappings.
Verification: bun test launcher/config-domain-parsers.test.ts launcher/parse-args.test.ts, bun run test:launcher, and bun run test:fast all pass.
Final Summary
Split launcher/config.ts into focused domain parser and CLI parsing modules while preserving the public launcher parsing API (parseArgs, config readers, plugin runtime reader). Added focused launcher parser tests, expanded parse-args coverage, and removed launcher config dependency on Jellyfin token/userId fields to match the current session contract. Verified behavior with bun run test:launcher and bun run test:fast passing.
Definition of Done
- #1 Public launcher parsing API unchanged for downstream callers.
- #2 Help text and subcommand option behavior remains unchanged.
- #3
bun run test:launcherandbun run test:fastpass.