|
| 1 | +import authService from "./services/auth.service"; |
| 2 | +import setupService from "./services/setup.service"; |
| 3 | +import rl from "readline-sync"; |
| 4 | + |
| 5 | +(async () => { |
| 6 | + console.info("\nWelcome to the Pingvin Share Appwrite setup 👋"); |
| 7 | + console.info( |
| 8 | + "Please follow the questions and be sure that you ENTER THE CORRECT informations. Because the error handling isn't good.\n" |
| 9 | + ); |
| 10 | + try { |
| 11 | + process.env["APPWRITE_HOST"] = rl.question( |
| 12 | + "Appwrite host (http://localhost/v1): ", |
| 13 | + { |
| 14 | + defaultInput: "http://localhost/v1", |
| 15 | + } |
| 16 | + ); |
| 17 | + console.info("Authenticate..."); |
| 18 | + process.env["APPWRITE_USER_TOKEN"] = await authService.getToken(); |
| 19 | + |
| 20 | + console.info("Creating project..."); |
| 21 | + await setupService.createProject(); |
| 22 | + |
| 23 | + console.info("Generating API key for setup..."); |
| 24 | + process.env["APPWRITE_API_KEY"] = await authService.generateApiKey(); |
| 25 | + |
| 26 | + console.info("Generating API key for functions..."); |
| 27 | + process.env["APPWRITE_FUNCTION_API_KEY"] = |
| 28 | + await setupService.generateFunctionsApiKey(); |
| 29 | + |
| 30 | + console.info("Creating collections..."); |
| 31 | + await setupService.createCollections(); |
| 32 | + |
| 33 | + console.info("Creating functions..."); |
| 34 | + await setupService.createFunctions(); |
| 35 | + |
| 36 | + console.info("Creating function deployments..."); |
| 37 | + await setupService.createFunctionDeployments(); |
| 38 | + |
| 39 | + console.info("Adding frontend url..."); |
| 40 | + await setupService.addPlatform( |
| 41 | + rl.question("Frontend host of Pingvin Share (localhost): ", { |
| 42 | + defaultInput: "localhost", |
| 43 | + }) |
| 44 | + ); |
| 45 | + } catch (e) { |
| 46 | + console.error(e); |
| 47 | + console.error("\n\n ❌ Error: " + e.message); |
| 48 | + console.info( |
| 49 | + "\nSorry, an error occured while the setup. The full logs can be found above." |
| 50 | + ); |
| 51 | + return; |
| 52 | + } |
| 53 | + console.info("\n✅ Done"); |
| 54 | +})(); |
| 55 | +export {}; |
0 commit comments