@slicemachine/adapter-next 0.3.2-dev-next-release.4 → 0.3.2-dev-next-release.6
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/project-init.cjs +330 -58
- package/dist/hooks/project-init.cjs.map +1 -1
- package/dist/hooks/project-init.js +331 -59
- package/dist/hooks/project-init.js.map +1 -1
- package/dist/hooks/slice-create.cjs +3 -2
- package/dist/hooks/slice-create.cjs.map +1 -1
- package/dist/hooks/slice-create.js +3 -2
- package/dist/hooks/slice-create.js.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.cjs +3 -5
- package/dist/hooks/sliceSimulator-setup-read.cjs.map +1 -1
- package/dist/hooks/sliceSimulator-setup-read.js +3 -5
- package/dist/hooks/sliceSimulator-setup-read.js.map +1 -1
- package/dist/lib/checkHasAppRouter.cjs +10 -0
- package/dist/lib/checkHasAppRouter.cjs.map +1 -0
- package/dist/lib/checkHasAppRouter.d.ts +5 -0
- package/dist/lib/checkHasAppRouter.js +10 -0
- package/dist/lib/checkHasAppRouter.js.map +1 -0
- package/dist/lib/checkHasSrcDirectory.cjs +8 -0
- package/dist/lib/checkHasSrcDirectory.cjs.map +1 -0
- package/dist/lib/checkHasSrcDirectory.d.ts +5 -0
- package/dist/lib/checkHasSrcDirectory.js +8 -0
- package/dist/lib/checkHasSrcDirectory.js.map +1 -0
- package/dist/lib/getJSFileExtension.cjs +16 -0
- package/dist/lib/getJSFileExtension.cjs.map +1 -0
- package/dist/lib/getJSFileExtension.d.ts +7 -0
- package/dist/lib/getJSFileExtension.js +16 -0
- package/dist/lib/getJSFileExtension.js.map +1 -0
- package/dist/lib/upsertGlobalContentTypes.cjs +1 -1
- package/dist/lib/upsertGlobalContentTypes.cjs.map +1 -1
- package/dist/lib/upsertGlobalContentTypes.js +1 -1
- package/dist/lib/upsertGlobalContentTypes.js.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.cjs +3 -3
- package/dist/lib/upsertSliceLibraryIndexFile.cjs.map +1 -1
- package/dist/lib/upsertSliceLibraryIndexFile.js +3 -3
- package/dist/lib/upsertSliceLibraryIndexFile.js.map +1 -1
- package/dist/types.d.ts +40 -0
- package/package.json +3 -4
- package/src/hooks/project-init.ts +412 -64
- package/src/hooks/slice-create.ts +3 -5
- package/src/hooks/sliceSimulator-setup-read.ts +3 -5
- package/src/lib/checkHasAppRouter.ts +22 -0
- package/src/lib/checkHasSrcDirectory.ts +15 -0
- package/src/lib/getJSFileExtension.ts +29 -0
- package/src/lib/upsertGlobalContentTypes.ts +3 -1
- package/src/lib/upsertSliceLibraryIndexFile.ts +3 -4
- package/src/types.ts +44 -0
- package/dist/lib/getJSOrTSXFileExtension.cjs +0 -18
- package/dist/lib/getJSOrTSXFileExtension.cjs.map +0 -1
- package/dist/lib/getJSOrTSXFileExtension.d.ts +0 -8
- package/dist/lib/getJSOrTSXFileExtension.js +0 -18
- package/dist/lib/getJSOrTSXFileExtension.js.map +0 -1
- package/src/lib/getJSOrTSXFileExtension.ts +0 -26
|
@@ -6,9 +6,9 @@ import { NON_EDITABLE_FILE_BANNER } from "../constants";
|
|
|
6
6
|
|
|
7
7
|
import { PluginOptions } from "../types";
|
|
8
8
|
|
|
9
|
-
import { checkIsTypeScriptProject } from "./checkIsTypeScriptProject";
|
|
10
9
|
import { pascalCase } from "./pascalCase";
|
|
11
10
|
import { buildSliceLibraryDirectoryPath } from "./buildSliceLibraryDirectoryPath";
|
|
11
|
+
import { getJSFileExtension } from "./getJSFileExtension";
|
|
12
12
|
|
|
13
13
|
type UpsertSliceLibraryIndexFileArgs = {
|
|
14
14
|
libraryID: string;
|
|
@@ -17,17 +17,16 @@ type UpsertSliceLibraryIndexFileArgs = {
|
|
|
17
17
|
export const upsertSliceLibraryIndexFile = async (
|
|
18
18
|
args: UpsertSliceLibraryIndexFileArgs,
|
|
19
19
|
): Promise<void> => {
|
|
20
|
-
const
|
|
20
|
+
const extension = await getJSFileExtension({
|
|
21
21
|
helpers: args.helpers,
|
|
22
22
|
options: args.options,
|
|
23
23
|
});
|
|
24
|
-
|
|
25
24
|
const filePath = path.join(
|
|
26
25
|
buildSliceLibraryDirectoryPath({
|
|
27
26
|
libraryID: args.libraryID,
|
|
28
27
|
helpers: args.helpers,
|
|
29
28
|
}),
|
|
30
|
-
|
|
29
|
+
`index.${extension}`,
|
|
31
30
|
);
|
|
32
31
|
|
|
33
32
|
const slices = await args.actions.readAllSliceModelsForLibrary({
|
package/src/types.ts
CHANGED
|
@@ -1,13 +1,57 @@
|
|
|
1
1
|
export type PluginOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Determines if generated files should be formatted using Prettier.
|
|
4
|
+
*
|
|
5
|
+
* @defaultValue `true`
|
|
6
|
+
*/
|
|
2
7
|
format?: boolean;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Determines if Slice components should be lazy loaded when rendered.
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue `true`
|
|
13
|
+
*/
|
|
3
14
|
lazyLoadSlices?: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The filepath at which generated TypeScript types will be saved.
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue `prismicio-types.d.ts`
|
|
20
|
+
*/
|
|
21
|
+
generatedTypesFilePath?: string;
|
|
4
22
|
} & (
|
|
5
23
|
| {
|
|
24
|
+
/**
|
|
25
|
+
* Determines if generated files should be written in TypeScript or
|
|
26
|
+
* JavaScript.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue `true` if the project contains a `tsconfig.json`, `false` otherwise.
|
|
29
|
+
*/
|
|
6
30
|
typescript?: false;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Determines if generated JavaScript files should use a `.jsx` file
|
|
34
|
+
* extension.
|
|
35
|
+
*
|
|
36
|
+
* @defaultValue `false`
|
|
37
|
+
*/
|
|
7
38
|
jsxExtension?: boolean;
|
|
8
39
|
}
|
|
9
40
|
| {
|
|
41
|
+
/**
|
|
42
|
+
* Determines if generated files should be written in TypeScript or
|
|
43
|
+
* JavaScript.
|
|
44
|
+
*
|
|
45
|
+
* @defaultValue `true` if the project contains a `tsconfig.json`, `false` otherwise.
|
|
46
|
+
*/
|
|
10
47
|
typescript: true;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Determines if generated JavaScript files should use a `.jsx` file
|
|
51
|
+
* extension.
|
|
52
|
+
*
|
|
53
|
+
* @defaultValue `false`
|
|
54
|
+
*/
|
|
11
55
|
jsxExtension?: never;
|
|
12
56
|
}
|
|
13
57
|
);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const checkIsTypeScriptProject = require("./checkIsTypeScriptProject.cjs");
|
|
4
|
-
const getJSOrTSXFileExtension = async (args) => {
|
|
5
|
-
const isTypeScriptProject = await checkIsTypeScriptProject.checkIsTypeScriptProject({
|
|
6
|
-
helpers: args.helpers,
|
|
7
|
-
options: args.options
|
|
8
|
-
});
|
|
9
|
-
if (isTypeScriptProject) {
|
|
10
|
-
return "tsx";
|
|
11
|
-
} else if (args.options.jsxExtension) {
|
|
12
|
-
return "jsx";
|
|
13
|
-
} else {
|
|
14
|
-
return "js";
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
exports.getJSOrTSXFileExtension = getJSOrTSXFileExtension;
|
|
18
|
-
//# sourceMappingURL=getJSOrTSXFileExtension.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getJSOrTSXFileExtension.cjs","sources":["../../../src/lib/getJSOrTSXFileExtension.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"./checkIsTypeScriptProject\";\n\ntype GetJSOrTSXFileExtensionArgs = {\n\thelpers: SliceMachineContext<PluginOptions>[\"helpers\"];\n\toptions: SliceMachineContext<PluginOptions>[\"options\"];\n};\n\nexport const getJSOrTSXFileExtension = async (\n\targs: GetJSOrTSXFileExtensionArgs,\n): Promise<string> => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers: args.helpers,\n\t\toptions: args.options,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\treturn \"tsx\";\n\t} else if (args.options.jsxExtension) {\n\t\treturn \"jsx\";\n\t} else {\n\t\treturn \"js\";\n\t}\n};\n"],"names":["checkIsTypeScriptProject"],"mappings":";;;AAUa,MAAA,0BAA0B,OACtC,SACoB;AACd,QAAA,sBAAsB,MAAMA,kDAAyB;AAAA,IAC1D,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,qBAAqB;AACjB,WAAA;AAAA,EAAA,WACG,KAAK,QAAQ,cAAc;AAC9B,WAAA;AAAA,EAAA,OACD;AACC,WAAA;AAAA,EACP;AACF;;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
-
import type { PluginOptions } from "../types";
|
|
3
|
-
type GetJSOrTSXFileExtensionArgs = {
|
|
4
|
-
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
5
|
-
options: SliceMachineContext<PluginOptions>["options"];
|
|
6
|
-
};
|
|
7
|
-
export declare const getJSOrTSXFileExtension: (args: GetJSOrTSXFileExtensionArgs) => Promise<string>;
|
|
8
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { checkIsTypeScriptProject } from "./checkIsTypeScriptProject.js";
|
|
2
|
-
const getJSOrTSXFileExtension = async (args) => {
|
|
3
|
-
const isTypeScriptProject = await checkIsTypeScriptProject({
|
|
4
|
-
helpers: args.helpers,
|
|
5
|
-
options: args.options
|
|
6
|
-
});
|
|
7
|
-
if (isTypeScriptProject) {
|
|
8
|
-
return "tsx";
|
|
9
|
-
} else if (args.options.jsxExtension) {
|
|
10
|
-
return "jsx";
|
|
11
|
-
} else {
|
|
12
|
-
return "js";
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
getJSOrTSXFileExtension
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=getJSOrTSXFileExtension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getJSOrTSXFileExtension.js","sources":["../../../src/lib/getJSOrTSXFileExtension.ts"],"sourcesContent":["import { SliceMachineContext } from \"@slicemachine/plugin-kit\";\n\nimport type { PluginOptions } from \"../types\";\nimport { checkIsTypeScriptProject } from \"./checkIsTypeScriptProject\";\n\ntype GetJSOrTSXFileExtensionArgs = {\n\thelpers: SliceMachineContext<PluginOptions>[\"helpers\"];\n\toptions: SliceMachineContext<PluginOptions>[\"options\"];\n};\n\nexport const getJSOrTSXFileExtension = async (\n\targs: GetJSOrTSXFileExtensionArgs,\n): Promise<string> => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers: args.helpers,\n\t\toptions: args.options,\n\t});\n\n\tif (isTypeScriptProject) {\n\t\treturn \"tsx\";\n\t} else if (args.options.jsxExtension) {\n\t\treturn \"jsx\";\n\t} else {\n\t\treturn \"js\";\n\t}\n};\n"],"names":[],"mappings":";AAUa,MAAA,0BAA0B,OACtC,SACoB;AACd,QAAA,sBAAsB,MAAM,yBAAyB;AAAA,IAC1D,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,EAAA,CACd;AAED,MAAI,qBAAqB;AACjB,WAAA;AAAA,EAAA,WACG,KAAK,QAAQ,cAAc;AAC9B,WAAA;AAAA,EAAA,OACD;AACC,WAAA;AAAA,EACP;AACF;"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SliceMachineContext } from "@slicemachine/plugin-kit";
|
|
2
|
-
|
|
3
|
-
import type { PluginOptions } from "../types";
|
|
4
|
-
import { checkIsTypeScriptProject } from "./checkIsTypeScriptProject";
|
|
5
|
-
|
|
6
|
-
type GetJSOrTSXFileExtensionArgs = {
|
|
7
|
-
helpers: SliceMachineContext<PluginOptions>["helpers"];
|
|
8
|
-
options: SliceMachineContext<PluginOptions>["options"];
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const getJSOrTSXFileExtension = async (
|
|
12
|
-
args: GetJSOrTSXFileExtensionArgs,
|
|
13
|
-
): Promise<string> => {
|
|
14
|
-
const isTypeScriptProject = await checkIsTypeScriptProject({
|
|
15
|
-
helpers: args.helpers,
|
|
16
|
-
options: args.options,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
if (isTypeScriptProject) {
|
|
20
|
-
return "tsx";
|
|
21
|
-
} else if (args.options.jsxExtension) {
|
|
22
|
-
return "jsx";
|
|
23
|
-
} else {
|
|
24
|
-
return "js";
|
|
25
|
-
}
|
|
26
|
-
};
|