Skip to content

feat(prepare-sources): implement protocol-resolution module (RHIDP-15838) - #176

Open
davidfestal wants to merge 4 commits into
redhat-developer:mainfrom
davidfestal:fix-15838
Open

davidfestal wants to merge 4 commits into
redhat-developer:mainfrom
davidfestal:fix-15838

Conversation

@davidfestal

Copy link
Copy Markdown
Member

feat(prepare-sources): implement protocol-resolution pipeline module

Resolves RHIDP-15838

Summary

Adds the protocol-resolution module to the prepare-sources pipeline. This module rewrites workspace:^, workspace:*, workspace:~, and backstage:^ protocol references in package.json and yarn.lock into concrete npm semver ranges, and creates @internal/type-shims when scrubbed host-app types are needed by surviving code.

This is a full TypeScript rewrite of the legacy update-workspace.js --update + createTypeShimsPackage logic, using a parser-based (structured Lockfile/LockfileBlock) approach instead of regex-based string manipulation.

What's included

Core module (lib/modules/protocol-resolution/)

  • package-json.ts — resolves protocol refs across all five dep sections + resolutions
  • yarn-lock-update.ts — multi-pass lockfile orchestrator: delete stale blocks → convert protocol dep values → create missing npm resolution blocks → resolve dangling deps → enrich specifiers
  • yarn-lock-blocks.ts — creates hard npm resolution blocks (for both scrubbed and local packages)
  • yarn-lock-enrich.ts — adds missing specifiers to existing block keys
  • yarn-lock-metadata.ts — manifest + npm-registry metadata resolution for block creation
  • type-shims.ts — full type-shims package with asset-type detection, theme augmentation, EXTRA_RUNTIME_TYPES, and tsconfig wiring
  • semver-range.ts, version-map.ts, utils.ts, constants.ts — shared helpers

Behavioral alignment with legacy d405bc257 ("Additional version drift fixes")

  • Local/embedded packages now get separate hard npm blocks for dist-dynamic stability (replaces the old createCombinedKeysForLocalPackages approach that attached npm keys to soft blocks)
  • Dangling-dep resolution includes local packages
  • Specifier enrichment includes local packages with hard npm blocks

Test coverage — 24 declarative input/output fixtures covering:

  • All protocol variants (workspace:^, workspace:*, workspace:~, backstage:^)
  • resolutions section, workspaces: { packages: [...] } object format
  • Stale block deletion, dangling dep resolution, specifier enrichment
  • Type-shims: asset-type detection, theme augmentation, EXTRA_RUNTIME_TYPES, npm fallback
  • Hard npm blocks for local packages (comprehensive local + scrubbed scenario)
  • Error cases (missing manifest, missing yarn.lock)

NOTE: Based on top of PR #175 which should be merged first

davidfestal and others added 4 commits October 1, 2026 16:12
Generate manifest.json (workspace package inventory) and, when the
workspace contains backstage:^ dependencies, backstage-manifest.json
with @backstage package metadata extracted from yarn.lock and
validated against versions.backstage.io.

Add a zero-dependency Yarn Berry lockfile parser/serializer for
round-trip fidelity, shared manifest types, and fixture-based tests.
Extend test utilities with a mockFetch helper and wire the module
into the pipeline runner. Add @vitest/coverage-v8 and ignore the
coverage directory.

Assisted-by: Cursor
Signed-off-by: David Festal <dfestal@redhat.com>
Intersect `plugins-list.yaml` with `rhdh-supported-packages.txt` for the
current workspace, preserve packages referenced by
`dist-dynamic/embedded/*/package.json`, remove infrastructure directories
(`packages/app`, `packages/backend`, `.storybook`, `examples/`,
`node_modules`), and delete remaining non-supported plugin directories.
Rewrite the filtered `plugins-list.yaml` back to the overlay path,
preserving full lines including export CLI args.

Expose `overlayRepoRoot` on `PipelineInputs` so tier-list files can be read
from the overlay repository root instead of resolving `../..` inside the
module. Update the fixture loader to support an `input/overlay-root/`
directory for tier-list fixtures.

Add the module implementation, unit tests, fixtures, and README.md;
wire the module into the pipeline runner.

Assisted-by: Cursor
Signed-off-by: David Festal <dfestal@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: David Festal <dfestal@redhat.com>
…ne module

Remove test, mock, and dev-only files from surviving workspace packages:
directories `dev/`, `e2e-tests/`, `__tests__/`, `__mocks__/` and files matching
`*.test.ts`, `*.test.tsx`, `*.spec.ts`, `*.spec.tsx`, while preserving paths
under `node_modules/` and `dist-dynamic/`. Aligns with `sync-midstream.sh`
lines 917–924.

Add the module implementation, fixture-based tests, fixtures, and README.md;
wire the module into the pipeline runner. Exclude `__fixtures__` directories
from Vitest discovery in `vite.config.ts`.

Assisted-by: Cursor
Signed-off-by: David Festal <dfestal@redhat.com>
… pipeline module

Resolve `workspace:^` and `backstage:^` protocol references to concrete npm
semver ranges in `package.json` and `yarn.lock`. Preserve `workspace:^` for
packages that still exist locally on disk, and create `packages/type-shims`
when surviving code needs types from scrubbed packages.

Add shared `yarn-lock-helpers` for mutating parsed Yarn Berry lockfiles,
consumed by `protocol-resolution` and future modules. Add the module
implementation, fixture-based tests, fixtures, and README.md; wire the
module into the pipeline runner.

Assisted-by: Cursor
Signed-off-by: David Festal <dfestal@redhat.com>
@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

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.

1 participant