create-apollo-suite-monorepo 1.0.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.
- package/README.md +161 -0
- package/index.mjs +2021 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# create-apollo-suite-monorepo
|
|
2
|
+
|
|
3
|
+
Scaffold a pnpm monorepo where your custom frontend lives alongside Apollo CMS
|
|
4
|
+
mounted as a **git submodule** backend (read-only — pull updates only).
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npx create-apollo-suite-monorepo my-site
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
With flags:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx create-apollo-suite-monorepo my-site \
|
|
16
|
+
--frontend-name "@my-site/frontend" \
|
|
17
|
+
--db "postgresql://user:pass@localhost:5432/my-site" \
|
|
18
|
+
--url "http://localhost:3000" \
|
|
19
|
+
--locale th
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Result
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
my-site/
|
|
26
|
+
├── apps/
|
|
27
|
+
│ ├── frontend/ ← @my-site/frontend (Next.js skeleton)
|
|
28
|
+
│ └── backend/ ← git submodule → apollo-cms
|
|
29
|
+
├── package.json ← root workspace
|
|
30
|
+
├── pnpm-workspace.yaml
|
|
31
|
+
├── .env.local ← shared dev env
|
|
32
|
+
├── .gitmodules ← submodule config
|
|
33
|
+
└── .gitignore
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Routing modes
|
|
37
|
+
|
|
38
|
+
### Single-origin (default)
|
|
39
|
+
|
|
40
|
+
Both apps share one public origin (the frontend). The frontend's
|
|
41
|
+
`next.config.ts` rewrites these paths to the backend so `/_next/*` doesn't
|
|
42
|
+
collide:
|
|
43
|
+
|
|
44
|
+
| Browser path | Goes to |
|
|
45
|
+
| ------------------------------------ | -------------------- |
|
|
46
|
+
| `/`, your custom routes | `apps/frontend` |
|
|
47
|
+
| `/admin/*` | `apps/backend` (admin pages **and** their JS chunks) |
|
|
48
|
+
| `/api/auth/*`, `/api/v1/*`, `/api/admin/*`, `/api/email/*`, `/api/health`, `/api/mcp`, `/api/editing-presence/*` | `apps/backend` |
|
|
49
|
+
| `/uploads/*` | `apps/backend` (media) |
|
|
50
|
+
|
|
51
|
+
Apollo CMS reads `APOLLO_ASSET_PREFIX` (default `/admin`) and serves its built
|
|
52
|
+
JS under `<prefix>/_next/static/`. Because the prefix coincides with the admin
|
|
53
|
+
path, a single `/admin/:path*` rewrite covers both pages and chunks — no
|
|
54
|
+
separate asset rewrite is emitted. The frontend **must not** define routes at
|
|
55
|
+
`/admin`, `/api/auth`, `/api/v1`, etc.
|
|
56
|
+
|
|
57
|
+
You can override the prefix:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npx create-apollo-suite-monorepo my-app --admin-prefix /cms
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
When the prefix is anything other than `/admin`, the scaffold also emits a
|
|
64
|
+
matching `<prefix>/:path*` rewrite for backend chunks.
|
|
65
|
+
|
|
66
|
+
### Separate origins (fallback)
|
|
67
|
+
|
|
68
|
+
Pass `--admin-prefix none` (or `off`/`false`/`disabled`) to skip the rewrite
|
|
69
|
+
wiring. The backend runs at `http://localhost:3000` and the frontend at
|
|
70
|
+
`http://localhost:3001`. Useful when you'd rather deploy them on separate
|
|
71
|
+
subdomains (e.g. `cms.example.com` + `example.com`).
|
|
72
|
+
|
|
73
|
+
## Flags
|
|
74
|
+
|
|
75
|
+
| Flag | Default | Description |
|
|
76
|
+
| -------------------------- | --------------------------------------- | ------------------------------------ |
|
|
77
|
+
| `--frontend-name <name>` | `@<dir>/frontend` | Frontend `package.json` name |
|
|
78
|
+
| `--backend-url <url>` | `https://github.com/5Lab-Group-Co-Ltd/apollo-cms.git` | Submodule git URL |
|
|
79
|
+
| `--backend-branch <name>` | `main` | Submodule branch to track |
|
|
80
|
+
| `-d, --db <url>` | _(prompted)_ | `DATABASE_URL` for backend |
|
|
81
|
+
| `-u, --url <url>` | `:3001` single-origin / `:3000` separate | `NEXT_PUBLIC_SITE_URL` |
|
|
82
|
+
| `-l, --locale <code>` | `en` | `NEXT_PUBLIC_DEFAULT_LOCALE` |
|
|
83
|
+
| `--admin-prefix <path>` | `/admin` | Single-origin admin/asset namespace; `none` to disable. Alias: `--asset-prefix` |
|
|
84
|
+
| `--skip-install` | off | Don't run `pnpm install` |
|
|
85
|
+
| `--skip-submodule` | off | Don't add the git submodule |
|
|
86
|
+
| `-h, --help` | — | Show help |
|
|
87
|
+
|
|
88
|
+
## After install
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
cd my-site
|
|
92
|
+
pnpm backend:setup # push schema + seed apollo-cms
|
|
93
|
+
pnpm dev # frontend :3001 + backend :3000 in parallel
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
In single-origin mode open `http://localhost:3001/admin` (the frontend port);
|
|
97
|
+
the rewrite proxies to the backend and Better Auth's cookies/origins line up
|
|
98
|
+
because `NEXT_PUBLIC_SITE_URL` and the backend's `trustedProxyHeaders` are wired
|
|
99
|
+
to the public origin.
|
|
100
|
+
|
|
101
|
+
## Updating the backend
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
pnpm backend:update # git submodule update --remote --merge apps/backend
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Don't edit files inside `apps/backend` — open issues / PRs against the
|
|
108
|
+
`apollo-cms` repository upstream.
|
|
109
|
+
|
|
110
|
+
### Scaffolds created before v0.9.991
|
|
111
|
+
|
|
112
|
+
Two entries were missing from older scaffolds, and `pnpm dev` fails during
|
|
113
|
+
`plugins:build` without them:
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
error: Could not resolve: "ioredis"
|
|
117
|
+
error: Could not resolve: "@opentelemetry/api"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`apps/backend/plugins/*` has to be listed in the root `pnpm-workspace.yaml`
|
|
121
|
+
(apollo-cms's own workspace file is ignored once the submodule is a package of
|
|
122
|
+
an outer workspace, so the built-in plugins' dependencies never install), and
|
|
123
|
+
`@opentelemetry/api` has to be a root devDependency (bun's bundler resolves
|
|
124
|
+
`next`'s guarded `require()` of this optional peer, which pnpm — unlike bun —
|
|
125
|
+
does not install). Patch an existing scaffold with:
|
|
126
|
+
|
|
127
|
+
```yaml
|
|
128
|
+
# pnpm-workspace.yaml
|
|
129
|
+
packages:
|
|
130
|
+
- 'apps/*'
|
|
131
|
+
- 'apps/cms-plugins/*'
|
|
132
|
+
- 'apps/backend/plugins/*' # add this
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```jsonc
|
|
136
|
+
// package.json
|
|
137
|
+
"devDependencies": {
|
|
138
|
+
"concurrently": "^9.0.0",
|
|
139
|
+
"@opentelemetry/api": "^1.9.0" // add this
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
then re-run `pnpm install`.
|
|
144
|
+
|
|
145
|
+
## Deploying to production
|
|
146
|
+
|
|
147
|
+
The scaffold pins `packageManager: "pnpm@11.0.0"` so Corepack picks the right
|
|
148
|
+
pnpm. If your CI / deploy host installs pnpm separately, **make sure it's
|
|
149
|
+
pnpm 11+** — pnpm 11 sets `strictDepBuilds: true` by default and reads the
|
|
150
|
+
allow-list from `allowBuilds` in `pnpm-workspace.yaml`. pnpm 10 silently
|
|
151
|
+
ignores `allowBuilds`; pnpm 11 silently ignores the deprecated
|
|
152
|
+
`onlyBuiltDependencies`. Mixing the two leads to `sharp` (and `esbuild`,
|
|
153
|
+
`@swc/core`, …) skipping their postinstalls, which surfaces at runtime as:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
Failed to load external module sharp-<hash>:
|
|
157
|
+
Error: Cannot find module 'sharp-<hash>'
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The scaffold's `pnpm-workspace.yaml` already lists the binaries Apollo CMS
|
|
161
|
+
needs in `allowBuilds`. If you add a new native dep, append it there.
|