diff --git a/github_server/action.yml b/github_server/action.yml index 5310cf9c..6c7fac08 100644 --- a/github_server/action.yml +++ b/github_server/action.yml @@ -35,7 +35,7 @@ runs: mkdir /tmp/config echo "$CONFIG_CONTENTS" > /tmp/config/myconfig.yml docker pull brycewilley/smoldocassemble - docker run --env DA_ADMIN_EMAIL="admin@example.com" --env DA_ADMIN_PASSWORD="password" --env DA_ADMIN_API_KEY="${{ env.DA_ADMIN_API_KEY }}" --env DA_CONFIG=/tmp/config/myconfig.yml --env _ORIGIN=github_server --volume /tmp/config:/tmp/config --cap-add SYS_PTRACE --memory="4gb" -d -p 80:80 jhpyle/docassemble + docker run --env DA_ADMIN_EMAIL="admin@example.com" --env DA_ADMIN_PASSWORD="password" --env DA_ADMIN_API_KEY="${{ env.DA_ADMIN_API_KEY }}" --env DA_CONFIG=/tmp/config/myconfig.yml --volume /tmp/config:/tmp/config --cap-add SYS_PTRACE --memory="4gb" -d -p 80:80 jhpyle/docassemble # TODO before merge: do a while loop here until `localhost` shows "It's ready" sleep 480 curl localhost diff --git a/lib/docassemble/get_base_interview_url.js b/lib/docassemble/get_base_interview_url.js index dbb72527..bf51a968 100644 --- a/lib/docassemble/get_base_interview_url.js +++ b/lib/docassemble/get_base_interview_url.js @@ -11,12 +11,17 @@ let get_base_interview_url = async function () { * when the user is not logged in.) We can't use `reset=2` because it caused an * 'Unable to locate interview session' error. */ let server_url = session_vars.get_da_server_url(); - if (session_vars.get_origin() === "github_server") { - return `${ server_url }/interview?new_session=1&i=${session_vars.get_package_name().replace("-", ".")}%3A`; + console.log(session_vars.get_install_type()); + if (session_vars.get_install_type() === "server") { + let x = `${ server_url }/interview?new_session=1&i=${session_vars.get_package_name().replace("-", ".")}%3A`; + console.log(`base_interview_url: ${x}`) + return x; } else { let dev_id = await docassemble_api_interface.get_dev_id(); let project_name = session_vars.get_project_name(); - return`${ server_url }/interview?new_session=1&i=docassemble.playground${ dev_id }${ project_name }%3A`; + let x = `${ server_url }/interview?new_session=1&i=docassemble.playground${ dev_id }${ project_name }%3A`; + console.log(`base_interview_url: ${x}`) + return x; } }; diff --git a/lib/utils/session_vars.js b/lib/utils/session_vars.js index 155a0607..9956eb58 100644 --- a/lib/utils/session_vars.js +++ b/lib/utils/session_vars.js @@ -115,6 +115,7 @@ session_vars.get_languages = function () { const runtime_config_path = `runtime_config.json`; const project_name_key = `da_project_name`; +const install_type_key = `da_install_type`; session_vars.save_project_name = function ( project_name ) { /* Saves the name of the project to a json obj so deletion can use it later. * Built for local as well as remote testing. Assumes a kosher string. @@ -197,6 +198,36 @@ session_vars.save_artifacts_path_name = function ( path_name ) { return file; }; // Ends save_artifacts_path_name() + +session_vars.save_install_type = function (install_type) { + /* Save a key with the name of the current artifacts folder in case it doesn't exist. */ + + // Ensure artifacts path file exists + if ( !fs.existsSync( runtime_config_path ) ) { + // If the file doesn't exist, make one because next we need to read it + fs.writeFileSync( runtime_config_path, JSON.stringify( {}, null, 2 ) ); + } + + // Get the json, changing it, and re-write the file from scratch + let json = JSON.parse( fs.readFileSync( runtime_config_path ) ); + json[ install_type_key ] = install_type; + let file = fs.writeFileSync( runtime_config_path, JSON.stringify( json, null, 2 ) ); + + return file; +}; // Ends save_artifacts_path_name() + +session_vars.get_install_type = function () { + /* Get the name of the current artifacts path. */ + try { + let json = JSON.parse( fs.readFileSync( runtime_config_path )); + let install_type = json[ install_type_key ]; + + return install_type; + } catch ( error ) { + return null; + } +}; // Ends get_artifacts_path_name() + session_vars.get_artifacts_path_name = function () { /* Get the name of the current artifacts path. */ try {