Hi there,
i’ve done some changes on SubmissionTabHandler.js
.
Now i need to recompile pkp.min.js
to add the changes to this file.
How do i recompile it?
So lonG
Daniel
Hi there,
i’ve done some changes on SubmissionTabHandler.js
.
Now i need to recompile pkp.min.js
to add the changes to this file.
How do i recompile it?
So lonG
Daniel
Hi @j1shin,
See https://pkp.sfu.ca/wiki/index.php?title=JavaScript_coding_conventions#Building_and_Checking_JS_Code for details.
Regards,
Alec Smecher
Public Knowledge Project Team
Nah, forgive my blindness. Thanks.
Hi @j1shin,
Not a problem! The wiki is a maze and we’re in the process of reorganizing it.
Thanks,
Alec Smecher
Public Knowledge Project Team
Hi @asmecher ,
i cannot get it working, i’m getting all sorts of errors.
Trying to debug the script didn’t work either.
Perhaps it’s the tools version that matters.
Can you post a list with the version of each tool required?
Thanks.
So lonG
Hi @j1shin,
Check out the Travis configuration for specifics: Travis CI - Test and Deploy Your Code with Confidence
The first 3 builds (VALIDATION
) include the Javascript build process. The script that sets this up is in the github repo in lib/pkp/tools/travis/install-linter.sh
; then the travis testing itself occurs in lib/pkp/tools/buildjs.sh
.
Regards,
Alec Smecher
Public Knowledge Project Team
Hi @asmecher,
it compiles, yay. I am developing in a Windows environment hence it wasn’t as easy as calling the scripts. For reference, i had to
LF
line ending as bash scripts / tools cannot handle CRLF
(changed git configuration to core.autocrlf=false
, see https://stackoverflow.com/a/33424884/3936440)sed
call in build script lib/pkp/tools/buildjs.sh
lib/pkp/tools/travis/install-linter.sh
lib/pkp/tools/buildjs.sh -n
As already mentioned i had to change the sed
call in buildjs.sh
from
sed "s/^${TAB}//;s/${TAB}/ /g;s/^(function(\$) {//;s/^}(jQuery));//;s/@extends \(.*\)$/@extends {\1}/" "$JS_FILE" > "$WORKDIR/$JS_FILE"`
to
sed \
-e "s/^${TAB}//" \
-e "s/${TAB}/ /g" \
-e 's/^(function(\$) {//' \
-e 's/^}(jQuery));//' \
-e 's/@extends \(.*\)$/@extends {\1}/' \
"$JS_FILE" > "$WORKDIR/$JS_FILE"
because matching (function(\$) {
did not work with double quotes. I used single quotes instead to avoid special string handling (which should not be needed here anyway). Additionally i added line breaks to make the call more readable as at first i more or less struggled to understand the single line.
Should i provide a PR for the build script?
But … i still have an issue. After compiling the pkp.min.js
file still contains the old code. I’m a bit puzzled, how is this possible?
So lonG
Daniel
Hi @j1shin,
Hmm, are you handy with Vagrant? The quickest/easiest way to get this recompiled, or to compare your process on Windows with a known-working one on Linux, might be to use the Vagrant image (GitHub - pkp/vagrant: Vagrant environments for PKP software). I haven’t used this yet to recompile the JS but it’ll essentially be 90% the same environment as Travis uses, so the same steps to add the compiler and linter etc. should apply there verbatim.
Regards
Alec Smecher
Public Knowledge Project Team
Hi @asmecher
yeah i know about Vagrant, thanks for the suggestion. I have used it several times in the past but this time i wanted to try out the WIndows subsystem for Linux. Anyway, pkp.min.js
compiles fine now, dunno what was the issue yesterday, perhaps the missing sleep
May i provide a PR for the sed command update?
So lonG
Daniel
Hi @j1shin,
Sure, a PR for the sed change would be great – the script works fine over here as it currently stands, but I’ll have a look and a test to see how it affects my environment (and whether I was encountering the same problem, but somehow masked).
Regards,
Alec Smecher
Public Knowledge Project Team
Created a corresponding Github issue: [OJS] lib/pkp/tools/buildjs.sh is not working in Windows Subsystem for Linux / Debian · Issue #4043 · pkp/pkp-lib · GitHub