From 1c1e1f1e515316f33fa7a6f3da884de1e1aaa04c Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Wed, 15 Aug 2018 15:24:54 -0500 Subject: [PATCH] fix(link): support new repo association types --- packages/@ionic/cli-utils/src/definitions.ts | 24 +++++++++++---- packages/@ionic/cli-utils/src/guards.ts | 31 +++++++++++++++++--- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/packages/@ionic/cli-utils/src/definitions.ts b/packages/@ionic/cli-utils/src/definitions.ts index 9305746b92..29243cc90f 100644 --- a/packages/@ionic/cli-utils/src/definitions.ts +++ b/packages/@ionic/cli-utils/src/definitions.ts @@ -123,21 +123,33 @@ export interface GithubBranch { } export interface AppAssociation { - repository: GithubRepoAssociation; + repository: RepoAssociation; } -export interface RepoAssociation { +export interface RepoAssociationBase { html_url: string; clone_url: string; full_name: string; } -export interface GithubRepoAssociation extends RepoAssociation { - type: 'github'; - id: number; +export interface GithubRepoAssociation extends RepoAssociationBase { + type: 'github'; + id: number; +} + +export interface BitbucketCloudRepoAssociation extends RepoAssociationBase { + type: 'bitbucket_cloud'; + id: string; } -export type AssociationType = 'github'; +export interface BitbucketServerRepoAssociation extends RepoAssociationBase { + type: 'bitbucket_server'; + id: number; +} + +export type RepoAssociation = GithubRepoAssociation | BitbucketCloudRepoAssociation | BitbucketServerRepoAssociation; + +export type AssociationType = 'github' | 'bitbucket_cloud' | 'bitbucket_server'; export interface App { id: string; diff --git a/packages/@ionic/cli-utils/src/guards.ts b/packages/@ionic/cli-utils/src/guards.ts index f55e21e34d..6874e3b430 100644 --- a/packages/@ionic/cli-utils/src/guards.ts +++ b/packages/@ionic/cli-utils/src/guards.ts @@ -4,6 +4,8 @@ import { APIResponseSuccess, App, AppAssociation, + BitbucketCloudRepoAssociation, + BitbucketServerRepoAssociation, CommandPreRun, CordovaPackageJson, ExitCodeException, @@ -118,10 +120,17 @@ export function isGithubBranchListResponse(r: APIResponse): r is Response { @@ -137,6 +146,20 @@ export function isGithubRepoAssociation(a: object): a is GithubRepoAssociation { && typeof repo.id === 'number'; } +export function isBitbucketCloudRepoAssociation(a: object): a is BitbucketCloudRepoAssociation { + const repo = a as BitbucketCloudRepoAssociation; + return repo + && repo.type === 'bitbucket_cloud' + && typeof repo.id === 'string'; +} + +export function isBitbucketServerRepoAssociation(a: object): a is BitbucketServerRepoAssociation { + const repo = a as BitbucketServerRepoAssociation; + return repo + && repo.type === 'bitbucket_server' + && typeof repo.id === 'number'; +} + export function isApp(d: object): d is App { const details = d as App; return details