From 3d96b9b5f44f48ad5776d324d6d2f36a15fac0f7 Mon Sep 17 00:00:00 2001 From: weyu <985695055@qq.com> Date: Mon, 31 Mar 2025 14:38:15 +0800 Subject: [PATCH] fix openfeature --- libs/common.sh | 120 +++++++++++++++++++-------------------- webs/openfeature/toto.sh | 7 ++- 2 files changed, 65 insertions(+), 62 deletions(-) diff --git a/libs/common.sh b/libs/common.sh index 7d48131..d99d5cb 100644 --- a/libs/common.sh +++ b/libs/common.sh @@ -109,75 +109,75 @@ install_hugo_v145(){ } -# install_postcss(){ -# log_info "=============================================> 安装 postCSS" -# npm i -D postcss postcss-cli autoprefixer -# } +install_postcss(){ + log_info "=============================================> 安装 postCSS" + npm i -D postcss postcss-cli autoprefixer +} -# check_cdn_change(){ -# log_info "=============================================> 以下文件进行了 cdn 替换,请确认文件在 https://cdn.cncfstack.com 是否存在" -# grep "cdn.cncfstack.com" ./* -R |grep -v "otocn\.sed"|awk -F':' '{print $1}' -# } +check_cdn_change(){ + log_info "=============================================> 以下文件进行了 cdn 替换,请确认文件在 https://cdn.cncfstack.com 是否存在" + grep "cdn.cncfstack.com" ./* -R |grep -v "otocn\.sed"|awk -F':' '{print $1}' +} -# check_not_change(){ -# log_info "=============================================> 以下可能的外部文件未被处理" -# # 有些图标表情使用 CDN 的 SVG,这类也可以代理。TODO:有些svg中会包含地址,这类是不需要处理的,但是会grep出来。不移除会有大量的无效信息,还是不显示svg内容,根据实际情况单独处理 -# # raw.githubusercontent.com 是 github 的内容,太多输出了,有依赖单独处理吧 -# grep -iEo "(maxcdn.bootstrapcdn.com|code.jquery.com|cdnjs.cloudflare.com|cdn-images.mailchimp.com|cdn.jsdelivr.net|fonts.googleapis.com|unpkg.com|www.googletagmanager.com)" ./* -R |grep -vE "(\.sh\:|\.md\:|\.toml|index\.rss\.xml|README\.txt\:|otocn\.sed\:|\.svg\:|node_modules)" -# } +check_not_change(){ + log_info "=============================================> 以下可能的外部文件未被处理" + # 有些图标表情使用 CDN 的 SVG,这类也可以代理。TODO:有些svg中会包含地址,这类是不需要处理的,但是会grep出来。不移除会有大量的无效信息,还是不显示svg内容,根据实际情况单独处理 + # raw.githubusercontent.com 是 github 的内容,太多输出了,有依赖单独处理吧 + grep -iEo "(maxcdn.bootstrapcdn.com|code.jquery.com|cdnjs.cloudflare.com|cdn-images.mailchimp.com|cdn.jsdelivr.net|fonts.googleapis.com|unpkg.com|www.googletagmanager.com)" ./* -R |grep -vE "(\.sh\:|\.md\:|\.toml|index\.rss\.xml|README\.txt\:|otocn\.sed\:|\.svg\:|node_modules)" +} -# find_and_sed(){ -# # 查找可能存在外部地址的文件, -# # 对于其他文件即使包含外部地址也不需要处理,比如 svg 图片中的google字体地址 -# find . -type f \( -iname "*.txt" \ -# -o -iname "*.md" \ -# -o -iname "*.toml" \ -# -o -iname "*.js" \ -# -o -iname "*.mjs" \ -# -o -iname "*.html" \ -# -o -iname "*.css" \ -# -o -iname "*.sass" \ -# -o -iname "*.scss" \ -# -o -iname "*.tpl" \ -# -o -iname "*.rst" \) > ${workdir}/filelist +find_and_sed(){ + # 查找可能存在外部地址的文件, + # 对于其他文件即使包含外部地址也不需要处理,比如 svg 图片中的google字体地址 + find . -type f \( -iname "*.txt" \ + -o -iname "*.md" \ + -o -iname "*.toml" \ + -o -iname "*.js" \ + -o -iname "*.mjs" \ + -o -iname "*.html" \ + -o -iname "*.css" \ + -o -iname "*.sass" \ + -o -iname "*.scss" \ + -o -iname "*.tpl" \ + -o -iname "*.rst" \) > ${workdir}/filelist -# # 循环依次处理可能包含外部链接的文件,并进行替换 -# for file in `cat ${workdir}/filelist` -# do -# sudo sed -i -f ${initdir}/toto.sed $file -# done + # 循环依次处理可能包含外部链接的文件,并进行替换 + for file in `cat ${workdir}/filelist` + do + sudo sed -i -f ${initdir}/toto.sed $file + done -# check_cdn_change -# check_not_change -# } + check_cdn_change + check_not_change +} -# # 可以指定处理的路径,这在构建完成后再进行替换时很有用 -# find_and_sed_v2(){ -# path=$1 -# # 查找可能存在外部地址的文件, -# # 对于其他文件即使包含外部地址也不需要处理,比如 svg 图片中的google字体地址 -# find $path -type f -iname "*.txt" \ -# -o -iname "*.md" \ -# -o -iname "*.toml" \ -# -o -iname "*.js" \ -# -o -iname "*.mjs" \ -# -o -iname "*.html" \ -# -o -iname "*.css" \ -# -o -iname "*.sass" \ -# -o -iname "*.scss" \ -# -o -iname "*.tpl" \ -# -o -iname "*.rst" > ${workdir}/filelist +# 可以指定处理的路径,这在构建完成后再进行替换时很有用 +find_and_sed_v2(){ + path=$1 + # 查找可能存在外部地址的文件, + # 对于其他文件即使包含外部地址也不需要处理,比如 svg 图片中的google字体地址 + find $path -type f -iname "*.txt" \ + -o -iname "*.md" \ + -o -iname "*.toml" \ + -o -iname "*.js" \ + -o -iname "*.mjs" \ + -o -iname "*.html" \ + -o -iname "*.css" \ + -o -iname "*.sass" \ + -o -iname "*.scss" \ + -o -iname "*.tpl" \ + -o -iname "*.rst" > ${workdir}/filelist -# # 循环依次处理可能包含外部链接的文件,并进行替换 -# for file in `cat ${workdir}/filelist` -# do -# sudo sed -i -f ${initdir}/toto.sed $file -# done + # 循环依次处理可能包含外部链接的文件,并进行替换 + for file in `cat ${workdir}/filelist` + do + sudo sed -i -f ${initdir}/toto.sed $file + done -# check_cdn_change -# #check_not_change -# } \ No newline at end of file + check_cdn_change + #check_not_change +} \ No newline at end of file diff --git a/webs/openfeature/toto.sh b/webs/openfeature/toto.sh index 7a05238..19557c9 100644 --- a/webs/openfeature/toto.sh +++ b/webs/openfeature/toto.sh @@ -8,9 +8,10 @@ source ${initdir}/libs/common.sh before_openfeature(){ + git submodule update --init --recursive yarn install - log_info "=============================================> 配置文件 docusaurus.config.js 添加 umami" + log_info "=============================================> 配置文件 docusaurus.config.ts 添加 umami" #sed -ri "s|themeConfig:\s*\{|plugins: [()=>({name:'umami-analytics',injectHtmlTags:()=>({headTags:[{tagName:'script',attributes:{defer:true,src:'https://umami.cncfstack.com/script.js','data-website-id':'e560133a-5a27-40ad-b816-9896199ffb01'}}]})})],themeConfig: {|g" docusaurus.config.js sed -ri "s|plugins:\s*\[|plugins: [()=>({name:'umami-analytics',injectHtmlTags:()=>({headTags:[{tagName:'script',attributes:{defer:true,src:'https://umami.cncfstack.com/script.js','data-website-id':'2ef83157-07a7-4bff-a911-e05f83e8663b'}}]})}),|g" docusaurus.config.ts @@ -27,6 +28,8 @@ after_openfeature(){ log_info "=============================================> 开始 npm run build 构建" yarn run build + + log_info "=============================================> 当前目录中文件列表" ls -lh @@ -40,7 +43,7 @@ save_return(){ cd $workdir if cat .git/config |grep '/open-feature/openfeature.dev.git' ;then - log_info "=============================================> 匹配到 chaos-mesh" + log_info "=============================================> 匹配到 open-feature" before_openfeature find_and_sed_v2 "./build" after_openfeature