create-apollo-monorepo 0.5.4 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +80 -3
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -352,6 +352,11 @@ function writeRootPackageJson(targetDir, dirName) {
352
352
  // `pnpm setup` is pnpm's CLI bootstrap built-in — must use `run` to
353
353
  // forward to the workspace's setup script (apollo-cms's db:push + db:seed).
354
354
  "backend:setup": "pnpm --filter ./apps/backend run setup",
355
+ // Full apollo-cms upgrade pipeline: drizzle push + replay
356
+ // src/upgrades/0.1.*.ts data migrations + seed. Run this after
357
+ // `pnpm backend:update` so any data-migration step from the new
358
+ // apollo-cms version is applied — `backend:setup` alone skips it.
359
+ "backend:upgrade": "pnpm --filter ./apps/backend exec bun run upgrade",
355
360
  },
356
361
  devDependencies: {
357
362
  concurrently: "^9.0.0",
@@ -409,6 +414,58 @@ function writePnpmWorkspace(targetDir) {
409
414
  );
410
415
  }
411
416
 
417
+ // Single-origin nginx reference. Only emitted when adminPrefix is set, since
418
+ // in separate-origins mode the two apps live on their own domains/ports and
419
+ // don't need the prefix-aware location ordering.
420
+ function writeNginxSample(targetDir, adminPrefix) {
421
+ const prefix = adminPrefix || "/admin";
422
+ const conf = `# Apollo CMS — single-origin nginx sample.
423
+ # Mirrors apps/frontend/next.config.ts rewrites (frontend :3001 / backend :3000).
424
+ # No caching headers — Next.js sets its own. Add SSL + HTTP→HTTPS in production.
425
+
426
+ upstream apollo_frontend { server 127.0.0.1:3001; }
427
+ upstream apollo_backend { server 127.0.0.1:3000; }
428
+
429
+ server {
430
+ listen 80;
431
+ server_name _;
432
+
433
+ client_max_body_size 50m;
434
+
435
+ proxy_http_version 1.1;
436
+ proxy_set_header Host $host;
437
+ proxy_set_header X-Real-IP $remote_addr;
438
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
439
+ proxy_set_header X-Forwarded-Proto $scheme;
440
+ proxy_set_header X-Forwarded-Host $host;
441
+
442
+ # Backend — admin UI + chunks (APOLLO_ASSET_PREFIX=${prefix}), media, Sentry tunnel
443
+ location = ${prefix} { proxy_pass http://apollo_backend; }
444
+ location ^~ ${prefix}/ { proxy_pass http://apollo_backend; }
445
+ location ^~ /uploads/ { proxy_pass http://apollo_backend; }
446
+ location = /monitoring { proxy_pass http://apollo_backend; }
447
+
448
+ # Backend SSE — long-lived, no buffering
449
+ location ^~ /api/editing-presence/ {
450
+ proxy_pass http://apollo_backend;
451
+ proxy_buffering off;
452
+ proxy_read_timeout 24h;
453
+ }
454
+
455
+ # Backend APIs (mirror the list in apps/frontend/next.config.ts).
456
+ # \`editing-presence\` is included so the bare path also routes to backend;
457
+ # streaming sub-paths still match the \`^~\` block above first.
458
+ location ~ ^/api/(auth|v1|cron|email|health|mcp|admin|editing-presence)(/|$) {
459
+ proxy_pass http://apollo_backend;
460
+ }
461
+
462
+ # Frontend — everything else
463
+ location / { proxy_pass http://apollo_frontend; }
464
+ }
465
+ `;
466
+ writeFileSync(resolve(targetDir, "nginx.conf.sample"), conf);
467
+ }
468
+
412
469
  function writeRootGitignore(targetDir) {
413
470
  const ignore = [
414
471
  "node_modules",
@@ -857,6 +914,13 @@ paths to the backend so /_next/* doesn't collide:
857
914
  The frontend MUST NOT define routes at \`/admin\`, \`/api/auth\`, \`/api/v1\`, etc.
858
915
  If you need your own API, namespace it under \`/api/internal/*\` or similar.
859
916
 
917
+ ### Reverse proxy (nginx)
918
+
919
+ A reference \`nginx.conf.sample\` ships at the repo root with the same routing
920
+ baked in (frontend on :3001, backend on :3000). Use it when fronting both apps
921
+ behind a single TLS-terminating proxy outside Vercel — drop in your domain and
922
+ SSL certs.
923
+
860
924
  To **disable** single-origin and run the backend on its own subdomain,
861
925
  delete \`APOLLO_ASSET_PREFIX\` from \`apps/backend/.env.local\` and remove the
862
926
  \`rewrites()\` block from \`apps/frontend/next.config.ts\`.
@@ -944,12 +1008,20 @@ folder + \`plugin.json#name\`.
944
1008
 
945
1009
  ## Updating the backend
946
1010
 
947
- Apollo CMS is tracked as a git submodule. Pull the latest:
1011
+ Apollo CMS is tracked as a git submodule. Full upgrade flow:
948
1012
 
949
1013
  \`\`\`bash
950
- pnpm backend:update
1014
+ pnpm backend:update # fast-forward apps/backend to the latest apollo-cms commit
1015
+ pnpm install # in case the submodule changed package.json
1016
+ pnpm backend:upgrade # drizzle push + replay version migrations + seed
951
1017
  \`\`\`
952
1018
 
1019
+ | Script | What it does |
1020
+ | --- | --- |
1021
+ | \`pnpm backend:update\` | \`git submodule update --remote --merge apps/backend\` — code only |
1022
+ | \`pnpm backend:setup\` | First-time bootstrap: \`db:push\` + \`db:seed\` only |
1023
+ | \`pnpm backend:upgrade\` | Full pipeline: \`db:push\` + replay \`src/upgrades/0.1.*.ts\` data migrations + \`db:seed\`. **Use this** after \`backend:update\` — \`backend:setup\` skips the data-migration phase. |
1024
+
953
1025
  Do **not** edit files inside \`apps/backend\`. Open issues / PRs in the
954
1026
  \`apollo-cms\` repository upstream.
955
1027
 
@@ -1072,7 +1144,12 @@ async function main() {
1072
1144
  writeRootGitignore(targetDir);
1073
1145
  writeRootEnv(targetDir, { dbUrl, siteUrl, locale, authSecret, cronSecret, adminPrefix, backendInternalUrl });
1074
1146
  writeReadme(targetDir, dirName, frontendName, adminPrefix);
1075
- success("package.json, pnpm-workspace.yaml, .gitignore, .env.local, README.md");
1147
+ if (adminPrefix) writeNginxSample(targetDir, adminPrefix);
1148
+ success(
1149
+ `package.json, pnpm-workspace.yaml, .gitignore, .env.local, README.md${
1150
+ adminPrefix ? ", nginx.conf.sample" : ""
1151
+ }`,
1152
+ );
1076
1153
 
1077
1154
  // ── Step 4: git init ──
1078
1155
  step(4, "Initializing git");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-apollo-monorepo",
3
- "version": "0.5.4",
3
+ "version": "0.6.1",
4
4
  "description": "Scaffold a monorepo with a frontend app and Apollo CMS as a git submodule backend (single-origin via Next.js rewrites + assetPrefix)",
5
5
  "bin": {
6
6
  "create-apollo-monorepo": "index.mjs"