replit-tools 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/setup-claude-code.sh +103 -30
package/package.json
CHANGED
|
@@ -43,8 +43,36 @@ log() {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
# =============================================================================
|
|
46
|
-
# Step 0: Show version
|
|
46
|
+
# Step 0: Show version, check for updates, and auto-update if available
|
|
47
47
|
# =============================================================================
|
|
48
|
+
auto_update_scripts() {
|
|
49
|
+
local latest_ver="$1"
|
|
50
|
+
local tmp_dir=$(mktemp -d)
|
|
51
|
+
|
|
52
|
+
# Download and extract latest package
|
|
53
|
+
if npm pack "${PACKAGE_NAME}@${latest_ver}" --pack-destination="${tmp_dir}" >/dev/null 2>&1; then
|
|
54
|
+
local tarball="${tmp_dir}/${PACKAGE_NAME}-${latest_ver}.tgz"
|
|
55
|
+
if [ -f "${tarball}" ]; then
|
|
56
|
+
tar -xzf "${tarball}" -C "${tmp_dir}" 2>/dev/null
|
|
57
|
+
|
|
58
|
+
# Copy updated scripts
|
|
59
|
+
if [ -d "${tmp_dir}/package/scripts" ]; then
|
|
60
|
+
cp -f "${tmp_dir}/package/scripts/"*.sh "${SCRIPTS_DIR}/" 2>/dev/null
|
|
61
|
+
chmod 755 "${SCRIPTS_DIR}/"*.sh 2>/dev/null
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# Update version file
|
|
65
|
+
echo "${latest_ver}" > "${VERSION_FILE}"
|
|
66
|
+
|
|
67
|
+
rm -rf "${tmp_dir}"
|
|
68
|
+
return 0
|
|
69
|
+
fi
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
rm -rf "${tmp_dir}" 2>/dev/null
|
|
73
|
+
return 1
|
|
74
|
+
}
|
|
75
|
+
|
|
48
76
|
if [[ $- == *i* ]]; then
|
|
49
77
|
CURRENT_VERSION=""
|
|
50
78
|
if [ -f "${VERSION_FILE}" ]; then
|
|
@@ -56,8 +84,14 @@ if [[ $- == *i* ]]; then
|
|
|
56
84
|
LATEST_VERSION=$(timeout 3 npm view "${PACKAGE_NAME}" version 2>/dev/null || echo "")
|
|
57
85
|
|
|
58
86
|
if [ -n "${LATEST_VERSION}" ] && [ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ]; then
|
|
59
|
-
echo "📦 DATA Tools v${CURRENT_VERSION}
|
|
60
|
-
echo "
|
|
87
|
+
echo "📦 DATA Tools v${CURRENT_VERSION} → v${LATEST_VERSION}"
|
|
88
|
+
echo " ⬆️ Auto-updating..."
|
|
89
|
+
|
|
90
|
+
if auto_update_scripts "${LATEST_VERSION}"; then
|
|
91
|
+
echo " ✅ Updated to v${LATEST_VERSION}"
|
|
92
|
+
else
|
|
93
|
+
echo " ⚠️ Auto-update failed, continuing with v${CURRENT_VERSION}"
|
|
94
|
+
fi
|
|
61
95
|
else
|
|
62
96
|
echo "📦 DATA Tools v${CURRENT_VERSION}"
|
|
63
97
|
fi
|
|
@@ -98,33 +132,71 @@ fi
|
|
|
98
132
|
# Step 4: Find latest Claude version and create binary symlink
|
|
99
133
|
# =============================================================================
|
|
100
134
|
|
|
101
|
-
#
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
135
|
+
# Check multiple locations for Claude binary (handles race conditions on container restart)
|
|
136
|
+
find_claude_binary() {
|
|
137
|
+
local found_binary=""
|
|
138
|
+
local found_version=""
|
|
139
|
+
|
|
140
|
+
# Priority 1: Our persistent versions directory
|
|
141
|
+
if [ -d "${CLAUDE_VERSIONS}" ]; then
|
|
142
|
+
local ver=$(ls -1 "${CLAUDE_VERSIONS}" 2>/dev/null | grep -v '^\.' | sort -V | tail -n1)
|
|
143
|
+
if [ -n "${ver}" ] && [ -f "${CLAUDE_VERSIONS}/${ver}" ]; then
|
|
144
|
+
found_binary="${CLAUDE_VERSIONS}/${ver}"
|
|
145
|
+
found_version="${ver}"
|
|
146
|
+
fi
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
# Priority 2: Check if claude command already works (might be from previous install)
|
|
150
|
+
if [ -z "${found_binary}" ]; then
|
|
151
|
+
local existing_claude=$(command -v claude 2>/dev/null)
|
|
152
|
+
if [ -n "${existing_claude}" ] && [ -x "${existing_claude}" ]; then
|
|
153
|
+
# Follow symlinks to find actual binary
|
|
154
|
+
local real_path=$(readlink -f "${existing_claude}" 2>/dev/null)
|
|
155
|
+
if [ -f "${real_path}" ]; then
|
|
156
|
+
found_binary="${real_path}"
|
|
157
|
+
found_version=$(basename "${real_path}")
|
|
110
158
|
fi
|
|
111
159
|
fi
|
|
112
|
-
|
|
113
|
-
fi
|
|
160
|
+
fi
|
|
114
161
|
|
|
115
|
-
|
|
116
|
-
if [ -
|
|
117
|
-
|
|
118
|
-
|
|
162
|
+
# Priority 3: Default install location (not through our symlink)
|
|
163
|
+
if [ -z "${found_binary}" ]; then
|
|
164
|
+
local default_loc="${HOME}/.local/share/claude/versions"
|
|
165
|
+
# Check if this is a real directory, not our symlink
|
|
166
|
+
if [ -d "${default_loc}" ] && [ ! -L "${default_loc}" ]; then
|
|
167
|
+
local ver=$(ls -1 "${default_loc}" 2>/dev/null | grep -v '^\.' | sort -V | tail -n1)
|
|
168
|
+
if [ -n "${ver}" ] && [ -f "${default_loc}/${ver}" ]; then
|
|
169
|
+
found_binary="${default_loc}/${ver}"
|
|
170
|
+
found_version="${ver}"
|
|
171
|
+
fi
|
|
172
|
+
fi
|
|
173
|
+
fi
|
|
174
|
+
|
|
175
|
+
# Return results via global variables
|
|
176
|
+
FOUND_CLAUDE_BINARY="${found_binary}"
|
|
177
|
+
FOUND_CLAUDE_VERSION="${found_version}"
|
|
178
|
+
}
|
|
119
179
|
|
|
120
|
-
|
|
121
|
-
|
|
180
|
+
# Find any existing Claude installation
|
|
181
|
+
find_claude_binary
|
|
182
|
+
|
|
183
|
+
if [ -n "${FOUND_CLAUDE_BINARY}" ]; then
|
|
184
|
+
CLAUDE_BINARY="${FOUND_CLAUDE_BINARY}"
|
|
185
|
+
LATEST_VERSION="${FOUND_CLAUDE_VERSION}"
|
|
186
|
+
|
|
187
|
+
# Ensure binary is in our persistent directory
|
|
188
|
+
if [ ! -f "${CLAUDE_VERSIONS}/${LATEST_VERSION}" ]; then
|
|
189
|
+
cp -p "${CLAUDE_BINARY}" "${CLAUDE_VERSIONS}/${LATEST_VERSION}" 2>/dev/null || true
|
|
190
|
+
chmod 755 "${CLAUDE_VERSIONS}/${LATEST_VERSION}" 2>/dev/null || true
|
|
191
|
+
CLAUDE_BINARY="${CLAUDE_VERSIONS}/${LATEST_VERSION}"
|
|
192
|
+
log "✅ Claude ${LATEST_VERSION} synced to persistent storage"
|
|
193
|
+
fi
|
|
122
194
|
|
|
123
195
|
# Create or update the binary symlink
|
|
124
|
-
if [ ! -L "${LOCAL_BIN}/claude" ] || [ "$(readlink -f "${LOCAL_BIN}/claude")" != "${
|
|
196
|
+
if [ ! -L "${LOCAL_BIN}/claude" ] || [ "$(readlink -f "${LOCAL_BIN}/claude")" != "${CLAUDE_VERSIONS}/${LATEST_VERSION}" ]; then
|
|
125
197
|
rm -f "${LOCAL_BIN}/claude" 2>/dev/null || true
|
|
126
|
-
ln -sf "${
|
|
127
|
-
log "✅ Claude binary symlink: ~/.local/bin/claude -> ${
|
|
198
|
+
ln -sf "${CLAUDE_VERSIONS}/${LATEST_VERSION}" "${LOCAL_BIN}/claude"
|
|
199
|
+
log "✅ Claude binary symlink: ~/.local/bin/claude -> ${CLAUDE_VERSIONS}/${LATEST_VERSION}"
|
|
128
200
|
fi
|
|
129
201
|
else
|
|
130
202
|
# Claude not installed - install it
|
|
@@ -132,15 +204,16 @@ else
|
|
|
132
204
|
|
|
133
205
|
# Install Claude Code using the official installer
|
|
134
206
|
if curl -fsSL https://claude.ai/install.sh | bash 2>/dev/null; then
|
|
135
|
-
# After install,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
207
|
+
# After install, find and sync the binary
|
|
208
|
+
find_claude_binary
|
|
209
|
+
if [ -n "${FOUND_CLAUDE_BINARY}" ]; then
|
|
210
|
+
LATEST_VERSION="${FOUND_CLAUDE_VERSION}"
|
|
211
|
+
if [ ! -f "${CLAUDE_VERSIONS}/${LATEST_VERSION}" ]; then
|
|
212
|
+
cp -p "${FOUND_CLAUDE_BINARY}" "${CLAUDE_VERSIONS}/${LATEST_VERSION}" 2>/dev/null || true
|
|
140
213
|
chmod 755 "${CLAUDE_VERSIONS}/${LATEST_VERSION}" 2>/dev/null || true
|
|
141
|
-
ln -sf "${CLAUDE_VERSIONS}/${LATEST_VERSION}" "${LOCAL_BIN}/claude"
|
|
142
|
-
log "✅ Claude Code ${LATEST_VERSION} installed"
|
|
143
214
|
fi
|
|
215
|
+
ln -sf "${CLAUDE_VERSIONS}/${LATEST_VERSION}" "${LOCAL_BIN}/claude"
|
|
216
|
+
log "✅ Claude Code ${LATEST_VERSION} installed"
|
|
144
217
|
fi
|
|
145
218
|
else
|
|
146
219
|
log "❌ Failed to install Claude Code"
|