File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 11import chalk from 'chalk' ;
22import { getAuthToken } from './commands/auth.js' ;
3+ import { readFile } from 'fs/promises' ;
4+ import { fileURLToPath } from 'url' ;
5+ import { dirname , join } from 'path' ;
36
47export const PROJECT_NAME = 'puter-cli' ;
58export const API_BASE = 'https://api.puter.com' ;
@@ -296,6 +299,23 @@ export function getDefaultHomePage(appName) {
296299}
297300
298301
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+
299319/**
300320 * Get latest package info from npm registery
301321 */
@@ -305,7 +325,6 @@ export async function getLatestVersion(packageName) {
305325 let data = await response . json ( ) ;
306326 return data ;
307327 } catch ( error ) {
308- console . error ( `Error fetching latest version for ${ packageName } :` , error . message ) ;
309- return null ;
328+ return getVersionFromPackage ( ) ;
310329 }
311330 }
You can’t perform that action at this time.
0 commit comments