-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: break down the cli application function to specific file #74
refactor: break down the cli application function to specific file #74
Conversation
Hi @GabrielePicco, for part 3
I came up of the following solution. Solution
In the above text file, we need observe the way the variable name are defined.
/// Create a component which holds position data.
fn create_component_template_simple(name: &str, program_path: &Path) -> Files {
// Define the path to the template file in the "templates" folder
let template_path = Path::new("templates").join("component_template.txt");
// Read the template content from the text file
let mut template =
fs::read_to_string(&template_path).expect("Failed to read component template file");
let program_id = anchor_cli::rust_template::get_or_create_program_id(name).to_string();
// Replace placeholders with actual values
template = template.replace("{{PROGRAM_ID}}", &program_id);
template = template.replace("{{STRUCT_NAME}}", &name.to_upper_camel_case());
// Return the modified string as part of the function
vec![(program_path.join("src").join("lib.rs"), template)]
} |
Thanks @iamnamananand996 for the contribution. Separating and simplifying the |
Hi @GabrielePicco, Thanks for the suggestion above, really appreciate it. I dig down into the BTW, above PR is ready now for review. |
@iamnamananand996 the deployment keys should be injected from secret ENV variables by the workflow: https://github.com/magicblock-labs/bolt/blob/main/.github/workflows/run-tests.yml#L142 |
Hi @GabrielePicco, you are correct, deployment keys should be injected from secret ENV variables by the workflow. Problem is by default GitHub does not allow it for Fork repository to read the |
Thanks @iamnamananand996. #76 is now merged, rebasing the branch on |
96c421c
to
afe4215
Compare
Hi @GabrielePicco, this PR is hanging here from a long time. can we merge this, if it looks good to you. |
Problem
Right now, if we observe the
cli-application
it is centralized into 2 big files, which in a long term will become very hard to mange, better to break down these file to specific task files.Solution
lib.rs
filerust_template.rs
rather than hardcoding the template text into code directly, add it into a text file and read it.