diff --git a/.build.sh b/.build.sh index 0b2dabba4efbd9c700a1cb47bbb958317ee17a90..d5a129e81200df7a2632f1f16b9f09f3940d6938 100755 --- a/.build.sh +++ b/.build.sh @@ -6,13 +6,13 @@ apt-get update && apt-get install -y devscripts CHANGELOG="package/debian/changelog" LINE=$(head -n 1 $CHANGELOG) -PACKAGE=$(echo $LINE | cut -d' ' -f1) -VERSION=$(echo $LINE | cut -d' ' -f2 | grep -o -E '[0-9]*\.[0-9]*\.[0-9]*') -tar --exclude=debian -czf ${PACKAGE}_${VERSION}.orig.tar.gz package/* +PACKAGE=$(echo "$LINE" | cut -d' ' -f1) +VERSION=$(echo "$LINE" | cut -d' ' -f2 | grep -o -E '[0-9]*\.[0-9]*\.[0-9]*') +tar --exclude=debian -czf "${PACKAGE}"_"${VERSION}".orig.tar.gz package/* -cd package +cd package || exit -1 debuild -us -uc --lintian-opts --profile debian -cd ../ +cd ../ || exit -1 mkdir build/ -mv ${PACKAGE}* build/ +mv "${PACKAGE}"* build/ diff --git a/.deploy.sh b/.deploy.sh index d02eac5c5b4f503eaf15e5d3c814b5eecb161bd2..7ebaab5d735f737aa0a6176555ac83dc23086e30 100755 --- a/.deploy.sh +++ b/.deploy.sh @@ -5,7 +5,7 @@ apt-get update && apt-get install -y dput ssh -eval $(ssh-agent -s) +eval "$(ssh-agent -s)" ssh-add <(echo "$PRIV_KEY") echo "Deploy job name: $CI_JOB_NAME" @@ -15,9 +15,10 @@ if [ "$CI_JOB_NAME" = "deploy_for_testing" ]; then elif [ "$CI_JOB_NAME" = "deploy_for_stable" ]; then CHANGELOG="package/debian/changelog" LINE=$(head -n 1 $CHANGELOG) - PACKAGE=$(echo $LINE | cut -d' ' -f1) - VERSION=$(echo $LINE | cut -d' ' -f2 | grep -o -E '[0-9]*\.[0-9]*\.[0-9]*') + PACKAGE=$(echo "$LINE" | cut -d' ' -f1) + VERSION=$(echo "$LINE" | cut -d' ' -f2 | grep -o -E '[0-9]*\.[0-9]*\.[0-9]*') REPREPRO_CMD="reprepro -Vb /home/repository/www/le6 copysrc stable testing $PACKAGE $VERSION" + # shellcheck disable=SC2029 ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa repository@repo.c3sl.ufpr.br "$REPREPRO_CMD" fi diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b8948c825b59519227cf6846fc225176b24c28d8..323fa631fc005cedde43f55295e7962254efb400 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,28 @@ ## Template para empacotamento utilizando o Gitlab-ci. stages: + - lint - build - test - deploy +linter_shell: + stage: lint + tags: + - debian-packaging + script: + - ./.linter_shell.sh + +linter_javascript: + stage: lint + tags: + - ubuntu + - regular + script: + - apt-get update && apt-get install -y nodejs npm nodejs-legacy + - npm install -g jshint + - jshint package/ + build: stage: build artifacts: diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000000000000000000000000000000000000..1bb8e137784120c9aa840a02938fcc2e92e93a3d --- /dev/null +++ b/.jshintrc @@ -0,0 +1,4 @@ +{ + "esversion": 6, + "laxbreak": true +} diff --git a/.linter_shell.sh b/.linter_shell.sh new file mode 100755 index 0000000000000000000000000000000000000000..5a7a90d6c86d945be6d4c09d9b83379e52e5f47e --- /dev/null +++ b/.linter_shell.sh @@ -0,0 +1,23 @@ +#!/bin/bash +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +sh_files=$(find -name "*.sh") +exe_files=$(grep -Erl "#\!/bin/(bash|sh)" --exclude=*.* package) +files="$sh_files\n$exe_files" +#find no files +if [[ "$files" == "\n" ]];then + echo -e "${YELLOW}No shell files found!${NC}" + exit 0 +fi + +echo -e "$files"| xargs shellcheck -s bash +if [[ $? -eq 0 ]];then + echo "AWESOME!No problems found." + exit 0 +else + echo -e "Understand errors in: ${BLUE}https://github.com/koalaman/shellcheck/wiki${NC}" + exit 1 +fi + diff --git a/package/le-edubar@c3sl.ufpr.br/constants.js b/package/le-edubar@c3sl.ufpr.br/constants.js index a04ca147e5bf60dbde2076c35438aa9a539a868d..c316434aa1cb2ab9612996977daf2b7c99d3f0ee 100644 --- a/package/le-edubar@c3sl.ufpr.br/constants.js +++ b/package/le-edubar@c3sl.ufpr.br/constants.js @@ -53,7 +53,7 @@ const DOWNLOAD_PATH = "/var/cache/le-edubar/"; /*TAGS*/ const URL_SUBJECTS = "https://api.portalmec.c3sl.ufpr.br/v1/subjects"; const URL_EDUCATIONAL_STAGES = "https://api.portalmec.c3sl.ufpr.br/v1/educational_stages"; -const URL_OBJECT_TYPES = "https://api.portalmec.c3sl.ufpr.br/v1/object_types" +const URL_OBJECT_TYPES = "https://api.portalmec.c3sl.ufpr.br/v1/object_types"; const ICON_THUMBNAIL = { /*DEFAULT*/ diff --git a/package/le-edubar@c3sl.ufpr.br/download.sh b/package/le-edubar@c3sl.ufpr.br/download.sh index 74c0b2dd647b557ff42c7b0e145f08e8f4d3bb96..4709beb46d2db644559d28bc9ef6432876bcbcf7 100755 --- a/package/le-edubar@c3sl.ufpr.br/download.sh +++ b/package/le-edubar@c3sl.ufpr.br/download.sh @@ -33,7 +33,7 @@ if test ! -d "$fdir" ;then mkdir -p "$fdir" fi -cd "$fdir" +cd "$fdir" || exit -1 #Create file folder if test ! -d "$file_id" ; then @@ -41,7 +41,7 @@ if test ! -d "$file_id" ; then fi #Download file -cd "$fdir/$file_id" +cd "$fdir/$file_id" || exit -1 wget -T 15 -O "$file_name.$file_ext" "$url" --no-check-certificate if test $? -ne 0 ; then @@ -50,8 +50,8 @@ if test $? -ne 0 ; then exit 4 fi -JSON="`wget -qO- https://api.portalmec.c3sl.ufpr.br/v1/learning_objects/$file_id`" -echo $JSON > ".$file_id.json" +JSON="$(wget -qO- https://api.portalmec.c3sl.ufpr.br/v1/learning_objects/"$file_id")" +echo "$JSON" > ".$file_id.json" #UPDATE .learning_objects.json -gdbus call --system --dest br.ufpr.c3sl.edubar --object-path /br/ufpr/c3sl/edubar --method br.ufpr.c3sl.edubar.Download.UpdateJSON "$file_id" \ No newline at end of file +gdbus call --system --dest br.ufpr.c3sl.edubar --object-path /br/ufpr/c3sl/edubar --method br.ufpr.c3sl.edubar.Download.UpdateJSON "$file_id" diff --git a/package/le-edubar@c3sl.ufpr.br/edubus.js b/package/le-edubar@c3sl.ufpr.br/edubus.js index a2eb9e2c9d6a9ab159d501484f4e8f36402e08ff..86b8d8581414788d9ed351272f5dbaf8a3cad98a 100644 --- a/package/le-edubar@c3sl.ufpr.br/edubus.js +++ b/package/le-edubar@c3sl.ufpr.br/edubus.js @@ -22,16 +22,16 @@ const Gio = imports.gi.Gio; -const download_interface = '<node>\ - <interface name="br.ufpr.c3sl.edubar.Download">\ - <method name="Start">\ - <arg type="s" direction="in"/>\ - <arg type="s" direction="in"/>\ - <arg type="s" direction="in"/>\ - <arg type="b" direction="out" />\ - </method>\ - </interface>\ -</node>'; +const download_interface = '<node>'+ +' <interface name="br.ufpr.c3sl.edubar.Download">'+ +' <method name="Start">'+ +' <arg type="s" direction="in"/>'+ +' <arg type="s" direction="in"/>'+ +' <arg type="s" direction="in"/>'+ +' <arg type="b" direction="out" />'+ +' </method>'+ +' </interface>'+ +'</node>'; var iface_download = Gio.DBusProxy.makeProxyWrapper(download_interface); var download = iface_download(Gio.DBus.system,"br.ufpr.c3sl.edubar","/br/ufpr/c3sl/edubar"); @@ -40,27 +40,27 @@ var download = iface_download(Gio.DBus.system,"br.ufpr.c3sl.edubar","/br/ufpr/c3 * DBUS functions returns an Array. That's why you must use Method()[0] * to get the first output sometimes. */ -const file_interface = '<node>\ - <interface name="br.ufpr.c3sl.edubar.File">\ - <method name="Exists">\ - <arg type="s" direction="in"/>\ - <arg type="b" direction="out" />\ - </method>\ - <method name="Size">\ - <arg type="s" direction="in"/>\ - <arg type="d" direction="out" />\ - </method>\ - <method name="GetLocalFiles">\ - <arg type="i" direction="in"/>\ - <arg type="s" direction="in"/>\ - <arg type="s" direction="in"/>\ - <arg type="av" direction="out" />\ - </method>\ - <method name="GetTotalFiles">\ - <arg type="d" direction="out" />\ - </method>\ - </interface>\ -</node>'; +const file_interface = '<node>'+ +' <interface name="br.ufpr.c3sl.edubar.File">'+ +' <method name="Exists">'+ +' <arg type="s" direction="in"/>'+ +' <arg type="b" direction="out" />'+ +' </method>'+ +' <method name="Size">'+ +' <arg type="s" direction="in"/>'+ +' <arg type="d" direction="out" />'+ +' </method>'+ +' <method name="GetLocalFiles">'+ +' <arg type="i" direction="in"/>'+ +' <arg type="s" direction="in"/>'+ +' <arg type="s" direction="in"/>'+ +' <arg type="av" direction="out" />'+ +' </method>'+ +' <method name="GetTotalFiles">'+ +' <arg type="d" direction="out" />'+ +' </method>'+ +' </interface>'+ +'</node>'; var iface_file = Gio.DBusProxy.makeProxyWrapper(file_interface); -var file = iface_file(Gio.DBus.system,"br.ufpr.c3sl.edubar","/br/ufpr/c3sl/edubar"); \ No newline at end of file +var file = iface_file(Gio.DBus.system,"br.ufpr.c3sl.edubar","/br/ufpr/c3sl/edubar"); diff --git a/package/le-edubar@c3sl.ufpr.br/extension.js b/package/le-edubar@c3sl.ufpr.br/extension.js index 0f602a49a3e55887136b91d015b22dd99a0d0919..f1e667961ef1436d1ef342a4d03c4a0934378820 100644 --- a/package/le-edubar@c3sl.ufpr.br/extension.js +++ b/package/le-edubar@c3sl.ufpr.br/extension.js @@ -79,7 +79,7 @@ function check_searching() { /* Create a Soup Session connection*/ function create_soup_session() { - soup_result = new Array(); + soup_result = []; if (soup_session != null) { return; } @@ -197,7 +197,7 @@ function send_soup_request (request_message, searching_text, local_text) { if (message.status_code !== 200) { searching_text.text = 'Sem resposta do servidor.'; - on_going_downloads = new Array(); + on_going_downloads = []; return; } @@ -811,7 +811,7 @@ function create_result(edu_object) { style_class: 'result-title', })); - make_text_justify(result.get_last_child().clutter_text) + make_text_justify(result.get_last_child().clutter_text); result.add_actor(create_info_box(edu_object)); @@ -875,7 +875,7 @@ function create_result(edu_object) { id : edu_object.id.toString(), name : edu_name[0], size : edu_object.attachments[edu_id].size, - } + }; button_group.add_actor(result_button(learning_content)); } @@ -1144,7 +1144,7 @@ var toggle_overview = { Constants.update_result_size(); if (Overview.viewSelector._isActivated()) { - Overview.viewSelector._searchCancelled() + Overview.viewSelector._searchCancelled(); } Main.overview._controls._group.get_last_child().opacity = 0; Overview._dash.actor.hide(); @@ -1188,7 +1188,7 @@ var toggle_overview = { portal_button.remove(); } }, -} +}; /*Portal MEC button*/ var portal_button = { @@ -1225,7 +1225,7 @@ var portal_button = { this.edubutton.hide(); Panel._rightBox.remove_child(this.edubutton); }, -} +}; /*Portal MEC search box * input_edu.entry = Search Box @@ -1316,7 +1316,7 @@ var input_edu = { set_text: function (new_text) { this.entry.text = new_text; } -} +}; /*Extension Main()*/ function init(extensionMeta) { @@ -1324,7 +1324,7 @@ function init(extensionMeta) { meta_path = extensionMeta.path; theme.append_search_path(meta_path + "/icons/portal"); theme.append_search_path(meta_path + "/icons/FlatRemix"); - on_going_downloads = new Array(); + on_going_downloads = []; input_edu.create(); portal_button.create(); } diff --git a/package/le-edubar@c3sl.ufpr.br/prefabs.js b/package/le-edubar@c3sl.ufpr.br/prefabs.js index c109f3727d080c7132c81dfb7760ee5385f56f94..4afbf96aa251bb45a971f140e9f56a37618917dd 100644 --- a/package/le-edubar@c3sl.ufpr.br/prefabs.js +++ b/package/le-edubar@c3sl.ufpr.br/prefabs.js @@ -96,7 +96,7 @@ function FilterTag (name,api_name) { } else { this.next.add_filter(name,api_name); } - } + }; } /*Search Filter is a class of a group of filter choices, like order by*/ @@ -111,6 +111,6 @@ function SearchFilter (title,type){ } else { this.next.add_filter(name,api_name); } - } + }; }