Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sandstorm app package support #285

Closed
wants to merge 3 commits into from
Closed

Conversation

ocdtrekkie
Copy link
Contributor

With these changes, the Sandstorm packaged version can run the same code as a standard deployment with a single additional configuration option. I am not much of a JavaScript developer, so nitpicks are welcome.

Fixes #284

By opening a pull request, I certify that I hold the intellectual property of the code I am submitting,
and I am granting the initial authors of WBO a perpetual, worldwide, non-exclusive, royalty-free, and irrevocable license to this code.

Copy link
Owner

@lovasoa lovasoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

I don't have the competence to review and maintain the things in .sandstorm. I'll merge the changes to the application itself though, after you fix my little nitpicks :)

# -*- mode: ruby -*-
# vi: set ft=ruby :

# CAUTION: DO NOT MAKE CHANGES TO THIS FILE. The vagrant-spk upgradevm process will overwrite it.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this file auto-generated ? If so, then maybe it shouldn't be on git ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these file need to be on git ?

Comment on lines +19 to +24
try {
const { uid, gid } = os.userInfo();
} catch (e) {
console.error(`os.userInfo does not work in this environment.`);
const { uid, gid } = [];
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not work, does it ? uid and gid become local to the scope of the try/catch.

Looking at the code, we could avoid the call to userInfo completely in the normal case, since we use the uid/gid only when the writeFileSync fails.

  try {
    fs.writeFileSync(tmpfile, "{}");
    fs.unlinkSync(tmpfile);
  } catch (e) {
    let err_msg = "does not allow file creation and deletion. ";
    try {
        const { uid, gid } = os.userInfo();
        err_msg += "Check the permissions of the directory, and if needed change them so that " +
      `user with UID ${uid} has access to them. This can be achieved by running the command: chown ${uid}:${gid} on the directory`;
      } finally {
             return err_msg;
      }
  }

@@ -57,5 +57,8 @@ module.exports = {

/** Secret key for jwt */
AUTH_SECRET_KEY: (process.env["AUTH_SECRET_KEY"] || ""),

/** If this variable is set, automatically redirect to this board. */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** If this variable is set, automatically redirect to this board. */
/** If this variable is set, automatically redirect to this board from the root of the application. */

indexTemplate.serve(request, response);
else
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the double negation is hard to process. Maybe invert the if and else: if (config.DEFAULT_BOARD) ... else ...

indexTemplate.serve(request, response);
else
response.writeHead(302, { Location: 'boards/' + config.DEFAULT_BOARD });
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The board name needs to be urlencoded.

@ocdtrekkie
Copy link
Contributor Author

These changes worked for me in the sense that the Sandstorm package still works, and without the environment variable set, the index loads, but I suspect you are correct that I never actually test a path where the userInfo is actually used, and your solution is better. I will amend my changes tonight, along with the other changes.

As far as the contents of .sandstorm, generally, yes they all are committed together. pgp-signature is actually a file specific to this package which states I control the app publishing key for this package. While we discourage the Vagrantfile and global-setup.sh being edited, they carry some important information to replicate the build environment, such as what box is used, and regenerating them is only done in breaking scenarios, usually.

Honestly one of my unsolved problems is I did notice you don't commit your screenshots to the repo, and for the Sandstorm app metadata, we generally would. It is possible that upstreaming the package metadata is the wrong call if you prefer to keep a fairly lean tree: I potentially could PR the changes to WBO itself, but keep the .sandstorm directory on its own repository.

Instead of it being a fork of WBO, I can have the separate build repo clone the official WBO repo in the build process, which could be used verbatim since I'm upstreaming the needed changes to WBO to work on Sandstorm.

@lovasoa
Copy link
Owner

lovasoa commented Oct 26, 2023

I potentially could PR the changes to WBO itself, but keep the .sandstorm directory on its own repository.
Instead of it being a fork of WBO, I can have the separate build repo clone the official WBO repo in the build process, which could be used verbatim since I'm upstreaming the needed changes to WBO to work on Sandstorm.

I think that would work better for me, yes !

@ocdtrekkie
Copy link
Contributor Author

Awesome. I will do some reorganizing on my end and submit a PR with just the improved changes to your code.

@ocdtrekkie ocdtrekkie closed this Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Note: There is now a Sandstorm package for this app!
2 participants