Skip to content

Commit 63725f7

Browse files
authored
fix: CreateChangeFile (like knope document-change) now prints package names. (#669)
Closes #634 Co-authored-by: Dylan Anthony <[email protected]>
1 parent 89fe37c commit 63725f7

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

docs/src/content/docs/tutorials/releasing-multiple-packages.mdx

+8-8
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,19 @@ Knope will ask which packages the change impacts:
227227

228228
```text
229229
? Which packages does this change affect?
230-
> [ ] pizza
230+
[x] pizza
231231
[ ] toppings
232-
[ ] calzone
232+
> [x] calzone
233233
[↑↓ to move, space to select one, → to all, ← to none, type to filter]
234234
```
235235

236236
Use the arrow keys and space bar to select `pizza` and `calzone`, then press enter.
237-
Next, select `patch` as the change type for each (they're in order):
237+
Next, select `patch` as the change type for each:
238238

239239
```text
240240
> Which packages does this change affect? pizza, calzone
241-
> What type of change is this? patch
242-
? What type of change is this?
241+
> What type of change is this for pizza? patch
242+
? What type of change is this for calzone?
243243
major
244244
minor
245245
> patch
@@ -250,8 +250,8 @@ Finally, summarize the change:
250250

251251
```text
252252
> Which packages does this change affect? pizza, calzone
253-
> What type of change is this? patch
254-
> What type of change is this? patch
253+
> What type of change is this for pizza? patch
254+
> What type of change is this for calzone? patch
255255
? What is a short summary of this change? The cheese is now distributed more evenly
256256
[This will be used as a header in the changelog]
257257
```
@@ -260,8 +260,8 @@ This will create a change file that looks like this:
260260

261261
```md title=".changeset/the_cheese_is_now_distributed_more_evenly.md"
262262
---
263-
calzone: patch
264263
pizza: patch
264+
calzone: patch
265265
---
266266

267267
# The cheese is now distributed more evenly

src/step/releases/changesets.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(crate) fn create_change_file(run_type: RunType) -> Result<RunType, Error> {
3131
let versioning = packages
3232
.into_iter()
3333
.map(|package| {
34-
let package_name = package.to_string();
34+
let package_name = package.name;
3535
let change_types = package
3636
.changelog_sections
3737
.into_keys()
@@ -43,11 +43,21 @@ pub(crate) fn create_change_file(run_type: RunType) -> Result<RunType, Error> {
4343
}
4444
})
4545
.collect_vec();
46-
Select::new("What type of change is this?", change_types)
46+
let prompt = if let Some(package_name) = package_name.as_ref() {
47+
format!("What type of change is this for {package_name}?")
48+
} else {
49+
"What type of change is this?".to_string()
50+
};
51+
Select::new(&prompt, change_types)
4752
.prompt()
4853
.map_err(prompt::Error::from)
4954
.map_err(Error::from)
50-
.map(|change_type| (package_name, change_type.into()))
55+
.map(|change_type| {
56+
(
57+
package_name.unwrap_or_default().to_string(),
58+
change_type.into(),
59+
)
60+
})
5161
})
5262
.collect::<Result<Versioning, Error>>()?;
5363
let summary = inquire::Text::new("What is a short summary of this change?")

src/step/releases/package.rs

+6
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ impl Display for Package {
164164
#[serde(transparent)]
165165
pub(crate) struct PackageName(String);
166166

167+
impl Default for PackageName {
168+
fn default() -> Self {
169+
Self(DEFAULT_CHANGESET_PACKAGE_NAME.to_string())
170+
}
171+
}
172+
167173
impl Display for PackageName {
168174
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
169175
self.0.fmt(f)

0 commit comments

Comments
 (0)