-
Notifications
You must be signed in to change notification settings - Fork 22
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
2c71158
commit 9115018
Showing
17 changed files
with
328 additions
and
271 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -71,5 +71,5 @@ fn check_npm() -> Result<()> { | |
} | ||
|
||
fn check_mkdocs() -> Result<()> { | ||
Mkdocs::build() | ||
Mkdocs::check() | ||
} |
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,7 @@ | ||
use anyhow::Result; | ||
|
||
use crate::toolchains::mkdocs::Mkdocs; | ||
|
||
pub fn publish_mkdocs(dry_run: bool) -> Result<()> { | ||
Mkdocs::publish(dry_run) | ||
} |
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 |
---|---|---|
@@ -1,52 +1,6 @@ | ||
use std::collections::HashMap; | ||
use std::path::Path; | ||
|
||
use anyhow::{Context, Result}; | ||
use infra_utils::commands::Command; | ||
use infra_utils::github::GitHub; | ||
use infra_utils::paths::PathExtensions; | ||
use serde::Deserialize; | ||
use anyhow::Result; | ||
use infra_utils::pipenv::PipEnv; | ||
|
||
pub fn setup_pipenv() -> Result<()> { | ||
// Install the 'pipenv' binary using the version defined in the `Pipfile`. | ||
install_pipenv_binary()?; | ||
|
||
// Use it to install other dependencies: | ||
install_project_packages()?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[derive(Deserialize)] | ||
struct Pipfile { | ||
packages: HashMap<String, String>, | ||
} | ||
|
||
fn install_pipenv_binary() -> Result<()> { | ||
let pip_file_toml = Path::repo_path("Pipfile").read_to_string()?; | ||
let pip_file: Pipfile = toml::from_str(&pip_file_toml)?; | ||
|
||
// This should be a value like "==YYYY.MM.DD" | ||
let version = pip_file | ||
.packages | ||
.get("pipenv") | ||
.context("Failed to find 'pipenv' in 'Pipfile' packages.")?; | ||
|
||
// pip3 install "pipenv==YYYY.MM.DD" | ||
Command::new("pip3") | ||
.arg("install") | ||
.arg(format!("pipenv{version}")) | ||
.run() | ||
} | ||
|
||
fn install_project_packages() -> Result<()> { | ||
let mut command = Command::new("python3") | ||
.property("-m", "pipenv") | ||
.arg("install"); | ||
|
||
if GitHub::is_running_in_ci() { | ||
command = command.flag("--deploy"); | ||
} | ||
|
||
command.run() | ||
PipEnv::install_packages() | ||
} |
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 |
---|---|---|
|
@@ -3,34 +3,53 @@ use std::path::Path; | |
use anyhow::Result; | ||
use infra_utils::commands::Command; | ||
use infra_utils::paths::PathExtensions; | ||
use infra_utils::pipenv::PipEnv; | ||
|
||
pub struct Mkdocs; | ||
|
||
impl Mkdocs { | ||
pub fn build() -> Result<()> { | ||
mkdocs_command() | ||
.arg("build") | ||
.flag("--clean") | ||
.flag("--strict") | ||
.run() | ||
pub fn check() -> Result<()> { | ||
mkdocs().arg("build").flag("--clean").flag("--strict").run() | ||
} | ||
|
||
pub fn watch() -> Result<()> { | ||
// _MKDOCS_WATCH_PORT_ | keep in sync with the port number defined in "$REPO_ROOT/.devcontainer/devcontainer.json" | ||
const PORT: usize = 5353; | ||
|
||
mkdocs_command() | ||
mkdocs() | ||
.arg("serve") | ||
.flag("--clean") | ||
.flag("--watch-theme") | ||
.property("--dev-addr", format!("localhost:{PORT}")) | ||
.run() | ||
} | ||
|
||
pub fn publish(dry_run: bool) -> Result<()> { | ||
Command::new("git") | ||
.args(["fetch", "origin", "gh-pages"]) | ||
.property("--depth", "1") | ||
.run()?; | ||
|
||
// only once: | ||
// mike set-default [identifier] | ||
|
||
// # git config user.name ci-bot | ||
// # git config user.email [email protected] | ||
|
||
// - run: "python3 -m pipenv run mike deploy main" | ||
// if (dry_run) add "--push" to the "deploy" command | ||
|
||
// # or: | ||
// # use 'mike list [identifier]' first to check if the version exists | ||
// # - run: "python3 -m pipenv run mike deploy 0.15.0 latest --update-aliases --push" | ||
// if (dry_run) add "--push" to the "deploy" command | ||
} | ||
} | ||
|
||
fn mkdocs() -> Command { | ||
PipEnv::run("mkdocs").current_dir(Path::repo_path("documentation")) | ||
} | ||
|
||
fn mkdocs_command() -> Command { | ||
Command::new("python3") | ||
.property("-m", "pipenv") | ||
.args(["run", "mkdocs"]) | ||
.current_dir(Path::repo_path("documentation")) | ||
fn mike() -> Command { | ||
PipEnv::run("mike").current_dir(Path::repo_path("documentation")) | ||
} |
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 |
---|---|---|
|
@@ -4,4 +4,5 @@ pub mod commands; | |
pub mod git; | ||
pub mod github; | ||
pub mod paths; | ||
pub mod pipenv; | ||
pub mod terminal; |
Oops, something went wrong.