Skip to content

Commit

Permalink
update based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Jun 1, 2024
1 parent 8a7bc08 commit 82919fd
Show file tree
Hide file tree
Showing 30 changed files with 50 additions and 88 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- omit in toc -->
# install-action

[![release](https://img.shields.io/github/release/taiki-e/install-action?style=flat-square&logo=github)](https://github.com/taiki-e/install-action/releases/latest)
Expand Down
38 changes: 19 additions & 19 deletions TOOLS.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion manifests/biome.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/cargo-audit.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/cargo-cyclonedx.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/cargo-deny.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/cargo-dinghy.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/cargo-make.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/dprint.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/editorconfig-checker.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/git-cliff.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/just.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/mdbook-linkcheck.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/mdbook.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/osv-scanner.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/parse-changelog.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/protoc.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/shellcheck.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/shfmt.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/wasm-bindgen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/wasm-pack.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/wasmtime.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion manifests/zola.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tools/codegen/base/biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"repository": "https://github.com/biomejs/biome",
"website": "https://biomejs.dev",
"tag_prefix": "cli/v",
"bin": "${package}${exe}",
"platform": {
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/cargo-audit.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"repository": "https://github.com/rustsec/rustsec",
"website": "https://github.com/rustsec/rustsec/tree/HEAD/cargo-audit",
"license_markdown": "[Apache-2.0](https://github.com/rustsec/rustsec/blob/HEAD/cargo-audit/LICENSE-APACHE) OR [MIT](https://github.com/rustsec/rustsec/blob/HEAD/cargo-audit/LICENSE-MIT)",
"tag_prefix": "cargo-audit/v",
"rust_crate": "${package}",
Expand Down
1 change: 1 addition & 0 deletions tools/codegen/base/shellcheck.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"repository": "https://github.com/koalaman/shellcheck",
"website": "https://www.shellcheck.net",
"tag_prefix": "v",
"bin": "${package}-v${version}/${package}${exe}",
"platform": {
Expand Down
3 changes: 0 additions & 3 deletions tools/codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ impl<'de> Deserialize<'de> for Version {
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Manifests {
pub rust_crate: Option<String>,
/// Optional website override.
#[serde(skip_serializing_if = "Option::is_none")]
pub website: Option<String>,
pub template: Option<ManifestTemplate>,
/// Markdown for the licenses.
pub license_markdown: String,
Expand Down
32 changes: 4 additions & 28 deletions tools/codegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,36 +154,12 @@ fn main() -> Result<()> {
}

// Populate website
manifests.website = None;
//qmanifests.website = None;
if let Some(website) = base_info.website {
if website.is_empty() || website == base_info.repository {
panic!("Please do not put the repository in website, or set website to an empty value");
}
eprintln!("set to {website}");
manifests.website = Some(website);
} else {
if let Some(ref crate_io_info) = crates_io_info {
if let Some(ref homepage) = crate_io_info.crate_.homepage {
if !homepage.is_empty()
&& homepage != &base_info.repository
&& !homepage.contains("crates.io")
{
manifests.website = Some(homepage.clone());
eprintln!("set to {homepage}");
}
}
}
if manifests.website.is_none() {
if let Some(homepage) = repo_info.homepage {
if !homepage.is_empty()
&& homepage != base_info.repository
&& !homepage.contains("crates.io")
{
manifests.website = Some(homepage.clone());
eprintln!("set to {homepage}");
}
}
}
//manifests.website = Some(website);
}

// Populate license_markdown
Expand All @@ -199,8 +175,6 @@ fn main() -> Result<()> {
{
manifests.license_markdown = license_markdown;
}
} else {
panic!("No license found in crate metadata; set license_markdown manually")
}
} else if let Some(license) = repo_info.license {
if let Some(license) = license.spdx_id {
Expand Down Expand Up @@ -783,6 +757,7 @@ mod github {
#[derive(Debug, Deserialize)]
pub(crate) struct RepoMetadata {
#[serde(default)]
#[allow(dead_code)]
pub(crate) homepage: Option<String>,
#[serde(default)]
pub(crate) license: Option<RepoLicense>,
Expand Down Expand Up @@ -835,6 +810,7 @@ mod crates_io {

#[derive(Debug, Deserialize)]
pub(crate) struct CrateMetadata {
#[allow(dead_code)]
pub(crate) homepage: Option<String>,
pub(crate) repository: Option<String>,
}
Expand Down
37 changes: 23 additions & 14 deletions tools/codegen/src/tools-markdown.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::{env, fmt, path::PathBuf};
use std::{env, fmt, io::Write, path::PathBuf};

use anyhow::Result;
use fs_err as fs;
Expand Down Expand Up @@ -29,7 +29,7 @@ fn main() -> Result<()> {
paths.sort_by_key(fs_err::DirEntry::path);

let mut tools = vec![
ReadmeEntry {
MarkdownEntry {
name: "nextest".to_string(),
alias: "cargo-nextest".to_string().into(),
website: "https://nexte.st/".to_string(),
Expand All @@ -39,7 +39,7 @@ fn main() -> Result<()> {
repository: "https://github.com/nextest-rs/nextest".to_string(),
license_markdown: "[Apache-2.0](https://github.com/nextest-rs/nextest/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/nextest-rs/nextest/blob/HEAD/LICENSE-MIT)".to_string()
},
ReadmeEntry {
MarkdownEntry {
name: "valgrind".to_string(),
alias: None,
website: "https://valgrind.org/".to_string(),
Expand All @@ -64,7 +64,7 @@ fn main() -> Result<()> {
let manifests: Manifests =
serde_json::from_slice(&fs::read(manifest_dir.join(file_name))?)?;

let website = match manifests.website {
let website = match base_info.website {
Some(website) => website,
None => base_info.repository.clone(),
};
Expand All @@ -88,7 +88,7 @@ fn main() -> Result<()> {

let license_markdown = manifests.license_markdown;

let readme_entry = ReadmeEntry {
let readme_entry = MarkdownEntry {
name,
website,
repository,
Expand All @@ -101,22 +101,31 @@ fn main() -> Result<()> {
tools.push(readme_entry);
}

println!("# Tools");
println!();
println!("| Name | Where binaries will be installed | Where will it be installed from | Supported platform | License |");
println!("| ---- | -------------------------------- | ------------------------------- | ------------------ | ------- |");

tools.sort_by(|x, y| x.name.cmp(&y.name));

let mut markdown_file = workspace_root.clone();
markdown_file.push("TOOLS.md");

let file = std::fs::File::create(markdown_file).expect("Unable to create file");
let mut file = std::io::BufWriter::new(file);

let header = "# Tools
| Name | Where binaries will be installed | Where will it be installed from | Supported platform | License |
| ---- | -------------------------------- | ------------------------------- | ------------------ | ------- |
";

file.write_all(header.as_bytes()).expect("Unable to write header");

for tool in tools {
println!("{tool}");
file.write_all(tool.to_string().as_bytes()).expect("Unable to write entry");
}

Ok(())
}

#[derive(Debug)]
struct ReadmeEntry {
struct MarkdownEntry {
name: String,
alias: Option<String>,
website: String,
Expand Down Expand Up @@ -183,7 +192,7 @@ impl fmt::Display for InstalledTo {
}
}

impl fmt::Display for ReadmeEntry {
impl fmt::Display for MarkdownEntry {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let name = format!("| [**{}**]({}) ", self.name, self.website);
f.write_str(&name)?;
Expand All @@ -209,7 +218,7 @@ impl fmt::Display for ReadmeEntry {
}

f.write_str(&format!("| {} ", self.platforms))?;
f.write_str(&format!("| {} |", self.license_markdown))?;
f.write_str(&format!("| {} |\n", self.license_markdown))?;
Ok(())
}
}

0 comments on commit 82919fd

Please sign in to comment.