replit-tools 1.1.2 → 1.1.4
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 +38 -2
- package/package.json +1 -1
- package/scripts/setup-claude-code.sh +60 -0
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
|
|
@@ -665,10 +696,15 @@ alias claude-pick='claude -r --dangerously-skip-permissions'
|
|
|
665
696
|
// SHOW COMPLETION MESSAGE
|
|
666
697
|
// ═══════════════════════════════════════════════════════════════════
|
|
667
698
|
|
|
699
|
+
// Save version info for setup script to read
|
|
700
|
+
try {
|
|
701
|
+
fs.writeFileSync(path.join(REPLIT_TOOLS, '.version'), VERSION);
|
|
702
|
+
} catch {}
|
|
703
|
+
|
|
668
704
|
console.log('');
|
|
669
705
|
console.log('╔═════════════════════════════════════════════════════════════╗');
|
|
670
706
|
console.log('║ ║');
|
|
671
|
-
console.log(
|
|
707
|
+
console.log(`║ ✅ DATA Tools v${VERSION} Installation Complete!`.padEnd(62) + '║');
|
|
672
708
|
console.log('║ ║');
|
|
673
709
|
console.log('╠═════════════════════════════════════════════════════════════╣');
|
|
674
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,62 @@ log() {
|
|
|
38
42
|
fi
|
|
39
43
|
}
|
|
40
44
|
|
|
45
|
+
# =============================================================================
|
|
46
|
+
# Step 0: Show version, check for updates, and auto-update if available
|
|
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
|
+
|
|
76
|
+
if [[ $- == *i* ]]; then
|
|
77
|
+
CURRENT_VERSION=""
|
|
78
|
+
if [ -f "${VERSION_FILE}" ]; then
|
|
79
|
+
CURRENT_VERSION=$(cat "${VERSION_FILE}" 2>/dev/null)
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
if [ -n "${CURRENT_VERSION}" ]; then
|
|
83
|
+
# Check for updates (with timeout, don't block shell startup)
|
|
84
|
+
LATEST_VERSION=$(timeout 3 npm view "${PACKAGE_NAME}" version 2>/dev/null || echo "")
|
|
85
|
+
|
|
86
|
+
if [ -n "${LATEST_VERSION}" ] && [ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ]; then
|
|
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
|
|
95
|
+
else
|
|
96
|
+
echo "📦 DATA Tools v${CURRENT_VERSION}"
|
|
97
|
+
fi
|
|
98
|
+
fi
|
|
99
|
+
fi
|
|
100
|
+
|
|
41
101
|
# =============================================================================
|
|
42
102
|
# Step 1: Ensure persistent directories exist
|
|
43
103
|
# =============================================================================
|