-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli.rs): add
init plugin
command, bootstraps a plugin project (#…
- Loading branch information
1 parent
3a59f5f
commit ac8e69a
Showing
98 changed files
with
1,616 additions
and
96 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,5 @@ | ||
--- | ||
"cli.rs": patch | ||
--- | ||
|
||
Added `$ tauri init plugin` command, which initializes a Tauri plugin. |
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
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,44 @@ | ||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
use std::{ | ||
collections::BTreeMap, | ||
fs::{create_dir_all, File}, | ||
io::Write, | ||
path::Path, | ||
}; | ||
|
||
use handlebars::Handlebars; | ||
use include_dir::Dir; | ||
|
||
pub fn render<P: AsRef<Path>>( | ||
handlebars: &Handlebars, | ||
data: &BTreeMap<&str, serde_json::Value>, | ||
dir: &Dir, | ||
out_dir: P, | ||
) -> crate::Result<()> { | ||
create_dir_all(out_dir.as_ref().join(dir.path()))?; | ||
for file in dir.files() { | ||
let mut file_path = file.path().to_path_buf(); | ||
// cargo for some reason ignores the /templates folder packaging when it has a Cargo.toml file inside | ||
// so we rename the extension to `.crate-manifest` | ||
if let Some(extension) = file_path.extension() { | ||
if extension == "crate-manifest" { | ||
file_path.set_extension("toml"); | ||
} | ||
} | ||
let mut output_file = File::create(out_dir.as_ref().join(file_path))?; | ||
if let Some(utf8) = file.contents_utf8() { | ||
handlebars | ||
.render_template_to_write(utf8, &data, &mut output_file) | ||
.expect("Failed to render template"); | ||
} else { | ||
output_file.write_all(file.contents())?; | ||
} | ||
} | ||
for dir in dir.dirs() { | ||
render(handlebars, data, dir, out_dir.as_ref())?; | ||
} | ||
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
Oops, something went wrong.