MCPcopy Create free account
hub / github.com/Wulf/create-rust-app / install

Method install

crates/create-rust-app_cli/src/plugins/container.rs:19–55  ·  view source on GitHub ↗
(&self, install_config: InstallConfig)

Source from the content-addressed store, hash-verified

17 }
18
19 fn install(&self, install_config: InstallConfig) -> Result<()> {
20 for filename in Asset::iter() {
21 let file_contents = Asset::get(filename.as_ref()).unwrap();
22 let mut file_path = std::path::PathBuf::from(&install_config.project_dir);
23 file_path.push(filename.as_ref());
24 let mut directory_path = std::path::PathBuf::from(&file_path);
25 directory_path.pop();
26
27 add_file_msg(filename.as_ref());
28 std::fs::create_dir_all(directory_path)?;
29 std::fs::write(file_path, file_contents.data)?;
30 }
31
32 fs::replace(
33 "Dockerfile",
34 "$APP_BINARY_NAME",
35 install_config.project_name.as_str(),
36 )?;
37
38 // TODO: Fix these appends/prepends by prepending the filepath with project_dir
39 // currently, this works because we assume the current working directory is the project's root
40 fs::append(
41 "README.md",
42 r"
43# Containerize your application
44
45## Building a container
46`docker build -t image-name .`
47
48## Running the container
49`docker run -e SECRET_KEY=123 -e DATABASE_URL=postgres://postgres:postgres@localhost/database -p 3000:3000 image-name`
50
51",
52 )?;
53
54 Ok(())
55 }
56}

Callers

nothing calls this directly

Calls 3

add_file_msgFunction · 0.85
replaceFunction · 0.85
appendFunction · 0.85

Tested by

no test coverage detected