@suffolklitlab/alkiln 5.15.4 → 5.16.0
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/.github/workflows/da_image_v_sha_7d13853.yml +67 -0
- package/CHANGELOG.md +21 -2
- package/action.yml +3 -1
- package/action_for_github_server/action.yml +26 -9
- package/docs/016_root_path_2026_04_09.md +17 -0
- package/lib/scope.js +1 -1
- package/lib/setup/artifacts.js +10 -10
- package/lib/utils/Log.js +1 -0
- package/lib/utils/files.js +11 -7
- package/lib/utils/session_vars.js +11 -1
- package/lib/utils/set_sources_paths.js +8 -6
- package/package.json +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: Use docassemble image version
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
show_docker_output:
|
|
9
|
+
required: false
|
|
10
|
+
default: false
|
|
11
|
+
type: boolean
|
|
12
|
+
description: 'Show the docker logs while building the GitHub server container. It will also save the docker log artifact. This might show sensitive config information.'
|
|
13
|
+
# Experimental
|
|
14
|
+
enable_tmate:
|
|
15
|
+
type: boolean
|
|
16
|
+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
|
17
|
+
required: false
|
|
18
|
+
default: false
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
|
|
22
|
+
github-server-tests:
|
|
23
|
+
# Avoids running double tests when someone on the team makes a pull request
|
|
24
|
+
# 1: Trigger job on push or dispatch from this repository
|
|
25
|
+
# 2: Trigger job on pull request from a fork
|
|
26
|
+
if: (
|
|
27
|
+
github.event_name != 'pull_request'
|
|
28
|
+
&& ! github.event.pull_request.head.repo.fork
|
|
29
|
+
) || (
|
|
30
|
+
github.event_name == 'pull_request'
|
|
31
|
+
&& github.event.pull_request.head.repo.fork
|
|
32
|
+
)
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
strategy:
|
|
35
|
+
matrix:
|
|
36
|
+
node-version: [24.x]
|
|
37
|
+
|
|
38
|
+
steps:
|
|
39
|
+
# Place the root directory in this branch to access relative paths to
|
|
40
|
+
# action files
|
|
41
|
+
- uses: actions/checkout@v4
|
|
42
|
+
|
|
43
|
+
- name: "ALKiln - Use a specific docassemble image version to start the isolated temporary docassemble server on GitHub"
|
|
44
|
+
id: github_server
|
|
45
|
+
uses: ./action_for_github_server
|
|
46
|
+
with:
|
|
47
|
+
SHOW_DOCKER_OUTPUT: "${{ github.event.inputs.show_docker_output }}"
|
|
48
|
+
DOCASSEMBLE_IMAGE: "ghcr.io/suffolklitlab/docassemble:sha-7d13853"
|
|
49
|
+
- run: echo "ALKiln finished starting the isolated GitHub docassemble server"
|
|
50
|
+
shell: bash
|
|
51
|
+
|
|
52
|
+
## Optional debugging to explore things like docker issues
|
|
53
|
+
#- name: Docker debug tmate session
|
|
54
|
+
# #if: ${{ failure() && github.event.inputs.enable_tmate == 'true' }}
|
|
55
|
+
# uses: mxschmitt/action-tmate@v3
|
|
56
|
+
|
|
57
|
+
- name: "ALKiln - Confirm docassemble packages get installed correctly"
|
|
58
|
+
if: ${{ success() }}
|
|
59
|
+
id: alkiln
|
|
60
|
+
uses: ./
|
|
61
|
+
with:
|
|
62
|
+
# Required inputs. See
|
|
63
|
+
# https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#sandbox-inputs
|
|
64
|
+
SERVER_URL: "${{ steps.github_server.outputs.SERVER_URL }}"
|
|
65
|
+
DOCASSEMBLE_DEVELOPER_API_KEY: "${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}"
|
|
66
|
+
INSTALL_METHOD: "server"
|
|
67
|
+
ALKILN_TAG_EXPRESSION: "@e3" # One very simple test
|
package/CHANGELOG.md
CHANGED
|
@@ -43,7 +43,26 @@ Format:
|
|
|
43
43
|
-
|
|
44
44
|
-->
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
## [5.16.0] - 2026-05-14
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
- Adds a new optional parameter to `action_for_github_server/action.yml`, the full name of the docassemble image. It defaults to `jhpyle/docassemble:latest`, what we previously used, but can also be changed to an earlier version (`jhpyle/docassemble:1.9.8`) or a different fork of docassemble (`ghcr.io/suffolklitlab/docassemble:latest`). Note that old docassemble versions may sometimes get removed.
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- Changed the default version of docassemblecli to 0.0.25
|
|
55
|
+
- Use `cwd` as the base of file paths. Motivated by ALKiP's upcoming need to change the way it handles its own file paths.
|
|
56
|
+
- Handle curl failures while waiting for docassemble server startup. Wrapped the curl call with set +e / set -e so GitHub Actions does not exit on curl failures. All non-zero curl exit codes are treated as "not ready yet" and retried - this covers transient errors like exit code 56 (connection dropped) and exit code 7 (connection refused) that may come up during startup. Added a comment explaining the permissive approach. Changed response value from "000" to "missing" for clarity in logs. See [#1044](https://github.com/SuffolkLITLab/ALKiln/issues/1044).
|
|
57
|
+
|
|
58
|
+
### Fixed
|
|
59
|
+
|
|
60
|
+
- Print error correctly when missing sources paths
|
|
61
|
+
- Changed the default version of docassemblecli to 0.0.25
|
|
62
|
+
|
|
63
|
+
### Security
|
|
64
|
+
|
|
65
|
+
- Security: Gave our main action's `npm install` call the arguments ` --ignore-scripts --min-release-age=7` to improve security against malicious `pre-install` and `post-install` scripts. See [#1053](https://github.com/SuffolkLITLab/ALKiln/issues/1053).
|
|
47
66
|
|
|
48
67
|
## [5.15.4] - 2025-11-29
|
|
49
68
|
|
|
@@ -1235,4 +1254,4 @@ Note: published on incorrect commit
|
|
|
1235
1254
|
- `example.feature` - an example test to get a project started
|
|
1236
1255
|
- `github/workflows/run_form_tests.yml` - Automated github workflow to run tests when code is pushed and a manual trigger for testing without needing to push
|
|
1237
1256
|
- `.gitignore` - ignores files that are generated by the tests and shouldn't be added to the repo
|
|
1238
|
-
- `package.json` - keep up-to-date version of this test repository and hold scripts that the automated tests run
|
|
1257
|
+
- `package.json` - keep up-to-date version of this test repository and hold scripts that the automated tests run
|
package/action.yml
CHANGED
|
@@ -120,7 +120,9 @@ runs:
|
|
|
120
120
|
run: |
|
|
121
121
|
log="💡 ALK0026 INFO: Install ALKiln directly from npm"
|
|
122
122
|
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
|
|
123
|
-
npm install -g "@suffolklitlab/alkiln@$ALKILN_VERSION"
|
|
123
|
+
npm install --ignore-scripts --min-release-age=7 -g "@suffolklitlab/alkiln@$ALKILN_VERSION"
|
|
124
|
+
npm rebuild -g puppeteer --update-binary
|
|
125
|
+
|
|
124
126
|
|
|
125
127
|
# Files prep
|
|
126
128
|
- shell: bash
|
|
@@ -23,10 +23,14 @@ inputs:
|
|
|
23
23
|
description: "Default is 600 seconds. Maximum amount of seconds to give the docassemble docker container to serve the site."
|
|
24
24
|
required: false
|
|
25
25
|
default: 600 # 10 min
|
|
26
|
+
DOCASSEMBLE_IMAGE:
|
|
27
|
+
description: "The specific docassemble image to use."
|
|
28
|
+
required: false
|
|
29
|
+
default: jhpyle/docassemble
|
|
26
30
|
DOCASSEMBLECLI_VERSION:
|
|
27
31
|
description: "The version of docassemblecli to install."
|
|
28
32
|
required: false
|
|
29
|
-
default: "0.0.
|
|
33
|
+
default: "0.0.25"
|
|
30
34
|
|
|
31
35
|
outputs:
|
|
32
36
|
DOCASSEMBLE_DEVELOPER_API_KEY:
|
|
@@ -155,35 +159,37 @@ runs:
|
|
|
155
159
|
if: ${{ env.OUTPUT_DOCKER == 'false' }}
|
|
156
160
|
env:
|
|
157
161
|
CONFIG_ARGS: ${{ env.CONFIG_ARGS }}
|
|
162
|
+
DOCASSEMBLE_IMAGE: "${{ inputs.DOCASSEMBLE_IMAGE }}"
|
|
158
163
|
shell: bash
|
|
159
164
|
run: |
|
|
160
165
|
log="💡 ALK0009 INFO: Download and start docker silently"
|
|
161
166
|
echo -e "\n$log" >> "${{ env.DEBUG_LOGS_PATH }}"
|
|
162
|
-
docker pull
|
|
167
|
+
docker pull "$DOCASSEMBLE_IMAGE" > /dev/null 2>&1
|
|
163
168
|
docker run --name docassemble_container \
|
|
164
169
|
--env DA_ADMIN_EMAIL="$DA_ADMIN_EMAIL" \
|
|
165
170
|
--env DA_ADMIN_PASSWORD="$DA_ADMIN_PASSWORD" \
|
|
166
171
|
--env DA_ADMIN_API_KEY="$DA_ADMIN_API_KEY" \
|
|
167
172
|
$CONFIG_ARGS \
|
|
168
173
|
--cap-add SYS_PTRACE \
|
|
169
|
-
--memory="4gb" -d -p 80:80
|
|
174
|
+
--memory="4gb" -d -p 80:80 "$DOCASSEMBLE_IMAGE" > /dev/null 2>&1
|
|
170
175
|
# With output
|
|
171
176
|
- name: "💡 ALK0010 INFO: Download and start docker"
|
|
172
177
|
if: ${{ env.OUTPUT_DOCKER == 'true' }}
|
|
173
178
|
env:
|
|
174
179
|
CONFIG_ARGS: ${{ env.CONFIG_ARGS }}
|
|
180
|
+
DOCASSEMBLE_IMAGE: "${{ inputs.DOCASSEMBLE_IMAGE }}"
|
|
175
181
|
shell: bash
|
|
176
182
|
run: |
|
|
177
183
|
log="💡 ALK0010 INFO: Download and start docker"
|
|
178
184
|
echo -e "\n$log" >> "${{ env.DEBUG_LOGS_PATH }}"
|
|
179
|
-
docker pull
|
|
185
|
+
docker pull "$DOCASSEMBLE_IMAGE"
|
|
180
186
|
docker run --name docassemble_container \
|
|
181
187
|
--env DA_ADMIN_EMAIL="$DA_ADMIN_EMAIL" \
|
|
182
188
|
--env DA_ADMIN_PASSWORD="$DA_ADMIN_PASSWORD" \
|
|
183
189
|
--env DA_ADMIN_API_KEY="$DA_ADMIN_API_KEY" \
|
|
184
190
|
$CONFIG_ARGS \
|
|
185
191
|
--cap-add SYS_PTRACE \
|
|
186
|
-
--memory="4gb" -d -p 80:80
|
|
192
|
+
--memory="4gb" -d -p 80:80 "$DOCASSEMBLE_IMAGE"
|
|
187
193
|
|
|
188
194
|
# Section for showing the time it takes to start the server.
|
|
189
195
|
|
|
@@ -213,14 +219,25 @@ runs:
|
|
|
213
219
|
|
|
214
220
|
# Check if max seconds till loading has passed
|
|
215
221
|
if [[ $SECONDS -ge $MAX_SECONDS_FOR_DOCKER ]]; then
|
|
216
|
-
log3="🤕 ALK0014 ERROR: Timed out waiting for docker container to serve the site. If you want to give your docker container more
|
|
222
|
+
log3="🤕 ALK0014 ERROR: Timed out waiting for docker container to serve the site. If you want to give your docker container more time to install, set the MAX_SECONDS_FOR_DOCKER input for this action."
|
|
217
223
|
echo -e "\n$log3" >> "${{ env.DEBUG_LOGS_PATH }}" && echo -e "$log3"
|
|
218
224
|
exit 1
|
|
219
225
|
fi
|
|
220
226
|
|
|
221
227
|
# Set the variable to a new string value in each iteration
|
|
222
|
-
|
|
223
|
-
|
|
228
|
+
# We intentionally skip all non-zero curl exit codes here instead of handling specific ones.
|
|
229
|
+
# During server startup there are several transient errors that can come up and since we already log the exit code and have a timeout,
|
|
230
|
+
# retrying on all of them is safer than trying to maintain a list of specific codes to handle.
|
|
231
|
+
set +e
|
|
232
|
+
response=$(curl -o /dev/null -s -w "%{http_code}" http://localhost:80/health_check?ready=1)
|
|
233
|
+
status=$?
|
|
234
|
+
set -e
|
|
235
|
+
|
|
236
|
+
if [[ $status -ne 0 ]]; then
|
|
237
|
+
response="missing"
|
|
238
|
+
fi
|
|
239
|
+
|
|
240
|
+
log4="💡 ALK0015 INFO: Response is $response (curl exit code: $status)"
|
|
224
241
|
echo -e "\n$log4" >> "${{ env.DEBUG_LOGS_PATH }}" && echo -e "$log4"
|
|
225
242
|
|
|
226
243
|
# Check if the string includes the desired text
|
|
@@ -228,7 +245,7 @@ runs:
|
|
|
228
245
|
log5="💡 ALK0016 SUCCESS: Success! The docker container is ready!"
|
|
229
246
|
echo -e "\n$log5" >> "${{ env.DEBUG_LOGS_PATH }}" && echo -e "$log5"
|
|
230
247
|
else
|
|
231
|
-
log6="💡 ALK0017 INFO: The docker container is not ready yet. Will check again in 30 seconds."
|
|
248
|
+
log6="💡 ALK0017 INFO: The docker container is not ready yet (HTTP=$response, curl exit code=$status). Will check again in 30 seconds."
|
|
232
249
|
echo -e "\n$log6" >> "${{ env.DEBUG_LOGS_PATH }}" && echo -e "$log6"
|
|
233
250
|
sleep 30
|
|
234
251
|
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Root path
|
|
2
|
+
|
|
3
|
+
This code assumes the current working directory (cwd) will contain the necessary files and folders to get files like `.feature` files and the test run runtime config file.
|
|
4
|
+
|
|
5
|
+
When you run ALKiln on the command line, run the tests in the root directory of the docassemble package with the tests. There are other ways to tell processes where the root directory is. For example, ALKiP, a docassemble package that uses ALKiln inside an author's server, runs `subprocess.run()` or `subprocess.Popen()` with `cwd=`. In ALKiP the `cwd` is most likely `/tmp`.
|
|
6
|
+
|
|
7
|
+
Files that make this root path assumption:
|
|
8
|
+
|
|
9
|
+
- lib/utils/set_sources_paths.js
|
|
10
|
+
- lib/utils/files.js
|
|
11
|
+
- lib/utils/session_vars.js
|
|
12
|
+
|
|
13
|
+
ALKiln makes assumptions about specific folder names inside the root directory. See `lib/utils/set_sources_paths.js` and `validate.js` for where it looks for `.feature` files.
|
|
14
|
+
|
|
15
|
+
## Anti-goals
|
|
16
|
+
|
|
17
|
+
It is possible for us to make the root path configurable in a few ways (env vars, command line args, etc.), but we are avoiding adding that maintenance cost until we see a need.
|
package/lib/scope.js
CHANGED
|
@@ -2768,7 +2768,7 @@ module.exports = {
|
|
|
2768
2768
|
pic_name = `pic_on-${ short_id }-${ timestamp }`;
|
|
2769
2769
|
}
|
|
2770
2770
|
|
|
2771
|
-
await scope.take_a_screenshot( scope, { path:
|
|
2771
|
+
await scope.take_a_screenshot( scope, { path: `${ scope.paths.scenario }/${ pic_name }.jpg` });
|
|
2772
2772
|
|
|
2773
2773
|
await scope.afterStep( scope );
|
|
2774
2774
|
}, // Ends scope.steps.screenshot()
|
package/lib/setup/artifacts.js
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
const session_vars = require(`../utils/session_vars`);
|
|
4
4
|
const files = require(`../utils/files`);
|
|
5
|
-
const Log = require(`../
|
|
5
|
+
const Log = require(`../utils/Log.js`);
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Reset and refresh artifacts path name. Use this at the start of every test
|
|
9
|
+
* run for that run's unique results.
|
|
10
|
+
* */
|
|
8
11
|
|
|
9
12
|
session_vars.delete_artifacts_path_name();
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
// If using `npm run cucumber` (as opposed to the bin commands),
|
|
13
|
-
// use `--` before `--sources=./foo`
|
|
14
|
-
const argv = require(`minimist`)( process.argv.slice(2) );
|
|
15
|
-
const artifacts_path = files.make_artifacts_folder( argv.path );
|
|
16
|
-
|
|
14
|
+
const artifacts_path = files.make_artifacts_folder();
|
|
17
15
|
session_vars.save_artifacts_path_name( artifacts_path );
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const log = new Log({ path: artifacts_path, context: `artifacts` });
|
|
18
|
+
log.info({ code: `ALK0278`, context: `artifacts`,},
|
|
19
|
+
`Created the artifacts folder at "${ artifacts_path }"`
|
|
20
|
+
);
|
package/lib/utils/Log.js
CHANGED
package/lib/utils/files.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const safe_filename = require('sanitize-filename');
|
|
3
|
+
const path = require(`path`);
|
|
3
4
|
|
|
4
5
|
let files = {};
|
|
5
6
|
|
|
@@ -21,27 +22,30 @@ files.readable_date = function() {
|
|
|
21
22
|
return fancy_str;
|
|
22
23
|
}; // Ends files.readable_date()
|
|
23
24
|
|
|
24
|
-
files.make_artifacts_folder = function (
|
|
25
|
+
files.make_artifacts_folder = function ( file_path ) {
|
|
25
26
|
/** Makes a folder in the root of the project if it doesn't
|
|
26
27
|
* already exist, either with the given name or with a default name.
|
|
27
28
|
*
|
|
28
29
|
* Works for local development as well, without action.yml or workflow files.
|
|
29
30
|
* */
|
|
30
|
-
if (
|
|
31
|
-
let name_parts =
|
|
31
|
+
if (file_path) {
|
|
32
|
+
let name_parts = file_path.split(`/`);
|
|
32
33
|
let safe_parts = [];
|
|
33
34
|
for ( let part of name_parts ) {
|
|
34
35
|
safe_parts.push(safe_filename( part ));
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
file_path = path.join( ...safe_parts );
|
|
37
38
|
} else {
|
|
38
|
-
|
|
39
|
+
file_path = `alkiln-${ files.readable_date() }`
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
const root = process.cwd();
|
|
43
|
+
root_path = path.join( root, file_path );
|
|
44
|
+
|
|
41
45
|
// `recursive` avoids errors if folder already exists
|
|
42
46
|
// https://nodejs.org/docs/latest-v18.x/api/fs.html#fspromisesmkdirpath-options
|
|
43
|
-
fs.mkdirSync(
|
|
44
|
-
return
|
|
47
|
+
fs.mkdirSync( root_path, { recursive: true });
|
|
48
|
+
return root_path;
|
|
45
49
|
}; // Ends files.make_artifacts_folder()
|
|
46
50
|
|
|
47
51
|
module.exports = files;
|
|
@@ -52,6 +52,10 @@ session_vars.get_origin = function () {
|
|
|
52
52
|
};
|
|
53
53
|
session_vars.get_user_project_name = function () { return process.env._PROJECT_NAME || null; };
|
|
54
54
|
session_vars.get_user_id = function () { return process.env._USER_ID || null; };
|
|
55
|
+
session_vars.get_runtime_config_path = function () {
|
|
56
|
+
const root = process.cwd(); // absolute path just to be sure
|
|
57
|
+
return path.join( root, `runtime_config.json` );
|
|
58
|
+
}
|
|
55
59
|
|
|
56
60
|
// More complex logic
|
|
57
61
|
session_vars.get_server_reload_timeout = function () {
|
|
@@ -133,7 +137,6 @@ session_vars.get_languages = function () {
|
|
|
133
137
|
}; // Ends session_vars.get_languages()
|
|
134
138
|
|
|
135
139
|
|
|
136
|
-
const runtime_config_path = `runtime_config.json`;
|
|
137
140
|
const project_name_key = `da_project_name`;
|
|
138
141
|
session_vars.save_project_name = function ( project_name ) {
|
|
139
142
|
/* Saves the name of the project to a json obj so deletion can use it later.
|
|
@@ -142,6 +145,7 @@ session_vars.save_project_name = function ( project_name ) {
|
|
|
142
145
|
* Should we try to prevent someone overwriting a previous project name?
|
|
143
146
|
*
|
|
144
147
|
* @param project_name { string } - purely alphanumeric string */
|
|
148
|
+
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
145
149
|
|
|
146
150
|
// Warn local developers if file already exists
|
|
147
151
|
if ( fs.existsSync( runtime_config_path ) ) {
|
|
@@ -172,6 +176,8 @@ session_vars.get_project_name = function () {
|
|
|
172
176
|
if ( session_vars.get_origin() === 'playground' ) {
|
|
173
177
|
return session_vars.get_user_project_name();
|
|
174
178
|
}
|
|
179
|
+
|
|
180
|
+
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
175
181
|
let json = JSON.parse( fs.readFileSync( runtime_config_path ));
|
|
176
182
|
let project_name = json[ project_name_key ] || null;
|
|
177
183
|
if ( session_vars.get_debug() ) { console.debug( `🐛 ALK0037 DEBUG: Project name from file is "${ project_name }".` ); }
|
|
@@ -180,6 +186,7 @@ session_vars.get_project_name = function () {
|
|
|
180
186
|
|
|
181
187
|
session_vars.delete_project_name = function () {
|
|
182
188
|
/* Empty the key storing the name of the docassemble Project */
|
|
189
|
+
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
183
190
|
try {
|
|
184
191
|
// Get the json, changing it, and re-write the file from scratch
|
|
185
192
|
let json = JSON.parse( fs.readFileSync( runtime_config_path ));
|
|
@@ -252,6 +259,7 @@ session_vars.save_runtime_config_var = function ({ key, value }) {
|
|
|
252
259
|
*
|
|
253
260
|
* @returns {binary?} file Runtime config file
|
|
254
261
|
*/
|
|
262
|
+
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
255
263
|
|
|
256
264
|
// Ensure runtime config file exists
|
|
257
265
|
if ( !fs.existsSync( runtime_config_path ) ) {
|
|
@@ -277,6 +285,7 @@ session_vars.get_runtime_config_var = function ( key ) {
|
|
|
277
285
|
*
|
|
278
286
|
* @returns {any} - Value of given key in runtime config file or null
|
|
279
287
|
*/
|
|
288
|
+
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
280
289
|
try {
|
|
281
290
|
let json = JSON.parse( fs.readFileSync( runtime_config_path ));
|
|
282
291
|
let value = json[ key ];
|
|
@@ -300,6 +309,7 @@ session_vars.delete_runtime_config_var = function ({ key }) {
|
|
|
300
309
|
*
|
|
301
310
|
* @returns {null}
|
|
302
311
|
* */
|
|
312
|
+
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
303
313
|
try {
|
|
304
314
|
if ( !fs.existsSync( runtime_config_path )) { return null; }
|
|
305
315
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const fast_glob = require(`fast-glob`);
|
|
2
|
+
const path = require(`path`);
|
|
2
3
|
|
|
3
4
|
const session_vars = require(`./session_vars`);
|
|
4
5
|
|
|
@@ -18,7 +19,7 @@ module.exports = function set_sources_paths({ log }) {
|
|
|
18
19
|
let maybe_paths = get_potential_paths();
|
|
19
20
|
|
|
20
21
|
let sources_paths = get_sources_paths({ maybe_paths });
|
|
21
|
-
if ( sources_paths === 0 ) {
|
|
22
|
+
if ( sources_paths.length === 0 ) {
|
|
22
23
|
// If we don't throw, it'll be more confusing when no tests run
|
|
23
24
|
log.throw({ code: `ALK0050`, context: `sources`,
|
|
24
25
|
error: new ReferenceError(
|
|
@@ -45,6 +46,7 @@ function get_potential_paths() {
|
|
|
45
46
|
// `project` is the name in the server docassemble "Project" page
|
|
46
47
|
let project = session_vars.get_user_project_name();
|
|
47
48
|
let id = session_vars.get_user_id();
|
|
49
|
+
let root = process.cwd(); // Assumes correct root. See docs about root path.
|
|
48
50
|
|
|
49
51
|
// process.argv is a list of strings of commands and args.
|
|
50
52
|
// Internal note: If using `npm run cucumber`, use `--` before
|
|
@@ -53,8 +55,8 @@ function get_potential_paths() {
|
|
|
53
55
|
default: {
|
|
54
56
|
sources: [
|
|
55
57
|
`./docassemble/*/data/sources`, // In GitHub folder
|
|
56
|
-
`/usr/share/docassemble/files/playgroundsources/${id}/${project}
|
|
57
|
-
`/
|
|
58
|
+
`/usr/share/docassemble/files/playgroundsources/${id}/${project}`, // From playground without S3
|
|
59
|
+
path.join( root, `/playgroundsources/${id}/${project}`), // From playground with S3
|
|
58
60
|
],
|
|
59
61
|
}
|
|
60
62
|
});
|
|
@@ -81,16 +83,16 @@ function get_sources_paths({ maybe_paths }) {
|
|
|
81
83
|
// Check every path, tracking which exist and which are missing
|
|
82
84
|
let existing_paths = [];
|
|
83
85
|
let missing_paths = [];
|
|
84
|
-
for ( let
|
|
86
|
+
for ( let maybe_path of maybe_paths ) {
|
|
85
87
|
let dirs = fast_glob.sync(
|
|
86
|
-
[
|
|
88
|
+
[ maybe_path ],
|
|
87
89
|
{ onlyFiles: false, suppressErrors: true }
|
|
88
90
|
);
|
|
89
91
|
|
|
90
92
|
if ( dirs.length > 0 ) {
|
|
91
93
|
existing_paths.push( ...dirs );
|
|
92
94
|
} else {
|
|
93
|
-
missing_paths.push(
|
|
95
|
+
missing_paths.push( maybe_path );
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
|