I develop a plugin for deploy app Angular/React/Vue in simple click. So, i trie to verify if the value of the placeholder is set or not to use it or not in my bash script call. Actually i try to redirect my differents "if" in actions. The differents scenarios of my plugins are:
client gives is public git ( so i just use the url )
client gives is public git with a specific folder of build app result ( in angular/vue its often /dist and in react it can be /build)
by default if you dont specify the folder, the default value in my bash is /dist (because its the classic folder)
client gives private git with token
client gives private git with token and a specific folder of build
So in this topic i show you my manifest.jps and the bash script to understand my problem.
I hope you can help me :) ( and sorry for my english i trie to amelior it)
settings:
fields:
- name: gitRepo
caption: Git Repo Url*
type: string
required: true
default: ''
regex: "^https?:\\/\\/.+$"
regexText: Incorrect URL. HTTPS link to Git repository is required.
- name: gitToken
caption: Token
type: string
required: false
default: ''
- name: buildPath
caption: your path for build
type: string
required: false
default: ''
onInstall:
- if ( ${settings.gitToken} && ${settings.buildPath} && ${settings.gitRepo} ): totalScript
- if ( ${settings.gitRepo} && ${settings.gitToken} ): scriptToken
- if ( ${settings.gitRepo} && ${settings.buildPath} ): scriptPath
- if ( ${settings.gitRepo} ): scriptRepo
actions:
totalScript:
cmd [cp]:
- curl -fsS https://raw.githubusercontent.com/user/scripts-sources/master/test-settings.sh | /bin/bash -s ${settings.gitRepo} -t ${settings.gitToken} -p ${settings.buildPath}
scriptToken:
cmd [cp]:
- curl -fsS https://raw.githubusercontent.com/user/scripts-sources/master/test-settings.sh | /bin/bash -s ${settings.gitRepo} -t ${settings.gitToken}
scriptPath:
cmd [cp]:
- curl -fsS https://raw.githubusercontent.com/user/scripts-sources/master/test-settings.sh | /bin/bash -s ${settings.gitRepo} -p ${settings.buildPath}
scriptRepo:
cmd [cp]:
- curl -fsS https://raw.githubusercontent.com/user/scripts-sources/master/test-settings.sh | /bin/bash -s ${settings.gitRepo}
test-settings.sh (this script works, i show it because its the link with my manifest)
#!/bin/bash
link=$1
# Options
#
while getopts "htp" OPTION
do
case $OPTION in
h)
usage
;;
t) token=$OPTARG
;;
p) pathBuild_form=$OPTARG
;;
esac
done
if [[ -z "$token" ]]
then
if [[ $link == *".git"* ]];
then
repo="https://"$(echo $link | cut -d'/' -f4 )@$(echo $link | cut -d'/' -f3)/$(echo $link | cut -d'/' -f4)/$(echo $link | cut -d'/' -f5)
else
repo="https://"$(echo $link | cut -d'/' -f4 )@$(echo $link | cut -d'/' -f3)/$(echo $link | cut -d'/' -f4)/$(echo $link | cut -d'/' -f5).git
fi
else
if [[ $link == *".git"* ]];
then
repo="https://"$(echo $link | cut -d'/' -f4 ):$token@$(echo $link | cut -d'/' -f3)/$(echo $link | cut -d'/' -f4)/$(echo $link | cut -d'/' -f5)
else
repo="https://"$(echo $link | cut -d'/' -f4 ):$token@$(echo $link | cut -d'/' -f3)/$(echo $link | cut -d'/' -f4)/$(echo $link | cut -d'/' -f5).git
fi
fi
git clone $repo
pathBuild=$(echo $link | cut -d'/' -f5 | cut -f1 -d".")
npm install --prefix ./$pathBuild
npm run build --prefix ./$pathBuild
if [[ ! -z "$pathBuild_form" ]]
then
mv $pathBuild/$pathBuild_form/* /home/jacqueax/MyApp
else
var=$(ls $pathBuild/dist)
if [[ $var == *"index"* ]]; then
mv $pathBuild/dist/* /home/jacqueax/MyApp
else
mv dist/$var/* /home/jacqueax/MyApp
fi
fi
rm -rf $pathBuild
So for the moment i see this in log when the client just put the public git :
WARNING: if ( && && https://github.com/user/js-app-forBuild ): invalid condition. Response: {"result":1704,"line":3,"response":null,"source":"hx-core","error":"org.mozilla.javascript.EvaluatorException: syntax error"}
---> this line correspond of my first "if"; others log are similary
I just want to verify if the placeholder is set or not.Actually the values of placeholder is used and its not that i want ( because if the token for example is not put in settings the "if" where there are token var will be empty and "if" failed.