This is an automated email from the ASF dual-hosted git repository. linkinstar pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git
commit e8c6a5ae92e3bdf250760a488552273af1e8b891 Author: robin <[email protected]> AuthorDate: Mon Jul 15 15:13:52 2024 +0800 refactor: Update sync-info.yaml and sync-info.sh scripts --- .github/workflows/sync-info.yml | 2 + plugins_desc.json | 212 +++++++++++++++++++++++++++++++++++++--- script/sync-info.sh | 46 ++++++++- 3 files changed, 242 insertions(+), 18 deletions(-) diff --git a/.github/workflows/sync-info.yml b/.github/workflows/sync-info.yml index 8184889..3c50f6e 100644 --- a/.github/workflows/sync-info.yml +++ b/.github/workflows/sync-info.yml @@ -31,6 +31,8 @@ jobs: - name: Install jq run: sudo apt-get install jq + - name: Install yq + run: sudo apt-get install yq - name: Run script run: script/sync-info.sh diff --git a/plugins_desc.json b/plugins_desc.json index 91e5bd2..0eaf02b 100644 --- a/plugins_desc.json +++ b/plugins_desc.json @@ -1,16 +1,196 @@ -[ - {"name": "Redis Cache", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/cache-redis", "desc": "Experience reliable performance with Redis in-memory caching."}, - {"name": "OAuth 2.0", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/connector-basic", "desc": "Connect Answer with various service providers."}, - {"name": "GitHub Login", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/connector-github", "desc": "Sign up or log in with your existing GitHub account."}, - {"name": "Google Login", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/connector-google", "desc": "Access Answer with your trusted Google account."}, - {"name": "DingTalk Login", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/connector-dingtalk", "desc": "Sign in or create an account using DingTalk credentials."}, - {"name": "Elasticsearch", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/search-elasticsearch", "desc": "Power up Answer with fast and accurate search."}, - {"name": "Meilisearch", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/search-meilisearch", "desc": "Supercharge your search with Meilisearch in Answer."}, - {"name": "Algolia Search", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/search-algolia", "desc": "Elevate the search with Algolia's power."}, - {"name": "Alibaba Cloud OSS", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/storage-aliyunoss", "desc": "Enjoy reliable, scalable cloud storage for files."}, - {"name": "Amazon S3 Storage", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/storage-s3", "desc": "Store and manage your data securely with Amazon S3."}, - {"name": "Chart Editor", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/editor-chart", "desc": "Visualize the data with the charts directly in the markdown editor."}, - {"name": "Formula Editor", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/editor-formula", "desc": "Add equations and mathematical expressions to markedown content."}, - {"name": "WeCom Login", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/user-center-wecom", "desc": "Scan and login with WeCom seamlessly. "}, - {"name": "Get Notified on Slack", "link": "https://github.com/apache/incubator-answer-plugins/tree/main/notification-slack", "desc": "Streamline team communication with instant notification."} -] \ No newline at end of file +{ + "zh_CN": [ + { + "name": "Google 连接器", + "desc": "用于接入 Google 第三方登录", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/connector-google" + }, + { + "name": "阿里云OSS存储", + "desc": "上传文件到阿里云OSS存储", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/storage-aliyunoss" + }, + { + "name": "Slack 通知", + "desc": "发送通知到 Slack", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/notification-slack" + }, + { + "name": "内容嵌入", + "desc": "在内容中嵌入其他网站", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/embed-basic" + }, + { + "name": "基础验证码", + "desc": "默认图形验证码", + "link": "https://github.com/apache/incubator-answer-plugins/tree/main/captcha-basic" + }, + { + "name": "MeiliSearch", + "desc": "MeiliSearch 是一个强大、快速、开源、易于使用和部署的搜索引擎。", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/search-meilisearch" + }, + { + "name": "Akismet Anti-Spam", + "desc": "Akismet Anti-Spam is used to check the content of posts and comments against the Akismet web service to see if they look like spam.", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/reviewer-akismet" + }, + { + "name": "通用连接器", + "desc": "适用于各种 OAuth 登录的通用插件", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/connector-basic" + }, + { + "name": "Elasticsearch 引擎", + "desc": "使用 Elasticsearch 作为搜索引擎", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/search-elasticsearch" + }, + { + "name": "Apache 连接器", + "desc": "用于接入 Apache Oauth", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/connector-apache" + }, + { + "name": "Google reCAPTCHA v2", + "desc": "Google reCAPTCHA v2 插件", + "link": "https://github.com/apache/incubator-answer-plugins/tree/main/captcha-google-v2" + }, + { + "name": "Redis缓存", + "desc": "使用Redis作为缓存", + "link": "https://github.com/apache/incubator-answer-plugins/tree/main/cache-redis" + }, + { + "name": "图表编辑器", + "desc": "在编辑器中渲染图表", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/editor-chart" + }, + { + "name": "钉钉连接器", + "desc": "用于接入钉钉第三方登录", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/connector-dingtalk" + }, + { + "name": "公式编辑器", + "desc": "在编辑器中渲染公式", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/editor-formula" + }, + { + "name": "GitHub 连接器", + "desc": "用于接入 GitHub 第三方登录", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/connector-github" + }, + { + "name": "S3 存储", + "desc": "上传文件到S3存储", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/storage-s3" + }, + { + "name": "基础审核插件", + "desc": "基础的通用审核插件", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/reviewer-basic" + }, + { + "name": "企业微信", + "desc": "从企业微信获取用户信息并同步到用户中心", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/user-center-wecom" + } + ], + "en_US": [ + { + "name": "Google Connector", + "desc": "Connect to Google for third-party login", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/connector-google" + }, + { + "name": "Aliyun OSS storage", + "desc": "Upload files to AliCloud OSS storage", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/storage-aliyunoss" + }, + { + "name": "Slack Notification", + "desc": "Send notifications to Slack", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/notification-slack" + }, + { + "name": "Embed", + "desc": "Embed content from other sites", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/embed-basic" + }, + { + "name": "Basic Captcha", + "desc": "Default graphic verification code", + "link": "https://github.com/apache/incubator-answer-plugins/tree/main/captcha-basic" + }, + { + "name": "MeiliSearch", + "desc": "MeiliSearch is a powerful, fast, open-source, easy to use and deploy search engine.", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/search-meilisearch" + }, + { + "name": "Akismet Anti-Spam", + "desc": "Akismet Anti-Spam is used to check the content of posts and comments against the Akismet web service to see if they look like spam.", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/reviewer-akismet" + }, + { + "name": "OAuth2 Basic", + "desc": "Generic OAuth2 Plugin", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/connector-basic" + }, + { + "name": "Elasticsearch Engine", + "desc": "Use Elasticsearch as search engine", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/search-elasticsearch" + }, + { + "name": "Apache Connector", + "desc": "Connect to Apache Oauth", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/connector-apache" + }, + { + "name": "Google reCAPTCHA v2", + "desc": "Google reCAPTCHA v2 plugin", + "link": "https://github.com/apache/incubator-answer-plugins/tree/main/captcha-google-v2" + }, + { + "name": "Redis Cache", + "desc": "Use Redis as cache", + "link": "https://github.com/apache/incubator-answer-plugins/tree/main/cache-redis" + }, + { + "name": "Chart Editor", + "desc": "Render chart in editor", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/editor-chart" + }, + { + "name": "Dingtalk Connector", + "desc": "Connect to Dingtalk for third-party login", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/connector-dingtalk" + }, + { + "name": "Formula Editor", + "desc": "Render formula in editor", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/editor-formula" + }, + { + "name": "GitHub Connector", + "desc": "Connect to GitHub for third-party login", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/connector-github" + }, + { + "name": "S3 storage", + "desc": "Upload files to S3 storage", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/storage-s3" + }, + { + "name": "Review Basic", + "desc": "Generic review rule plugin", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/reviewer-basic" + }, + { + "name": "WeCom", + "desc": "Get user info from WeCom and sync to User Center", + "link": "https://apache.com/apache/incubator-answer-plugins/tree/main/user-center-wecom" + } + ] +} diff --git a/script/sync-info.sh b/script/sync-info.sh index 09d38d3..48cb109 100755 --- a/script/sync-info.sh +++ b/script/sync-info.sh @@ -16,7 +16,6 @@ # specific language governing permissions and limitations # under the License. - project_root="." for dir in $(find "$project_root" -type d); do @@ -28,8 +27,51 @@ for dir in $(find "$project_root" -type d); do version=$(awk '/version:/{print $2}' "$dir/info.yaml") if [ -f "$dir/package.json" ]; then - jq --arg version "$version" '.version = $version' "$dir/package.json" > "$dir/package.json.tmp" + jq --arg version "$version" '.version = $version' "$dir/package.json" >"$dir/package.json.tmp" mv "$dir/package.json.tmp" "$dir/package.json" fi fi done + +echo "{}" >"$project_root/plugins_desc.json" + +for dir in $(find "$project_root" -type d); do + if [[ "$dir" == *node_modules* ]] || [[ "$dir" == *.git* ]] || [[ "$dir" == *.vscode* ]]; then + continue + fi + + slug_name="" + link="" + if [ -f "$dir/info.yaml" ]; then + slug_name=$(yq '.slug_name' "$dir/info.yaml") + link=$(yq '.link' "$dir/info.yaml") + fi + + if [ -d "$dir/i18n" ]; then + for file in $(find "$dir/i18n" -type f -name "*.yaml"); do + if [ -f "$file" ]; then + file_name=$(basename "$file") + file_name=${file_name%.*} + + if [ -f "$file" ]; then + name=$(yq ".plugin.${slug_name}.backend.info.name.other" "$file") + description=$(yq ".plugin.${slug_name}.backend.info.description.other" "$file") + + if [ "$name" == "null" ] || [ "$description" == "null" ]; then + continue + fi + + if [ -f "$project_root/plugins_desc.json" ]; then + if [ "$(jq ".$file_name" "$project_root/plugins_desc.json")" != "null" ]; then + jq ".$file_name += [{\"name\": \"$name\", \"desc\": \"$description\", \"link\": \"$link\"}]" "$project_root/plugins_desc.json" >"$project_root/plugins_desc.json.tmp" + mv "$project_root/plugins_desc.json.tmp" "$project_root/plugins_desc.json" + else + jq ".$file_name = [{\"name\": \"$name\", \"desc\": \"$description\", \"link\": \"$link\"}]" "$project_root/plugins_desc.json" >"$project_root/plugins_desc.json.tmp" + mv "$project_root/plugins_desc.json.tmp" "$project_root/plugins_desc.json" + fi + fi + fi + fi + done + fi +done
