@pilatos/bitbucket-cli 1.9.0 → 1.9.1

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 (2) hide show
  1. package/dist/index.js +38 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -21124,6 +21124,27 @@ class BaseCommand {
21124
21124
  }
21125
21125
  return value;
21126
21126
  }
21127
+ parseIntOption(value, name) {
21128
+ const parsed = Number.parseInt(value, 10);
21129
+ if (Number.isNaN(parsed)) {
21130
+ throw new BBError({
21131
+ code: 5002 /* VALIDATION_INVALID */,
21132
+ message: `--${name} must be a valid integer`,
21133
+ context: { [name]: value }
21134
+ });
21135
+ }
21136
+ return parsed;
21137
+ }
21138
+ parseEnumOption(value, name, allowed) {
21139
+ if (!allowed.includes(value)) {
21140
+ throw new BBError({
21141
+ code: 5002 /* VALIDATION_INVALID */,
21142
+ message: `--${name} must be one of: ${allowed.join(", ")}`,
21143
+ context: { [name]: value }
21144
+ });
21145
+ }
21146
+ return value;
21147
+ }
21127
21148
  }
21128
21149
 
21129
21150
  // src/commands/auth/login.command.ts
@@ -21641,7 +21662,8 @@ class CreateRepoCommand extends BaseCommand {
21641
21662
  this.configService = configService;
21642
21663
  }
21643
21664
  async execute(options, context) {
21644
- const { name, description, project } = options;
21665
+ const { description, project } = options;
21666
+ const name = this.requireOption(options.name, "name");
21645
21667
  const isPublic = options.public === true;
21646
21668
  const workspace = await this.resolveWorkspace(options.workspace);
21647
21669
  const request = {
@@ -21979,7 +22001,13 @@ class ListPRsCommand extends BaseCommand {
21979
22001
  ...context.globalOptions,
21980
22002
  ...options
21981
22003
  });
21982
- const state = options.state || "OPEN";
22004
+ const ALLOWED_STATES = [
22005
+ "OPEN",
22006
+ "MERGED",
22007
+ "DECLINED",
22008
+ "SUPERSEDED"
22009
+ ];
22010
+ const state = options.state ? this.parseEnumOption(options.state, "state", ALLOWED_STATES) : "OPEN";
21983
22011
  const limit = parseLimit(options.limit);
21984
22012
  const reviewerQuery = options.mine ? await this.buildMineFilter() : undefined;
21985
22013
  const values = await collectPages({
@@ -22994,7 +23022,7 @@ class ListCommentsPRCommand extends BaseCommand {
22994
23022
  ...context.globalOptions,
22995
23023
  ...options
22996
23024
  });
22997
- const prId = Number.parseInt(options.id, 10);
23025
+ const prId = this.parseIntOption(options.id, "id");
22998
23026
  const limit = parseLimit(options.limit);
22999
23027
  const values = await collectPages({
23000
23028
  limit,
@@ -23050,8 +23078,8 @@ class EditCommentPRCommand extends BaseCommand {
23050
23078
  ...context.globalOptions,
23051
23079
  ...options
23052
23080
  });
23053
- const prId = Number.parseInt(options.prId, 10);
23054
- const commentId = Number.parseInt(options.commentId, 10);
23081
+ const prId = this.parseIntOption(options.prId, "pr-id");
23082
+ const commentId = this.parseIntOption(options.commentId, "comment-id");
23055
23083
  const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdCommentsCommentIdPut({
23056
23084
  workspace: repoContext.workspace,
23057
23085
  repoSlug: repoContext.repoSlug,
@@ -23093,8 +23121,8 @@ class DeleteCommentPRCommand extends BaseCommand {
23093
23121
  ...context.globalOptions,
23094
23122
  ...options
23095
23123
  });
23096
- const prId = Number.parseInt(options.prId, 10);
23097
- const commentId = Number.parseInt(options.commentId, 10);
23124
+ const prId = this.parseIntOption(options.prId, "pr-id");
23125
+ const commentId = this.parseIntOption(options.commentId, "comment-id");
23098
23126
  await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdCommentsCommentIdDelete({
23099
23127
  workspace: repoContext.workspace,
23100
23128
  repoSlug: repoContext.repoSlug,
@@ -23131,7 +23159,7 @@ class AddReviewerPRCommand extends BaseCommand {
23131
23159
  ...context.globalOptions,
23132
23160
  ...options
23133
23161
  });
23134
- const prId = Number.parseInt(options.id, 10);
23162
+ const prId = this.parseIntOption(options.id, "id");
23135
23163
  const userResponse = await this.usersApi.usersSelectedUserGet({
23136
23164
  selectedUser: options.username
23137
23165
  });
@@ -23190,7 +23218,7 @@ class RemoveReviewerPRCommand extends BaseCommand {
23190
23218
  ...context.globalOptions,
23191
23219
  ...options
23192
23220
  });
23193
- const prId = Number.parseInt(options.id, 10);
23221
+ const prId = this.parseIntOption(options.id, "id");
23194
23222
  const userResponse = await this.usersApi.usersSelectedUserGet({
23195
23223
  selectedUser: options.username
23196
23224
  });
@@ -23244,7 +23272,7 @@ class ListReviewersPRCommand extends BaseCommand {
23244
23272
  ...context.globalOptions,
23245
23273
  ...options
23246
23274
  });
23247
- const prId = Number.parseInt(options.id, 10);
23275
+ const prId = this.parseIntOption(options.id, "id");
23248
23276
  const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
23249
23277
  workspace: repoContext.workspace,
23250
23278
  repoSlug: repoContext.repoSlug,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pilatos/bitbucket-cli",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "A command-line interface for Bitbucket Cloud",
5
5
  "author": "",
6
6
  "license": "MIT",