@suffolklitlab/alkiln 4.11.2 → 4.11.3
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
CHANGED
|
@@ -40,6 +40,13 @@ Format:
|
|
|
40
40
|
-->
|
|
41
41
|
<!-- ## [Unreleased] -->
|
|
42
42
|
|
|
43
|
+
## [4.11.3] - 2023-04-06
|
|
44
|
+
### Changed
|
|
45
|
+
- Project name prefix now includes ALKiln in it for clarity
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
- Projects created in da each have a unique name. https://github.com/SuffolkLITLab/ALKiln/issues/663
|
|
49
|
+
|
|
43
50
|
## [4.11.2] - 2023-03-22
|
|
44
51
|
### Security
|
|
45
52
|
- Pass docassemble API keys through HTTP headers instead of as parameters.
|
|
@@ -204,16 +204,17 @@ da_i.loop_to_create_project = async function( creation_options ) {
|
|
|
204
204
|
let wait_seconds = creation_options.wait_seconds || 5;
|
|
205
205
|
|
|
206
206
|
let project_name = null;
|
|
207
|
-
|
|
207
|
+
// Unlikely, but 2 devs could run locally and create the same Project name
|
|
208
|
+
let num_tries = 0;
|
|
208
209
|
|
|
209
210
|
// Try to create a project. If the project name is already taken, increment and loop again.
|
|
210
|
-
while (
|
|
211
|
-
|
|
211
|
+
while ( num_tries <= max_tries ) {
|
|
212
|
+
num_tries++;
|
|
212
213
|
try {
|
|
213
214
|
|
|
214
215
|
// Try next name that could be unique. Must remove all non-valid characters
|
|
215
216
|
// TODO: This sanitization is already done in session_vars, so remove it from here
|
|
216
|
-
project_name = session_vars.get_project_base_name().replace(/[^A-Za-z0-9]/g, '') +
|
|
217
|
+
project_name = session_vars.get_project_base_name().replace(/[^A-Za-z0-9]/g, '') + `${Date.now()}`;
|
|
217
218
|
log.info({ pre: `Trying to create a docassemble Project with the name ${ project_name }` });
|
|
218
219
|
let response = await _da_REST.create_project( project_name, timeout );
|
|
219
220
|
log.info({ pre: `The docassemble server is ready. Created a Project named ${ project_name }` });
|
|
@@ -226,7 +227,7 @@ da_i.loop_to_create_project = async function( creation_options ) {
|
|
|
226
227
|
|
|
227
228
|
if ( response && response.data ) {
|
|
228
229
|
if ( response.data.includes( `Invalid project` ) ) {
|
|
229
|
-
if (
|
|
230
|
+
if ( num_tries < max_tries ) {
|
|
230
231
|
// A non-unique project name. Try the next project name.
|
|
231
232
|
continue;
|
|
232
233
|
|
|
@@ -254,11 +255,11 @@ da_i.loop_to_create_project = async function( creation_options ) {
|
|
|
254
255
|
|
|
255
256
|
// If it's a timeout error, server is busy. Try again after waiting.
|
|
256
257
|
// Why are we using `max_tries` for timeout error as well?
|
|
257
|
-
if ( is_timeout_error( error ) &&
|
|
258
|
+
if ( is_timeout_error( error ) && num_tries < max_tries ) {
|
|
258
259
|
log.info({ pre: `The docassemble server was busy when we tried to `
|
|
259
|
-
+ `create the Project. Attempt ${
|
|
260
|
+
+ `create the Project. Attempt ${ num_tries } of `
|
|
260
261
|
+ `${ max_tries }. Will try again in ${ wait_seconds } seconds.` });
|
|
261
|
-
|
|
262
|
+
num_tries--; // Don't count this try
|
|
262
263
|
await time.waitForTimeout( wait_seconds * 1000 );
|
|
263
264
|
continue;
|
|
264
265
|
|
package/lib/docassemble/setup.js
CHANGED
|
@@ -25,6 +25,7 @@ const setup = async () => {
|
|
|
25
25
|
// avoids showing confusing node errors to users that they shouldn't have to fix
|
|
26
26
|
try {
|
|
27
27
|
project_name = await da_i.loop_to_create_project();
|
|
28
|
+
log.info({type: `setup`, pre: `Created a Project named ${ project_name }`});
|
|
28
29
|
} catch (error) {
|
|
29
30
|
log.error({type: `setup`, pre: `an unexpected error occurred while trying to create a docassemble project in the user's account`, data: JSON.stringify(error, null, 4)})
|
|
30
31
|
// we don't re-throw the exception, so make sure to exit with 1 to let Github Actions know the script failed
|
|
@@ -75,7 +75,7 @@ session_vars.get_package_name = function () {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
session_vars.get_project_base_name = function () {
|
|
78
|
-
let name = `
|
|
78
|
+
let name = `ALKilnTest${ session_vars.get_package_name() }${ session_vars.get_branch_name() }`;
|
|
79
79
|
let sanitized_name = name.replace( /[^A-Za-z0-9]/g, '' );
|
|
80
80
|
return sanitized_name;
|
|
81
81
|
};
|