diff --git a/src/commands/type-create.ts b/src/commands/type-create.ts index 268bdc1..b3e7d3d 100644 --- a/src/commands/type-create.ts +++ b/src/commands/type-create.ts @@ -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, diff --git a/test/type-create.test.ts b/test/type-create.test.ts index 60ecce6..1d02530 100644 --- a/test/type-create.test.ts +++ b/test/type-create.test.ts @@ -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 }) => { @@ -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 }) => { @@ -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 }) => {