Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/commands/type-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ export default createCommand(config, async ({ positionals, values }) => {
}
: { Main: {} };

if (!single) {
json.Main = {
uid: { type: "UID", config: { label: "UID" } },
...json.Main,
};
}

const model: CustomType = {
id,
label: name,
Expand Down
3 changes: 3 additions & 0 deletions test/type-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ it("creates a custom type", async ({ expect, prismic, project }) => {
const id = snakeCase(label!);
const created = await readLocalCustomType(project, id);
expect(created).toMatchObject({ label, format: "custom", repeatable: true });
expect(created.json.Main.uid).toEqual({ type: "UID", config: { label: "UID" } });
});

it("creates a page type with --format page", async ({ expect, prismic, project }) => {
Expand All @@ -32,6 +33,7 @@ it("creates a page type with --format page", async ({ expect, prismic, project }
expect(created).toMatchObject({ format: "page", repeatable: true });
expect(created.json).toHaveProperty("SEO & Metadata");
expect(created.json.Main).toHaveProperty("slices");
expect(created.json.Main.uid).toEqual({ type: "UID", config: { label: "UID" } });
});

it("creates a single custom type", async ({ expect, prismic, project }) => {
Expand All @@ -43,6 +45,7 @@ it("creates a single custom type", async ({ expect, prismic, project }) => {
const id = snakeCase(label!);
const created = await readLocalCustomType(project, id);
expect(created).toMatchObject({ format: "custom", repeatable: false });
expect(created.json.Main).not.toHaveProperty("uid");
});

it("creates a custom type with a custom id", async ({ expect, prismic, project }) => {
Expand Down