Skip to content

pivot: split the 4,948-line module into Public/Private files and small functions #163

Open

Description

@eizedev

PowerShellUniversal.Component.Pivot.psm1 is one file of 4,948 lines with 66 functions and three products in it: the component (New-UDPivotReport), the template stores (lines about 721-1789) and a report engine without a browser (about 2683-4946, Invoke-UDPivotReport, Get-UDPivotSource, HTTP transport, a SQL helper).

The repository's rule (AGENTS.md, "How we build") is one exported function per file in Public/, helpers in Private/, the .psm1 only loading them, C# in .cs files.

To do:

  • Split the module into Public/ and Private/ files; the build (build/Copy-SharedCode.ps1 already writes Private/) packs them.
  • Break the long functions into steps: New-UDPivotReport (about 663 lines, 40+ parameters), Get-UDPivotSqlColumnDescription (about 426), Invoke-UDPivotReport (about 333), Invoke-UDPivotTemplateStore (about 230).
  • Move ReportWriterSource and HttpTransportSource out of here-strings into .cs files, or drop the C# path if a measurement shows it is not needed.
  • One error helper with error ids instead of about 74 bare throw strings.
  • Decide whether the report engine becomes its own module.

Not affected: behaviour. The Pester and browser tests must pass unchanged before and after.

Activity

  1. eizedev commented on Nov 22, 2026

    @eizedev
    OwnerAuthor

    The growth guards from #166 now track this module: Pivot.psm1 2,731 code lines in the baseline, New-UDPivotReport 267, Invoke-UDPivotTemplateStore 158, Invoke-UDPivotReport 150 (limits: file 300, function 100). The split must lower them with npm run growth -- --update.

    Before the split: #165 (the bundle folder public/ collides with Public/ on macOS and Windows).

  2. eizedev commented on Nov 22, 2026

    @eizedev
    OwnerAuthor

    Done in #171 (merged as 0f29450):

    • The module is split: Public/ (11 commands), Private/ (one helper per file), Private/Settings/ for the $Script: limits and state. The .psm1 only loads them.
    • The C# moved out of the here-strings into Private/ReportWriter.cs and Private/HttpTransport.cs.
    • New-UDPivotReport (267 → 95 code lines), Invoke-UDPivotTemplateStore (158 → 51) and Invoke-UDPivotReport (150 → 55) run their steps through helpers. Get-UDPivotSqlColumnDescription was already below the limit (54).
    • The growth baseline no longer lists the Pivot module.

    Moved:

    Still open here:

    • One error helper with error ids instead of the bare throw strings.
    • Whether the report engine becomes its own module.
  3. added this to the Maintenance milestone on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions