keyshade-xyz / cli

CLI for keyshade
Mozilla Public License 2.0
5 stars 0 forks source link

Add support for project initialization #3

Closed rajdip-b closed 4 months ago

rajdip-b commented 6 months ago

Description

This is a parent issue. All the other issues linked to it will be having the same properties mentioned. The goal here is to enable users to create a new project in any of their preferred stacks or programming languages. We would enable creating this directly via our CLI. The usage would look something like this:

ks init --name <project_name> --type <project_type>

The options does the following:

Example - Running the following command,

ks init --name my-api --type nestjs

will create a new project named my-api in the current working directory, which is a nestjs project.

Architecture

Initialization

We aim to keep things simple. Here is the approach we take to implement this feature:

Auto generated code

The purpose of this code is to do the following things:

Code structure

We want to use the following class structure:

Here is the example code:

trait InitAction {
    fn initialize(&self) {
        println!("Initializing project...");
        self.initialize_config();
        self.initialize_schema();
        self.initialize_project();
        self.initialize_code();
        println!("Project initialized successfully!");
    }

    fn initialize_config(&self) {
        println!("keyshade.toml generated");
    }

    fn initialize_schema(&self);
    fn initialize_project(&self);
    fn initialize_code(&self);
}

trait JavaInitAction: InitAction {
    fn initialize_schema(&self) {
        println!("Java schema generated");
    }
}

trait NodeJSInitAction: InitAction {
    fn initialize_schema(&self) {
        println!("NodeJS schema generated");
    }
}

struct NestJSInitAction;

impl NodeJSInitAction for NestJSInitAction {
    fn initialize_project(&self) {
        println!("NestJS project created");
    }

    fn initialize_code(&self) {
        println!("NestJS boilerplate code added");
    }
}

struct MavenInitAction;

impl JavaInitAction for MavenInitAction {
    fn initialize_project(&self) {
        println!("Maven project created");
    }

    fn initialize_code(&self) {
        println!("Maven boilerplate code added");
    }
}

fn main() {
    let action: &dyn InitAction = &MavenInitAction;
    action.initialize();
}

Supported frameworks and languages

This section contains the issues related to maintaining and expanding the functionality of this feature.

Sambit003 commented 4 months ago

No need of this feature. Directly populating to the process.env.