(&self, install_config: InstallConfig)
| 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 | // TODO: Fix these appends/prepends by prepending the filepath with project_dir |
| 40 | // currently, this works because we assume the current working directory is the project's root |
| 41 | fs::prepend( |
| 42 | "frontend/src/App.tsx", |
| 43 | r"import { useAuth, useAuthCheck } from './hooks/useAuth' |
| 44 | import { AccountPage } from './containers/AccountPage' |
| 45 | import { LoginPage } from './containers/LoginPage' |
| 46 | import { ActivationPage } from './containers/ActivationPage' |
| 47 | import { RegistrationPage } from './containers/RegistrationPage' |
| 48 | import { RecoveryPage } from './containers/RecoveryPage' |
| 49 | import { ResetPage } from './containers/ResetPage'", |
| 50 | )?; |
| 51 | fs::prepend( |
| 52 | "frontend/bundles/index.tsx", |
| 53 | "import { AuthProvider } from '../src/hooks/useAuth'", |
| 54 | )?; |
| 55 | fs::replace( |
| 56 | "frontend/src/App.tsx", |
| 57 | "const App = () => {", |
| 58 | r"const App = () => { |
| 59 | useAuthCheck() |
| 60 | const auth = useAuth() |
| 61 | ", |
| 62 | )?; |
| 63 | fs::replace( |
| 64 | "frontend/src/App.tsx", |
| 65 | r"{/* CRA: routes */}", |
| 66 | r#"{/* CRA: routes */} |
| 67 | <Route path="/login" element={<LoginPage />} /> |
| 68 | <Route path="/recovery" element={<RecoveryPage />} /> |
| 69 | <Route path="/reset" element={<ResetPage />} /> |
| 70 | <Route path="/activate" element={<ActivationPage />} /> |
| 71 | <Route path="/register" element={<RegistrationPage />} /> |
| 72 | <Route path="/account" element={<AccountPage />} /> |
| 73 | "#, |
| 74 | )?; |
| 75 | fs::replace( |
| 76 | "frontend/src/App.tsx", |
| 77 | "{/* CRA: left-aligned nav buttons */}", |
| 78 | r#"{/* CRA: left-aligned nav buttons */} |
| 79 | <a className="NavButton" onClick={() => navigate('/account')}>Account</a>"#, |
nothing calls this directly
no test coverage detected