From f87e5fe831d96d58904e5575eaab8ed41534fa53 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 13 Aug 2020 16:23:13 +0300 Subject: [PATCH] Use v2 subdir in prepare script --- prepare.sh | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/prepare.sh b/prepare.sh index 3594c72..e9cfb22 100755 --- a/prepare.sh +++ b/prepare.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash prefix=v2 @@ -9,35 +9,20 @@ fi API_GO_PATH=$(pwd) API_PATH=$1 +mkdir $API_GO_PATH/$prefix 2>/dev/null # MOVE FILES FROM API REPO cd $API_PATH ARGS=$(find ./ -name '*.proto' -not -path './vendor/*') for file in $ARGS; do dir=$(dirname $file) - cp -r $dir $API_GO_PATH + cp -r $dir $API_GO_PATH/$prefix done -cd $API_GO_PATH +cd $API_GO_PATH/$prefix # MODIFY FILES for file in $ARGS; do - TYPES=$(grep '^import' $file | sed 's/import\ \"\(.*\)\/.*/\1/' | sort | uniq) - PKG=$(grep '^package' $file | sed 's/package\ \(.*\);/\1/') - - TYPES=( "${TYPES[@]}" "${PKG[@]}") # merge two arrays - TYPES=$(printf "%s\n" "${TYPES[@]}" | sort | uniq) # left only uniq elemetns - - for t in $TYPES; do - sed -i "s/$t\./$t\.$prefix\./" $file - sed -i "s/$t\//$t\/$prefix\//" $file - done - - sed -i "s/^package\(.*\);/package\1.$prefix;/" $file - sed -i "s/go_package\(.*\)\";$/go_package\1\/$prefix\";/" $file - - dir=$(dirname $file) - mkdir $dir/v2 2>/dev/null - mv $file $dir/v2 + sed -i "s/import\ \"\(.*\)\";/import\ \"$prefix\/\1\";/" $file done # COMPILE