@slicemachine/adapter-next 0.3.85 → 0.3.86-alpha.lg-page-routes.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/dist/hooks/page-route-create.cjs +396 -0
- package/dist/hooks/page-route-create.cjs.map +1 -0
- package/dist/hooks/page-route-create.d.ts +10 -0
- package/dist/hooks/page-route-create.js +396 -0
- package/dist/hooks/page-route-create.js.map +1 -0
- package/dist/plugin.cjs +8 -0
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +9 -1
- package/dist/plugin.js.map +1 -1
- package/dist/sliceTemplates/AlternateGrid/index.cjs +4 -0
- package/dist/sliceTemplates/AlternateGrid/index.cjs.map +1 -1
- package/dist/sliceTemplates/AlternateGrid/index.js +4 -0
- package/dist/sliceTemplates/AlternateGrid/index.js.map +1 -1
- package/dist/sliceTemplates/CustomerLogos/index.cjs +5 -0
- package/dist/sliceTemplates/CustomerLogos/index.cjs.map +1 -1
- package/dist/sliceTemplates/CustomerLogos/index.js +5 -0
- package/dist/sliceTemplates/CustomerLogos/index.js.map +1 -1
- package/package.json +4 -3
- package/src/hooks/page-route-create.ts +472 -0
- package/src/plugin.ts +10 -0
- package/src/sliceTemplates/AlternateGrid/index.ts +4 -0
- package/src/sliceTemplates/CustomerLogos/index.ts +5 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { stripIndent } from "common-tags";
|
|
2
|
+
import { checkHasProjectFile, writeProjectFile } from "@slicemachine/plugin-kit/fs";
|
|
3
|
+
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
|
|
4
|
+
import { getJSFileExtension } from "../lib/getJSFileExtension.js";
|
|
5
|
+
import { checkHasAppRouter } from "../lib/checkHasAppRouter.js";
|
|
6
|
+
import path__default from "node:path";
|
|
7
|
+
const createComponentFile = async ({ data, helpers, options }) => {
|
|
8
|
+
const isTypeScript = await checkIsTypeScriptProject({
|
|
9
|
+
helpers,
|
|
10
|
+
options
|
|
11
|
+
});
|
|
12
|
+
const hasSrcDirectory = await checkHasProjectFile({
|
|
13
|
+
filename: "src",
|
|
14
|
+
helpers
|
|
15
|
+
});
|
|
16
|
+
const hasAppRouter = await checkHasAppRouter({ helpers });
|
|
17
|
+
const pageRoute = data.model.route ?? data.model.id;
|
|
18
|
+
const pageRouteLength = pageRoute.split("/").length - 1;
|
|
19
|
+
const contents = generatePageComponent(data.model, {
|
|
20
|
+
hasAppRouter,
|
|
21
|
+
isTypeScript,
|
|
22
|
+
hasSrcDirectory,
|
|
23
|
+
pageRouteLength
|
|
24
|
+
});
|
|
25
|
+
const routeBase = hasAppRouter ? "app" : "pages";
|
|
26
|
+
const routeDirectoryPath = hasSrcDirectory ? path__default.join("src", routeBase) : routeBase;
|
|
27
|
+
const extension = await getJSFileExtension({
|
|
28
|
+
helpers,
|
|
29
|
+
options,
|
|
30
|
+
jsx: true
|
|
31
|
+
});
|
|
32
|
+
let filePath;
|
|
33
|
+
if (hasAppRouter) {
|
|
34
|
+
const fileName = data.model.repeatable ? `[uid]/page.${extension}` : `page.${extension}`;
|
|
35
|
+
filePath = path__default.join(routeDirectoryPath, pageRoute, fileName);
|
|
36
|
+
} else {
|
|
37
|
+
const fileName = data.model.repeatable ? `${pageRoute}/[uid].${extension}` : `${pageRoute}.${extension}`;
|
|
38
|
+
filePath = path__default.join(routeDirectoryPath, fileName);
|
|
39
|
+
}
|
|
40
|
+
await writeProjectFile({
|
|
41
|
+
filename: filePath,
|
|
42
|
+
contents,
|
|
43
|
+
format: options.format,
|
|
44
|
+
helpers
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const pageRouteCreate = async (data, context) => {
|
|
48
|
+
await createComponentFile({ data, ...context });
|
|
49
|
+
};
|
|
50
|
+
function generatePageComponent(customType, env) {
|
|
51
|
+
if (env.hasAppRouter) {
|
|
52
|
+
return generateAppRouterPage(customType, env.isTypeScript, env.hasSrcDirectory, env.pageRouteLength);
|
|
53
|
+
} else {
|
|
54
|
+
return generatePagesRouterPage(customType, env.isTypeScript, env.hasSrcDirectory, env.pageRouteLength);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function generateAppRouterPage(customType, isTypeScript, hasSrcDirectory, pageRouteLength) {
|
|
58
|
+
const levelsUp = customType.repeatable ? pageRouteLength + 1 : pageRouteLength;
|
|
59
|
+
const levelsUpWithSrc = hasSrcDirectory ? levelsUp + 1 : levelsUp;
|
|
60
|
+
const importPath = "../".repeat(levelsUpWithSrc) + "prismicio";
|
|
61
|
+
const slicesPath = "../".repeat(levelsUpWithSrc) + "slices";
|
|
62
|
+
if (customType.repeatable) {
|
|
63
|
+
if (isTypeScript) {
|
|
64
|
+
return stripIndent`
|
|
65
|
+
import { Metadata } from "next";
|
|
66
|
+
import { notFound } from "next/navigation";
|
|
67
|
+
import { asImageSrc } from "@prismicio/client";
|
|
68
|
+
import { SliceZone } from "@prismicio/react";
|
|
69
|
+
|
|
70
|
+
import { createClient } from "${importPath}";
|
|
71
|
+
import { components } from "${slicesPath}";
|
|
72
|
+
|
|
73
|
+
type Params = { uid: string };
|
|
74
|
+
|
|
75
|
+
export default async function Page({ params }: { params: Promise<Params> }) {
|
|
76
|
+
const { uid } = await params;
|
|
77
|
+
const client = createClient();
|
|
78
|
+
const page = await client
|
|
79
|
+
.getByUID("${customType.id}", uid)
|
|
80
|
+
.catch(() => notFound());
|
|
81
|
+
|
|
82
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function generateMetadata({
|
|
86
|
+
params,
|
|
87
|
+
}: {
|
|
88
|
+
params: Promise<Params>;
|
|
89
|
+
}): Promise<Metadata> {
|
|
90
|
+
const { uid } = await params;
|
|
91
|
+
const client = createClient();
|
|
92
|
+
const page = await client
|
|
93
|
+
.getByUID("${customType.id}", uid)
|
|
94
|
+
.catch(() => notFound());
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
title: page.data.meta_title,
|
|
98
|
+
description: page.data.meta_description,
|
|
99
|
+
openGraph: {
|
|
100
|
+
images: [{ url: asImageSrc(page.data.meta_image) ?? "" }],
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function generateStaticParams() {
|
|
106
|
+
const client = createClient();
|
|
107
|
+
const pages = await client.getAllByType("${customType.id}");
|
|
108
|
+
|
|
109
|
+
return pages.map((page) => ({ uid: page.uid }));
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
} else {
|
|
113
|
+
return stripIndent`
|
|
114
|
+
import { notFound } from "next/navigation";
|
|
115
|
+
import { asImageSrc } from "@prismicio/client";
|
|
116
|
+
import { SliceZone } from "@prismicio/react";
|
|
117
|
+
|
|
118
|
+
import { createClient } from "${importPath}";
|
|
119
|
+
import { components } from "${slicesPath}";
|
|
120
|
+
|
|
121
|
+
export default async function Page({ params }) {
|
|
122
|
+
const { uid } = await params;
|
|
123
|
+
const client = createClient();
|
|
124
|
+
const page = await client
|
|
125
|
+
.getByUID("${customType.id}", uid)
|
|
126
|
+
.catch(() => notFound());
|
|
127
|
+
|
|
128
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function generateMetadata({ params }) {
|
|
132
|
+
const { uid } = await params;
|
|
133
|
+
const client = createClient();
|
|
134
|
+
const page = await client
|
|
135
|
+
.getByUID("${customType.id}", uid)
|
|
136
|
+
.catch(() => notFound());
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
title: page.data.meta_title,
|
|
140
|
+
description: page.data.meta_description,
|
|
141
|
+
openGraph: {
|
|
142
|
+
images: [{ url: asImageSrc(page.data.meta_image) ?? "" }],
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export async function generateStaticParams() {
|
|
148
|
+
const client = createClient();
|
|
149
|
+
const pages = await client.getAllByType("${customType.id}");
|
|
150
|
+
|
|
151
|
+
return pages.map((page) => ({ uid: page.uid }));
|
|
152
|
+
}
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
if (isTypeScript) {
|
|
157
|
+
return stripIndent`
|
|
158
|
+
import { type Metadata } from "next";
|
|
159
|
+
import { notFound } from "next/navigation";
|
|
160
|
+
import { asImageSrc } from "@prismicio/client";
|
|
161
|
+
import { SliceZone } from "@prismicio/react";
|
|
162
|
+
|
|
163
|
+
import { createClient } from "${importPath}";
|
|
164
|
+
import { components } from "${slicesPath}";
|
|
165
|
+
|
|
166
|
+
export default async function Page() {
|
|
167
|
+
const client = createClient();
|
|
168
|
+
const page = await client.getSingle("${customType.id}").catch(() => notFound());
|
|
169
|
+
|
|
170
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
174
|
+
const client = createClient();
|
|
175
|
+
const page = await client.getSingle("${customType.id}").catch(() => notFound());
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
title: page.data.meta_title,
|
|
179
|
+
description: page.data.meta_description,
|
|
180
|
+
openGraph: {
|
|
181
|
+
images: [{ url: asImageSrc(page.data.meta_image) ?? "" }],
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
} else {
|
|
187
|
+
return stripIndent`
|
|
188
|
+
import { notFound } from "next/navigation";
|
|
189
|
+
import { asImageSrc } from "@prismicio/client";
|
|
190
|
+
import { SliceZone } from "@prismicio/react";
|
|
191
|
+
|
|
192
|
+
import { createClient } from "${importPath}";
|
|
193
|
+
import { components } from "${slicesPath}";
|
|
194
|
+
|
|
195
|
+
export default async function Page() {
|
|
196
|
+
const client = createClient();
|
|
197
|
+
const page = await client.getSingle("${customType.id}").catch(() => notFound());
|
|
198
|
+
|
|
199
|
+
return <SliceZone slices={page.data.slices} components={components} />;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export async function generateMetadata() {
|
|
203
|
+
const client = createClient();
|
|
204
|
+
const page = await client.getSingle("${customType.id}").catch(() => notFound());
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
title: page.data.meta_title,
|
|
208
|
+
description: page.data.meta_description,
|
|
209
|
+
openGraph: {
|
|
210
|
+
images: [{ url: asImageSrc(page.data.meta_image) ?? "" }],
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
`;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function generatePagesRouterPage(customType, isTypeScript, hasSrcDirectory, pageRouteLength) {
|
|
219
|
+
const levelsUp = customType.repeatable ? pageRouteLength + 1 : pageRouteLength;
|
|
220
|
+
const levelsUpWithSrc = hasSrcDirectory ? levelsUp + 1 : levelsUp;
|
|
221
|
+
const importPath = "../".repeat(levelsUpWithSrc) + "prismicio";
|
|
222
|
+
const slicesPath = "../".repeat(levelsUpWithSrc) + "slices";
|
|
223
|
+
if (customType.repeatable) {
|
|
224
|
+
if (isTypeScript) {
|
|
225
|
+
return stripIndent`
|
|
226
|
+
import { GetStaticPropsContext, InferGetStaticPropsType } from "next";
|
|
227
|
+
import Head from "next/head";
|
|
228
|
+
import { isFilled, asLink, asImageSrc } from "@prismicio/client";
|
|
229
|
+
import { SliceZone } from "@prismicio/react";
|
|
230
|
+
|
|
231
|
+
import { components } from "${slicesPath}";
|
|
232
|
+
import { createClient } from "${importPath}";
|
|
233
|
+
|
|
234
|
+
type Params = { uid: string };
|
|
235
|
+
|
|
236
|
+
export default function Page({
|
|
237
|
+
page,
|
|
238
|
+
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
|
239
|
+
return (
|
|
240
|
+
<>
|
|
241
|
+
<Head>
|
|
242
|
+
<title>{page.data.meta_title}</title>
|
|
243
|
+
{isFilled.keyText(page.data.meta_description) ? (
|
|
244
|
+
<meta name="description" content={page.data.meta_description} />
|
|
245
|
+
) : null}
|
|
246
|
+
{isFilled.image(page.data.meta_image) ? (
|
|
247
|
+
<meta property="og:image" content={asImageSrc(page.data.meta_image) || ""} />
|
|
248
|
+
) : null}
|
|
249
|
+
</Head>
|
|
250
|
+
<SliceZone slices={page.data.slices} components={components} />
|
|
251
|
+
</>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export async function getStaticProps({
|
|
256
|
+
params,
|
|
257
|
+
previewData,
|
|
258
|
+
}: GetStaticPropsContext<Params>) {
|
|
259
|
+
const client = createClient({ previewData });
|
|
260
|
+
const page = await client.getByUID("${customType.id}", params!.uid);
|
|
261
|
+
|
|
262
|
+
return { props: { page } };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export async function getStaticPaths() {
|
|
266
|
+
const client = createClient();
|
|
267
|
+
const pages = await client.getAllByType("${customType.id}");
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
paths: pages.map((page) => asLink(page)),
|
|
271
|
+
fallback: false,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
`;
|
|
275
|
+
} else {
|
|
276
|
+
return stripIndent`
|
|
277
|
+
import Head from "next/head";
|
|
278
|
+
import { isFilled, asLink, asImageSrc } from "@prismicio/client";
|
|
279
|
+
import { SliceZone } from "@prismicio/react";
|
|
280
|
+
|
|
281
|
+
import { components } from "${slicesPath}";
|
|
282
|
+
import { createClient } from "${importPath}";
|
|
283
|
+
|
|
284
|
+
export default function Page({ page }) {
|
|
285
|
+
return (
|
|
286
|
+
<>
|
|
287
|
+
<Head>
|
|
288
|
+
<title>{page.data.meta_title}</title>
|
|
289
|
+
{isFilled.keyText(page.data.meta_description) ? (
|
|
290
|
+
<meta name="description" content={page.data.meta_description} />
|
|
291
|
+
) : null}
|
|
292
|
+
{isFilled.image(page.data.meta_image) ? (
|
|
293
|
+
<meta property="og:image" content={asImageSrc(page.data.meta_image) || ""} />
|
|
294
|
+
) : null}
|
|
295
|
+
</Head>
|
|
296
|
+
<SliceZone slices={page.data.slices} components={components} />
|
|
297
|
+
</>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export async function getStaticProps({ params, previewData }) {
|
|
302
|
+
const client = createClient({ previewData });
|
|
303
|
+
const page = await client.getByUID("${customType.id}", params.uid);
|
|
304
|
+
|
|
305
|
+
return { props: { page } };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export async function getStaticPaths() {
|
|
309
|
+
const client = createClient();
|
|
310
|
+
const pages = await client.getAllByType("${customType.id}");
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
paths: pages.map((page) => asLink(page)),
|
|
314
|
+
fallback: false,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
`;
|
|
318
|
+
}
|
|
319
|
+
} else {
|
|
320
|
+
if (isTypeScript) {
|
|
321
|
+
return stripIndent`
|
|
322
|
+
import { GetStaticPropsContext, InferGetStaticPropsType } from "next";
|
|
323
|
+
import Head from "next/head";
|
|
324
|
+
import { isFilled, asImageSrc } from "@prismicio/client";
|
|
325
|
+
import { SliceZone } from "@prismicio/react";
|
|
326
|
+
|
|
327
|
+
import { components } from "${slicesPath}";
|
|
328
|
+
import { createClient } from "${importPath}";
|
|
329
|
+
|
|
330
|
+
export default function Page({
|
|
331
|
+
page,
|
|
332
|
+
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
|
333
|
+
return (
|
|
334
|
+
<>
|
|
335
|
+
<Head>
|
|
336
|
+
<title>{page.data.meta_title}</title>
|
|
337
|
+
{isFilled.keyText(page.data.meta_description) ? (
|
|
338
|
+
<meta name="description" content={page.data.meta_description} />
|
|
339
|
+
) : null}
|
|
340
|
+
{isFilled.image(page.data.meta_image) ? (
|
|
341
|
+
<meta property="og:image" content={asImageSrc(page.data.meta_image) || ""} />
|
|
342
|
+
) : null}
|
|
343
|
+
</Head>
|
|
344
|
+
<SliceZone slices={page.data.slices} components={components} />
|
|
345
|
+
</>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export async function getStaticProps({ previewData }: GetStaticPropsContext) {
|
|
350
|
+
const client = createClient({ previewData });
|
|
351
|
+
const page = await client.getSingle("${customType.id}");
|
|
352
|
+
|
|
353
|
+
return { props: { page } };
|
|
354
|
+
}
|
|
355
|
+
`;
|
|
356
|
+
} else {
|
|
357
|
+
return stripIndent`
|
|
358
|
+
import Head from "next/head";
|
|
359
|
+
import { isFilled, asImageSrc } from "@prismicio/client";
|
|
360
|
+
import { SliceZone } from "@prismicio/react";
|
|
361
|
+
|
|
362
|
+
import { components } from "${slicesPath}";
|
|
363
|
+
import { createClient } from "${importPath}";
|
|
364
|
+
|
|
365
|
+
export default function Page({ page }) {
|
|
366
|
+
return (
|
|
367
|
+
<>
|
|
368
|
+
<Head>
|
|
369
|
+
<title>{page.data.meta_title}</title>
|
|
370
|
+
{isFilled.keyText(page.data.meta_description) ? (
|
|
371
|
+
<meta name="description" content={page.data.meta_description} />
|
|
372
|
+
) : null}
|
|
373
|
+
{isFilled.image(page.data.meta_image) ? (
|
|
374
|
+
<meta property="og:image" content={asImageSrc(page.data.meta_image) || ""} />
|
|
375
|
+
) : null}
|
|
376
|
+
</Head>
|
|
377
|
+
<SliceZone slices={page.data.slices} components={components} />
|
|
378
|
+
</>
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export async function getStaticProps({ previewData }) {
|
|
383
|
+
const client = createClient({ previewData });
|
|
384
|
+
const page = await client.getSingle("${customType.id}");
|
|
385
|
+
|
|
386
|
+
return { props: { page } };
|
|
387
|
+
}
|
|
388
|
+
`;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
export {
|
|
393
|
+
generatePageComponent,
|
|
394
|
+
pageRouteCreate
|
|
395
|
+
};
|
|
396
|
+
//# sourceMappingURL=page-route-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-route-create.js","sources":["../../../src/hooks/page-route-create.ts"],"sourcesContent":["import { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport { stripIndent } from \"common-tags\";\n\nimport type {\n\tCustomTypeUpdateRouteHook,\n\tCustomTypeUpdateRouteHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkHasAppRouter } from \"../lib/checkHasAppRouter\";\nimport path from \"node:path\";\n\ntype Args = {\n\tdata: CustomTypeUpdateRouteHookData;\n} & SliceMachineContext<PluginOptions>;\n\nconst createComponentFile = async ({ data, helpers, options }: Args) => {\n\tconst isTypeScript = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tconst pageRoute = data.model.route ?? data.model.id;\n\tconst pageRouteLength = pageRoute.split(\"/\").length - 1;\n\n\tconst contents = generatePageComponent(data.model, {\n\t\thasAppRouter,\n\t\tisTypeScript,\n\t\thasSrcDirectory,\n\t\tpageRouteLength,\n\t});\n\n\tconst routeBase = hasAppRouter ? \"app\" : \"pages\";\n\tconst routeDirectoryPath = hasSrcDirectory\n\t\t? path.join(\"src\", routeBase)\n\t\t: routeBase;\n\n\tconst extension = await getJSFileExtension({\n\t\thelpers,\n\t\toptions,\n\t\tjsx: true,\n\t});\n\tlet filePath: string;\n\n\tif (hasAppRouter) {\n\t\tconst fileName = data.model.repeatable\n\t\t\t? `[uid]/page.${extension}`\n\t\t\t: `page.${extension}`;\n\n\t\tfilePath = path.join(routeDirectoryPath, pageRoute, fileName);\n\t} else {\n\t\tconst fileName = data.model.repeatable\n\t\t\t? `${pageRoute}/[uid].${extension}`\n\t\t\t: `${pageRoute}.${extension}`;\n\n\t\tfilePath = path.join(routeDirectoryPath, fileName);\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename: filePath,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nexport const pageRouteCreate: CustomTypeUpdateRouteHook<PluginOptions> = async (\n\tdata,\n\tcontext,\n) => {\n\tawait createComponentFile({ data, ...context });\n};\n\nexport function generatePageComponent(\n\tcustomType: CustomType,\n\tenv: {\n\t\thasAppRouter: boolean;\n\t\tisTypeScript: boolean;\n\t\thasSrcDirectory: boolean;\n\t\tpageRouteLength: number;\n\t},\n): string {\n\tif (env.hasAppRouter) {\n\t\treturn generateAppRouterPage(\n\t\t\tcustomType,\n\t\t\tenv.isTypeScript,\n\t\t\tenv.hasSrcDirectory,\n\t\t\tenv.pageRouteLength,\n\t\t);\n\t} else {\n\t\treturn generatePagesRouterPage(\n\t\t\tcustomType,\n\t\t\tenv.isTypeScript,\n\t\t\tenv.hasSrcDirectory,\n\t\t\tenv.pageRouteLength,\n\t\t);\n\t}\n}\n\nfunction generateAppRouterPage(\n\tcustomType: CustomType,\n\tisTypeScript: boolean,\n\thasSrcDirectory: boolean,\n\tpageRouteLength: number,\n): string {\n\t// Calculate import paths based on directory depth\n\t// Single: app/[id]/page.tsx → ../../prismicio (or ../../../prismicio if src/)\n\t// Repeatable: app/[id]/[uid]/page.tsx → ../../../prismicio (or ../../../../prismicio if src/)\n\tconst levelsUp = customType.repeatable\n\t\t? pageRouteLength + 1\n\t\t: pageRouteLength;\n\tconst levelsUpWithSrc = hasSrcDirectory ? levelsUp + 1 : levelsUp;\n\tconst importPath = \"../\".repeat(levelsUpWithSrc) + \"prismicio\";\n\tconst slicesPath = \"../\".repeat(levelsUpWithSrc) + \"slices\";\n\n\tif (customType.repeatable) {\n\t\tif (isTypeScript) {\n\t\t\treturn stripIndent`\n import { Metadata } from \"next\";\n import { notFound } from \"next/navigation\";\n import { asImageSrc } from \"@prismicio/client\";\n import { SliceZone } from \"@prismicio/react\";\n\n import { createClient } from \"${importPath}\";\n import { components } from \"${slicesPath}\";\n\n type Params = { uid: string };\n\n export default async function Page({ params }: { params: Promise<Params> }) {\n const { uid } = await params;\n const client = createClient();\n const page = await client\n .getByUID(\"${customType.id}\", uid)\n .catch(() => notFound());\n\n return <SliceZone slices={page.data.slices} components={components} />;\n }\n\n export async function generateMetadata({\n params,\n }: {\n params: Promise<Params>;\n }): Promise<Metadata> {\n const { uid } = await params;\n const client = createClient();\n const page = await client\n .getByUID(\"${customType.id}\", uid)\n .catch(() => notFound());\n\n return {\n title: page.data.meta_title,\n description: page.data.meta_description,\n openGraph: {\n images: [{ url: asImageSrc(page.data.meta_image) ?? \"\" }],\n },\n };\n }\n\n export async function generateStaticParams() {\n const client = createClient();\n const pages = await client.getAllByType(\"${customType.id}\");\n\n return pages.map((page) => ({ uid: page.uid }));\n }\n `;\n\t\t} else {\n\t\t\treturn stripIndent`\n import { notFound } from \"next/navigation\";\n import { asImageSrc } from \"@prismicio/client\";\n import { SliceZone } from \"@prismicio/react\";\n\n import { createClient } from \"${importPath}\";\n import { components } from \"${slicesPath}\";\n\n export default async function Page({ params }) {\n const { uid } = await params;\n const client = createClient();\n const page = await client\n .getByUID(\"${customType.id}\", uid)\n .catch(() => notFound());\n\n return <SliceZone slices={page.data.slices} components={components} />;\n }\n\n export async function generateMetadata({ params }) {\n const { uid } = await params;\n const client = createClient();\n const page = await client\n .getByUID(\"${customType.id}\", uid)\n .catch(() => notFound());\n\n return {\n title: page.data.meta_title,\n description: page.data.meta_description,\n openGraph: {\n images: [{ url: asImageSrc(page.data.meta_image) ?? \"\" }],\n },\n };\n }\n\n export async function generateStaticParams() {\n const client = createClient();\n const pages = await client.getAllByType(\"${customType.id}\");\n\n return pages.map((page) => ({ uid: page.uid }));\n }\n `;\n\t\t}\n\t} else {\n\t\t// Single type\n\t\tif (isTypeScript) {\n\t\t\treturn stripIndent`\n import { type Metadata } from \"next\";\n import { notFound } from \"next/navigation\";\n import { asImageSrc } from \"@prismicio/client\";\n import { SliceZone } from \"@prismicio/react\";\n\n import { createClient } from \"${importPath}\";\n import { components } from \"${slicesPath}\";\n\n export default async function Page() {\n const client = createClient();\n const page = await client.getSingle(\"${customType.id}\").catch(() => notFound());\n\n return <SliceZone slices={page.data.slices} components={components} />;\n }\n\n export async function generateMetadata(): Promise<Metadata> {\n const client = createClient();\n const page = await client.getSingle(\"${customType.id}\").catch(() => notFound());\n\n return {\n title: page.data.meta_title,\n description: page.data.meta_description,\n openGraph: {\n images: [{ url: asImageSrc(page.data.meta_image) ?? \"\" }],\n },\n };\n }\n `;\n\t\t} else {\n\t\t\treturn stripIndent`\n import { notFound } from \"next/navigation\";\n import { asImageSrc } from \"@prismicio/client\";\n import { SliceZone } from \"@prismicio/react\";\n\n import { createClient } from \"${importPath}\";\n import { components } from \"${slicesPath}\";\n\n export default async function Page() {\n const client = createClient();\n const page = await client.getSingle(\"${customType.id}\").catch(() => notFound());\n\n return <SliceZone slices={page.data.slices} components={components} />;\n }\n\n export async function generateMetadata() {\n const client = createClient();\n const page = await client.getSingle(\"${customType.id}\").catch(() => notFound());\n\n return {\n title: page.data.meta_title,\n description: page.data.meta_description,\n openGraph: {\n images: [{ url: asImageSrc(page.data.meta_image) ?? \"\" }],\n },\n };\n }\n `;\n\t\t}\n\t}\n}\n\nfunction generatePagesRouterPage(\n\tcustomType: CustomType,\n\tisTypeScript: boolean,\n\thasSrcDirectory: boolean,\n\tpageRouteLength: number,\n): string {\n\t// Calculate import paths based on directory depth\n\t// Single: pages/[id].tsx → ../prismicio (or ../../prismicio if src/)\n\t// Repeatable: pages/[id]/[uid].tsx → ../../prismicio (or ../../../prismicio if src/)\n\tconst levelsUp = customType.repeatable\n\t\t? pageRouteLength + 1\n\t\t: pageRouteLength;\n\tconst levelsUpWithSrc = hasSrcDirectory ? levelsUp + 1 : levelsUp;\n\tconst importPath = \"../\".repeat(levelsUpWithSrc) + \"prismicio\";\n\tconst slicesPath = \"../\".repeat(levelsUpWithSrc) + \"slices\";\n\n\tif (customType.repeatable) {\n\t\tif (isTypeScript) {\n\t\t\treturn stripIndent`\n import { GetStaticPropsContext, InferGetStaticPropsType } from \"next\";\n import Head from \"next/head\";\n import { isFilled, asLink, asImageSrc } from \"@prismicio/client\";\n import { SliceZone } from \"@prismicio/react\";\n\n import { components } from \"${slicesPath}\";\n import { createClient } from \"${importPath}\";\n\n type Params = { uid: string };\n\n export default function Page({\n page,\n }: InferGetStaticPropsType<typeof getStaticProps>) {\n return (\n <>\n <Head>\n <title>{page.data.meta_title}</title>\n {isFilled.keyText(page.data.meta_description) ? (\n <meta name=\"description\" content={page.data.meta_description} />\n ) : null}\n {isFilled.image(page.data.meta_image) ? (\n <meta property=\"og:image\" content={asImageSrc(page.data.meta_image) || \"\"} />\n ) : null}\n </Head>\n <SliceZone slices={page.data.slices} components={components} />\n </>\n );\n }\n\n export async function getStaticProps({\n params,\n previewData,\n }: GetStaticPropsContext<Params>) {\n const client = createClient({ previewData });\n const page = await client.getByUID(\"${customType.id}\", params!.uid);\n\n return { props: { page } };\n }\n\n export async function getStaticPaths() {\n const client = createClient();\n const pages = await client.getAllByType(\"${customType.id}\");\n\n return {\n paths: pages.map((page) => asLink(page)),\n fallback: false,\n };\n }\n `;\n\t\t} else {\n\t\t\treturn stripIndent`\n import Head from \"next/head\";\n import { isFilled, asLink, asImageSrc } from \"@prismicio/client\";\n import { SliceZone } from \"@prismicio/react\";\n\n import { components } from \"${slicesPath}\";\n import { createClient } from \"${importPath}\";\n\n export default function Page({ page }) {\n return (\n <>\n <Head>\n <title>{page.data.meta_title}</title>\n {isFilled.keyText(page.data.meta_description) ? (\n <meta name=\"description\" content={page.data.meta_description} />\n ) : null}\n {isFilled.image(page.data.meta_image) ? (\n <meta property=\"og:image\" content={asImageSrc(page.data.meta_image) || \"\"} />\n ) : null}\n </Head>\n <SliceZone slices={page.data.slices} components={components} />\n </>\n );\n }\n\n export async function getStaticProps({ params, previewData }) {\n const client = createClient({ previewData });\n const page = await client.getByUID(\"${customType.id}\", params.uid);\n\n return { props: { page } };\n }\n\n export async function getStaticPaths() {\n const client = createClient();\n const pages = await client.getAllByType(\"${customType.id}\");\n\n return {\n paths: pages.map((page) => asLink(page)),\n fallback: false,\n };\n }\n `;\n\t\t}\n\t} else {\n\t\t// Single type\n\t\tif (isTypeScript) {\n\t\t\treturn stripIndent`\n import { GetStaticPropsContext, InferGetStaticPropsType } from \"next\";\n import Head from \"next/head\";\n import { isFilled, asImageSrc } from \"@prismicio/client\";\n import { SliceZone } from \"@prismicio/react\";\n\n import { components } from \"${slicesPath}\";\n import { createClient } from \"${importPath}\";\n\n export default function Page({\n page,\n }: InferGetStaticPropsType<typeof getStaticProps>) {\n return (\n <>\n <Head>\n <title>{page.data.meta_title}</title>\n {isFilled.keyText(page.data.meta_description) ? (\n <meta name=\"description\" content={page.data.meta_description} />\n ) : null}\n {isFilled.image(page.data.meta_image) ? (\n <meta property=\"og:image\" content={asImageSrc(page.data.meta_image) || \"\"} />\n ) : null}\n </Head>\n <SliceZone slices={page.data.slices} components={components} />\n </>\n );\n }\n\n export async function getStaticProps({ previewData }: GetStaticPropsContext) {\n const client = createClient({ previewData });\n const page = await client.getSingle(\"${customType.id}\");\n\n return { props: { page } };\n }\n `;\n\t\t} else {\n\t\t\treturn stripIndent`\n import Head from \"next/head\";\n import { isFilled, asImageSrc } from \"@prismicio/client\";\n import { SliceZone } from \"@prismicio/react\";\n\n import { components } from \"${slicesPath}\";\n import { createClient } from \"${importPath}\";\n\n export default function Page({ page }) {\n return (\n <>\n <Head>\n <title>{page.data.meta_title}</title>\n {isFilled.keyText(page.data.meta_description) ? (\n <meta name=\"description\" content={page.data.meta_description} />\n ) : null}\n {isFilled.image(page.data.meta_image) ? (\n <meta property=\"og:image\" content={asImageSrc(page.data.meta_image) || \"\"} />\n ) : null}\n </Head>\n <SliceZone slices={page.data.slices} components={components} />\n </>\n );\n }\n\n export async function getStaticProps({ previewData }) {\n const client = createClient({ previewData });\n const page = await client.getSingle(\"${customType.id}\");\n\n return { props: { page } };\n }\n `;\n\t\t}\n\t}\n}\n"],"names":["path"],"mappings":";;;;;;AAwBA,MAAM,sBAAsB,OAAO,EAAE,MAAM,SAAS,cAAmB;AACtE,QAAM,eAAe,MAAM,yBAAyB;AAAA,IACnD;AAAA,IACA;AAAA,EAAA,CACA;AACD,QAAM,kBAAkB,MAAM,oBAAoB;AAAA,IACjD,UAAU;AAAA,IACV;AAAA,EAAA,CACA;AACD,QAAM,eAAe,MAAM,kBAAkB,EAAE,SAAS;AAExD,QAAM,YAAY,KAAK,MAAM,SAAS,KAAK,MAAM;AACjD,QAAM,kBAAkB,UAAU,MAAM,GAAG,EAAE,SAAS;AAEtD,QAAM,WAAW,sBAAsB,KAAK,OAAO;AAAA,IAClD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AAED,QAAM,YAAY,eAAe,QAAQ;AACzC,QAAM,qBAAqB,kBACxBA,cAAK,KAAK,OAAO,SAAS,IAC1B;AAEH,QAAM,YAAY,MAAM,mBAAmB;AAAA,IAC1C;AAAA,IACA;AAAA,IACA,KAAK;AAAA,EAAA,CACL;AACD,MAAI;AAEJ,MAAI,cAAc;AACjB,UAAM,WAAW,KAAK,MAAM,aACzB,cAAc,SAAS,KACvB,QAAQ,SAAS;AAEpB,eAAWA,cAAK,KAAK,oBAAoB,WAAW,QAAQ;AAAA,EAC7D,OAAO;AACN,UAAM,WAAW,KAAK,MAAM,aACzB,GAAG,SAAS,UAAU,SAAS,KAC/B,GAAG,SAAS,IAAI,SAAS;AAE5B,eAAWA,cAAK,KAAK,oBAAoB,QAAQ;AAAA,EAClD;AAEA,QAAM,iBAAiB;AAAA,IACtB,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,EAAA,CACA;AACF;AAEO,MAAM,kBAA4D,OACxE,MACA,YACG;AACH,QAAM,oBAAoB,EAAE,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;AAAA;AAAA;AAAA;AAAA;AAAA,sCAK4B,UAAU;AAAA,wCACR,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gDAqBF,WAAW,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qDAOR,WAAW,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQhE;AAAA,EACD,OAAO;AAEN,QAAI,cAAc;AACjB,aAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAM4B,UAAU;AAAA,wCACR,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAuBD,WAAW,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA,IAK5D,OAAO;AACN,aAAO;AAAA;AAAA;AAAA;AAAA;AAAA,sCAK4B,UAAU;AAAA,wCACR,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAqBD,WAAW,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA,IAK5D;AAAA,EACD;AACD;"}
|
package/dist/plugin.cjs
CHANGED
|
@@ -12,6 +12,7 @@ const documentationRead = require("./hooks/documentation-read.cjs");
|
|
|
12
12
|
const projectInit = require("./hooks/project-init.cjs");
|
|
13
13
|
const sliceCreate = require("./hooks/slice-create.cjs");
|
|
14
14
|
const snippetRead = require("./hooks/snippet-read.cjs");
|
|
15
|
+
const pageRouteCreate = require("./hooks/page-route-create.cjs");
|
|
15
16
|
const index = require("./sliceTemplates/Hero/index.cjs");
|
|
16
17
|
const index$3 = require("./sliceTemplates/CallToAction/index.cjs");
|
|
17
18
|
const index$2 = require("./sliceTemplates/AlternateGrid/index.cjs");
|
|
@@ -198,6 +199,13 @@ const plugin = pluginKit.defineSliceMachinePlugin({
|
|
|
198
199
|
...context
|
|
199
200
|
});
|
|
200
201
|
});
|
|
202
|
+
hook("custom-type:update-route", async (data, context) => {
|
|
203
|
+
await fs.updateCustomTypeRoute({
|
|
204
|
+
model: data.model,
|
|
205
|
+
...context
|
|
206
|
+
});
|
|
207
|
+
await pageRouteCreate.pageRouteCreate(data, context);
|
|
208
|
+
});
|
|
201
209
|
hook("custom-type:read", async (data, context) => {
|
|
202
210
|
return await fs.readCustomTypeModel({
|
|
203
211
|
customTypeID: data.id,
|
package/dist/plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","sources":["../../src/plugin.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\nimport {\n\tdeleteCustomTypeDirectory,\n\tdeleteCustomTypeFile,\n\tdeleteSliceDirectory,\n\tdeleteSliceFile,\n\treadCustomTypeFile,\n\treadCustomTypeLibrary,\n\treadCustomTypeModel,\n\treadProjectEnvironment,\n\treadSliceFile,\n\treadSliceLibrary,\n\treadSliceModel,\n\treadSliceTemplateLibrary,\n\trenameCustomType,\n\trenameSlice,\n\tupsertGlobalTypeScriptTypes,\n\twriteCustomTypeFile,\n\twriteCustomTypeModel,\n\twriteProjectEnvironment,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { rejectIfNecessary } from \"./lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"./lib/upsertSliceLibraryIndexFile\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\nimport {\n\tPRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME,\n\tDEFAULT_ENVIRONMENT_VARIABLE_FILE_PATH,\n\tENVIRONMENT_VARIABLE_PATHS,\n} from \"./constants\";\n\nimport { documentationRead } from \"./hooks/documentation-read\";\nimport { projectInit } from \"./hooks/project-init\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { snippetRead } from \"./hooks/snippet-read\";\n\n// Slice Template Library\nimport * as Hero from \"./sliceTemplates/Hero\";\nimport * as CallToAction from \"./sliceTemplates/CallToAction\";\nimport * as AlternateGrid from \"./sliceTemplates/AlternateGrid\";\nimport * as CustomerLogos from \"./sliceTemplates/CustomerLogos\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\t////////////////////////////////////////////////////////////////\n\t\t// project:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"project:init\", projectInit);\n\t\thook(\"project:environment:update\", async (data, context) => {\n\t\t\tawait writeProjectEnvironment({\n\t\t\t\tvariableName: PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME,\n\t\t\t\tenvironment: data.environment,\n\t\t\t\tfilename:\n\t\t\t\t\tcontext.options.environmentVariableFilePath ||\n\t\t\t\t\tDEFAULT_ENVIRONMENT_VARIABLE_FILE_PATH,\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\t\thook(\"project:environment:read\", async (_data, context) => {\n\t\t\tconst projectEnvironment = await readProjectEnvironment({\n\t\t\t\tvariableName: PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME,\n\t\t\t\tfilenames: [\n\t\t\t\t\t...ENVIRONMENT_VARIABLE_PATHS,\n\t\t\t\t\tcontext.options.environmentVariableFilePath,\n\t\t\t\t].filter((filename): filename is NonNullable<typeof filename> =>\n\t\t\t\t\tBoolean(filename),\n\t\t\t\t),\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tenvironment: projectEnvironment.environment,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", async (data, context) => {\n\t\t\tawait writeSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:rename\", async (data, context) => {\n\t\t\tawait renameSlice({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:delete\", async (data, context) => {\n\t\t\tawait deleteSliceDirectory({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:read\", async (data, context) => {\n\t\t\treturn await readSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:update\", async (data, context) => {\n\t\t\tawait writeSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:delete\", async (data, context) => {\n\t\t\tawait deleteSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:read\", async (data, context) => {\n\t\t\tconst file = await readSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-library:read\", async (data, context) => {\n\t\t\treturn await readSliceLibrary({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-template-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-template-library:read\", async (data, context) => {\n\t\t\treturn await readSliceTemplateLibrary({\n\t\t\t\t...data,\n\t\t\t\t...context,\n\t\t\t\tdirName: path.dirname(fileURLToPath(new URL(import.meta.url))),\n\t\t\t\ttemplates: [Hero, CustomerLogos, AlternateGrid, CallToAction],\n\t\t\t\tcomponentFileNames: {\n\t\t\t\t\tjs: \"javascript.jsx\",\n\t\t\t\t\tts: \"typescript.tsx\",\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type:create\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:rename\", async (data, context) => {\n\t\t\tawait renameCustomType({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeDirectory({\n\t\t\t\tcustomTypeID: data.model.id,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:read\", async (data, context) => {\n\t\t\treturn await readCustomTypeModel({\n\t\t\t\tcustomTypeID: data.id,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:read\", async (data, context) => {\n\t\t\tconst file = await readCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type-library:read\", async (_data, context) => {\n\t\t\treturn await readCustomTypeLibrary({\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// snippet:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// documentation:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"documentation:read\", documentationRead);\n\t},\n});\n"],"names":["defineSliceMachinePlugin","pkgName","projectInit","writeProjectEnvironment","PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME","DEFAULT_ENVIRONMENT_VARIABLE_FILE_PATH","readProjectEnvironment","ENVIRONMENT_VARIABLE_PATHS","sliceCreate","writeSliceModel","upsertGlobalTypeScriptTypes","renameSlice","rejectIfNecessary","upsertSliceLibraryIndexFile","deleteSliceDirectory","readSliceModel","writeSliceFile","deleteSliceFile","readSliceFile","readSliceLibrary","readSliceTemplateLibrary","fileURLToPath","Hero","CustomerLogos","AlternateGrid","CallToAction","writeCustomTypeModel","renameCustomType","deleteCustomTypeDirectory","readCustomTypeModel","writeCustomTypeFile","deleteCustomTypeFile","readCustomTypeFile","readCustomTypeLibrary","snippetRead","documentationRead"],"mappings":";;;;;;;;;;;;;;;;;;;AAiDO,MAAM,SAASA,UAAAA,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL,MAAMC,SAAAA;AAAAA,EAAA;AAAA,EAEP,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAAA;AAAA,EAEjB,MAAM,EAAE,QAAM;AAKb,SAAK,gBAAgBC,uBAAW;AAChC,SAAK,8BAA8B,OAAO,MAAM,YAAW;AAC1D,YAAMC,2BAAwB;AAAA,QAC7B,cAAcC,UAAAA;AAAAA,QACd,aAAa,KAAK;AAAA,QAClB,UACC,QAAQ,QAAQ,+BAChBC,UAAAA;AAAAA,QACD,SAAS,QAAQ;AAAA,MAAA,CACjB;AAAA,IACF,CAAC;AACD,SAAK,4BAA4B,OAAO,OAAO,YAAW;AACzD,YAAM,qBAAqB,MAAMC,0BAAuB;AAAA,QACvD,cAAcF,UAAAA;AAAAA,QACd,WAAW;AAAA,UACV,GAAGG,UAAAA;AAAAA,UACH,QAAQ,QAAQ;AAAA,QAAA,EACf,OAAO,CAAC,aACT,QAAQ,QAAQ,CAAC;AAAA,QAElB,SAAS,QAAQ;AAAA,MAAA,CACjB;AAED,aAAO;AAAA,QACN,aAAa,mBAAmB;AAAA,MAAA;AAAA,IAElC,CAAC;AAMD,SAAK,gBAAgBC,uBAAW;AAChC,SAAK,gBAAgB,OAAO,MAAM,YAAW;AAC5C,YAAMC,mBAAgB;AAAA,QACrB,WAA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MAAM,YAAW;AAChD,aAAO,MAAMmB,GAAAA,oBAAoB;AAAA,QAChC,cAAc,KAAK;AAAA,QACnB,GAAG;AAAA,MAAA,CACH;AAAA,IACF,CAAC;AACD,SAAK,4BAA4B,OAAO,MAAM,YAAW;AACxD,YAAMC,uBAAoB;AAAA,QACzB,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK,MAAM;AAAA,QACrB,UAAU,KAAK,MAAM;AAAA,QACrB,GAAG;AAAA,MAAA,CACH;AAAA,IACF,CAAC;AACD,SAAK,4BAA4B,OAAO,MAAM,YAAW;AACxD,YAAMC,wBAAqB;AAAA,QAC1B,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAAA,IACF,CAAC;AACD,SAAK,0BAA0B,OAAO,MAAM,YAAW;AACtD,YAAM,OAAO,MAAMC,sBAAmB;AAAA,QACrC,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAED,aAAO;AAAA,QACN,MAAM;AAAA,MAAA;AAAA,IAER,CAAC;AAMD,SAAK,4BAA4B,OAAO,OAAO,YAAW;AACzD,aAAO,MAAMC,GAAAA,sBAAsB;AAAA,QAClC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAAA,IACF,CAAC;AAMD,SAAK,gBAAgBC,uBAAW;AAMhC,SAAK,sBAAsBC,mCAAiB;AAAA,EAC7C;AACA,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs","sources":["../../src/plugin.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { defineSliceMachinePlugin } from \"@slicemachine/plugin-kit\";\nimport {\n\tdeleteCustomTypeDirectory,\n\tdeleteCustomTypeFile,\n\tdeleteSliceDirectory,\n\tdeleteSliceFile,\n\treadCustomTypeFile,\n\treadCustomTypeLibrary,\n\treadCustomTypeModel,\n\treadProjectEnvironment,\n\treadSliceFile,\n\treadSliceLibrary,\n\treadSliceModel,\n\treadSliceTemplateLibrary,\n\trenameCustomType,\n\tupdateCustomTypeRoute,\n\trenameSlice,\n\tupsertGlobalTypeScriptTypes,\n\twriteCustomTypeFile,\n\twriteCustomTypeModel,\n\twriteProjectEnvironment,\n\twriteSliceFile,\n\twriteSliceModel,\n} from \"@slicemachine/plugin-kit/fs\";\n\nimport { rejectIfNecessary } from \"./lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"./lib/upsertSliceLibraryIndexFile\";\n\nimport { name as pkgName } from \"../package.json\";\nimport { PluginOptions } from \"./types\";\nimport {\n\tPRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME,\n\tDEFAULT_ENVIRONMENT_VARIABLE_FILE_PATH,\n\tENVIRONMENT_VARIABLE_PATHS,\n} from \"./constants\";\n\nimport { documentationRead } from \"./hooks/documentation-read\";\nimport { projectInit } from \"./hooks/project-init\";\nimport { sliceCreate } from \"./hooks/slice-create\";\nimport { snippetRead } from \"./hooks/snippet-read\";\nimport { pageRouteCreate } from \"./hooks/page-route-create\";\n\n// Slice Template Library\nimport * as Hero from \"./sliceTemplates/Hero\";\nimport * as CallToAction from \"./sliceTemplates/CallToAction\";\nimport * as AlternateGrid from \"./sliceTemplates/AlternateGrid\";\nimport * as CustomerLogos from \"./sliceTemplates/CustomerLogos\";\n\nexport const plugin = defineSliceMachinePlugin<PluginOptions>({\n\tmeta: {\n\t\tname: pkgName,\n\t},\n\tdefaultOptions: {\n\t\tformat: true,\n\t\tlazyLoadSlices: true,\n\t},\n\tsetup({ hook }) {\n\t\t////////////////////////////////////////////////////////////////\n\t\t// project:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"project:init\", projectInit);\n\t\thook(\"project:environment:update\", async (data, context) => {\n\t\t\tawait writeProjectEnvironment({\n\t\t\t\tvariableName: PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME,\n\t\t\t\tenvironment: data.environment,\n\t\t\t\tfilename:\n\t\t\t\t\tcontext.options.environmentVariableFilePath ||\n\t\t\t\t\tDEFAULT_ENVIRONMENT_VARIABLE_FILE_PATH,\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\t\thook(\"project:environment:read\", async (_data, context) => {\n\t\t\tconst projectEnvironment = await readProjectEnvironment({\n\t\t\t\tvariableName: PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME,\n\t\t\t\tfilenames: [\n\t\t\t\t\t...ENVIRONMENT_VARIABLE_PATHS,\n\t\t\t\t\tcontext.options.environmentVariableFilePath,\n\t\t\t\t].filter((filename): filename is NonNullable<typeof filename> =>\n\t\t\t\t\tBoolean(filename),\n\t\t\t\t),\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tenvironment: projectEnvironment.environment,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice:create\", sliceCreate);\n\t\thook(\"slice:update\", async (data, context) => {\n\t\t\tawait writeSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:rename\", async (data, context) => {\n\t\t\tawait renameSlice({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:delete\", async (data, context) => {\n\t\t\tawait deleteSliceDirectory({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\trejectIfNecessary(\n\t\t\t\tawait Promise.allSettled([\n\t\t\t\t\tupsertSliceLibraryIndexFile({\n\t\t\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t\tupsertGlobalTypeScriptTypes({\n\t\t\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\t\t\tformat: context.options.format,\n\t\t\t\t\t\t...context,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t);\n\t\t});\n\t\thook(\"slice:read\", async (data, context) => {\n\t\t\treturn await readSliceModel({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:update\", async (data, context) => {\n\t\t\tawait writeSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:delete\", async (data, context) => {\n\t\t\tawait deleteSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"slice:asset:read\", async (data, context) => {\n\t\t\tconst file = await readSliceFile({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\tsliceID: data.sliceID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-library:read\", async (data, context) => {\n\t\t\treturn await readSliceLibrary({\n\t\t\t\tlibraryID: data.libraryID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// slice-template-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"slice-template-library:read\", async (data, context) => {\n\t\t\treturn await readSliceTemplateLibrary({\n\t\t\t\t...data,\n\t\t\t\t...context,\n\t\t\t\tdirName: path.dirname(fileURLToPath(new URL(import.meta.url))),\n\t\t\t\ttemplates: [Hero, CustomerLogos, AlternateGrid, CallToAction],\n\t\t\t\tcomponentFileNames: {\n\t\t\t\t\tjs: \"javascript.jsx\",\n\t\t\t\t\tts: \"typescript.tsx\",\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type:create\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeModel({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:rename\", async (data, context) => {\n\t\t\tawait renameCustomType({\n\t\t\t\tmodel: data.model,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeDirectory({\n\t\t\t\tcustomTypeID: data.model.id,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait upsertGlobalTypeScriptTypes({\n\t\t\t\tfilename: context.options.generatedTypesFilePath,\n\t\t\t\tformat: context.options.format,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:update-route\", async (data, context) => {\n\t\t\tawait updateCustomTypeRoute({\n\t\t\t\tmodel: data.model,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\tawait pageRouteCreate(data, context);\n\t\t});\n\t\thook(\"custom-type:read\", async (data, context) => {\n\t\t\treturn await readCustomTypeModel({\n\t\t\t\tcustomTypeID: data.id,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:update\", async (data, context) => {\n\t\t\tawait writeCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.asset.id,\n\t\t\t\tcontents: data.asset.data,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:delete\", async (data, context) => {\n\t\t\tawait deleteCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\t\t});\n\t\thook(\"custom-type:asset:read\", async (data, context) => {\n\t\t\tconst file = await readCustomTypeFile({\n\t\t\t\tcustomTypeID: data.customTypeID,\n\t\t\t\tfilename: data.assetID,\n\t\t\t\t...context,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tdata: file,\n\t\t\t};\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// custom-type-library:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"custom-type-library:read\", async (_data, context) => {\n\t\t\treturn await readCustomTypeLibrary({\n\t\t\t\thelpers: context.helpers,\n\t\t\t});\n\t\t});\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// snippet:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"snippet:read\", snippetRead);\n\n\t\t////////////////////////////////////////////////////////////////\n\t\t// documentation:*\n\t\t////////////////////////////////////////////////////////////////\n\n\t\thook(\"documentation:read\", documentationRead);\n\t},\n});\n"],"names":["defineSliceMachinePlugin","pkgName","projectInit","writeProjectEnvironment","PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME","DEFAULT_ENVIRONMENT_VARIABLE_FILE_PATH","readProjectEnvironment","ENVIRONMENT_VARIABLE_PATHS","sliceCreate","writeSliceModel","upsertGlobalTypeScriptTypes","renameSlice","rejectIfNecessary","upsertSliceLibraryIndexFile","deleteSliceDirectory","readSliceModel","writeSliceFile","deleteSliceFile","readSliceFile","readSliceLibrary","readSliceTemplateLibrary","fileURLToPath","Hero","CustomerLogos","AlternateGrid","CallToAction","writeCustomTypeModel","renameCustomType","deleteCustomTypeDirectory","updateCustomTypeRoute","pageRouteCreate","readCustomTypeModel","writeCustomTypeFile","deleteCustomTypeFile","readCustomTypeFile","readCustomTypeLibrary","snippetRead","documentationRead"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmDO,MAAM,SAASA,UAAAA,yBAAwC;AAAA,EAC7D,MAAM;AAAA,IACL,MAAMC,SAAAA;AAAAA,EAAA;AAAA,EAEP,gBAAgB;AAAA,IACf,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAAA;AAAA,EAEjB,MAAM,EAAE,QAAM;AAKb,SAAK,gBAAgBC,uBAAW;AAChC,SAAK,8B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QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAAA,IACF,CAAC;AACD,SAAK,0BAA0B,OAAO,MAAM,YAAW;AACtD,YAAM,OAAO,MAAMC,sBAAmB;AAAA,QACrC,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,QACf,GAAG;AAAA,MAAA,CACH;AAED,aAAO;AAAA,QACN,MAAM;AAAA,MAAA;AAAA,IAER,CAAC;AAMD,SAAK,4BAA4B,OAAO,OAAO,YAAW;AACzD,aAAO,MAAMC,GAAAA,sBAAsB;AAAA,QAClC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAAA,IACF,CAAC;AAMD,SAAK,gBAAgBC,uBAAW;AAMhC,SAAK,sBAAsBC,mCAAiB;AAAA,EAC7C;AACA,CAAA;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path__default from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { defineSliceMachinePlugin } from "@slicemachine/plugin-kit";
|
|
4
|
-
import { writeProjectEnvironment, readProjectEnvironment, writeSliceModel, upsertGlobalTypeScriptTypes, renameSlice, deleteSliceDirectory, readSliceModel, writeSliceFile, deleteSliceFile, readSliceFile, readSliceLibrary, readSliceTemplateLibrary, writeCustomTypeModel, renameCustomType, deleteCustomTypeDirectory, readCustomTypeModel, writeCustomTypeFile, deleteCustomTypeFile, readCustomTypeFile, readCustomTypeLibrary } from "@slicemachine/plugin-kit/fs";
|
|
4
|
+
import { writeProjectEnvironment, readProjectEnvironment, writeSliceModel, upsertGlobalTypeScriptTypes, renameSlice, deleteSliceDirectory, readSliceModel, writeSliceFile, deleteSliceFile, readSliceFile, readSliceLibrary, readSliceTemplateLibrary, writeCustomTypeModel, renameCustomType, deleteCustomTypeDirectory, updateCustomTypeRoute, readCustomTypeModel, writeCustomTypeFile, deleteCustomTypeFile, readCustomTypeFile, readCustomTypeLibrary } from "@slicemachine/plugin-kit/fs";
|
|
5
5
|
import { rejectIfNecessary } from "./lib/rejectIfNecessary.js";
|
|
6
6
|
import { upsertSliceLibraryIndexFile } from "./lib/upsertSliceLibraryIndexFile.js";
|
|
7
7
|
import { name } from "./packages/adapter-next/package.json.js";
|
|
@@ -10,6 +10,7 @@ import { documentationRead } from "./hooks/documentation-read.js";
|
|
|
10
10
|
import { projectInit } from "./hooks/project-init.js";
|
|
11
11
|
import { sliceCreate } from "./hooks/slice-create.js";
|
|
12
12
|
import { snippetRead } from "./hooks/snippet-read.js";
|
|
13
|
+
import { pageRouteCreate } from "./hooks/page-route-create.js";
|
|
13
14
|
import * as index from "./sliceTemplates/Hero/index.js";
|
|
14
15
|
import * as index$3 from "./sliceTemplates/CallToAction/index.js";
|
|
15
16
|
import * as index$2 from "./sliceTemplates/AlternateGrid/index.js";
|
|
@@ -195,6 +196,13 @@ const plugin = defineSliceMachinePlugin({
|
|
|
195
196
|
...context
|
|
196
197
|
});
|
|
197
198
|
});
|
|
199
|
+
hook("custom-type:update-route", async (data, context) => {
|
|
200
|
+
await updateCustomTypeRoute({
|
|
201
|
+
model: data.model,
|
|
202
|
+
...context
|
|
203
|
+
});
|
|
204
|
+
await pageRouteCreate(data, context);
|
|
205
|
+
});
|
|
198
206
|
hook("custom-type:read", async (data, context) => {
|
|
199
207
|
return await readCustomTypeModel({
|
|
200
208
|
customTypeID: data.id,
|