@decocms/blocks-cli 7.81.0 → 7.81.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/blocks-cli",
|
|
3
|
-
"version": "7.81.
|
|
3
|
+
"version": "7.81.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Deco codegen (generate-blocks, generate-schema, generate-invoke) and Fresh-to-TanStack migration tooling",
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"lint:unused": "knip"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@decocms/blocks": "7.81.
|
|
36
|
+
"@decocms/blocks": "7.81.1",
|
|
37
37
|
"ts-morph": "^27.0.0",
|
|
38
38
|
"tsx": "^4.22.5"
|
|
39
39
|
},
|
|
@@ -58,7 +58,18 @@ describe("generate-loaders — loader vs action emit", () => {
|
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
it("keeps actions as plain pass-throughs — never routed through createLoaderEntry", () => {
|
|
61
|
-
expect(out).toContain(
|
|
61
|
+
expect(out).toContain(
|
|
62
|
+
'"site/actions/addToCart": async (props: any, request?: Request, ctx?: any) => {',
|
|
63
|
+
);
|
|
62
64
|
expect(out).not.toContain('createLoaderEntry("site/actions/addToCart"');
|
|
63
65
|
});
|
|
66
|
+
|
|
67
|
+
it("types entries with the 3-arg (props, request, ctx) signature", () => {
|
|
68
|
+
expect(out).toContain("(props: any, request?: Request, ctx?: any) => Promise<any>");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("forwards ctx from action pass-throughs to the module default", () => {
|
|
72
|
+
expect(out).toContain("return (mod.default as any)(props, request, ctx);");
|
|
73
|
+
expect(out).not.toContain("return (mod.default as any)(props, request);");
|
|
74
|
+
});
|
|
64
75
|
});
|
|
@@ -10,11 +10,14 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Each loader/action file that exports a default function gets a generated
|
|
12
12
|
* entry like:
|
|
13
|
-
* "site/loaders/SAP/getUser": async (props, request) => {
|
|
13
|
+
* "site/loaders/SAP/getUser": async (props, request, ctx) => {
|
|
14
14
|
* const mod = await import("../../loaders/SAP/getUser");
|
|
15
|
-
* return mod.default(props, request);
|
|
15
|
+
* return mod.default(props, request, ctx);
|
|
16
16
|
* },
|
|
17
17
|
*
|
|
18
|
+
* `ctx` is the Fresh-style AppContext `/deco/invoke` builds per request, so
|
|
19
|
+
* migrated `(props, req, ctx)` loaders/actions keep reading `ctx.<app>`.
|
|
20
|
+
*
|
|
18
21
|
* Both keyed with and without `.ts` suffix for CMS block compatibility.
|
|
19
22
|
*
|
|
20
23
|
* Files listed in --exclude are skipped (they need custom wiring in setup.ts).
|
|
@@ -211,12 +214,12 @@ if (hasLoaderEntries) {
|
|
|
211
214
|
lines.push("");
|
|
212
215
|
}
|
|
213
216
|
lines.push(
|
|
214
|
-
"export const siteLoaders: Record<string, (props: any, request?: Request) => Promise<any>> = {",
|
|
217
|
+
"export const siteLoaders: Record<string, (props: any, request?: Request, ctx?: any) => Promise<any>> = {",
|
|
215
218
|
);
|
|
216
219
|
|
|
217
220
|
// Cast the dynamic-import default to `any` so legacy 3-arg
|
|
218
|
-
// `(props, req, ctx)` Fresh/Deno loaders still type-check.
|
|
219
|
-
//
|
|
221
|
+
// `(props, req, ctx)` Fresh/Deno loaders still type-check. `ctx` is forwarded
|
|
222
|
+
// as-is; callers without one (CMS resolution) pass `undefined`.
|
|
220
223
|
for (const entry of entries) {
|
|
221
224
|
if (entry.kind === "loader") {
|
|
222
225
|
// Both alias keys share the same dedup namespace (the non-.ts name) so a
|
|
@@ -228,13 +231,13 @@ for (const entry of entries) {
|
|
|
228
231
|
` "${entry.key}.ts": createLoaderEntry("${entry.key}", () => import("${entry.importPath}")),`,
|
|
229
232
|
);
|
|
230
233
|
} else {
|
|
231
|
-
lines.push(` "${entry.key}": async (props: any, request?: Request) => {`);
|
|
234
|
+
lines.push(` "${entry.key}": async (props: any, request?: Request, ctx?: any) => {`);
|
|
232
235
|
lines.push(` const mod = await import("${entry.importPath}");`);
|
|
233
|
-
lines.push(" return (mod.default as any)(props, request);");
|
|
236
|
+
lines.push(" return (mod.default as any)(props, request, ctx);");
|
|
234
237
|
lines.push(" },");
|
|
235
|
-
lines.push(` "${entry.key}.ts": async (props: any, request?: Request) => {`);
|
|
238
|
+
lines.push(` "${entry.key}.ts": async (props: any, request?: Request, ctx?: any) => {`);
|
|
236
239
|
lines.push(` const mod = await import("${entry.importPath}");`);
|
|
237
|
-
lines.push(" return (mod.default as any)(props, request);");
|
|
240
|
+
lines.push(" return (mod.default as any)(props, request, ctx);");
|
|
238
241
|
lines.push(" },");
|
|
239
242
|
}
|
|
240
243
|
}
|