Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

11 changes: 11 additions & 0 deletions .idea/resolver.iml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ resolver-cli get dfd project_name


The `scaffold` action is used to scaffold projects for different development tools and languages which includes:
- ReactJS
- ReactTs
- React
- Hardhat
- NestJs
- Laravel
Expand All @@ -65,13 +64,13 @@ The `scaffold` action is used to scaffold projects for different development too
#### ReactJS
Creates a React project with JavaScript
```sh
resolver-cli scaffold reactjs project_name
resolver-cli scaffold react <project_name> --lan=j
```

#### ReactTS
Creates a React project with TypeScript
```sh
resolver-cli scaffold reactts project_name
resolver-cli scaffold react <project_name> --lan=t
```

#### Hardhat
Expand Down
68 changes: 68 additions & 0 deletions install_resolver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
set -e
echo -e "installing the resolver cli via curl"

RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
WHITE="\033[0m"

# getting the operating system of the machine
OS=$(uname -s)
echo -e "${RED} RED first ,${GREEN} Green next, ${YELLOW} Yellow after"

check_for_pkg_config_openssl() {
echo -e "checking if openssl and pkg_config are available"
if ! pkg-config --exists openssl; then
echo -e "could not find openssl and pkg_config"
#check for the os
echo -e "checking the machine OS and the installing the packages"
if [ "$OS" = "Darwin" ]; then
if ! command -v brew >/dev/null ; then
echo -e "homebrew is not installed, installing homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
echo -e "installing openssl and pkg_config"
brew install openssl
brew install pkg-config

elif [ "$OS" = "Linux" ]; then
echo -e "updating linux packages"
sudo apt-get update -y || true
echo -e "installing openssl and pkg-config"
sudo apt-get install -y libssl-dev pkg-config

else
echo -e "Unsupported OS: ${OS} detected"
exit 1
fi
else
echo -e "${GREEN} openssl and pkg-config are already installed"
fi
}

echo -e "checking if curl already exists"
if ! command -v curl >/dev/null; then
echo -e "${RED} curl is missing"
exit 1
fi

check_for_pkg_config_openssl

echo -e "checking if rust is installed "
if ! (command -v rustc >/dev/null && cargo >/dev/null); then
#install rust here if not installed
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y
source "$HOME/.cargo/env"
else
echo -e "${GREEN} rust is already installed with ${YELLOW}$(rustc --version), ${YELLOW}$(cargo --version)"
fi


if ! command -v resolver-cli >/dev/null; then
# install resolver here
cargo install resolver-cli
echo -e "${GREEN}resolver-cli has been installed successfully"
else
echo -e "${WHITE} resolver version ${YELLOW}$(resolver-cli --version) is already installed"
fi
45 changes: 26 additions & 19 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use std::error::Error;
use colored::*;

pub mod utils;
use utils::helpers::*;
use utils::constants::*;
pub use utils::command_arguments::*;
pub use utils::{command_arguments::*,
constants::*,
helpers::{scaffold::*, installer::*
}};


pub fn resolve(args: ClapperArgs) -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -61,21 +62,27 @@ pub fn resolve(args: ClapperArgs) -> Result<(), Box<dyn Error>> {
},
EntityType::Scaffold(scaffold_command) => {
match scaffold_command.command {
ScaffoldSubCommand::Reactjs(dir) => {
match create_react_app(dir.dir_name.clone()) {
Ok(_) => println!("{}", "Successfully created the React project!".bright_blue()),
Err(e) => {
return Err(e);
}
}
},
ScaffoldSubCommand::Reactts(dir) => {
match create_react_app_with_typescript(dir.dir_name.clone()) {
Ok(_) => println!("{}", "Successfully created the TypeScript React project!".bright_blue()),
Err(e) => {
return Err(e);
}
}
ScaffoldSubCommand::React(user_choice) => {
match user_choice.lan {
ReactVariants::J => {
println!("javascript was chosen as the project language");
match create_react_app(user_choice.dir_name.clone()) {
Ok(_) => println!("{}", "Successfully created the React project!".bright_blue()),
Err(e) => {
return Err(e);
}
}
},
ReactVariants::T => {
println!("typescript was chosen as the project language");
match create_react_app_with_typescript(user_choice.dir_name.clone()) {
Ok(_) => println!("{}", "Successfully created the React project!".bright_blue()),
Err(e) => {
return Err(e);
}
}
},
}
},
ScaffoldSubCommand::Hardhat(dir) => {
match create_hardhat_project(dir.dir_name.clone()) {
Expand Down Expand Up @@ -188,7 +195,7 @@ pub fn resolve(args: ClapperArgs) -> Result<(), Box<dyn Error>> {
return Err(e);
}
}
}
},
}
},
EntityType::Install(install_command) => {
Expand Down
32 changes: 27 additions & 5 deletions src/utils/command_arguments.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clap::{Args, Parser, Subcommand};
use clap::{Args, Parser, Subcommand, ValueEnum};

#[derive(Debug, Parser)]
#[clap(author, version, about)]
Expand Down Expand Up @@ -53,9 +53,9 @@ pub struct ScaffoldCommand {
#[derive(Debug, Subcommand)]
pub enum ScaffoldSubCommand {
/// Scaffolds a create-react-app JavaScript project
Reactjs(GetDir),
/// Scaffolds a create-react-app TypeScript project
Reactts(GetDir),
// Reactjs(GetDir),
// /// Scaffolds a create-react-app TypeScript project
// Reactts(GetDir),
/// Scaffolds a Hardhat project
Hardhat(GetDir),
/// Scaffolds a NestJS project
Expand Down Expand Up @@ -84,6 +84,8 @@ pub enum ScaffoldSubCommand {
AnchorTS(GetDir),
/// Scaffold an Anchor project with Rust Tests
AnchorRust(GetDir),
// scaffold a react project
React(CreateReactSubCommand),
}

// ----------------
Expand Down Expand Up @@ -122,12 +124,32 @@ pub enum InstallSubCommand {
// --------------------------------------
// GetDir: For passing the directory name
// --------------------------------------
#[derive(Debug, Args)]
#[derive(Debug, Args,)]
pub struct GetDir {
/// Specifies the name of the project directory to initialize
pub dir_name: String,
}


// for passing both the directory name and the language of choice
// the args is an inbuilt library from clap used to take input from the terminal
#[derive(Debug, Args,)]
pub struct CreateReactSubCommand {
pub dir_name: String, // Specifies the name of the project directory to initialize

#[clap(long , short)] // this is used purposely for explicit choice when dealing with the argument via terminal hence --lan t or --lan=t
pub lan: ReactVariants, // specifies the language of choice for the project
}

// to choose the language variants
// the valueEnum , just like the Args is a library from clap used to take argument from the terminal
#[derive(Debug, ValueEnum, Clone)]
pub enum ReactVariants {
J, // javascript
T, // typescript
}


#[derive(Debug, Args)]
pub struct Version {
pub version_name: String,
Expand Down
Loading