Skip to content

Avoid main.js in git repo - #1641

Merged
karussell merged 14 commits into
masterfrom
avoid_main_js
Jun 28, 2019
Merged

karussell merged 14 commits into
masterfrom
avoid_main_js

Conversation

@karussell

@karussell karussell commented Jun 22, 2019 •

Copy link
Copy Markdown
Member

Fixes #1548

from @michaz
Build and deploy it with its appropriate toolchain (npm probably?)

I think this is the easiest way to solve the problem: removing main.js from git and creating it on travis. I.e. in every released jar the main.js will be still included.

TODOs

  • adopt docs for developers (check user docs too, include mention of assets overrides section - see below)
  • adopt docker
  • include nvm&npm install in graphhopper.sh?
  • make sure server restart is not required for JS changes (there seems to be something broken, maybe due to the recent dropwizard upgrade?) I used the config-example.yml where the assets overrides section is uncommented. This is a bit ugly but as we do not want this in production we need to have it as it is.

@karussell karussell added this to the 0.13 milestone Jun 22, 2019
@karussell karussell changed the title Avoid main js Avoid main.js in git repo Jun 22, 2019
@easbar

easbar commented Jun 22, 2019

Copy link
Copy Markdown
Member

Nice! Where will main.js be available for download after the travis build ?

@karussell

karussell commented Jun 22, 2019 •

Copy link
Copy Markdown
Member Author

Nice! Where will main.js be available for download after the travis build ?

It is not available for download. But it is included in the jar file like before. (I hope, not verified yet ;) )

So everyone using the release won't notice the change. And everyone using the sources will have to create it before using it. I'm thinking of including a oneliner to prepare everything for that.

I have thought about the "downloadable main.js"-option, but everytime we change something, we need to point to a new release in index.html or package.json, which we will likely forget (often)

Comment thread docs/core/quickstart-from-source.md Outdated
People with IDE knowledge can directly jump to [Start Development](#start-development)

Now, before you proceed install git and jdk8, then do:
Now, before you proceed install git and jdk8 or jdk11, then do:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe it would make sense to split this in two lines. It's too easy to misread this sentence IMHO :).

Install git and jdk8 or jdk11.

Then do:

# create main.js via npm, can be omitted if no UI is needed
cd web && npm install && npm run bundleProduction && cd ..
# fetches main.js, can be omitted if no UI is needed
cd web/src/main/resources/ && ZFILE=/tmp/gh.jar && wget -O $ZFILE "https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.graphhopper&a=graphhopper-web&v=LATEST" && unzip $ZFILE assets/js/main.js && rm $ZFILE && cd ../../../..

@karussell karussell Jun 28, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

With this "trick" we fetch the latest snapshot main.js that is bundled in the maven repo of "graphhopper-web" and there is no longer a need to install npm if no JS development is done. I think with this it is again easy enough to install graphhopper and ready to merge - what do you think @boldtrn ?

(Unfortunately nexus does not seem to allow to download just a single file from a zip container unlike e.g. artifactory, so we have to download the whole jar, but better than whole npm and dependencies)

@karussell
karussell merged commit 393f913 into master Jun 28, 2019
@karussell
karussell deleted the avoid_main_js branch June 28, 2019 14:14
@easbar easbar mentioned this pull request Jun 29, 2019
@karussell

karussell commented Jul 1, 2019 •

Copy link
Copy Markdown
Member Author

Nice! Where will main.js be available for download after the travis build ?

As mentioned above. The main.js is downloadable from the snapshots and releases via fetching the graphhopper-web jar and then unzipping. See docs/core/quickstart-from-source.md for the master

Update: should we include a maven plugin? ( https://github.com/eirslett/frontend-maven-plugin suggested from @michaz )

@max-kubierschky

Copy link
Copy Markdown
Contributor

Please put a hint about uncommenting the assets overrides section in config.yml and/or about how to do it with npm in the developer quickstart. It took me a whole day to figure this out (no blame intended, you are doing an awesome job).

@karussell

karussell commented Sep 24, 2019 •

Copy link
Copy Markdown
Member Author

It should be already there :)

https://github.com/graphhopper/graphhopper/blob/master/docs/core/quickstart-from-source.md#javascript

But yes, we need to improve this as I stumbled also over this although I should know...

@max-kubierschky

max-kubierschky commented Sep 24, 2019 •

Copy link
Copy Markdown
Contributor

Oops, indeed, sorry.

I remember having read the first sentence of the paragraph: "When developing the UI ...", thought "Not for me" and skipped it. But when I pointed the browser to localhost:8989, it didn't seem to work.

@karussell

Copy link
Copy Markdown
Member Author

If you do not intend to change the UI then npm and also this line should not be required.

Did you include the following line before running the graphhopper.sh script?

cd web/src/main/resources/ && ZFILE=/tmp/gh.jar && wget -O $ZFILE "https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.graphhopper&a=graphhopper-web&v=LATEST" && unzip $ZFILE assets/js/main.js && rm $ZFILE && cd ../../../..
./graphhopper.sh -a web -i europe_germany_berlin.pbf

@max-kubierschky

Copy link
Copy Markdown
Contributor

Yes, I tried that.

@karussell

Copy link
Copy Markdown
Member Author

Strange. Maybe you have no wget installed or some other error occured for the first command?

I tried to reproduce a problem but even if I removed the jar and main.js files:

./graphhopper.sh clean
rm web/src/main/resources/assets/js/main.js

the two lines worked and the main.js was included in the jar, i.e. the UI was properly showned (and the main.js served from classpath).

@max-kubierschky

Copy link
Copy Markdown
Contributor

I retried with a newly downloaded repository. When I run the line you mentioned above before running graphhopper from the Intellij IDE, everything works.

So the only thing that needs to be changed in the developer quickstart is deleting the sentence "People with IDE knowledge can directly jump to Start Development." and maybe in the section "Start Development" a hint, that you need to run that line.

Not running that line reproduced my problem.
FYI here's a transcript of what I did:

  • git clone git://github.com/graphhopper/graphhopper.git
  • edit Run Configurations as described on the Quick Start Page
  • run Web Application ==> config.yml not found
  • cp config-example.yml config.yml
  • run Web Application ==> java.lang.IllegalStateException: Your specified OSM file does not exist:/home/max/cproj/wifaz/graphhopper/europe_germany_berlin.osm.pbf
  • ./graphhopper.sh -a web -i europe_germany_berlin.pbf -o europe_germany_berlin.osm-gh/
  • run Web Application ==> Server starts and responds, but shows no map (main.js is missing)

@karussell

Copy link
Copy Markdown
Member Author

"People with IDE knowledge can directly jump to Start Development."

Ups, thanks that is a problem that we need to fix! Either by removing or an improved IDE section - maybe you have a minute to improve this :) ? And make it really simple and obvious for starting developers.

Because the wget will automatically download the main.js and the graphhopper.sh script will fetch the pbf and copy the config.yml from config-example.yml.

@max-kubierschky

Copy link
Copy Markdown
Contributor

maybe you have a minute to improve this
Yes of course. Do I need to make a pull request for this?

@karussell

Copy link
Copy Markdown
Member Author

Would be best, yes

@maxmargolin

Copy link
Copy Markdown

Hey, thank you for the change It helped me get started.
May I suggest also changing "When developing the UI for GraphHopper" to something more similar to "If you intend to use the UI".
when just checking that quick-starting worked(or seeing that config changes had taken effect), someone like me may want to just see the changed affected in the UI, without necessarily "developing it".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants