Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate out prep-from-local, prep-from-master commands into .sh files #2951

Merged
merged 6 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"clear": "docusaurus clear && bash ./placeholderReset.sh",
"deploy": "docusaurus deploy",
"docusaurus": "docusaurus",
"prep-from-local": "bash -c 'array_root=($npm_package_config_prep_array_root);array_en=($npm_package_config_prep_array_en);for folder in ${array_en[@]}; do cp -r $0/$folder docs/en;echo \"Copied $folder from [$0]\";done;for folder in ${array_root[@]}; do cp -r $0/$folder docs/;echo \"Copied $folder from [$0]\";done;echo \"Prep completed\";'",
"prep-from-master": "bash -c 'array_root=($npm_package_config_prep_array_root);array_en=($npm_package_config_prep_array_en);ch_temp=/tmp/ch_temp_$RANDOM && mkdir -p $ch_temp && git clone --depth 1 --branch master https://github.com/ClickHouse/ClickHouse $ch_temp; for folder in ${array_en[@]}; do cp -r $ch_temp/$folder docs/en;echo \"Copied $folder from ClickHouse master branch\";done;for folder in ${array_root[@]}; do cp -r $ch_temp/$folder docs/;echo \"Copied $folder from ClickHouse master branch\";done;rm -rf $ch_temp && echo \"Prep completed\";'",
"prep-from-local": "bash scripts/prep-from-local.sh",
"prep-from-master": "bash scripts/prep-from-master.sh",
"copy-clickhouse-repo-docs": "bash ./copyClickhouseRepoDocs.sh",
"serve": "docusaurus serve",
"build-api-doc": "node clickhouseapi.js",
Expand Down
44 changes: 44 additions & 0 deletions scripts/prep-from-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#! ./bin/bash

# Due to the fact that some of the documentation content is stored on the main repo at ClickHouse/ClickHouse
# this script is used to copy across those documents to ClickHouse/clickhouse-docs from a local copy of the
# repo. To use it provide the path to ClickHouse/ClickHouse locally as a command line argument.
# eg: yarn prep-from-local "home/users/Desktop/ClickHouse"

array_root=($npm_package_config_prep_array_root)
array_en=($npm_package_config_prep_array_en)
error_flag=0

# Check if any arguments were provided
if [ $# -eq 0 ]; then
echo -e "\033[0;31mError: No path for ClickHouse provided as command-line argument. \033[0m \neg: yarn prep-from-local \"/home/user/Desktop/ClickHouse\""
exit 1
fi

# Copy across english language docs folders from main repo
for folder in ${array_en[@]}
do
if ! cp -r $1/$folder docs/en; then
echo -e "\033[0;31mFailed to copy $folder from [$0]\033[0m"
error_flag=1
else
echo -e "\033[0;32mCopied $folder from [$0]\033[0m"
fi
done

# Copy across remaining language docs folders from main repo
for folder in ${array_root[@]}
do
if ! cp -r $1/$folder docs/; then
echo -e "\033[0;31mFailed to copy $folder from [$0]\033[0m"
error_flag=1
else
echo -e "\033[0;32mCopied $folder from [$0]\033[0m"
fi
done

if [ $error_flag -eq 1 ]; then
exit 1
fi

echo -e "\033[0;32mPreparation from local completed successfully\033[0m"
11 changes: 11 additions & 0 deletions scripts/prep-from-master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! ./bin/bash

# Due to the fact that some of the documentation content is stored on the main repo at ClickHouse/ClickHouse
# this script is used to copy across those documents to ClickHouse/clickhouse-docs from remote repository.

array_root=($npm_package_config_prep_array_root)
array_en=($npm_package_config_prep_array_en)
ch_temp=/tmp/ch_temp_$RANDOM && mkdir -p $ch_temp && git clone --depth 1 --branch master https://github.com/ClickHouse/ClickHouse $ch_temp

bash scripts/prep-from-local.sh "$ch_temp"
rm -rf $ch_temp
Loading