create-apollo-monorepo 0.6.2 → 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 +27 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -348,8 +348,13 @@ function writeRootPackageJson(targetDir, dirName) {
|
|
|
348
348
|
// (production uses Vercel Cron via apps/backend/vercel.json).
|
|
349
349
|
"predev:setup":
|
|
350
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.
|
|
351
356
|
dev:
|
|
352
|
-
"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\"",
|
|
353
358
|
"dev:frontend": "pnpm --filter ./apps/frontend dev",
|
|
354
359
|
"dev:backend":
|
|
355
360
|
"pnpm predev:setup && pnpm --filter ./apps/backend exec next dev",
|
|
@@ -359,6 +364,8 @@ function writeRootPackageJson(targetDir, dirName) {
|
|
|
359
364
|
"pnpm cms-plugins:build && pnpm --filter ./apps/backend exec bun run plugins:build && pnpm --filter ./apps/backend build && pnpm --filter ./apps/frontend build",
|
|
360
365
|
"cms-plugins:build":
|
|
361
366
|
"pnpm --filter './apps/cms-plugins/*' --parallel --if-present build",
|
|
367
|
+
"cms-plugins:dev":
|
|
368
|
+
"pnpm --filter './apps/cms-plugins/*' --parallel --if-present dev",
|
|
362
369
|
"cms-plugin:new": "node scripts/new-cms-plugin.mjs",
|
|
363
370
|
lint: "pnpm -r lint",
|
|
364
371
|
typecheck: "pnpm -r typecheck",
|
|
@@ -741,6 +748,11 @@ function writeExampleCmsPlugin(targetDir, dirName) {
|
|
|
741
748
|
},
|
|
742
749
|
scripts: {
|
|
743
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",
|
|
744
756
|
},
|
|
745
757
|
devDependencies: {
|
|
746
758
|
esbuild: "^0.24.0",
|
|
@@ -749,9 +761,12 @@ function writeExampleCmsPlugin(targetDir, dirName) {
|
|
|
749
761
|
writeFileSync(resolve(pluginDir, "package.json"), JSON.stringify(pkg, null, 2) + "\n");
|
|
750
762
|
|
|
751
763
|
// Tiny zero-config build: bundle index.ts → dist/server.mjs as ESM Node.
|
|
752
|
-
|
|
764
|
+
// Pass --watch to keep esbuild's context alive and rebuild on file changes.
|
|
765
|
+
const buildMjs = `import { context, build } from "esbuild";
|
|
753
766
|
|
|
754
|
-
|
|
767
|
+
const watch = process.argv.includes("--watch");
|
|
768
|
+
|
|
769
|
+
const options = {
|
|
755
770
|
entryPoints: ["./index.ts"],
|
|
756
771
|
outfile: "./dist/server.mjs",
|
|
757
772
|
format: "esm",
|
|
@@ -762,7 +777,15 @@ await build({
|
|
|
762
777
|
// backend at runtime via the loader's dynamic import().
|
|
763
778
|
external: ["@/*", "next", "react", "react-dom"],
|
|
764
779
|
logLevel: "info",
|
|
765
|
-
}
|
|
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
|
+
}
|
|
766
789
|
`;
|
|
767
790
|
writeFileSync(resolve(pluginDir, "build.mjs"), buildMjs);
|
|
768
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"
|