fix(cli): identify custom patterns that extend the default pattern
If a custom pattern is used, `backstage.json` will not be updated.
However, if the custom pattern extends the default pattern,
`backstage.json` will be updated, too.
Example:
- `@backstage/*` (default)
- `@{backstage,backstage-community}/*`
- `@{extra1,backstage,extra2}/*`
Fixes: #28839
Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Modify the `backstage.json` also for custom patterns if it extends the default pattern.
|
||||
|
||||
Examples:
|
||||
|
||||
- `@backstage/*` (default pattern)
|
||||
- `@{backstage,backstage-community}/*`
|
||||
- `@{extra1,backstage,extra2}/*`
|
||||
@@ -772,6 +772,7 @@ describe('bump', () => {
|
||||
res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
releaseVersion: '1.0.0',
|
||||
packages: [],
|
||||
}),
|
||||
),
|
||||
@@ -797,7 +798,7 @@ describe('bump', () => {
|
||||
'bumping @backstage-extra/custom in b to ^1.1.0',
|
||||
'bumping @backstage-extra/custom-two in b to ^2.0.0',
|
||||
'bumping @backstage/theme in b to ^2.0.0',
|
||||
'Skipping backstage.json update as custom pattern is used',
|
||||
'Your project is now at version 1.0.0, which has been written to backstage.json',
|
||||
'Running yarn install to install new versions',
|
||||
'Checking for moved packages to the @backstage-community namespace...',
|
||||
'⚠️ The following packages may have breaking changes:',
|
||||
|
||||
@@ -18,6 +18,7 @@ maybeBootstrapProxy();
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import chalk from 'chalk';
|
||||
import { minimatch } from 'minimatch';
|
||||
import semver from 'semver';
|
||||
import { OptionValues } from 'commander';
|
||||
import yaml from 'yaml';
|
||||
@@ -78,6 +79,14 @@ type PkgVersionInfo = {
|
||||
location: string;
|
||||
};
|
||||
|
||||
function extendsDefaultPattern(pattern: string): boolean {
|
||||
if (!pattern.endsWith('/*')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return minimatch('@backstage/', pattern.slice(0, -1));
|
||||
}
|
||||
|
||||
export default async (opts: OptionValues) => {
|
||||
const lockfilePath = paths.resolveTargetRoot('yarn.lock');
|
||||
const lockfile = await Lockfile.load(lockfilePath);
|
||||
@@ -245,8 +254,8 @@ export default async (opts: OptionValues) => {
|
||||
|
||||
console.log();
|
||||
|
||||
// Do not update backstage.json when upgrade patterns are used.
|
||||
if (pattern === DEFAULT_PATTERN_GLOB) {
|
||||
// Do not update backstage.json when default pattern is not covered
|
||||
if (extendsDefaultPattern(pattern)) {
|
||||
await bumpBackstageJsonVersion(
|
||||
releaseManifest.releaseVersion,
|
||||
hasYarnPlugin,
|
||||
|
||||
Reference in New Issue
Block a user