(&self, install_config: InstallConfig)
| 20 | |
| 21 | #[allow(clippy::too_many_lines)] |
| 22 | fn install(&self, install_config: InstallConfig) -> Result<()> { |
| 23 | if !install_config.plugin_auth { |
| 24 | crate::logger::error("The GraphQL plugin requires the Auth plugin!"); |
| 25 | std::process::exit(1); |
| 26 | } |
| 27 | |
| 28 | for filename in Asset::iter() { |
| 29 | let file_contents = Asset::get(filename.as_ref()).unwrap(); |
| 30 | let mut file_path = std::path::PathBuf::from(&install_config.project_dir); |
| 31 | file_path.push(filename.as_ref()); |
| 32 | let mut directory_path = std::path::PathBuf::from(&file_path); |
| 33 | directory_path.pop(); |
| 34 | |
| 35 | add_file_msg(filename.as_ref()); |
| 36 | std::fs::create_dir_all(directory_path)?; |
| 37 | std::fs::write(file_path, file_contents.data)?; |
| 38 | } |
| 39 | |
| 40 | add_dependency( |
| 41 | &install_config.project_dir, |
| 42 | "async-graphql", |
| 43 | r#"async-graphql = "3.0.38""#, |
| 44 | )?; |
| 45 | add_dependency( |
| 46 | &install_config.project_dir, |
| 47 | "jsonwebtoken", |
| 48 | r#"jsonwebtoken = "8.1.0""#, |
| 49 | )?; |
| 50 | match install_config.backend_framework { |
| 51 | BackendFramework::ActixWeb => { |
| 52 | add_dependency( |
| 53 | &install_config.project_dir, |
| 54 | "async-graphql-actix-web", |
| 55 | r#"async-graphql-actix-web = "3.0.38""#, |
| 56 | )?; |
| 57 | } |
| 58 | BackendFramework::Poem => { |
| 59 | add_dependency( |
| 60 | &install_config.project_dir, |
| 61 | "async-graphql-poem", |
| 62 | r#"async-graphql-poem = "3.0.38""#, |
| 63 | )?; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | fs::prepend( |
| 68 | "frontend/src/App.tsx", |
| 69 | r"import { useApolloClient } from '@apollo/client' |
| 70 | import { GraphQLPage } from './containers/GraphQLPage'", |
| 71 | )?; |
| 72 | |
| 73 | fs::replace( |
| 74 | "frontend/src/App.tsx", |
| 75 | "/* CRA: app hooks */", |
| 76 | "/* CRA: app hooks */\n const apollo = useApolloClient()", |
| 77 | )?; |
| 78 | |
| 79 | fs::replace( |
nothing calls this directly
no test coverage detected