puter-cli 1.8.0 → 1.8.1

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/CHANGELOG.md CHANGED
@@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [v1.8.1](https://github.com/HeyPuter/puter-cli/compare/v1.8.0...v1.8.1)
8
+
9
+ - fix: better version status handling and error resilience [`ab467e8`](https://github.com/HeyPuter/puter-cli/commit/ab467e8e57cb4f82619424b12136724904df0302)
10
+
7
11
  #### [v1.8.0](https://github.com/HeyPuter/puter-cli/compare/v1.7.3...v1.8.0)
8
12
 
13
+ > 2 April 2025
14
+
9
15
  - feat(files): add edit command to modify remote files with local editor [`220b07c`](https://github.com/HeyPuter/puter-cli/commit/220b07c79fa9e9ab2e0e668cfbd7e5260c9746a2)
10
16
 
11
17
  #### [v1.7.3](https://github.com/HeyPuter/puter-cli/compare/v1.7.2...v1.7.3)
package/README.md CHANGED
@@ -135,7 +135,7 @@ P.S. These commands consider the current directory as the base path for every op
135
135
  ```
136
136
  P.S. The `--delete` flag removes files in the remote directory that don't exist locally. The `-r` flag enables recursive synchronization of subdirectories.
137
137
 
138
- **Edit a file**: Edit remote text files using your preferred local text editor.
138
+ - **Edit a file**: Edit remote text files using your preferred local text editor.
139
139
  ```bash
140
140
  puter> edit <file>
141
141
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "puter-cli",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Command line interface for Puter cloud platform",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/commons.js CHANGED
@@ -345,16 +345,46 @@ export async function getVersionFromPackage() {
345
345
  * Get latest package info from npm registery
346
346
  */
347
347
  export async function getLatestVersion(packageName) {
348
+ let currentVersion = 'unknown';
349
+ let latestVersion = null;
350
+ let status = 'offline'; // Default status
351
+
348
352
  try {
349
- const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
350
- let data = await response.json();
351
- const currentVersion = await getVersionFromPackage();
352
- if (data.version !== currentVersion){
353
- return `v${currentVersion} (latest: ${data.version})`;
354
- }
355
- return `v${currentVersion}`;
353
+ // Attempt to get the current version first
354
+ currentVersion = await getVersionFromPackage();
355
+ if (!currentVersion) {
356
+ currentVersion = 'unknown'; // Fallback if local version fetch fails
357
+ }
358
+
359
+ // Attempt to fetch the latest version from npm
360
+ try {
361
+ const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
362
+ if (response.ok) {
363
+ const data = await response.json();
364
+ latestVersion = data.version;
365
+ }
366
+ } catch (fetchError) {
367
+ // Ignore fetch errors
368
+ // console.warn(chalk.yellow(`Could not fetch latest version for ${packageName}: ${fetchError.message}`));
369
+ }
370
+
371
+ // Determine the status based on fetched versions
372
+ if (latestVersion) {
373
+ if (currentVersion !== 'unknown' && latestVersion === currentVersion) {
374
+ status = 'up-to-date';
375
+ } else if (currentVersion !== 'unknown' && latestVersion !== currentVersion) {
376
+ status = `latest: ${latestVersion}`;
377
+ } else {
378
+ // If currentVersion is unknown but we got latest, show latest
379
+ status = `latest: ${latestVersion}`;
380
+ }
381
+ }
382
+ // status remains 'offline'...
383
+
356
384
  } catch (error) {
357
- console.error(`ERROR: ${error.message}`);
358
- return "<Unknown>";
385
+ // Catch errors from getVersionFromPackage or other unexpected issues
386
+ console.error(chalk.red(`Error determining version status: ${error.message}`));
387
+ status = 'error'; // Indicate an error occurred
359
388
  }
360
- }
389
+ return `v${currentVersion} (${status})`;
390
+ }