rampup 0.1.10 ā 0.1.12
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 +88 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -28,7 +28,46 @@ const execAsync = promisify(exec);
|
|
|
28
28
|
const __filename = fileURLToPath(import.meta.url);
|
|
29
29
|
const __dirname = path.dirname(__filename);
|
|
30
30
|
|
|
31
|
-
const VERSION = '0.1.
|
|
31
|
+
const VERSION = '0.1.12';
|
|
32
|
+
const PACKAGE_NAME = 'rampup';
|
|
33
|
+
|
|
34
|
+
// Check for updates and auto-update if available
|
|
35
|
+
async function checkForUpdates() {
|
|
36
|
+
try {
|
|
37
|
+
// Check npm registry for latest version
|
|
38
|
+
const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`);
|
|
39
|
+
if (!response.ok) return;
|
|
40
|
+
|
|
41
|
+
const data = await response.json();
|
|
42
|
+
const latestVersion = data.version;
|
|
43
|
+
|
|
44
|
+
if (latestVersion && latestVersion !== VERSION) {
|
|
45
|
+
// Compare versions
|
|
46
|
+
const current = VERSION.split('.').map(Number);
|
|
47
|
+
const latest = latestVersion.split('.').map(Number);
|
|
48
|
+
|
|
49
|
+
const isNewer = latest[0] > current[0] ||
|
|
50
|
+
(latest[0] === current[0] && latest[1] > current[1]) ||
|
|
51
|
+
(latest[0] === current[0] && latest[1] === current[1] && latest[2] > current[2]);
|
|
52
|
+
|
|
53
|
+
if (isNewer) {
|
|
54
|
+
console.log(chalk.yellow(`\nš¦ Update available: ${VERSION} ā ${latestVersion}`));
|
|
55
|
+
console.log(chalk.dim(` Run: npm i -g ${PACKAGE_NAME}\n`));
|
|
56
|
+
|
|
57
|
+
// Auto-update option (uncomment to enable)
|
|
58
|
+
// console.log(chalk.dim(' Updating automatically...'));
|
|
59
|
+
// await execAsync(`npm i -g ${PACKAGE_NAME}`);
|
|
60
|
+
// console.log(chalk.green(' ā Updated! Please restart ramp.\n'));
|
|
61
|
+
// process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
// Silently fail - don't block CLI usage
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Run update check in background (non-blocking)
|
|
70
|
+
checkForUpdates();
|
|
32
71
|
|
|
33
72
|
// ASCII art banner
|
|
34
73
|
const banner = `
|
|
@@ -1126,8 +1165,19 @@ Be friendly, practical, and reference specific files when relevant. If asked abo
|
|
|
1126
1165
|
|
|
1127
1166
|
console.log(chalk.cyan('\nš Ending voice session...'));
|
|
1128
1167
|
console.log(chalk.dim(`Session: ${totalSessionMinutes.toFixed(2)} min`));
|
|
1129
|
-
console.log(chalk.dim(`Total usage: ${usage.totalMinutes.toFixed(2)} min\n`));
|
|
1130
1168
|
|
|
1169
|
+
// Show credits used and remaining
|
|
1170
|
+
try {
|
|
1171
|
+
const balance = await getTokenBalance();
|
|
1172
|
+
if (balance?.balances?.[0]) {
|
|
1173
|
+
const credits = balance.balances[0];
|
|
1174
|
+
const creditsUsed = Math.max(2, Math.ceil(totalSessionMinutes * 4));
|
|
1175
|
+
console.log(chalk.dim(`Credits used: ${creditsUsed}`));
|
|
1176
|
+
console.log(chalk.cyan(`Credits remaining: ${credits.balance}`));
|
|
1177
|
+
}
|
|
1178
|
+
} catch {}
|
|
1179
|
+
|
|
1180
|
+
console.log();
|
|
1131
1181
|
process.exit(0);
|
|
1132
1182
|
}
|
|
1133
1183
|
|
|
@@ -2029,6 +2079,42 @@ program
|
|
|
2029
2079
|
console.log(chalk.green(`ā Logged out from ${user.email}\n`));
|
|
2030
2080
|
});
|
|
2031
2081
|
|
|
2082
|
+
program
|
|
2083
|
+
.command('update')
|
|
2084
|
+
.description('Update Ramp CLI to the latest version')
|
|
2085
|
+
.action(async () => {
|
|
2086
|
+
console.log(banner);
|
|
2087
|
+
console.log(chalk.bold.blue('š¦ Updating Ramp CLI\n'));
|
|
2088
|
+
|
|
2089
|
+
const spinner = ora('Checking for updates...').start();
|
|
2090
|
+
|
|
2091
|
+
try {
|
|
2092
|
+
// Check npm registry for latest version
|
|
2093
|
+
const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`);
|
|
2094
|
+
if (!response.ok) throw new Error('Failed to check npm registry');
|
|
2095
|
+
|
|
2096
|
+
const data = await response.json();
|
|
2097
|
+
const latestVersion = data.version;
|
|
2098
|
+
|
|
2099
|
+
if (latestVersion === VERSION) {
|
|
2100
|
+
spinner.succeed(`Already on latest version (${VERSION})\n`);
|
|
2101
|
+
return;
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
spinner.text = `Updating ${VERSION} ā ${latestVersion}...`;
|
|
2105
|
+
|
|
2106
|
+
// Run npm update
|
|
2107
|
+
await execAsync(`npm i -g ${PACKAGE_NAME}@latest`);
|
|
2108
|
+
|
|
2109
|
+
spinner.succeed(`Updated to ${latestVersion}!\n`);
|
|
2110
|
+
console.log(chalk.green('Please restart ramp to use the new version.\n'));
|
|
2111
|
+
} catch (error) {
|
|
2112
|
+
spinner.fail('Update failed');
|
|
2113
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
2114
|
+
console.log(chalk.dim(`\nTry manually: npm i -g ${PACKAGE_NAME}\n`));
|
|
2115
|
+
}
|
|
2116
|
+
});
|
|
2117
|
+
|
|
2032
2118
|
program
|
|
2033
2119
|
.command('whoami')
|
|
2034
2120
|
.description('Show current logged in user')
|