@codefresh-io/cf-git-providers
TypeScript icon, indicating that this package has built-in type declarations

0.15.3 • Public • Published

cf-git-providers

An NPM module/CLI for interacting with various git providers

Using the CLI

Install

In case you have node.js installed you can easily install with NPM:

npm install -g @codefresh-io/cf-git-providers

Or you can run it as a Docker container:

docker run -it --rm --entrypoint "sh" codefresh/cgp

Authenticate

To use the cli tool you will need to provide it with a Codefresh git context which you can get by using the codefresh-cli:

codefresh get context <context-name> -o json --decrypt | base64

Then, to provide this value to the cli by adding it to each command with the flag --git-context or (preferably) by exporting the CF_GIT_CONTEXT environment variable, example:

export CF_GIT_CONTEXT=$(codefresh get context <context-name> -o json --decrypt | base64)

Usage

Examples:

  • To get the list of repositories for a specific owner:

    cgp list repos --owner codefresh-io

  • To create a repository webhook:

    cgp create webhook --owner codefresh-io --repo cli --endpoint http://example.com --secret some-secret

Using the npm module

Install

With npm:

npm install @codefresh-io/cf-git-providers

With yarn:

yarn add @codefresh-io/cf-git-providers

Usage

import { getProviderByContext } from '@codefresh-io/cf-git-providers'

(async function () {
	try {
		const provider = await getProviderByContext(gitContext, providerOptions)
		const fileContents = await provider.fetchRawFile({ owner, repo, ref, path })
		console.log(fileContents)
	} catch (error) {
		console.error(error)
	}
})()

/@codefresh-io/cf-git-providers/

    Package Sidebar

    Install

    npm i @codefresh-io/cf-git-providers

    Weekly Downloads

    131

    Version

    0.15.3

    License

    MIT

    Unpacked Size

    438 kB

    Total Files

    107

    Last publish

    Collaborators

    • plakyda-codefresh
    • z-tikhonov-codefresh
    • denis-codefresh
    • yaroslav-codefresh
    • scme0
    • atgardner
    • mikeshl
    • bohdan.pisarenko
    • ilia-medvedev-codefresh
    • vasil-s
    • vitalii.chyrka
    • noam-codefresh
    • oleksandr-codefresh
    • andrii-codefresh
    • codefresh
    • gil-levkovitch
    • bogdan-volynets
    • kimaharfi
    • eticodefresh
    • vadim-kharin-codefresh
    • ziv_levi
    • alina_yablochnikova