@slicemachine/adapter-sveltekit 0.3.78-beta.9 → 0.3.79-alpha.jp-fix-cr-modal-rules-of-hooks.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/AlternateGrid/javascript.4.svelte +227 -0
- package/dist/AlternateGrid/javascript.svelte +6 -5
- package/dist/AlternateGrid/typescript.4.svelte +224 -0
- package/dist/AlternateGrid/typescript.svelte +9 -4
- package/dist/CallToAction/javascript.4.svelte +127 -0
- package/dist/CallToAction/javascript.svelte +6 -5
- package/dist/CallToAction/typescript.4.svelte +124 -0
- package/dist/CallToAction/typescript.svelte +4 -2
- package/dist/CustomerLogos/javascript.4.svelte +124 -0
- package/dist/CustomerLogos/javascript.svelte +6 -5
- package/dist/CustomerLogos/typescript.4.svelte +121 -0
- package/dist/CustomerLogos/typescript.svelte +4 -2
- package/dist/Hero/javascript.4.svelte +190 -0
- package/dist/Hero/javascript.svelte +5 -4
- package/dist/Hero/typescript.4.svelte +187 -0
- package/dist/Hero/typescript.svelte +4 -2
- package/dist/hooks/documentation-read.cjs +14 -51
- package/dist/hooks/documentation-read.cjs.map +1 -1
- package/dist/hooks/documentation-read.js +14 -51
- package/dist/hooks/documentation-read.js.map +1 -1
- package/dist/hooks/documentation-read.templates.cjs +114 -0
- package/dist/hooks/documentation-read.templates.cjs.map +1 -0
- package/dist/hooks/documentation-read.templates.d.ts +9 -0
- package/dist/hooks/documentation-read.templates.js +114 -0
- package/dist/hooks/documentation-read.templates.js.map +1 -0
- package/dist/hooks/project-init.cjs +44 -143
- package/dist/hooks/project-init.cjs.map +1 -1
- package/dist/hooks/project-init.js +44 -143
- package/dist/hooks/project-init.js.map +1 -1
- package/dist/hooks/project-init.templates.cjs +181 -0
- package/dist/hooks/project-init.templates.cjs.map +1 -0
- package/dist/hooks/project-init.templates.d.ts +12 -0
- package/dist/hooks/project-init.templates.js +181 -0
- package/dist/hooks/project-init.templates.js.map +1 -0
- package/dist/hooks/slice-create.cjs +5 -52
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +5 -52
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/hooks/slice-create.templates.cjs +61 -0
- package/dist/hooks/slice-create.templates.cjs.map +1 -0
- package/dist/hooks/slice-create.templates.d.ts +6 -0
- package/dist/hooks/slice-create.templates.js +61 -0
- package/dist/hooks/slice-create.templates.js.map +1 -0
- package/dist/lib/getSvelteMajor.cjs +38 -0
- package/dist/lib/getSvelteMajor.cjs.map +1 -0
- package/dist/lib/getSvelteMajor.d.ts +1 -0
- package/dist/lib/getSvelteMajor.js +16 -0
- package/dist/lib/getSvelteMajor.js.map +1 -0
- package/dist/lib/requireResolve.cjs +16 -0
- package/dist/lib/requireResolve.cjs.map +1 -0
- package/dist/lib/requireResolve.d.ts +10 -0
- package/dist/lib/requireResolve.js +16 -0
- package/dist/lib/requireResolve.js.map +1 -0
- package/dist/plugin.cjs +4 -2
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +4 -2
- package/dist/plugin.js.map +1 -1
- package/dist/simulator/SliceSimulator.svelte +3 -2
- package/dist/simulator/SliceSimulator.svelte.d.ts +7 -19
- package/package.json +8 -7
- package/src/hooks/documentation-read.templates.ts +170 -0
- package/src/hooks/documentation-read.ts +21 -59
- package/src/hooks/project-init.templates.ts +208 -0
- package/src/hooks/project-init.ts +57 -147
- package/src/hooks/slice-create.templates.ts +103 -0
- package/src/hooks/slice-create.ts +7 -66
- package/src/lib/getSvelteMajor.ts +23 -0
- package/src/lib/requireResolve.ts +30 -0
- package/src/plugin.ts +5 -2
- package/src/simulator/SliceSimulator.svelte +3 -2
@@ -0,0 +1,114 @@
|
|
1
|
+
import { source } from "common-tags";
|
2
|
+
var __freeze = Object.freeze;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
5
|
+
var _a, _b, _c, _d;
|
6
|
+
function dataFileTemplate(args) {
|
7
|
+
const { model, typescript } = args;
|
8
|
+
const repeatableTS = source`
|
9
|
+
import { createClient } from "$lib/prismicio";
|
10
|
+
import type { PageServerLoad, EntryGenerator } from './$types';
|
11
|
+
|
12
|
+
export const load: PageServerLoad = async ({ params, fetch, cookies }) => {
|
13
|
+
const client = createClient({ fetch, cookies });
|
14
|
+
|
15
|
+
const page = await client.getByUID("${model.id}", params.uid);
|
16
|
+
|
17
|
+
return {
|
18
|
+
page,
|
19
|
+
};
|
20
|
+
}
|
21
|
+
|
22
|
+
export const entries: EntryGenerator = async () => {
|
23
|
+
const client = createClient();
|
24
|
+
|
25
|
+
const pages = await client.getAllByType("${model.id}");
|
26
|
+
|
27
|
+
return pages.map((page) => {
|
28
|
+
return { uid: page.uid };
|
29
|
+
});
|
30
|
+
}
|
31
|
+
`;
|
32
|
+
const nonrepeatableTS = source`
|
33
|
+
import { createClient } from "$lib/prismicio";
|
34
|
+
import type { PageServerLoad, EntryGenerator } from './$types';
|
35
|
+
|
36
|
+
export const load: PageServerLoad = async ({ params, fetch, cookies }) => {
|
37
|
+
const client = createClient({ fetch, cookies });
|
38
|
+
|
39
|
+
const page = await client.getSingle("${model.id}");
|
40
|
+
|
41
|
+
return {
|
42
|
+
page,
|
43
|
+
};
|
44
|
+
}
|
45
|
+
|
46
|
+
export const entries: EntryGenerator = async () => {
|
47
|
+
return [{}]
|
48
|
+
}
|
49
|
+
`;
|
50
|
+
const repeatableJS = source`
|
51
|
+
import { createClient } from "$lib/prismicio";
|
52
|
+
|
53
|
+
/* @type {import("./$types").PageServerLoad} */
|
54
|
+
export async function load({ params, fetch, cookies }) {
|
55
|
+
const client = createClient({ fetch, cookies });
|
56
|
+
|
57
|
+
const page = await client.getByUID("${model.id}", params.uid);
|
58
|
+
|
59
|
+
return {
|
60
|
+
page,
|
61
|
+
};
|
62
|
+
}
|
63
|
+
|
64
|
+
/* @type {import("./$types").EntryGenerator} */
|
65
|
+
export async function entries() {
|
66
|
+
const client = createClient();
|
67
|
+
|
68
|
+
const pages = await client.getAllByType("${model.id}");
|
69
|
+
|
70
|
+
return pages.map((page) => {
|
71
|
+
return { uid: page.uid };
|
72
|
+
});
|
73
|
+
}
|
74
|
+
`;
|
75
|
+
const nonrepeatableJS = source`
|
76
|
+
import { createClient } from "$lib/prismicio";
|
77
|
+
|
78
|
+
/* @type {import("./$types").PageServerLoad} */
|
79
|
+
export async function load({ params, fetch, cookies }) {
|
80
|
+
const client = createClient({ fetch, cookies });
|
81
|
+
|
82
|
+
const page = await client.getSingle("${model.id}");
|
83
|
+
|
84
|
+
return {
|
85
|
+
page,
|
86
|
+
};
|
87
|
+
}
|
88
|
+
|
89
|
+
/* @type {import("./$types").EntryGenerator} */
|
90
|
+
export async function entries() {
|
91
|
+
return [{}]
|
92
|
+
}
|
93
|
+
`;
|
94
|
+
if (typescript) {
|
95
|
+
return model.repeatable ? repeatableTS : nonrepeatableTS;
|
96
|
+
}
|
97
|
+
return model.repeatable ? repeatableJS : nonrepeatableJS;
|
98
|
+
}
|
99
|
+
function componentFileTemplate(args) {
|
100
|
+
const { typescript, version } = args;
|
101
|
+
const v5TS = source(_a || (_a = __template(['\n <script lang="ts">\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n import type { PageProps } from "./$types";\n\n const { data }: PageProps = $props();\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
|
102
|
+
const v5JS = source(_b || (_b = __template(['\n <script>\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n\n /* @type {import("./$types").PageProps} */\n const { data } = $props();\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
|
103
|
+
const v4TS = source(_c || (_c = __template(['\n <script lang="ts">\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n import type { PageData } from "./$types";\n\n export let data: PageData;\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
|
104
|
+
const v4JS = source(_d || (_d = __template(['\n <script>\n import { SliceZone } from "@prismicio/svelte";\n\n import { components } from "$lib/slices";\n\n /* @type {import("./$types").PageData} */\n export let data;\n <\/script>\n\n <SliceZone slices={data.page.data.slices} {components} />\n '])));
|
105
|
+
if (typescript) {
|
106
|
+
return version <= 4 ? v4TS : v5TS;
|
107
|
+
}
|
108
|
+
return version <= 4 ? v4JS : v5JS;
|
109
|
+
}
|
110
|
+
export {
|
111
|
+
componentFileTemplate,
|
112
|
+
dataFileTemplate
|
113
|
+
};
|
114
|
+
//# sourceMappingURL=documentation-read.templates.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"documentation-read.templates.js","sources":["../../../src/hooks/documentation-read.templates.ts"],"sourcesContent":["import { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport { source as svelte, source as ts, source as js } from \"common-tags\";\n\nexport function dataFileTemplate(args: {\n\tmodel: CustomType;\n\ttypescript: boolean;\n}): string {\n\tconst { model, typescript } = args;\n\n\tconst repeatableTS = ts`\n\t\timport { createClient } from \"$lib/prismicio\";\n\t\timport type { PageServerLoad, EntryGenerator } from './$types';\n\n\t\texport const load: PageServerLoad = async ({ params, fetch, cookies }) => {\n\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\treturn {\n\t\t\t\tpage,\n\t\t\t};\n\t\t}\n\n\t\texport const entries: EntryGenerator = async () => {\n\t\t\tconst client = createClient();\n\n\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\treturn pages.map((page) => {\n\t\t\t\treturn { uid: page.uid };\n\t\t\t});\n\t\t}\n\t`;\n\n\tconst nonrepeatableTS = ts`\n\t\timport { createClient } from \"$lib/prismicio\";\n\t\timport type { PageServerLoad, EntryGenerator } from './$types';\n\n\t\texport const load: PageServerLoad = async ({ params, fetch, cookies }) => {\n\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\treturn {\n\t\t\t\tpage,\n\t\t\t};\n\t\t}\n\n\t\texport const entries: EntryGenerator = async () => {\n\t\t\treturn [{}]\n\t\t}\n\t`;\n\n\tconst repeatableJS = js`\n\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t/* @type {import(\"./$types\").PageServerLoad} */\n\t\texport async function load({ params, fetch, cookies }) {\n\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\tconst page = await client.getByUID(\"${model.id}\", params.uid);\n\n\t\t\treturn {\n\t\t\t\tpage,\n\t\t\t};\n\t\t}\n\n\t\t/* @type {import(\"./$types\").EntryGenerator} */\n\t\texport async function entries() {\n\t\t\tconst client = createClient();\n\n\t\t\tconst pages = await client.getAllByType(\"${model.id}\");\n\n\t\t\treturn pages.map((page) => {\n\t\t\t\treturn { uid: page.uid };\n\t\t\t});\n\t\t}\n\t`;\n\n\tconst nonrepeatableJS = js`\n\t\timport { createClient } from \"$lib/prismicio\";\n\n\t\t/* @type {import(\"./$types\").PageServerLoad} */\n\t\texport async function load({ params, fetch, cookies }) {\n\t\t\tconst client = createClient({ fetch, cookies });\n\n\t\t\tconst page = await client.getSingle(\"${model.id}\");\n\n\t\t\treturn {\n\t\t\t\tpage,\n\t\t\t};\n\t\t}\n\n\t\t/* @type {import(\"./$types\").EntryGenerator} */\n\t\texport async function entries() {\n\t\t\treturn [{}]\n\t\t}\n\t`;\n\n\tif (typescript) {\n\t\treturn model.repeatable ? repeatableTS : nonrepeatableTS;\n\t}\n\n\treturn model.repeatable ? repeatableJS : nonrepeatableJS;\n}\n\nexport function componentFileTemplate(args: {\n\ttypescript: boolean;\n\tversion: number;\n}): string {\n\tconst { typescript, version } = args;\n\n\tconst v5TS = svelte`\n\t\t<script lang=\"ts\">\n\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\timport { components } from \"$lib/slices\";\n\t\t\timport type { PageProps } from \"./$types\";\n\n\t\t\tconst { data }: PageProps = $props();\n\t\t</script>\n\n\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t`;\n\n\tconst v5JS = svelte`\n\t\t<script>\n\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\timport { components } from \"$lib/slices\";\n\n\t\t\t/* @type {import(\"./$types\").PageProps} */\n\t\t\tconst { data } = $props();\n\t\t</script>\n\n\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t`;\n\n\tconst v4TS = svelte`\n\t\t<script lang=\"ts\">\n\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\timport { components } from \"$lib/slices\";\n\t\t\timport type { PageData } from \"./$types\";\n\n\t\t\texport let data: PageData;\n\t\t</script>\n\n\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t`;\n\n\tconst v4JS = svelte`\n\t\t<script>\n\t\t\timport { SliceZone } from \"@prismicio/svelte\";\n\n\t\t\timport { components } from \"$lib/slices\";\n\n\t\t\t/* @type {import(\"./$types\").PageData} */\n\t\t\texport let data;\n\t\t</script>\n\n\t\t<SliceZone slices={data.page.data.slices} {components} />\n\t`;\n\n\tif (typescript) {\n\t\treturn version <= 4 ? v4TS : v5TS;\n\t}\n\n\treturn version <= 4 ? v4JS : v5JS;\n}\n"],"names":["ts","js","svelte"],"mappings":";;;;AACA,IAAA,IAAA,IAAA,IAAA;AAEM,SAAU,iBAAiB,MAGhC;AACM,QAAA,EAAE,OAAO,WAAe,IAAA;AAE9B,QAAM,eAAeA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,yCAOmB,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8CAUH,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQrD,QAAM,kBAAkBA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,0CAOiB,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYjD,QAAM,eAAeC;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,yCAOmB,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8CAWH,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQrD,QAAM,kBAAkBA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,0CAOiB,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAajD,MAAI,YAAY;AACR,WAAA,MAAM,aAAa,eAAe;AAAA,EAC1C;AAEO,SAAA,MAAM,aAAa,eAAe;AAC1C;AAEM,SAAU,sBAAsB,MAGrC;AACM,QAAA,EAAE,YAAY,QAAY,IAAA;AAEhC,QAAM,OAAOC,OAAM,OAAA,KAAA,WAAA,CAAA,sSAAA,CAAA,EAAA;AAanB,QAAM,OAAOA,OAAM,OAAA,KAAA,WAAA,CAAA,iRAAA,CAAA,EAAA;AAanB,QAAM,OAAOA,OAAM,OAAA,KAAA,WAAA,CAAA,0RAAA,CAAA,EAAA;AAanB,QAAM,OAAOA,OAAM,OAAA,KAAA,WAAA,CAAA,sQAAA,CAAA,EAAA;AAanB,MAAI,YAAY;AACR,WAAA,WAAW,IAAI,OAAO;AAAA,EAC9B;AAEO,SAAA,WAAW,IAAI,OAAO;AAC9B;"}
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const path = require("node:path");
|
4
4
|
const fs = require("@slicemachine/plugin-kit/fs");
|
5
5
|
const commonTags = require("common-tags");
|
6
|
+
const magicast = require("magicast");
|
6
7
|
const checkIsTypeScriptProject = require("../lib/checkIsTypeScriptProject.cjs");
|
7
8
|
const getJSFileExtension = require("../lib/getJSFileExtension.cjs");
|
9
|
+
const getSvelteMajor = require("../lib/getSvelteMajor.cjs");
|
8
10
|
const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
|
9
11
|
const upsertSliceLibraryIndexFile = require("../lib/upsertSliceLibraryIndexFile.cjs");
|
10
|
-
const
|
12
|
+
const projectInit_templates = require("./project-init.templates.cjs");
|
11
13
|
function _interopNamespaceDefault(e) {
|
12
14
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
13
15
|
if (e) {
|
@@ -25,10 +27,6 @@ function _interopNamespaceDefault(e) {
|
|
25
27
|
return Object.freeze(n);
|
26
28
|
}
|
27
29
|
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
28
|
-
var __freeze = Object.freeze;
|
29
|
-
var __defProp = Object.defineProperty;
|
30
|
-
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
31
|
-
var _a, _b;
|
32
30
|
const installDependencies = async ({ installDependencies: installDependencies2 }) => {
|
33
31
|
await installDependencies2({
|
34
32
|
dependencies: {
|
@@ -38,113 +36,13 @@ const installDependencies = async ({ installDependencies: installDependencies2 }
|
|
38
36
|
});
|
39
37
|
};
|
40
38
|
const createPrismicIOFile = async ({ helpers, options }) => {
|
41
|
-
const isTypeScriptProject = await checkIsTypeScriptProject.checkIsTypeScriptProject({
|
42
|
-
helpers,
|
43
|
-
options
|
44
|
-
});
|
45
39
|
const extension = await getJSFileExtension.getJSFileExtension({ helpers, options });
|
46
40
|
const filename = path__namespace.join(`src/lib/prismicio.${extension}`);
|
47
41
|
if (await fs.checkHasProjectFile({ filename, helpers })) {
|
48
42
|
return;
|
49
43
|
}
|
50
|
-
|
51
|
-
|
52
|
-
contents = commonTags.source`
|
53
|
-
import * as prismic from "@prismicio/client";
|
54
|
-
import { type CreateClientConfig, enableAutoPreviews } from '@prismicio/svelte/kit';
|
55
|
-
import config from "../../slicemachine.config.json";
|
56
|
-
|
57
|
-
/**
|
58
|
-
* The project's Prismic repository name.
|
59
|
-
*/
|
60
|
-
export const repositoryName =
|
61
|
-
import${"."}meta${"."}env.${constants.PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || config.repositoryName;
|
62
|
-
|
63
|
-
/**
|
64
|
-
* A list of Route Resolver objects that define how a document's \`url\` field is resolved.
|
65
|
-
*
|
66
|
-
* {@link https://prismic.io/docs/route-resolver#route-resolver}
|
67
|
-
*/
|
68
|
-
// TODO: Update the routes array to match your project's route structure.
|
69
|
-
const routes: prismic.ClientConfig["routes"] = [
|
70
|
-
// Examples:
|
71
|
-
// {
|
72
|
-
// type: "homepage",
|
73
|
-
// path: "/",
|
74
|
-
// },
|
75
|
-
// {
|
76
|
-
// type: "page",
|
77
|
-
// path: "/:uid",
|
78
|
-
// },
|
79
|
-
];
|
80
|
-
|
81
|
-
/**
|
82
|
-
* Creates a Prismic client for the project's repository. The client is used to
|
83
|
-
* query content from the Prismic API.
|
84
|
-
*
|
85
|
-
* @param config - Configuration for the Prismic client.
|
86
|
-
*/
|
87
|
-
export const createClient = ({ cookies, ...config }: CreateClientConfig = {}) => {
|
88
|
-
const client = prismic.createClient(repositoryName, {
|
89
|
-
routes,
|
90
|
-
...config,
|
91
|
-
});
|
92
|
-
|
93
|
-
enableAutoPreviews({ client, cookies });
|
94
|
-
|
95
|
-
return client;
|
96
|
-
};
|
97
|
-
`;
|
98
|
-
} else {
|
99
|
-
contents = commonTags.source`
|
100
|
-
import * as prismic from "@prismicio/client";
|
101
|
-
import { enableAutoPreviews } from '@prismicio/svelte/kit';
|
102
|
-
import config from "../../slicemachine.config.json";
|
103
|
-
|
104
|
-
/**
|
105
|
-
* The project's Prismic repository name.
|
106
|
-
*/
|
107
|
-
export const repositoryName =
|
108
|
-
import${"."}meta${"."}env.${constants.PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || config.repositoryName;
|
109
|
-
|
110
|
-
/**
|
111
|
-
* A list of Route Resolver objects that define how a document's \`url\` field is resolved.
|
112
|
-
*
|
113
|
-
* {@link https://prismic.io/docs/route-resolver#route-resolver}
|
114
|
-
*
|
115
|
-
* @type {prismic.ClientConfig["routes"]}
|
116
|
-
*/
|
117
|
-
// TODO: Update the routes array to match your project's route structure.
|
118
|
-
const routes = [
|
119
|
-
// Examples:
|
120
|
-
// {
|
121
|
-
// type: "homepage",
|
122
|
-
// path: "/",
|
123
|
-
// },
|
124
|
-
// {
|
125
|
-
// type: "page",
|
126
|
-
// path: "/:uid",
|
127
|
-
// },
|
128
|
-
];
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Creates a Prismic client for the project's repository. The client is used to
|
132
|
-
* query content from the Prismic API.
|
133
|
-
*
|
134
|
-
* @param {import('@prismicio/svelte/kit').CreateClientConfig} config - Configuration for the Prismic client.
|
135
|
-
*/
|
136
|
-
export const createClient = ({ cookies, ...config } = {}) => {
|
137
|
-
const client = prismic.createClient(repositoryName, {
|
138
|
-
routes,
|
139
|
-
...config,
|
140
|
-
});
|
141
|
-
|
142
|
-
enableAutoPreviews({ client, cookies });
|
143
|
-
|
144
|
-
return client;
|
145
|
-
};
|
146
|
-
`;
|
147
|
-
}
|
44
|
+
const typescript = await checkIsTypeScriptProject.checkIsTypeScriptProject({ helpers, options });
|
45
|
+
const contents = projectInit_templates.prismicIOFileTemplate({ typescript });
|
148
46
|
await fs.writeProjectFile({
|
149
47
|
filename,
|
150
48
|
contents,
|
@@ -157,7 +55,9 @@ const createSliceSimulatorPage = async ({ helpers, options }) => {
|
|
157
55
|
if (await fs.checkHasProjectFile({ filename, helpers })) {
|
158
56
|
return;
|
159
57
|
}
|
160
|
-
const contents =
|
58
|
+
const contents = projectInit_templates.sliceSimulatorPageTemplate({
|
59
|
+
version: await getSvelteMajor.getSvelteMajor()
|
60
|
+
});
|
161
61
|
await fs.writeProjectFile({
|
162
62
|
filename,
|
163
63
|
contents,
|
@@ -195,16 +95,8 @@ const createPreviewAPIRoute = async ({ helpers, options }) => {
|
|
195
95
|
if (await fs.checkHasProjectFile({ filename, helpers })) {
|
196
96
|
return;
|
197
97
|
}
|
198
|
-
const
|
199
|
-
|
200
|
-
import { createClient } from '$lib/prismicio';
|
201
|
-
|
202
|
-
export async function GET({ fetch, request, cookies }) {
|
203
|
-
const client = createClient({ fetch });
|
204
|
-
|
205
|
-
return await redirectToPreviewURL({ client, request, cookies });
|
206
|
-
}
|
207
|
-
`;
|
98
|
+
const typescript = await checkIsTypeScriptProject.checkIsTypeScriptProject({ helpers, options });
|
99
|
+
const contents = projectInit_templates.previewAPIRouteTemplate({ typescript });
|
208
100
|
await fs.writeProjectFile({
|
209
101
|
filename,
|
210
102
|
contents,
|
@@ -255,28 +147,7 @@ const createRootLayoutFile = async ({ helpers, options }) => {
|
|
255
147
|
if (await fs.checkHasProjectFile({ filename, helpers })) {
|
256
148
|
return;
|
257
149
|
}
|
258
|
-
const contents =
|
259
|
-
<script>
|
260
|
-
import { isFilled, asImageSrc } from '@prismicio/client';
|
261
|
-
import { PrismicPreview } from '@prismicio/svelte/kit';
|
262
|
-
import { page } from '$app/state';
|
263
|
-
import { repositoryName } from '$lib/prismicio';
|
264
|
-
<\/script>
|
265
|
-
|
266
|
-
<svelte:head>
|
267
|
-
<title>{page.data.page?.data.meta_title}</title>
|
268
|
-
<meta property="og:title" content={page.data.page?.data.meta_title} />
|
269
|
-
{#if isFilled.keyText(page.data.page?.data.meta_description)}
|
270
|
-
<meta name="description" content={page.data.page.data.meta_description} />
|
271
|
-
<meta property="og:description" content={page.data.page.data.meta_description} />
|
272
|
-
{/if}
|
273
|
-
{#if isFilled.image(page.data.page?.data.meta_image)}
|
274
|
-
<meta property="og:image" content={asImageSrc(page.data.page.data.meta_image)} />
|
275
|
-
{/if}
|
276
|
-
</svelte:head>
|
277
|
-
<slot />
|
278
|
-
<PrismicPreview {repositoryName} />
|
279
|
-
`])));
|
150
|
+
const contents = projectInit_templates.rootLayoutTemplate({ version: await getSvelteMajor.getSvelteMajor() });
|
280
151
|
await fs.writeProjectFile({
|
281
152
|
filename,
|
282
153
|
contents,
|
@@ -291,9 +162,9 @@ const createRootLayoutFile = async ({ helpers, options }) => {
|
|
291
162
|
});
|
292
163
|
};
|
293
164
|
const modifySliceMachineConfig = async ({ helpers, options, actions }) => {
|
294
|
-
var
|
165
|
+
var _a;
|
295
166
|
const project = await helpers.getProject();
|
296
|
-
(
|
167
|
+
(_a = project.config).localSliceSimulatorURL || (_a.localSliceSimulatorURL = "http://localhost:5173/slice-simulator");
|
297
168
|
if (await fs.checkHasProjectFile({
|
298
169
|
filename: "./src/lib",
|
299
170
|
helpers
|
@@ -318,6 +189,35 @@ const upsertSliceLibraryIndexFiles = async (context) => {
|
|
318
189
|
await upsertSliceLibraryIndexFile.upsertSliceLibraryIndexFile({ libraryID, ...context });
|
319
190
|
}));
|
320
191
|
};
|
192
|
+
const modifyViteConfig = async ({ helpers, options }) => {
|
193
|
+
var _a, _b;
|
194
|
+
let filename = "vite.config.js";
|
195
|
+
if (!await fs.checkHasProjectFile({ filename, helpers })) {
|
196
|
+
filename = "vite.config.ts";
|
197
|
+
}
|
198
|
+
if (!await fs.checkHasProjectFile({ filename, helpers })) {
|
199
|
+
return;
|
200
|
+
}
|
201
|
+
const filepath = helpers.joinPathFromRoot(filename);
|
202
|
+
const mod = await magicast.loadFile(filepath);
|
203
|
+
if (mod.exports.default.$type !== "function-call") {
|
204
|
+
return;
|
205
|
+
}
|
206
|
+
const config = mod.exports.default.$args[0];
|
207
|
+
config.server ?? (config.server = {});
|
208
|
+
(_a = config.server).fs ?? (_a.fs = {});
|
209
|
+
(_b = config.server.fs).allow ?? (_b.allow = []);
|
210
|
+
if (!config.server.fs.allow.includes("./slicemachine.config.json")) {
|
211
|
+
config.server.fs.allow.push("./slicemachine.config.json");
|
212
|
+
}
|
213
|
+
const contents = mod.generate().code.replace(/\n\s*\n(?=\s*server:)/, "\n");
|
214
|
+
await fs.writeProjectFile({
|
215
|
+
filename,
|
216
|
+
contents,
|
217
|
+
format: options.format,
|
218
|
+
helpers
|
219
|
+
});
|
220
|
+
};
|
321
221
|
const projectInit = async ({ installDependencies: _installDependencies }, context) => {
|
322
222
|
rejectIfNecessary.rejectIfNecessary(await Promise.allSettled([
|
323
223
|
installDependencies({ installDependencies: _installDependencies }),
|
@@ -328,7 +228,8 @@ const projectInit = async ({ installDependencies: _installDependencies }, contex
|
|
328
228
|
createPreviewRouteDirectory(context),
|
329
229
|
createPreviewRouteMatcherFile(context),
|
330
230
|
createRootLayoutServerFile(context),
|
331
|
-
createRootLayoutFile(context)
|
231
|
+
createRootLayoutFile(context),
|
232
|
+
modifyViteConfig(context)
|
332
233
|
]));
|
333
234
|
await upsertSliceLibraryIndexFiles(context);
|
334
235
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"project-init.cjs","sources":["../../../src/hooks/project-init.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport type {\n\tProjectInitHook,\n\tProjectInitHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\nimport { PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME } from \"../constants\";\n\ntype InstallDependenciesArgs = {\n\tinstallDependencies: ProjectInitHookData[\"installDependencies\"];\n};\n\nconst installDependencies = async ({\n\tinstallDependencies,\n}: InstallDependenciesArgs) => {\n\tawait installDependencies({\n\t\tdependencies: {\n\t\t\t\"@prismicio/client\": \"latest\",\n\t\t\t\"@prismicio/svelte\": \"latest\",\n\t\t},\n\t});\n};\n\ntype CreatePrismicIOFileArgs = SliceMachineContext<PluginOptions>;\n\nconst createPrismicIOFile = async ({\n\thelpers,\n\toptions,\n}: CreatePrismicIOFileArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = path.join(`src/lib/prismicio.${extension}`);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents: string;\n\n\tif (isTypeScriptProject) {\n\t\tcontents = source`\n\t\t\timport * as prismic from \"@prismicio/client\";\n\t\t\timport { type CreateClientConfig, enableAutoPreviews } from '@prismicio/svelte/kit';\n\t\t\timport config from \"../../slicemachine.config.json\";\n\n\t\t\t/**\n\t\t\t * The project's Prismic repository name.\n\t\t\t */\n\t\t\texport const repositoryName =\n\t\t\t\timport${\".\"}meta${\".\"}env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || config.repositoryName;\n\n\t\t\t/**\n\t\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t\t *\n\t\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t\t */\n\t\t\t// TODO: Update the routes array to match your project's route structure.\n\t\t\tconst routes: prismic.ClientConfig[\"routes\"] = [\n\t\t\t\t// Examples:\n\t\t\t\t// {\n\t\t\t\t// \ttype: \"homepage\",\n\t\t\t\t// \tpath: \"/\",\n\t\t\t\t// },\n\t\t\t\t// {\n\t\t\t\t// \ttype: \"page\",\n\t\t\t\t// \tpath: \"/:uid\",\n\t\t\t\t// },\n\t\t\t];\n\n\t\t\t/**\n\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t * query content from the Prismic API.\n\t\t\t *\n\t\t\t * @param config - Configuration for the Prismic client.\n\t\t\t */\n\t\t\texport const createClient = ({ cookies, ...config }: CreateClientConfig = {}) => {\n\t\t\t\tconst client = prismic.createClient(repositoryName, {\n\t\t\t\t\troutes,\n\t\t\t\t\t...config,\n\t\t\t\t});\n\n\t\t\t\tenableAutoPreviews({ client, cookies });\n\n\t\t\t\treturn client;\n\t\t\t};\n\t\t`;\n\t} else {\n\t\tcontents = source`\n\t\t\timport * as prismic from \"@prismicio/client\";\n\t\t\timport { enableAutoPreviews } from '@prismicio/svelte/kit';\n\t\t\timport config from \"../../slicemachine.config.json\";\n\n\t\t\t/**\n\t\t\t * The project's Prismic repository name.\n\t\t\t */\n\t\t\texport const repositoryName =\n\t\t\t\timport${\".\"}meta${\".\"}env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || config.repositoryName;\n\n\t\t\t/**\n\t\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t\t *\n\t\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t\t *\n\t\t\t * @type {prismic.ClientConfig[\"routes\"]}\n\t\t\t */\n\t\t\t// TODO: Update the routes array to match your project's route structure.\n\t\t\tconst routes = [\n\t\t\t\t// Examples:\n\t\t\t\t// {\n\t\t\t\t// \ttype: \"homepage\",\n\t\t\t\t// \tpath: \"/\",\n\t\t\t\t// },\n\t\t\t\t// {\n\t\t\t\t// \ttype: \"page\",\n\t\t\t\t// \tpath: \"/:uid\",\n\t\t\t\t// },\n\t\t\t];\n\n\t\t\t/**\n\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t * query content from the Prismic API.\n\t\t\t *\n\t\t\t * @param {import('@prismicio/svelte/kit').CreateClientConfig} config - Configuration for the Prismic client.\n\t\t\t */\n\t\t\texport const createClient = ({ cookies, ...config } = {}) => {\n\t\t\t\tconst client = prismic.createClient(repositoryName, {\n\t\t\t\t\troutes,\n\t\t\t\t\t...config,\n\t\t\t\t});\n\n\t\t\t\tenableAutoPreviews({ client, cookies });\n\n\t\t\t\treturn client;\n\t\t\t};\n\t\t`;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createSliceSimulatorPage = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst filename = path.join(\n\t\t\"src\",\n\t\t\"routes\",\n\t\t\"slice-simulator\",\n\t\t\"+page.svelte\",\n\t);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\t<script>\n\t\t\timport { SliceSimulator } from '@slicemachine/adapter-sveltekit/simulator';\n\t\t\timport { SliceZone } from '@prismicio/svelte';\n\t\t\timport { components } from '$lib/slices';\n\t\t</script>\n\n\t\t<SliceSimulator let:slices>\n\t\t\t<SliceZone {slices} {components} />\n\t\t</SliceSimulator>\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t\thelpers,\n\t});\n};\n\nconst createPreviewRouteMatcherFile = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = path.join(`src/params/preview.${extension}`);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\texport function match(param) {\n\t\t\treturn param === 'preview';\n\t\t}\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createPreviewAPIRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = path.join(\n\t\t\"src\",\n\t\t\"routes\",\n\t\t\"api\",\n\t\t\"preview\",\n\t\t`+server.${extension}`,\n\t);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\timport { redirectToPreviewURL } from '@prismicio/svelte/kit';\n\t\timport { createClient } from '$lib/prismicio';\n\n\t\texport async function GET({ fetch, request, cookies }) {\n\t\t\tconst client = createClient({ fetch });\n\n\t\t\treturn await redirectToPreviewURL({ client, request, cookies });\n\t\t}\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createPreviewRouteDirectory = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst filename = path.join(\n\t\t\"src\",\n\t\t\"routes\",\n\t\t\"[[preview=preview]]\",\n\t\t\"README.md\",\n\t);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\tThis directory adds support for optional \\`/preview\\` routes. Do not remove this directory.\n\n\t\tAll routes within this directory will be served using the following URLs:\n\n\t\t- \\`/example-route\\` (prerendered)\n\t\t- \\`/preview/example-route\\` (server-rendered)\n\n\t\tSee <https://prismic.io/docs/svelte-preview> for more information.\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createRootLayoutServerFile = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = path.join(`src/routes/+layout.server.${extension}`);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\texport const prerender = \"auto\";\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createRootLayoutFile = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst filename = path.join(\"src\", \"routes\", \"+layout.svelte\");\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\t<script>\n\t\t\timport { isFilled, asImageSrc } from '@prismicio/client';\n\t\t\timport { PrismicPreview } from '@prismicio/svelte/kit';\n\t\t\timport { page } from '$app/state';\n\t\t\timport { repositoryName } from '$lib/prismicio';\n\t\t</script>\n\n\t\t<svelte:head>\n\t\t\t<title>{page.data.page?.data.meta_title}</title>\n\t\t\t<meta property=\"og:title\" content={page.data.page?.data.meta_title} />\n\t\t\t{#if isFilled.keyText(page.data.page?.data.meta_description)}\n\t\t\t\t<meta name=\"description\" content={page.data.page.data.meta_description} />\n\t\t\t\t<meta property=\"og:description\" content={page.data.page.data.meta_description} />\n\t\t\t{/if}\n\t\t\t{#if isFilled.image(page.data.page?.data.meta_image)}\n\t\t\t\t<meta property=\"og:image\" content={asImageSrc(page.data.page.data.meta_image)} />\n\t\t\t{/if}\n\t\t</svelte:head>\n\t\t<slot />\n\t\t<PrismicPreview {repositoryName} />\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t\thelpers,\n\t});\n};\n\nconst modifySliceMachineConfig = async ({\n\thelpers,\n\toptions,\n\tactions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst project = await helpers.getProject();\n\n\t// Add Slice Simulator URL.\n\tproject.config.localSliceSimulatorURL ||=\n\t\t\"http://localhost:5173/slice-simulator\";\n\n\t// Nest the default Slice Library in the src directory if it exists and\n\t// is empty.\n\tif (\n\t\t(await checkHasProjectFile({\n\t\t\tfilename: \"./src/lib\",\n\t\t\thelpers,\n\t\t})) &&\n\t\tproject.config.libraries &&\n\t\tJSON.stringify(project.config.libraries) === JSON.stringify([\"./slices\"])\n\t) {\n\t\tconst sliceLibrary = await actions.readSliceLibrary({\n\t\t\tlibraryID: project.config.libraries[0],\n\t\t});\n\n\t\tif (sliceLibrary.sliceIDs.length < 1) {\n\t\t\tproject.config.libraries = [\"./src/lib/slices\"];\n\t\t}\n\t}\n\n\tawait helpers.updateSliceMachineConfig(project.config, {\n\t\tformat: options.format,\n\t});\n};\n\nconst upsertSliceLibraryIndexFiles = async (\n\tcontext: SliceMachineContext<PluginOptions>,\n) => {\n\t// We must use the `getProject()` helper to get the latest version of\n\t// the project config. The config may have been modified in\n\t// `modifySliceMachineConfig()` and will not be relfected in\n\t// `context.project`.\n\t// TODO: Automatically update the plugin runner's in-memory `project`\n\t// object when `updateSliceMachineConfig()` is called.\n\tconst project = await context.helpers.getProject();\n\n\tif (!project.config.libraries) {\n\t\treturn;\n\t}\n\n\tawait Promise.all(\n\t\tproject.config.libraries.map(async (libraryID) => {\n\t\t\tawait upsertSliceLibraryIndexFile({ libraryID, ...context });\n\t\t}),\n\t);\n};\n\nexport const projectInit: ProjectInitHook<PluginOptions> = async (\n\t{ installDependencies: _installDependencies },\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tinstallDependencies({ installDependencies: _installDependencies }),\n\t\t\tmodifySliceMachineConfig(context),\n\t\t\tcreatePrismicIOFile(context),\n\t\t\tcreateSliceSimulatorPage(context),\n\t\t\tcreatePreviewAPIRoute(context),\n\t\t\tcreatePreviewRouteDirectory(context),\n\t\t\tcreatePreviewRouteMatcherFile(context),\n\t\t\tcreateRootLayoutServerFile(context),\n\t\t\tcreateRootLayoutFile(context),\n\t\t]),\n\t);\n\n\t// This must happen after `modifySliceMachineConfig()` since the\n\t// location of the default Slice library may change.\n\tawait upsertSliceLibraryIndexFiles(context);\n};\n"],"names":["installDependencies","checkIsTypeScriptProject","getJSFileExtension","path","checkHasProjectFile","source","PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME","writeProjectFile","_a","upsertSliceLibraryIndexFile","rejectIfNecessary"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,IAAA;AAwBA,MAAM,sBAAsB,OAAO,EAClC,q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AE,qBAAqB,qBAAA,GACvB,YACG;AAEFC,sCAAA,MAAM,QAAQ,WAAW;AAAA,IACxB,oBAAoB,EAAE,qBAAqB,sBAAsB;AAAA,IACjE,yBAAyB,OAAO;AAAA,IAChC,oBAAoB,OAAO;AAAA,IAC3B,yBAAyB,OAAO;AAAA,IAChC,sBAAsB,OAAO;AAAA,IAC7B,4BAA4B,OAAO;AAAA,IACnC,8BAA8B,OAAO;AAAA,IACrC,2BAA2B,OAAO;AAAA,IAClC,qBAAqB,OAAO;AAAA,EAC5B,CAAA,CAAC;AAKH,QAAM,6BAA6B,OAAO;AAC3C;;"}
|
1
|
+
{"version":3,"file":"project-init.cjs","sources":["../../../src/hooks/project-init.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport type {\n\tProjectInitHook,\n\tProjectInitHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\nimport { loadFile } from \"magicast\";\n\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { getSvelteMajor } from \"../lib/getSvelteMajor\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\nimport {\n\tpreviewAPIRouteTemplate,\n\tprismicIOFileTemplate,\n\trootLayoutTemplate,\n\tsliceSimulatorPageTemplate,\n} from \"./project-init.templates\";\n\ntype InstallDependenciesArgs = {\n\tinstallDependencies: ProjectInitHookData[\"installDependencies\"];\n};\n\nconst installDependencies = async ({\n\tinstallDependencies,\n}: InstallDependenciesArgs) => {\n\tawait installDependencies({\n\t\tdependencies: {\n\t\t\t\"@prismicio/client\": \"latest\",\n\t\t\t\"@prismicio/svelte\": \"latest\",\n\t\t},\n\t});\n};\n\ntype CreatePrismicIOFileArgs = SliceMachineContext<PluginOptions>;\n\nconst createPrismicIOFile = async ({\n\thelpers,\n\toptions,\n}: CreatePrismicIOFileArgs) => {\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = path.join(`src/lib/prismicio.${extension}`);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst typescript = await checkIsTypeScriptProject({ helpers, options });\n\tconst contents = prismicIOFileTemplate({ typescript });\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createSliceSimulatorPage = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst filename = path.join(\n\t\t\"src\",\n\t\t\"routes\",\n\t\t\"slice-simulator\",\n\t\t\"+page.svelte\",\n\t);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = sliceSimulatorPageTemplate({\n\t\tversion: await getSvelteMajor(),\n\t});\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t\thelpers,\n\t});\n};\n\nconst createPreviewRouteMatcherFile = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = path.join(`src/params/preview.${extension}`);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\texport function match(param) {\n\t\t\treturn param === 'preview';\n\t\t}\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createPreviewAPIRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = path.join(\n\t\t\"src\",\n\t\t\"routes\",\n\t\t\"api\",\n\t\t\"preview\",\n\t\t`+server.${extension}`,\n\t);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst typescript = await checkIsTypeScriptProject({ helpers, options });\n\tconst contents = previewAPIRouteTemplate({ typescript });\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createPreviewRouteDirectory = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst filename = path.join(\n\t\t\"src\",\n\t\t\"routes\",\n\t\t\"[[preview=preview]]\",\n\t\t\"README.md\",\n\t);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\tThis directory adds support for optional \\`/preview\\` routes. Do not remove this directory.\n\n\t\tAll routes within this directory will be served using the following URLs:\n\n\t\t- \\`/example-route\\` (prerendered)\n\t\t- \\`/preview/example-route\\` (server-rendered)\n\n\t\tSee <https://prismic.io/docs/svelte-preview> for more information.\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createRootLayoutServerFile = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = path.join(`src/routes/+layout.server.${extension}`);\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\texport const prerender = \"auto\";\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createRootLayoutFile = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst filename = path.join(\"src\", \"routes\", \"+layout.svelte\");\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = rootLayoutTemplate({ version: await getSvelteMajor() });\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\tformatOptions: {\n\t\t\tprettier: {\n\t\t\t\tplugins: [\"prettier-plugin-svelte\"],\n\t\t\t\tparser: \"svelte\",\n\t\t\t},\n\t\t},\n\t\thelpers,\n\t});\n};\n\nconst modifySliceMachineConfig = async ({\n\thelpers,\n\toptions,\n\tactions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst project = await helpers.getProject();\n\n\t// Add Slice Simulator URL.\n\tproject.config.localSliceSimulatorURL ||=\n\t\t\"http://localhost:5173/slice-simulator\";\n\n\t// Nest the default Slice Library in the src directory if it exists and\n\t// is empty.\n\tif (\n\t\t(await checkHasProjectFile({\n\t\t\tfilename: \"./src/lib\",\n\t\t\thelpers,\n\t\t})) &&\n\t\tproject.config.libraries &&\n\t\tJSON.stringify(project.config.libraries) === JSON.stringify([\"./slices\"])\n\t) {\n\t\tconst sliceLibrary = await actions.readSliceLibrary({\n\t\t\tlibraryID: project.config.libraries[0],\n\t\t});\n\n\t\tif (sliceLibrary.sliceIDs.length < 1) {\n\t\t\tproject.config.libraries = [\"./src/lib/slices\"];\n\t\t}\n\t}\n\n\tawait helpers.updateSliceMachineConfig(project.config, {\n\t\tformat: options.format,\n\t});\n};\n\nconst upsertSliceLibraryIndexFiles = async (\n\tcontext: SliceMachineContext<PluginOptions>,\n) => {\n\t// We must use the `getProject()` helper to get the latest version of\n\t// the project config. The config may have been modified in\n\t// `modifySliceMachineConfig()` and will not be relfected in\n\t// `context.project`.\n\t// TODO: Automatically update the plugin runner's in-memory `project`\n\t// object when `updateSliceMachineConfig()` is called.\n\tconst project = await context.helpers.getProject();\n\n\tif (!project.config.libraries) {\n\t\treturn;\n\t}\n\n\tawait Promise.all(\n\t\tproject.config.libraries.map(async (libraryID) => {\n\t\t\tawait upsertSliceLibraryIndexFile({ libraryID, ...context });\n\t\t}),\n\t);\n};\n\nconst modifyViteConfig = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tlet filename = \"vite.config.js\";\n\tif (!(await checkHasProjectFile({ filename, helpers }))) {\n\t\tfilename = \"vite.config.ts\";\n\t}\n\tif (!(await checkHasProjectFile({ filename, helpers }))) {\n\t\t// Couldn't find the config file.\n\t\treturn;\n\t}\n\tconst filepath = helpers.joinPathFromRoot(filename);\n\n\tconst mod = await loadFile(filepath);\n\tif (mod.exports.default.$type !== \"function-call\") {\n\t\t// Invalid config file.\n\t\treturn;\n\t}\n\n\t// Add `./slicemachine.config.json` to allowed files.\n\tconst config = mod.exports.default.$args[0];\n\tconfig.server ??= {};\n\tconfig.server.fs ??= {};\n\tconfig.server.fs.allow ??= [];\n\tif (!config.server.fs.allow.includes(\"./slicemachine.config.json\")) {\n\t\tconfig.server.fs.allow.push(\"./slicemachine.config.json\");\n\t}\n\n\t// Remove an empty line above the `server` property.\n\tconst contents = mod.generate().code.replace(/\\n\\s*\\n(?=\\s*server:)/, \"\\n\");\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nexport const projectInit: ProjectInitHook<PluginOptions> = async (\n\t{ installDependencies: _installDependencies },\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tinstallDependencies({ installDependencies: _installDependencies }),\n\t\t\tmodifySliceMachineConfig(context),\n\t\t\tcreatePrismicIOFile(context),\n\t\t\tcreateSliceSimulatorPage(context),\n\t\t\tcreatePreviewAPIRoute(context),\n\t\t\tcreatePreviewRouteDirectory(context),\n\t\t\tcreatePreviewRouteMatcherFile(context),\n\t\t\tcreateRootLayoutServerFile(context),\n\t\t\tcreateRootLayoutFile(context),\n\t\t\tmodifyViteConfig(context),\n\t\t]),\n\t);\n\n\t// This must happen after `modifySliceMachineConfig()` since the\n\t// location of the default Slice library may change.\n\tawait upsertSliceLibraryIndexFiles(context);\n};\n"],"names":["installDependencies","getJSFileExtension","path","checkHasProjectFile","checkIsTypeScriptProject","prismicIOFileTemplate","writeProjectFile","sliceSimulatorPageTemplate","getSvelteMajor","source","previewAPIRouteTemplate","rootLayoutTemplate","upsertSliceLibraryIndexFile","loadFile","rejectIfNecessary"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,sBAAsB,OAAO,EAClC,qBAAAA,2BAC6B;AAC7B,QAAMA,qBAAoB;AAAA,IACzB,cAAc;AAAA,MACb,qBAAqB;AAAA,MACrB,qBAAqB;AAAA,IACrB;AAAA,EAAA,CACD;AACF;AAIA,MAAM,sBAAsB,OAAO,EAClC,SACA,cAC6B;AAC7B,QAAM,YAAY,MAAMC,mBAAA,mBAAmB,EAAE,SAAS,QAAS,CAAA;AAC/D,QAAM,WAAWC,gBAAK,KAAK,qBAAqB,SAAS,EAAE;AAE3D,MAAI,MAAMC,GAAAA,oBAAoB,EAAE,UAAU,QAAS,CAAA,GAAG;AACrD;AAAA,EACD;AAEA,QAAM,aAAa,MAAMC,yBAAA,yBAAyB,EAAE,SAAS,QAAS,CAAA;AACtE,QAAM,WAAWC,sBAAAA,sBAAsB,EAAE,WAAY,CAAA;AAErD,QAAMC,oBAAiB;AAAA,IACtB;AAAA,IACA;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,EAAA,CACA;AACF;AAEA,MAAM,2BAA2B,OAAO,EACvC,SACA,cACwC;AACxC,QAAM,WAAWJ,gBAAK,KACrB,OACA,UACA,mBACA,cAAc;AAGf,MAAI,MAAMC,GAAAA,oBAAoB,EAAE,UAAU,QAAS,CAAA,GAAG;AACrD;AAAA,EACD;AAEA,QAAM,WAAWI,sBAAAA,2BAA2B;AAAA,IAC3C,SAAS,MAAMC,eAAAA,eAAgB;AAAA,EAAA,CAC/B;A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