-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1c9347
commit 2f349d4
Showing
5 changed files
with
107 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[licenses] | ||
# This section is considered when running `cargo deny check license` | ||
# More documentation for the licenses section can be found here: | ||
# https://github.com/EmbarkStudios/cargo-deny#the-licenses-section | ||
|
||
# Uncomment the following line to change the lint level for unlicensed crates [possible values: "deny", "allow" or "warn"]. | ||
#unlicensed = "deny" | ||
|
||
# Uncomment the following line to explictly allow certain licenses [possible values: any SPDX 2.1 identifier]. | ||
#allow = [] | ||
|
||
# Uncomment the following line to explictly disallow certain licenses [possible values: any SPDX 2.1 identifier]. | ||
#deny = [] | ||
|
||
# Uncomment the following line to change the lint level for licenses considered copyleft [possible values: "deny", "allow" or "warn"]. | ||
#copyleft = "warn" | ||
|
||
# Uncomment the following line to approve or deny OSI-approved or FSF Free/Libre licenses [possible values: "both", "either", "osi-only", "fsf-only" or "neither"]. | ||
#allow-osi-fsf-free = "neither" | ||
|
||
# Uncomment the following line to change the confidence threshold. [possible values: any between 0.0 and 1.0]. | ||
# The higher the value, the more closely the license text must be to the canonical license text of a valid SPDX license file. | ||
#confidence-threshold = 0.8 | ||
|
||
[bans] | ||
# This section is considered when running `cargo deny check ban`. | ||
# More documentation about the 'bans' section can be found here: | ||
# https://github.com/EmbarkStudios/cargo-deny#crate-bans-cargo-deny-check-ban | ||
|
||
# Uncomment the following line to change what happens when multiple versions of the same crate are encountered [possible values: "deny", "warn" or "allow"]. | ||
#multiple-versions = "warn" | ||
|
||
# Uncomment the following line to change the highlighting variant used to multiple versions of the same crate when creating | ||
# a dotgraph of your crates dependencies [possible values: "lowest-version", "simplest-path" or "all"]. | ||
#highlight = "all" | ||
|
||
# Uncomment the following line to allow specific crates. | ||
#allow = [] | ||
|
||
# Uncomment the following line to deny specific crates. | ||
#deny = [] | ||
|
||
# Uncomment the following line to skip specific crates. | ||
#skip = [] | ||
|
||
# Uncomment the following line to skip specific crates (including different versions of the same crate down the dependency | ||
# tree). By default, the depth is infinite. If however desired, the depth can be ajusted. | ||
#skip-tree = [] |
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
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
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,41 @@ | ||
use anyhow::{ensure, Context, Error}; | ||
use std::path::PathBuf; | ||
use structopt::StructOpt; | ||
|
||
use crate::common::make_absolute_path; | ||
|
||
#[derive(StructOpt, Debug, Clone)] | ||
pub struct Args { | ||
/// The path to the config file. Defaults to <context>/deny.toml | ||
#[structopt(short, long, parse(from_os_str))] | ||
config: Option<PathBuf>, | ||
} | ||
|
||
const DENY_TOML: &str = "deny.toml"; | ||
const CONTENTS: &[u8] = include_bytes!("../../resources/template.toml"); | ||
|
||
pub fn cmd(args: Args, context_dir: PathBuf) -> Result<(), Error> { | ||
let cfg_file = args | ||
.config | ||
.clone() | ||
.or_else(|| Some(DENY_TOML.into())) | ||
.map(|path| make_absolute_path(path, context_dir)) | ||
.context("unable to determine config path")?; | ||
|
||
// make sure the file does not exist yet | ||
ensure!( | ||
std::fs::metadata(&cfg_file).is_err(), | ||
"unable to initialize cargo deny config file ; the provided path already exists" | ||
); | ||
// make sure the path does not terminate in '..'; we need a file name. | ||
ensure!( | ||
&cfg_file.file_name().is_some(), | ||
"unable to create a config file with the given name ; the given file path is not valid" | ||
); | ||
|
||
log::info!("saving config file to: {}", &cfg_file.display()); | ||
|
||
std::fs::write(cfg_file, CONTENTS).context("unable to write config file")?; | ||
|
||
Ok(()) | ||
} |
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