@suffolklitlab/alkiln 5.15.4-ref-paths-1 → 5.15.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.
- package/CHANGELOG.md +1 -9
- package/lib/scope.js +1 -1
- package/lib/setup/artifacts.js +10 -10
- package/lib/utils/Log.js +0 -1
- package/lib/utils/files.js +7 -11
- package/lib/utils/session_vars.js +1 -11
- package/lib/utils/set_sources_paths.js +6 -8
- package/npm-shrinkwrap.json +7 -3
- package/package.json +1 -1
- package/docs/016_root_path_2026_04_09.md +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -43,15 +43,7 @@ Format:
|
|
|
43
43
|
-
|
|
44
44
|
-->
|
|
45
45
|
|
|
46
|
-
## [Unreleased]
|
|
47
|
-
|
|
48
|
-
### Changed
|
|
49
|
-
|
|
50
|
-
- Use `cwd` as the base of file paths. Motivated by ALKiP's need to change the way it handles its own file paths.
|
|
51
|
-
|
|
52
|
-
### Fixed
|
|
53
|
-
|
|
54
|
-
- Print error correctly when missing sources paths
|
|
46
|
+
<!-- ## [Unreleased] -->
|
|
55
47
|
|
|
56
48
|
## [5.15.4] - 2025-11-29
|
|
57
49
|
|
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(`../setup/artifacts.js`);
|
|
6
6
|
|
|
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
|
-
* */
|
|
7
|
+
/** Reset and refresh artifacts path name */
|
|
11
8
|
|
|
12
9
|
session_vars.delete_artifacts_path_name();
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
// process.argv is a list of strings of commands and args.
|
|
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
|
+
|
|
15
17
|
session_vars.save_artifacts_path_name( artifacts_path );
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`Created the artifacts folder at "${ artifacts_path }"`
|
|
20
|
-
);
|
|
19
|
+
// Leave the config Project name value as it is. Local developers find it
|
|
20
|
+
// useful to re-use that value.
|
package/lib/utils/Log.js
CHANGED
package/lib/utils/files.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const safe_filename = require('sanitize-filename');
|
|
3
|
-
const path = require(`path`);
|
|
4
3
|
|
|
5
4
|
let files = {};
|
|
6
5
|
|
|
@@ -22,30 +21,27 @@ files.readable_date = function() {
|
|
|
22
21
|
return fancy_str;
|
|
23
22
|
}; // Ends files.readable_date()
|
|
24
23
|
|
|
25
|
-
files.make_artifacts_folder = function (
|
|
24
|
+
files.make_artifacts_folder = function (path) {
|
|
26
25
|
/** Makes a folder in the root of the project if it doesn't
|
|
27
26
|
* already exist, either with the given name or with a default name.
|
|
28
27
|
*
|
|
29
28
|
* Works for local development as well, without action.yml or workflow files.
|
|
30
29
|
* */
|
|
31
|
-
if (
|
|
32
|
-
let name_parts =
|
|
30
|
+
if (path) {
|
|
31
|
+
let name_parts = path.split(`/`);
|
|
33
32
|
let safe_parts = [];
|
|
34
33
|
for ( let part of name_parts ) {
|
|
35
34
|
safe_parts.push(safe_filename( part ));
|
|
36
35
|
}
|
|
37
|
-
|
|
36
|
+
path = safe_parts.join(`/`);
|
|
38
37
|
} else {
|
|
39
|
-
|
|
38
|
+
path = `alkiln-${ files.readable_date() }`
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
const root = process.cwd();
|
|
43
|
-
root_path = path.join( root, file_path );
|
|
44
|
-
|
|
45
41
|
// `recursive` avoids errors if folder already exists
|
|
46
42
|
// https://nodejs.org/docs/latest-v18.x/api/fs.html#fspromisesmkdirpath-options
|
|
47
|
-
fs.mkdirSync(
|
|
48
|
-
return
|
|
43
|
+
fs.mkdirSync( path, { recursive: true });
|
|
44
|
+
return path;
|
|
49
45
|
}; // Ends files.make_artifacts_folder()
|
|
50
46
|
|
|
51
47
|
module.exports = files;
|
|
@@ -52,10 +52,6 @@ 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
|
-
}
|
|
59
55
|
|
|
60
56
|
// More complex logic
|
|
61
57
|
session_vars.get_server_reload_timeout = function () {
|
|
@@ -137,6 +133,7 @@ session_vars.get_languages = function () {
|
|
|
137
133
|
}; // Ends session_vars.get_languages()
|
|
138
134
|
|
|
139
135
|
|
|
136
|
+
const runtime_config_path = `runtime_config.json`;
|
|
140
137
|
const project_name_key = `da_project_name`;
|
|
141
138
|
session_vars.save_project_name = function ( project_name ) {
|
|
142
139
|
/* Saves the name of the project to a json obj so deletion can use it later.
|
|
@@ -145,7 +142,6 @@ session_vars.save_project_name = function ( project_name ) {
|
|
|
145
142
|
* Should we try to prevent someone overwriting a previous project name?
|
|
146
143
|
*
|
|
147
144
|
* @param project_name { string } - purely alphanumeric string */
|
|
148
|
-
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
149
145
|
|
|
150
146
|
// Warn local developers if file already exists
|
|
151
147
|
if ( fs.existsSync( runtime_config_path ) ) {
|
|
@@ -176,8 +172,6 @@ session_vars.get_project_name = function () {
|
|
|
176
172
|
if ( session_vars.get_origin() === 'playground' ) {
|
|
177
173
|
return session_vars.get_user_project_name();
|
|
178
174
|
}
|
|
179
|
-
|
|
180
|
-
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
181
175
|
let json = JSON.parse( fs.readFileSync( runtime_config_path ));
|
|
182
176
|
let project_name = json[ project_name_key ] || null;
|
|
183
177
|
if ( session_vars.get_debug() ) { console.debug( `🐛 ALK0037 DEBUG: Project name from file is "${ project_name }".` ); }
|
|
@@ -186,7 +180,6 @@ session_vars.get_project_name = function () {
|
|
|
186
180
|
|
|
187
181
|
session_vars.delete_project_name = function () {
|
|
188
182
|
/* Empty the key storing the name of the docassemble Project */
|
|
189
|
-
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
190
183
|
try {
|
|
191
184
|
// Get the json, changing it, and re-write the file from scratch
|
|
192
185
|
let json = JSON.parse( fs.readFileSync( runtime_config_path ));
|
|
@@ -259,7 +252,6 @@ session_vars.save_runtime_config_var = function ({ key, value }) {
|
|
|
259
252
|
*
|
|
260
253
|
* @returns {binary?} file Runtime config file
|
|
261
254
|
*/
|
|
262
|
-
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
263
255
|
|
|
264
256
|
// Ensure runtime config file exists
|
|
265
257
|
if ( !fs.existsSync( runtime_config_path ) ) {
|
|
@@ -285,7 +277,6 @@ session_vars.get_runtime_config_var = function ( key ) {
|
|
|
285
277
|
*
|
|
286
278
|
* @returns {any} - Value of given key in runtime config file or null
|
|
287
279
|
*/
|
|
288
|
-
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
289
280
|
try {
|
|
290
281
|
let json = JSON.parse( fs.readFileSync( runtime_config_path ));
|
|
291
282
|
let value = json[ key ];
|
|
@@ -309,7 +300,6 @@ session_vars.delete_runtime_config_var = function ({ key }) {
|
|
|
309
300
|
*
|
|
310
301
|
* @returns {null}
|
|
311
302
|
* */
|
|
312
|
-
const runtime_config_path = session_vars.get_runtime_config_path();
|
|
313
303
|
try {
|
|
314
304
|
if ( !fs.existsSync( runtime_config_path )) { return null; }
|
|
315
305
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const fast_glob = require(`fast-glob`);
|
|
2
|
-
const path = require(`path`);
|
|
3
2
|
|
|
4
3
|
const session_vars = require(`./session_vars`);
|
|
5
4
|
|
|
@@ -19,7 +18,7 @@ module.exports = function set_sources_paths({ log }) {
|
|
|
19
18
|
let maybe_paths = get_potential_paths();
|
|
20
19
|
|
|
21
20
|
let sources_paths = get_sources_paths({ maybe_paths });
|
|
22
|
-
if ( sources_paths
|
|
21
|
+
if ( sources_paths === 0 ) {
|
|
23
22
|
// If we don't throw, it'll be more confusing when no tests run
|
|
24
23
|
log.throw({ code: `ALK0050`, context: `sources`,
|
|
25
24
|
error: new ReferenceError(
|
|
@@ -46,7 +45,6 @@ function get_potential_paths() {
|
|
|
46
45
|
// `project` is the name in the server docassemble "Project" page
|
|
47
46
|
let project = session_vars.get_user_project_name();
|
|
48
47
|
let id = session_vars.get_user_id();
|
|
49
|
-
let root = process.cwd(); // Assumes correct root. See docs about root path.
|
|
50
48
|
|
|
51
49
|
// process.argv is a list of strings of commands and args.
|
|
52
50
|
// Internal note: If using `npm run cucumber`, use `--` before
|
|
@@ -55,8 +53,8 @@ function get_potential_paths() {
|
|
|
55
53
|
default: {
|
|
56
54
|
sources: [
|
|
57
55
|
`./docassemble/*/data/sources`, // In GitHub folder
|
|
58
|
-
`/usr/share/docassemble/files/playgroundsources/${id}/${project}`, // From playground without S3
|
|
59
|
-
|
|
56
|
+
`/usr/share/docassemble/files/playgroundsources/${id}/${project}/*.feature`, // From playground without S3
|
|
57
|
+
`/tmp/playgroundsources/${id}/${project}/*.feature` // From playground with S3
|
|
60
58
|
],
|
|
61
59
|
}
|
|
62
60
|
});
|
|
@@ -83,16 +81,16 @@ function get_sources_paths({ maybe_paths }) {
|
|
|
83
81
|
// Check every path, tracking which exist and which are missing
|
|
84
82
|
let existing_paths = [];
|
|
85
83
|
let missing_paths = [];
|
|
86
|
-
for ( let
|
|
84
|
+
for ( let path of maybe_paths ) {
|
|
87
85
|
let dirs = fast_glob.sync(
|
|
88
|
-
[
|
|
86
|
+
[ path ],
|
|
89
87
|
{ onlyFiles: false, suppressErrors: true }
|
|
90
88
|
);
|
|
91
89
|
|
|
92
90
|
if ( dirs.length > 0 ) {
|
|
93
91
|
existing_paths.push( ...dirs );
|
|
94
92
|
} else {
|
|
95
|
-
missing_paths.push(
|
|
93
|
+
missing_paths.push( path );
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
96
|
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suffolklitlab/alkiln",
|
|
3
|
-
"version": "5.15.
|
|
3
|
+
"version": "5.15.1-update-deps2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@suffolklitlab/alkiln",
|
|
9
|
-
"version": "5.15.
|
|
9
|
+
"version": "5.15.1-update-deps2",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@axe-core/puppeteer": "4.7.3",
|
|
@@ -380,6 +380,7 @@
|
|
|
380
380
|
"version": "4.0.1",
|
|
381
381
|
"resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-4.0.1.tgz",
|
|
382
382
|
"integrity": "sha512-Kxap9uP5jD8tHUZVjTWgzxemi/0uOsbGjd4LBOSxcJoOCRbESFwemUzilJuzNTB8pcTQUh8D5oudUyxfkJOKmA==",
|
|
383
|
+
"peer": true,
|
|
383
384
|
"peerDependencies": {
|
|
384
385
|
"@cucumber/messages": ">=17.1.1"
|
|
385
386
|
}
|
|
@@ -388,6 +389,7 @@
|
|
|
388
389
|
"version": "19.1.4",
|
|
389
390
|
"resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-19.1.4.tgz",
|
|
390
391
|
"integrity": "sha512-Pksl0pnDz2l1+L5Ug85NlG6LWrrklN9qkMxN5Mv+1XZ3T6u580dnE6mVaxjJRdcOq4tR17Pc0RqIDZMyVY1FlA==",
|
|
392
|
+
"peer": true,
|
|
391
393
|
"dependencies": {
|
|
392
394
|
"@types/uuid": "8.3.4",
|
|
393
395
|
"class-transformer": "0.5.1",
|
|
@@ -1482,7 +1484,8 @@
|
|
|
1482
1484
|
"node_modules/devtools-protocol": {
|
|
1483
1485
|
"version": "0.0.1312386",
|
|
1484
1486
|
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1312386.tgz",
|
|
1485
|
-
"integrity": "sha512-DPnhUXvmvKT2dFA/j7B+riVLUt9Q6RKJlcppojL5CoRywJJKLDYnRlw0gTFKfgDPHP5E04UoB71SxoJlVZy8FA=="
|
|
1487
|
+
"integrity": "sha512-DPnhUXvmvKT2dFA/j7B+riVLUt9Q6RKJlcppojL5CoRywJJKLDYnRlw0gTFKfgDPHP5E04UoB71SxoJlVZy8FA==",
|
|
1488
|
+
"peer": true
|
|
1486
1489
|
},
|
|
1487
1490
|
"node_modules/diff": {
|
|
1488
1491
|
"version": "5.0.0",
|
|
@@ -3008,6 +3011,7 @@
|
|
|
3008
3011
|
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-22.15.0.tgz",
|
|
3009
3012
|
"integrity": "sha512-XjCY1SiSEi1T7iSYuxS82ft85kwDJUS7wj1Z0eGVXKdtr5g4xnVcbjwxhq5xBnpK/E7x1VZZoJDxpjAOasHT4Q==",
|
|
3010
3013
|
"hasInstallScript": true,
|
|
3014
|
+
"peer": true,
|
|
3011
3015
|
"dependencies": {
|
|
3012
3016
|
"@puppeteer/browsers": "2.3.0",
|
|
3013
3017
|
"cosmiconfig": "^9.0.0",
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Root path
|
|
2
|
-
|
|
3
|
-
This code assumes the current root directory 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.
|