Skip to content

Commit

Permalink
Revert "Replace runtime_config.json var with _ORIGIN env var. Not sure"
Browse files Browse the repository at this point in the history
This reverts commit 0507540.
  • Loading branch information
plocket committed Aug 13, 2023
1 parent 0507540 commit 93d8cd1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion github_server/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]" --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="[email protected]" --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
Expand Down
11 changes: 8 additions & 3 deletions lib/docassemble/get_base_interview_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};

Expand Down
31 changes: 31 additions & 0 deletions lib/utils/session_vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 93d8cd1

Please sign in to comment.