create-avocado-site 0.10.0 → 0.11.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/dist/prompts.js +2 -0
- package/dist/templates/common.js +6 -2
- package/dist/templates/demo-app.js +27 -1
- package/dist/types.d.ts +7 -0
- package/dist/versions.d.ts +1 -1
- package/dist/versions.js +1 -1
- package/package.json +3 -3
package/dist/prompts.js
CHANGED
|
@@ -20,6 +20,7 @@ export async function demoConfig(dirName) {
|
|
|
20
20
|
sitePort,
|
|
21
21
|
editorPort,
|
|
22
22
|
draftSecret: randomBytes(24).toString("hex"),
|
|
23
|
+
publishToken: randomBytes(24).toString("hex"),
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
@@ -115,5 +116,6 @@ async function integratePrompts(cwd) {
|
|
|
115
116
|
// telling the reader to replace it with a long random string, and a value
|
|
116
117
|
// that already looks filled in is a step nobody performs.
|
|
117
118
|
draftSecret: randomBytes(24).toString("hex"),
|
|
119
|
+
publishToken: randomBytes(24).toString("hex"),
|
|
118
120
|
};
|
|
119
121
|
}
|
package/dist/templates/common.js
CHANGED
|
@@ -183,8 +183,12 @@ EDITOR_CORS_ORIGINS=http://localhost:${config.editorPort}
|
|
|
183
183
|
# your edits.
|
|
184
184
|
DRAFT_MODE_SECRET=${config.draftSecret}
|
|
185
185
|
|
|
186
|
-
#
|
|
187
|
-
#
|
|
186
|
+
# Guards POST /api/editor/publish, which overwrites this site's content. Not
|
|
187
|
+
# optional: without it that route is refused outright under NODE_ENV=production,
|
|
188
|
+
# because the alternative — what shipped before — was an unauthenticated write
|
|
189
|
+
# endpoint on every deployed site. Whatever publishes to this app (the
|
|
190
|
+
# orchestrator, CI) must send the same value as \`x-publish-token\`.
|
|
191
|
+
PUBLISH_TOKEN=${config.publishToken}
|
|
188
192
|
`;
|
|
189
193
|
return c.envVars ? `${c.envVars}\n\n${common}` : common;
|
|
190
194
|
}
|
|
@@ -186,6 +186,13 @@ NEXT_PUBLIC_SITE_URL=http://localhost:${config.sitePort}
|
|
|
186
186
|
# quietly renders the published page instead of your edits.
|
|
187
187
|
DRAFT_MODE_SECRET=${config.draftSecret}
|
|
188
188
|
|
|
189
|
+
# Guards POST /api/editor/publish, which rewrites content/pages.json. Generated
|
|
190
|
+
# rather than left blank: that route used to read a variable no scaffold wrote,
|
|
191
|
+
# so its token check never ran and any caller could replace the whole site.
|
|
192
|
+
# Nothing here needs it — the editor publishes through the orchestrator's
|
|
193
|
+
# adapter, not this route — but it ships mounted, so it ships guarded.
|
|
194
|
+
PUBLISH_TOKEN=${config.publishToken}
|
|
195
|
+
|
|
189
196
|
# ---------------------------------------------------------------------------
|
|
190
197
|
# Production only. \`npm run dev\` needs none of this.
|
|
191
198
|
#
|
|
@@ -411,7 +418,14 @@ const handler = createOrchestrator({
|
|
|
411
418
|
// first-run suggestions on the answer; without it they fall back to the
|
|
412
419
|
// generic list written for a site nobody has seen.
|
|
413
420
|
demoContent: true,
|
|
414
|
-
|
|
421
|
+
// \`writeOnPublish\` defaults to false, which made Publish a no-op that still
|
|
422
|
+
// reported success — and the README next to it promised the file was
|
|
423
|
+
// rewritten. A demo whose content lives in a writable file on your own
|
|
424
|
+
// machine is exactly the case the default is wrong for.
|
|
425
|
+
adapter: jsonFileAdapter({
|
|
426
|
+
path: resolve(process.cwd(), "content/pages.json"),
|
|
427
|
+
writeOnPublish: true,
|
|
428
|
+
}),
|
|
415
429
|
previewUrl: "http://localhost:${config.sitePort}",
|
|
416
430
|
})
|
|
417
431
|
|
|
@@ -484,6 +498,18 @@ sessions can reuse them. \`auth: () => true\` runs it open, if that is what you
|
|
|
484
498
|
want — it is one line you type on purpose rather than a default you reach by
|
|
485
499
|
forgetting.
|
|
486
500
|
|
|
501
|
+
That gate covers \`/api/avocado/*\`. \`/api/editor/*\` is a second, separate
|
|
502
|
+
handler, and \`POST /api/editor/publish\` overwrites your content — so it is
|
|
503
|
+
guarded by its own \`PUBLISH_TOKEN\`, generated into \`.env.local\` for you and
|
|
504
|
+
required in production. Carry it into the deployment's environment along with
|
|
505
|
+
the variable above; without it that one route answers 401 and says so.
|
|
506
|
+
|
|
507
|
+
One thing publishing cannot do in production: rewrite \`content/pages.json\`.
|
|
508
|
+
Most hosts (Vercel, and every container built from this image) give you a
|
|
509
|
+
read-only filesystem at runtime, so \`writeOnPublish\` works on your machine and
|
|
510
|
+
fails on theirs. A deployed site publishes into something that persists —
|
|
511
|
+
a CMS adapter, a database, or a commit back to the repo.
|
|
512
|
+
|
|
487
513
|
## What is where
|
|
488
514
|
|
|
489
515
|
| Path | What it is |
|
package/dist/types.d.ts
CHANGED
|
@@ -33,6 +33,13 @@ export type ScaffoldConfig = {
|
|
|
33
33
|
* fixed, so two demos on one machine do not share a draft cookie secret.
|
|
34
34
|
*/
|
|
35
35
|
draftSecret: string;
|
|
36
|
+
/**
|
|
37
|
+
* Value written as `PUBLISH_TOKEN`. Generated, not left blank: the publish
|
|
38
|
+
* route was scaffolded as `publishSecret: process.env.PUBLISH_TOKEN || undefined`
|
|
39
|
+
* against a variable no scaffold ever wrote, so the guard was dead code and
|
|
40
|
+
* `POST /api/editor/publish` took content from anyone who asked.
|
|
41
|
+
*/
|
|
42
|
+
publishToken: string;
|
|
36
43
|
};
|
|
37
44
|
export type GeneratedFile = {
|
|
38
45
|
path: string;
|
package/dist/versions.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* `@avocadostudio-ai/orchestrator-core`, already pinned there; naming it again
|
|
18
18
|
* here is how a project ends up with two.
|
|
19
19
|
*/
|
|
20
|
-
export declare const AVOCADO = "0.
|
|
20
|
+
export declare const AVOCADO = "0.11.0";
|
|
21
21
|
/**
|
|
22
22
|
* Next 15.5.15 rather than 16, because that is the version every example app
|
|
23
23
|
* and the demo site in this repository build and test against. The SDK
|
package/dist/versions.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* `@avocadostudio-ai/orchestrator-core`, already pinned there; naming it again
|
|
18
18
|
* here is how a project ends up with two.
|
|
19
19
|
*/
|
|
20
|
-
export const AVOCADO = "0.
|
|
20
|
+
export const AVOCADO = "0.11.0";
|
|
21
21
|
/**
|
|
22
22
|
* Next 15.5.15 rather than 16, because that is the version every example app
|
|
23
23
|
* and the demo site in this repository build and test against. The SDK
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-avocado-site",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Bootstrap a runnable Avocado Studio demo site, or wire Avocado into an existing Next.js project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@types/node": "^22.13.10",
|
|
35
35
|
"tsx": "^4.19.0",
|
|
36
36
|
"typescript": "^5.7.3",
|
|
37
|
-
"@avocadostudio-ai/shared": "0.
|
|
38
|
-
"@avocadostudio-ai/site-sdk": "0.
|
|
37
|
+
"@avocadostudio-ai/shared": "0.11.0",
|
|
38
|
+
"@avocadostudio-ai/site-sdk": "0.11.0"
|
|
39
39
|
},
|
|
40
40
|
"license": "Apache-2.0",
|
|
41
41
|
"homepage": "https://docs.avocadostudio.dev",
|