vercel 54.18.7 → 54.20.0

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 (45) hide show
  1. package/dist/chunks/add-IB7HE5S5.js +134 -0
  2. package/dist/chunks/{add-P6CBTAGK.js → add-TF5VZLCY.js} +3 -3
  3. package/dist/chunks/{chunk-AXFSALI3.js → chunk-4BEUS7AL.js} +293 -71
  4. package/dist/chunks/chunk-4QVAYRYH.js +71 -0
  5. package/dist/chunks/{chunk-RKLBPBRM.js → chunk-7PAKWBN4.js} +2 -2
  6. package/dist/chunks/chunk-AUECDTMX.js +128 -0
  7. package/dist/chunks/{chunk-E2ENQE2W.js → chunk-BUZRVER7.js} +1 -0
  8. package/dist/chunks/{chunk-L6QLQSJE.js → chunk-GDAO4PGA.js} +1 -1
  9. package/dist/chunks/chunk-I3HGCZ4E.js +72 -0
  10. package/dist/chunks/{chunk-DXL7EPOQ.js → chunk-JDO6BSKN.js} +2 -2
  11. package/dist/chunks/chunk-JHQOIGTY.js +363 -0
  12. package/dist/chunks/chunk-KXGWAWRV.js +148 -0
  13. package/dist/chunks/{chunk-XQQXV6ZZ.js → chunk-LFODAB54.js} +1 -0
  14. package/dist/chunks/chunk-RY3AVR6E.js +111 -0
  15. package/dist/chunks/{chunk-JREEV2EL.js → chunk-T63I6OUR.js} +1 -1
  16. package/dist/chunks/chunk-VGIMO3ZK.js +17 -0
  17. package/dist/chunks/{chunk-VTE7W5ZP.js → chunk-ZZIAWRCX.js} +0 -8
  18. package/dist/chunks/image-2DL7JEWW.js +73 -0
  19. package/dist/chunks/inspect-6IHZTLFA.js +167 -0
  20. package/dist/chunks/inspect-EGXHWKY3.js +163 -0
  21. package/dist/chunks/inspect-PL3PE5IJ.js +136 -0
  22. package/dist/chunks/{inspect-KYVZQL56.js → inspect-Z3QJOMNP.js} +2 -2
  23. package/dist/chunks/{list-MUFZTUZA.js → list-BB4T4KT5.js} +1 -1
  24. package/dist/chunks/{list-BYTNF7D7.js → list-KNRPDNQF.js} +2 -2
  25. package/dist/chunks/ls-EP4Q6VF4.js +214 -0
  26. package/dist/chunks/{ls-PDILBRUL.js → ls-FTQGK4R6.js} +3 -3
  27. package/dist/chunks/ls-IQKMDRUB.js +165 -0
  28. package/dist/chunks/ls-MUS72LBS.js +201 -0
  29. package/dist/chunks/{query-75PT24SH.js → query-C6FEOG5R.js} +1 -1
  30. package/dist/chunks/rm-EZFCCZFT.js +137 -0
  31. package/dist/chunks/{rm-BJSTNUIJ.js → rm-GWW57H2V.js} +3 -3
  32. package/dist/chunks/rm-NMSG2WG6.js +137 -0
  33. package/dist/chunks/{rule-inspect-WTU3MGMH.js → rule-inspect-XPZJO3Y4.js} +3 -3
  34. package/dist/chunks/{rules-6PXGKHFH.js → rules-C6SB24UO.js} +6 -6
  35. package/dist/chunks/tags-5PFVWGLK.js +67 -0
  36. package/dist/chunks/{update-TTPNV44H.js → update-BCLMLJM7.js} +3 -3
  37. package/dist/commands/build/index.js +5 -1
  38. package/dist/commands/deploy/index.js +5 -2
  39. package/dist/commands/env/index.js +8 -3
  40. package/dist/commands/link/index.js +4 -1
  41. package/dist/commands-bulk.js +3304 -1952
  42. package/dist/help.js +1 -1
  43. package/dist/index.js +28 -5
  44. package/dist/version.mjs +1 -1
  45. package/package.json +16 -16
@@ -0,0 +1,71 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __dirname_ } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ const __filename = __fileURLToPath(import.meta.url);
6
+ const __dirname = __dirname_(__filename);
7
+
8
+ // src/commands/vcr/utils/paths.ts
9
+ function baseQuery(scope) {
10
+ return new URLSearchParams({
11
+ teamId: scope.teamId,
12
+ projectId: scope.projectId
13
+ });
14
+ }
15
+ function repositoriesPath(scope, opts = {}) {
16
+ const query = baseQuery(scope);
17
+ if (opts.limit !== void 0) {
18
+ query.set("limit", String(opts.limit));
19
+ }
20
+ if (opts.cursor) {
21
+ query.set("cursor", opts.cursor);
22
+ }
23
+ return `/v1/vcr/repository?${query.toString()}`;
24
+ }
25
+ function repositoryPath(scope, idOrName) {
26
+ return `/v1/vcr/repository/${encodeURIComponent(idOrName)}?${baseQuery(scope).toString()}`;
27
+ }
28
+ function repositoryImagesPath(scope, idOrName, opts = {}) {
29
+ const query = baseQuery(scope);
30
+ if (opts.limit !== void 0) {
31
+ query.set("limit", String(opts.limit));
32
+ }
33
+ if (opts.cursor) {
34
+ query.set("cursor", opts.cursor);
35
+ }
36
+ if (opts.untagged) {
37
+ query.set("untagged", "true");
38
+ }
39
+ return `/v1/vcr/repository/${encodeURIComponent(idOrName)}/images?${query.toString()}`;
40
+ }
41
+ function imagePath(scope, idOrName, imageId) {
42
+ return `/v1/vcr/repository/${encodeURIComponent(idOrName)}/images/${encodeURIComponent(imageId)}?${baseQuery(scope).toString()}`;
43
+ }
44
+ function repositoryTagsPath(scope, idOrName, opts = {}) {
45
+ const query = baseQuery(scope);
46
+ if (opts.limit !== void 0) {
47
+ query.set("limit", String(opts.limit));
48
+ }
49
+ if (opts.cursor) {
50
+ query.set("cursor", opts.cursor);
51
+ }
52
+ if (opts.sortBy) {
53
+ query.set("sortBy", opts.sortBy);
54
+ }
55
+ if (opts.sortOrder) {
56
+ query.set("sortOrder", opts.sortOrder);
57
+ }
58
+ return `/v1/vcr/repository/${encodeURIComponent(idOrName)}/tags?${query.toString()}`;
59
+ }
60
+ function repositoryTagPath(scope, idOrName, tag) {
61
+ return `/v1/vcr/repository/${encodeURIComponent(idOrName)}/tags/${encodeURIComponent(tag)}?${baseQuery(scope).toString()}`;
62
+ }
63
+
64
+ export {
65
+ repositoriesPath,
66
+ repositoryPath,
67
+ repositoryImagesPath,
68
+ imagePath,
69
+ repositoryTagsPath,
70
+ repositoryTagPath
71
+ };
@@ -6,12 +6,12 @@ const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
7
  import {
8
8
  resolveAlertsScope
9
- } from "./chunk-L6QLQSJE.js";
9
+ } from "./chunk-GDAO4PGA.js";
10
10
  import {
11
11
  handleValidationError,
12
12
  outputError,
13
13
  validateAllProjectMutualExclusivity
14
- } from "./chunk-E2ENQE2W.js";
14
+ } from "./chunk-BUZRVER7.js";
15
15
  import {
16
16
  AGENT_REASON
17
17
  } from "./chunk-QH7WYDEP.js";
@@ -0,0 +1,128 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __dirname_ } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ const __filename = __fileURLToPath(import.meta.url);
6
+ const __dirname = __dirname_(__filename);
7
+ import {
8
+ formatOption,
9
+ limitOption,
10
+ projectOption,
11
+ yesOption
12
+ } from "./chunk-EJ6GQI6F.js";
13
+ import {
14
+ packageName
15
+ } from "./chunk-P6AK7SVK.js";
16
+
17
+ // src/commands/vcr/image/command.ts
18
+ var projectScopeOption = {
19
+ ...projectOption,
20
+ shorthand: "p",
21
+ description: "Project name or ID (defaults to the linked project)."
22
+ };
23
+ var cursorOption = {
24
+ name: "cursor",
25
+ shorthand: "c",
26
+ type: String,
27
+ deprecated: false,
28
+ description: "Cursor from a previous page to continue listing from",
29
+ argument: "STRING"
30
+ };
31
+ var imageLsSubcommand = {
32
+ name: "ls",
33
+ aliases: ["list"],
34
+ description: "List images in a container registry repository",
35
+ arguments: [
36
+ {
37
+ name: "repository",
38
+ required: true
39
+ }
40
+ ],
41
+ options: [
42
+ projectScopeOption,
43
+ {
44
+ name: "untagged",
45
+ shorthand: null,
46
+ type: Boolean,
47
+ deprecated: false,
48
+ description: "Only list images that have no tags"
49
+ },
50
+ limitOption,
51
+ cursorOption,
52
+ formatOption
53
+ ],
54
+ examples: [
55
+ {
56
+ name: "List images in a repository",
57
+ value: `${packageName} vcr image ls my-app`
58
+ },
59
+ {
60
+ name: "List untagged images as JSON",
61
+ value: `${packageName} vcr image ls my-app --untagged --format json`
62
+ }
63
+ ]
64
+ };
65
+ var imageInspectSubcommand = {
66
+ name: "inspect",
67
+ aliases: ["get"],
68
+ description: "Show details for a single image, including its layer history",
69
+ arguments: [
70
+ {
71
+ name: "repository",
72
+ required: true
73
+ },
74
+ {
75
+ name: "imageId",
76
+ required: true
77
+ }
78
+ ],
79
+ options: [projectScopeOption, formatOption],
80
+ examples: [
81
+ {
82
+ name: "Inspect an image by id",
83
+ value: `${packageName} vcr image inspect my-app img_abc123`
84
+ }
85
+ ]
86
+ };
87
+ var imageRmSubcommand = {
88
+ name: "rm",
89
+ aliases: ["remove", "delete"],
90
+ description: "Delete an image from a repository",
91
+ arguments: [
92
+ {
93
+ name: "repository",
94
+ required: true
95
+ },
96
+ {
97
+ name: "imageId",
98
+ required: true
99
+ }
100
+ ],
101
+ options: [projectScopeOption, yesOption, formatOption],
102
+ examples: [
103
+ {
104
+ name: "Delete an image by id",
105
+ value: `${packageName} vcr image rm my-app img_abc123`
106
+ },
107
+ {
108
+ name: "Delete an image without the confirmation prompt",
109
+ value: `${packageName} vcr image rm my-app img_abc123 --yes`
110
+ }
111
+ ]
112
+ };
113
+ var imageAggregateCommand = {
114
+ name: "image",
115
+ aliases: ["images"],
116
+ description: "List, inspect, or delete images in a repository",
117
+ arguments: [],
118
+ subcommands: [imageLsSubcommand, imageInspectSubcommand, imageRmSubcommand],
119
+ options: [],
120
+ examples: []
121
+ };
122
+
123
+ export {
124
+ imageLsSubcommand,
125
+ imageInspectSubcommand,
126
+ imageRmSubcommand,
127
+ imageAggregateCommand
128
+ };
@@ -137,6 +137,7 @@ function handleValidationError(result, jsonOutput, client) {
137
137
  }
138
138
 
139
139
  export {
140
+ parseTimeFlag,
140
141
  resolveTimeRange,
141
142
  validateAllProjectMutualExclusivity,
142
143
  validateTimeBound,
@@ -6,7 +6,7 @@ const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
7
  import {
8
8
  outputError
9
- } from "./chunk-E2ENQE2W.js";
9
+ } from "./chunk-BUZRVER7.js";
10
10
  import {
11
11
  AGENT_REASON
12
12
  } from "./chunk-QH7WYDEP.js";
@@ -0,0 +1,72 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __dirname_ } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ const __filename = __fileURLToPath(import.meta.url);
6
+ const __dirname = __dirname_(__filename);
7
+ import {
8
+ require_bytes
9
+ } from "./chunk-P6AK7SVK.js";
10
+ import {
11
+ require_ms
12
+ } from "./chunk-GGP5R3FU.js";
13
+ import {
14
+ __toESM
15
+ } from "./chunk-TZ2YI2VH.js";
16
+
17
+ // src/commands/vcr/utils/format.ts
18
+ var import_ms = __toESM(require_ms(), 1);
19
+ var import_bytes = __toESM(require_bytes(), 1);
20
+ function formatBytes(size) {
21
+ if (typeof size !== "number" || Number.isNaN(size)) {
22
+ return "-";
23
+ }
24
+ return import_bytes.default.format(size, { decimalPlaces: 1 }) ?? "-";
25
+ }
26
+ function formatRelativeTime(iso) {
27
+ const time = new Date(iso).getTime();
28
+ if (Number.isNaN(time)) {
29
+ return "-";
30
+ }
31
+ return `${(0, import_ms.default)(Date.now() - time)} ago`;
32
+ }
33
+ function formatDigest(digest) {
34
+ if (!digest) {
35
+ return "-";
36
+ }
37
+ return digest.replace(/^sha256:/, "").slice(0, 12);
38
+ }
39
+ function formatImageStatus(status) {
40
+ switch (status) {
41
+ case "ready":
42
+ return "Ready";
43
+ case "preparing":
44
+ return "Preparing";
45
+ case "unoptimized":
46
+ return "Ready (unoptimized)";
47
+ default:
48
+ return "-";
49
+ }
50
+ }
51
+ var VCR_REGISTRY = "vcr.vercel.com";
52
+ function formatImageReference(teamSlug, projectName, repositoryName, digest) {
53
+ if (!digest) {
54
+ return "-";
55
+ }
56
+ return `${VCR_REGISTRY}/${teamSlug}/${projectName}/${repositoryName}@${digest}`;
57
+ }
58
+ function formatTagReference(teamSlug, projectName, repositoryName, tag) {
59
+ if (!tag) {
60
+ return "-";
61
+ }
62
+ return `${VCR_REGISTRY}/${teamSlug}/${projectName}/${repositoryName}:${tag}`;
63
+ }
64
+
65
+ export {
66
+ formatBytes,
67
+ formatRelativeTime,
68
+ formatDigest,
69
+ formatImageStatus,
70
+ formatImageReference,
71
+ formatTagReference
72
+ };
@@ -15,9 +15,9 @@ import {
15
15
  } from "./chunk-FZZWTDNQ.js";
16
16
  import {
17
17
  apiCommand,
18
- listSubcommand2 as listSubcommand,
18
+ listSubcommand3 as listSubcommand,
19
19
  loginCommand
20
- } from "./chunk-AXFSALI3.js";
20
+ } from "./chunk-4BEUS7AL.js";
21
21
  import {
22
22
  require_semver
23
23
  } from "./chunk-IB5L4LKZ.js";
@@ -0,0 +1,363 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __dirname_ } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ const __filename = __fileURLToPath(import.meta.url);
6
+ const __dirname = __dirname_(__filename);
7
+ import {
8
+ outputError
9
+ } from "./chunk-BUZRVER7.js";
10
+ import {
11
+ validateJsonOutput
12
+ } from "./chunk-XPKWKPWA.js";
13
+ import {
14
+ AGENT_REASON
15
+ } from "./chunk-QH7WYDEP.js";
16
+ import {
17
+ getScope
18
+ } from "./chunk-P726GMBL.js";
19
+ import {
20
+ getLinkedProject,
21
+ getProjectByNameOrId
22
+ } from "./chunk-RB7WQKNC.js";
23
+ import {
24
+ buildCommandWithGlobalFlags,
25
+ outputAgentError
26
+ } from "./chunk-IZOHLD5D.js";
27
+ import {
28
+ ProjectNotFound,
29
+ isAPIError,
30
+ packageName
31
+ } from "./chunk-P6AK7SVK.js";
32
+ import {
33
+ output_manager_default
34
+ } from "./chunk-OX7KI3LF.js";
35
+
36
+ // src/commands/vcr/utils/resolve-vcr-scope.ts
37
+ function emitVcrScopeError(client, jsonOutput, code, message, agent) {
38
+ outputAgentError(
39
+ client,
40
+ {
41
+ status: "error",
42
+ reason: agent.reason,
43
+ message,
44
+ hint: agent.hint,
45
+ next: agent.next
46
+ },
47
+ 1
48
+ );
49
+ return outputError(client, jsonOutput, code, message);
50
+ }
51
+ async function resolveVcrScope(client, opts) {
52
+ if (opts.project) {
53
+ const { team } = await getScope(client);
54
+ if (!team) {
55
+ const msg = "No team context found. Run `vercel switch` to select a team, or use `vercel link` in a project directory.";
56
+ return emitVcrScopeError(client, opts.jsonOutput, "NO_TEAM", msg, {
57
+ reason: AGENT_REASON.MISSING_SCOPE,
58
+ hint: "Select a team scope before using --project with vcr.",
59
+ next: [
60
+ {
61
+ command: buildCommandWithGlobalFlags(client.argv, "whoami"),
62
+ when: "See current user and team"
63
+ },
64
+ {
65
+ command: buildCommandWithGlobalFlags(client.argv, "teams switch"),
66
+ when: "Switch to a team that owns the project"
67
+ }
68
+ ]
69
+ });
70
+ }
71
+ let projectResult;
72
+ try {
73
+ projectResult = await getProjectByNameOrId(client, opts.project, team.id);
74
+ } catch (err) {
75
+ if (isAPIError(err)) {
76
+ const msg = err.serverMessage || (err.status === 403 ? `You do not have permission to access project "${opts.project}" in team "${team.slug}".` : `API error (${err.status}).`);
77
+ const reason = err.status === 401 ? "not_authorized" : err.status === 403 ? "forbidden" : AGENT_REASON.API_ERROR;
78
+ return emitVcrScopeError(
79
+ client,
80
+ opts.jsonOutput,
81
+ err.code || "API_ERROR",
82
+ msg,
83
+ {
84
+ reason,
85
+ next: [
86
+ {
87
+ command: buildCommandWithGlobalFlags(
88
+ client.argv,
89
+ "vcr ls --project <name_or_id>"
90
+ ),
91
+ when: "Retry with a project you can access (replace <name_or_id>)"
92
+ }
93
+ ]
94
+ }
95
+ );
96
+ }
97
+ throw err;
98
+ }
99
+ if (projectResult instanceof ProjectNotFound) {
100
+ const msg = `Project "${opts.project}" was not found in team "${team.slug}".`;
101
+ return emitVcrScopeError(
102
+ client,
103
+ opts.jsonOutput,
104
+ "PROJECT_NOT_FOUND",
105
+ msg,
106
+ {
107
+ reason: AGENT_REASON.NOT_FOUND,
108
+ next: [
109
+ {
110
+ command: buildCommandWithGlobalFlags(client.argv, "project ls"),
111
+ when: "List projects in the current team to pick a name"
112
+ }
113
+ ]
114
+ }
115
+ );
116
+ }
117
+ return {
118
+ teamId: team.id,
119
+ teamSlug: team.slug,
120
+ projectId: projectResult.id,
121
+ projectName: projectResult.name
122
+ };
123
+ }
124
+ const linkedProject = await getLinkedProject(client);
125
+ if (linkedProject.status === "error") {
126
+ return linkedProject.exitCode;
127
+ }
128
+ if (linkedProject.status === "not_linked") {
129
+ const msg = "No linked project found. Run `vercel link` to link a project, or pass --project <name>.";
130
+ return emitVcrScopeError(client, opts.jsonOutput, "NOT_LINKED", msg, {
131
+ reason: AGENT_REASON.NOT_LINKED,
132
+ hint: "Agents should pass --project when no .vercel link exists in --cwd.",
133
+ next: [
134
+ {
135
+ command: buildCommandWithGlobalFlags(client.argv, "link"),
136
+ when: "Link this directory to a Vercel project"
137
+ },
138
+ {
139
+ command: buildCommandWithGlobalFlags(
140
+ client.argv,
141
+ "vcr ls --project <name_or_id>"
142
+ ),
143
+ when: "List repositories for a project without linking (replace <name_or_id>)"
144
+ }
145
+ ]
146
+ });
147
+ }
148
+ return {
149
+ teamId: linkedProject.org.id,
150
+ teamSlug: linkedProject.org.slug,
151
+ projectId: linkedProject.project.id,
152
+ projectName: linkedProject.project.name
153
+ };
154
+ }
155
+
156
+ // src/commands/vcr/utils/validators.ts
157
+ function validateVcrJsonOutput(client, flags) {
158
+ const fr = validateJsonOutput(flags);
159
+ if (!fr.valid) {
160
+ outputAgentError(
161
+ client,
162
+ {
163
+ status: "error",
164
+ reason: AGENT_REASON.INVALID_ARGUMENTS,
165
+ message: fr.error
166
+ },
167
+ 1
168
+ );
169
+ output_manager_default.error(fr.error);
170
+ return 1;
171
+ }
172
+ return { jsonOutput: fr.jsonOutput };
173
+ }
174
+ function validateVcrChoice(client, flag, value, choices, jsonOutput) {
175
+ if (value === void 0 || choices.includes(value)) {
176
+ return void 0;
177
+ }
178
+ const message = `Invalid value for ${flag}: "${value}". Must be one of: ${choices.join(", ")}.`;
179
+ outputAgentError(
180
+ client,
181
+ {
182
+ status: "error",
183
+ reason: AGENT_REASON.INVALID_ARGUMENTS,
184
+ message
185
+ },
186
+ 1
187
+ );
188
+ return outputError(client, jsonOutput, "INVALID_ARGUMENTS", message);
189
+ }
190
+ function requireVcrRepository(client, repository, jsonOutput, usage) {
191
+ if (repository) {
192
+ return void 0;
193
+ }
194
+ outputAgentError(
195
+ client,
196
+ {
197
+ status: "error",
198
+ reason: AGENT_REASON.MISSING_ARGUMENTS,
199
+ message: `Missing repository. Example: ${packageName} ${usage}`,
200
+ next: [
201
+ {
202
+ command: buildCommandWithGlobalFlags(client.argv, "vcr ls"),
203
+ when: "List repositories to pick a name or id"
204
+ }
205
+ ]
206
+ },
207
+ 1
208
+ );
209
+ return outputError(
210
+ client,
211
+ jsonOutput,
212
+ "MISSING_ARGUMENTS",
213
+ `Usage: \`vercel ${usage}\``
214
+ );
215
+ }
216
+ function requireVcrRepositoryAndTag(client, repository, tag, jsonOutput, usage) {
217
+ if (repository && tag) {
218
+ return void 0;
219
+ }
220
+ outputAgentError(
221
+ client,
222
+ {
223
+ status: "error",
224
+ reason: AGENT_REASON.MISSING_ARGUMENTS,
225
+ message: `Missing arguments. Example: ${packageName} ${usage}`,
226
+ next: [
227
+ {
228
+ command: buildCommandWithGlobalFlags(
229
+ client.argv,
230
+ "vcr tag ls <repository>"
231
+ ),
232
+ when: "List tags to pick a tag (replace <repository>)"
233
+ }
234
+ ]
235
+ },
236
+ 1
237
+ );
238
+ return outputError(
239
+ client,
240
+ jsonOutput,
241
+ "MISSING_ARGUMENTS",
242
+ `Usage: \`vercel ${usage}\``
243
+ );
244
+ }
245
+ function requireVcrRepositoryAndImageId(client, repository, imageId, jsonOutput, usage) {
246
+ if (repository && imageId) {
247
+ return void 0;
248
+ }
249
+ outputAgentError(
250
+ client,
251
+ {
252
+ status: "error",
253
+ reason: AGENT_REASON.MISSING_ARGUMENTS,
254
+ message: `Missing arguments. Example: ${packageName} ${usage}`,
255
+ next: [
256
+ {
257
+ command: buildCommandWithGlobalFlags(
258
+ client.argv,
259
+ "vcr image ls <repository>"
260
+ ),
261
+ when: "List images to pick an image id (replace <repository>)"
262
+ }
263
+ ]
264
+ },
265
+ 1
266
+ );
267
+ return outputError(
268
+ client,
269
+ jsonOutput,
270
+ "MISSING_ARGUMENTS",
271
+ `Usage: \`vercel ${usage}\``
272
+ );
273
+ }
274
+
275
+ // src/commands/vcr/utils/errors.ts
276
+ var NOT_AUTHORIZED_MESSAGE = "You do not have access to the container registry in this scope. Ensure your role can manage the project, or pass --token and --scope.";
277
+ var NOT_AUTHORIZED_HINT = "Confirm team scope with whoami; use --scope <team-slug> if the repository lives under another team.";
278
+ var genericMessage = (err) => err.serverMessage || `API error (${err.status}).`;
279
+ var STATUS_INFO = {
280
+ 401: {
281
+ reason: "not_authorized",
282
+ message: () => NOT_AUTHORIZED_MESSAGE,
283
+ hint: NOT_AUTHORIZED_HINT,
284
+ suggestWhoami: true
285
+ },
286
+ 403: {
287
+ reason: "forbidden",
288
+ message: () => NOT_AUTHORIZED_MESSAGE,
289
+ hint: NOT_AUTHORIZED_HINT,
290
+ suggestWhoami: true
291
+ },
292
+ 404: { reason: AGENT_REASON.NOT_FOUND, message: genericMessage },
293
+ 409: { reason: "conflict", message: genericMessage },
294
+ 429: { reason: "rate_limited", message: genericMessage }
295
+ };
296
+ function resolveStatusInfo(err) {
297
+ if (STATUS_INFO[err.status]) {
298
+ return STATUS_INFO[err.status];
299
+ }
300
+ if (err.status >= 500) {
301
+ return {
302
+ reason: AGENT_REASON.API_ERROR,
303
+ message: () => `The container registry endpoint failed (${err.status}). Re-run with --debug and share the x-vercel-id from the failed request.`
304
+ };
305
+ }
306
+ return { reason: AGENT_REASON.API_ERROR, message: genericMessage };
307
+ }
308
+ function handleVcrApiError(client, err, jsonOutput, opts = {}) {
309
+ const info = resolveStatusInfo(err);
310
+ const message = info.message(err);
311
+ const next = [];
312
+ if (info.suggestWhoami) {
313
+ next.push({
314
+ command: buildCommandWithGlobalFlags(client.argv, "whoami"),
315
+ when: "See current user and team"
316
+ });
317
+ }
318
+ if (opts.retry) {
319
+ next.push(opts.retry);
320
+ }
321
+ outputAgentError(
322
+ client,
323
+ {
324
+ status: "error",
325
+ reason: info.reason,
326
+ message,
327
+ ...info.hint ? { hint: info.hint } : {},
328
+ ...next.length > 0 ? { next } : {}
329
+ },
330
+ 1
331
+ );
332
+ return outputError(client, jsonOutput, err.code || "API_ERROR", message);
333
+ }
334
+ function emitVcrArgParseError(client, err, recoverTemplate) {
335
+ const msg = err instanceof Error ? err.message : String(err);
336
+ const projectFlagMissingArg = msg.includes("--project") && msg.includes("requires argument");
337
+ outputAgentError(
338
+ client,
339
+ {
340
+ status: "error",
341
+ reason: AGENT_REASON.INVALID_ARGUMENTS,
342
+ message: projectFlagMissingArg ? "`--project` requires a project name or id (for example `--project my-app`)." : msg,
343
+ next: [
344
+ {
345
+ command: buildCommandWithGlobalFlags(client.argv, recoverTemplate),
346
+ when: projectFlagMissingArg ? "Re-run with a project name or id (replace placeholder)" : "See valid usage"
347
+ }
348
+ ]
349
+ },
350
+ 1
351
+ );
352
+ }
353
+
354
+ export {
355
+ resolveVcrScope,
356
+ validateVcrJsonOutput,
357
+ validateVcrChoice,
358
+ requireVcrRepository,
359
+ requireVcrRepositoryAndTag,
360
+ requireVcrRepositoryAndImageId,
361
+ handleVcrApiError,
362
+ emitVcrArgParseError
363
+ };