prismic-ts-codegen 0.1.7 → 0.1.8
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.
|
@@ -3,13 +3,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const node_module = require("node:module");
|
|
4
4
|
const detectTypesProvider = async (config = {}) => {
|
|
5
5
|
const require2 = node_module.createRequire(config.cwd || process.cwd());
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
6
|
+
try {
|
|
7
|
+
if (Number.parseInt(require2("@prismicio/client/package.json").version.split(".")[0]) >= 7) {
|
|
8
|
+
return "@prismicio/client";
|
|
9
|
+
}
|
|
10
|
+
} catch {
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
require2.resolve("@prismicio/types");
|
|
12
14
|
return "@prismicio/types";
|
|
15
|
+
} catch {
|
|
13
16
|
}
|
|
14
17
|
};
|
|
15
18
|
exports.detectTypesProvider = detectTypesProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectTypesProvider.cjs","sources":["../../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n *\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst require = createRequire(config.cwd || process.cwd());\n\n\
|
|
1
|
+
{"version":3,"file":"detectTypesProvider.cjs","sources":["../../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n *\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst require = createRequire(config.cwd || process.cwd());\n\n\ttry {\n\t\tif (\n\t\t\tNumber.parseInt(\n\t\t\t\trequire(\"@prismicio/client/package.json\").version.split(\".\")[0],\n\t\t\t) >= 7\n\t\t) {\n\t\t\treturn \"@prismicio/client\";\n\t\t}\n\t} catch {\n\t\t// noop\n\t}\n\n\ttry {\n\t\trequire.resolve(\"@prismicio/types\");\n\n\t\treturn \"@prismicio/types\";\n\t} catch {\n\t\t// noop\n\t}\n};\n"],"names":["require","createRequire"],"mappings":";;;AAgBO,MAAM,sBAAsB,OAClC,SAAoC,OACG;AACvC,QAAMA,WAAUC,YAAAA,cAAc,OAAO,OAAO,QAAQ,KAAK;AAErD,MAAA;AACH,QACC,OAAO,SACND,SAAQ,gCAAgC,EAAE,QAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAC3D,GACJ;AACM,aAAA;AAAA,IACP;AAAA,EAAA,QACA;AAAA,EAED;AAEG,MAAA;AACH,IAAAA,SAAQ,QAAQ,kBAAkB;AAE3B,WAAA;AAAA,EAAA,QACN;AAAA,EAED;AACF;;"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
const detectTypesProvider = async (config = {}) => {
|
|
3
3
|
const require2 = createRequire(config.cwd || process.cwd());
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
4
|
+
try {
|
|
5
|
+
if (Number.parseInt(require2("@prismicio/client/package.json").version.split(".")[0]) >= 7) {
|
|
6
|
+
return "@prismicio/client";
|
|
7
|
+
}
|
|
8
|
+
} catch {
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
require2.resolve("@prismicio/types");
|
|
10
12
|
return "@prismicio/types";
|
|
13
|
+
} catch {
|
|
11
14
|
}
|
|
12
15
|
};
|
|
13
16
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectTypesProvider.js","sources":["../../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n *\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst require = createRequire(config.cwd || process.cwd());\n\n\
|
|
1
|
+
{"version":3,"file":"detectTypesProvider.js","sources":["../../src/detectTypesProvider.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { TypesProvider } from \"./generateTypes\";\n\nexport type DetectTypesProviderConfig = {\n\tcwd?: string;\n};\n\n/**\n * Detects which types provider should be used for a project.\n *\n * @param config - Configures the detection.\n *\n * @returns The types provider identifier to use, or `undefined` if on cannot be\n * determined.\n */\nexport const detectTypesProvider = async (\n\tconfig: DetectTypesProviderConfig = {},\n): Promise<TypesProvider | undefined> => {\n\tconst require = createRequire(config.cwd || process.cwd());\n\n\ttry {\n\t\tif (\n\t\t\tNumber.parseInt(\n\t\t\t\trequire(\"@prismicio/client/package.json\").version.split(\".\")[0],\n\t\t\t) >= 7\n\t\t) {\n\t\t\treturn \"@prismicio/client\";\n\t\t}\n\t} catch {\n\t\t// noop\n\t}\n\n\ttry {\n\t\trequire.resolve(\"@prismicio/types\");\n\n\t\treturn \"@prismicio/types\";\n\t} catch {\n\t\t// noop\n\t}\n};\n"],"names":["require"],"mappings":";AAgBO,MAAM,sBAAsB,OAClC,SAAoC,OACG;AACvC,QAAMA,WAAU,cAAc,OAAO,OAAO,QAAQ,KAAK;AAErD,MAAA;AACH,QACC,OAAO,SACNA,SAAQ,gCAAgC,EAAE,QAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAC3D,GACJ;AACM,aAAA;AAAA,IACP;AAAA,EAAA,QACA;AAAA,EAED;AAEG,MAAA;AACH,IAAAA,SAAQ,QAAQ,kBAAkB;AAE3B,WAAA;AAAA,EAAA,QACN;AAAA,EAED;AACF;"}
|
package/package.json
CHANGED
|
@@ -19,14 +19,23 @@ export const detectTypesProvider = async (
|
|
|
19
19
|
): Promise<TypesProvider | undefined> => {
|
|
20
20
|
const require = createRequire(config.cwd || process.cwd());
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
try {
|
|
23
|
+
if (
|
|
24
|
+
Number.parseInt(
|
|
25
|
+
require("@prismicio/client/package.json").version.split(".")[0],
|
|
26
|
+
) >= 7
|
|
27
|
+
) {
|
|
28
|
+
return "@prismicio/client";
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
// noop
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
require.resolve("@prismicio/types");
|
|
36
|
+
|
|
30
37
|
return "@prismicio/types";
|
|
38
|
+
} catch {
|
|
39
|
+
// noop
|
|
31
40
|
}
|
|
32
41
|
};
|