@suffolklitlab/alkiln 5.12.0-delete6 → 5.13.0-logs1

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.
Files changed (35) hide show
  1. package/.env.example +29 -0
  2. package/.github/workflows/github_server.yml +11 -9
  3. package/.github/workflows/log_code_tests.yml +0 -2
  4. package/.github/workflows/playground.yml +7 -5
  5. package/CHANGELOG.md +30 -5
  6. package/CONTRIBUTING.md +98 -83
  7. package/action.yml +66 -28
  8. package/action_for_github_server/action.yml +59 -31
  9. package/docs/decisions/006_which_log_level_to_pick_2024_09_5.md +46 -0
  10. package/docs/decisions/adopt_architectural_decision_records.md +58 -0
  11. package/docs/decisions/detect_sign_in.md +124 -0
  12. package/docs/decisions/pdfjs_version_2024_08_08.md +18 -0
  13. package/docs/decisions/reports_and_logs_2024_08_11.md +141 -0
  14. package/docs/decisions/update_puppeteer_2024_07_28.md +62 -0
  15. package/lib/docassemble/docassemble_api_interface.js +63 -34
  16. package/lib/docassemble/server_install.js +23 -9
  17. package/lib/docassemble/setup.js +33 -20
  18. package/lib/docassemble/takedown.js +27 -7
  19. package/lib/run_cucumber.js +81 -33
  20. package/lib/scope.js +152 -79
  21. package/lib/steps.js +84 -51
  22. package/lib/utils/files.js +8 -6
  23. package/lib/utils/log.js +477 -84
  24. package/lib/utils/reports.js +14 -5
  25. package/lib/utils/session_vars.js +25 -18
  26. package/lib/utils/time.js +44 -0
  27. package/npm-shrinkwrap.json +635 -193
  28. package/package.json +6 -6
  29. package/tests/log_codes/check_codes.sh +163 -108
  30. package/tests/log_codes/log_code_expected_instances.txt +213 -0
  31. package/tests/unit_tests/getAllFields.test.js +5 -0
  32. package/tests/unit_tests/getMatchingRows.test.js +5 -0
  33. package/tests/unit_tests/log.test.js +20 -0
  34. package/tests/unit_tests/normalizeTable.test.js +5 -0
  35. package/tests/log_codes/deleted_codes.json +0 -8
@@ -3,19 +3,22 @@ const fg = require('fast-glob');
3
3
  const path = require('path');
4
4
  require('dotenv').config();
5
5
 
6
- /**
7
- * This code assumes that this module is run as part of a GitHub Action. If the
8
- * customer is running it as a CLI tool, then they won't get useful messages yet.
9
- */
10
-
11
- /* This file provides user info variables. E.g. server address. They're either
12
- * `process.env` vars or vars that have been built from `process.env` vars.
13
- * It is meant to avoid duplication, make testing easier, and leave room for
14
- * future manipulation. No other file should need to use `process.env`.
15
- *
16
- * We have a bunch of `.get_foo()` functions partly because it makes the code
17
- * much easier to test.
18
- */
6
+ /** WARNING: Avoid importing other project files into here. Every other
7
+ * file should be able to reference this one without worrying
8
+ * about circular references.
9
+ * */
10
+
11
+ /** This file provides user info variable getters and setters.
12
+ * E.g. server address. It often uses `process.env` vars or
13
+ * vars that have been built from `process.env` vars. It is
14
+ * meant to avoid duplication, make testing easier, and leave
15
+ * room for future manipulation.
16
+ *
17
+ * No other file should need to use `process.env`.
18
+ *
19
+ * We use `.get_foo()` functions partly because it makes the code
20
+ * easier to test.
21
+ * */
19
22
 
20
23
  const session_vars = {};
21
24
 
@@ -136,7 +139,7 @@ session_vars.save_project_name = function ( project_name ) {
136
139
  let file = fs.writeFileSync( runtime_config_path, JSON.stringify( json, null, 2 ) );
137
140
 
138
141
  if ( session_vars.get_debug() ) {
139
- console.log( `🐞 ALK0036 DEBUG: Stored name of Project "${ project_name }" locally.` );
142
+ console.debug( `🐛 ALK0036 DEBUG: Stored name of Project "${ project_name }" locally.` );
140
143
  }
141
144
  return file;
142
145
  }; // Ends save_project_name()
@@ -148,7 +151,7 @@ session_vars.get_project_name = function () {
148
151
  }
149
152
  let json = JSON.parse( fs.readFileSync( runtime_config_path ));
150
153
  let project_name = json[ project_name_key ] || null;
151
- if ( session_vars.get_debug() ) { console.log( `🐞 ALK0037 DEBUG: Project name from file is "${ project_name }".` ); }
154
+ if ( session_vars.get_debug() ) { console.debug( `🐛 ALK0037 DEBUG: Project name from file is "${ project_name }".` ); }
152
155
  return project_name;
153
156
  }; // Ends get_project_name()
154
157
 
@@ -172,7 +175,11 @@ session_vars.delete_project_name = function () {
172
175
  // const file_storing_artifact_path = `_alkiln_test_artifacts_dir_name.json`;
173
176
  const artifacts_path_key = `artifacts_path`;
174
177
  session_vars.save_artifacts_path_name = function ( path_name ) {
175
- /* Save a key with the name of the current artifacts folder in case it doesn't exist. */
178
+ /** Save a key with the name of the current artifacts folder
179
+ * in case it doesn't exist. Should we create the path in here
180
+ * if it doesn't exist? Should we reserve this file for getting
181
+ * and setting?
182
+ * */
176
183
  return session_vars.save_runtime_config_var({ key: artifacts_path_key, value: path_name });
177
184
  }; // Ends save_artifacts_path_name()
178
185
  session_vars.get_artifacts_path_name = function () {
@@ -226,7 +233,7 @@ session_vars.save_runtime_config_var = function ({ key, value }) {
226
233
  let file = fs.writeFileSync( runtime_config_path, JSON.stringify( json, null, 2 ) );
227
234
 
228
235
  if ( session_vars.get_debug() ) {
229
- console.log( `🐞 ALK0040 DEBUG: Stored runtime config var "${key}" locally as "${value}".` );
236
+ console.debug( `🐛 ALK0040 DEBUG: Stored runtime config var "${key}" locally as "${value}".` );
230
237
  }
231
238
  return file;
232
239
  }; // Ends session_vars.save_runtime_config_var()
@@ -242,7 +249,7 @@ session_vars.get_runtime_config_var = function ( key ) {
242
249
  let json = JSON.parse( fs.readFileSync( runtime_config_path ));
243
250
  let value = json[ key ];
244
251
  if ( session_vars.get_debug() ) {
245
- console.log( `🐞 ALK0041 DEBUG: Runtime config var "${key}"" is "${value}".` );
252
+ console.debug( `🐛 ALK0041 DEBUG: Runtime config var "${key}" is "${value}".` );
246
253
  }
247
254
 
248
255
  return value;
package/lib/utils/time.js CHANGED
@@ -24,3 +24,47 @@ time.waitForTimeout = function( milliseconds ) {
24
24
  setTimeout(resolve, milliseconds);
25
25
  });
26
26
  };
27
+ time.sleep = time.waitForTimeout;
28
+ time.wait = time.waitForTimeout;
29
+
30
+ time.filename_date = function() {
31
+ /** Return the current timestamp in a human-readable
32
+ * filename-safe format to match the workflow artifact
33
+ * date format.
34
+ * See https://stackoverflow.com/a/48729396/14144258 and https://stackoverflow.com/a/6040556/14144258
35
+ */
36
+ // let date = new Date(); // now
37
+ // let day = ("0" + date.getUTCDate()).slice(-2);
38
+ // let month = ("0" + (date.getUTCMonth() + 1)).slice(-2);
39
+ // let year = date.getUTCFullYear();
40
+ // let hours = ("0" + date.getUTCHours()).slice(-2);
41
+ // let mins = ("0" + date.getUTCMinutes()).slice(-2);
42
+ // let secs = ("0" + date.getUTCSeconds()).slice(-2);
43
+
44
+ let dt = time.get_time_parts();
45
+ let safe_date = `${ dt.y }-${ dt.mon }-${ dt.d } at ${ dt.h }h${ dt.min }m${ dt.s }sUTC`;
46
+ return safe_date;
47
+ }; // Ends time.filename_date()
48
+
49
+ time.log_date = function () {
50
+ /** Return the current timestamp in a human-readable
51
+ * more compact log format.
52
+ * See https://stackoverflow.com/a/48729396/14144258 and https://stackoverflow.com/a/6040556/14144258
53
+ */
54
+ let dt = time.get_time_parts();
55
+ let short_date = `${ dt.y }-${ dt.mon }-${ dt.d } ${ dt.h }:${ dt.min }:${ dt.s }UTC`;
56
+ return short_date;
57
+ }; // Ends time.log_date()
58
+
59
+ time.get_time_parts = function () {
60
+ /** Get all the parts of the date as numbers. */
61
+ let date = new Date(); // now
62
+ return ({
63
+ y: date.getUTCFullYear(),
64
+ mon: ("0" + (date.getUTCMonth() + 1)).slice(-2),
65
+ d: ("0" + date.getUTCDate()).slice(-2),
66
+ h: ("0" + date.getUTCHours()).slice(-2),
67
+ min: ("0" + date.getUTCMinutes()).slice(-2),
68
+ s: ("0" + date.getUTCSeconds()).slice(-2),
69
+ });
70
+ }