-
Notifications
You must be signed in to change notification settings - Fork 159
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
Updated package.json and added font-awesome-rails gem #658
Conversation
Hi @jywarren @pydevsg @RuthNjeri. Pls could you review this pull request. Thanks. This PR aims to create a This shouldn't be merged straightaway though!!! The dependencies are distributed on different files. Hence all the changes should be done like #661 to retain the functionality with the new change. |
Hi @waridrox 👋🏾 My first concern is all the tests in this PR failing, it seems to relate to the updates. I see a package.json file, should there be a lock file? Similar to the Rails gemfile? Also, maybe to speed off the merging of one of the issues being solved here, one idea is to split the work focusing on the font awesome and the other handling the package.json file it would also help narrowing down on what is causing the tests to fail. |
Hi @RuthNjeri 🙌, thanks for pointing out the missing
The app works fine on
|
Hi, @waridrox . |
Thanks @waridrox and @pydevsg, glad to hear that everything is working as expected. Just to make sure I have understood you correctly, the When you mention that you haven't updated the paths to access the The setup needs to pass first in order for the tests to run From what you are saying, @waridrox, it seems the setup won't pass until files have the updated path to |
Sorry for the confusion @RuthNjeri 😅, in an attempt to move away from bower dependencies, I have extracted the dependable files (available/deprecated as bower dependencies) and put them in the assets folder, thereby changing the path in the files that require those dependencies.
Sure then I'll look into the tests and make tweaks accordingly. Thanks :) |
Just chiming in here -- great start!
I see we're doing the same here as in plots2, which looks good: https://github.com/publiclab/plots2/blob/4756f69a856e0328a2ce60a60778bced74d9d370/Gemfile#L73 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @waridrox -- left a lot of comments but I think the overall is that we could simplify this considerably and narrow the possible errors by sticking with the existing versions of all the package.json modules, and where they don't exist or need to be replaced, looking to the plots2 repository for the version we used there. However, swapping in other versions is likely to work mainly for CSS or image/font assets, and not for JS, which would be likely to break.
Can we try a narrower set of changes and see how it does, for example sourcing the NPM module for Junction font, and reverting most or all of the package.json version changes?
activerecord (= 5.2.4.3) | ||
activestorage (= 5.2.4.3) | ||
activesupport (= 5.2.4.3) | ||
rails (5.2.4.6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, these are some pretty big changes here unrelated to the new gem. But let's see, maybe that wasn't an issue. In general, though, perhaps we should do what we can to limit the upgrades to just those directly related to the issue at hand... makes it easier to debug and review as well!
@@ -0,0 +1,553 @@ | |||
<?xml version="1.0" standalone="no"?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so all the Junction fonts are available on NPM here: https://github.com/publiclab/plots2/blob/main/package.json#L45
Shall we switch to using that?
//= require bootstrap-css/js/bootstrap.min.js | ||
//= require getusermedia.js/dist/getUserMedia.min.js | ||
//= require bootstrap.min.js | ||
//= require getusermedia-js/dist/getUserMedia.min.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, yes, this looks like typical changes required when moving from Bower to NPM. Great!!
@@ -0,0 +1,6 @@ | |||
/*! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I don't think actually importing the whole library is ideal. In general we want to avoid that at all costs, in fact!
However, looking at plots2 we have a good alternative NPM module here: https://github.com/publiclab/plots2/blob/4756f69a856e0328a2ce60a60778bced74d9d370/package.json#L26
@@ -19,7 +19,6 @@ | |||
<link rel="shortcut icon" href="//spectralworkbench.org/images/spectral-workbench-256.png" /> | |||
|
|||
<%= stylesheet_link_tag "application", :media => "all" %> | |||
<link rel="stylesheet" href="/lib/fontawesome/css/font-awesome.min.css"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because we're going to be compiling them into the main stylesheet, or making it appear in an asset path that's searched, so it's auto-included from line 21?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the font-awesome
gem enables the use of the lib since that is already included in the application.css
file.
@@ -54,6 +54,8 @@ class Application < Rails::Application | |||
|
|||
# Enable the asset pipeline | |||
config.assets.enabled = true | |||
config.assets.paths << Rails.root.join("app", "assets", "fonts") | |||
config.assets.paths << Rails.root.join("node_modules") | |||
config.assets.paths << Rails.root.join('public/lib') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So yes, here is my preference, especially for fontawesome and things that have fonts, stylesheets, or image assets, which we may need to be able to access via a public web route. But cool to see the above options added too. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, now there's no need of this, assets can be accessed at public/lib
path with yarn
@@ -10,6 +10,8 @@ | |||
# Rails.application.config.assets.paths << Emoji.images_path | |||
# Version of your assets, change this if you want to expire all your assets | |||
config.assets.paths << Rails.root.join('public/lib') | |||
config.assets.paths << Rails.root.join("node_modules") | |||
config.assets.paths << Rails.root.join("app", "assets", "fonts") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it required to do it twice?
"dependencies": { | ||
"ace-builds": "jywarren/ace-builds#v1.2.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch out - here, this looks like I customized it before including it. We should stick with the version I had pegged to, just in case. For the remainder, I worry about the versions you've chosen... some are major version number upgrades (see https://docs.npmjs.com/about-semantic-versioning/) and are likely to break the app. Was there a reason to attempt upgrades of all these modules at once? It could be much easier to go one by one and check each time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So wherever we can't find a published NPM module, the syntax is that it will search as follows:
jywarren/ace-builds#v1.2.4
means:
https://github.com/jywarren/ace-builds with branch or commit v1.2.4
So that would be:
https://github.com/jywarren/ace-builds/tree/v1.2.4
We can point at non-NPM-published code in this way, as long as we specify a commit or a published release in this syntax. Just in case you run into issues, but I think all of these were already pegged to repositories rather than NPM modules, already, when we originally migrated from Bower!
"bootstrap": "^3.4.1", | ||
"d3": "^3.5.17", | ||
"flot": "^0.8.0-alpha", | ||
"getusermedia-js": "^1.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful that this package could be entirely different from the one specified before - by a different author, etc. Maybe best stick with the existing one for now?
In fact, i see that the error is still So, if you revert the package.json file, then generate a new lockfile with THAT SAID, we are using Yarn in this repo. So the lockfile really ought to be Did it really error asking for
What was the exact error when it asked for Yes - it was asking why packages weren't showing in the lockfile, but not
And it was happening during this
My guess is that you had modified the Hope this helps. Maybe we just need a much narrower set of changes to start this PR? |
OK, so let's try splitting this into separate PRs. One for changing the name in package.json to This is exciting, great start, @waridrox!!! |
Done in #671 |
Very nicely done. thank yoU! |
Part of #645
Ok so the
package.json
file hadspectral-workbench
as the project name which conflicts with the spectral-workbench.js library currently hosted on npm. As of now, it is named asspectralworkbench
which could be renamed to something meaningful later 😅.Plus there's an inclusion of
font-awesome-rails
gem that provides access to the font-awesome lib. The goal is to rely as little as possible on CDN services...The
Gemfile.lock
works fine locally but need to see if it works on the live versionCC: @jywarren @pydevsg
Thanks!