@cmssy/cli 9.9.0 → 10.0.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/assets/init/next/app/[[...path]]/page.tsx +1 -11
- package/assets/init/remix/app/routes.ts +0 -2
- package/dist/index.js +64 -12
- package/package.json +2 -2
- package/assets/init/astro/src/pages/robots.txt.ts +0 -5
- package/assets/init/astro/src/pages/sitemap.xml.ts +0 -5
- package/assets/init/next/app/robots.ts +0 -4
- package/assets/init/next/app/sitemap.ts +0 -7
- package/assets/init/remix/app/routes/robots.ts +0 -4
- package/assets/init/remix/app/routes/sitemap.ts +0 -4
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createCmssyPage } from "@cmssy/next/server";
|
|
2
2
|
import { cmssy } from "@/cmssy.config";
|
|
3
3
|
import { blocks } from "@/cmssy/blocks";
|
|
4
4
|
import { CmssyEditor } from "@/cmssy/editor";
|
|
5
5
|
|
|
6
|
-
type PageProps = { params: Promise<{ path?: string[] }> };
|
|
7
|
-
|
|
8
|
-
export async function generateMetadata({ params }: PageProps) {
|
|
9
|
-
const { path } = await params;
|
|
10
|
-
// As routed, prefix and all: the prefix IS the language. Strip it and every
|
|
11
|
-
// translated page gets the default language's title - and a canonical
|
|
12
|
-
// pointing at the default language's URL, which reads as "duplicate".
|
|
13
|
-
return buildCmssyMetadata(cmssy, path);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
6
|
export default createCmssyPage(cmssy, blocks, { editor: CmssyEditor });
|
|
@@ -3,8 +3,6 @@ import { type RouteConfig, index, route } from "@react-router/dev/routes";
|
|
|
3
3
|
// The splat does not match "/", so the homepage needs its own entry - it is the
|
|
4
4
|
// same route module, mounted twice.
|
|
5
5
|
export default [
|
|
6
|
-
route("sitemap.xml", "routes/sitemap.ts"),
|
|
7
|
-
route("robots.txt", "routes/robots.ts"),
|
|
8
6
|
index("routes/page.tsx"),
|
|
9
7
|
route("*", "routes/page.tsx", { id: "cmssy-catch-all" }),
|
|
10
8
|
] satisfies RouteConfig;
|
package/dist/index.js
CHANGED
|
@@ -172,9 +172,7 @@ var FRAMEWORKS = [
|
|
|
172
172
|
"blocks/hero/Hero.tsx",
|
|
173
173
|
"app/[[...path]]/page.tsx",
|
|
174
174
|
"app/cmssy-edit/[[...path]]/page.tsx",
|
|
175
|
-
"app/api/draft/route.ts"
|
|
176
|
-
"app/robots.ts",
|
|
177
|
-
"app/sitemap.ts"
|
|
175
|
+
"app/api/draft/route.ts"
|
|
178
176
|
]
|
|
179
177
|
},
|
|
180
178
|
{
|
|
@@ -191,9 +189,7 @@ var FRAMEWORKS = [
|
|
|
191
189
|
"src/cmssy/hero.tsx",
|
|
192
190
|
"src/components/Blocks.tsx",
|
|
193
191
|
"src/pages/[...path].astro",
|
|
194
|
-
"src/pages/cmssy-edit/[...path].astro"
|
|
195
|
-
"src/pages/robots.txt.ts",
|
|
196
|
-
"src/pages/sitemap.xml.ts"
|
|
192
|
+
"src/pages/cmssy-edit/[...path].astro"
|
|
197
193
|
]
|
|
198
194
|
},
|
|
199
195
|
{
|
|
@@ -208,9 +204,7 @@ var FRAMEWORKS = [
|
|
|
208
204
|
"app/cmssy/blocks.ts",
|
|
209
205
|
"app/cmssy/editor.tsx",
|
|
210
206
|
"app/cmssy/hero.tsx",
|
|
211
|
-
"app/routes/page.tsx"
|
|
212
|
-
"app/routes/robots.ts",
|
|
213
|
-
"app/routes/sitemap.ts"
|
|
207
|
+
"app/routes/page.tsx"
|
|
214
208
|
]
|
|
215
209
|
}
|
|
216
210
|
];
|
|
@@ -577,7 +571,7 @@ function frameworkNotes(framework, root, skipped) {
|
|
|
577
571
|
if (framework.name === "remix" && skipped.includes("app/routes.ts")) {
|
|
578
572
|
notes.push({
|
|
579
573
|
status: "unknown",
|
|
580
|
-
message: "app/routes.ts already existed - mount routes/page.tsx (index + splat)
|
|
574
|
+
message: "app/routes.ts already existed - mount routes/page.tsx (index + splat) there yourself, or rerun with --force"
|
|
581
575
|
});
|
|
582
576
|
}
|
|
583
577
|
return notes;
|
|
@@ -775,6 +769,54 @@ function buildDraftPreviewUrls(previewUrl, draftSecret) {
|
|
|
775
769
|
exitUrl: `${base}?disable=1`
|
|
776
770
|
};
|
|
777
771
|
}
|
|
772
|
+
function draftRouteFix(cwd) {
|
|
773
|
+
const path = `${nextSrcPrefix(cwd)}app/api/draft/route.ts`;
|
|
774
|
+
return [
|
|
775
|
+
`add ${path} so Preview can enter draft mode:`,
|
|
776
|
+
' import { createDraftRoute } from "@cmssy/next/server";',
|
|
777
|
+
' import { cmssy } from "@/cmssy.config";',
|
|
778
|
+
" export const GET = createDraftRoute(cmssy);"
|
|
779
|
+
].join("\n");
|
|
780
|
+
}
|
|
781
|
+
async function checkDraftRouteMounted(previewUrl, fetchImpl, cwd) {
|
|
782
|
+
const base = draftRouteBase(previewUrl);
|
|
783
|
+
if (!base) {
|
|
784
|
+
return {
|
|
785
|
+
status: "fail",
|
|
786
|
+
message: `the workspace preview URL ${previewUrl} is not a valid URL`,
|
|
787
|
+
fix: "set a valid deployed origin as the preview URL: cmssy link --preview-url https://your-site.com"
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
let status;
|
|
791
|
+
try {
|
|
792
|
+
status = (await fetchImpl(base, {
|
|
793
|
+
method: "HEAD",
|
|
794
|
+
signal: AbortSignal.timeout(5e3)
|
|
795
|
+
})).status;
|
|
796
|
+
} catch {
|
|
797
|
+
return {
|
|
798
|
+
status: "unknown",
|
|
799
|
+
message: `could not reach ${base} to check the /api/draft route`
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
if (status === 404) {
|
|
803
|
+
return {
|
|
804
|
+
status: "fail",
|
|
805
|
+
message: `the /api/draft route is not mounted at ${previewUrl} - Preview will 404`,
|
|
806
|
+
fix: draftRouteFix(cwd)
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
if (status === 500) {
|
|
810
|
+
return {
|
|
811
|
+
status: "fail",
|
|
812
|
+
message: `the /api/draft route is mounted but misconfigured at ${previewUrl} - the draft secret must be at least 16 characters`
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
return {
|
|
816
|
+
status: "ok",
|
|
817
|
+
message: `the /api/draft route is mounted at ${previewUrl}`
|
|
818
|
+
};
|
|
819
|
+
}
|
|
778
820
|
async function selectWorkspace(workspaces, options, deps) {
|
|
779
821
|
if (workspaces.length === 0) {
|
|
780
822
|
throw new CliError(
|
|
@@ -914,8 +956,17 @@ async function runLink(options, deps) {
|
|
|
914
956
|
log(formatResult(reachable));
|
|
915
957
|
const secretResult = await checkDraftSecret(preflight);
|
|
916
958
|
log(formatResult(secretResult));
|
|
959
|
+
let draftRouteResult = null;
|
|
960
|
+
if (reachable.previewUrl) {
|
|
961
|
+
draftRouteResult = await checkDraftRouteMounted(
|
|
962
|
+
reachable.previewUrl,
|
|
963
|
+
deps.fetch,
|
|
964
|
+
cwd
|
|
965
|
+
);
|
|
966
|
+
log(formatResult(draftRouteResult));
|
|
967
|
+
}
|
|
917
968
|
log(formatEditorLink(buildEditorUrl(preflight)));
|
|
918
|
-
if (reachable.previewUrl && secretResult.status !== "fail") {
|
|
969
|
+
if (reachable.previewUrl && secretResult.status !== "fail" && draftRouteResult?.status !== "fail") {
|
|
919
970
|
const draftUrls = buildDraftPreviewUrls(
|
|
920
971
|
reachable.previewUrl,
|
|
921
972
|
draftSecret
|
|
@@ -924,7 +975,8 @@ async function runLink(options, deps) {
|
|
|
924
975
|
log(formatDraftPreviewLink(draftUrls.draftUrl, draftUrls.exitUrl));
|
|
925
976
|
}
|
|
926
977
|
}
|
|
927
|
-
|
|
978
|
+
const failed = reachable.status === "fail" || secretResult.status === "fail" || draftRouteResult?.status === "fail";
|
|
979
|
+
return failed ? 1 : 0;
|
|
928
980
|
} catch (error) {
|
|
929
981
|
if (error instanceof CliError) {
|
|
930
982
|
log(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "The cmssy CLI: `cmssy init` wires cmssy into an existing Next.js, Astro or React Router app; `cmssy link` connects it to a workspace and verifies the editor wiring.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"assets"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@cmssy/core": "
|
|
30
|
+
"@cmssy/core": "10.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^20.0.0",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createCmssySitemap } from "@cmssy/next/server";
|
|
2
|
-
import { cmssy } from "@/cmssy.config";
|
|
3
|
-
|
|
4
|
-
// One entry per language version of every published page, with hreflang and
|
|
5
|
-
// x-default. Rendering products or categories from model records? They are not
|
|
6
|
-
// pages - add them through `extra`.
|
|
7
|
-
export default createCmssySitemap(cmssy);
|