Commit 1a6d7d9
authored
refactor(scripts): move collection scripts from plugins to collections (#728)
Extracted 11 collection-management functions from *PluginHelpers.psm1*
into a dedicated *CollectionHelpers.psm1* module under
`scripts/collections/Modules/`, establishing a clear separation between
collection and plugin concerns. Relocated collection validation scripts
and their tests alongside the new module, updated all consumer imports,
and expanded test coverage with new suites for both the extracted module
and the previously untested *Validate-Marketplace.ps1* script.
## Description
### Module Extraction and Restructuring
The core of this change split *PluginHelpers.psm1* into two focused
modules. Eleven collection-related functions moved to the new
*CollectionHelpers.psm1*: `Get-AllCollections`, `Get-ArtifactFiles`,
`Get-ArtifactFrontmatter`, `Get-CollectionArtifactKey`,
`Get-CollectionManifest`, `Resolve-CollectionItemMaturity`,
`Test-ArtifactDeprecated`, `Test-DeprecatedPath`,
`Test-HveCoreRepoRelativePath`, `Test-HveCoreRepoSpecificPath`, and
`Update-HveCoreAllCollection`. The trimmed *PluginHelpers.psm1* retained
only plugin-specific operations (symlink, manifest, packaging) and added
a **backward-compatible re-import** of *CollectionHelpers.psm1* so
existing consumers continue to work during transition.
### Script Relocation and Consumer Updates
Renamed *Validate-Collections.ps1* from `scripts/plugins/` to
`scripts/collections/` and updated its import to reference
*CollectionHelpers.psm1*. The previously local `Resolve-ItemMaturity`
helper was consolidated into the extracted
`Resolve-CollectionItemMaturity` function. Four consumer scripts
received import path updates:
- *Package-Extension.ps1* and *Prepare-Extension.ps1* switched from
*PluginHelpers.psm1* to *CollectionHelpers.psm1*
- *Generate-Plugins.ps1* added *CollectionHelpers.psm1* as a second
import alongside *PluginHelpers.psm1*
- Updated the `lint:collections-metadata` npm script path in
*package.json*
### Test Coverage Expansion
Created *CollectionHelpers.Tests.ps1* (564 lines) covering all 11
extracted functions with Describe blocks for path exclusion, deprecated
handling, maturity resolution, frontmatter parsing, and
`Update-HveCoreAllCollection` workflows including DryRun safety.
Relocated *Validate-Collections.Tests.ps1* from `scripts/tests/plugins/`
to `scripts/tests/collections/` and removed the superseded
`Resolve-ItemMaturity` test block. Removed ~270 lines of tests from
*PluginHelpers.Tests.ps1* for functions that moved to
*CollectionHelpers*.
Created *Validate-Marketplace.Tests.ps1* (354 lines, 15 Describe blocks)
covering marketplace manifest validation: format checks, required
fields, version consistency, duplicate detection, and source directory
verification.
Added `'collections'` to coverage directories in *pester.config.ps1* and
introduced a defensive *CollectionHelpers.psm1* re-import in
*Generate-Plugins.Tests.ps1* to handle PowerShell module scope
invalidation from nested `-Force` imports. Overall test coverage
improved from 82.70% to **84.12%** across 1,500 tests with zero
failures.
### Documentation
Updated the Scripts Organization section in
*.github/copilot-instructions.md* with the new `scripts/collections/`
entry. Revised *scripts/README.md* directory tree, scripts table, and
tests table. Narrowed *scripts/plugins/README.md* to plugin-only
content. Created *scripts/collections/README.md* with directory
documentation, scripts table, and prerequisites.
## Related Issue(s)
Related to #521
## Type of Change
Select all that apply:
**Code & Documentation:**
- [ ] Bug fix (non-breaking change fixing an issue)
- [ ] New feature (non-breaking change adding functionality)
- [ ] Breaking change (fix or feature causing existing functionality to
change)
- [x] Documentation update
**Infrastructure & Configuration:**
- [ ] GitHub Actions workflow
- [ ] Linting configuration (markdown, PowerShell, etc.)
- [ ] Security configuration
- [ ] DevContainer configuration
- [ ] Dependency update
**AI Artifacts:**
- [ ] Reviewed contribution with `prompt-builder` agent and addressed
all feedback
- [ ] Copilot instructions (`.github/instructions/*.instructions.md`)
- [ ] Copilot prompt (`.github/prompts/*.prompt.md`)
- [ ] Copilot agent (`.github/agents/*.agent.md`)
- [ ] Copilot skill (`.github/skills/*/SKILL.md`)
> **Note for AI Artifact Contributors**:
>
> - **Agents**: Research, indexing/referencing other project (using
standard VS Code GitHub Copilot/MCP tools), planning, and general
implementation agents likely already exist. Review `.github/agents/`
before creating new ones.
> - **Skills**: Must include both bash and PowerShell scripts. See
[Skills](../docs/contributing/skills.md).
> - **Model Versions**: Only contributions targeting the **latest
Anthropic and OpenAI models** will be accepted. Older model versions
(e.g., GPT-3.5, Claude 3) will be rejected.
> - See [Agents Not
Accepted](../docs/contributing/custom-agents.md#agents-not-accepted) and
[Model Version
Requirements](../docs/contributing/ai-artifacts-common.md#model-version-requirements).
**Other:**
- [x] Script/automation (`.ps1`, `.sh`, `.py`)
- [ ] Other (please describe):
## Sample Prompts (for AI Artifact Contributions)
<!-- Not applicable: no AI artifact contributions in this PR -->
## Testing
All 11 extracted functions have dedicated test coverage in
*CollectionHelpers.Tests.ps1*. The new *Validate-Marketplace.Tests.ps1*
provides 15 Describe blocks covering format validation, required fields,
version consistency, duplicate detection, and source directory
verification. Existing *Validate-Collections.Tests.ps1* was relocated
and updated to match the new module structure. Coverage configuration in
*pester.config.ps1* was updated to include the `scripts/collections/`
directory.
Full suite: **1,500 tests, 0 failures, 84.12% code coverage** (up from
82.70%).
## Checklist
### Required Checks
- [x] Documentation is updated (if applicable)
- [x] Files follow existing naming conventions
- [x] Changes are backwards compatible (if applicable)
- [x] Tests added for new functionality (if applicable)
### AI Artifact Contributions
<!-- Not applicable: no AI artifact contributions in this PR -->
- [ ] Used `/prompt-analyze` to review contribution
- [ ] Addressed all feedback from `prompt-builder` review
- [ ] Verified contribution follows common standards and type-specific
requirements
### Required Automated Checks
The following validation commands must pass before merging:
- [x] Markdown linting: `npm run lint:md`
- [x] Spell checking: `npm run spell-check`
- [x] Frontmatter validation: `npm run lint:frontmatter`
- [x] Skill structure validation: `npm run validate:skills`
- [x] Link validation: `npm run lint:md-links`
- [x] PowerShell analysis: `npm run lint:ps`
- [x] Plugin freshness: `npm run plugin:generate`
## Security Considerations
<!-- 1 parent 0a600ba commit 1a6d7d9
17 files changed
Lines changed: 1547 additions & 1052 deletions
File tree
- .github
- scripts
- collections
- Modules
- extension
- plugins
- Modules
- tests
- collections
- plugins
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
0 commit comments