为了,不一次次重复。集合工作流程为命令,是必要的。 我所有的*-zh 项目:中文翻译 和 *-explain:解释都是从这里开始的。
$ init https://github.com/worrydream/Tangle.git es
$ init https://github.com/worrydream/Tangle.git ex
zh
/explain
的 项目名称,并建立此名称目录git
存储库,放入目录 source
中(此处存在本地/远程的分支,由第三参数决定)git
信息(日期,commit 码)gitignore,readme
… 快速初始化的 js 工具。(运用之前获得的信息+参数).mds-list
文件(使用 find)repo="${1##*/}"
repo=${repo/.git/}
two=$repo
echo "$repo"
source $HOME/.bashrc
if [ "$2" = "ex" ]; then
echo "explain <-><0>"
repodir=$repo'-explain'
else
echo "translate <><>"
repodir=$repo'-zh'
fi
echo "1. $repodir"
mkdir $repodir
cd $repodir
echo "\n2. source dir"
git init
if [ "$3" = "no" ]; then
# es repo.git no local-path
cd -
abspath=$(cd ${4%/*} && echo $PWD/${4##*/})
echo `ln -s $abspath $PWD/$repodir/source`
cd -
else
git clone $1 'source'
fi
cd './source' || mkdir "source"
COMMIT=$(git rev-parse HEAD) && DATE=$(git log -1 --date=short --format="%ad")
cd -
echo "\n3. git info"
echo $1
echo $COMMIT
echo $DATE
if [[ $PWD =~ "-zh" || $PWD =~ "-explain" ]]; then
echo "\n5. mrm ***"
mrm readme --config:repos $2 --config:name $1 --config:commit $COMMIT --config:date $DATE
mrm gitignore
sleep .5
echo "6. find *.md with source into .mds-list"
list="$(find ./source -type f -name \*.md)"
echo "here >>>>>> $list\n"
echo "$list\n" >'./.mds-list'
# for file in $list; do if [ ! -f "$file" ]; then
# echo "MISSING: $file"
# else
# echo "$file\n" >> "./mds-list";
# fi;
# done
echo "7. add sync-en.sh to sync en:*.md with .mds-list "
cat "$HOME/sync-en.sh" >./sync-en.sh
chmod +x ./sync-en.sh
echo "\n8. start translate readme.md and move"
local-translateMds source/readme.md -T 'inlineCode,link' -C
cp source/readme.md ./en.md
echo "\n9. doc-templite"
if [ "$2" = "ex" ]; then
echo "explain"
doc-templite-explain
cat source/readme.zh.md >>./zh.md
else
echo "translate"
doc-templite-translate
cat source/readme.zh.md >>./readme.md
fi
echo "\n10. >> hub cmd to hub-create.sh"
if [ "$2" = "ex" ]; then
huC='hub create -d "explain:<'$two'> something :heart: '$DATE' explaining" '
else
huC='hub create -d "中文翻译:<'$two'> something :heart: '$DATE' working on" '
fi
echo $huC >>hub-create.sh
else
echo "错误 :not in *-zh Dir"
fi
主要是,对.mds-list
的复制
cat './.mds-list' | while read line || [[ -n ${line} ]]
do
testseq="zh.md"
if [[ $line =~ $testseq || "$line" == "" ]]; then
echo "skip $line"
else
lowline=`echo "$line" | awk '{print tolower($0)}'`
# lowwer string
zh=${line//source\//}
dir=$(dirname $zh)
source_readme="./source/readme.md"
if [[ $lowline == $source_readme ]];then
# source/[readme|REAMDE].md => en.md
filename="en.md"
else
# source/other.md => ./other.md
filename=$(basename $zh)
fi
echo "$line >> $dir/$filename"
mkdir -p $dir && cp $line "$_/$filename"
fi
done