puter-cli 1.1.0 → 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.
@@ -0,0 +1,36 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: 20
18
+ - run: npm ci
19
+ - run: npm test
20
+
21
+ publish-gpr:
22
+ needs: build
23
+ runs-on: ubuntu-latest
24
+ permissions:
25
+ contents: read
26
+ packages: write
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: actions/setup-node@v4
30
+ with:
31
+ node-version: 20
32
+ registry-url: https://npm.pkg.github.com/
33
+ - run: npm ci
34
+ - run: npm publish
35
+ env:
36
+ NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Puter-CLI
2
2
 
3
+ <p align="center">
4
+ <img alt="test" src="https://github.com/bitsnaps/puter-cli/actions/workflows/npm-publish-github-packages.yml/badge.svg">
5
+ <img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/bitsnaps/puter-cli">
6
+ </p>
7
+
8
+
3
9
  The **Puter CLI** is a command-line interface tool designed to interact with the **Puter Cloud Platform**. If you don't have an account you can [Signup](https://puter.com/?r=N5Y0ZYTF) from here for free. This cli tool allows users to manage files, directories, applications, and other resources directly from the terminal. This tool is ideal for developers and power users who prefer working with command-line utilities.
4
10
 
5
11
 
@@ -33,7 +39,7 @@ npm install -g puter-cli
33
39
 
34
40
  Execute the following command to check the installation process:
35
41
  ```bash
36
- puter help
42
+ puter --version
37
43
  ```
38
44
 
39
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.0",
3
+ "version": "1.1.2",
4
4
  "description": "Command line interface for Puter cloud platform",
5
5
  "main": "index.js",
6
6
  "bin": {