Skip to content
Merged
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
16 changes: 15 additions & 1 deletion src/subcommands/publishing_scaffold_native_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ pub struct PublishingScaffoldNativePackageSubcommandArgs {
/// Rust triple representing the platform that `lib-source` was compiled under.
lib_triple: Utf8PathBuf,

/// The value of the "name" field in the main package's "package.json". Used to add context to
/// the README.md about the purpose of the package.
#[arg(long, default_value = None)]
lib_package_name: Option<String>,

Comment on lines +20 to +24
Copy link
Collaborator Author

@1egoman 1egoman Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this optional because I think there are situations where the parent package may not be clear at build time / it may not make sense to include it in the readme. Making this required also then breaks the nice <lib source> <triple> required args pattern which makes getting started slower.

/// The value to set the "name" field of the generated package.json
#[arg(long)]
package_name: String,
Expand Down Expand Up @@ -70,7 +75,7 @@ pub fn run(args: PublishingScaffoldNativePackageSubcommandArgs) -> Result<()> {
},
}
},
"files": ["src"],
"files": ["src", "README.md"],
"engines": { "node": ">= 18" },
});
fs::write(
Expand Down Expand Up @@ -104,5 +109,14 @@ pub fn run(args: PublishingScaffoldNativePackageSubcommandArgs) -> Result<()> {
).context(format!("Error writing {filename}"))?;
}

fs::write(
args.out_dir.clone().join("README.md"),
if let Some(lib_package_name) = args.lib_package_name {
format!("# {}\nThis is an internal package containing the `{}` platform binary for the `{}` package.\n", args.package_name, args.lib_triple, lib_package_name)
} else {
format!("# {}\nThis is an internal package containing a `{}` platform binary.\n", args.package_name, args.lib_triple)
},
).context(format!("Error writing README.md"))?;

Ok(())
}