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 +1 -1
- package/bin/index.js +42 -32
- package/commands/commons.js +16 -1
- package/package.json +1 -1
package/README.md
CHANGED
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
+
});
|
package/commands/commons.js
CHANGED
|
@@ -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
|
+
}
|