Skip to content

Commit 9faabc2

Browse files
authored
feat: add logic to write platform specific README in native package scaffolding (#27)
1 parent e00e0f5 commit 9faabc2

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/subcommands/publishing_scaffold_native_package.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ pub struct PublishingScaffoldNativePackageSubcommandArgs {
1717
/// Rust triple representing the platform that `lib-source` was compiled under.
1818
lib_triple: Utf8PathBuf,
1919

20+
/// The value of the "name" field in the main package's "package.json". Used to add context to
21+
/// the README.md about the purpose of the package.
22+
#[arg(long, default_value = None)]
23+
lib_package_name: Option<String>,
24+
2025
/// The value to set the "name" field of the generated package.json
2126
#[arg(long)]
2227
package_name: String,
@@ -70,7 +75,7 @@ pub fn run(args: PublishingScaffoldNativePackageSubcommandArgs) -> Result<()> {
7075
},
7176
}
7277
},
73-
"files": ["src"],
78+
"files": ["src", "README.md"],
7479
"engines": { "node": ">= 18" },
7580
});
7681
fs::write(
@@ -104,5 +109,14 @@ pub fn run(args: PublishingScaffoldNativePackageSubcommandArgs) -> Result<()> {
104109
).context(format!("Error writing {filename}"))?;
105110
}
106111

112+
fs::write(
113+
args.out_dir.clone().join("README.md"),
114+
if let Some(lib_package_name) = args.lib_package_name {
115+
format!("# {}\nThis is an internal package containing the `{}` platform binary for the `{}` package.\n", args.package_name, args.lib_triple, lib_package_name)
116+
} else {
117+
format!("# {}\nThis is an internal package containing a `{}` platform binary.\n", args.package_name, args.lib_triple)
118+
},
119+
).context(format!("Error writing README.md"))?;
120+
107121
Ok(())
108122
}

0 commit comments

Comments
 (0)