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

Method install

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

Source from the content-addressed store, hash-verified

20
21 #[allow(clippy::too_many_lines)]
22 fn install(&self, install_config: InstallConfig) -> Result<()> {
23 for filename in Asset::iter() {
24 let file_contents = Asset::get(filename.as_ref()).unwrap();
25 let mut file_path = std::path::PathBuf::from(&install_config.project_dir);
26 file_path.push(filename.as_ref());
27 let mut directory_path = std::path::PathBuf::from(&file_path);
28 directory_path.pop();
29
30 add_file_msg(filename.as_ref());
31 std::fs::create_dir_all(directory_path)?;
32 std::fs::write(file_path, file_contents.data)?;
33 }
34
35 // ===============================
36 // PATCH FRONTEND
37 // ===============================
38
39 fs::append(
40 ".env.example",
41 r"
42S3_HOST=http://localhost:9000
43S3_REGION=minio
44S3_BUCKET=bucket
45S3_ACCESS_KEY_ID=access_key
46S3_SECRET_ACCESS_KEY=secret_key
47",
48 )?;
49
50 fs::replace(
51 "frontend/src/App.tsx",
52 r"{/* CRA: routes */}",
53 r#"{/* CRA: routes */}
54 <Route path="/files" element={<Files />} />"#,
55 )?;
56
57 fs::replace(
58 "frontend/src/App.tsx",
59 r#"<a className="NavButton" onClick={() => navigate('/todos')}>Todos</a>"#,
60 r#"<a className="NavButton" onClick={() => navigate('/todos')}>Todos</a>
61 <a className="NavButton" onClick={() => navigate('/files')}>Files</a>"#,
62 )?;
63
64 fs::replace(
65 "frontend/src/App.tsx",
66 r"import { Todos } from './containers/Todo'",
67 r"import { Todos } from './containers/Todo'
68import { Files } from './containers/Files'",
69 )?;
70
71 crate::content::migration::create(
72 "plugin_storage",
73 match install_config.backend_database {
74 BackendDatabase::Postgres => indoc! {r"
75CREATE TABLE attachment_blobs(
76 id SERIAL PRIMARY KEY,
77
78 key TEXT NOT NULL,
79 file_name TEXT NOT NULL,

Callers

nothing calls this directly

Calls 6

add_file_msgFunction · 0.85
appendFunction · 0.85
replaceFunction · 0.85
register_actixFunction · 0.85
register_poemFunction · 0.85
createFunction · 0.50

Tested by

no test coverage detected