kramdown-plantuml 1.0.5 → 1.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71464ee363c4a9b9859ffd72421d6840d1f26018a0fdc20eaae4fa4f17011f26
4
- data.tar.gz: f4cde15688ebcc236bfd2e3f5458c8d62722b8ff4fdac2767682f32643839013
3
+ metadata.gz: beba25f229338deced9900f7a611c9040846e562c966de164e88dbb040acadde
4
+ data.tar.gz: 8c2aa7aa04a1a6e59a98032e1cc325544a2be7c3bc3cd407cbb3af09babe390c
5
5
  SHA512:
6
- metadata.gz: ed9a469ba9ec78c8d498fab3cb412220466d76344aadceea56d89634f8f2b25523bc10566a023ecdd7e3a8fa7373a0c49d2677e5ceb6058206e913ffd5cb3a7b
7
- data.tar.gz: 5d969b52c7cf030910cc6ffe6d0c85c7492487c421de35a40e9f6ca965bf35420761ca4be1540eba53eecb339154a94e212815525bd18529d96e3236b9949efb
6
+ metadata.gz: fcdfa9c61a9b2c751aeae743edfb58d81c3602e1eb62f6b8993fd11b2372dd6ee271f77737f655967a093c03a90d0ebf3b4865c703b7a5ed2d7b806c5a4d19d5
7
+ data.tar.gz: d35a3daea2ab515d0fd788d8b2fb0575c4993e4f25ba3c7ebda02631b8ae8d397dc88917b3809cf732e9b9a5d16bbbfa52cdfa2095a682c68de8d6ed8fba3377
@@ -0,0 +1,2 @@
1
+ ignore:
2
+ - "spec"
@@ -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
@@ -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 "$@"
@@ -26,14 +26,32 @@ parse_args() {
26
26
  verbose=true
27
27
  shift
28
28
  elif [[ $1 = "-g" || $1 = "--gem" ]]; then
29
- gem=$2
30
- shift 2
29
+ gem=${2// }
30
+
31
+ if [[ "$gem" = "--"* ]]; then
32
+ gem=""
33
+ shift 1
34
+ else
35
+ shift 2
36
+ fi
31
37
  elif [[ $1 = "-t" || $1 = "--token" ]]; then
32
- token=$2
33
- shift 2
38
+ token=${2// }
39
+
40
+ if [[ "$token" = "--"* ]]; then
41
+ token=""
42
+ shift 1
43
+ else
44
+ shift 2
45
+ fi
34
46
  elif [[ $1 = "-o" || $1 = "--owner" ]]; then
35
- owner=$2
36
- shift 2
47
+ owner=${2// }
48
+
49
+ if [[ "$owner" = "--"* ]]; then
50
+ owner=""
51
+ shift 1
52
+ else
53
+ shift 2
54
+ fi
37
55
  else
38
56
  break
39
57
  fi
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env bash
2
+ # shellcheck disable=3000-SC4000
3
+
2
4
  set -o errexit # Abort if any command fails
3
5
  me=$(basename "$0")
4
6
 
5
7
  help_message="\
6
8
  Usage:
7
- $me --workdir <workdir> [--gemdir <gemdir> | --version <version> --token <token>] [--verbose]
8
- $me --help
9
+ ${me} --workdir <workdir> [--gemdir <gemdir> | --version <version> --token <token>] [--verbose]
10
+ ${me} --help
9
11
  Arguments:
10
12
  -w, --workdir <workdir> The path to the working directory.
11
13
  -g, --gemdir <gemdir> The path to directory of the Gem file to test.
@@ -18,113 +20,139 @@ Arguments:
18
20
  parse_args() {
19
21
  while : ; do
20
22
  if [[ $1 = "-h" || $1 = "--help" ]]; then
21
- echo "$help_message"
23
+ echo "${help_message}"
22
24
  return 0
23
25
  elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
24
26
  verbose=true
25
27
  shift
26
28
  elif [[ $1 = "-g" || $1 = "--gemdir" ]]; then
27
- gemdir=$2
28
- shift 2
29
+ gemdir=${2// }
30
+
31
+ if [[ "${gemdir}" = "--"* ]]; then
32
+ gemdir=""
33
+ shift 1
34
+ else
35
+ shift 2
36
+ fi
29
37
  elif [[ $1 = "-v" || $1 = "--version" ]]; then
30
- version=$2
31
- shift 2
38
+ version=${2// }
39
+
40
+ if [[ "${version}" = "--"* ]]; then
41
+ version=""
42
+ shift 1
43
+ else
44
+ shift 2
45
+ fi
32
46
  elif [[ $1 = "-t" || $1 = "--token" ]]; then
33
- token=$2
34
- shift 2
47
+ token=${2// }
48
+
49
+ if [[ "${token}" = "--"* ]]; then
50
+ token=""
51
+ shift 1
52
+ else
53
+ shift 2
54
+ fi
35
55
  elif [[ $1 = "-w" || $1 = "--workdir" ]]; then
36
- workdir=$2
37
- shift 2
56
+ workdir=${2// }
57
+
58
+ if [[ "${workdir}" = "--"* ]]; then
59
+ workdir=""
60
+ shift 1
61
+ else
62
+ shift 2
63
+ fi
38
64
  else
39
65
  break
40
66
  fi
41
67
  done
42
68
 
43
- if [[ -z "$workdir" ]]; then
69
+ if [[ -z "${workdir}" ]]; then
44
70
  echo "Missing required argument: --workdir <workdir>."
45
- echo "$help_message"
71
+ echo "${help_message}"
46
72
  return 1
47
73
  fi
48
74
 
49
- if [[ (-z "$gemdir" && -z "$token") || (-n "$gemdir" && -n "$token") ]]; then
75
+ if [[ (-z "${gemdir}" && -z "${token}") || (-n "${gemdir}" && -n "${token}") ]]; then
50
76
  echo "Missing or invalid required arguments: --gemdir <gem-path> or --token <token>."
51
77
  echo "Either [--gemdir] or [--token] needs to be provided, but not both."
52
- echo "$help_message"
78
+ echo "${help_message}"
53
79
  return 1
54
80
  fi
55
81
 
56
- if [[ (-n "$version" && -z "$token") || (-z "$version" && -n "$token") ]]; then
82
+ if [[ (-n "${version}" && -z "${token}") || (-z "${version}" && -n "${token}") ]]; then
57
83
  echo "Missing or invalid required arguments: --version <gem-path> and --token <token>."
58
84
  echo "When either argument is present, both must be."
59
- echo "$help_message"
85
+ echo "${help_message}"
60
86
  return 1
61
87
  fi
62
88
  }
63
89
 
64
90
  # Echo expanded commands as they are executed (for debugging)
65
91
  enable_expanded_output() {
66
- if [ $verbose ]; then
92
+ if [ "${verbose}" = true ]; then
67
93
  set -o xtrace
68
94
  set +o verbose
95
+ export VERBOSE=true
69
96
  fi
70
97
  }
71
98
 
72
99
  test_gem() {
73
- cd "$workdir"
100
+ local jekyll_build_args=()
74
101
 
75
- gem install bundler
102
+ cd "${workdir}"
76
103
 
77
- if [[ -n "$token" ]]; then
104
+ if [[ -n "${token}" ]]; then
78
105
  # A non-empty $token means we should install the Gem from GPR
79
106
  repository="https://rubygems.pkg.github.com/swedbankpay"
80
- bundle config "$repository" "SwedbankPay:$token"
81
- printf "source '%s' do\n\tgem 'kramdown-plantuml', '%s'\nend" "$repository" "$version" >> Gemfile
107
+ bundle config "${repository}" "SwedbankPay:${token}"
108
+ printf "source '%s' do\n\tgem 'kramdown-plantuml', '%s'\nend" "${repository}" "${version}" >> Gemfile
82
109
  else
83
- echo "gem 'kramdown-plantuml', path: '$gemdir'" >> Gemfile
110
+ echo "gem 'kramdown-plantuml', path: '${gemdir}'" >> Gemfile
84
111
  fi
85
112
 
86
- if [[ $verbose ]]; then
113
+ if [[ "${verbose}" = true ]]; then
87
114
  cat Gemfile
115
+ jekyll_build_args+=(--verbose)
88
116
  fi
89
117
 
90
118
  bundle install
91
- bundle exec jekyll build
119
+ bundle exec jekyll build "${jekyll_build_args[@]}"
92
120
 
93
- file="$workdir/_site/index.html"
121
+ file="${workdir}/_site/index.html"
94
122
 
95
- file_contains "$file" "class=\"plantuml\""
96
- file_contains "$file" "<svg"
97
- file_contains "$file" "<ellipse"
98
- file_contains "$file" "<polygon"
99
- file_contains "$file" "<path"
123
+ file_contains "${file}" "class=\"plantuml theme-spacelab\""
124
+ file_contains "${file}" "<svg"
125
+ file_contains "${file}" "<ellipse"
126
+ file_contains "${file}" "<polygon"
127
+ file_contains "${file}" "<path"
100
128
  }
101
129
 
102
130
  file_contains() {
103
131
  file=$1
104
132
  contents=$2
105
133
 
106
- if [[ -z "$file" ]]; then
134
+ if [[ -z "${file}" ]]; then
107
135
  echo "file_contains missing required argument <file>."
108
136
  return 1
109
137
  fi
110
138
 
111
- if [[ -z "$contents" ]]; then
139
+ if [[ -z "${contents}" ]]; then
112
140
  echo "file_contains missing required argument <contents>."
113
141
  return 1
114
142
  fi
115
143
 
116
- if [[ ! -f "$file" ]]; then
117
- echo "file_contains <file> not found: '$file'."
144
+ if [[ ! -f "${file}" ]]; then
145
+ echo "file_contains <file> not found: '${file}'."
118
146
  return 1
119
147
  fi
120
148
 
121
- if grep --quiet --fixed-strings "$contents" "$file"; then
122
- echo "Success! '$contents' found in '$file'."
149
+ if grep --quiet --fixed-strings "${contents}" "${file}"; then
150
+ echo "Success! '${contents}' found in '${file}'."
123
151
  else
124
- echo "Failed! '$contents' not found in '$file'."
152
+ echo "Failed! '${contents}' not found in '${file}'."
125
153
 
126
- if [[ $verbose ]]; then
127
- cat "$file"
154
+ if [ "${verbose}" = true ]; then
155
+ cat "${file}"
128
156
  fi
129
157
 
130
158
  return 1