-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-local.sh
More file actions
executable file
·65 lines (54 loc) · 2.06 KB
/
install-local.sh
File metadata and controls
executable file
·65 lines (54 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# usage: ./install-local.sh /path/to/your/vault
# example: ./install-local.sh "/Users/marco/Documents/My Vault"
# Load .env file if it exists
if [ -f .env ]; then
set -a
source .env
set +a
fi
PLUGIN_ID="obsidian-s3-publisher"
# Use command line argument if provided, otherwise use env var
VAULT_PATH="${1:-$OBSIDIAN_VAULT_PATH}"
# Remove trailing slash and expand tilde
VAULT_PATH="${VAULT_PATH%/}"
VAULT_PATH="${VAULT_PATH/#\~/$HOME}"
if [ -n "$INSTALLDIR" ]; then
# Remove trailing slash and expand tilde from INSTALLDIR
INSTALLDIR="${INSTALLDIR%/}"
INSTALLDIR="${INSTALLDIR/#\~/$HOME}"
# If INSTALLDIR is provided (e.g. from .env), use it as the base plugins folder
# Example: INSTALLDIR=~/vault/.obsidian/plugins/
TARGET_DIR="$INSTALLDIR/$PLUGIN_ID"
# Ensure directory expansion if ~ is used (conceptually, though shell handles it mostly if unquoted, but better to be safe)
# Actually, we should just trust the path.
echo "Using INSTALLDIR from environment: $INSTALLDIR"
else
# Fallback to Vault Path argument
if [ -z "$VAULT_PATH" ]; then
echo "Error: Vault path not provided."
echo "Usage: ./install-local.sh <path-to-obsidian-vault>"
echo "Or set INSTALLDIR in .env (e.g., INSTALLDIR=/path/to/vault/.obsidian/plugins)"
exit 1
fi
TARGET_DIR="$VAULT_PATH/.obsidian/plugins/$PLUGIN_ID"
fi
# We can't easily check for .obsidian existence if we use INSTALLDIR blindly,
# but let's assume the user knows what they are doing if setting env var.
if [ -z "$INSTALLDIR" ] && [ ! -d "$VAULT_PATH/.obsidian" ]; then
echo "Error: Directory '$VAULT_PATH/.obsidian' does not exist."
echo "Are you sure this is an Obsidian Vault?"
exit 1
fi
echo "Building plugin..."
npm run build
if [ $? -ne 0 ]; then
echo "Build failed. Aborting."
exit 1
fi
echo "Creating plugin directory at $TARGET_DIR..."
mkdir -p "$TARGET_DIR"
echo "Copying files..."
cp main.js manifest.json styles.css "$TARGET_DIR/"
echo "✅ Installed successfully!"
echo "Reload Obsidian (Cmd+R) to load the new plugin code."