-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Component
Other
Bug Description
When using the Extension, and in Windows/PowerShell.
The Generate-PrReference.ps1 script included in the VS Code extension package fails to execute because it depends on the CIHelpers.psm1 module located at scripts/lib/Modules/CIHelpers.psm1, which is not included in the extension package.
When users try to run the script from the installed extension directory, they encounter a module import error:
Import-Module: %USERPROFILE%\.vscode-insiders\extensions\ise-hve-essentials.hve-core-2.0.1\scripts\dev-tools\Generate-PrReference.ps1:29:1
Line |
29 | Import-Module (Join-Path $PSScriptRoot "../lib/Modules/CIHelpers.psm1 …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The specified module
| '%USERPROFILE%\.vscode-insiders\extensions\ise-hve-essentials.hve-core-2.0.1\scripts\dev-tools\..\lib\Modules\CIHelpers.psm1' was not loaded because no valid module file was found in any module directory.
Expected Behavior
The Generate-PrReference.ps1 script should execute successfully when run from the extension installation directory. All required dependencies and modules should be included in the extension package.
Steps to Reproduce
- Install the HVE Core VS Code extension (ise-hve-essentials.hve-core)
- Navigate to a git repository (e.g.,
cd) - Run the PR reference generation script from the extension:
pwsh -File "%USERPROFILE%\.vscode-insiders\extensions\ise-hve-essentials.hve-core-2.0.1\scripts\dev-tools\Generate-PrReference.ps1" -BaseBranch "origin/main"
- Observe the import module error
Additional Context
Root Cause
The extension packaging process copies scripts/dev-tools to the extension but does not copy scripts/lib, which contains the required CIHelpers.psm1 module.
There is no corresponding copy operation for scripts/lib.
Additional Context
Affected Files:
- scripts/dev-tools/Generate-PrReference.ps1 (line 29)
- scripts/lib/Modules/CIHelpers.psm1 (missing from extension)
Packaging Script Location:
Dependency:
The CIHelpers.psm1 module provides CI platform detection and output utilities used by multiple scripts in the dev-tools directory.
Note that scripts/lib/** is NOT included in the whitelist.
Potential Solutions:
- Add scripts/lib to .vscodeignore and Package-Extension.ps1 (Recommended):
- Add
!scripts/lib/**to the whitelist in extension/.vscodeignore - Add a Copy-Item command in scripts/extension/Package-Extension.ps1 after line 484:
Copy-Item -Path "$RepoRoot/scripts/lib" -Destination "$ExtensionDirectory/scripts/lib" -Recurse
- Add
- Make script standalone: Refactor
Generate-PrReference.ps1to not depend on external modules (increases maintenance burden) - Bundle dependencies inline: Copy
CIHelpers.psm1directly intoscripts/dev-tools/Modules/directory (duplicates code) - Document limitation: Update documentation to indicate the script can only run from source repository, not from extension installation (reduces utility)
Impact Scope
- Affects
Generate-PrReference.ps1(confirmed) - Other scripts in
scripts/dev-tools/appear to be unaffected (no other modules dependencies found)
Scope Expansion: Packaging Script Testability
During code review, the following issues were identified in Package-Extension.ps1:
Problem Statement
The Invoke-PackageExtension function has:
- ~200 lines of tightly coupled code
- Cyclomatic complexity 18-22 (target: 8-10)
- ~50% test coverage due to untestable platform-specific code paths
- Silent failure modes that mask packaging issues
Target Metrics
| Metric | Current | Target |
|---|---|---|
| Function length | ~200 lines | ~80 lines |
| Cyclomatic complexity | 18-22 | 8-10 |
| Test coverage | ~50% | 80%+ |
Refactoring Approach
Extract 8 pure/testable functions from the monolithic implementation:
Pure Functions (stateless, easily testable):
Test-PackagingInputsValid- Validates required paths, tools, environmentGet-PackagingDirectorySpec- Returns array of directory copy specificationsGet-PackagingFiles- Returns array of individual file copy specificationsGet-VsceArguments- Constructs argument array for vsce command
I/O Functions (mockable boundaries):
Copy-PackagingDirectories- Executes directory copies with progressInvoke-VsceCommand- Wrapsnpx @vscode/vscewithUseWindowsWrapperparameterRemove-PackagingArtifacts- Cleans up temporary files and foldersRestore-PackageJsonVersion- Restores original package.json after packaging
Acceptance Criteria
- CIHelpers.psm1 included in extension package (original bug)
- Explicit error when CIHelpers.psm1 is missing during packaging
- Extracted functions have individual Pester test coverage
- Platform-specific
cmd /cwrapper logic is injectable for testing - Function complexity reduced to single responsibility per function