我想验证我的设置(manifest.jps)的占位符是否被设置为在我的bash(manifest中调用的bash)中使用



我为Angular/React/Vue应用程序开发了一个插件,只需点击即可。因此,我尝试验证占位符的值是否设置为在我的bash脚本调用中使用它。事实上,我试图在行动中重定向我的差异"如果"。我的插件的不同场景是:

  • 客户端给出的是公共git(所以我只使用url(

  • 客户端提供的是带有构建应用程序结果的特定文件夹的公共git(在角度/vue中,它经常/分散,在反应中,它可以/构建(

    默认情况下,如果你没有指定文件夹,我的bash中的默认值是/dist(因为它是经典的文件夹(

  • 客户端提供带有令牌的私有git

  • 客户端提供带有令牌的私有git和构建的特定文件夹

因此,在本主题中,我将向您展示我的manifest.js和bash脚本,以了解我的问题。

我希望你能帮助我:((对我的英语感到抱歉,我试图改善它(

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(这个脚本有效,我展示它是因为它是与我的清单的链接(


#!/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

因此,目前我在日志中看到了这一点,当客户端刚刚放入公共git:时

警告:如果(&&https://github.com/user/js-app-forBuild(:无效条件。响应:{"result":1704,"line":3,"Response":null,"source":"hx core","error":"org.mozilla.javascript.EvaluatorException:语法错误"}

--->这行对应于我的第一个"if";其他日志与相似

我只是想验证占位符是否已设置。实际上占位符的值被使用了,这不是我想要的(因为如果例如令牌没有放在设置中,则有令牌var的"if"将为空,"if"失败

占位符可以替换为默认值或空字符串。所有列出的IF函数可能看起来像:
if ( '${settings.gitToken:}' && '${settings.buildPath:}' && '${settings.gitRepo:}' ): totalScript

if ( settings.gitToken && settings.buildPath && settings.gitRepo ): totalScript

查看我们的文档占位符的默认值

最新更新