puter-cli 1.1.1 → 1.1.2

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/README.md CHANGED
@@ -39,7 +39,7 @@ npm install -g puter-cli
39
39
 
40
40
  Execute the following command to check the installation process:
41
41
  ```bash
42
- puter help
42
+ puter --version
43
43
  ```
44
44
 
45
45
  ## Usage
package/bin/index.js CHANGED
@@ -3,36 +3,46 @@ import { Command } from 'commander';
3
3
  import { login, logout } from '../commands/auth.js';
4
4
  import { init } from '../commands/init.js';
5
5
  import { startShell } from '../commands/shell.js';
6
+ import { PROJECT_NAME, getLatestVersion } from '../commands/commons.js';
6
7
 
7
- const program = new Command();
8
-
9
- program
10
- .name('puter')
11
- .description('CLI tool for Puter cloud platform')
12
- .version('1.0.0');
13
-
14
- program
15
- .command('login')
16
- .description('Login to Puter account')
17
- .action(login);
18
-
19
- program
20
- .command('logout')
21
- .description('Logout from Puter account')
22
- .action(logout);
23
-
24
- program
25
- .command('init')
26
- .description('Initialize a new Puter app')
27
- .action(init);
28
-
29
- program
30
- .command('shell')
31
- .description('Start interactive shell')
32
- .action(startShell);
33
-
34
- if (process.argv.length === 2) {
35
- startShell();
36
- } else {
37
- program.parse();
38
- }
8
+
9
+ async function main() {
10
+ const { version } = await getLatestVersion(PROJECT_NAME);
11
+
12
+ const program = new Command();
13
+ program
14
+ .name(PROJECT_NAME)
15
+ .description('CLI tool for Puter cloud platform')
16
+ .version(version);
17
+
18
+ program
19
+ .command('login')
20
+ .description('Login to Puter account')
21
+ .action(login);
22
+
23
+ program
24
+ .command('logout')
25
+ .description('Logout from Puter account')
26
+ .action(logout);
27
+
28
+ program
29
+ .command('init')
30
+ .description('Initialize a new Puter app')
31
+ .action(init);
32
+
33
+ program
34
+ .command('shell')
35
+ .description('Start interactive shell')
36
+ .action(startShell);
37
+
38
+ if (process.argv.length === 2) {
39
+ startShell();
40
+ } else {
41
+ program.parse();
42
+ }
43
+ }
44
+
45
+ main().catch((err) => {
46
+ console.error(err);
47
+ process.exit(1);
48
+ });
@@ -293,4 +293,19 @@ export function getDefaultHomePage(appName) {
293
293
  </html>`;
294
294
 
295
295
  return defaultIndexContent;
296
- }
296
+ }
297
+
298
+
299
+ /**
300
+ * Get latest package info from npm registery
301
+ */
302
+ export async function getLatestVersion(packageName) {
303
+ try {
304
+ const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
305
+ let data = await response.json();
306
+ return data;
307
+ } catch (error) {
308
+ console.error(`Error fetching latest version for ${packageName}:`, error.message);
309
+ return null;
310
+ }
311
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "puter-cli",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Command line interface for Puter cloud platform",
5
5
  "main": "index.js",
6
6
  "bin": {