Skip to content

refactor(echarts): one function per file, and New-UDEChart in steps - #173

Merged
eizedev merged 5 commits into
mainfrom
refactor/echarts-split
Nov 23, 2026
Merged

eizedev merged 5 commits into
mainfrom
refactor/echarts-split

Conversation

@eizedev

@eizedev eizedev commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Fixes #169

PowerShellUniversal.Component.ECharts.psm1 held 7 functions in 329 code lines, and New-UDEChart had 193 code lines. This pull request splits the module the way #171 split Pivot and shortens New-UDEChart. Commands, parameters, help and output stay the same.

What changed

  • Public/: the 3 exported commands, one per file. Private/: the 4 helpers that were in the module file, unchanged, and 4 new ones. The functions moved by the parser's extents, so their text is unchanged in the first commit.
  • The .psm1 only loads, like Pivot's: Export-ModuleMember takes the file names, and a source checkout loads shared/powershell directly (recognised by the missing Private/SHARED.txt). Build-Module.ps1 already copies Public/ and Private/.
  • New-UDEChart runs its steps through helpers with one job each:
    • Register-UDEChartEvent: registers the handlers under the chart's id and returns their props.
    • New-UDEChartProp: the props every chart has. The parameters with a default are passed on their own, because they are not in $PSBoundParameters.
    • Get-UDEChartOptionalProp: the props of the parameters given, with the conversions (themes, tooltip mode, colour map, choices in lower case).
    • Write-UDEChartTypeWarning: the warning for a parameter the chart type ignores. It still reaches -WarningAction and -WarningVariable of New-UDEChart.
      The order of the steps is the same: handlers first, the props, then the warnings.
  • Tests: the two file tests of the Pivot module (Public/ matches FunctionsToExport; every $Bound['key'] a helper reads is a parameter of a public command) now live in ModuleFiles.Tests.ps1 and run for both split modules. The build test that the built module carries Public/ and Private/ and exports the manifest's commands runs for both too. I checked that the -Bound test fails for a misspelled key in an ECharts helper.
  • AGENTS.md names both split modules and the moved test. The ECharts CHANGELOG has an entry under Unreleased. The growth baseline is lowered: the module file is gone from it, New-UDEChart goes from 193 to 121.

Growth numbers

Offender Before After
PowerShellUniversal.Component.ECharts.psm1 (file) 329 9
New-UDEChart 193 121 (108 of them the param() block)

New-UDEChart stays over the limit of 100 because its param() block alone has 103 parameters on 108 lines. Getting under it would mean changing the command's parameters, which this pull request keeps as they are.

Checks

  • Get-Command -Module with parameter sets, parameter attributes and OutputType, Get-Help -Full of every command, and the exported functions: identical before and after, for the source module and the built module.
  • The output of New-UDEChart for seven calls that together use every parameter, with all four handlers: identical props, the same handler registrations and the same warnings as on main.
  • docs/site/Build-Site.ps1: docs/site/generated/ is identical before and after. Its examples run the real New-UDEChart.
  • A new test sends every parameter of New-UDEChart and checks that it arrives under its camelCase prop, a choice in lower case. The parameter map had no such test before. I checked that it fails for a mistyped map entry and for a choice left out of the lower-casing.
  • Pester: 367 passed, 0 failed, 7 skipped (before the last test commit; the touched test files pass after it). npm test: 165 passed. PSScriptAnalyzer as in CI: no findings. Growth: all four guards ok. Build-Module.ps1 for all five modules.
  • Places checked: AGENTS.md, the ECharts README and CHANGELOG, docs/ (no page names the module file), docs/development, Build-Site, CI, the tests that import the module.

Not tested on PSU

I did not run this on a PowerShell Universal instance. Not covered without PSU:

  • The asset registration and the bundle in a real app (the tests stub PSU's Endpoint type and the asset id).
  • Endpoint.Register with PSU's real type: the handlers are now registered from a helper, with New-UDEChart's $PSCmdlet passed on. Its result is discarded, so a return value could not reach the props.
  • Import time in PSU's runspaces with 14 files instead of one (for Pivot, refactor(pivot): one function per file, and the three long functions in steps #171 measured about 11 ms more per runspace outside PSU).

Not in this pull request

  • The loader in the .psm1 is the same nine lines in Pivot and ECharts. A shared loader would have to be found before shared/ is loaded, so I kept the copy. If a third module is split, it is worth a shared piece.
  • Perspective (one function) and the demo modules stay as they are.
  • The Endpoint stub for tests outside PSU is now in three test files. A shared test helper would hold it once; I left that for a separate change.

🤖 Generated with Claude Code

eizedev and others added 4 commits November 23, 2026 01:34
The functions move unchanged, split by the parser's extents. The .psm1 only loads them, as in the
pivot module: a source checkout loads shared/powershell directly, recognised by the missing
Private/SHARED.txt.

Refs #169

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…b each

New-UDEChart registers its handlers, builds the props every chart has, adds those of the parameters
given and warns about parameters the chart type ignores, each through a helper. Inputs are passed as
parameters; helpers that read many of its parameters get $PSBoundParameters as -Bound. 193 code lines
become 121 (108 of them the param() block). The growth baseline is lowered.

Refs #169

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ModuleFiles.Tests.ps1 holds the two tests PivotModule.Tests.ps1 had (Public/ matches FunctionsToExport,
the -Bound keys) and runs them for both split modules; the build test of Public/ and Private/ runs for
both too. AGENTS.md names both split modules and the moved test.

Refs #169

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m the review

- ECharts.Tests: each New-UDEChart parameter given arrives as its camelCase prop, a choice in lower
  case; a mistyped map entry or a missing lower-casing fails it.
- ModuleFiles.Tests: $script:module, as PSScriptAnalyzer asks; the build test names its module.
- Register-UDEChartEvent discards what Endpoint.Register returns.

Refs #169

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@eizedev
eizedev merged commit a26cc9f into main Nov 23, 2026
11 checks passed
@eizedev
eizedev deleted the refactor/echarts-split branch November 23, 2026 02:43
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.

echarts: Public/Private files and a shorter New-UDEChart

1 participant