批量上传node包到nexus

3 篇文章 0 订阅
#!/bin/bash
# ./batch_bao.sh -u 用户名-p 密码 -r 本地仓库地址
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params
# https://www.jianshu.com/p/c04f1cc65a3d
# nrm use yapi_npm
# npm publish --registry http://10.33.6.49:8081/repository/yapi_npm/
# ./batch_bao.sh -u admin -p admin123 -r http://10.33.6.49:8081/repository/yapi_npm/ -m /home/lizhihua/yapi/vendors/node_modules -f package.json

REPO_URL='http://10.33.6.49:8081/repository/yapi_npm/'
USERNAME='admin'
PASSWORD='admin123'
MULU='.'
HASFILE='package.json'

echo 
while getopts ":r:u:p:m:f:" opt; do
	case $opt in
		r) REPO_URL="$OPTARG"
		;;
		u) USERNAME="$OPTARG"
		;;
		p) PASSWORD="$OPTARG"
		;;
		m) MULU="$OPTARG"
		;;
		f) HASFILE="$OPTARG"
		;;
	esac
done



# 先注释了
# find . -type f -not -path './batch_bao\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;

# echo curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} 

# 判断目录下是否存在 package.json 
for file in "$MULU"/*; 
do 
if [ -d "$file" ]; 
then
	# echo $file 
    #这里写上传代码 $file是目录名
    if [ -f "$file/$HASFILE" ];then
	    echo "$file/$HASFILE"
	    cd "$file"
	    npm publish --registry "$REPO_URL"
	fi;
  
fi; 
done
#!/bin/bash
# ./batch_bao.sh -u 用户名-p 密码 -r 本地仓库地址 -m 目录 -f 检测文件
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params
# https://www.jianshu.com/p/c04f1cc65a3d
# nrm use yapi_npm
# npm publish --registry http://10.33.6.49:8081/repository/yapi_npm/
# ./batch_bao.sh -u admin -p admin123 -r http://10.33.6.49:8081/repository/yapi_npm/ -m /home/lizhihua/yapi/vendors/node_modules -f package.json

REPO_URL='http://10.33.6.49:8081/repository/yapi_npm/'
USERNAME='admin'
PASSWORD='admin123'
MULU='.'
HASFILE='package.json'

echo 
while getopts ":r:u:p:m:f:" opt; do
	case $opt in
		r) REPO_URL="$OPTARG"
		;;
		u) USERNAME="$OPTARG"
		;;
		p) PASSWORD="$OPTARG"
		;;
		m) MULU="$OPTARG"
		;;
		f) HASFILE="$OPTARG"
		;;
	esac
done



# 先注释了
# find . -type f -not -path './batch_bao\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;

# echo curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} 

# 判断目录下是否存在 package.json 
for file in "$MULU"/*; 
do 
if [ -d "$file" ]; 
then
	# echo $file 
    #这里写上传代码 $file是目录名
    if [ -f "$file/$HASFILE" ];then
	    echo "$file/$HASFILE"
	    cd "$file"
	    npm publish --registry "$REPO_URL"
	fi;
  
fi; 
done


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值