create-apollo-monorepo 0.6.1 → 0.7.0
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/index.mjs +41 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -246,6 +246,20 @@ function preflight(flags) {
|
|
|
246
246
|
success("pnpm found");
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
// bun is required at runtime by apps/backend (apollo-cms): db:push, db:seed,
|
|
250
|
+
// dev:cron, plugins:build, the upgrade pipeline, and pre-commit hooks all
|
|
251
|
+
// shell out to `bun`. The scaffold itself works without bun, but `pnpm dev`,
|
|
252
|
+
// `pnpm backend:setup`, and `pnpm backend:upgrade` will fail without it.
|
|
253
|
+
if (!commandExists("bun")) {
|
|
254
|
+
warn(
|
|
255
|
+
"bun not found — required by apps/backend for db:push, db:seed, dev:cron,\n" +
|
|
256
|
+
" plugins:build, and the upgrade pipeline.\n" +
|
|
257
|
+
" Install: curl -fsSL https://bun.sh/install | bash (or: brew install bun)",
|
|
258
|
+
);
|
|
259
|
+
} else {
|
|
260
|
+
success("bun found");
|
|
261
|
+
}
|
|
262
|
+
|
|
249
263
|
const targetDir = resolve(flags.directory);
|
|
250
264
|
if (existsSync(targetDir)) {
|
|
251
265
|
fatal(`Directory already exists: ${targetDir}\n Choose a different name or remove it first.`);
|
|
@@ -334,8 +348,13 @@ function writeRootPackageJson(targetDir, dirName) {
|
|
|
334
348
|
// (production uses Vercel Cron via apps/backend/vercel.json).
|
|
335
349
|
"predev:setup":
|
|
336
350
|
"pnpm cms-plugins:build && pnpm --filter ./apps/backend exec bun run plugins:build",
|
|
351
|
+
// `pnpm dev` runs FE + BE Next.js dev servers (which watch their own
|
|
352
|
+
// src/) plus a parallel cms-plugins watcher, so editing
|
|
353
|
+
// apps/cms-plugins/<slug>/index.ts triggers an esbuild incremental
|
|
354
|
+
// rebuild and the backend's plugin loader picks up the fresh
|
|
355
|
+
// dist/server.mjs on next request.
|
|
337
356
|
dev:
|
|
338
|
-
"pnpm predev:setup && concurrently -k -n FE,BE -c blue,magenta \"pnpm --filter ./apps/frontend dev\" \"pnpm --filter ./apps/backend exec next dev\"",
|
|
357
|
+
"pnpm predev:setup && concurrently -k -n FE,BE,PL -c blue,magenta,yellow \"pnpm --filter ./apps/frontend dev\" \"pnpm --filter ./apps/backend exec next dev\" \"pnpm cms-plugins:dev\"",
|
|
339
358
|
"dev:frontend": "pnpm --filter ./apps/frontend dev",
|
|
340
359
|
"dev:backend":
|
|
341
360
|
"pnpm predev:setup && pnpm --filter ./apps/backend exec next dev",
|
|
@@ -345,6 +364,8 @@ function writeRootPackageJson(targetDir, dirName) {
|
|
|
345
364
|
"pnpm cms-plugins:build && pnpm --filter ./apps/backend exec bun run plugins:build && pnpm --filter ./apps/backend build && pnpm --filter ./apps/frontend build",
|
|
346
365
|
"cms-plugins:build":
|
|
347
366
|
"pnpm --filter './apps/cms-plugins/*' --parallel --if-present build",
|
|
367
|
+
"cms-plugins:dev":
|
|
368
|
+
"pnpm --filter './apps/cms-plugins/*' --parallel --if-present dev",
|
|
348
369
|
"cms-plugin:new": "node scripts/new-cms-plugin.mjs",
|
|
349
370
|
lint: "pnpm -r lint",
|
|
350
371
|
typecheck: "pnpm -r typecheck",
|
|
@@ -727,6 +748,11 @@ function writeExampleCmsPlugin(targetDir, dirName) {
|
|
|
727
748
|
},
|
|
728
749
|
scripts: {
|
|
729
750
|
build: "node ./build.mjs",
|
|
751
|
+
// `dev` is the watcher entry — `pnpm dev` from the monorepo root fans
|
|
752
|
+
// out to it via `cms-plugins:dev`, so editing index.ts triggers an
|
|
753
|
+
// incremental rebuild and the backend's plugin loader picks up the new
|
|
754
|
+
// dist/server.mjs on the next request.
|
|
755
|
+
dev: "node ./build.mjs --watch",
|
|
730
756
|
},
|
|
731
757
|
devDependencies: {
|
|
732
758
|
esbuild: "^0.24.0",
|
|
@@ -735,9 +761,12 @@ function writeExampleCmsPlugin(targetDir, dirName) {
|
|
|
735
761
|
writeFileSync(resolve(pluginDir, "package.json"), JSON.stringify(pkg, null, 2) + "\n");
|
|
736
762
|
|
|
737
763
|
// Tiny zero-config build: bundle index.ts → dist/server.mjs as ESM Node.
|
|
738
|
-
|
|
764
|
+
// Pass --watch to keep esbuild's context alive and rebuild on file changes.
|
|
765
|
+
const buildMjs = `import { context, build } from "esbuild";
|
|
739
766
|
|
|
740
|
-
|
|
767
|
+
const watch = process.argv.includes("--watch");
|
|
768
|
+
|
|
769
|
+
const options = {
|
|
741
770
|
entryPoints: ["./index.ts"],
|
|
742
771
|
outfile: "./dist/server.mjs",
|
|
743
772
|
format: "esm",
|
|
@@ -748,7 +777,15 @@ await build({
|
|
|
748
777
|
// backend at runtime via the loader's dynamic import().
|
|
749
778
|
external: ["@/*", "next", "react", "react-dom"],
|
|
750
779
|
logLevel: "info",
|
|
751
|
-
}
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
if (watch) {
|
|
783
|
+
const ctx = await context(options);
|
|
784
|
+
await ctx.watch();
|
|
785
|
+
console.log("[cms-plugin] watching index.ts → dist/server.mjs");
|
|
786
|
+
} else {
|
|
787
|
+
await build(options);
|
|
788
|
+
}
|
|
752
789
|
`;
|
|
753
790
|
writeFileSync(resolve(pluginDir, "build.mjs"), buildMjs);
|
|
754
791
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-apollo-monorepo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
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"
|