dudaanton_obsidian-strudel-.../build_and_copy_plugin.sh

56 lines
1.3 KiB
Bash
Raw Normal View History

2025-10-23 17:54:43 +00:00
#!/bin/bash
source ./.env
# Exit immediately if a command exits with a non-zero status.
set -e
2025-10-24 16:37:01 +00:00
if [ "$1" = "prod" ]; then
TARGET_DIR="$TARGET_VAULT_DIR"
echo ">>> Building for PROD vault"
else
TARGET_DIR="$TARGET_TEST_VAULT_DIR"
echo ">>> Building for TEST vault"
fi
if [ -z "$TARGET_DIR" ]; then
echo "Error: Target directory is not defined. Check your .env file."
exit 1
fi
2025-10-23 17:54:43 +00:00
# Define plugin source and build directories
PLUGIN_DIR="."
BUILD_DIR="$PLUGIN_DIR/build"
echo "--- Building Strudel Obsidian Plugin ---"
# Install dependencies if node_modules doesn't exist
if [ ! -d "node_modules" ]; then
echo "Node modules not found. Installing dependencies..."
npm install
fi
# Run the build script
echo "Running build..."
npm run build
echo "--- Copying Plugin Files to Test Vault ---"
# Create target directory in test vault if it doesn't exist
2025-10-24 16:37:01 +00:00
mkdir -p "$TARGET_DIR"
echo "Ensured target directory exists: $TARGET_DIR"
2025-10-23 17:54:43 +00:00
# Copy built files
2025-10-24 16:37:01 +00:00
cp -X "$BUILD_DIR/main.js" "$TARGET_DIR/main.js"
2025-10-23 17:54:43 +00:00
echo "Copied main.js"
2025-10-24 17:30:28 +00:00
cp -X "$BUILD_DIR/styles.css" "$TARGET_DIR/styles.css"
2025-10-23 17:54:43 +00:00
echo "Copied styles.css"
2025-10-24 16:37:01 +00:00
cp -X "$PLUGIN_DIR/manifest.json" "$TARGET_DIR/manifest.json"
2025-10-23 17:54:43 +00:00
echo "Copied manifest.json"
echo "--- Plugin Build and Copy Complete ---"
2025-10-24 16:37:01 +00:00
echo "Plugin files are ready in: $TARGET_DIR"