-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(release): ensure @org/package style names are wrapped in quotes i…
…n plan files
- Loading branch information
1 parent
132ce96
commit 99cf75e
Showing
3 changed files
with
55 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/nx/src/command-line/release/utils/generate-version-plan-content.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { generateVersionPlanContent } from './generate-version-plan-content'; | ||
|
||
describe('generateVersionPlanContent()', () => { | ||
it('should generate the version plan content', () => { | ||
expect(generateVersionPlanContent({ proj: '1.0.0' }, 'message')) | ||
.toMatchInlineSnapshot(` | ||
"--- | ||
proj: 1.0.0 | ||
--- | ||
message | ||
" | ||
`); | ||
}); | ||
|
||
it('should wrap project keys in quotes if they start with an @ symbol', () => { | ||
expect( | ||
generateVersionPlanContent( | ||
{ '@proj/foo': '1.0.0', 'a-b-c': '2.3.4' }, | ||
'message' | ||
) | ||
).toMatchInlineSnapshot(` | ||
"--- | ||
'@proj/foo': 1.0.0 | ||
a-b-c: 2.3.4 | ||
--- | ||
message | ||
" | ||
`); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/nx/src/command-line/release/utils/generate-version-plan-content.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export function generateVersionPlanContent( | ||
bumps: Record<string, string>, | ||
message: string | ||
): string { | ||
return `--- | ||
${Object.entries(bumps) | ||
.filter(([_, version]) => version !== 'none') | ||
.map(([projectOrGroup, version]) => { | ||
let key = projectOrGroup; | ||
// frontmatter parsing will blow up if we don't wrap @org/package style project names in quotes | ||
if (key.startsWith('@')) { | ||
key = `'${key}'`; | ||
} | ||
return `${key}: ${version}`; | ||
}) | ||
.join('\n')} | ||
--- | ||
${message} | ||
`; | ||
} |