mirror of
https://github.com/embersparks/obsidian-github-stars-manager.git
synced 2026-07-22 06:44:31 +00:00
chore: 移除个人路径信息,提供通用 example 部署文件
- 从 git 跟踪移除含个人路径的部署脚本(deploy.bat, deploy-wsl.sh 等) - 新增 deploy.example.bat 和 deploy-wsl.example.sh 供用户自定义 - .env.example 改为通用占位符路径 - CLAUDE.md 部署命令改用环境变量引用 - esbuild.config.mjs 移除 Node 22 不兼容的 setEncoding 调用和中文路径 hack - .gitignore 补充 deploy-wsl.sh Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0204294a2e
commit
af98fdfe7d
11 changed files with 138 additions and 527 deletions
10
.env.example
10
.env.example
|
|
@ -1,4 +1,8 @@
|
|||
# This is an example file for setting up your local development environment.
|
||||
# Copy this file to .env and replace the value with the path to your Obsidian plugins directory.
|
||||
# Local development environment configuration.
|
||||
# Copy this file to .env and replace the values with your own paths.
|
||||
|
||||
OBSIDIAN_PLUGIN_DIR="C:/Users/your-username/Documents/Obsidian Vault/.obsidian/plugins"
|
||||
# Path to your Obsidian vault's plugins directory
|
||||
# Windows example: C:/Users/your-username/Documents/Obsidian Vault/.obsidian/plugins
|
||||
# WSL example: /mnt/c/Users/your-username/Documents/Obsidian Vault/.obsidian/plugins
|
||||
# macOS example: /Users/your-username/Documents/Obsidian Vault/.obsidian/plugins
|
||||
OBSIDIAN_PLUGIN_DIR="/path/to/your/obsidian-vault/.obsidian/plugins"
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -42,6 +42,7 @@ setup-env.bat
|
|||
setup-env.ps1
|
||||
deploy.bat
|
||||
deploy-fixed.bat
|
||||
deploy-wsl.sh
|
||||
|
||||
# Environment variables
|
||||
.env
|
||||
|
|
|
|||
34
CLAUDE.md
34
CLAUDE.md
|
|
@ -34,22 +34,22 @@ This is an Obsidian plugin for managing GitHub starred repositories. The plugin
|
|||
5. Export service transforms repository data into various formats
|
||||
|
||||
### Settings Management
|
||||
The plugin uses Obsidian's settings system with the following key configurations:
|
||||
- GitHub personal access token (stored securely)
|
||||
- Export preferences and formats
|
||||
|
||||
### Interface Style
|
||||
- The plugin no longer provides an in-plugin theme switch
|
||||
- The interface follows Obsidian's active light/dark appearance
|
||||
- Style files: `styles.css`; `themes.css` is legacy and should not be used to describe current user-facing theme switching
|
||||
- Emoji support utility (`src/emojiUtils.ts`)
|
||||
|
||||
### Development Principles
|
||||
1. **Obsidian 外观兼容性 (Obsidian Appearance Compatibility)**: 所有界面修改都需要在 Obsidian 浅色和深色外观下保持可读、可用,且操作逻辑一致 (All UI changes must remain readable and usable in Obsidian light and dark appearance with identical operation logic)
|
||||
2. **自动构建部署 (Auto Build & Deploy)**: 添加或者修改功能后自动重新编译,并部署到本地插件目录 (After adding or modifying functionality, automatically recompile and deploy to local plugin directory):
|
||||
```bash
|
||||
npm run build && cp main.js manifest.json styles.css "/mnt/e/cai的黑曜石/.obsidian/plugins/github-stars-manager/"
|
||||
```
|
||||
The plugin uses Obsidian's settings system with the following key configurations:
|
||||
- GitHub personal access token (stored securely)
|
||||
- Export preferences and formats
|
||||
|
||||
### Interface Style
|
||||
- The plugin no longer provides an in-plugin theme switch
|
||||
- The interface follows Obsidian's active light/dark appearance
|
||||
- Style files: `styles.css`; `themes.css` is legacy and should not be used to describe current user-facing theme switching
|
||||
- Emoji support utility (`src/emojiUtils.ts`)
|
||||
|
||||
### Development Principles
|
||||
1. **Obsidian 外观兼容性 (Obsidian Appearance Compatibility)**: 所有界面修改都需要在 Obsidian 浅色和深色外观下保持可读、可用,且操作逻辑一致 (All UI changes must remain readable and usable in Obsidian light and dark appearance with identical operation logic)
|
||||
2. **自动构建部署 (Auto Build & Deploy)**: 添加或者修改功能后自动重新编译,并部署到本地插件目录 (After adding or modifying functionality, automatically recompile and deploy to local plugin directory):
|
||||
```bash
|
||||
npm run build && cp main.js manifest.json styles.css "$OBSIDIAN_PLUGIN_DIR/github-stars-manager/"
|
||||
```
|
||||
3. **代码安全 (Code Security)**: 遵循Obsidian插件商店安全要求,使用requestUrl替代fetch,避免innerHTML等不安全操作 (Follow Obsidian plugin store security requirements, use requestUrl instead of fetch, avoid unsafe operations like innerHTML)
|
||||
4. **类型安全 (Type Safety)**: 使用严格的TypeScript类型定义,避免any类型,确保代码可维护性 (Use strict TypeScript type definitions, avoid any types, ensure code maintainability)
|
||||
|
||||
|
|
@ -303,4 +303,4 @@ These standards are enforced by ObsidianReviewBot during plugin submission revie
|
|||
5. Commit and push to GitHub
|
||||
6. Submit to plugin store
|
||||
7. Address review feedback
|
||||
8. Repeat until approved
|
||||
8. Repeat until approved
|
||||
|
|
|
|||
107
deploy-fixed.bat
107
deploy-fixed.bat
|
|
@ -1,107 +0,0 @@
|
|||
@echo off
|
||||
chcp 65001 >nul
|
||||
echo 手动部署 Obsidian GitHub Stars Manager 插件
|
||||
echo ==========================================
|
||||
echo.
|
||||
|
||||
:: 设置目标路径
|
||||
set "TARGET_DIR=E:\cai的黑曜石\.obsidian\plugins\obsidian-github-stars-manager"
|
||||
set "BACKUP_DIR=%TARGET_DIR%\backup"
|
||||
|
||||
echo 目标目录: %TARGET_DIR%
|
||||
echo 备份目录: %BACKUP_DIR%
|
||||
echo.
|
||||
|
||||
:: 检查目标目录是否存在
|
||||
if not exist "%TARGET_DIR%" (
|
||||
echo 创建目标目录...
|
||||
mkdir "%TARGET_DIR%"
|
||||
)
|
||||
|
||||
:: 检查备份目录是否存在
|
||||
if not exist "%BACKUP_DIR%" (
|
||||
echo 创建备份目录...
|
||||
mkdir "%BACKUP_DIR%"
|
||||
)
|
||||
|
||||
:: 获取当前时间戳
|
||||
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
|
||||
set "timestamp=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%_%dt:~8,2%-%dt:~10,2%-%dt:~12,2%"
|
||||
|
||||
echo 开始部署...
|
||||
echo.
|
||||
|
||||
:: 备份并复制 main.js
|
||||
if exist "%TARGET_DIR%\main.js" (
|
||||
echo 备份 main.js...
|
||||
copy "%TARGET_DIR%\main.js" "%BACKUP_DIR%\main.js.%timestamp%.backup" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ main.js 备份成功
|
||||
) else (
|
||||
echo ❌ main.js 备份失败
|
||||
)
|
||||
)
|
||||
|
||||
if exist "main.js" (
|
||||
copy "main.js" "%TARGET_DIR%\main.js" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ main.js 复制成功
|
||||
) else (
|
||||
echo ❌ main.js 复制失败
|
||||
)
|
||||
) else (
|
||||
echo ⚠️ main.js 不存在,请先运行 npm run build
|
||||
)
|
||||
|
||||
:: 备份并复制 styles.css
|
||||
if exist "%TARGET_DIR%\styles.css" (
|
||||
echo 备份 styles.css...
|
||||
copy "%TARGET_DIR%\styles.css" "%BACKUP_DIR%\styles.css.%timestamp%.backup" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ styles.css 备份成功
|
||||
) else (
|
||||
echo ❌ styles.css 备份失败
|
||||
)
|
||||
)
|
||||
|
||||
if exist "styles.css" (
|
||||
copy "styles.css" "%TARGET_DIR%\styles.css" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ styles.css 复制成功
|
||||
) else (
|
||||
echo ❌ styles.css 复制失败
|
||||
)
|
||||
) else (
|
||||
echo ⚠️ styles.css 不存在
|
||||
)
|
||||
|
||||
:: 备份并复制 manifest.json
|
||||
if exist "%TARGET_DIR%\manifest.json" (
|
||||
echo 备份 manifest.json...
|
||||
copy "%TARGET_DIR%\manifest.json" "%BACKUP_DIR%\manifest.json.%timestamp%.backup" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ manifest.json 备份成功
|
||||
) else (
|
||||
echo ❌ manifest.json 备份失败
|
||||
)
|
||||
)
|
||||
|
||||
if exist "manifest.json" (
|
||||
copy "manifest.json" "%TARGET_DIR%\manifest.json" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ manifest.json 复制成功
|
||||
) else (
|
||||
echo ❌ manifest.json 复制失败
|
||||
)
|
||||
) else (
|
||||
echo ⚠️ manifest.json 不存在
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 🎉 部署完成!
|
||||
echo 📁 插件文件已复制到: %TARGET_DIR%
|
||||
echo 📦 备份文件保存在: %BACKUP_DIR%
|
||||
echo.
|
||||
echo 现在你可以在 Obsidian 中重新加载插件来查看更改。
|
||||
echo.
|
||||
pause
|
||||
54
deploy-wsl.example.sh
Normal file
54
deploy-wsl.example.sh
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Deploy Obsidian GitHub Stars Manager Plugin (WSL)
|
||||
# Usage: Copy this file to deploy-wsl.sh and set TARGET_DIR below.
|
||||
|
||||
echo "Deploy Obsidian GitHub Stars Manager Plugin (WSL)"
|
||||
echo "=========================================="
|
||||
echo
|
||||
|
||||
# Set your Obsidian plugin directory here, e.g.:
|
||||
# TARGET_DIR="/mnt/c/Users/YourName/YourVault/.obsidian/plugins/github-stars-manager"
|
||||
TARGET_DIR="${OBSIDIAN_PLUGIN_DIR:-}"
|
||||
|
||||
if [ -z "$TARGET_DIR" ]; then
|
||||
echo "Error: OBSIDIAN_PLUGIN_DIR is not set."
|
||||
echo "Either export it or edit this script to set TARGET_DIR directly."
|
||||
echo ""
|
||||
echo " export OBSIDIAN_PLUGIN_DIR=\"/mnt/c/Users/YourName/YourVault/.obsidian/plugins/github-stars-manager\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGET_DIR="$TARGET_DIR/github-stars-manager"
|
||||
|
||||
echo "Target: $TARGET_DIR"
|
||||
echo
|
||||
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
echo "Creating target directory..."
|
||||
mkdir -p "$TARGET_DIR"
|
||||
fi
|
||||
|
||||
echo "Deploying..."
|
||||
echo
|
||||
|
||||
if [ -f "main.js" ]; then
|
||||
cp "main.js" "$TARGET_DIR/main.js"
|
||||
echo "Done: main.js"
|
||||
else
|
||||
echo "Warning: main.js not found, run npm run build first"
|
||||
fi
|
||||
|
||||
if [ -f "styles.css" ]; then
|
||||
cp "styles.css" "$TARGET_DIR/styles.css"
|
||||
echo "Done: styles.css"
|
||||
fi
|
||||
|
||||
if [ -f "manifest.json" ]; then
|
||||
cp "manifest.json" "$TARGET_DIR/manifest.json"
|
||||
echo "Done: manifest.json"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Deploy complete: $TARGET_DIR"
|
||||
echo "Reload the plugin in Obsidian to see changes."
|
||||
134
deploy-wsl.sh
134
deploy-wsl.sh
|
|
@ -1,134 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 部署 Obsidian GitHub Stars Manager 插件到 WSL 环境
|
||||
echo "部署 Obsidian GitHub Stars Manager 插件 (WSL)"
|
||||
echo "=========================================="
|
||||
echo
|
||||
|
||||
# 设置目标路径
|
||||
TARGET_DIR="/mnt/e/cai的黑曜石/.obsidian/plugins/obsidian-github-stars-manager"
|
||||
BACKUP_DIR="$TARGET_DIR/backup"
|
||||
|
||||
echo "目标目录: $TARGET_DIR"
|
||||
echo "备份目录: $BACKUP_DIR"
|
||||
echo
|
||||
|
||||
# 检查目标目录是否存在
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
echo "创建目标目录..."
|
||||
mkdir -p "$TARGET_DIR"
|
||||
fi
|
||||
|
||||
# 检查备份目录是否存在
|
||||
if [ ! -d "$BACKUP_DIR" ]; then
|
||||
echo "创建备份目录..."
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
fi
|
||||
|
||||
# 获取当前时间戳
|
||||
timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
|
||||
|
||||
echo "开始部署..."
|
||||
echo
|
||||
|
||||
# 备份并复制 main.js
|
||||
if [ -f "$TARGET_DIR/main.js" ]; then
|
||||
echo "备份 main.js..."
|
||||
cp "$TARGET_DIR/main.js" "$BACKUP_DIR/main.js.$timestamp.backup"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ main.js 备份成功"
|
||||
else
|
||||
echo "❌ main.js 备份失败"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "main.js" ]; then
|
||||
cp "main.js" "$TARGET_DIR/main.js"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ main.js 复制成功"
|
||||
else
|
||||
echo "❌ main.js 复制失败"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ main.js 不存在,请先运行 npm run build"
|
||||
fi
|
||||
|
||||
# 备份并复制 styles.css
|
||||
if [ -f "$TARGET_DIR/styles.css" ]; then
|
||||
echo "备份 styles.css..."
|
||||
cp "$TARGET_DIR/styles.css" "$BACKUP_DIR/styles.css.$timestamp.backup"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ styles.css 备份成功"
|
||||
else
|
||||
echo "❌ styles.css 备份失败"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "styles.css" ]; then
|
||||
cp "styles.css" "$TARGET_DIR/styles.css"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ styles.css 复制成功"
|
||||
else
|
||||
echo "❌ styles.css 复制失败"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ styles.css 不存在"
|
||||
fi
|
||||
|
||||
# 备份并复制 themes.css
|
||||
if [ -f "$TARGET_DIR/themes.css" ]; then
|
||||
echo "备份 themes.css..."
|
||||
cp "$TARGET_DIR/themes.css" "$BACKUP_DIR/themes.css.$timestamp.backup"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ themes.css 备份成功"
|
||||
else
|
||||
echo "❌ themes.css 备份失败"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "themes.css" ]; then
|
||||
cp "themes.css" "$TARGET_DIR/themes.css"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ themes.css 复制成功"
|
||||
else
|
||||
echo "❌ themes.css 复制失败"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ themes.css 不存在"
|
||||
fi
|
||||
|
||||
# 备份并复制 manifest.json
|
||||
if [ -f "$TARGET_DIR/manifest.json" ]; then
|
||||
echo "备份 manifest.json..."
|
||||
cp "$TARGET_DIR/manifest.json" "$BACKUP_DIR/manifest.json.$timestamp.backup"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ manifest.json 备份成功"
|
||||
else
|
||||
echo "❌ manifest.json 备份失败"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "manifest.json" ]; then
|
||||
cp "manifest.json" "$TARGET_DIR/manifest.json"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ manifest.json 复制成功"
|
||||
else
|
||||
echo "❌ manifest.json 复制失败"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ manifest.json 不存在"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "🎉 部署完成!"
|
||||
echo "📁 插件文件已复制到: $TARGET_DIR"
|
||||
echo "📦 备份文件保存在: $BACKUP_DIR"
|
||||
echo
|
||||
echo "现在你可以在 Obsidian 中重新加载插件来查看更改。"
|
||||
echo
|
||||
|
||||
# 设置正确的权限
|
||||
chmod 644 "$TARGET_DIR"/*.js "$TARGET_DIR"/*.css "$TARGET_DIR"/*.json 2>/dev/null
|
||||
|
||||
echo "权限设置完成。"
|
||||
echo
|
||||
129
deploy.bat
129
deploy.bat
|
|
@ -1,129 +0,0 @@
|
|||
@echo off
|
||||
chcp 65001 >nul
|
||||
echo 手动部署 Obsidian GitHub Stars Manager 插件
|
||||
echo ==========================================
|
||||
echo.
|
||||
|
||||
:: 设置目标路径
|
||||
set "TARGET_DIR=E:\cai的黑曜石\.obsidian\plugins\obsidian-github-stars-manager"
|
||||
set "BACKUP_DIR=%TARGET_DIR%\backup"
|
||||
|
||||
echo 目标目录: %TARGET_DIR%
|
||||
echo 备份目录: %BACKUP_DIR%
|
||||
echo.
|
||||
|
||||
:: 检查目标目录是否存在
|
||||
if not exist "%TARGET_DIR%" (
|
||||
echo 创建目标目录...
|
||||
mkdir "%TARGET_DIR%"
|
||||
)
|
||||
|
||||
:: 检查备份目录是否存在
|
||||
if not exist "%BACKUP_DIR%" (
|
||||
echo 创建备份目录...
|
||||
mkdir "%BACKUP_DIR%"
|
||||
)
|
||||
|
||||
:: 获取当前时间戳
|
||||
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
|
||||
set "timestamp=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%_%dt:~8,2%-%dt:~10,2%-%dt:~12,2%"
|
||||
|
||||
echo 开始部署...
|
||||
echo.
|
||||
|
||||
:: 备份并复制 main.js
|
||||
if exist "%TARGET_DIR%\main.js" (
|
||||
echo 备份 main.js...
|
||||
copy "%TARGET_DIR%\main.js" "%BACKUP_DIR%\main.js.%timestamp%.backup" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ main.js 备份成功
|
||||
) else (
|
||||
echo ❌ main.js 备份失败
|
||||
)
|
||||
)
|
||||
|
||||
if exist "main.js" (
|
||||
copy "main.js" "%TARGET_DIR%\main.js" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ main.js 复制成功
|
||||
) else (
|
||||
echo ❌ main.js 复制失败
|
||||
)
|
||||
) else (
|
||||
echo ⚠️ main.js 不存在,请先运行 npm run build
|
||||
)
|
||||
|
||||
:: 备份并复制 styles.css
|
||||
if exist "%TARGET_DIR%\styles.css" (
|
||||
echo 备份 styles.css...
|
||||
copy "%TARGET_DIR%\styles.css" "%BACKUP_DIR%\styles.css.%timestamp%.backup" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ styles.css 备份成功
|
||||
) else (
|
||||
echo ❌ styles.css 备份失败
|
||||
)
|
||||
)
|
||||
|
||||
if exist "styles.css" (
|
||||
copy "styles.css" "%TARGET_DIR%\styles.css" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ styles.css 复制成功
|
||||
) else (
|
||||
echo ❌ styles.css 复制失败
|
||||
)
|
||||
) else (
|
||||
echo ⚠️ styles.css 不存在
|
||||
)
|
||||
|
||||
:: 备份并复制 themes.css
|
||||
if exist "%TARGET_DIR%\themes.css" (
|
||||
echo 备份 themes.css...
|
||||
copy "%TARGET_DIR%\themes.css" "%BACKUP_DIR%\themes.css.%timestamp%.backup" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ themes.css 备份成功
|
||||
) else (
|
||||
echo ❌ themes.css 备份失败
|
||||
)
|
||||
)
|
||||
|
||||
if exist "themes.css" (
|
||||
copy "themes.css" "%TARGET_DIR%\themes.css" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ themes.css 复制成功
|
||||
) else (
|
||||
echo ❌ themes.css 复制失败
|
||||
)
|
||||
) else (
|
||||
echo ⚠️ themes.css 不存在
|
||||
)
|
||||
|
||||
:: 备份并复制 manifest.json
|
||||
if exist "%TARGET_DIR%\manifest.json" (
|
||||
echo 备份 manifest.json...
|
||||
copy "%TARGET_DIR%\manifest.json" "%BACKUP_DIR%\manifest.json.%timestamp%.backup" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ manifest.json 备份成功
|
||||
) else (
|
||||
echo ❌ manifest.json 备份失败
|
||||
)
|
||||
)
|
||||
|
||||
if exist "manifest.json" (
|
||||
copy "manifest.json" "%TARGET_DIR%\manifest.json" >nul
|
||||
if %errorlevel% equ 0 (
|
||||
echo ✅ manifest.json 复制成功
|
||||
) else (
|
||||
echo ❌ manifest.json 复制失败
|
||||
)
|
||||
) else (
|
||||
echo ⚠️ manifest.json 不存在
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 🎉 部署完成!
|
||||
echo 📁 插件文件已复制到: %TARGET_DIR%
|
||||
echo 📦 备份文件保存在: %BACKUP_DIR%
|
||||
echo.
|
||||
echo 现在你可以在 Obsidian 中重新加载插件来查看更改。
|
||||
echo.
|
||||
pause
|
||||
52
deploy.example.bat
Normal file
52
deploy.example.bat
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
@echo off
|
||||
chcp 65001 >nul
|
||||
echo Deploy Obsidian GitHub Stars Manager Plugin
|
||||
echo ==========================================
|
||||
echo.
|
||||
|
||||
:: Read plugin directory from environment variable
|
||||
:: Set this via: setx OBSIDIAN_PLUGIN_DIR "your-path"
|
||||
:: Or create a .env file with OBSIDIAN_PLUGIN_DIR="your-path"
|
||||
if "%OBSIDIAN_PLUGIN_DIR%"=="" (
|
||||
echo Error: OBSIDIAN_PLUGIN_DIR environment variable is not set.
|
||||
echo Please run: setx OBSIDIAN_PLUGIN_DIR "C:\Users\YourName\YourVault\.obsidian\plugins"
|
||||
echo Or copy .env.example to .env and set the path there.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "TARGET_DIR=%OBSIDIAN_PLUGIN_DIR%\github-stars-manager"
|
||||
|
||||
echo Target: %TARGET_DIR%
|
||||
echo.
|
||||
|
||||
if not exist "%TARGET_DIR%" (
|
||||
echo Creating target directory...
|
||||
mkdir "%TARGET_DIR%"
|
||||
)
|
||||
|
||||
echo Deploying...
|
||||
echo.
|
||||
|
||||
if exist "main.js" (
|
||||
copy "main.js" "%TARGET_DIR%\main.js" >nul
|
||||
echo Done: main.js
|
||||
) else (
|
||||
echo Warning: main.js not found, run npm run build first
|
||||
)
|
||||
|
||||
if exist "styles.css" (
|
||||
copy "styles.css" "%TARGET_DIR%\styles.css" >nul
|
||||
echo Done: styles.css
|
||||
)
|
||||
|
||||
if exist "manifest.json" (
|
||||
copy "manifest.json" "%TARGET_DIR%\manifest.json" >nul
|
||||
echo Done: manifest.json
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Deploy complete: %TARGET_DIR%
|
||||
echo Reload the plugin in Obsidian to see changes.
|
||||
echo.
|
||||
pause
|
||||
|
|
@ -30,51 +30,6 @@ function loadLocalEnvFile(envPath = ".env") {
|
|||
|
||||
loadLocalEnvFile();
|
||||
|
||||
// 设置正确的字符编码处理
|
||||
process.stdout.setEncoding('utf8');
|
||||
process.stderr.setEncoding('utf8');
|
||||
|
||||
// 修复Windows中文路径显示问题的函数
|
||||
function fixChinesePathDisplay(pathStr) {
|
||||
try {
|
||||
// 直接使用Buffer进行编码转换
|
||||
if (typeof pathStr === 'string') {
|
||||
// 尝试多种编码修复方案
|
||||
let fixedPath = pathStr;
|
||||
|
||||
// 方案1:已知的乱码字符替换
|
||||
const replacements = {
|
||||
'鐨<>': '的',
|
||||
'榛<>': '黑',
|
||||
'鏇<>': '曜',
|
||||
'鐭<>': '石',
|
||||
'鐢<>': '用',
|
||||
'鎴<>': '户'
|
||||
};
|
||||
|
||||
for (const [wrong, correct] of Object.entries(replacements)) {
|
||||
fixedPath = fixedPath.replace(new RegExp(wrong, 'g'), correct);
|
||||
}
|
||||
|
||||
// 方案2:如果还有乱码,尝试编码转换
|
||||
if (fixedPath.match(/[\u4e00-\u9fff]/g) && fixedPath.includes('鐨<>')) {
|
||||
try {
|
||||
// 尝试从GBK转UTF-8
|
||||
const buffer = Buffer.from(pathStr, 'binary');
|
||||
fixedPath = buffer.toString('utf8');
|
||||
} catch (e) {
|
||||
// 如果转换失败,保持原样
|
||||
}
|
||||
}
|
||||
|
||||
return fixedPath;
|
||||
}
|
||||
return pathStr;
|
||||
} catch (error) {
|
||||
console.warn('Path encoding fix failed:', error);
|
||||
return pathStr;
|
||||
}
|
||||
}
|
||||
|
||||
const banner =
|
||||
`/*
|
||||
|
|
@ -126,16 +81,14 @@ const copyPlugin = {
|
|||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
const backupFile = path.join(backupDir, `${fileName}.${timestamp}.backup`);
|
||||
fs.copyFileSync(targetFile, backupFile);
|
||||
// 修复中文路径显示
|
||||
const displayBackupPath = fixChinesePathDisplay(backupFile);
|
||||
console.log(`Backed up ${fileName} to ${displayBackupPath}`);
|
||||
|
||||
console.log(`Backed up ${fileName} to ${backupFile}`);
|
||||
}
|
||||
|
||||
// Copy new file
|
||||
fs.copyFileSync(sourceFile, targetFile);
|
||||
// 修复中文路径显示
|
||||
const displayTargetDir = fixChinesePathDisplay(targetDir);
|
||||
console.log(`Copied ${fileName} to ${displayTargetDir}`);
|
||||
|
||||
console.log(`Copied ${fileName} to ${targetDir}`);
|
||||
} catch (err) {
|
||||
console.error(`Error copying ${fileName}:`, err);
|
||||
}
|
||||
|
|
@ -156,12 +109,9 @@ const copyPlugin = {
|
|||
|
||||
// Copy manifest.json with backup
|
||||
backupAndCopy("manifest.json", path.join(targetDir, "manifest.json"), "manifest.json");
|
||||
|
||||
// 修复中文路径显示
|
||||
const displayTargetDir = fixChinesePathDisplay(targetDir);
|
||||
const displayBackupDir = fixChinesePathDisplay(backupDir);
|
||||
console.log(`\n✅ Plugin files deployed to: ${displayTargetDir}`);
|
||||
console.log(`📦 Backups stored in: ${displayBackupDir}`);
|
||||
|
||||
console.log(`\n✅ Plugin files deployed to: ${targetDir}`);
|
||||
console.log(`📦 Backups stored in: ${backupDir}`);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
@echo off
|
||||
chcp 65001 >nul
|
||||
echo 设置 Obsidian 插件自动部署环境变量
|
||||
echo =====================================
|
||||
echo.
|
||||
|
||||
set "OBSIDIAN_PATH=E:\cai的黑曜石\.obsidian\plugins"
|
||||
|
||||
echo 当前设置的路径: %OBSIDIAN_PATH%
|
||||
echo.
|
||||
|
||||
choice /C YN /M "是否使用此路径作为 Obsidian 插件目录"
|
||||
|
||||
if errorlevel 2 (
|
||||
echo.
|
||||
set /p "OBSIDIAN_PATH=请输入你的 Obsidian 插件目录路径: "
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 正在设置环境变量...
|
||||
|
||||
:: 设置用户环境变量
|
||||
setx OBSIDIAN_PLUGIN_DIR "%OBSIDIAN_PATH%"
|
||||
|
||||
if %errorlevel% equ 0 (
|
||||
echo.
|
||||
echo ✅ 环境变量设置成功!
|
||||
echo 📁 OBSIDIAN_PLUGIN_DIR = %OBSIDIAN_PATH%
|
||||
echo.
|
||||
echo 现在你可以运行以下命令来自动部署插件:
|
||||
echo npm run build
|
||||
echo.
|
||||
echo 注意:你可能需要重启命令行或 VS Code 来使环境变量生效。
|
||||
) else (
|
||||
echo.
|
||||
echo ❌ 环境变量设置失败,请检查权限或手动设置。
|
||||
)
|
||||
|
||||
echo.
|
||||
pause
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
# PowerShell 版本的环境变量设置脚本
|
||||
Write-Host "设置 Obsidian 插件自动部署环境变量" -ForegroundColor Green
|
||||
Write-Host "=====================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
$defaultPath = "E:\cai的黑曜石\.obsidian\plugins"
|
||||
Write-Host "当前设置的路径: $defaultPath" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
$choice = Read-Host "是否使用此路径作为 Obsidian 插件目录? (Y/N)"
|
||||
|
||||
if ($choice -eq "N" -or $choice -eq "n") {
|
||||
$obsidianPath = Read-Host "请输入你的 Obsidian 插件目录路径"
|
||||
} else {
|
||||
$obsidianPath = $defaultPath
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "正在设置环境变量..." -ForegroundColor Blue
|
||||
|
||||
try {
|
||||
# 设置用户环境变量
|
||||
[Environment]::SetEnvironmentVariable("OBSIDIAN_PLUGIN_DIR", $obsidianPath, "User")
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "✅ 环境变量设置成功!" -ForegroundColor Green
|
||||
Write-Host "📁 OBSIDIAN_PLUGIN_DIR = $obsidianPath" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "现在你可以运行以下命令来自动部署插件:" -ForegroundColor Yellow
|
||||
Write-Host " npm run build" -ForegroundColor White
|
||||
Write-Host ""
|
||||
Write-Host "注意:你可能需要重启命令行或 VS Code 来使环境变量生效。" -ForegroundColor Magenta
|
||||
} catch {
|
||||
Write-Host ""
|
||||
Write-Host "❌ 环境变量设置失败: $($_.Exception.Message)" -ForegroundColor Red
|
||||
Write-Host "请尝试以管理员身份运行此脚本。" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Read-Host "按 Enter 键退出"
|
||||
Loading…
Reference in a new issue