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
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