Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/verify-plugin-export.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ jobs:
- extensions
- global-header
- homepage
- lightspeed
- orchestrator
- quickstart
- scorecard
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to `@red-hat-developer-hub/cli` are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.11.4 - 2026-07-30

### Fixed

- Propagate monorepo root yarn resolutions to dynamic plugin exports:
read resolutions from the monorepo root `package.json` and propagate
them to the generated `dist-dynamic/package.json`, filtering out `patch:`
resolutions.

## 1.11.3 - 2026-07-20

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/rhdh-plugins-build-package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('export and package rhdh-plugins scorecard workspace plugin', () => {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
const role = packageJson.backstage?.role;
const expectedFeatures = expect.objectContaining({
'./alpha': '@backstage/FrontendPlugin',
'.': '@backstage/FrontendPlugin',
});
if (role === 'frontend-plugin') {
// eslint-disable-next-line jest/no-conditional-expect
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@red-hat-developer-hub/cli",
"description": "CLI for developing Backstage plugins and apps",
"version": "1.11.3",
"version": "1.11.4",
"publishConfig": {
"access": "public"
},
Expand Down
30 changes: 30 additions & 0 deletions src/commands/export-dynamic-plugin/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
isValidPluginModule,
} from './backend-utils';

export async function getMonorepoRootResolutions(): Promise<
Record<string, string>
> {
const rootPkgPath = path.join(paths.targetRoot, 'package.json');
return (await fs.readJson(rootPkgPath).catch(() => ({}))).resolutions || {};
}

export async function backend(opts: OptionValues): Promise<string> {
const targetRelativePath = 'dist-dynamic';
const target = path.join(paths.targetDir, targetRelativePath);
Expand All @@ -68,6 +75,8 @@
const suppressNative = (opts.suppressNativePackage || []) as string[];
const ignoreVersionCheck = (opts.ignoreVersionCheck || []) as string[];
const monoRepoPackages = await getPackages(paths.targetDir);

const rootResolutions = await getMonorepoRootResolutions();
const embeddedResolvedPackages = await searchEmbedded(
pkg,
packagesToEmbed,
Expand Down Expand Up @@ -291,6 +300,7 @@
// which are related to the packaging of the original static package.
scripts: {},
},
rootResolutions,
additionalResolutions: {
...embeddedDependenciesResolutions,
...suppressNative
Expand Down Expand Up @@ -772,6 +782,7 @@
})
| undefined;
additionalOverrides?: { [key: string]: any } | undefined;
rootResolutions?: Record<string, string> | undefined;

Check warning on line 785 in src/commands/export-dynamic-plugin/backend.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Consider removing 'undefined' type or '?' specifier, one of them is redundant.

See more on https://sonarcloud.io/project/issues?id=redhat-developer_rhdh-cli&issues=AZ-z9jKrOdAYSreXHQJk&open=AZ-z9jKrOdAYSreXHQJk&pullRequest=152
additionalResolutions?: { [key: string]: any } | undefined;
after?: ((pkg: BackstagePackageJson) => void) | undefined;
}): (dynamicPkgPath: string) => Promise<void> {
Expand Down Expand Up @@ -945,13 +956,32 @@
// to prevent npm version drift during yarn install --no-immutable.
// Existing resolutions and additionalResolutions (embedded file: refs) take precedence.
const resolutions = (pkgToCustomize as any).resolutions || {};

// Skip patch: resolutions — the .yarn/patches/ files won't exist in the
// dist-dynamic directory so those entries can't be applied. Propagating
// only plain version resolutions avoids asymmetry when the workspace is
// scrubbed (--remove-patches deletes patch: entries between loops).
const filteredRootResolutions: Record<string, string> = {};
if (options.rootResolutions) {
for (const [key, value] of Object.entries(options.rootResolutions)) {
if (value.startsWith('patch:')) continue;
filteredRootResolutions[key] = value;
}
}
const rootResKeys = Object.keys(filteredRootResolutions);
if (rootResKeys.length > 0) {
Task.log(
` Propagating ${rootResKeys.length} root resolution(s) to dist-dynamic: ${rootResKeys.join(', ')}`,
);
}
(pkgToCustomize as any).resolutions = {
// The following lines are a workaround for the fact that the @aws-sdk/util-utf8-browser package
// is not compatible with the NPM 9+, so that `npm pack` would not grab the Javascript files.
// This package has been deprecated in favor of @smithy/util-utf8.
//
// See https://github.com/aws/aws-sdk-js-v3/issues/5305.
'@aws-sdk/util-utf8-browser': 'npm:@smithy/util-utf8@~2',
...filteredRootResolutions,
...pinnedResolutions,
...resolutions,
...(options.additionalResolutions || {}),
Expand Down
6 changes: 5 additions & 1 deletion src/commands/export-dynamic-plugin/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { buildScalprumPlugin } from '../../lib/builder/buildScalprumPlugin';
import { productionPack } from '../../lib/packager/productionPack';
import { paths } from '../../lib/paths';
import { Task } from '../../lib/tasks';
import { customizeForDynamicUse } from './backend';
import { customizeForDynamicUse, getMonorepoRootResolutions } from './backend';
import { detectBackstageFeatures } from './features';

function isTruthyCiEnv(value: string | undefined): boolean {
Expand Down Expand Up @@ -128,6 +128,9 @@ export async function frontend(
: undefined;

const monoRepoPackages = await getPackages(paths.targetDir);

const rootResolutions = await getMonorepoRootResolutions();

await customizeForDynamicUse({
embedded: [],
isYarnV1: false,
Expand All @@ -142,6 +145,7 @@ export async function frontend(
scripts: {},
files,
},
rootResolutions,
after: detectedFeatures
? pkg => {
pkg.backstage = pkg.backstage ?? {};
Expand Down
Loading