manage.sh 2.29 KB
Newer Older
rinpatch's avatar
rinpatch committed
1
2
3
4
5
#!/bin/sh

fetch() {
  if [ $LOCAL = false ]; then
    mkdir .tmp
6
    git clone $FRONTEND_REPO --branch develop --depth 1 .tmp/fe
rinpatch's avatar
rinpatch committed
7
8
    git clone $BACKEND_REPO --branch $BRANCH --depth 1 .tmp/be
    FRONTEND_REPO=.tmp/fe
rinpatch's avatar
rinpatch committed
9
    BACKEND_REPO=.tmp/be
rinpatch's avatar
rinpatch committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  fi
  rm -rf docs/frontend
  rm -rf docs/backend
  mkdir docs/frontend
  mkdir docs/backend
  cp -r $FRONTEND_REPO/docs/* docs/frontend
  cp -r $BACKEND_REPO/docs/* docs/backend
  rm -rf .tmp
}

build() {
  mkdocs build
}

all() {
	fetch
	build
}

29
30
FRONTEND_REMOTE_REPO_DEFAULT='https://git.pleroma.social/pleroma/pleroma-fe.git'
BACKEND_REMOTE_REPO_DEFAULT='https://git.pleroma.social/pleroma/pleroma.git'
rinpatch's avatar
rinpatch committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

FRONTEND_LOCAL_REPO_DEFAULT='../pleroma-fe'
BACKEND_LOCAL_REPO_DEFAULT='../pleroma'
BRANCH='develop'

if [ -z "$1" ] || [ "$1" = "--help" ]; then
	echo "Usage: $(basename "$0") <stage> [<options>]

  The stages are:

  fetch [<options>]
    Fetch frontend and backend documentation and dump it into \`docs\`.
    The location of frontend and backend repositories defaults to
    $FRONTEND_REMOTE_REPO_DEFAULT and $BACKEND_REMOTE_REPO_DEFAULT
    respectively and can be overriden by \`--frontend-repo\` and \`--backend-repo\`.
    The branch defaults to \`$BRANCH\` and can be overriden by \`--branch\`.

    If you want to use local copies of the repositories, add \`--local\`
    to options. Then the location of frontend and backend repositiories
    will default to $FRONTEND_LOCAL_REPO_DEFAULT and $BACKEND_LOCAL_REPO_DEFAULT respectively and
    can be overriden by \`--frontend-repo\` and \`--backend-repo\` as well.

  build [<options>]
   Build the documentation

  all [<options>]
   Execute all stages
  "
else
	LOCAL=false
        stage="$1"
	shift
	while echo "$1" | grep "^-" > /dev/null; do
		case "$1" in
		--local)
			LOCAL=true
			shift
			;;
		--frontend-repo)
			FRONTEND_REPO="$2"
			shift 2
			;;
		--backend-repo)
			BACKEND_REPO="$2"
			shift 2
			;;
77
		--branch)
78
			BRANCH="$2"
79
80
			shift 2
			;;
rinpatch's avatar
rinpatch committed
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
		-*)
			echo "invalid option: $1" 1>&2
			shift 1
			;;
		esac
	done
	if [ $LOCAL = true ]; then
	  FRONTEND_REPO="${FRONTEND_REPO:-$FRONTEND_LOCAL_REPO_DEFAULT}"
	  BACKEND_REPO="${BACKEND_REPO:-$BACKEND_LOCAL_REPO_DEFAULT}"
	else
	  FRONTEND_REPO="${FRONTEND_REPO:-$FRONTEND_REMOTE_REPO_DEFAULT}"
	  BACKEND_REPO="${BACKEND_REPO:-$BACKEND_REMOTE_REPO_DEFAULT}"
	fi
	$stage
fi