replit-tools 1.1.1 → 1.1.3
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/index.js +60 -2
- package/package.json +1 -1
- package/scripts/setup-claude-code.sh +41 -1
package/index.js
CHANGED
|
@@ -9,6 +9,11 @@ const WORKSPACE = '/home/runner/workspace';
|
|
|
9
9
|
const HOME = os.homedir();
|
|
10
10
|
const REPLIT_TOOLS = path.join(WORKSPACE, '.replit-tools');
|
|
11
11
|
|
|
12
|
+
// Get version from package.json
|
|
13
|
+
const PACKAGE_JSON = require('./package.json');
|
|
14
|
+
const VERSION = PACKAGE_JSON.version;
|
|
15
|
+
const PACKAGE_NAME = PACKAGE_JSON.name;
|
|
16
|
+
|
|
12
17
|
// Helper to run commands safely without crashing the installer
|
|
13
18
|
function safeExec(cmd, options = {}) {
|
|
14
19
|
try {
|
|
@@ -47,6 +52,24 @@ function safeExec(cmd, options = {}) {
|
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
|
|
55
|
+
// Check for updates from npm
|
|
56
|
+
function checkForUpdates() {
|
|
57
|
+
try {
|
|
58
|
+
const result = spawnSync('npm', ['view', PACKAGE_NAME, 'version'], {
|
|
59
|
+
encoding: 'utf8',
|
|
60
|
+
timeout: 5000,
|
|
61
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
62
|
+
});
|
|
63
|
+
if (result.status === 0 && result.stdout) {
|
|
64
|
+
const latestVersion = result.stdout.trim();
|
|
65
|
+
if (latestVersion && latestVersion !== VERSION) {
|
|
66
|
+
return latestVersion;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} catch {}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
50
73
|
// Helper to migrate data from old location to new
|
|
51
74
|
function migrateDirectory(oldPath, newPath, description) {
|
|
52
75
|
if (fs.existsSync(oldPath) && !fs.existsSync(newPath)) {
|
|
@@ -85,8 +108,16 @@ function main() {
|
|
|
85
108
|
|
|
86
109
|
console.log('');
|
|
87
110
|
console.log('╭─────────────────────────────────────────────────────────╮');
|
|
88
|
-
console.log(
|
|
111
|
+
console.log(`│ DATA Tools v${VERSION.padEnd(44)}│`);
|
|
112
|
+
console.log('│ Claude & Codex Persistence for Replit │');
|
|
89
113
|
console.log('╰─────────────────────────────────────────────────────────╯');
|
|
114
|
+
|
|
115
|
+
// Check for updates
|
|
116
|
+
const latestVersion = checkForUpdates();
|
|
117
|
+
if (latestVersion) {
|
|
118
|
+
console.log(` ⬆️ Update available: v${VERSION} → v${latestVersion}`);
|
|
119
|
+
console.log(` Run: npx -y ${PACKAGE_NAME}@latest`);
|
|
120
|
+
}
|
|
90
121
|
console.log('');
|
|
91
122
|
|
|
92
123
|
// Helper to check if command exists
|
|
@@ -350,6 +381,28 @@ function main() {
|
|
|
350
381
|
} else {
|
|
351
382
|
const version = claudeVersions.sort().pop() || 'installed';
|
|
352
383
|
console.log(`✅ Claude Code already installed (${version})`);
|
|
384
|
+
|
|
385
|
+
// Ensure binary is in our versions directory
|
|
386
|
+
const defaultVersionsDir = path.join(HOME, '.local/share/claude/versions');
|
|
387
|
+
const sourceDirs = [defaultVersionsDir, oldLocations.versions];
|
|
388
|
+
|
|
389
|
+
for (const sourceDir of sourceDirs) {
|
|
390
|
+
try {
|
|
391
|
+
if (fs.existsSync(sourceDir)) {
|
|
392
|
+
const versions = fs.readdirSync(sourceDir).filter(f => !f.startsWith('.'));
|
|
393
|
+
versions.forEach(v => {
|
|
394
|
+
const src = path.join(sourceDir, v);
|
|
395
|
+
const dest = path.join(claudeVersionsDir, v);
|
|
396
|
+
if (!fs.existsSync(dest) && fs.existsSync(src)) {
|
|
397
|
+
try {
|
|
398
|
+
fs.copyFileSync(src, dest);
|
|
399
|
+
fs.chmodSync(dest, '755');
|
|
400
|
+
} catch {}
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
} catch {}
|
|
405
|
+
}
|
|
353
406
|
}
|
|
354
407
|
|
|
355
408
|
// ═══════════════════════════════════════════════════════════════════
|
|
@@ -643,10 +696,15 @@ alias claude-pick='claude -r --dangerously-skip-permissions'
|
|
|
643
696
|
// SHOW COMPLETION MESSAGE
|
|
644
697
|
// ═══════════════════════════════════════════════════════════════════
|
|
645
698
|
|
|
699
|
+
// Save version info for setup script to read
|
|
700
|
+
try {
|
|
701
|
+
fs.writeFileSync(path.join(REPLIT_TOOLS, '.version'), VERSION);
|
|
702
|
+
} catch {}
|
|
703
|
+
|
|
646
704
|
console.log('');
|
|
647
705
|
console.log('╔═════════════════════════════════════════════════════════════╗');
|
|
648
706
|
console.log('║ ║');
|
|
649
|
-
console.log(
|
|
707
|
+
console.log(`║ ✅ DATA Tools v${VERSION} Installation Complete!`.padEnd(62) + '║');
|
|
650
708
|
console.log('║ ║');
|
|
651
709
|
console.log('╠═════════════════════════════════════════════════════════════╣');
|
|
652
710
|
console.log('║ ║');
|
package/package.json
CHANGED
|
@@ -31,6 +31,10 @@ CLAUDE_SYMLINK="${HOME}/.claude"
|
|
|
31
31
|
LOCAL_BIN="${HOME}/.local/bin"
|
|
32
32
|
LOCAL_SHARE_CLAUDE="${HOME}/.local/share/claude"
|
|
33
33
|
|
|
34
|
+
# Version file
|
|
35
|
+
VERSION_FILE="${REPLIT_TOOLS}/.version"
|
|
36
|
+
PACKAGE_NAME="replit-tools"
|
|
37
|
+
|
|
34
38
|
# Logging helper
|
|
35
39
|
log() {
|
|
36
40
|
if [[ $- == *i* ]]; then
|
|
@@ -38,6 +42,28 @@ log() {
|
|
|
38
42
|
fi
|
|
39
43
|
}
|
|
40
44
|
|
|
45
|
+
# =============================================================================
|
|
46
|
+
# Step 0: Show version and check for updates (only in interactive shells)
|
|
47
|
+
# =============================================================================
|
|
48
|
+
if [[ $- == *i* ]]; then
|
|
49
|
+
CURRENT_VERSION=""
|
|
50
|
+
if [ -f "${VERSION_FILE}" ]; then
|
|
51
|
+
CURRENT_VERSION=$(cat "${VERSION_FILE}" 2>/dev/null)
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
if [ -n "${CURRENT_VERSION}" ]; then
|
|
55
|
+
# Check for updates (with timeout, don't block shell startup)
|
|
56
|
+
LATEST_VERSION=$(timeout 3 npm view "${PACKAGE_NAME}" version 2>/dev/null || echo "")
|
|
57
|
+
|
|
58
|
+
if [ -n "${LATEST_VERSION}" ] && [ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ]; then
|
|
59
|
+
echo "📦 DATA Tools v${CURRENT_VERSION} (update available: v${LATEST_VERSION})"
|
|
60
|
+
echo " Run: npx -y ${PACKAGE_NAME}@latest"
|
|
61
|
+
else
|
|
62
|
+
echo "📦 DATA Tools v${CURRENT_VERSION}"
|
|
63
|
+
fi
|
|
64
|
+
fi
|
|
65
|
+
fi
|
|
66
|
+
|
|
41
67
|
# =============================================================================
|
|
42
68
|
# Step 1: Ensure persistent directories exist
|
|
43
69
|
# =============================================================================
|
|
@@ -71,6 +97,21 @@ fi
|
|
|
71
97
|
# =============================================================================
|
|
72
98
|
# Step 4: Find latest Claude version and create binary symlink
|
|
73
99
|
# =============================================================================
|
|
100
|
+
|
|
101
|
+
# First, sync any versions from default location to our directory
|
|
102
|
+
DEFAULT_VERSIONS="${HOME}/.local/share/claude/versions"
|
|
103
|
+
if [ -d "${DEFAULT_VERSIONS}" ]; then
|
|
104
|
+
for version_file in "${DEFAULT_VERSIONS}"/*; do
|
|
105
|
+
if [ -f "${version_file}" ]; then
|
|
106
|
+
version_name=$(basename "${version_file}")
|
|
107
|
+
if [ ! -f "${CLAUDE_VERSIONS}/${version_name}" ]; then
|
|
108
|
+
cp -p "${version_file}" "${CLAUDE_VERSIONS}/${version_name}" 2>/dev/null || true
|
|
109
|
+
chmod 755 "${CLAUDE_VERSIONS}/${version_name}" 2>/dev/null || true
|
|
110
|
+
fi
|
|
111
|
+
fi
|
|
112
|
+
done
|
|
113
|
+
fi
|
|
114
|
+
|
|
74
115
|
LATEST_VERSION=""
|
|
75
116
|
if [ -d "${CLAUDE_VERSIONS}" ]; then
|
|
76
117
|
LATEST_VERSION=$(ls -1 "${CLAUDE_VERSIONS}" 2>/dev/null | grep -v '^\.' | sort -V | tail -n1)
|
|
@@ -92,7 +133,6 @@ else
|
|
|
92
133
|
# Install Claude Code using the official installer
|
|
93
134
|
if curl -fsSL https://claude.ai/install.sh | bash 2>/dev/null; then
|
|
94
135
|
# After install, copy to our versions directory
|
|
95
|
-
DEFAULT_VERSIONS="${HOME}/.local/share/claude/versions"
|
|
96
136
|
if [ -d "${DEFAULT_VERSIONS}" ]; then
|
|
97
137
|
LATEST_VERSION=$(ls -1 "${DEFAULT_VERSIONS}" 2>/dev/null | grep -v '^\.' | sort -V | tail -n1)
|
|
98
138
|
if [ -n "${LATEST_VERSION}" ]; then
|