lunel-cli 0.1.0
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/dist/index.d.ts +2 -0
- package/dist/index.js +41 -0
- package/package.json +38 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import qrcode from "qrcode-terminal";
|
|
3
|
+
const PROXY_URL = process.env.LUNEL_PROXY_URL || "https://proxy-1.lunel.dev";
|
|
4
|
+
async function createSession() {
|
|
5
|
+
const response = await fetch(`${PROXY_URL}/v1/session`, {
|
|
6
|
+
method: "POST",
|
|
7
|
+
headers: {
|
|
8
|
+
"Content-Type": "application/json",
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error(`Failed to create session: ${response.status}`);
|
|
13
|
+
}
|
|
14
|
+
const data = (await response.json());
|
|
15
|
+
return data.code;
|
|
16
|
+
}
|
|
17
|
+
function displayQR(code) {
|
|
18
|
+
console.log("\n");
|
|
19
|
+
qrcode.generate(code, { small: true }, (qr) => {
|
|
20
|
+
console.log(qr);
|
|
21
|
+
console.log(`\n Session code: ${code}\n`);
|
|
22
|
+
console.log(" Scan the QR code with the Lunel app to connect.\n");
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async function main() {
|
|
26
|
+
console.log("Connecting to Lunel...");
|
|
27
|
+
try {
|
|
28
|
+
const code = await createSession();
|
|
29
|
+
displayQR(code);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error instanceof Error) {
|
|
33
|
+
console.error(`Error: ${error.message}`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.error("An unexpected error occurred");
|
|
37
|
+
}
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lunel-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"author": [
|
|
5
|
+
{
|
|
6
|
+
"name": "Soham Bharambe",
|
|
7
|
+
"email": "soham@lunel.dev"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "Rinkit Adhana",
|
|
11
|
+
"email": "rinkit@lunel.dev"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"license": "Functional Source License, Version 1.1, Apache 2.0 Future License",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"bin": {
|
|
17
|
+
"lunel-cli": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"dev": "tsc && node dist/index.js",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"qrcode-terminal": "^0.12.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^20.0.0",
|
|
32
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
33
|
+
"typescript": "^5.0.0"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|