diff --git a/frontend/scripts/card_builder_static_build.sh b/frontend/scripts/card_builder_static_build.sh deleted file mode 100644 index 6d15487c..00000000 --- a/frontend/scripts/card_builder_static_build.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -# Switch cwd to the project folder -cd $(dirname "$0") - -# Import the utilities functions -source ./scm_base.sh - -# Clean up the build directory -rm -rf dist output output_resource ${ROOT}/output ${ROOT}/output_resource - -# Prepare -prepare_environment - -# Install the dependencies -install_package_deps @flowpd/card-lynx-runtime - -SKIP_POST_INSTALL=true rush build -t @flowpd/card-lynx-runtime - -# Create artifact -OUTPUT_DIR="${ROOT_DIR}/output" -OUTPUT_RESOURCE_DIR="${ROOT_DIR}/output_resource" - -# copy lynx runtime sdk -cp -r "${ROOT_DIR}"/packages/lynx-runtime-sdk/dist "${OUTPUT_DIR}"/lynx_sdk/"${CUSTOM_LYNX_VERSION}" -cp -r "${ROOT_DIR}"/packages/lynx-runtime-sdk/dist "${OUTPUT_RESOURCE_DIR}"/lynx_sdk/"${CUSTOM_LYNX_VERSION}" - -# if [[ $CUSTOM_VERSION = 'release' ]]; then -# TARGETS=("sg" "va") -# SOURCES=("sg_release" "va_release") -# else -# TARGETS=("boe" "cn" "sg") -# SOURCES=("cn_boe" "cn_inhouse" "sg_inhouse") -# fi - - -# # Loop through targets and sources -# for ((i=0; i<${#TARGETS[@]}; i++)); do -# # Create output directories -# mkdir -p "${OUTPUT_DIR}/${TARGETS[i]}" -# mkdir -p "${OUTPUT_RESOURCE_DIR}/${TARGETS[i]}" - -# # Copy index.html -# cp "./output/${SOURCES[i]}/"*.html "${OUTPUT_DIR}/${TARGETS[i]}" - -# # Copy static files -# cp -r "./output/${SOURCES[i]}/"* "${OUTPUT_RESOURCE_DIR}/${TARGETS[i]}" -# done diff --git a/frontend/scripts/del-branch.sh b/frontend/scripts/del-branch.sh deleted file mode 100644 index 48a98850..00000000 --- a/frontend/scripts/del-branch.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -git fetch - -# List of complete names of the remote branch to delete, including the origin prefix -declare -a branches_to_delete_full=( - origin/feat/analysis-tyy - origin/feat/query_classify -) - -# The name of the remote repository, default is origin -remote_name="origin" - -# Function to delete a remote branch -delete_branch() { - local branch_name_with_origin=$1 - # Remove the origin prefix - local branch_name=$(echo "$branch_name_with_origin" | sed 's/^'"$remote_name"'\///') - - if git show-ref --verify --quiet "refs/remotes/$branch_name_with_origin"; then - echo "正在删除远程分支: $branch_name" - git push "$remote_name" --delete "$branch_name" --no-verify - if [ $? -eq 0 ]; then - echo "远程分支 $branch_name 已被删除。" - else - echo "删除远程分支 $branch_name 失败,请检查分支名称或权限。" - fi - else - echo "分支 $branch_name 不存在,无需删除。" - fi -} - -# Traverse the branch list and call the delete function -for full_branch_name in "${branches_to_delete_full[@]}"; do - delete_branch "$full_branch_name" -done - -echo "批量删除操作完成。" diff --git a/frontend/scripts/find-empty-files.sh b/frontend/scripts/find-empty-files.sh deleted file mode 100644 index 62b8821b..00000000 --- a/frontend/scripts/find-empty-files.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Directory to search -SEARCH_DIR=${1:-.} # The default directory is the current directory - -# Check input parameters -if [ -z "$SEARCH_DIR" ]; then - echo "Usage: $0 " - exit 1 -fi - -# Get all .tsx and .less files tracked by Git -git ls-files --others --ignored --exclude-standard -o -c -- "$SEARCH_DIR" ':!*.tsx' ':!*.less' | while read -r FILE; do - if [[ "$FILE" == *.tsx || "$FILE" == *.less ]]; then - # Get the number of file lines - LINE_COUNT=$(wc -l < "$FILE") - # If the file line count is empty, delete the file and output the file path - if [ "$LINE_COUNT" -eq 0 ]; then - echo "Deleting empty file: $FILE" - rm "$FILE" - fi - fi -done diff --git a/frontend/scripts/pre-push-hook.sh b/frontend/scripts/pre-push-hook.sh index ae59f6e5..a6d564d8 100644 --- a/frontend/scripts/pre-push-hook.sh +++ b/frontend/scripts/pre-push-hook.sh @@ -1,4 +1,20 @@ #!/bin/bash +# +# Copyright 2025 coze-dev Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Set the red ANSI escape code RED='\033[0;31m' @@ -13,8 +29,8 @@ CURRENT_ORIGIN_BRANCH=$(git rev-parse --abbrev-ref @{u}) # block_unresolved_conflict "$CURRENT_BRANCH..$CURRENT_ORIGIN_BRANCH" # fi -if [ "$CURRENT_BRANCH" = "master" ] && [ "$CURRENT_USER" != "ci_flow@bytedance.com" ]; then - echo "${RED}Do not push to master branch manually!!!${NC}" +if [ "$CURRENT_BRANCH" = "main" ] && [ "$CURRENT_USER" != "ci_flow@bytedance.com" ]; then + echo "${RED}Do not push to main branch manually!!!${NC}" exit 1 fi diff --git a/frontend/scripts/publish-pro.sh b/frontend/scripts/publish-pro.sh deleted file mode 100644 index d5289809..00000000 --- a/frontend/scripts/publish-pro.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env bash -# The script is used to execute the package publishing logic within the SCM - -source ./scripts/scm_base.sh - -# Prepare -prepare_environment - -# ignore install -export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=true -export CYPRESS_INSTALL_BINARY=0 -export TAIKO_SKIP_CHROMIUM_DOWNLOAD=0 -export RE2_DOWNLOAD_SKIP_PATH=1 -export RE2_DOWNLOAD_MIRROR=​https://bnpm.bytedance.net/mirrors - -# custom_env -export NPM_AUTH_TOKEN=$CUSTOM_NPM_AUTH_TOKEN -export GITLAB_TOKEN=$CUSTOM_GITLAB_TOKEN -export CODEBASE_JWT=$CUSTOM_CODEBASE_JWT -export COZE_HUB_APP_ID=$CUSTOM_COZE_HUB_APP_ID -export COZE_HUB_KEY_ID=$CUSTOM_COZE_HUB_KEY_ID -export COZE_HUB_PRIVATE_KEY=$CUSTOM_COZE_HUB_PRIVATE_KEY - -export DEBUG=$CUSTOM_DEBUG -# resolve 400 error https://bytedance.feishu.cn/wiki/wikcnOUP2D6rGipIaN8q7UdzO0e -export CI_NAME=allow_same_version_$BUILD_VERSION -export DEFAULT_BRANCH=$BUILD_REPO_BRANCH -export WEBHOOK_URL=$CUSTOM_WEBHOOK_URL -# publish type example: beta or alpha -PUBLISH_TYPE=$CUSTOM_PUBLISH_TYPE -# use for npm tag -PUBLISH_TAG=$CUSTOM_PUBLISH_TAG -# only beta use for now -PATCH_TAG=$CUSTOM_PATCH_TAG -BY_DIFF=$CUSTOM_BY_DIFF - -# to packages -TO_PACKAGES=$CUSTOM_TO_PACKAGES -# from tag -FROM_TAG=$CUSTOM_FROM_TAG -# independent -INDEPENDENT=$CUSTOM_INDEPENDENT - -# scm env -BUILD_USER=$BUILD_USER -# version or publiish or tag -MODE=$CUSTOM_MODE -# publish sha -PUBLISH_SHA=$CUSTOM_PUBLISH_SHA -# just list and detch not version -LIST_ONLY=$CUSTOM_LIST_ONLY - -initialization() { - # npm - npm config set registry https://bnpm.byted.org - npm config set //bnpm.byted.org/:_authToken $NPM_AUTH_TOKEN - npm whoami - - # git - git config user.name ci_flow - git config user.email ci_flow@bytedance.com - git remote set-url origin https://bot-studio-monorepo:$GITLAB_TOKEN@code.byted.org/obric/bot-studio-monorepo.git -} - -fetch() { - git fetch --filter=blob:none --unshallow -q -} - -initialization - -echo "to packages" -echo $TO_PACKAGES - -echo "from tag" -echo $FROM_TAG - -if [ -n "${PUBLISH_TAG}" ]; then - PUBLISH_TAG="--tag ${PUBLISH_TAG}" -fi - -if [ -n "${PUBLISH_TYPE}" ]; then - PUBLISH_TYPE="--pre ${PUBLISH_TYPE}" -fi - -if [ -n "${WEBHOOK_URL}" ]; then - WEBHOOK_URL="-w ${WEBHOOK_URL}" -fi - -if [ -n "${BUILD_USER}" ]; then - BUILD_USER="-a ${BUILD_USER}" -fi - -echo "安装依赖" -node infra/rush-increment-install/lib/index.js -node common/scripts/install-run-rush.js build -t @coze/cli -v - -if [ "$MODE" == "version" -o "$MODE" == "multiple" ]; then - echo "获取仓库 tags 列表" - fetch - - echo "计算版本更新列表" - # Copy output to root dir - mkdir -p $ROOT_DIR/output - OUTPUT_COMMAND="node ee/infra/rush-x/bin/run version --list $PUBLISH_TYPE $PUBLISH_TAG $PATCH_TAG $TO_PACKAGES $FROM_TAG $BY_DIFF $INDEPENDENT -b $DEFAULT_BRANCH" - $OUTPUT_COMMAND >>$ROOT_DIR/output/output.txt - - if [ "$LIST_ONLY" != "true" ]; then - - echo "版本更新列表写入 output.txt" - - echo "执行 version" - if [ "$MODE" == "multiple" ]; then - # In multiple mode, only the result of the publish step can be output - node ee/infra/rush-x/bin/run version $PUBLISH_TYPE $PUBLISH_TAG $PATCH_TAG $TO_PACKAGES $FROM_TAG $BY_DIFF $INDEPENDENT -b $DEFAULT_BRANCH - else - node ee/infra/rush-x/bin/run version $PUBLISH_TYPE $PUBLISH_TAG $PATCH_TAG $TO_PACKAGES $FROM_TAG $BY_DIFF $INDEPENDENT $WEBHOOK_URL $BUILD_USER -b $DEFAULT_BRANCH - fi - echo "version 完成" - fi -fi - -if [ "$MODE" == "multiple" ]; then - PUBLISH_SHA=$(git rev-parse HEAD) -fi - -if [ "$MODE" == "publish" -o "$MODE" == "multiple" ]; then - mkdir -p $ROOT_DIR/output - echo "Publish sha $PUBLISH_SHA" - echo "Publish sha $PUBLISH_SHA" >>$ROOT_DIR/output/output.txt - - echo "执行 publish" - node ee/infra/rush-x/bin/run publish --sha $PUBLISH_SHA $PUBLISH_TAG $WEBHOOK_URL $BUILD_USER - echo "publish 完成" -fi - -# Update distTag -if [ "$MODE" == "tag" ]; then - fetch - mkdir -p $ROOT_DIR/output - echo "Publish sha $PUBLISH_SHA" - echo "Publish sha $PUBLISH_SHA" >>$ROOT_DIR/output/output.txt - - echo "执行 dist tag" - # The point WEBHOOK_URL are basically different in different modes, and you need to pay attention when passing parameters again - node ee/infra/rush-x/bin/run publish --sha $PUBLISH_SHA $PUBLISH_TAG --dist-tag $WEBHOOK_URL $BUILD_USER - echo "dist-tag 完成" -fi diff --git a/frontend/scripts/scan-outdate-branch.sh b/frontend/scripts/scan-outdate-branch.sh deleted file mode 100644 index 972d5b5d..00000000 --- a/frontend/scripts/scan-outdate-branch.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -# Define the cut-off date, 3 months from now -cutoff=$(date -v-2m +%s) -branches_to_delete=() -outdated_branches_with_change=() - -echo "| 分支名 | commits 数量 | 作者 | 最后更新时间 | log |" -echo "| ----- | ----- | ----- | ----- | ----- |" - -# Get all remote branches - -for branch in $(git for-each-ref refs/remotes/origin --format '%(refname:short)'); do - # Skip branches with 'release/' in their name - if [[ $branch == *'release/'* ]]; then - continue - fi - - # Get the date of the last commit on the branch - last_commit=$(git log -1 --pretty=format:%ct $branch) - - # If the last commit is older than the cutoff date, delete the branch - if [ $last_commit -lt $cutoff ]; then - # Check if there are commits that are not merged into master - if [ "$(git log origin/master..$branch)" != "" ]; then - commits=$(git log --pretty=format:'%an' origin/master..$branch) - echo "| $branch | $(echo "$commits" | wc -l) | $(echo "$(git show -s --format="%an | %ci | %s" origin/master..$branch )" | head -n 1) |" - outdated_branches_with_change+=("$branch") - else - branches_to_delete+=("$branch") - fi - fi -done - -echo "these branches should be deleted:\n" - -for branch in "${branches_to_delete[@]}" -do - echo "Deleting $branch" - git push origin --delete ${branch#origin/} --no-verify -done - -echo "----------------------------------------------" - -# echo "these branches outdated but with not commit changes:\n" - -# for branch in "${outdated_branches_with_change[@]}" -# do -# echo "$branch" -# done - diff --git a/frontend/scripts/setup-env.sh b/frontend/scripts/setup-env.sh index 7a7d09d8..b57df4ae 100644 --- a/frontend/scripts/setup-env.sh +++ b/frontend/scripts/setup-env.sh @@ -1,4 +1,20 @@ #!/usr/bin/env bash +# +# Copyright 2025 coze-dev Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # Setup common env for CI & SCM # 1. Ignore installs that do not affect builds @@ -6,7 +22,6 @@ export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=true export CYPRESS_INSTALL_BINARY=0 export TAIKO_SKIP_CHROMIUM_DOWNLOAD=0 export RE2_DOWNLOAD_SKIP_PATH=1 -export RE2_DOWNLOAD_MIRROR="​https://bnpm.bytedance.net/mirrors" # 2. Effective in the CI environment: echo ::set-env name=PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD::$PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD diff --git a/frontend/scripts/subdir-cloc.sh b/frontend/scripts/subdir-cloc.sh deleted file mode 100644 index be56fc2b..00000000 --- a/frontend/scripts/subdir-cloc.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -# usage: -# cd $path/to/monorepo -# sh scripts/subdir-cloc.sh $relative_path/to/some/dir -# -# example: sh scripts/subdir-cloc.sh apps/bot/src/routes - -if [ "$#" -ne 1 ]; then - echo "Usage: $0 directory" - exit 1 -fi - -directory=$1 - -#First create or empty an existing result file -echo "Directory, files,language,blank,comment,code" > cloc_results2.csv - -#Use the find command to find all subdirectories in the foo directory -#If you only want to iterate through direct subdirectories, you can remove the -maxdepth and -mindepth options -find $directory -type d -mindepth 1 -maxdepth 1 | while read subdir -do - #Use the cloc tool to calculate the number of lines of code per subdirectory - #Then use the awk tool to extract the required data: directory name, number of files, and number of lines of code - cloc_result=$(cloc $subdir --csv --quiet | tail -n 1) - lines=$(echo "$cloc_result" | awk -F "\"*,\"*" 'NR==3 {print $4}') - echo "$subdir, $cloc_result" >> cloc_results2.csv -done