@nolimitcli/cli 1.0.0 → 1.1.0

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.
Files changed (2) hide show
  1. package/dist/index.js +42 -38
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ const program = new Command();
17
17
  program
18
18
  .name('nolimit')
19
19
  .description('No subscription. Just code.')
20
- .version('1.0.0');
20
+ .version('1.1.0');
21
21
  // Auth command - register and get API key
22
22
  program
23
23
  .command('auth')
@@ -68,6 +68,13 @@ program
68
68
  }
69
69
  const spinner = ora('Requesting ad...').start();
70
70
  try {
71
+ // Get starting balance
72
+ const balanceResponse = await fetch(`${API_BASE}/api/credits/balance`, {
73
+ headers: { 'Authorization': `Bearer ${apiKey}` },
74
+ });
75
+ const startBalance = balanceResponse.ok
76
+ ? (await balanceResponse.json()).balance
77
+ : 0;
71
78
  // Request ad
72
79
  const adResponse = await fetch(`${API_BASE}/api/ads/request`, {
73
80
  method: 'GET',
@@ -86,42 +93,39 @@ program
86
93
  console.log();
87
94
  // Open ad viewer in browser
88
95
  const adUrl = `${API_BASE}/ad-viewer.html?adId=${adData.adId}&apiKey=${apiKey}`;
89
- console.log(chalk.dim('Opening ad in browser...'));
90
96
  await open(adUrl);
91
- // Wait for user to complete ad
92
- console.log();
93
- console.log(chalk.yellow('Complete the ad in your browser.'));
94
- console.log(chalk.dim('Press Enter when done...'));
95
- await new Promise((resolve) => {
96
- process.stdin.once('data', () => resolve());
97
- });
98
- // Verify completion
99
- const verifySpinner = ora('Verifying...').start();
100
- const verifyResponse = await fetch(`${API_BASE}/api/ads/verify-completion`, {
101
- method: 'POST',
102
- headers: {
103
- 'Content-Type': 'application/json',
104
- 'Authorization': `Bearer ${apiKey}`,
105
- },
106
- body: JSON.stringify({
107
- adId: adData.adId,
108
- completedAt: Date.now(),
109
- events: [
110
- { event: 'play', time: 0 },
111
- { event: 'midpoint', time: Math.floor(adData.duration / 2) },
112
- { event: 'complete', time: adData.duration },
113
- ],
114
- }),
115
- });
116
- if (!verifyResponse.ok) {
117
- const errorData = await verifyResponse.json().catch(() => ({}));
118
- throw new Error(errorData.error || `Verification failed: ${verifyResponse.status}`);
97
+ // Auto-poll for completion (no manual Enter needed)
98
+ const waitSpinner = ora('Watching ad...').start();
99
+ let attempts = 0;
100
+ const maxAttempts = 60; // 60 seconds max wait
101
+ while (attempts < maxAttempts) {
102
+ await new Promise(resolve => setTimeout(resolve, 1000));
103
+ attempts++;
104
+ // Update spinner with countdown
105
+ const remaining = adData.duration - Math.min(attempts, adData.duration);
106
+ if (remaining > 0) {
107
+ waitSpinner.text = `${remaining}s remaining...`;
108
+ }
109
+ else {
110
+ waitSpinner.text = 'Verifying...';
111
+ }
112
+ // Check if balance increased (ad completed)
113
+ const checkResponse = await fetch(`${API_BASE}/api/credits/balance`, {
114
+ headers: { 'Authorization': `Bearer ${apiKey}` },
115
+ });
116
+ if (checkResponse.ok) {
117
+ const newData = await checkResponse.json();
118
+ if (newData.balance > startBalance) {
119
+ waitSpinner.succeed(chalk.green('Tokens earned!'));
120
+ console.log();
121
+ console.log(chalk.bold.green(`+${(newData.balance - startBalance).toLocaleString()}`), 'tokens');
122
+ console.log(chalk.dim('Balance:'), chalk.bold(newData.balance.toLocaleString()), chalk.dim('(~' + Math.floor(newData.balance / 1500) + ' prompts)'));
123
+ return;
124
+ }
125
+ }
119
126
  }
120
- const verifyData = await verifyResponse.json();
121
- verifySpinner.succeed(chalk.green('Tokens earned'));
122
- console.log();
123
- console.log(chalk.bold.green(`+${verifyData.tokensGranted.toLocaleString()}`), 'tokens');
124
- console.log(chalk.dim('New balance:'), chalk.bold(verifyData.newBalance.toLocaleString()));
127
+ waitSpinner.fail('Timed out waiting for ad completion');
128
+ console.log(chalk.dim('Try running'), chalk.cyan('nolimit earn'), chalk.dim('again'));
125
129
  }
126
130
  catch (error) {
127
131
  spinner.fail(chalk.red('Failed'));
@@ -151,10 +155,10 @@ program
151
155
  const data = await response.json();
152
156
  spinner.succeed('Balance');
153
157
  console.log();
154
- console.log(chalk.bold.white(data.balance.toLocaleString()), 'tokens');
158
+ console.log(chalk.bold.white(data.balance.toLocaleString()), 'tokens', chalk.dim('(~' + Math.floor(data.balance / 1500) + ' prompts)'));
155
159
  console.log();
156
- console.log(chalk.dim('Total earned:'), data.totalEarned.toLocaleString());
157
- console.log(chalk.dim('Total spent:'), data.totalSpent.toLocaleString());
160
+ console.log(chalk.dim('Earned:'), data.totalEarned.toLocaleString());
161
+ console.log(chalk.dim('Spent:'), data.totalSpent.toLocaleString());
158
162
  }
159
163
  catch (error) {
160
164
  spinner.fail(chalk.red('Failed'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolimitcli/cli",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "description": "No subscription. Just code. Watch an ad, build without limits.",
6
6
  "main": "dist/index.js",