@suffolklitlab/alkiln 5.13.0 → 5.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "5.13.0",
3
+ "version": "5.13.1",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -37,21 +37,21 @@
37
37
  "@axe-core/puppeteer": "4.7.3",
38
38
  "@cucumber/cucumber": "9.3.0",
39
39
  "@faker-js/faker": "7.3.0",
40
- "axios": "0.24.0",
40
+ "axios": "1.7.3",
41
41
  "chai": "4.2.0",
42
42
  "cheerio": "1.0.0-rc.10",
43
43
  "deep-equal-in-any-order": "2.0.0",
44
+ "diff": "5.0.0",
44
45
  "dotenv": "8.2.0",
45
46
  "fast-glob": "3.2.12",
46
47
  "minimatch": "3.0.5",
47
48
  "minimist": "1.2.8",
48
49
  "mocha": "9.2.2",
49
- "puppeteer": "20.8.2",
50
+ "pdfjs-dist": "3.11.174",
51
+ "puppeteer": "22.15.0",
50
52
  "qs": "6.10.3",
51
53
  "sanitize-filename": "1.6.3",
52
- "uuid": "8.3.2",
53
- "pdfjs-dist": "3.2.146",
54
- "diff": "5.0.0"
54
+ "uuid": "8.3.2"
55
55
  },
56
56
  "bin": {
57
57
  "alkiln-server-install": "./lib/docassemble/server_install.js",
@@ -1,139 +1,193 @@
1
1
  #!/bin/bash
2
2
 
3
- # Identify missing and duplicate message code issues
3
+ # Identify missing and/or duplicate log codes
4
+
5
+ # Profiling performance
6
+ # set -x
7
+ # PS4='+ $EPOCHREALTIME ($LINENO) '
8
+ # alias echo='time echo'
4
9
 
5
10
  exit_code=0
6
11
 
7
- # Check if the caller sent an argument to the script
8
- if [ $# -eq 0 ]; then
9
- # If there was no argument, set a default value
10
- directory="../.."
11
- else
12
- # If there was an argument, use it
13
- directory="$1"
14
- fi
12
+ echo " -------------------------------------------------------
13
+ | Usage: |
14
+ | bash $(basename $0) [dir] [c file] [c folder] [-l arg]
15
+ | dir: The directory in which to search for logs |
16
+ | c file: Name of the log instance counter file |
17
+ | c folder: Path to the folder of the log counter file |
18
+ | -l arg: \"1\" prints extra logs |
19
+ -------------------------------------------------------"
20
+
21
+ # Get flags and their values
22
+ loudness="0"
23
+ while getopts ':l:' opt; do
24
+ case "${opt}" in
25
+ l) loudness="${OPTARG}";;
26
+ \?) script_args+=("-$OPTARG");;
27
+ esac
28
+ done
15
29
 
16
- # The grepped files will include the list of all the codes that have been
17
- # removed and are no longer used. Syntax used works with GitHub cli ([[:digit:]])
18
- # https://stackoverflow.com/a/6901221
19
- lines=$(grep -roh --exclude="tests/log_codes/check_codes.sh" --exclude="debug_log.txt" --exclude="cucumber-report.txt" --exclude-dir="ALKilnTests" --exclude-dir="node_modules" --exclude-dir='alkiln-*' --exclude-dir='_alkiln*' 'ALK[[:digit:]][[:digit:]][[:digit:]][[:digit:]]' "$directory")
20
- sorted=$(echo "$lines" | sort -n)
30
+ # Use global "option index" to get the next args
21
31
 
32
+ where_to_look=${@:$OPTIND:1} # User's value
33
+ if [ "$where_to_look" = "" ]; then
34
+ where_to_look="../.." # Default value
35
+ fi
22
36
 
23
- echo "=== Missing codes ==="
37
+ expected_instances_file=${@:$OPTIND+1:1} # User's value
38
+ if [ "$expected_instances_file" = "" ]; then
39
+ expected_instances_file="log_code_expected_instances.txt" # Default value
40
+ fi
24
41
 
25
- # # -- Version 1 --
26
- # # More understandable version that doesn't yet come out with a final variable
27
- # # Keeping it here for discussion
28
- # nums=$(echo "$sorted" | sed 's/^ALK0*//')
42
+ expected_instances_folder=${@:$OPTIND+2:1} # User's value
43
+ if [ "$expected_instances_folder" = "" ]; then
44
+ expected_instances_folder="$where_to_look/tests/log_codes" # Default value
45
+ fi
29
46
 
30
- # missing_numbers=()
31
- # prev_number=0
32
- # echo "$nums" | while read -r current_number; do
47
+ expected_instances_path="$expected_instances_folder/$expected_instances_file"
33
48
 
34
- # diff=$((current_number - prev_number))
35
- # # If the difference is more than 1, print the missing
36
- # # numbers until we catch up with the current number
37
- # if [ $diff -gt 1 ]; then
38
- # for ((i=prev_number+1; i<current_number; i++)); do
39
- # printf -v missing_number "ALK%04d" $i
40
- # missing_numbers+=("$missing_number")
41
- # echo $missing_number
42
- # # missing_numbers+=$(echo "%04d\n" $missing_number)
43
- # done
44
- # echo "---"
45
- # fi
49
+ if [[ "$loudness" != "0" ]]; then
50
+ echo "loudness: $loudness"
51
+ echo "where_to_look: $where_to_look"
52
+ echo "File showing expected instances of log codes: $expected_instances_path"
53
+ fi
46
54
 
47
- # prev_number=$current_number
48
55
 
49
- # done
56
+ # removed and are no longer used. Syntax used works with GitHub cli - [[:digit:]]
57
+ # https://stackoverflow.com/a/6901221
58
+ instances=$(find "$where_to_look" -type f ! -name "check_codes.sh" ! -name "CONTRIBUTING.md" ! -name "$expected_instances_file" ! -name "debug_log.txt" ! -name "cucumber-report.txt" ! -path "*/node_modules/*" ! -path "*/ALKilnTests/*" ! -path "*/alkiln-*/*" ! -path "*/_alkiln*/*" -print0 | xargs -0 -P 4 grep -0 -ro 'ALK[[:digit:]][[:digit:]][[:digit:]][[:digit:]]' | grep -v -- '--' )
50
59
 
51
- # missing_numbers_str=$(printf '%s' "${missing_numbers[@]}")
52
- # echo "missing: $missing_numbers_str"
60
+ if [[ "$loudness" != "0" ]]; then
61
+ total_instances=$(echo "$instances" | wc -l)
62
+ echo "Number 'ALK' logs found: $total_instances"
63
+ fi
53
64
 
65
+ # Get the unique paths for every code
66
+ codes_unique_paths=()
67
+ # Also get the actual highest code by its number
68
+ highest_code="1"
69
+ for one_code in $instances; do
70
+ # Format of the string is "the/path:ALK####"
71
+ # Split around the ":"
72
+ path=$(echo "$one_code" | cut -d ":" -f 1)
73
+ code=$(echo "$one_code" | cut -d ":" -f 2)
74
+ # Get the code as an integer
75
+ item_index=$(echo "$code" | sed 's/^ALK0*//')
76
+ if [[ $item_index == "" ]]; then
77
+ item_index=0
78
+ fi
79
+ # This name is bad. It's really each log code's
80
+ # unique appearance. We could just use any string,
81
+ # but the path name gives a little more info.
82
+ # ¯\_(ツ)_/¯
83
+ # Also, we really want a list here, but bash can't
84
+ # make nested lists, so we're using ";" as a safe
85
+ # delimiter. If the user wants verbose output,
86
+ # we can also use it to help format the output.
87
+ codes_unique_paths[$item_index]+=";$path"
88
+
89
+ if (( highest_code < item_index )); then
90
+ highest_code="$item_index"
91
+ fi
92
+ done
54
93
 
55
- # -- Version 2 --
56
- # Version that is opaque, but generates a variable to check at the end
94
+ if [[ "$loudness" != "0" ]]; then
95
+ echo "Instance count: ${#codes_unique_paths[@]}"
96
+ echo ">>> highest_code <<<: $highest_code"
97
+ echo "Paths of ALK0000: ${codes_unique_paths[0]}"
98
+ fi
57
99
 
58
- # 0's in front of numbers confuses bash about the number format. Remove them.
59
- just_numbers=$(echo "$sorted" | sed 's/^ALK0*//')
100
+ indx=0
101
+ too_many=()
102
+ missing=()
103
+ while [ "$indx" -lt "$highest_code" ]; do
104
+ # Turn the index into a log code by prepending ALK and adding leading zeros
105
+ log_code=$(printf "ALK%04d" "$indx")
106
+ # Count ";" - a stand-in for the number of
107
+ # instances of the log code
108
+ num_paths=$(echo "${codes_unique_paths[$indx]}" | awk '{orig_len = length($0); gsub(/;/, "", $0); new_len = length($0); print orig_len - new_len}')
109
+ # The # of expected instances of the log code
110
+ # in all the relevant ALKiln files.
111
+ num_expected=($(grep -oh "$log_code:[[:digit:]]" "$expected_instances_path" | sed 's/^ALK[[:digit:]][[:digit:]][[:digit:]][[:digit:]]://'))
112
+ # The file tracking the # of expected instances
113
+ # may have a typo. One likely typo is we can catch:
114
+ # Putting 2 entries for one log code in the file.
115
+ num_expectations_found=${#num_expected[@]}
116
+ if [[ "$num_expectations_found" -gt "1" ]]; then
117
+ echo "WARNING: Multiple entries of '$log_code' in $expected_instances_path. Using the first one because that's easiest: ${num_expected[0]}"
118
+ num_expected=${num_expected[0]}
119
+ fi
120
+
121
+ if [[ "$num_expected" == "" ]]; then
122
+ num_expected="1"
123
+ fi
124
+
125
+ # To add to the list of strings to print later
126
+ short_msg="$log_code $num_paths/$num_expected"
127
+ long_msg="$log_code act/exp "
128
+ long_msg+="$num_paths/$num_expected:"
129
+ long_msg+=$(echo "${codes_unique_paths[$indx]}" | sed 's/;/\n - /g')
130
+
131
+ # missing
132
+ if [ "$num_paths" -lt "$num_expected" ]; then
133
+ if [[ "$loudness" != "0" ]]; then
134
+ missing+=("$long_msg")
135
+ else
136
+ missing+=("$short_msg")
137
+ fi
138
+
139
+ # too_many
140
+ elif [ "$num_paths" -gt "$num_expected" ]; then
141
+ if [[ "$loudness" != "0" ]]; then
142
+ too_many+=("$long_msg")
143
+ else
144
+ too_many+=("$short_msg")
145
+ fi
146
+ fi
147
+
148
+ let indx++
149
+ done
60
150
 
61
- # Convert the list into an array
62
- IFS=$'\n' read -rd '' -a num_array <<<"$just_numbers"
63
- # Find the minimum and maximum numbers in the array
64
- min_num=$(printf "%s\n" "${num_array[@]}" | sort -n | head -n 1)
65
- max_num=$(printf "%s\n" "${num_array[@]}" | sort -n | tail -n 1)
66
151
 
67
- # Generate a sequence of numbers from min to max with leading zeros
68
- expected_sequence=""
69
- for ((i=min_num; i<=max_num; i++)); do
70
- # Make sure these won't look like numbers to avoid confusing bash
71
- expected_sequence+=$(printf "ALK%04d" $i)$'\n'
72
- done
73
- # # Alternative code for above. seq doesn't exist everywhere. Keep this
74
- # till we look up installing seq to avoid loop)
75
- # expected_sequence=$(printf "ALK%04d\n" $(seq $min_num $max_num))
76
-
77
- # Compare the expected sequence with the actual numbers
78
- missing_numbers=$(comm -23 <(printf "%s\n" "$expected_sequence" | sort -n) <(printf "%s\n" "$sorted"))
79
- if [ -z "$missing_numbers" ]; then
80
- echo "None"
81
- else
82
- echo "$missing_numbers"
83
- ((exit_code+=2))
152
+ if [[ "$loudness" != "0" ]]; then
153
+ echo ""
154
+ echo "Missing count: ${#missing[@]}"
155
+ echo "Too many count: ${#too_many[@]}"
84
156
  fi
85
157
 
158
+ # === Results ===
86
159
 
87
- echo "
88
- === Duplicate codes ==="
89
-
90
- # We know these duplicates are ok
91
- accepted_duplicates="ALK0000
92
- ALK0002
93
- ALK0003
94
- ALK0006
95
- ALK0007
96
- ALK0008
97
- ALK0009
98
- ALK0010
99
- ALK0011
100
- ALK0012
101
- ALK0018
102
- ALK0019
103
- ALK0023
104
- ALK0024
105
- ALK0026
106
- ALK0027
107
- ALK0028
108
- ALK0030
109
- ALK0049
110
- ALK0184"
111
-
112
- # Use a sorted list. `uniq` only detects consecutive duplicates
113
- duplicates=$(echo "$sorted" | uniq -d)
114
- unaccepted_duplicates=$(echo "$duplicates" | grep -v -f <(echo "$accepted_duplicates"))
115
-
116
- if [ -z "$unaccepted_duplicates" ]; then
117
- echo "None"
160
+ printf "\n=== Missing instances (actual/expected) ===\n"
161
+ if [[ "${#missing[@]}" > 0 ]]; then
162
+ printf '%s\n' "${missing[@]}"
163
+ ((exit_code+=2))
118
164
  else
119
- echo "$unaccepted_duplicates"
120
- ((exit_code+=20))
165
+ printf "None"
121
166
  fi
122
167
 
123
- # === Final messages ===
124
- echo "
125
- Exit code meanings:
126
- - code 2: missing codes
127
- - code 20: duplicate codes
128
- - code 22: both
129
- "
168
+ printf "\n\n=== Too many instances (actual/expected) ===\n"
169
+ if [[ "${#too_many[@]}" > 0 ]]; then
170
+ printf '%s\n' "${too_many[@]}"
171
+ ((exit_code+=20))
172
+ else
173
+ printf "None"
174
+ fi
130
175
 
131
176
  if test $exit_code -eq 0; then
132
- echo "🌈 Passed! The codes for logs are as they should be."
133
- highest=$(echo "$sorted" | tail -n 1)
134
- echo "The highest log code is $highest"
177
+ printf "\n\n🌈 Passed! The codes for logs are as they should be."
178
+ printf "\n\n💡 Highest log code: $highest_code\n"
135
179
  else
136
- echo "🤕 ERROR: Log codes are messed up. Exited with exit code $exit_code. See above for more details."
180
+ printf "\n\n🤕 ERROR: "
181
+ if [[ "$exit_code" == "2" ]]; then
182
+ printf "Missing codes"
183
+ elif [[ "$exit_code" == "20" ]]; then
184
+ printf "Duplicate codes"
185
+ elif [[ "$exit_code" == "22" ]]; then
186
+ printf "Both missing and duplicate codes"
187
+ fi
188
+ echo ""
189
+ echo "Exit code: $exit_code"
137
190
  fi
138
191
 
192
+
139
193
  exit $exit_code
@@ -0,0 +1,209 @@
1
+ The log codes we have or have had in our ALKiln code base and the number of times each log code should appear in our code base to make sure that we don't repeat codes where we shouldn't and that we don't leave out/skip code numbers. 0 means a code we have deleted from ALKiln.
2
+
3
+ Why we need duplicate codes sometimes: GitHub actions sometimes don't have ways to avoid writing a code in both the `name` of a step and in the `run` value. Using it in both places is a decision we've currently made. Other codes are used in multiple places as defaults. These are a couple of examples of why this can be useful.
4
+
5
+ The script that tests the log codes will ignore this file (or any file with this name), and any file with these names: check_codes.sh, debug_log.txt, cucumber-report.txt. It will also ignore files in folders with these names:, node_modules, ALKilnTests, alkiln-*, _alkiln*. That list might get updated, so for an up-to-date list, always check the file check_codes.sh where we use `--exclude=` and such.
6
+
7
+ ALK0000:8
8
+ ALK0001:1
9
+ ALK0002:2
10
+ ALK0003:2
11
+ ALK0004:1
12
+ ALK0005:1
13
+ ALK0006:2
14
+ ALK0007:3
15
+ ALK0008:3
16
+ ALK0009:2
17
+ ALK0010:2
18
+ ALK0011:3
19
+ ALK0012:2
20
+ ALK0013:1
21
+ ALK0014:1
22
+ ALK0015:1
23
+ ALK0016:1
24
+ ALK0017:1
25
+ ALK0018:2
26
+ ALK0019:2
27
+ ALK0020:1
28
+ ALK0021:1
29
+ ALK0022:1
30
+ ALK0023:2
31
+ ALK0024:2
32
+ ALK0025:1
33
+ ALK0026:2
34
+ ALK0027:2
35
+ ALK0028:3
36
+ ALK0029:1
37
+ ALK0030:2
38
+ ALK0031:1
39
+ ALK0032:1
40
+ ALK0033:1
41
+ ALK0034:1
42
+ ALK0035:1
43
+ ALK0036:1
44
+ ALK0037:1
45
+ ALK0038:1
46
+ ALK0039:1
47
+ ALK0040:1
48
+ ALK0041:1
49
+ ALK0042:1
50
+ ALK0043:1
51
+ ALK0044:1
52
+ ALK0045:1
53
+ ALK0046:1
54
+ ALK0047:1
55
+ ALK0048:1
56
+ ALK0049:1
57
+ ALK0050:1
58
+ ALK0051:1
59
+ ALK0052:1
60
+ ALK0053:1
61
+ ALK0054:1
62
+ ALK0055:1
63
+ ALK0056:1
64
+ ALK0057:1
65
+ ALK0058:1
66
+ ALK0059:1
67
+ ALK0060:1
68
+ ALK0061:1
69
+ ALK0062:1
70
+ ALK0063:1
71
+ ALK0064:1
72
+ ALK0065:1
73
+ ALK0066:1
74
+ ALK0067:1
75
+ ALK0068:1
76
+ ALK0069:1
77
+ ALK0070:1
78
+ ALK0071:1
79
+ ALK0072:1
80
+ ALK0073:1
81
+ ALK0074:1
82
+ ALK0075:1
83
+ ALK0076:1
84
+ ALK0077:1
85
+ ALK0078:1
86
+ ALK0079:1
87
+ ALK0080:1
88
+ ALK0081:1
89
+ ALK0082:1
90
+ ALK0083:1
91
+ ALK0084:1
92
+ ALK0085:1
93
+ ALK0086:1
94
+ ALK0087:1
95
+ ALK0088:1
96
+ ALK0089:1
97
+ ALK0090:1
98
+ ALK0091:1
99
+ ALK0092:1
100
+ ALK0093:1
101
+ ALK0094:1
102
+ ALK0095:1
103
+ ALK0096:1
104
+ ALK0097:1
105
+ ALK0098:1
106
+ ALK0099:1
107
+ ALK0100:1
108
+ ALK0101:1
109
+ ALK0102:1
110
+ ALK0103:1
111
+ ALK0104:1
112
+ ALK0105:1
113
+ ALK0106:1
114
+ ALK0107:1
115
+ ALK0108:1
116
+ ALK0109:1
117
+ ALK0110:1
118
+ ALK0111:1
119
+ ALK0112:1
120
+ ALK0113:1
121
+ ALK0114:1
122
+ ALK0115:1
123
+ ALK0116:1
124
+ ALK0117:1
125
+ ALK0118:1
126
+ ALK0119:1
127
+ ALK0120:1
128
+ ALK0121:1
129
+ ALK0122:1
130
+ ALK0123:1
131
+ ALK0124:1
132
+ ALK0125:1
133
+ ALK0126:1
134
+ ALK0127:1
135
+ ALK0128:1
136
+ ALK0129:1
137
+ ALK0130:1
138
+ ALK0131:1
139
+ ALK0132:1
140
+ ALK0133:1
141
+ ALK0134:1
142
+ ALK0135:1
143
+ ALK0136:1
144
+ ALK0137:1
145
+ ALK0138:1
146
+ ALK0139:1
147
+ ALK0140:1
148
+ ALK0141:1
149
+ ALK0142:1
150
+ ALK0143:1
151
+ ALK0144:1
152
+ ALK0145:1
153
+ ALK0146:1
154
+ ALK0147:1
155
+ ALK0148:1
156
+ ALK0149:1
157
+ ALK0150:1
158
+ ALK0151:1
159
+ ALK0152:1
160
+ ALK0153:1
161
+ ALK0154:1
162
+ ALK0155:1
163
+ ALK0156:1
164
+ ALK0157:1
165
+ ALK0158:1
166
+ ALK0159:1
167
+ ALK0160:1
168
+ ALK0161:1
169
+ ALK0162:1
170
+ ALK0163:1
171
+ ALK0164:1
172
+ ALK0165:1
173
+ ALK0166:1
174
+ ALK0167:1
175
+ ALK0168:1
176
+ ALK0169:1
177
+ ALK0170:1
178
+ ALK0171:1
179
+ ALK0172:1
180
+ ALK0173:1
181
+ ALK0174:1
182
+ ALK0175:1
183
+ ALK0176:1
184
+ ALK0177:1
185
+ ALK0178:1
186
+ ALK0179:1
187
+ ALK0180:1
188
+ ALK0181:1
189
+ ALK0182:1
190
+ ALK0183:1
191
+ ALK0184:2
192
+ ALK0185:1
193
+ ALK0186:1
194
+ ALK0187:1
195
+ ALK0188:1
196
+ ALK0189:1
197
+ ALK0190:1
198
+ ALK0191:1
199
+ ALK0192:1
200
+ ALK0193:1
201
+ ALK0194:1
202
+ ALK0195:1
203
+ ALK0196:1
204
+ ALK0197:1
205
+ ALK0198:1
206
+ ALK0199:1
207
+ ALK0200:1
208
+ ALK0201:1
209
+ ALK0202:1
@@ -1,8 +0,0 @@
1
- [
2
- "== Actual deleted codes ==",
3
- "None",
4
- "== Tests ==",
5
- "ALK test 0059",
6
- "ALK test 0092",
7
- "ALK test 0225"
8
- ]