Skip to content

Commit

Permalink
Merge pull request #101 from perryrh0dan/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
perryrh0dan authored Oct 4, 2020
2 parents d5cdd09 + 7c8baa6 commit 08ab4a3
Show file tree
Hide file tree
Showing 14 changed files with 288 additions and 208 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ install:
- sh scripts/install.sh
- source ~/.cargo/env || true
script:
- bash scripts/script.sh
- bash scripts/test.sh
after_script: set +e
before_deploy:
- sh scripts/before_deploy.sh
Expand Down
30 changes: 18 additions & 12 deletions Cargo.lock

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

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[package]
name = "tmpo"
description = "Command line utility to create new workspaces based on predefined templates"
version = "1.8.2"
authors = ["Thomas Pöhlmann <[email protected]>"]
edition = "2018"
license = "MIT"

[dependencies]
clap = { git = "https://github.com/clap-rs/clap/" }
clap = { version = "3.0.0-beta.2" }
serde = { version = "1.0.104", features = ["derive"] }
serde_json = "1.0.48"
serde_yaml = "0.8.13"
Expand All @@ -18,10 +20,10 @@ dialoguer = "0.6.2"
tempfile = "3.1.0"
flate2 = "1.0.17"
tar = "0.4.29"
handlebars = "3.4.0"
handlebars = "3.5.0"
regex = "1.3.9"
url = "2.1.1"
base64 = "0.12.3"
base64 = "0.13.0"

[dependencies.reqwest]
version = "0.10.8"
Expand Down
4 changes: 4 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ cross build --release --target x86_64-pc-windows-gnu
``` bash
cargo flamegraph --dev --bin=tmpo init thomas
```
## Codecoverage

- Install [grcov](https://github.com/mozilla/grcov)
- Run ./scripts/coverage.sh
50 changes: 26 additions & 24 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
<a href="https://travis-ci.com/perryrh0dan/tmpo">
<img alt="Build Status" src="https://travis-ci.com/perryrh0dan/tmpo.svg?branch=master" />
</a>
<a href="https://codecov.io/gh/perryrh0dan/tmpo">
<img src="https://codecov.io/gh/perryrh0dan/tmpo/branch/master/graph/badge.svg" />
</a>
<img src="https://img.shields.io/badge/coverage-64%2C5%25-yellow" />
<a href="https://codeclimate.com/github/perryrh0dan/tmpo/maintainability">
<img src="https://api.codeclimate.com/v1/badges/83561b59422e2492f9db/maintainability" />
</a>
Expand All @@ -27,7 +25,7 @@

## Description

Tmpo enables you to effectively create new workspaces based on predefined templates. To share templates across your team tmpo is using a git repository to manage your templates. Templates are automaticly fetched and merged on all clients.
Tmpo enables you to effectively create new workspaces based on predefined templates. To share templates across your team tmpo is using a git repository to manage your templates. Templates are automaticly fetched and merged on all clients.

<div align="center">
<img alt="diagram" width="100%" src="./media/diagram.png"/>
Expand All @@ -38,11 +36,12 @@ Visit the [contributing guidelines](https://github.com/perryrh0dan/tmpo/blob/mas
Come over to [Gitter](https://gitter.im/perryrh0dantmpo/community?source=orgpage) or [Twitter](https://twitter.com/perryrh0dan1) to share your thoughts on the project.

## Highlights

- Setup complex workspaces in seconds
- Templates support inheritence and placeholders
- Simple, Lightweight & fast
- Cross-platform: Linux, Windows and mac are official supported
- Everything can be a template. Python, Rust, Typescript, latex, markdown,...
- Everything can be a template. Python, Rust, Typescript, latex, markdown,...
- Share templates across your team or community with git
- Configurable through `~/.tmpo/config.yaml`
- Self Updater
Expand Down Expand Up @@ -78,18 +77,20 @@ A detailed description can be found [here](https://github.com/perryrh0dan/tmpo/b
### Quick Start

1. Add a [repository](#repositories) or use the [default repository](https://github.com/perryrh0dan/templates)
``` bash

```bash
tmpo repository add
```

2. Setup your first project
``` bash

```bash
tmpo init
```

### CLI

```
```
tmpo 1.5.3
Thomas P. <[email protected]>
Cli to create new workspaces based on templates
Expand All @@ -116,36 +117,37 @@ A repository is a folder that contains up to n different templates. A repository

To add a new repository use the `repository subcommand` and follow the instructions on the screen.

``` bash
```bash
tmpo repository add
```

### Templates

Templates can be configured with a `meta.json` in the template root.
Templates can be configured with a `meta.json` in the template root.
For a detailed description how to create and maintain templates have a look at the instructions in the default template repository [repository](https://github.com/perryrh0dan/templates)

## Configuration

The configuration file should only be changed by experienced users.

To configure tmpo navigate to the ~/.tmpo/config.yaml file and modify any of the options to match your own preference. To reset back to the default values, simply delete the config file from your home directory.

The following illustrates all the available options with their respective default values.

``` yaml
templates_dir: /home/thomas/.tmpo/templates
templates_repositories:
- name: default
description: this is the default template repository from tpoe
git_options:
enabled: true
provider: github
url: "https://github.com/perryrh0dan/templates"
branch: master
auth: none
token:
username: ~
password: ~
```yaml
templates_dir: /home/thomas/.tmpo/templates
templates_repositories:
- name: default
description: this is the default template repository from tpoe
git_options:
enabled: true
provider: github
url: "https://github.com/perryrh0dan/templates"
branch: master
auth: none
token:
username: ~
password: ~
```
## Development
Expand Down
4 changes: 3 additions & 1 deletion scripts/manually.sh → scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This script can be used for manual building tmpo

echo "Build x86_64-unknown-linux-gnu"
cross build --release --target x86_64-unknown-linux-gnu

echo "Build x86_64-pc-windows-gnu"
cross build --release --target x86_64-pc-windows-gnu
cross build --release --target x86_64-pc-windows-gnu
15 changes: 15 additions & 0 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This script can be used for generating a coverage report

rustup default nightly

export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Cpanic=abort"

cargo build

cargo test

grcov ./target/debug/ -s . -t html --llvm --branch --ignore-not-existing -o ./target/debug/coverage/

rustup default stable
File renamed without changes.
75 changes: 40 additions & 35 deletions src/git/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,46 +95,51 @@ pub fn build_meta_url(repository_url: &str) -> Result<String, RunError> {
Ok(meta_url)
}

#[test]
fn build_meta_url_success_default() {
let repository_url = "https://github.com/perryrh0dan/templates";

let url = build_meta_url(repository_url);
assert_eq!(
url.unwrap(),
"https://raw.githubusercontent.com/perryrh0dan/templates/master/meta.json"
);
}
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn build_meta_url_success_default() {
let repository_url = "https://github.com/perryrh0dan/templates";

let url = build_meta_url(repository_url);
assert_eq!(
url.unwrap(),
"https://raw.githubusercontent.com/perryrh0dan/templates/master/meta.json"
);
}

#[test]
fn build_meta_url_success_http() {
let repository_url = "http://github.com/perryrh0dan/templates";
#[test]
fn build_meta_url_success_http() {
let repository_url = "http://github.com/perryrh0dan/templates";

let url = build_meta_url(repository_url);
assert_eq!(
url.unwrap(),
"https://raw.githubusercontent.com/perryrh0dan/templates/master/meta.json"
);
}
let url = build_meta_url(repository_url);
assert_eq!(
url.unwrap(),
"https://raw.githubusercontent.com/perryrh0dan/templates/master/meta.json"
);
}

#[test]
fn build_meta_url_failure() {
let repository_url = "https://github.de/perryrh0dan/templates";
#[test]
fn build_meta_url_failure() {
let repository_url = "https://github.de/perryrh0dan/templates";

match build_meta_url(repository_url) {
Ok(_) => assert!(false),
Err(_) => assert!(true),
match build_meta_url(repository_url) {
Ok(_) => assert!(false),
Err(_) => assert!(true),
}
}
}

#[test]
fn fetch_meta_success() {
let mut options = git::Options::new();
options.enabled = true;
options.provider = Some(git::Provider::GITHUB);
options.auth = Some(git::AuthType::NONE);
options.url = Some(String::from("https://github.com/perryrh0dan/templates"));
#[test]
fn fetch_meta_success() {
let mut options = git::Options::new();
options.enabled = true;
options.provider = Some(git::Provider::GITHUB);
options.auth = Some(git::AuthType::NONE);
options.url = Some(String::from("https://github.com/perryrh0dan/templates"));

let meta = fetch_meta(&options).unwrap();
assert_eq!(meta.name, "default");
let meta = fetch_meta(&options).unwrap();
assert_eq!(meta.name, "default");
}
}
Loading

0 comments on commit 08ab4a3

Please sign in to comment.