npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

clone-repo

v1.0.2

Published

使用node提取git仓库的下载工具,支持 GitHub,Gitee,GitLab,Bitbucket。

Downloads

12

Readme

clone-repo

使用node提取git仓库的下载工具,支持 GitHub,Gitee,GitLab,Bitbucket。

安装

npm install clone-repo

API

clone-repo(store, destination, options= {})

将目标仓库 store 下载到指定文件夹 destination

可以配置 options 参数,返回Promise。200即代表success。

store

仓库地址简写字符串(当然你也可以直接使用仓库地址,后面会有提到):

  • GitHub —github:账户名/仓库名, 默认是github,故而可以简写为 账户名/仓库名
  • Gitee — gitee:账户名/仓库名
  • GitLab — gitlab:账户名/仓库名
  • Bitbucket — bitbucket:账户名/仓库名

store 参数默认使用 master 主分支,你也可以这样指定分支 账户名/仓库名#分支名

为了指定下类型,你可以指定一个自定义来源:gitlab:xxx.com:账户名/仓库名

除非指定了协议, 否则自定义来源将分别默认为 httpsgit @

direct

使用 direct 将绕过 仓库地址简写字符串 解释器,直接使用 url 地址。

如果在非克隆{clone:false}的情况下使用 direct, 则必使用完整 zip 文件 url ,如果需要,请指定包括分支的完整路径。

如果在克隆{clone:true}的情况下使用 direct,你必须指定 git 仓库的完整地址,可以用 URL 片段指定分支,格式形如: direct:url#分支名

destination

git下载的文件,保存的目标位置。

options

可选参数对象,目前只接受clone{Boolean}默认值false , true 表示使用 git clone 替代 http 下载。

clone

true 会在每次克隆前,删除destination中的所有文件,克隆完成后,会删除destination下所有的.git*文件

return

返回Promise

示例

仓库地址简写字符串

使用 http 方式从 Github 仓库的main 分支下载。

clone-repo("zhangxin1001/xinui-vue#main","test/del").then(()=>{
	//其他操作
})

使用 git clone 方式从 Gitee 仓库的 master 分支下载。

clone-repo("gitee:用户名/仓库名","test/del",{clone:true}).then(()=>{
	//其他操作
})

使用 git clone 方式从 Bitbucket 仓库的 my-branch 分支下载。

clone-repo('bitbucket:用户名/仓库名#my-branch', 'test/del', { clone: true }).then(() => {
	//其他操作
})

使用 http 方式从 GitLab 仓库的 my-branch 分支下载。

clone-repo('gitlab:xxxxgitlab.com:用户名/仓库名#my-branch', 'test/del').then(() => {
	//其他操作
})

直接使用 url(Direct)

直接使用 url 通过 http 下载。

clone-repo('direct:http://git.xxxx.com:8181/xxxxx.git', 'test/del', { clone: true }).then(() => {
	//其他操作
})

License

MIT

声明

本库基于 download-git-repo 3.0.2 版本扩展开发。

download-git-repo 库,虽功能完善,但其不支持Gitee未返回Promise(采用的是callback的方式)。

故此对其做了enhancement。