@codefresh-io/cf-git-providers
Advanced tools
@@ -76,2 +76,11 @@ import { Provider, Repository, Branch, Webhook, ProviderName } from './types'; | ||
}): Promise<Repository[]>; | ||
createCommitStatus(opt: { | ||
owner: string; | ||
repo: string; | ||
sha: string; | ||
targetUrl: string; | ||
state: string; | ||
description: string; | ||
context: string; | ||
}): Promise<void>; | ||
} |
@@ -202,4 +202,7 @@ "use strict"; | ||
} | ||
async createCommitStatus(opt) { | ||
throw new Error("Method not implemented."); | ||
} | ||
} | ||
exports.default = BitbucketServer; | ||
//# sourceMappingURL=bitbucket-server.js.map |
@@ -76,2 +76,11 @@ import { ProviderName, Provider, Branch, Repository, Webhook } from './types'; | ||
}): Promise<Repository[]>; | ||
createCommitStatus(opt: { | ||
owner: string; | ||
repo: string; | ||
sha: string; | ||
targetUrl: string; | ||
state: string; | ||
description: string; | ||
context: string; | ||
}): Promise<void>; | ||
} |
@@ -115,4 +115,7 @@ "use strict"; | ||
} | ||
async createCommitStatus(opt) { | ||
throw new Error("Method not implemented."); | ||
} | ||
} | ||
exports.default = Bitbucket; | ||
//# sourceMappingURL=bitbucket.js.map |
@@ -1,2 +0,2 @@ | ||
import { ProviderName, Provider, Branch, Repository, Webhook } from './types'; | ||
import { ProviderName, Provider, Branch, Repository, Webhook, CommitStatus } from './types'; | ||
export default class Github implements Provider { | ||
@@ -70,2 +70,11 @@ private githubClient; | ||
}): Promise<string[]>; | ||
createCommitStatus(opt: { | ||
owner: string; | ||
repo: string; | ||
sha: string; | ||
targetUrl: string; | ||
state: CommitStatus; | ||
description: string; | ||
context: string; | ||
}): Promise<void>; | ||
} |
@@ -14,2 +14,9 @@ "use strict"; | ||
const MAX_RESULTS = 10000; | ||
const statesMap = { | ||
pending: 'pending', | ||
running: 'pending', | ||
success: 'success', | ||
failure: 'failure', | ||
error: 'error', | ||
}; | ||
const _cleanFilePath = (filepath) => { | ||
@@ -301,4 +308,25 @@ const prefix = './'; | ||
} | ||
async createCommitStatus(opt) { | ||
const { owner, repo, sha, targetUrl, state, description, context } = opt; | ||
const [err, res] = await helpers_1.to(this.githubClient.repos.createCommitStatus({ | ||
owner, | ||
repo, | ||
sha, | ||
target_url: targetUrl, | ||
state: statesMap[state], | ||
description, | ||
context, | ||
})); | ||
if (err) { | ||
throw new CFError({ | ||
message: `Failed to create commit status: ${JSON.stringify(opt)}, status code: ${err.status}`, | ||
cause: err, | ||
}); | ||
} | ||
else if (res.status >= 400) { | ||
throw new CFError(`Failed to create commit status: ${JSON.stringify(opt)}, status code: ${res.status}`); | ||
} | ||
} | ||
} | ||
exports.default = Github; | ||
//# sourceMappingURL=github.js.map |
@@ -72,2 +72,11 @@ import { Provider, Branch, Repository, Webhook, ProviderName } from './types'; | ||
}): Promise<Repository[]>; | ||
createCommitStatus(opt: { | ||
owner: string; | ||
repo: string; | ||
sha: string; | ||
targetUrl: string; | ||
state: string; | ||
description: string; | ||
context: string; | ||
}): Promise<void>; | ||
} |
@@ -110,4 +110,7 @@ "use strict"; | ||
} | ||
async createCommitStatus(opt) { | ||
throw new Error("Method not implemented."); | ||
} | ||
} | ||
exports.default = Gitlab; | ||
//# sourceMappingURL=gitlab.js.map |
@@ -15,2 +15,3 @@ export declare type ProviderConstructor = new (opt: { | ||
export declare type ProviderName = 'github' | 'bitbucket' | 'gitlab' | 'bitbucket-server'; | ||
export declare type CommitStatus = 'pending' | 'running' | 'success' | 'failure' | 'error'; | ||
export interface Provider { | ||
@@ -70,2 +71,11 @@ getName(): ProviderName; | ||
}): Promise<Webhook>; | ||
createCommitStatus(opt: { | ||
owner: string; | ||
repo: string; | ||
sha: string; | ||
targetUrl: string; | ||
state: CommitStatus; | ||
description: string; | ||
context: string; | ||
}): Promise<void>; | ||
deleteRepositoryWebhook(opt: { | ||
@@ -72,0 +82,0 @@ owner: string; |
{ | ||
"name": "@codefresh-io/cf-git-providers", | ||
"version": "0.0.34", | ||
"version": "0.0.35", | ||
"description": "An NPM module/CLI for interacting with various git providers", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
151229
6.83%66
4.76%2363
8.59%