puter-cli 1.3.0 → 1.4.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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/commons.js +21 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,15 @@ 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.4.0](https://github.com/bitsnaps/puter-cli/compare/v1.3.0...v1.4.0)
|
|
8
|
+
|
|
9
|
+
- offline mode to get version [`d3c1dc2`](https://github.com/bitsnaps/puter-cli/commit/d3c1dc275bf8a1f38f083c8cdb066fb884a08138)
|
|
10
|
+
- changelog: update [`f0cc1e3`](https://github.com/bitsnaps/puter-cli/commit/f0cc1e36b2b246d65a88f32c626942c0e15ac245)
|
|
11
|
+
|
|
7
12
|
#### [v1.3.0](https://github.com/bitsnaps/puter-cli/compare/v1.2.1...v1.3.0)
|
|
8
13
|
|
|
14
|
+
> 22 January 2025
|
|
15
|
+
|
|
9
16
|
- ci: simplify workflow [`757b41c`](https://github.com/bitsnaps/puter-cli/commit/757b41caa62dc71946e7f1ffb34a32f2871248e0)
|
|
10
17
|
- test: setup coverage [`2dd6500`](https://github.com/bitsnaps/puter-cli/commit/2dd650088ad9ecb6f7f9cd60b3dab80d48ac2611)
|
|
11
18
|
- ci: update packages [`b346932`](https://github.com/bitsnaps/puter-cli/commit/b346932c4b6af2d8e43279ad3f35c45e451fd9f0)
|
package/package.json
CHANGED
package/src/commons.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { getAuthToken } from './commands/auth.js';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
3
6
|
|
|
4
7
|
export const PROJECT_NAME = 'puter-cli';
|
|
5
8
|
export const API_BASE = 'https://api.puter.com';
|
|
@@ -296,6 +299,23 @@ export function getDefaultHomePage(appName) {
|
|
|
296
299
|
}
|
|
297
300
|
|
|
298
301
|
|
|
302
|
+
/**
|
|
303
|
+
* Read latest package from package file
|
|
304
|
+
*/
|
|
305
|
+
export async function getVersionFromPackage() {
|
|
306
|
+
try {
|
|
307
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
308
|
+
const __dirname = dirname(__filename);
|
|
309
|
+
const packageJson = JSON.parse(
|
|
310
|
+
await readFile(join(__dirname, 'package.json'), 'utf8')
|
|
311
|
+
);
|
|
312
|
+
return packageJson.version;
|
|
313
|
+
} catch (error) {
|
|
314
|
+
console.error(`Error fetching latest version:`, error.message);
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
299
319
|
/**
|
|
300
320
|
* Get latest package info from npm registery
|
|
301
321
|
*/
|
|
@@ -305,7 +325,6 @@ export async function getLatestVersion(packageName) {
|
|
|
305
325
|
let data = await response.json();
|
|
306
326
|
return data;
|
|
307
327
|
} catch (error) {
|
|
308
|
-
|
|
309
|
-
return null;
|
|
328
|
+
return getVersionFromPackage();
|
|
310
329
|
}
|
|
311
330
|
}
|