🔧 chore: Update changelog, enhance prepare script, and add openapi command

This commit is contained in:
web@ppanel 2024-12-28 23:24:40 +07:00
parent cd49427dad
commit a93db4eb9f
4 changed files with 59 additions and 24 deletions

View File

@ -1,12 +1,12 @@
<a name="readme-top"></a>
# Changelog
# [1.0.0-beta.3](https://github.com/perfect-panel/ppanel-web/compare/v1.0.0-beta.2...v1.0.0-beta.3) (2024-12-26)
### ♻ Code Refactoring
* **config**: Simplify environment variable handling and improve build script ([cf54d0f](https://github.com/perfect-panel/ppanel-web/commit/cf54d0f))
- **config**: Simplify environment variable handling and improve build script ([cf54d0f](https://github.com/perfect-panel/ppanel-web/commit/cf54d0f))
<a name="readme-top"></a>

View File

@ -21,6 +21,7 @@
"dev": "turbo dev",
"lint": "turbo lint",
"locale": "turbo locale && bun prettier",
"openapi": "turbo openapi && bun prettier",
"prepare": "./scripts/prepare.sh",
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,cjs,mjs,md,json}\"",
"release": "semantic-release",

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Skip entire script in CI environment
# Skip script in CI environment
if [ "$CI" = "true" ]; then
echo "CI environment detected, skipping script execution."
exit 0
@ -12,28 +12,39 @@ if [ ! -d ".git" ]; then
exit 1
fi
# Check if .husky folder exists and skip `npx husky install` if it does
if [ -d ".husky" ]; then
echo ".husky folder already exists. Skipping npx husky install."
else
echo "Setting up Husky..."
if npx husky; then
echo "Husky has been successfully set up."
else
echo "Failed to set up Husky. Skipping."
exit 1
fi
fi
# Function to set up a Husky hook
setup_husky_hook() {
local hook_name=$1
local hook_content=$2
local hook_file=".husky/$hook_name"
if [ -f "$hook_file" ]; then
echo "$hook_name hook is already set up. Skipping."
return
fi
if [ ! -f ".husky/$hook_name" ]; then
echo "Setting up $hook_name hook..."
echo "$hook_content" > ".husky/$hook_name" || echo "Failed to set up $hook_name hook. Skipping."
chmod +x ".husky/$hook_name" || echo "Failed to make $hook_name hook executable. Skipping."
echo "$hook_content" > "$hook_file" && chmod +x "$hook_file"
if [ $? -eq 0 ]; then
echo "$hook_name hook has been successfully set up."
else
echo "$hook_name hook is already set up."
echo "Failed to set up $hook_name hook. Skipping."
fi
}
# Ensure Husky is installed and initialized
if [ ! -d ".husky" ]; then
echo "Setting up Husky..."
npx husky || echo "Failed to set up Husky. Skipping."
else
echo "Husky is already set up."
fi
# Set up pre-commit hook
setup_husky_hook "pre-commit" "#!/bin/sh
. \"\$(dirname \"\$0\")/_/husky.sh\"
@ -50,11 +61,16 @@ npx --no-install commitlint --edit \"\$1\""
install_global_package() {
local package_name=$1
if ! npm list -g --depth=0 "$package_name" > /dev/null 2>&1; then
if npm list -g --depth=0 "$package_name" > /dev/null 2>&1; then
echo "$package_name is already installed. Skipping installation."
return
fi
echo "Installing $package_name globally..."
npm install -g "$package_name" || echo "Failed to install $package_name globally. Skipping."
if npm install -g "$package_name"; then
echo "$package_name has been successfully installed."
else
echo "$package_name is already installed."
echo "Failed to install $package_name globally. Skipping."
fi
}
@ -62,6 +78,24 @@ install_global_package() {
install_global_package "@lobehub/i18n-cli"
install_global_package "@lobehub/commit-cli"
# Check if .husky/_/prepare-commit-msg exists
if [ -f ".husky/_/prepare-commit-msg" ]; then
echo "prepare-commit-msg hook already exists. Skipping lobe-commit -i."
else
# If the hook does not exist, set it up and run lobe-commit -i
echo "Setting up prepare-commit-msg hook..."
if npx husky add .husky/prepare-commit-msg "exec < /dev/tty && npx lobe-commit -i"; then
echo "prepare-commit-msg hook has been successfully set up."
# Run lobe-commit interactively
echo "Running lobe-commit -i..."
lobe-commit -i || echo "lobe-commit failed. Skipping."
if lobe-commit -i; then
echo "lobe-commit executed successfully."
else
echo "lobe-commit failed. Skipping."
fi
else
echo "Failed to set up prepare-commit-msg hook. Skipping lobe-commit."
exit 1
fi
fi