Skip to content

feat: Multi-package support for CLI commands (analyze, test, autodoc, changelog, release notes) #17

@tsavo-at-pieces

Description

@tsavo-at-pieces

Overview

The CI workflow template already generates per-sub-package analyze/test steps via Mustache loops (ci.skeleton.yaml lines 164-175, 272-283), but the corresponding CLI commands only operate at the repo root. This means:

  • manage_cicd analyze only analyzes the root package
  • manage_cicd test only tests the root package
  • manage_cicd autodoc has no sub-package awareness
  • manage_cicd compose (changelog) generates a flat changelog for root only
  • manage_cicd release-notes generates flat release notes for root only
  • manage_cicd create-release only bumps the root pubspec.yaml version

The ci.sub_packages config field is already defined and initialized in init_command.dart, but TriageConfig has no getter for it and most commands ignore it entirely.

First consumer: dart_custom_lint -- a repo with 5+ workspace packages (custom_lint, custom_lint_builder, custom_lint_core, custom_lint_visitor, lint_visitor_generator).

Implementation Plan

1. Add subPackages getter to TriageConfig

File: lib/src/triage/utils/config.dart

  • Add SubPackageEntry data class with name and path fields
  • Add List<SubPackageEntry> get subPackages getter reading from ['ci', 'sub_packages']
  • Filter out invalid entries (missing name or path)

2. Extend AnalyzeCommand for sub-packages

File: lib/src/cli/commands/analyze_command.dart

  • Load sub_packages from CI config (via WorkflowGenerator.loadCiConfig)
  • If sub_packages is non-empty, iterate and run dart analyze in each sub-package directory
  • Still run root analyze first
  • Aggregate results: fail if ANY sub-package fails
  • Log per-package status (pass/fail)

3. Extend TestCommand for sub-packages

File: lib/src/cli/commands/test_command.dart

  • Load sub_packages from CI config
  • If sub_packages is non-empty, iterate and run dart test in each sub-package directory
  • Skip sub-packages with no test/ directory
  • Same 20-minute timeout per sub-package
  • Aggregate results: fail if ANY sub-package fails

4. Extend AutodocCommand for sub-packages

File: lib/src/cli/commands/autodoc_command.dart

  • Support per-sub-package autodoc module definitions in root autodoc.json
  • OR support per-sub-package autodoc.json configs at sub-package paths
  • Generate docs per sub-package with output scoped to sub-package directory

5. Hierarchical Changelog (ComposeCommand)

File: lib/src/cli/commands/compose_command.dart

  • When sub_packages exist, include per-package diffs in the compose prompt
  • Generate hierarchical CHANGELOG with sub-sections per package
  • Root-level summary = hierarchical summarization of all sub-package changes
  • Format: ## [version] -> ### Root Changes -> ### custom_lint -> ### custom_lint_builder -> etc.

6. Hierarchical Release Notes (ReleaseNotesCommand)

File: lib/src/cli/commands/release_notes_command.dart

  • When sub_packages exist, generate per-package commit analysis
  • Root release notes = hierarchical summary of all sub-package changes
  • Include per-package highlights sections
  • Migration guide should cover cross-package breaking changes

7. Multi-package version bump (CreateReleaseCommand)

File: lib/src/cli/commands/create_release_command.dart

  • When sub_packages exist, bump version in each sub-package pubspec.yaml
  • Add sub-package pubspec.yaml files to git commit
  • Include sub-package release notes in the release folder structure

8. Version determination awareness

File: lib/src/cli/commands/determine_version_command.dart

  • Consider changes in sub-package directories when determining version bump type
  • Breaking changes in any sub-package should trigger at minimum a minor bump at root

Config Schema

{
  "ci": {
    "sub_packages": [
      { "name": "custom_lint", "path": "packages/custom_lint" },
      { "name": "custom_lint_builder", "path": "packages/custom_lint_builder" },
      { "name": "custom_lint_core", "path": "packages/custom_lint_core" },
      { "name": "custom_lint_visitor", "path": "packages/custom_lint_visitor" },
      { "name": "lint_visitor_generator", "path": "packages/lint_visitor_generator" }
    ]
  }
}

Acceptance Criteria

  • manage_cicd analyze runs analysis on root AND all sub-packages
  • manage_cicd test runs tests on root AND all sub-packages (skip if no test/ dir)
  • CHANGELOG.md has hierarchical structure when sub-packages exist
  • Release notes summarize changes across all packages hierarchically
  • Version bump applies to root and all sub-packages
  • CI template continues working unchanged (already supports sub_packages)
  • dart_custom_lint can be onboarded as first consumer

Files Changed (Estimated)

File Change
lib/src/triage/utils/config.dart Add SubPackageEntry + getter
lib/src/cli/commands/analyze_command.dart Sub-package iteration
lib/src/cli/commands/test_command.dart Sub-package iteration
lib/src/cli/commands/autodoc_command.dart Sub-package doc generation
lib/src/cli/commands/compose_command.dart Hierarchical changelog
lib/src/cli/commands/release_notes_command.dart Hierarchical release notes
lib/src/cli/commands/create_release_command.dart Multi-pubspec version bump
lib/src/cli/commands/determine_version_command.dart Sub-package change awareness
lib/src/cli/utils/workflow_generator.dart Minor -- already supports sub_packages

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions