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,80 @@
1
+ import { parseArgs } from "node:util";
2
+
3
+ import { isAuthenticated } from "./lib/auth";
4
+ import { safeGetRepositoryFromConfig } from "./lib/config";
5
+ import { stringify } from "./lib/json";
6
+ import { ForbiddenRequestError, request } from "./lib/request";
7
+ import { getRepoUrl } from "./lib/url";
8
+
9
+ const HELP = `
10
+ Remove the slice simulator URL from a Prismic repository.
11
+
12
+ By default, this command reads the repository from prismic.config.json at the
13
+ project root.
14
+
15
+ USAGE
16
+ prismic preview remove-simulator [flags]
17
+
18
+ FLAGS
19
+ -r, --repo string Repository domain
20
+ -h, --help Show help for command
21
+
22
+ LEARN MORE
23
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.
24
+ `.trim();
25
+
26
+ export async function previewRemoveSimulator(): Promise<void> {
27
+ const {
28
+ values: { help, repo = await safeGetRepositoryFromConfig() },
29
+ } = parseArgs({
30
+ args: process.argv.slice(4), // skip: node, script, "preview", "remove-simulator"
31
+ options: {
32
+ repo: { type: "string", short: "r" },
33
+ help: { type: "boolean", short: "h" },
34
+ },
35
+ allowPositionals: false,
36
+ });
37
+
38
+ if (help) {
39
+ console.info(HELP);
40
+ return;
41
+ }
42
+
43
+ if (!repo) {
44
+ console.error("Missing prismic.config.json or --repo option");
45
+ process.exitCode = 1;
46
+ return;
47
+ }
48
+
49
+ const authenticated = await isAuthenticated();
50
+ if (!authenticated) {
51
+ handleUnauthenticated();
52
+ return;
53
+ }
54
+
55
+ const response = await removeSimulatorUrl(repo);
56
+ if (!response.ok) {
57
+ if (response.error instanceof ForbiddenRequestError) {
58
+ handleUnauthenticated();
59
+ } else {
60
+ console.error(`Failed to remove simulator URL: ${stringify(response.value)}`);
61
+ process.exitCode = 1;
62
+ }
63
+ return;
64
+ }
65
+
66
+ console.info("Simulator URL removed.");
67
+ }
68
+
69
+ async function removeSimulatorUrl(repo: string) {
70
+ const url = new URL("/core/repository", await getRepoUrl(repo));
71
+ return await request(url, {
72
+ method: "PATCH",
73
+ body: { simulator_url: "" },
74
+ });
75
+ }
76
+
77
+ function handleUnauthenticated() {
78
+ console.error("Not logged in. Run `prismic login` first.");
79
+ process.exitCode = 1;
80
+ }
@@ -0,0 +1,109 @@
1
+ import { parseArgs } from "node:util";
2
+
3
+ import { isAuthenticated } from "./lib/auth";
4
+ import { safeGetRepositoryFromConfig } from "./lib/config";
5
+ import { stringify } from "./lib/json";
6
+ import { ForbiddenRequestError, request } from "./lib/request";
7
+ import { getRepoUrl } from "./lib/url";
8
+ import { getPreviews } from "./preview-list";
9
+
10
+ const HELP = `
11
+ Remove a preview configuration from a Prismic repository.
12
+
13
+ By default, this command reads the repository from prismic.config.json at the
14
+ project root.
15
+
16
+ USAGE
17
+ prismic preview remove <url> [flags]
18
+
19
+ ARGUMENTS
20
+ <url> Preview URL to remove
21
+
22
+ FLAGS
23
+ -r, --repo string Repository domain
24
+ -h, --help Show help for command
25
+
26
+ LEARN MORE
27
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.
28
+ `.trim();
29
+
30
+ export async function previewRemove(): Promise<void> {
31
+ const {
32
+ values: { help, repo = await safeGetRepositoryFromConfig() },
33
+ positionals: [previewUrl],
34
+ } = parseArgs({
35
+ args: process.argv.slice(4), // skip: node, script, "preview", "remove"
36
+ options: {
37
+ repo: { type: "string", short: "r" },
38
+ help: { type: "boolean", short: "h" },
39
+ },
40
+ allowPositionals: true,
41
+ });
42
+
43
+ if (help) {
44
+ console.info(HELP);
45
+ return;
46
+ }
47
+
48
+ if (!previewUrl) {
49
+ console.error("Missing required argument: <url>");
50
+ process.exitCode = 1;
51
+ return;
52
+ }
53
+
54
+ if (!repo) {
55
+ console.error("Missing prismic.config.json or --repo option");
56
+ process.exitCode = 1;
57
+ return;
58
+ }
59
+
60
+ const authenticated = await isAuthenticated();
61
+ if (!authenticated) {
62
+ handleUnauthenticated();
63
+ return;
64
+ }
65
+
66
+ const previewsResponse = await getPreviews(repo);
67
+ if (!previewsResponse.ok) {
68
+ if (previewsResponse.error instanceof ForbiddenRequestError) {
69
+ handleUnauthenticated();
70
+ } else {
71
+ console.error(`Failed to fetch previews: ${stringify(previewsResponse.value)}`);
72
+ process.exitCode = 1;
73
+ }
74
+ return;
75
+ }
76
+
77
+ const preview = previewsResponse.value.results.find((p) => p.url === previewUrl);
78
+ if (!preview) {
79
+ console.error(`Preview not found: ${previewUrl}`);
80
+ process.exitCode = 1;
81
+ return;
82
+ }
83
+
84
+ const response = await removePreview(repo, preview.id);
85
+ if (!response.ok) {
86
+ if (response.error instanceof ForbiddenRequestError) {
87
+ handleUnauthenticated();
88
+ } else {
89
+ console.error(`Failed to remove preview: ${stringify(response.value)}`);
90
+ process.exitCode = 1;
91
+ }
92
+ return;
93
+ }
94
+
95
+ console.info(`Preview removed: ${previewUrl}`);
96
+ }
97
+
98
+ async function removePreview(repo: string, id: string) {
99
+ const url = new URL(`/previews/delete/${id}`, await getRepoUrl(repo));
100
+ return await request(url, {
101
+ method: "POST",
102
+ body: {},
103
+ });
104
+ }
105
+
106
+ function handleUnauthenticated() {
107
+ console.error("Not logged in. Run `prismic login` first.");
108
+ process.exitCode = 1;
109
+ }
@@ -0,0 +1,137 @@
1
+ import { parseArgs } from "node:util";
2
+
3
+ import { isAuthenticated } from "./lib/auth";
4
+ import { safeGetRepositoryFromConfig } from "./lib/config";
5
+ import { stringify } from "./lib/json";
6
+ import { ForbiddenRequestError, request } from "./lib/request";
7
+ import { getRepoUrl } from "./lib/url";
8
+ import { parsePreviewUrl } from "./preview-add";
9
+ import { getPreviews } from "./preview-list";
10
+
11
+ const HELP = `
12
+ Update the name of a preview configuration.
13
+
14
+ By default, this command reads the repository from prismic.config.json at the
15
+ project root.
16
+
17
+ USAGE
18
+ prismic preview set-name <url> <name> [flags]
19
+
20
+ ARGUMENTS
21
+ <url> Preview URL to update
22
+ <name> New display name
23
+
24
+ FLAGS
25
+ -r, --repo string Repository domain
26
+ -h, --help Show help for command
27
+
28
+ LEARN MORE
29
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.
30
+ `.trim();
31
+
32
+ export async function previewSetName(): Promise<void> {
33
+ const {
34
+ values: { help, repo = await safeGetRepositoryFromConfig() },
35
+ positionals: [previewUrl, name],
36
+ } = parseArgs({
37
+ args: process.argv.slice(4), // skip: node, script, "preview", "set-name"
38
+ options: {
39
+ repo: { type: "string", short: "r" },
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 (!previewUrl) {
51
+ console.error("Missing required argument: <url>");
52
+ process.exitCode = 1;
53
+ return;
54
+ }
55
+
56
+ if (!name) {
57
+ console.error("Missing required argument: <name>");
58
+ process.exitCode = 1;
59
+ return;
60
+ }
61
+
62
+ if (!repo) {
63
+ console.error("Missing prismic.config.json or --repo option");
64
+ process.exitCode = 1;
65
+ return;
66
+ }
67
+
68
+ const authenticated = await isAuthenticated();
69
+ if (!authenticated) {
70
+ handleUnauthenticated();
71
+ return;
72
+ }
73
+
74
+ const parsed = parsePreviewUrl(previewUrl);
75
+ if (!parsed) {
76
+ console.error(`Invalid URL: ${previewUrl}`);
77
+ process.exitCode = 1;
78
+ return;
79
+ }
80
+
81
+ const previewsResponse = await getPreviews(repo);
82
+ if (!previewsResponse.ok) {
83
+ if (previewsResponse.error instanceof ForbiddenRequestError) {
84
+ handleUnauthenticated();
85
+ } else {
86
+ console.error(`Failed to fetch previews: ${stringify(previewsResponse.value)}`);
87
+ process.exitCode = 1;
88
+ }
89
+ return;
90
+ }
91
+
92
+ const preview = previewsResponse.value.results.find((p) => p.url === previewUrl);
93
+ if (!preview) {
94
+ console.error(`Preview not found: ${previewUrl}`);
95
+ process.exitCode = 1;
96
+ return;
97
+ }
98
+
99
+ const response = await updatePreview(repo, preview.id, {
100
+ name,
101
+ websiteURL: parsed.websiteURL,
102
+ resolverPath: parsed.resolverPath,
103
+ });
104
+
105
+ if (!response.ok) {
106
+ if (response.error instanceof ForbiddenRequestError) {
107
+ handleUnauthenticated();
108
+ } else {
109
+ console.error(`Failed to update preview: ${stringify(response.value)}`);
110
+ process.exitCode = 1;
111
+ }
112
+ return;
113
+ }
114
+
115
+ console.info(`Preview updated: ${previewUrl}`);
116
+ }
117
+
118
+ async function updatePreview(
119
+ repo: string,
120
+ id: string,
121
+ config: { name: string; websiteURL: string; resolverPath: string | undefined },
122
+ ) {
123
+ const url = new URL(`/previews/save/${id}`, await getRepoUrl(repo));
124
+ return await request(url, {
125
+ method: "POST",
126
+ body: {
127
+ name: config.name,
128
+ websiteURL: config.websiteURL,
129
+ resolverPath: config.resolverPath,
130
+ },
131
+ });
132
+ }
133
+
134
+ function handleUnauthenticated() {
135
+ console.error("Not logged in. Run `prismic login` first.");
136
+ process.exitCode = 1;
137
+ }
@@ -0,0 +1,116 @@
1
+ import { parseArgs } from "node:util";
2
+
3
+ import { isAuthenticated } from "./lib/auth";
4
+ import { safeGetRepositoryFromConfig } from "./lib/config";
5
+ import { stringify } from "./lib/json";
6
+ import { ForbiddenRequestError, request } from "./lib/request";
7
+ import { getRepoUrl } from "./lib/url";
8
+
9
+ const HELP = `
10
+ Set the slice simulator URL for a Prismic repository.
11
+
12
+ If the URL pathname does not end with /slice-simulator, it is appended
13
+ automatically.
14
+
15
+ By default, this command reads the repository from prismic.config.json at the
16
+ project root.
17
+
18
+ USAGE
19
+ prismic preview set-simulator <url> [flags]
20
+
21
+ ARGUMENTS
22
+ <url> Simulator URL (e.g. https://example.com/slice-simulator)
23
+
24
+ FLAGS
25
+ -r, --repo string Repository domain
26
+ -h, --help Show help for command
27
+
28
+ EXAMPLES
29
+ prismic preview set-simulator https://my-site.com
30
+ prismic preview set-simulator http://localhost:3000/slice-simulator
31
+
32
+ LEARN MORE
33
+ Use \`prismic <command> <subcommand> --help\` for more information about a command.
34
+ `.trim();
35
+
36
+ export async function previewSetSimulator(): Promise<void> {
37
+ const {
38
+ values: { help, repo = await safeGetRepositoryFromConfig() },
39
+ positionals: [urlArg],
40
+ } = parseArgs({
41
+ args: process.argv.slice(4), // skip: node, script, "preview", "set-simulator"
42
+ options: {
43
+ repo: { type: "string", short: "r" },
44
+ help: { type: "boolean", short: "h" },
45
+ },
46
+ allowPositionals: true,
47
+ });
48
+
49
+ if (help) {
50
+ console.info(HELP);
51
+ return;
52
+ }
53
+
54
+ if (!urlArg) {
55
+ console.error("Missing required argument: <url>");
56
+ process.exitCode = 1;
57
+ return;
58
+ }
59
+
60
+ if (!repo) {
61
+ console.error("Missing prismic.config.json or --repo option");
62
+ process.exitCode = 1;
63
+ return;
64
+ }
65
+
66
+ const authenticated = await isAuthenticated();
67
+ if (!authenticated) {
68
+ handleUnauthenticated();
69
+ return;
70
+ }
71
+
72
+ const simulatorUrl = normalizeSimulatorUrl(urlArg);
73
+ if (!simulatorUrl) {
74
+ console.error(`Invalid URL: ${urlArg}`);
75
+ process.exitCode = 1;
76
+ return;
77
+ }
78
+
79
+ const response = await setSimulatorUrl(repo, simulatorUrl);
80
+ if (!response.ok) {
81
+ if (response.error instanceof ForbiddenRequestError) {
82
+ handleUnauthenticated();
83
+ } else {
84
+ console.error(`Failed to set simulator URL: ${stringify(response.value)}`);
85
+ process.exitCode = 1;
86
+ }
87
+ return;
88
+ }
89
+
90
+ console.info(`Simulator URL set: ${simulatorUrl}`);
91
+ }
92
+
93
+ export function normalizeSimulatorUrl(url: string): string | undefined {
94
+ try {
95
+ const parsed = new URL(url);
96
+ if (!parsed.pathname.endsWith("/slice-simulator")) {
97
+ parsed.pathname = parsed.pathname.replace(/\/+$/, "") + "/slice-simulator";
98
+ }
99
+ return parsed.toString();
100
+ } catch {
101
+ return undefined;
102
+ }
103
+ }
104
+
105
+ async function setSimulatorUrl(repo: string, simulatorUrl: string) {
106
+ const url = new URL("/core/repository", await getRepoUrl(repo));
107
+ return await request(url, {
108
+ method: "PATCH",
109
+ body: { simulator_url: simulatorUrl },
110
+ });
111
+ }
112
+
113
+ function handleUnauthenticated() {
114
+ console.error("Not logged in. Run `prismic login` first.");
115
+ process.exitCode = 1;
116
+ }
package/src/preview.ts ADDED
@@ -0,0 +1,75 @@
1
+ import { parseArgs } from "node:util";
2
+
3
+ import { previewAdd } from "./preview-add";
4
+ import { previewGetSimulator } from "./preview-get-simulator";
5
+ import { previewList } from "./preview-list";
6
+ import { previewRemove } from "./preview-remove";
7
+ import { previewRemoveSimulator } from "./preview-remove-simulator";
8
+ import { previewSetName } from "./preview-set-name";
9
+ import { previewSetSimulator } from "./preview-set-simulator";
10
+
11
+ const HELP = `
12
+ Manage preview configurations in a Prismic repository.
13
+
14
+ USAGE
15
+ prismic preview <command> [flags]
16
+
17
+ COMMANDS
18
+ add Add a preview configuration
19
+ list List preview configurations
20
+ remove Remove a preview configuration
21
+ set-name Update a preview's name
22
+ set-simulator Set the slice simulator URL
23
+ get-simulator Show the slice simulator URL
24
+ remove-simulator Remove the slice simulator URL
25
+
26
+ FLAGS
27
+ -h, --help Show help for command
28
+
29
+ LEARN MORE
30
+ Use \`prismic preview <command> --help\` for more information about a command.
31
+ `.trim();
32
+
33
+ export async function preview(): Promise<void> {
34
+ const {
35
+ positionals: [subcommand],
36
+ } = parseArgs({
37
+ args: process.argv.slice(3), // skip: node, script, "preview"
38
+ options: {
39
+ help: { type: "boolean", short: "h" },
40
+ },
41
+ allowPositionals: true,
42
+ strict: false,
43
+ });
44
+
45
+ switch (subcommand) {
46
+ case "add":
47
+ await previewAdd();
48
+ break;
49
+ case "list":
50
+ await previewList();
51
+ break;
52
+ case "remove":
53
+ await previewRemove();
54
+ break;
55
+ case "set-name":
56
+ await previewSetName();
57
+ break;
58
+ case "set-simulator":
59
+ await previewSetSimulator();
60
+ break;
61
+ case "get-simulator":
62
+ await previewGetSimulator();
63
+ break;
64
+ case "remove-simulator":
65
+ await previewRemoveSimulator();
66
+ break;
67
+ default: {
68
+ if (subcommand) {
69
+ console.error(`Unknown preview subcommand: ${subcommand}\n`);
70
+ process.exitCode = 1;
71
+ }
72
+ console.info(HELP);
73
+ }
74
+ }
75
+ }