|
11 | 11 | python3 scripts/dev-mobile-setup.py --restore # undo all changes |
12 | 12 |
|
13 | 13 | Files modified: |
14 | | - app/proxy/envoy.yaml - adds IP to CORS allow list |
15 | | - app/backend.dev.env - sets COOKIE_DOMAIN and media server URLs |
16 | | - app/web/.env.localdev - sets API and media URLs |
17 | | - app/mobile/.env - switches from staging to local dev mode |
| 14 | + app/proxy/envoy.yaml - adds IP to CORS allow list |
| 15 | + app/backend.dev.env - sets COOKIE_DOMAIN and media server URLs |
| 16 | + app/media.dev.env - sets media server base URL (for image uploads) |
| 17 | + app/web/.env.localdev - sets API and media URLs |
| 18 | + app/web/.env.development - sets API and media URLs |
| 19 | + app/mobile/.env - switches from staging to local dev mode |
18 | 20 |
|
19 | 21 | Note: do NOT commit the envoy.yaml change. |
20 | 22 | """ |
|
29 | 31 |
|
30 | 32 | ENVOY_YAML = APP / "proxy" / "envoy.yaml" |
31 | 33 | BACKEND_ENV = APP / "backend.dev.env" |
| 34 | +MEDIA_ENV = APP / "media.dev.env" |
32 | 35 | WEB_ENV = APP / "web" / ".env.localdev" |
| 36 | +WEB_DEV_ENV = APP / "web" / ".env.development" |
33 | 37 | MOBILE_ENV = APP / "mobile" / ".env" |
34 | 38 |
|
35 | 39 | MOBILE_ENV_DEFAULT = """\ |
@@ -80,13 +84,26 @@ def setup(ip: str) -> None: |
80 | 84 | BACKEND_ENV.write_text(content) |
81 | 85 | print(" backend.dev.env updated COOKIE_DOMAIN and media server URLs") |
82 | 86 |
|
| 87 | + # media.dev.env — media server base URL (needed for upload response URLs) |
| 88 | + content = MEDIA_ENV.read_text() |
| 89 | + content = re.sub(r"^MEDIA_SERVER_BASE_URL=.*", f"MEDIA_SERVER_BASE_URL=http://{ip}:5001", content, flags=re.MULTILINE) |
| 90 | + MEDIA_ENV.write_text(content) |
| 91 | + print(" media.dev.env updated MEDIA_SERVER_BASE_URL") |
| 92 | + |
83 | 93 | # web/.env.localdev — API + media URLs |
84 | 94 | content = WEB_ENV.read_text() |
85 | 95 | content = re.sub(r'^NEXT_PUBLIC_API_BASE_URL=.*', f'NEXT_PUBLIC_API_BASE_URL="http://{ip}:8888"', content, flags=re.MULTILINE) |
86 | 96 | content = re.sub(r'^NEXT_PUBLIC_MEDIA_BASE_URL=.*', f'NEXT_PUBLIC_MEDIA_BASE_URL="http://{ip}:5001"', content, flags=re.MULTILINE) |
87 | 97 | WEB_ENV.write_text(content) |
88 | 98 | print(" web/.env.localdev updated API and media URLs") |
89 | 99 |
|
| 100 | + # web/.env.development — API + media URLs |
| 101 | + content = WEB_DEV_ENV.read_text() |
| 102 | + content = re.sub(r'^NEXT_PUBLIC_API_BASE_URL=.*', f'NEXT_PUBLIC_API_BASE_URL="http://{ip}:8888"', content, flags=re.MULTILINE) |
| 103 | + content = re.sub(r'^NEXT_PUBLIC_MEDIA_BASE_URL=.*', f'NEXT_PUBLIC_MEDIA_BASE_URL="http://{ip}:5001"', content, flags=re.MULTILINE) |
| 104 | + WEB_DEV_ENV.write_text(content) |
| 105 | + print(" web/.env.development updated API and media URLs") |
| 106 | + |
90 | 107 | # mobile/.env — comment out STAGE block, activate LOCAL block with real IP |
91 | 108 | MOBILE_ENV.write_text( |
92 | 109 | f"# STAGE:\n" |
@@ -130,13 +147,26 @@ def restore() -> None: |
130 | 147 | BACKEND_ENV.write_text(content) |
131 | 148 | print(" backend.dev.env restored to localhost") |
132 | 149 |
|
| 150 | + # media.dev.env — back to localhost |
| 151 | + content = MEDIA_ENV.read_text() |
| 152 | + content = re.sub(r"^MEDIA_SERVER_BASE_URL=.*", "MEDIA_SERVER_BASE_URL=http://localhost:5001", content, flags=re.MULTILINE) |
| 153 | + MEDIA_ENV.write_text(content) |
| 154 | + print(" media.dev.env restored to localhost") |
| 155 | + |
133 | 156 | # web/.env.localdev — back to localhost |
134 | 157 | content = WEB_ENV.read_text() |
135 | 158 | content = re.sub(r'^NEXT_PUBLIC_API_BASE_URL=.*', 'NEXT_PUBLIC_API_BASE_URL="http://localhost:8888"', content, flags=re.MULTILINE) |
136 | 159 | content = re.sub(r'^NEXT_PUBLIC_MEDIA_BASE_URL=.*', 'NEXT_PUBLIC_MEDIA_BASE_URL="http://localhost:5001"', content, flags=re.MULTILINE) |
137 | 160 | WEB_ENV.write_text(content) |
138 | 161 | print(" web/.env.localdev restored to localhost") |
139 | 162 |
|
| 163 | + # web/.env.development — back to staging |
| 164 | + content = WEB_DEV_ENV.read_text() |
| 165 | + content = re.sub(r'^NEXT_PUBLIC_API_BASE_URL=.*', 'NEXT_PUBLIC_API_BASE_URL="https://next.couchershq.org/api"', content, flags=re.MULTILINE) |
| 166 | + content = re.sub(r'^NEXT_PUBLIC_MEDIA_BASE_URL=.*', 'NEXT_PUBLIC_MEDIA_BASE_URL="https://dev-user-media.couchershq.org"', content, flags=re.MULTILINE) |
| 167 | + WEB_DEV_ENV.write_text(content) |
| 168 | + print(" web/.env.development restored to staging") |
| 169 | + |
140 | 170 | # mobile/.env — back to staging mode |
141 | 171 | MOBILE_ENV.write_text(MOBILE_ENV_DEFAULT) |
142 | 172 | print(" mobile/.env restored to staging mode") |
|
0 commit comments