prismic 0.0.0-pr.28.59bf330

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.
Files changed (158) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +69 -0
  3. package/dist/builders-hKD4IrLX-DsO7BUQw.mjs +97 -0
  4. package/dist/dist-B11B2hHn.mjs +1 -0
  5. package/dist/dist-DT8CtumB.mjs +1 -0
  6. package/dist/framework-CfjEoVk0.mjs +17 -0
  7. package/dist/index.mjs +2537 -0
  8. package/dist/nextjs-9z7YrSnS.mjs +312 -0
  9. package/dist/nuxt-KoJ61G2q.mjs +59 -0
  10. package/dist/sveltekit-DjXKCG78.mjs +226 -0
  11. package/package.json +58 -0
  12. package/src/codegen-types.ts +82 -0
  13. package/src/codegen.ts +45 -0
  14. package/src/custom-type-add-field-boolean.ts +185 -0
  15. package/src/custom-type-add-field-color.ts +168 -0
  16. package/src/custom-type-add-field-date.ts +171 -0
  17. package/src/custom-type-add-field-embed.ts +168 -0
  18. package/src/custom-type-add-field-geo-point.ts +165 -0
  19. package/src/custom-type-add-field-group.ts +142 -0
  20. package/src/custom-type-add-field-image.ts +168 -0
  21. package/src/custom-type-add-field-key-text.ts +168 -0
  22. package/src/custom-type-add-field-link.ts +191 -0
  23. package/src/custom-type-add-field-number.ts +200 -0
  24. package/src/custom-type-add-field-rich-text.ts +192 -0
  25. package/src/custom-type-add-field-select.ts +174 -0
  26. package/src/custom-type-add-field-timestamp.ts +171 -0
  27. package/src/custom-type-add-field-uid.ts +151 -0
  28. package/src/custom-type-add-field.ts +116 -0
  29. package/src/custom-type-connect-slice.ts +178 -0
  30. package/src/custom-type-create.ts +98 -0
  31. package/src/custom-type-disconnect-slice.ts +134 -0
  32. package/src/custom-type-list.ts +110 -0
  33. package/src/custom-type-remove-field.ts +135 -0
  34. package/src/custom-type-remove.ts +103 -0
  35. package/src/custom-type-set-name.ts +102 -0
  36. package/src/custom-type-view.ts +118 -0
  37. package/src/custom-type.ts +85 -0
  38. package/src/docs-fetch.ts +146 -0
  39. package/src/docs-list.ts +131 -0
  40. package/src/docs.ts +54 -0
  41. package/src/env.d.ts +12 -0
  42. package/src/framework/index.ts +399 -0
  43. package/src/framework/nextjs.templates.ts +426 -0
  44. package/src/framework/nextjs.ts +216 -0
  45. package/src/framework/nuxt.templates.ts +74 -0
  46. package/src/framework/nuxt.ts +250 -0
  47. package/src/framework/sveltekit.templates.ts +278 -0
  48. package/src/framework/sveltekit.ts +241 -0
  49. package/src/index.ts +155 -0
  50. package/src/init.ts +173 -0
  51. package/src/lib/auth.ts +200 -0
  52. package/src/lib/browser.ts +11 -0
  53. package/src/lib/config.ts +111 -0
  54. package/src/lib/custom-types-api.ts +385 -0
  55. package/src/lib/field-path.ts +81 -0
  56. package/src/lib/file.ts +49 -0
  57. package/src/lib/json.ts +3 -0
  58. package/src/lib/packageJson.ts +35 -0
  59. package/src/lib/profile.ts +39 -0
  60. package/src/lib/request.ts +116 -0
  61. package/src/lib/segment.ts +145 -0
  62. package/src/lib/sentry.ts +63 -0
  63. package/src/lib/string.ts +10 -0
  64. package/src/lib/url.ts +31 -0
  65. package/src/locale-add.ts +116 -0
  66. package/src/locale-list.ts +107 -0
  67. package/src/locale-remove.ts +88 -0
  68. package/src/locale-set-default.ts +131 -0
  69. package/src/locale.ts +60 -0
  70. package/src/login.ts +45 -0
  71. package/src/logout.ts +36 -0
  72. package/src/page-type-add-field-boolean.ts +179 -0
  73. package/src/page-type-add-field-color.ts +165 -0
  74. package/src/page-type-add-field-date.ts +168 -0
  75. package/src/page-type-add-field-embed.ts +165 -0
  76. package/src/page-type-add-field-geo-point.ts +162 -0
  77. package/src/page-type-add-field-group.ts +139 -0
  78. package/src/page-type-add-field-image.ts +165 -0
  79. package/src/page-type-add-field-key-text.ts +165 -0
  80. package/src/page-type-add-field-link.ts +188 -0
  81. package/src/page-type-add-field-number.ts +197 -0
  82. package/src/page-type-add-field-rich-text.ts +189 -0
  83. package/src/page-type-add-field-select.ts +171 -0
  84. package/src/page-type-add-field-timestamp.ts +168 -0
  85. package/src/page-type-add-field-uid.ts +148 -0
  86. package/src/page-type-add-field.ts +116 -0
  87. package/src/page-type-connect-slice.ts +178 -0
  88. package/src/page-type-create.ts +128 -0
  89. package/src/page-type-disconnect-slice.ts +134 -0
  90. package/src/page-type-list.ts +109 -0
  91. package/src/page-type-remove-field.ts +135 -0
  92. package/src/page-type-remove.ts +103 -0
  93. package/src/page-type-set-name.ts +102 -0
  94. package/src/page-type-set-repeatable.ts +111 -0
  95. package/src/page-type-view.ts +118 -0
  96. package/src/page-type.ts +90 -0
  97. package/src/preview-add.ts +126 -0
  98. package/src/preview-get-simulator.ts +104 -0
  99. package/src/preview-list.ts +106 -0
  100. package/src/preview-remove-simulator.ts +80 -0
  101. package/src/preview-remove.ts +109 -0
  102. package/src/preview-set-name.ts +137 -0
  103. package/src/preview-set-simulator.ts +116 -0
  104. package/src/preview.ts +75 -0
  105. package/src/pull.ts +236 -0
  106. package/src/push.ts +409 -0
  107. package/src/repo-create.ts +175 -0
  108. package/src/repo-get-access.ts +86 -0
  109. package/src/repo-list.ts +100 -0
  110. package/src/repo-set-access.ts +100 -0
  111. package/src/repo-set-name.ts +102 -0
  112. package/src/repo-view.ts +113 -0
  113. package/src/repo.ts +70 -0
  114. package/src/slice-add-field-boolean.ts +219 -0
  115. package/src/slice-add-field-color.ts +205 -0
  116. package/src/slice-add-field-date.ts +205 -0
  117. package/src/slice-add-field-embed.ts +205 -0
  118. package/src/slice-add-field-geo-point.ts +202 -0
  119. package/src/slice-add-field-group.ts +170 -0
  120. package/src/slice-add-field-image.ts +202 -0
  121. package/src/slice-add-field-key-text.ts +205 -0
  122. package/src/slice-add-field-link.ts +224 -0
  123. package/src/slice-add-field-number.ts +205 -0
  124. package/src/slice-add-field-rich-text.ts +229 -0
  125. package/src/slice-add-field-select.ts +211 -0
  126. package/src/slice-add-field-timestamp.ts +205 -0
  127. package/src/slice-add-field.ts +111 -0
  128. package/src/slice-add-variation.ts +142 -0
  129. package/src/slice-create.ts +164 -0
  130. package/src/slice-list-variations.ts +71 -0
  131. package/src/slice-list.ts +60 -0
  132. package/src/slice-remove-field.ts +125 -0
  133. package/src/slice-remove-variation.ts +113 -0
  134. package/src/slice-remove.ts +92 -0
  135. package/src/slice-rename.ts +104 -0
  136. package/src/slice-set-screenshot.ts +239 -0
  137. package/src/slice-view.ts +83 -0
  138. package/src/slice.ts +95 -0
  139. package/src/status.ts +834 -0
  140. package/src/sync.ts +259 -0
  141. package/src/token-create.ts +203 -0
  142. package/src/token-delete.ts +182 -0
  143. package/src/token-list.ts +223 -0
  144. package/src/token-set-name.ts +193 -0
  145. package/src/token.ts +60 -0
  146. package/src/webhook-add-header.ts +118 -0
  147. package/src/webhook-create.ts +152 -0
  148. package/src/webhook-disable.ts +109 -0
  149. package/src/webhook-enable.ts +132 -0
  150. package/src/webhook-list.ts +93 -0
  151. package/src/webhook-remove-header.ts +117 -0
  152. package/src/webhook-remove.ts +106 -0
  153. package/src/webhook-set-triggers.ts +148 -0
  154. package/src/webhook-status.ts +90 -0
  155. package/src/webhook-test.ts +106 -0
  156. package/src/webhook-view.ts +147 -0
  157. package/src/webhook.ts +95 -0
  158. package/src/whoami.ts +62 -0
@@ -0,0 +1,60 @@
1
+ import { parseArgs } from "node:util";
2
+
3
+ import { requireFramework } from "./framework";
4
+
5
+ const HELP = `
6
+ List all slices in a Prismic project.
7
+
8
+ USAGE
9
+ prismic slice list [flags]
10
+
11
+ FLAGS
12
+ --json Output as JSON
13
+ -h, --help Show help for command
14
+
15
+ EXAMPLES
16
+ prismic slice list
17
+ prismic slice list --json
18
+ `.trim();
19
+
20
+ export async function sliceList(): Promise<void> {
21
+ const {
22
+ values: { help, json },
23
+ } = parseArgs({
24
+ args: process.argv.slice(4), // skip: node, script, "slice", "list"
25
+ options: {
26
+ json: { type: "boolean" },
27
+ help: { type: "boolean", short: "h" },
28
+ },
29
+ allowPositionals: true,
30
+ });
31
+
32
+ if (help) {
33
+ console.info(HELP);
34
+ return;
35
+ }
36
+
37
+ const framework = await requireFramework();
38
+ if (!framework) return;
39
+
40
+ const sliceResults = await framework.getSlices();
41
+ const slices = sliceResults.map((s) => ({ id: s.model.id, name: s.model.name }));
42
+
43
+ if (slices.length === 0) {
44
+ if (json) {
45
+ console.info(JSON.stringify([]));
46
+ } else {
47
+ console.info("No slices found.");
48
+ }
49
+ return;
50
+ }
51
+
52
+ if (json) {
53
+ console.info(JSON.stringify(slices, null, 2));
54
+ } else {
55
+ console.info("ID\tNAME");
56
+ for (const slice of slices) {
57
+ console.info(`${slice.id}\t${slice.name}`);
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,125 @@
1
+ import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
+
3
+ import { parseArgs } from "node:util";
4
+
5
+ import { buildTypes } from "./codegen-types";
6
+ import { requireFramework } from "./framework";
7
+
8
+ const HELP = `
9
+ Remove a field from a slice variation.
10
+
11
+ USAGE
12
+ prismic slice remove-field <slice-id> <field-id> [flags]
13
+
14
+ ARGUMENTS
15
+ slice-id Slice identifier (required)
16
+ field-id Field identifier (required)
17
+
18
+ FLAGS
19
+ --variation string Target variation (default: "default")
20
+ --zone string Field zone: "primary" or "items" (default: "primary")
21
+ --types string Output file for generated types (default: "prismicio-types.d.ts")
22
+ -h, --help Show help for command
23
+
24
+ EXAMPLES
25
+ prismic slice remove-field MySlice title
26
+ prismic slice remove-field MySlice title --variation withImage
27
+ prismic slice remove-field MySlice item_title --zone items
28
+ `.trim();
29
+
30
+ export async function sliceRemoveField(): Promise<void> {
31
+ const {
32
+ values: { help, variation, zone, types },
33
+ positionals: [sliceId, fieldId],
34
+ } = parseArgs({
35
+ args: process.argv.slice(4), // skip: node, script, "slice", "remove-field"
36
+ options: {
37
+ variation: { type: "string", default: "default" },
38
+ zone: { type: "string", default: "primary" },
39
+ types: { type: "string" },
40
+ help: { type: "boolean", short: "h" },
41
+ },
42
+ allowPositionals: true,
43
+ });
44
+
45
+ if (help) {
46
+ console.info(HELP);
47
+ return;
48
+ }
49
+
50
+ if (!sliceId) {
51
+ console.error("Missing required argument: slice-id\n");
52
+ console.error("Usage: prismic slice remove-field <slice-id> <field-id>");
53
+ process.exitCode = 1;
54
+ return;
55
+ }
56
+
57
+ if (!fieldId) {
58
+ console.error("Missing required argument: field-id\n");
59
+ console.error("Usage: prismic slice remove-field <slice-id> <field-id>");
60
+ process.exitCode = 1;
61
+ return;
62
+ }
63
+
64
+ if (zone !== "primary" && zone !== "items") {
65
+ console.error(`Invalid zone: ${zone}. Must be "primary" or "items".`);
66
+ process.exitCode = 1;
67
+ return;
68
+ }
69
+
70
+ const framework = await requireFramework();
71
+ if (!framework) return;
72
+
73
+ let model: SharedSlice;
74
+ try {
75
+ model = await framework.readSlice(sliceId);
76
+ } catch {
77
+ console.error(`Slice not found: ${sliceId}\n\nCreate it first with: prismic slice create ${sliceId}`);
78
+ process.exitCode = 1;
79
+ return;
80
+ }
81
+
82
+ // Find the variation
83
+ const targetVariation = model.variations.find((v) => v.id === variation);
84
+ if (!targetVariation) {
85
+ console.error(`Variation not found: ${variation}`);
86
+ console.error(`Available variations: ${model.variations.map((v) => v.id).join(", ")}`);
87
+ process.exitCode = 1;
88
+ return;
89
+ }
90
+
91
+ // Check if field exists
92
+ const zoneFields = zone === "primary" ? targetVariation.primary : targetVariation.items;
93
+ if (!zoneFields || !(fieldId in zoneFields)) {
94
+ console.error(`Field "${fieldId}" not found in ${zone} zone of variation "${variation}"`);
95
+ process.exitCode = 1;
96
+ return;
97
+ }
98
+
99
+ // Remove the field
100
+ delete zoneFields[fieldId];
101
+
102
+ // Write updated model
103
+ try {
104
+ await framework.updateSlice(model);
105
+ } catch (error) {
106
+ if (error instanceof Error) {
107
+ console.error(`Failed to update slice: ${error.message}`);
108
+ } else {
109
+ console.error("Failed to update slice");
110
+ }
111
+ process.exitCode = 1;
112
+ return;
113
+ }
114
+
115
+ console.info(
116
+ `Removed field "${fieldId}" from ${zone} zone in variation "${variation}" of slice "${sliceId}"`,
117
+ );
118
+
119
+ try {
120
+ await buildTypes({ output: types });
121
+ console.info(`Updated types in ${types ?? "prismicio-types.d.ts"}`);
122
+ } catch (error) {
123
+ console.warn(`Could not generate types: ${error instanceof Error ? error.message : error}`);
124
+ }
125
+ }
@@ -0,0 +1,113 @@
1
+ import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
+
3
+ import { parseArgs } from "node:util";
4
+
5
+ import { buildTypes } from "./codegen-types";
6
+ import { requireFramework } from "./framework";
7
+
8
+ const HELP = `
9
+ Remove a variation from a slice.
10
+
11
+ USAGE
12
+ prismic slice remove-variation <slice-id> <variation-id> [flags]
13
+
14
+ ARGUMENTS
15
+ slice-id Slice identifier (required)
16
+ variation-id Variation to remove (required)
17
+
18
+ FLAGS
19
+ --types string Output file for generated types (default: "prismicio-types.d.ts")
20
+ -h, --help Show help for command
21
+
22
+ EXAMPLES
23
+ prismic slice remove-variation MySlice withImage
24
+ `.trim();
25
+
26
+ export async function sliceRemoveVariation(): Promise<void> {
27
+ const {
28
+ values: { help, types },
29
+ positionals: [sliceId, variationId],
30
+ } = parseArgs({
31
+ args: process.argv.slice(4), // skip: node, script, "slice", "remove-variation"
32
+ options: {
33
+ types: { type: "string" },
34
+ help: { type: "boolean", short: "h" },
35
+ },
36
+ allowPositionals: true,
37
+ });
38
+
39
+ if (help) {
40
+ console.info(HELP);
41
+ return;
42
+ }
43
+
44
+ if (!sliceId) {
45
+ console.error("Missing required argument: slice-id\n");
46
+ console.error("Usage: prismic slice remove-variation <slice-id> <variation-id>");
47
+ process.exitCode = 1;
48
+ return;
49
+ }
50
+
51
+ if (!variationId) {
52
+ console.error("Missing required argument: variation-id\n");
53
+ console.error("Usage: prismic slice remove-variation <slice-id> <variation-id>");
54
+ process.exitCode = 1;
55
+ return;
56
+ }
57
+
58
+ const framework = await requireFramework();
59
+ if (!framework) return;
60
+
61
+ let model: SharedSlice;
62
+ try {
63
+ model = await framework.readSlice(sliceId);
64
+ } catch {
65
+ console.error(`Slice not found: ${sliceId}\n\nCreate it first with: prismic slice create ${sliceId}`);
66
+ process.exitCode = 1;
67
+ return;
68
+ }
69
+
70
+ // Check if variation exists
71
+ const variationExists = model.variations.some((v) => v.id === variationId);
72
+ if (!variationExists) {
73
+ console.error(`Variation not found: ${variationId}`);
74
+ console.error(`Available variations: ${model.variations.map((v) => v.id).join(", ")}`);
75
+ process.exitCode = 1;
76
+ return;
77
+ }
78
+
79
+ // Prevent removing the last variation
80
+ if (model.variations.length === 1) {
81
+ console.error("Cannot remove the last variation from a slice.");
82
+ process.exitCode = 1;
83
+ return;
84
+ }
85
+
86
+ // Remove the variation
87
+ const updatedModel = {
88
+ ...model,
89
+ variations: model.variations.filter((v) => v.id !== variationId),
90
+ };
91
+
92
+ // Write updated model
93
+ try {
94
+ await framework.updateSlice(updatedModel);
95
+ } catch (error) {
96
+ if (error instanceof Error) {
97
+ console.error(`Failed to update slice: ${error.message}`);
98
+ } else {
99
+ console.error("Failed to update slice");
100
+ }
101
+ process.exitCode = 1;
102
+ return;
103
+ }
104
+
105
+ console.info(`Removed variation "${variationId}" from slice "${sliceId}"`);
106
+
107
+ try {
108
+ await buildTypes({ output: types });
109
+ console.info(`Updated types in ${types ?? "prismicio-types.d.ts"}`);
110
+ } catch (error) {
111
+ console.warn(`Could not generate types: ${error instanceof Error ? error.message : error}`);
112
+ }
113
+ }
@@ -0,0 +1,92 @@
1
+ import { parseArgs } from "node:util";
2
+
3
+ import { buildTypes } from "./codegen-types";
4
+ import { requireFramework } from "./framework";
5
+
6
+ const HELP = `
7
+ Remove a slice from the project.
8
+
9
+ USAGE
10
+ prismic slice remove <slice-id> [flags]
11
+
12
+ ARGUMENTS
13
+ slice-id Slice identifier (required)
14
+
15
+ FLAGS
16
+ -y Confirm removal
17
+ --types string Output file for generated types (default: "prismicio-types.d.ts")
18
+ -h, --help Show help for command
19
+
20
+ EXAMPLES
21
+ prismic slice remove MySlice
22
+ prismic slice remove MySlice -y
23
+ `.trim();
24
+
25
+ export async function sliceRemove(): Promise<void> {
26
+ const {
27
+ values: { help, y, types },
28
+ positionals: [sliceId],
29
+ } = parseArgs({
30
+ args: process.argv.slice(4), // skip: node, script, "slice", "remove"
31
+ options: {
32
+ y: { type: "boolean", short: "y" },
33
+ types: { type: "string" },
34
+ help: { type: "boolean", short: "h" },
35
+ },
36
+ allowPositionals: true,
37
+ });
38
+
39
+ if (help) {
40
+ console.info(HELP);
41
+ return;
42
+ }
43
+
44
+ if (!sliceId) {
45
+ console.error("Missing required argument: slice-id\n");
46
+ console.error("Usage: prismic slice remove <slice-id>");
47
+ process.exitCode = 1;
48
+ return;
49
+ }
50
+
51
+ const framework = await requireFramework();
52
+ if (!framework) return;
53
+
54
+ // Verify the slice exists
55
+ try {
56
+ await framework.readSlice(sliceId);
57
+ } catch {
58
+ console.error(`Slice not found: ${sliceId}\n\nCreate it first with: prismic slice create ${sliceId}`);
59
+ process.exitCode = 1;
60
+ return;
61
+ }
62
+
63
+ // Require -y flag to confirm deletion
64
+ if (!y) {
65
+ console.error(`Refusing to remove slice "${sliceId}" (this will delete the entire directory).`);
66
+ console.error("Re-run with -y to confirm.");
67
+ process.exitCode = 1;
68
+ return;
69
+ }
70
+
71
+ // Delete the slice directory
72
+ try {
73
+ await framework.deleteSlice(sliceId);
74
+ } catch (error) {
75
+ if (error instanceof Error) {
76
+ console.error(`Failed to remove slice: ${error.message}`);
77
+ } else {
78
+ console.error("Failed to remove slice");
79
+ }
80
+ process.exitCode = 1;
81
+ return;
82
+ }
83
+
84
+ console.info(`Removed slice "${sliceId}"`);
85
+
86
+ try {
87
+ await buildTypes({ output: types, framework });
88
+ console.info(`Updated types in ${types ?? "prismicio-types.d.ts"}`);
89
+ } catch (error) {
90
+ console.warn(`Could not generate types: ${error instanceof Error ? error.message : error}`);
91
+ }
92
+ }
@@ -0,0 +1,104 @@
1
+ import type { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
+
3
+ import { parseArgs } from "node:util";
4
+
5
+ import { buildTypes } from "./codegen-types";
6
+ import { requireFramework } from "./framework";
7
+
8
+ const HELP = `
9
+ Rename a slice (updates name field, optionally id and directory).
10
+
11
+ USAGE
12
+ prismic slice rename <slice-id> <new-name> [flags]
13
+
14
+ ARGUMENTS
15
+ slice-id Current slice identifier (required)
16
+ new-name New display name (required)
17
+
18
+ FLAGS
19
+ --id string Also change the slice ID (renames directory)
20
+ --types string Output file for generated types (default: "prismicio-types.d.ts")
21
+ -h, --help Show help for command
22
+
23
+ EXAMPLES
24
+ prismic slice rename MySlice "My New Name"
25
+ prismic slice rename MySlice "My New Name" --id NewSliceId
26
+ `.trim();
27
+
28
+ export async function sliceRename(): Promise<void> {
29
+ const {
30
+ values: { help, id: newId, types },
31
+ positionals: [sliceId, newName],
32
+ } = parseArgs({
33
+ args: process.argv.slice(4), // skip: node, script, "slice", "rename"
34
+ options: {
35
+ id: { type: "string" },
36
+ types: { type: "string" },
37
+ help: { type: "boolean", short: "h" },
38
+ },
39
+ allowPositionals: true,
40
+ });
41
+
42
+ if (help) {
43
+ console.info(HELP);
44
+ return;
45
+ }
46
+
47
+ if (!sliceId) {
48
+ console.error("Missing required argument: slice-id\n");
49
+ console.error("Usage: prismic slice rename <slice-id> <new-name>");
50
+ process.exitCode = 1;
51
+ return;
52
+ }
53
+
54
+ if (!newName) {
55
+ console.error("Missing required argument: new-name\n");
56
+ console.error("Usage: prismic slice rename <slice-id> <new-name>");
57
+ process.exitCode = 1;
58
+ return;
59
+ }
60
+
61
+ const framework = await requireFramework();
62
+ if (!framework) return;
63
+
64
+ let model: SharedSlice;
65
+ try {
66
+ model = await framework.readSlice(sliceId);
67
+ } catch {
68
+ console.error(`Slice not found: ${sliceId}\n\nCreate it first with: prismic slice create ${sliceId}`);
69
+ process.exitCode = 1;
70
+ return;
71
+ }
72
+
73
+ // Update the model
74
+ model.name = newName;
75
+ if (newId) {
76
+ model.id = newId;
77
+ }
78
+
79
+ // Write updated model (renameSlice handles directory rename)
80
+ try {
81
+ if (newId) {
82
+ await framework.renameSlice(model);
83
+ console.info(`Renamed slice "${sliceId}" to "${newId}" (${newName})`);
84
+ } else {
85
+ await framework.updateSlice(model);
86
+ console.info(`Renamed slice "${sliceId}" to "${newName}"`);
87
+ }
88
+ } catch (error) {
89
+ if (error instanceof Error) {
90
+ console.error(`Failed to update slice: ${error.message}`);
91
+ } else {
92
+ console.error("Failed to update slice");
93
+ }
94
+ process.exitCode = 1;
95
+ return;
96
+ }
97
+
98
+ try {
99
+ await buildTypes({ output: types, framework });
100
+ console.info(`Updated types in ${types ?? "prismicio-types.d.ts"}`);
101
+ } catch (error) {
102
+ console.warn(`Could not generate types: ${error instanceof Error ? error.message : error}`);
103
+ }
104
+ }