-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·101 lines (84 loc) · 2.54 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·101 lines (84 loc) · 2.54 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
set -euo pipefail
REPO="${IX_CURSOR_REPO:-ix-infrastructure/ix-cursor-plugin}"
REF="${IX_CURSOR_REF:-main}"
PLUGIN_NAME="${IX_CURSOR_PLUGIN_NAME:-ix-memory}"
CURSOR_LOCAL_ROOT="${HOME}/.cursor/plugins/local"
DEST_DIR="${CURSOR_LOCAL_ROOT}/${PLUGIN_NAME}"
ARCHIVE_URL="https://codeload.github.com/${REPO}/tar.gz/refs/heads/${REF}"
need_cmd() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "Error: required command not found: $1" >&2
exit 1
fi
}
echo "Installing ${PLUGIN_NAME} from ${REPO}@${REF}"
need_cmd curl
need_cmd tar
need_cmd node
if ! command -v ix >/dev/null 2>&1; then
echo "Error: 'ix' is not available on PATH." >&2
echo "Install ix first, then rerun this installer." >&2
exit 1
fi
TMP_DIR="$(mktemp -d)"
cleanup() {
rm -rf "${TMP_DIR}"
}
trap cleanup EXIT
mkdir -p "${CURSOR_LOCAL_ROOT}"
echo "Downloading archive..."
curl -fsSL "${ARCHIVE_URL}" -o "${TMP_DIR}/plugin.tar.gz"
echo "Extracting archive..."
tar -xzf "${TMP_DIR}/plugin.tar.gz" -C "${TMP_DIR}"
EXTRACTED_DIR="$(find "${TMP_DIR}" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
if [[ -z "${EXTRACTED_DIR}" ]]; then
echo "Error: could not find extracted plugin directory." >&2
exit 1
fi
if [[ ! -f "${EXTRACTED_DIR}/.cursor-plugin/plugin.json" ]]; then
echo "Error: extracted archive does not contain .cursor-plugin/plugin.json." >&2
echo "Check REPO and REF, or override them with IX_CURSOR_REPO / IX_CURSOR_REF." >&2
exit 1
fi
if [[ -L "${DEST_DIR}" ]]; then
echo "Removing existing symlink at ${DEST_DIR}"
rm "${DEST_DIR}"
elif [[ -d "${DEST_DIR}" ]]; then
echo "Replacing existing install at ${DEST_DIR}"
rm -rf "${DEST_DIR}"
elif [[ -e "${DEST_DIR}" ]]; then
echo "Error: ${DEST_DIR} exists and is not a directory or symlink." >&2
exit 1
fi
mkdir -p "${DEST_DIR}"
cp -R "${EXTRACTED_DIR}/." "${DEST_DIR}/"
if [[ ! -d "${DEST_DIR}/mcp/node_modules" ]]; then
if ! command -v npm >/dev/null 2>&1; then
echo "Error: npm is required because mcp/node_modules is missing." >&2
exit 1
fi
echo "Installing MCP runtime dependencies..."
(
cd "${DEST_DIR}/mcp"
npm ci --omit=dev
)
fi
if [[ ! -f "${DEST_DIR}/mcp/dist/server.js" ]]; then
if ! command -v npm >/dev/null 2>&1; then
echo "Error: npm is required because mcp/dist/server.js is missing." >&2
exit 1
fi
echo "Building MCP server..."
(
cd "${DEST_DIR}/mcp"
npm ci
npm run build
)
fi
echo
echo "Installed Cursor plugin:"
echo " ${DEST_DIR}"
echo
echo "Next step:"
echo " Restart Cursor or reload plugins so it picks up the new install."