How to use hosted-git-info - 10 common examples

To help you get started, we’ve selected a few hosted-git-info examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github npm / pacote / test / git.js View on Github external
// set this up first, so we can use 127.0.0.1 as our "hosted git" service
const httpPort = 18000 + (+process.env.TAP_CHILD_ID || 0)
const hostedUrl = `http://localhost:${httpPort}`
const ghi = require('hosted-git-info/git-host-info.js')
const gitPort = 12345 + (+process.env.TAP_CHILD_ID || 0)
ghi.localhost = {
  protocols: [ 'git+https', 'git+ssh' ],
  domain: `127.0.0.1:${gitPort}`,
  httpstemplate: 'git://{domain}/{user}{#committish}',
  treepath: 'not-implemented',
  tarballtemplate: `${hostedUrl}/repo-HEAD.tgz`,
  // shortcut MUST have a user and project, at least
  shortcuttemplate: '{type}:{user}/x{#committish}',
  pathtemplate: '/{user}{#committish}',
  pathmatch: /^\/(repo|submodule-repo)/,
  hashformat: h => h,
  protocols_re: /^(git):$/
}
ghi.localhostssh = {
  protocols: [ 'git+ssh' ],
  domain: `localhostssh:${gitPort}`,
  sshtemplate: `git://127.0.0.1:${gitPort}/{user}{#committish}`,
github npm / pacote / test / git.js View on Github external
const ghi = require('hosted-git-info/git-host-info.js')
const gitPort = 12345 + (+process.env.TAP_CHILD_ID || 0)
ghi.localhost = {
  protocols: [ 'git+https', 'git+ssh' ],
  domain: `127.0.0.1:${gitPort}`,
  httpstemplate: 'git://{domain}/{user}{#committish}',
  treepath: 'not-implemented',
  tarballtemplate: `${hostedUrl}/repo-HEAD.tgz`,
  // shortcut MUST have a user and project, at least
  shortcuttemplate: '{type}:{user}/x{#committish}',
  pathtemplate: '/{user}{#committish}',
  pathmatch: /^\/(repo|submodule-repo)/,
  hashformat: h => h,
  protocols_re: /^(git):$/
}
ghi.localhostssh = {
  protocols: [ 'git+ssh' ],
  domain: `localhostssh:${gitPort}`,
  sshtemplate: `git://127.0.0.1:${gitPort}/{user}{#committish}`,
  sshurltemplate: `git://127.0.0.1:${gitPort}/{user}{#committish}`,
  treepath: 'not-implemented',
  tarballtemplate: `${hostedUrl}/repo-HEAD.tgz`,
  // shortcut MUST have a user and project, at least
  shortcuttemplate: '{type}:{user}/x{#committish}',
  pathtemplate: '/{user}{#committish}',
  pathmatch: /^\/(repo|submodule-repo)/,
  hashformat: h => h,
  protocols_re: /^(git):$/
}


const remote = `git://localhost:${gitPort}/repo`
github sindresorhus / np / source / index.js View on Github external
}

	// TODO: Remove sometime far in the future
	if (options.skipCleanup) {
		options.cleanup = false;
	}

	const pkg = util.readPkg();
	const runTests = options.tests && !options.yolo;
	const runCleanup = options.cleanup && !options.yolo;
	const runPublish = options.publish && !pkg.private;
	const pkgManager = options.yarn === true ? 'yarn' : 'npm';
	const pkgManagerName = options.yarn === true ? 'Yarn' : 'npm';
	const rootDir = pkgDir.sync();
	const hasLockFile = fs.existsSync(path.resolve(rootDir, options.yarn ? 'yarn.lock' : 'package-lock.json')) || fs.existsSync(path.resolve(rootDir, 'npm-shrinkwrap.json'));
	const isOnGitHub = options.repoUrl && (hostedGitInfo.fromUrl(options.repoUrl) || {}).type === 'github';

	let publishStatus = 'UNKNOWN';

	const rollback = onetime(async () => {
		console.log('\nPublish failed. Rolling back to the previous state…');

		const tagVersionPrefix = await util.getTagVersionPrefix(options);

		const latestTag = await git.latestTag();
		const versionInLatestTag = latestTag.slice(tagVersionPrefix.length);

		try {
			if (versionInLatestTag === util.readPkg().version &&
				versionInLatestTag !== pkg.version) { // Verify that the package's version has been bumped before deleting the last tag and commit.
				await git.deleteTag(latestTag);
				await git.removeLastCommit();
github embark-framework / embark / packages / core / core / src / utils / template_generator.js View on Github external
// reformat uri before parsing with hosted-git-info. Allows for further syntax support.
    Object.keys(REPLACEMENTS).forEach(replacement => {
      if(uri.indexOf(replacement) === 0) uri = uri.replace(replacement, REPLACEMENTS[replacement]);
    });
    hgi = hostedGitInfo.fromUrl(uri);
    if (!hgi || hgi.user.includes('#')) {
      let templateAndBranch = uri.split('#');
      if (templateAndBranch.length === 1) {
        fallback = true;
        embarkVersion = semver(require(embarkPath('package.json')).version);
        templateAndBranch.push(`${embarkVersion.major}.${embarkVersion.minor}`);
      }
      templateAndBranch[0] = `embark-framework/embark-${templateAndBranch[0]}-template`;
      hgi = hostedGitInfo.fromUrl(templateAndBranch.join('#'));
      if (fallback) {
        hgi_fallback = hostedGitInfo.fromUrl(templateAndBranch[0]);
      }
    }
    if(!hgi) { throw new Error('Unsupported template name or git host URL'); }
    url = hgi.tarball();
    if (fallback) {
      url_fallback = hgi_fallback.tarball();
      folder_fallback = `${hgi_fallback.user}/${hgi_fallback.project}/master`;
    }
    const returnObject = {
      url,
      browse: decodeURIComponent(hgi.browse()),
      url_fallback,
      filePath_fallback: fallback && joinPath(".embark/templates/", folder_fallback, "archive.zip"),
      browse_fallback: fallback && decodeURIComponent(hgi_fallback.browse()),
      embarkVersion
    };
github bolav / fusepm / lib / install.js View on Github external
npm.load(conf, function (er) {
    if (er)
      throw er;
    var parsed = hostedFromURL(package);
    if (parsed) {
      console.log("Installing dependency", parsed.path());
  		git = require('npm/lib/utils/git');
  		var install_path = 'fuse_modules/' + parsed.path();
  		var stats;
  		try {
  			stats = fs.statSync(install_path);
  		}
  		catch (e) {
  		}
  		if (stats && stats.isDirectory()) {
  			return postInstall(package, fn, install_path);
  		}
      cloneRemote(parsed.path(), parsed.toString(), install_path, function (error) {
        if (error) throw error;
        postInstall(package, fn, install_path);
github android-js / androidjs-builder / example / helloworld / node_modules / normalize-package-data / lib / fixer.js View on Github external
, fixBugsField: function(data) {
    if (!data.bugs && data.repository && data.repository.url) {
      var hosted = hostedGitInfo.fromUrl(data.repository.url)
      if(hosted && hosted.bugs()) {
        data.bugs = {url: hosted.bugs()}
      }
    }
    else if(data.bugs) {
      var emailRe = /^.+@.*\..+$/
      if(typeof data.bugs == "string") {
        if(emailRe.test(data.bugs))
          data.bugs = {email:data.bugs}
        else if(url.parse(data.bugs).protocol)
          data.bugs = {url: data.bugs}
        else
          this.warn("nonEmailUrlBugsString")
      }
      else {
        bugsTypos(data.bugs, this.warn)
github npm / normalize-package-data / lib / fixer.js View on Github external
, fixBugsField: function(data) {
    if (!data.bugs && data.repository && data.repository.url) {
      var hosted = hostedGitInfo.fromUrl(data.repository.url)
      if(hosted && hosted.bugs()) {
        data.bugs = {url: hosted.bugs()}
      }
    }
    else if(data.bugs) {
      var emailRe = /^.+@.*\..+$/
      if(typeof data.bugs == "string") {
        if(emailRe.test(data.bugs))
          data.bugs = {email:data.bugs}
        else if(url.parse(data.bugs).protocol)
          data.bugs = {url: data.bugs}
        else
          this.warn("nonEmailUrlBugsString")
      }
      else {
        bugsTypos(data.bugs, this.warn)
github ember-learn / ember-cli-addon-docs / index.js View on Github external
config(env, baseConfig) {
    let pkg = this.parent.pkg;
    if (this._documentingAddonAt()) {
      pkg = require(path.join(this._documentingAddonAt(), 'package.json'));
    }

    let repo = pkg.repository;
    let info = require('hosted-git-info').fromUrl(repo.url || repo);
    let userConfig = this._readUserConfig();

    let docsAppPathInRepo = path.relative(
      this._getRepoRoot(),
      path.join(
        path.resolve(path.dirname(this.project.configPath()), '..'),
        'app'
      )
    );

    let addonPathInRepo = this._documentingAddonAt()
      ? path.relative(this._getRepoRoot(), path.join(this._documentingAddonAt(), 'addon'))
      : path.relative(this._getRepoRoot(), path.join(this.project.root, 'addon'));

    let config = {
      'ember-cli-addon-docs': {
github teppeis / thank-you-stars / lib / getGitRepoInfoFromPackage.js View on Github external
function getGitRepoInfoFromPackage(pkg) {
  normalize(pkg);
  if (pkg.repository && pkg.repository.type === "git") {
    return hostedGitInfo.fromUrl(pkg.repository.url);
  }
  return null;
}
github develar / electron-complete-builder / src / builder.ts View on Github external
export async function createPublisher(packager: Packager, options: BuildOptions): Promise {
  const repo = packager.devMetadata.repository || packager.metadata.repository
  let info: Info = null
  if (repo == null) {
    let url = process.env.TRAVIS_REPO_SLUG || process.env.APPVEYOR_PROJECT_SLUG
    if (url == null) {
      url = await getGitUrlFromGitConfig()
    }

    if (url != null) {
      info = parseRepositoryUrl(url)
    }

    if (info == null) {
      log("Cannot detect repository by .git/config")
      throw new Error("Please specify 'repository' in the dev package.json ('" + packager.devPackageFile + "')")
    }
  }
  else {
    info = parseRepositoryUrl(typeof repo === "string" ? repo : repo.url)
  }
  return new GitHubPublisher(info.user, info.project, packager.metadata.version, options.githubToken)
}

hosted-git-info

Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab

ISC
Latest version published 22 hours ago

Package Health Score

92 / 100
Full package analysis