@juuno-sdk/cli 1.0.7 → 1.0.8
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/bin/cli-router.js +94 -0
- package/package.json +3 -2
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared CLI command routing logic.
|
|
3
|
+
* Used by both cli.js (production) and cli-dev.js (development).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Helper function to parse auth options from args.
|
|
8
|
+
*/
|
|
9
|
+
export function parseAuthOptions(args) {
|
|
10
|
+
const emailIndex = args.indexOf('--email');
|
|
11
|
+
const passwordIndex = args.indexOf('--password');
|
|
12
|
+
const tokenIndex = args.indexOf('--token');
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
email: emailIndex !== -1 ? args[emailIndex + 1] : undefined,
|
|
16
|
+
password: passwordIndex !== -1 ? args[passwordIndex + 1] : undefined,
|
|
17
|
+
token: tokenIndex !== -1 ? args[tokenIndex + 1] : undefined,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Execute a CLI command with the given import prefix.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} command - The command to execute
|
|
25
|
+
* @param {string[]} args - Command arguments
|
|
26
|
+
* @param {string} importPrefix - Path prefix for imports (e.g., '../src/' or '../dist/cli/src/')
|
|
27
|
+
* @returns {Promise<number>} Exit code (0 for success, 1 for error)
|
|
28
|
+
*/
|
|
29
|
+
export async function runCommand(command, args, importPrefix) {
|
|
30
|
+
try {
|
|
31
|
+
// Handle login command.
|
|
32
|
+
if (command === 'login') {
|
|
33
|
+
const { login } = await import(`${importPrefix}login/index.js`);
|
|
34
|
+
const authOptions = parseAuthOptions(args);
|
|
35
|
+
await login({ email: authOptions.email, password: authOptions.password });
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Handle logout command.
|
|
40
|
+
if (command === 'logout') {
|
|
41
|
+
const { logout } = await import(`${importPrefix}logout/index.js`);
|
|
42
|
+
await logout();
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Handle whoami command.
|
|
47
|
+
if (command === 'whoami') {
|
|
48
|
+
const { whoami } = await import(`${importPrefix}whoami/index.js`);
|
|
49
|
+
await whoami();
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Handle deploy command.
|
|
54
|
+
if (command === 'deploy') {
|
|
55
|
+
const { deployApp } = await import(`${importPrefix}deploy/index.js`);
|
|
56
|
+
const buildDirIndex = args.indexOf('--build-dir');
|
|
57
|
+
const buildDir =
|
|
58
|
+
buildDirIndex !== -1 ? args[buildDirIndex + 1] : './dist';
|
|
59
|
+
const authOptions = parseAuthOptions(args);
|
|
60
|
+
await deployApp({ buildDir, ...authOptions });
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Handle list command.
|
|
65
|
+
if (command === 'list') {
|
|
66
|
+
const { listApps } = await import(`${importPrefix}list/index.js`);
|
|
67
|
+
const authOptions = parseAuthOptions(args);
|
|
68
|
+
await listApps(authOptions);
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Handle info command.
|
|
73
|
+
if (command === 'info') {
|
|
74
|
+
const { getAppInfo } = await import(`${importPrefix}info/index.js`);
|
|
75
|
+
const appId = args[1];
|
|
76
|
+
|
|
77
|
+
if (!appId || appId.startsWith('--')) {
|
|
78
|
+
console.error('Error: App ID is required');
|
|
79
|
+
console.error('Usage: juuno-cli info <app-id> [options]');
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const authOptions = parseAuthOptions(args);
|
|
84
|
+
await getAppInfo({ appId, ...authOptions });
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Command not recognized - return error code.
|
|
89
|
+
return 1;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
// Let errors propagate to the caller for proper handling.
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juuno-sdk/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Official CLI for Juuno external app development - simulator, deployment, and tools",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
|
-
"bin/cli.js"
|
|
12
|
+
"bin/cli.js",
|
|
13
|
+
"bin/cli-router.js"
|
|
13
14
|
],
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|