kramdown-plantuml 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/codecov.yml +2 -0
- data/.github/dependabot.yml +23 -0
- data/.github/mergify.yml +22 -0
- data/.github/scripts/amend.sh +176 -0
- data/.github/scripts/build-gem.sh +6 -0
- data/.github/scripts/inspect-gem.sh +72 -0
- data/.github/scripts/publish-gem.sh +121 -0
- data/.github/scripts/test-gem.sh +170 -0
- data/.github/scripts/variables.sh +72 -0
- data/.github/workflows/amend.yml +19 -0
- data/.github/workflows/no-java.yml +22 -0
- data/.github/workflows/no-plantuml.yml +23 -0
- data/.github/workflows/ruby.yml +176 -0
- data/.github/workflows/shell.yml +11 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/.rubocop.yml +18 -0
- data/CODE_OF_CONDUCT.md +131 -0
- data/Gemfile +8 -0
- data/GitVersion.yml +5 -0
- data/LICENSE +201 -0
- data/README.md +208 -0
- data/Rakefile +40 -0
- data/bin/net/sourceforge/plantuml/plantuml/1.2021.8/plantuml-1.2021.8.jar +0 -0
- data/kramdown-plantuml.gemspec +48 -0
- data/lib/kramdown-plantuml.rb +5 -0
- data/lib/kramdown-plantuml/bool_env.rb +24 -0
- data/lib/kramdown-plantuml/console_logger.rb +56 -0
- data/lib/kramdown-plantuml/converter.rb +42 -0
- data/lib/kramdown-plantuml/executor.rb +48 -0
- data/lib/kramdown-plantuml/hash.rb +14 -0
- data/lib/kramdown-plantuml/logger.rb +68 -0
- data/lib/kramdown-plantuml/plantuml_error.rb +33 -0
- data/lib/kramdown-plantuml/plantuml_result.rb +49 -0
- data/lib/kramdown-plantuml/themer.rb +50 -0
- data/lib/kramdown-plantuml/version.rb +7 -0
- data/lib/kramdown_html.rb +27 -0
- data/lib/which.rb +15 -0
- data/pom.xml +16 -0
- metadata +148 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 488e793ad6c95b20619319fdec43866b7a96369321767eb415c441b2d8946c0c
|
4
|
+
data.tar.gz: 2f9b7957b2b7d09ebe2758d1fc3f3600c7464f2ccee53d5ea11f04bf25b0df33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e4547033622f876ea2c63eb4af2f73433e57fa4cbe8bdd818bbcb5261f4bef829f50da55b9f5485023e5c040d7c260844f27fcf2a67f17858839aa4e9f0dab3
|
7
|
+
data.tar.gz: cd38086b669bf27b64ccae97f45005a23a508fdfd94647e40c2f8e9960a89edc0abd2781c74fb42493c1b1df7bd5c0aaee6c19acd63cf20394d594c077cc072d
|
data/.github/codecov.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: bundler
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: daily
|
7
|
+
time: "03:00"
|
8
|
+
timezone: Europe/Oslo
|
9
|
+
open-pull-requests-limit: 99
|
10
|
+
- package-ecosystem: maven
|
11
|
+
directory: "/"
|
12
|
+
schedule:
|
13
|
+
interval: daily
|
14
|
+
time: "03:00"
|
15
|
+
timezone: Europe/Oslo
|
16
|
+
open-pull-requests-limit: 99
|
17
|
+
- package-ecosystem: github-actions
|
18
|
+
directory: "/"
|
19
|
+
schedule:
|
20
|
+
interval: daily
|
21
|
+
time: "03:00"
|
22
|
+
timezone: Europe/Oslo
|
23
|
+
open-pull-requests-limit: 99
|
data/.github/mergify.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
pull_request_rules:
|
2
|
+
- name: Automatic approve on dependabot PR
|
3
|
+
conditions:
|
4
|
+
- author~=^dependabot(|-preview)\[bot\]$
|
5
|
+
actions:
|
6
|
+
review:
|
7
|
+
type: APPROVE
|
8
|
+
|
9
|
+
- name: Automatic merge on approval
|
10
|
+
conditions:
|
11
|
+
- author~=^dependabot(|-preview)\[bot\]$
|
12
|
+
actions:
|
13
|
+
merge:
|
14
|
+
method: merge
|
15
|
+
strict: smart
|
16
|
+
|
17
|
+
- name: Thank contributor
|
18
|
+
conditions:
|
19
|
+
- merged
|
20
|
+
actions:
|
21
|
+
comment:
|
22
|
+
message: "Thank you @{{author}} for your contribution!"
|
@@ -0,0 +1,176 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -o errexit # Abort if any command fails
|
3
|
+
me=$(basename "$0")
|
4
|
+
|
5
|
+
help_message="\
|
6
|
+
Usage: echo $me --user <username>
|
7
|
+
|
8
|
+
Checks out the pull request where an '/amend' comment is made and amends its
|
9
|
+
latest commit with the credentials of the user who wrote the '/amend' comment.
|
10
|
+
|
11
|
+
Arguments:
|
12
|
+
-u, --user The user name to use when authenticating against the remote
|
13
|
+
Git repository.
|
14
|
+
-h, --help Displays this help screen.
|
15
|
+
-v, --verbose Increase verbosity. Useful for debugging.
|
16
|
+
|
17
|
+
Environment Variables:
|
18
|
+
GITHUB_CONTEXT: An environment variable containing a JSON string of the GitHub
|
19
|
+
context object. Typically generated with \${{ toJson(github) }}.
|
20
|
+
GITHUB_TOKEN: The personal access token to use to authenticate against the
|
21
|
+
remote Git repository."
|
22
|
+
|
23
|
+
parse_args() {
|
24
|
+
while : ; do
|
25
|
+
if [[ $1 = "-h" || $1 = "--help" ]]; then
|
26
|
+
echo "$help_message"
|
27
|
+
return 0
|
28
|
+
elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
|
29
|
+
verbose=true
|
30
|
+
shift
|
31
|
+
elif [[ ( $1 = "-u" || $1 = "--user" ) && -n $2 ]]; then
|
32
|
+
auth_user=$2
|
33
|
+
shift 2
|
34
|
+
else
|
35
|
+
break
|
36
|
+
fi
|
37
|
+
done
|
38
|
+
}
|
39
|
+
|
40
|
+
parse_github_context() {
|
41
|
+
github_context_json="$GITHUB_CONTEXT"
|
42
|
+
|
43
|
+
if [[ -z "$github_context_json" ]]; then
|
44
|
+
echo "Missing or empty GITHUB_CONTEXT environment variable." >&2
|
45
|
+
echo "$help_message"
|
46
|
+
exit 1
|
47
|
+
fi
|
48
|
+
|
49
|
+
if [[ -z "$GITHUB_TOKEN" ]]; then
|
50
|
+
echo "Missing or empty GITHUB_TOKEN environment variable." >&2
|
51
|
+
echo "$help_message"
|
52
|
+
exit 1
|
53
|
+
fi
|
54
|
+
|
55
|
+
if [[ -z "$auth_user" ]]; then
|
56
|
+
echo "Missing or empty 'auth_user' argument." >&2
|
57
|
+
echo "$help_message"
|
58
|
+
exit 1
|
59
|
+
fi
|
60
|
+
|
61
|
+
sha=$(echo "$github_context_json" | jq --raw-output .sha)
|
62
|
+
pr_url=$(echo "$github_context_json" | jq --raw-output .event.issue.pull_request.html_url)
|
63
|
+
sender_login=$(echo "$github_context_json" | jq --raw-output .event.sender.login)
|
64
|
+
sender_url=$(echo "$github_context_json" | jq --raw-output .event.sender.url)
|
65
|
+
repo_url=$(echo "$github_context_json" | jq --raw-output .event.repository.html_url)
|
66
|
+
repo_clone_url=$(echo "$github_context_json" | jq --raw-output .event.repository.clone_url)
|
67
|
+
collaborators_url=$(echo "$github_context_json" | jq --raw-output .event.repository.collaborators_url)
|
68
|
+
|
69
|
+
if [[ -z "$sha" ]]; then
|
70
|
+
echo "No 'sha' found in the GitHub context." >&2
|
71
|
+
echo "$help_message"
|
72
|
+
exit 1
|
73
|
+
fi
|
74
|
+
|
75
|
+
if [[ -z "$pr_url" ]]; then
|
76
|
+
echo "No 'event.issue.pull_request.html_url' found in the GitHub context." >&2
|
77
|
+
echo "$help_message"
|
78
|
+
exit 1
|
79
|
+
fi
|
80
|
+
|
81
|
+
if [[ -z "$sender_login" ]]; then
|
82
|
+
echo "No 'event.sender.login' found in the GitHub context." >&2
|
83
|
+
echo "$help_message"
|
84
|
+
exit 1
|
85
|
+
fi
|
86
|
+
|
87
|
+
if [[ -z "$sender_url" ]]; then
|
88
|
+
echo "No 'event.sender.url' found in the GitHub context." >&2
|
89
|
+
echo "$help_message"
|
90
|
+
exit 1
|
91
|
+
fi
|
92
|
+
|
93
|
+
if [[ -z "$repo_url" ]]; then
|
94
|
+
echo "No 'event.repository.html_url' found in the GitHub context." >&2
|
95
|
+
echo "$help_message"
|
96
|
+
exit 1
|
97
|
+
fi
|
98
|
+
|
99
|
+
if [[ -z "$repo_clone_url" ]]; then
|
100
|
+
echo "No 'event.repository.clone_url' found in the GitHub context." >&2
|
101
|
+
echo "$help_message"
|
102
|
+
exit 1
|
103
|
+
fi
|
104
|
+
|
105
|
+
if [[ -z "$collaborators_url" ]]; then
|
106
|
+
echo "No 'event.repository.collaborators_url' found in the GitHub context." >&2
|
107
|
+
echo "$help_message"
|
108
|
+
exit 1
|
109
|
+
fi
|
110
|
+
|
111
|
+
user_json=$(gh api -X GET "$sender_url")
|
112
|
+
|
113
|
+
if [[ -z "$user_json" ]]; then
|
114
|
+
echo "The request for '$sender_url' failed." >&2
|
115
|
+
echo "$help_message"
|
116
|
+
exit 1
|
117
|
+
fi
|
118
|
+
|
119
|
+
name=$(echo "$user_json" | jq --raw-output .name)
|
120
|
+
email=$(echo "$user_json" | jq --raw-output .email)
|
121
|
+
|
122
|
+
if [[ -z "$name" ]]; then
|
123
|
+
echo "No 'name' found in '$sender_url'." >&2
|
124
|
+
echo "$help_message"
|
125
|
+
exit 1
|
126
|
+
fi
|
127
|
+
|
128
|
+
if [[ -z "$email" ]]; then
|
129
|
+
echo "No 'email' found in '$sender_url'." >&2
|
130
|
+
echo "$help_message"
|
131
|
+
exit 1
|
132
|
+
fi
|
133
|
+
|
134
|
+
# Replace the template part of the URL with the sender_login (collaborator).
|
135
|
+
# https://api.github.com/repos/asbjornu/test/collaborators{/collaborator}
|
136
|
+
collaborator_url="${collaborators_url/\{\/collaborator\}//$sender_login}"
|
137
|
+
|
138
|
+
# Add sender_login and password to the repository clone URL
|
139
|
+
authenticated_repo_url="${repo_clone_url/github\.com/$auth_user:$GITHUB_TOKEN@github.com}"
|
140
|
+
}
|
141
|
+
|
142
|
+
# echo expanded commands as they are executed (for debugging)
|
143
|
+
enable_expanded_output() {
|
144
|
+
if [ $verbose ]; then
|
145
|
+
set -o xtrace
|
146
|
+
set +o verbose
|
147
|
+
fi
|
148
|
+
}
|
149
|
+
|
150
|
+
amend() {
|
151
|
+
gh pr checkout "$pr_url"
|
152
|
+
gh pr comment --body "The commit $sha is being amended."
|
153
|
+
git config --global user.name "$name"
|
154
|
+
git config --global user.email "$email"
|
155
|
+
git remote set-url origin "$authenticated_repo_url"
|
156
|
+
git commit --amend --no-edit
|
157
|
+
git push --force
|
158
|
+
}
|
159
|
+
|
160
|
+
main() {
|
161
|
+
parse_args "$@"
|
162
|
+
enable_expanded_output
|
163
|
+
parse_github_context
|
164
|
+
|
165
|
+
# If the request for </repos/{owner}/{repo}/collaborators/{sender_login}>
|
166
|
+
# fails (404 not found), `gh` should return 1 and thus fail the entire
|
167
|
+
# script. For more information, see:
|
168
|
+
# https://docs.github.com/en/rest/reference/repos#check-if-a-user-is-a-repository-collaborator
|
169
|
+
if gh api -X GET "$collaborator_url" > /dev/null; then
|
170
|
+
amend
|
171
|
+
else
|
172
|
+
echo "'$sender_login' does not have access to the repository <$repo_url>."
|
173
|
+
fi
|
174
|
+
}
|
175
|
+
|
176
|
+
main "$@"
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e # Abort if any command fails
|
3
|
+
me=$(basename "$0")
|
4
|
+
|
5
|
+
help_message="\
|
6
|
+
Usage:
|
7
|
+
$me --gem <gem> [--verbose]
|
8
|
+
$me --help
|
9
|
+
Arguments:
|
10
|
+
-g, --gem <gem> The path to the Gem file to inspect.
|
11
|
+
-h, --help Displays this help screen.
|
12
|
+
-v, --verbose Increase verbosity. Useful for debugging."
|
13
|
+
|
14
|
+
parse_args() {
|
15
|
+
while : ; do
|
16
|
+
if [[ $1 = "-h" || $1 = "--help" ]]; then
|
17
|
+
echo "$help_message"
|
18
|
+
return 0
|
19
|
+
elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
|
20
|
+
verbose=true
|
21
|
+
shift
|
22
|
+
elif [[ $1 = "-g" || $1 = "--gem" ]]; then
|
23
|
+
gem=$2
|
24
|
+
shift 2
|
25
|
+
else
|
26
|
+
break
|
27
|
+
fi
|
28
|
+
done
|
29
|
+
|
30
|
+
if [[ -z "$gem" ]]; then
|
31
|
+
echo "Missing required argument: --gem <gem>."
|
32
|
+
echo "$help_message"
|
33
|
+
return 1
|
34
|
+
fi
|
35
|
+
}
|
36
|
+
|
37
|
+
# Echo expanded commands as they are executed (for debugging)
|
38
|
+
enable_expanded_output() {
|
39
|
+
if [ $verbose ]; then
|
40
|
+
echo "Verbose mode enabled."
|
41
|
+
set -o xtrace
|
42
|
+
set +o verbose
|
43
|
+
fi
|
44
|
+
}
|
45
|
+
|
46
|
+
inspect_gem() {
|
47
|
+
gem unpack "$gem"
|
48
|
+
gem_dir="${gem%.*}"
|
49
|
+
|
50
|
+
if [ $verbose ]; then
|
51
|
+
echo "Files in '$gem_dir':"
|
52
|
+
find "$gem_dir"
|
53
|
+
fi
|
54
|
+
|
55
|
+
if [[ ! -d "$gem_dir/bin" ]]; then
|
56
|
+
echo "ERROR! 'bin' folder missing from '$gem'."
|
57
|
+
return 1
|
58
|
+
fi
|
59
|
+
|
60
|
+
if ! (find "$gem_dir" -iname "plantuml*.jar" | grep -q .); then
|
61
|
+
echo "ERROR! 'plantuml.jar' missing from '$gem'."
|
62
|
+
return 1
|
63
|
+
fi
|
64
|
+
}
|
65
|
+
|
66
|
+
main() {
|
67
|
+
parse_args "$@"
|
68
|
+
enable_expanded_output
|
69
|
+
inspect_gem
|
70
|
+
}
|
71
|
+
|
72
|
+
main "$@"
|
@@ -0,0 +1,121 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e # Abort if any command fails
|
3
|
+
|
4
|
+
me=$(basename "$0")
|
5
|
+
|
6
|
+
help_message="\
|
7
|
+
Usage:
|
8
|
+
$me --gem <gem-path> --token <token> [--owner <owner>] [--verbose]
|
9
|
+
$me --help
|
10
|
+
Arguments:
|
11
|
+
-g, --gem <gem-path> The path of the Gem to publish.
|
12
|
+
-t, --token <token> The access token to use for publishing the gem to
|
13
|
+
the specified registry.
|
14
|
+
-o, --owner <owner> The owner to use when publishing to the GitHub
|
15
|
+
Package Registry. If empty, will publish to
|
16
|
+
RubyGems.org.
|
17
|
+
-h, --help Displays this help screen.
|
18
|
+
-v, --verbose Increase verbosity. Useful for debugging."
|
19
|
+
|
20
|
+
parse_args() {
|
21
|
+
while : ; do
|
22
|
+
if [[ $1 = "-h" || $1 = "--help" ]]; then
|
23
|
+
echo "$help_message"
|
24
|
+
return 0
|
25
|
+
elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
|
26
|
+
verbose=true
|
27
|
+
shift
|
28
|
+
elif [[ $1 = "-g" || $1 = "--gem" ]]; then
|
29
|
+
gem=${2// }
|
30
|
+
|
31
|
+
if [[ "$gem" = "--"* ]]; then
|
32
|
+
gem=""
|
33
|
+
shift 1
|
34
|
+
else
|
35
|
+
shift 2
|
36
|
+
fi
|
37
|
+
elif [[ $1 = "-t" || $1 = "--token" ]]; then
|
38
|
+
token=${2// }
|
39
|
+
|
40
|
+
if [[ "$token" = "--"* ]]; then
|
41
|
+
token=""
|
42
|
+
shift 1
|
43
|
+
else
|
44
|
+
shift 2
|
45
|
+
fi
|
46
|
+
elif [[ $1 = "-o" || $1 = "--owner" ]]; then
|
47
|
+
owner=${2// }
|
48
|
+
|
49
|
+
if [[ "$owner" = "--"* ]]; then
|
50
|
+
owner=""
|
51
|
+
shift 1
|
52
|
+
else
|
53
|
+
shift 2
|
54
|
+
fi
|
55
|
+
else
|
56
|
+
break
|
57
|
+
fi
|
58
|
+
done
|
59
|
+
|
60
|
+
if [[ -z "$gem" ]]; then
|
61
|
+
echo "Missing required argument: --gem <gem>."
|
62
|
+
echo "$help_message"
|
63
|
+
return 1
|
64
|
+
fi
|
65
|
+
|
66
|
+
if [[ -z "$token" ]]; then
|
67
|
+
echo "Missing required argument: --token <token>."
|
68
|
+
echo "$help_message"
|
69
|
+
return 1
|
70
|
+
fi
|
71
|
+
}
|
72
|
+
|
73
|
+
# Echo expanded commands as they are executed (for debugging)
|
74
|
+
enable_expanded_output() {
|
75
|
+
if [ $verbose ]; then
|
76
|
+
set -o xtrace
|
77
|
+
set +o verbose
|
78
|
+
fi
|
79
|
+
}
|
80
|
+
|
81
|
+
publish_gem() {
|
82
|
+
gem_home="$HOME/.gem"
|
83
|
+
credentials_file="$gem_home/credentials"
|
84
|
+
|
85
|
+
if [[ -n "$owner" ]]; then
|
86
|
+
auth_header="github: Bearer"
|
87
|
+
host="https://rubygems.pkg.github.com/$owner"
|
88
|
+
else
|
89
|
+
auth_header="rubygems_api_key:"
|
90
|
+
fi
|
91
|
+
|
92
|
+
mkdir -p "$gem_home"
|
93
|
+
touch "$credentials_file"
|
94
|
+
chmod 0600 "$credentials_file"
|
95
|
+
printf -- "---\n:%s %s\n" "$auth_header" "$token" > "$credentials_file"
|
96
|
+
|
97
|
+
if [[ -n "$host" ]]; then
|
98
|
+
if ! result=$(gem push --KEY github --host "$host" "$gem"); then
|
99
|
+
echo "ERROR: gem push failed."
|
100
|
+
|
101
|
+
if [[ $result == *"has already been pushed"* ]]; then
|
102
|
+
echo "ERROR: $gem has already been pushed."
|
103
|
+
# Silently ignore 'already been pushed' Gem errors.
|
104
|
+
return 0
|
105
|
+
else
|
106
|
+
echo "$result"
|
107
|
+
return 1
|
108
|
+
fi
|
109
|
+
fi
|
110
|
+
else
|
111
|
+
gem push "$gem"
|
112
|
+
fi
|
113
|
+
}
|
114
|
+
|
115
|
+
main() {
|
116
|
+
parse_args "$@"
|
117
|
+
enable_expanded_output
|
118
|
+
publish_gem
|
119
|
+
}
|
120
|
+
|
121
|
+
main "$@"
|
@@ -0,0 +1,170 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
# shellcheck disable=3000-SC4000
|
3
|
+
|
4
|
+
set -o errexit # Abort if any command fails
|
5
|
+
me=$(basename "$0")
|
6
|
+
|
7
|
+
help_message="\
|
8
|
+
Usage:
|
9
|
+
${me} --workdir <workdir> [--gemdir <gemdir> | --version <version> --token <token>] [--verbose]
|
10
|
+
${me} --help
|
11
|
+
Arguments:
|
12
|
+
-w, --workdir <workdir> The path to the working directory.
|
13
|
+
-g, --gemdir <gemdir> The path to directory of the Gem file to test.
|
14
|
+
-v, --version <version> The version of the Gem to test.
|
15
|
+
-t, --token <token> The GitHub token to use for retrieving the gem
|
16
|
+
from the GitHub Package Registry.
|
17
|
+
-h, --help Displays this help screen.
|
18
|
+
-v, --verbose Increase verbosity. Useful for debugging."
|
19
|
+
|
20
|
+
parse_args() {
|
21
|
+
while : ; do
|
22
|
+
if [[ $1 = "-h" || $1 = "--help" ]]; then
|
23
|
+
echo "${help_message}"
|
24
|
+
return 0
|
25
|
+
elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
|
26
|
+
verbose=true
|
27
|
+
shift
|
28
|
+
elif [[ $1 = "-g" || $1 = "--gemdir" ]]; then
|
29
|
+
gemdir=${2// }
|
30
|
+
|
31
|
+
if [[ "${gemdir}" = "--"* ]]; then
|
32
|
+
gemdir=""
|
33
|
+
shift 1
|
34
|
+
else
|
35
|
+
shift 2
|
36
|
+
fi
|
37
|
+
elif [[ $1 = "-v" || $1 = "--version" ]]; then
|
38
|
+
version=${2// }
|
39
|
+
|
40
|
+
if [[ "${version}" = "--"* ]]; then
|
41
|
+
version=""
|
42
|
+
shift 1
|
43
|
+
else
|
44
|
+
shift 2
|
45
|
+
fi
|
46
|
+
elif [[ $1 = "-t" || $1 = "--token" ]]; then
|
47
|
+
token=${2// }
|
48
|
+
|
49
|
+
if [[ "${token}" = "--"* ]]; then
|
50
|
+
token=""
|
51
|
+
shift 1
|
52
|
+
else
|
53
|
+
shift 2
|
54
|
+
fi
|
55
|
+
elif [[ $1 = "-w" || $1 = "--workdir" ]]; then
|
56
|
+
workdir=${2// }
|
57
|
+
|
58
|
+
if [[ "${workdir}" = "--"* ]]; then
|
59
|
+
workdir=""
|
60
|
+
shift 1
|
61
|
+
else
|
62
|
+
shift 2
|
63
|
+
fi
|
64
|
+
else
|
65
|
+
break
|
66
|
+
fi
|
67
|
+
done
|
68
|
+
|
69
|
+
if [[ -z "${workdir}" ]]; then
|
70
|
+
echo "Missing required argument: --workdir <workdir>."
|
71
|
+
echo "${help_message}"
|
72
|
+
return 1
|
73
|
+
fi
|
74
|
+
|
75
|
+
if [[ (-z "${gemdir}" && -z "${token}") || (-n "${gemdir}" && -n "${token}") ]]; then
|
76
|
+
echo "Missing or invalid required arguments: --gemdir <gem-path> or --token <token>."
|
77
|
+
echo "Either [--gemdir] or [--token] needs to be provided, but not both."
|
78
|
+
echo "${help_message}"
|
79
|
+
return 1
|
80
|
+
fi
|
81
|
+
|
82
|
+
if [[ (-n "${version}" && -z "${token}") || (-z "${version}" && -n "${token}") ]]; then
|
83
|
+
echo "Missing or invalid required arguments: --version <gem-path> and --token <token>."
|
84
|
+
echo "When either argument is present, both must be."
|
85
|
+
echo "${help_message}"
|
86
|
+
return 1
|
87
|
+
fi
|
88
|
+
}
|
89
|
+
|
90
|
+
# Echo expanded commands as they are executed (for debugging)
|
91
|
+
enable_expanded_output() {
|
92
|
+
if [ "${verbose}" = true ]; then
|
93
|
+
set -o xtrace
|
94
|
+
set +o verbose
|
95
|
+
export VERBOSE=true
|
96
|
+
fi
|
97
|
+
}
|
98
|
+
|
99
|
+
test_gem() {
|
100
|
+
local jekyll_build_args=()
|
101
|
+
|
102
|
+
cd "${workdir}"
|
103
|
+
|
104
|
+
gem install bundler
|
105
|
+
|
106
|
+
if [[ -n "${token}" ]]; then
|
107
|
+
# A non-empty $token means we should install the Gem from GPR
|
108
|
+
repository="https://rubygems.pkg.github.com/swedbankpay"
|
109
|
+
bundle config "${repository}" "SwedbankPay:${token}"
|
110
|
+
printf "source '%s' do\n\tgem 'kramdown-plantuml', '%s'\nend" "${repository}" "${version}" >> Gemfile
|
111
|
+
else
|
112
|
+
echo "gem 'kramdown-plantuml', path: '${gemdir}'" >> Gemfile
|
113
|
+
fi
|
114
|
+
|
115
|
+
if [[ "${verbose}" = true ]]; then
|
116
|
+
cat Gemfile
|
117
|
+
jekyll_build_args+=(--verbose)
|
118
|
+
fi
|
119
|
+
|
120
|
+
bundle install
|
121
|
+
bundle exec jekyll build "${jekyll_build_args[@]}"
|
122
|
+
|
123
|
+
file="${workdir}/_site/index.html"
|
124
|
+
|
125
|
+
file_contains "${file}" "class=\"plantuml theme-spacelab\""
|
126
|
+
file_contains "${file}" "<svg"
|
127
|
+
file_contains "${file}" "<ellipse"
|
128
|
+
file_contains "${file}" "<polygon"
|
129
|
+
file_contains "${file}" "<path"
|
130
|
+
}
|
131
|
+
|
132
|
+
file_contains() {
|
133
|
+
file=$1
|
134
|
+
contents=$2
|
135
|
+
|
136
|
+
if [[ -z "${file}" ]]; then
|
137
|
+
echo "file_contains missing required argument <file>."
|
138
|
+
return 1
|
139
|
+
fi
|
140
|
+
|
141
|
+
if [[ -z "${contents}" ]]; then
|
142
|
+
echo "file_contains missing required argument <contents>."
|
143
|
+
return 1
|
144
|
+
fi
|
145
|
+
|
146
|
+
if [[ ! -f "${file}" ]]; then
|
147
|
+
echo "file_contains <file> not found: '${file}'."
|
148
|
+
return 1
|
149
|
+
fi
|
150
|
+
|
151
|
+
if grep --quiet --fixed-strings "${contents}" "${file}"; then
|
152
|
+
echo "Success! '${contents}' found in '${file}'."
|
153
|
+
else
|
154
|
+
echo "Failed! '${contents}' not found in '${file}'."
|
155
|
+
|
156
|
+
if [ "${verbose}" = true ]; then
|
157
|
+
cat "${file}"
|
158
|
+
fi
|
159
|
+
|
160
|
+
return 1
|
161
|
+
fi
|
162
|
+
}
|
163
|
+
|
164
|
+
main() {
|
165
|
+
parse_args "$@"
|
166
|
+
enable_expanded_output
|
167
|
+
test_gem
|
168
|
+
}
|
169
|
+
|
170
|
+
main "$@"
|