Skip to content

feat: add .replicated config file parser and discovery logic#113

Merged
jdewinne merged 1 commit into
mainfrom
joshd/sc-136792/replicated-file-ignored-by-github-actions
May 12, 2026
Merged

feat: add .replicated config file parser and discovery logic#113
jdewinne merged 1 commit into
mainfrom
joshd/sc-136792/replicated-file-ignored-by-github-actions

Conversation

@jdewinne
Copy link
Copy Markdown
Contributor

Summary

Adds .replicated and .replicated.yaml config file parser and discovery logic to the library, matching the behavior of the replicatedhq/replicated CLI.

Changes

  • New src/config.ts

    • ReplicatedConfig, ChartConfig, PreflightConfig, and ReplLintConfig interfaces
    • findAndParseConfig(startPath) — walks upward from startPath toward the filesystem root, collecting all .replicated and .replicated.yaml files along the way (monorepo support). If startPath is a file, parses it directly.
    • parseConfigFile(filePath) — reads, parses YAML, validates, resolves relative paths to absolute (relative to the config file's directory), and returns the config.
    • Monorepo merging — merges discovered configs root → leaf:
      • Scalar fields (appId, appSlug, releaseLabel) are overridden by child configs
      • Channel arrays (promoteToChannelIds, promoteToChannelNames) are replaced if present
      • Resource arrays (charts, manifests, preflights) are appended and deduplicated by resolved absolute path
    • Validation matching the CLI:
      • Non-empty chart.path, preflight.path, and manifests entries
      • Preflight cross-field validation (chartNamechartVersion)
      • Glob syntax validation on paths containing *?[{
  • New src/config.test.ts

    • Tests for discovery, fallback to .replicated.yaml, relative path resolution, monorepo merging, deduplication, valid/invalid YAML parsing, validation errors, and repl-lint parsing.
  • src/index.ts — exports all new types and functions

  • package.json — adds picomatch dependency for glob pattern validation

Testing

  • npm run build
  • npm test — 87 passed, 0 failed ✅
  • npm run prettier

- Add src/config.ts with ReplicatedConfig interfaces (ChartConfig, PreflightConfig, ReplLintConfig)
- Implement findAndParseConfig() to walk upward and discover .replicated / .replicated.yaml files
- Implement parseConfigFile() to read, validate, and resolve relative paths to absolute
- Add monorepo config merging: scalars override, channel arrays replace, resource arrays append+dedupe
- Validate chart/preflight/manifest paths, preflight cross-fields, and glob syntax via picomatch
- Export new types and functions from src/index.ts
- Add comprehensive tests in src/config.test.ts
- Add picomatch dependency for glob pattern validation
@jdewinne jdewinne merged commit af364d3 into main May 12, 2026
1 check passed
@jdewinne jdewinne deleted the joshd/sc-136792/replicated-file-ignored-by-github-actions branch May 12, 2026 16:00
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