@slicemachine/adapter-nuxt 0.0.2-dev-plugins-m3.3 → 0.0.2-dev-plugins-m3.4
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.
|
@@ -26,22 +26,24 @@ const isCustomTypeModel = (input) => {
|
|
|
26
26
|
return typeof input === "object" && input !== null && "json" in input;
|
|
27
27
|
};
|
|
28
28
|
const customTypeLibraryRead = async (_data, { helpers }) => {
|
|
29
|
-
const
|
|
30
|
-
await fs__namespace.mkdir(
|
|
31
|
-
const childDirs = await fs__namespace.readdir(
|
|
29
|
+
const dir = buildCustomTypeLibraryDirectoryPath.buildCustomTypeLibraryDirectoryPath({ helpers });
|
|
30
|
+
await fs__namespace.mkdir(dir, { recursive: true });
|
|
31
|
+
const childDirs = await fs__namespace.readdir(dir, { withFileTypes: true });
|
|
32
32
|
const ids = [];
|
|
33
33
|
await Promise.all(childDirs.map(async (childDir) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
if (childDir.isDirectory()) {
|
|
35
|
+
const childDirContents = await fs__namespace.readdir(path__namespace.join(dir, childDir.name), {
|
|
36
|
+
withFileTypes: true
|
|
37
|
+
});
|
|
38
|
+
const isCustomTypeDir = childDirContents.some((entry) => {
|
|
39
|
+
return entry.isFile() && entry.name === "index.json";
|
|
40
|
+
});
|
|
41
|
+
if (isCustomTypeDir) {
|
|
42
|
+
const modelPath = path__namespace.join(dir, childDir.name, "index.json");
|
|
43
|
+
const modelContents = await readJSONFile.readJSONFile(modelPath);
|
|
44
|
+
if (isCustomTypeModel(modelContents)) {
|
|
45
|
+
ids.push(modelContents.id);
|
|
46
|
+
}
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypeLibrary-read.cjs","sources":["../../../src/hooks/customTypeLibrary-read.ts"],"sourcesContent":["import type { CustomTypeLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport type { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeLibraryDirectoryPath } from \"../lib/buildCustomTypeLibraryDirectoryPath\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst isCustomTypeModel = (\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinput: any,\n): input is CustomType => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nexport const customTypeLibraryRead: CustomTypeLibraryReadHook<\n\tPluginOptions\n> = async (_data, { helpers }) => {\n\tconst
|
|
1
|
+
{"version":3,"file":"customTypeLibrary-read.cjs","sources":["../../../src/hooks/customTypeLibrary-read.ts"],"sourcesContent":["import type { CustomTypeLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport type { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeLibraryDirectoryPath } from \"../lib/buildCustomTypeLibraryDirectoryPath\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst isCustomTypeModel = (\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinput: any,\n): input is CustomType => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nexport const customTypeLibraryRead: CustomTypeLibraryReadHook<\n\tPluginOptions\n> = async (_data, { helpers }) => {\n\tconst dir = buildCustomTypeLibraryDirectoryPath({ helpers });\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tconst childDirs = await fs.readdir(dir, { withFileTypes: true });\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(dir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isCustomTypeDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === \"index.json\";\n\t\t\t\t});\n\n\t\t\t\tif (isCustomTypeDir) {\n\t\t\t\t\tconst modelPath = path.join(dir, childDir.name, \"index.json\");\n\n\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\t\t\tids.push(modelContents.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n"],"names":["buildCustomTypeLibraryDirectoryPath","fs","path","readJSONFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,oBAAoB,CAEzB,UACwB;AACxB,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AACjE;AAEO,MAAM,wBAET,OAAO,OAAO,EAAE,cAAa;AAChC,QAAM,MAAMA,oCAAAA,oCAAoC,EAAE,QAAS,CAAA;AAG3D,QAAMC,cAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAEjC,QAAA,YAAY,MAAMA,cAAG,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE/D,QAAM,MAAgB,CAAA;AACtB,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AACrB,YAAA,mBAAmB,MAAMA,cAAG,QACjCC,gBAAK,KAAK,KAAK,SAAS,IAAI,GAC5B;AAAA,QACC,eAAe;AAAA,MAAA,CACf;AAEF,YAAM,kBAAkB,iBAAiB,KAAK,CAAC,UAAS;AACvD,eAAO,MAAM,OAAA,KAAY,MAAM,SAAS;AAAA,MAAA,CACxC;AAED,UAAI,iBAAiB;AACpB,cAAM,YAAYA,gBAAK,KAAK,KAAK,SAAS,MAAM,YAAY;AAEtD,cAAA,gBAAgB,MAAMC,0BAAa,SAAS;AAE9C,YAAA,kBAAkB,aAAa,GAAG;AACjC,cAAA,KAAK,cAAc,EAAE;AAAA,QACzB;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAA,CAAC;AAGI,SAAA;AAAA,IACN,KAAK,IAAI,KAAM;AAAA,EAAA;AAEjB;;"}
|
|
@@ -6,22 +6,24 @@ const isCustomTypeModel = (input) => {
|
|
|
6
6
|
return typeof input === "object" && input !== null && "json" in input;
|
|
7
7
|
};
|
|
8
8
|
const customTypeLibraryRead = async (_data, { helpers }) => {
|
|
9
|
-
const
|
|
10
|
-
await fs.mkdir(
|
|
11
|
-
const childDirs = await fs.readdir(
|
|
9
|
+
const dir = buildCustomTypeLibraryDirectoryPath({ helpers });
|
|
10
|
+
await fs.mkdir(dir, { recursive: true });
|
|
11
|
+
const childDirs = await fs.readdir(dir, { withFileTypes: true });
|
|
12
12
|
const ids = [];
|
|
13
13
|
await Promise.all(childDirs.map(async (childDir) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
if (childDir.isDirectory()) {
|
|
15
|
+
const childDirContents = await fs.readdir(path.join(dir, childDir.name), {
|
|
16
|
+
withFileTypes: true
|
|
17
|
+
});
|
|
18
|
+
const isCustomTypeDir = childDirContents.some((entry) => {
|
|
19
|
+
return entry.isFile() && entry.name === "index.json";
|
|
20
|
+
});
|
|
21
|
+
if (isCustomTypeDir) {
|
|
22
|
+
const modelPath = path.join(dir, childDir.name, "index.json");
|
|
23
|
+
const modelContents = await readJSONFile(modelPath);
|
|
24
|
+
if (isCustomTypeModel(modelContents)) {
|
|
25
|
+
ids.push(modelContents.id);
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customTypeLibrary-read.js","sources":["../../../src/hooks/customTypeLibrary-read.ts"],"sourcesContent":["import type { CustomTypeLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport type { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeLibraryDirectoryPath } from \"../lib/buildCustomTypeLibraryDirectoryPath\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst isCustomTypeModel = (\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinput: any,\n): input is CustomType => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nexport const customTypeLibraryRead: CustomTypeLibraryReadHook<\n\tPluginOptions\n> = async (_data, { helpers }) => {\n\tconst
|
|
1
|
+
{"version":3,"file":"customTypeLibrary-read.js","sources":["../../../src/hooks/customTypeLibrary-read.ts"],"sourcesContent":["import type { CustomTypeLibraryReadHook } from \"@slicemachine/plugin-kit\";\nimport type { CustomType } from \"@prismicio/types-internal/lib/customtypes\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { buildCustomTypeLibraryDirectoryPath } from \"../lib/buildCustomTypeLibraryDirectoryPath\";\nimport { readJSONFile } from \"../lib/readJSONFile\";\n\nimport type { PluginOptions } from \"../types\";\n\nconst isCustomTypeModel = (\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinput: any,\n): input is CustomType => {\n\treturn typeof input === \"object\" && input !== null && \"json\" in input;\n};\n\nexport const customTypeLibraryRead: CustomTypeLibraryReadHook<\n\tPluginOptions\n> = async (_data, { helpers }) => {\n\tconst dir = buildCustomTypeLibraryDirectoryPath({ helpers });\n\n\t// Ensure the directory exists.\n\tawait fs.mkdir(dir, { recursive: true });\n\n\tconst childDirs = await fs.readdir(dir, { withFileTypes: true });\n\n\tconst ids: string[] = [];\n\tawait Promise.all(\n\t\tchildDirs.map(async (childDir) => {\n\t\t\tif (childDir.isDirectory()) {\n\t\t\t\tconst childDirContents = await fs.readdir(\n\t\t\t\t\tpath.join(dir, childDir.name),\n\t\t\t\t\t{\n\t\t\t\t\t\twithFileTypes: true,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tconst isCustomTypeDir = childDirContents.some((entry) => {\n\t\t\t\t\treturn entry.isFile() && entry.name === \"index.json\";\n\t\t\t\t});\n\n\t\t\t\tif (isCustomTypeDir) {\n\t\t\t\t\tconst modelPath = path.join(dir, childDir.name, \"index.json\");\n\n\t\t\t\t\tconst modelContents = await readJSONFile(modelPath);\n\n\t\t\t\t\tif (isCustomTypeModel(modelContents)) {\n\t\t\t\t\t\tids.push(modelContents.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn {\n\t\tids: ids.sort(),\n\t};\n};\n"],"names":[],"mappings":";;;;AAUA,MAAM,oBAAoB,CAEzB,UACwB;AACxB,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AACjE;AAEO,MAAM,wBAET,OAAO,OAAO,EAAE,cAAa;AAChC,QAAM,MAAM,oCAAoC,EAAE,QAAS,CAAA;AAG3D,QAAM,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM;AAEjC,QAAA,YAAY,MAAM,GAAG,QAAQ,KAAK,EAAE,eAAe,MAAM;AAE/D,QAAM,MAAgB,CAAA;AACtB,QAAM,QAAQ,IACb,UAAU,IAAI,OAAO,aAAY;AAC5B,QAAA,SAAS,eAAe;AACrB,YAAA,mBAAmB,MAAM,GAAG,QACjC,KAAK,KAAK,KAAK,SAAS,IAAI,GAC5B;AAAA,QACC,eAAe;AAAA,MAAA,CACf;AAEF,YAAM,kBAAkB,iBAAiB,KAAK,CAAC,UAAS;AACvD,eAAO,MAAM,OAAA,KAAY,MAAM,SAAS;AAAA,MAAA,CACxC;AAED,UAAI,iBAAiB;AACpB,cAAM,YAAY,KAAK,KAAK,KAAK,SAAS,MAAM,YAAY;AAEtD,cAAA,gBAAgB,MAAM,aAAa,SAAS;AAE9C,YAAA,kBAAkB,aAAa,GAAG;AACjC,cAAA,KAAK,cAAc,EAAE;AAAA,QACzB;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAA,CAAC;AAGI,SAAA;AAAA,IACN,KAAK,IAAI,KAAM;AAAA,EAAA;AAEjB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slicemachine/adapter-nuxt",
|
|
3
|
-
"version": "0.0.2-dev-plugins-m3.
|
|
3
|
+
"version": "0.0.2-dev-plugins-m3.4",
|
|
4
4
|
"description": "Slice Machine adapter for Nuxt 3.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@prismicio/slice-simulator-core": "^0.2.7",
|
|
61
61
|
"@prismicio/types-internal": "2.0.0-alpha.9",
|
|
62
|
-
"@slicemachine/plugin-kit": "0.1.8-dev-plugins-m3.
|
|
62
|
+
"@slicemachine/plugin-kit": "0.1.8-dev-plugins-m3.4",
|
|
63
63
|
"common-tags": "^1.8.2",
|
|
64
64
|
"fs-extra": "^11.1.0",
|
|
65
65
|
"magicast": "^0.2.1",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"publishConfig": {
|
|
104
104
|
"access": "public"
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "7e5980c90b43f55e9ad3ff0885201fdf2f37b34d"
|
|
107
107
|
}
|
|
@@ -18,30 +18,35 @@ const isCustomTypeModel = (
|
|
|
18
18
|
export const customTypeLibraryRead: CustomTypeLibraryReadHook<
|
|
19
19
|
PluginOptions
|
|
20
20
|
> = async (_data, { helpers }) => {
|
|
21
|
-
const
|
|
21
|
+
const dir = buildCustomTypeLibraryDirectoryPath({ helpers });
|
|
22
22
|
|
|
23
23
|
// Ensure the directory exists.
|
|
24
|
-
await fs.mkdir(
|
|
24
|
+
await fs.mkdir(dir, { recursive: true });
|
|
25
25
|
|
|
26
|
-
const childDirs = await fs.readdir(
|
|
26
|
+
const childDirs = await fs.readdir(dir, { withFileTypes: true });
|
|
27
27
|
|
|
28
28
|
const ids: string[] = [];
|
|
29
29
|
await Promise.all(
|
|
30
30
|
childDirs.map(async (childDir) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
if (childDir.isDirectory()) {
|
|
32
|
+
const childDirContents = await fs.readdir(
|
|
33
|
+
path.join(dir, childDir.name),
|
|
34
|
+
{
|
|
35
|
+
withFileTypes: true,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
const isCustomTypeDir = childDirContents.some((entry) => {
|
|
39
|
+
return entry.isFile() && entry.name === "index.json";
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (isCustomTypeDir) {
|
|
43
|
+
const modelPath = path.join(dir, childDir.name, "index.json");
|
|
44
|
+
|
|
45
|
+
const modelContents = await readJSONFile(modelPath);
|
|
46
|
+
|
|
47
|
+
if (isCustomTypeModel(modelContents)) {
|
|
48
|
+
ids.push(modelContents.id);
|
|
49
|
+
}
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
}),
|