|
| 1 | +from create_api_app.conf.storage import Packages |
| 2 | + |
| 3 | + |
1 | 4 | class PoetryContent:
|
2 | 5 | """A helper class for retrieving content for the Poetry installation."""
|
3 | 6 |
|
@@ -28,3 +31,77 @@ def tailwind_font(self) -> str:
|
28 | 31 | " },",
|
29 | 32 | ]
|
30 | 33 | )
|
| 34 | + |
| 35 | + @classmethod |
| 36 | + def ut_remote_pattern(cls) -> list[str]: |
| 37 | + """Provides the `uploadthing` `remotePattern` found in the `next.config.mjs` file.""" |
| 38 | + return [ |
| 39 | + " {\n", |
| 40 | + ' protocol: "https",\n', |
| 41 | + ' hostname: "utfs.io",\n', |
| 42 | + " pathname: `/a/${process.env.NEXT_PUBLIC_UPLOADTHING_APP_ID}/*`,\n", |
| 43 | + " },\n", |
| 44 | + ] |
| 45 | + |
| 46 | + |
| 47 | +class EnvFileContent: |
| 48 | + """A helper class for creating the `.env.local` file.""" |
| 49 | + |
| 50 | + def __init__(self, packages: Packages) -> None: |
| 51 | + self.packages = packages |
| 52 | + |
| 53 | + def uploadthing(self) -> list[str]: |
| 54 | + """Returns the `Uploadthing` API key content.""" |
| 55 | + return [ |
| 56 | + "# Uploadthing: storing files and handling file uploading", |
| 57 | + "# https://uploadthing.com/", |
| 58 | + "UPLOADTHING_SECRET=", |
| 59 | + "NEXT_PUBLIC_UPLOADTHING_APP_ID=", |
| 60 | + "", |
| 61 | + ] |
| 62 | + |
| 63 | + def clerk(self) -> list[str]: |
| 64 | + """Returns the `Clerk` API key content.""" |
| 65 | + return [ |
| 66 | + "# Clerk: User Authentication", |
| 67 | + "# https://clerk.com/docs/quickstarts/nextjs", |
| 68 | + "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=", |
| 69 | + "CLERK_SECRET_KEY=", |
| 70 | + "", |
| 71 | + "NEXT_PUBLIC_CLERK_SIGN_IN_URL=/auth/sign-in", |
| 72 | + "NEXT_PUBLIC_CLERK_SIGN_UP_URL=/auth/sign-up", |
| 73 | + "NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/", |
| 74 | + "NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/", |
| 75 | + "", |
| 76 | + ] |
| 77 | + |
| 78 | + def stripe(self) -> list[str]: |
| 79 | + """Returns the `Sstripe` API key content.""" |
| 80 | + return [ |
| 81 | + "# Stripe: user payments", |
| 82 | + "# https://stripe.com/docs", |
| 83 | + "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=", |
| 84 | + "STRIPE_SECRET_KEY=", |
| 85 | + "STRIPE_WEBHOOK_SECRET=", |
| 86 | + "NEXT_PUBLIC_STRIPE_CLIENT_ID=", |
| 87 | + "NEXT_PUBLIC_PLATFORM_SUBSCRIPTION_PERCENT=1", |
| 88 | + "NEXT_PUBLIC_PLATFORM_ONETIME_FEE=2", |
| 89 | + "NEXT_PUBLIC_PLATFORM_PERCENT=1", |
| 90 | + "NEXT_PRODUCT_ID=", |
| 91 | + "", |
| 92 | + ] |
| 93 | + |
| 94 | + def make(self) -> str: |
| 95 | + """Creates the `env` file content.""" |
| 96 | + map = { |
| 97 | + "clerk": self.clerk(), |
| 98 | + "uploadthing": self.uploadthing(), |
| 99 | + "stripe": self.stripe(), |
| 100 | + } |
| 101 | + |
| 102 | + content = [] |
| 103 | + for package in self.packages.items: |
| 104 | + if not package.exclude: |
| 105 | + content.extend(map[package.name]) |
| 106 | + |
| 107 | + return "\n".join(content) |
0 commit comments