topnic-https 0.1.10 → 0.2.12
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.js +5 -5
- package/package.json +1 -1
- package/src/sharing/shareManager.js +8 -5
package/bin/cli.js
CHANGED
@@ -51,14 +51,14 @@ program
|
|
51
51
|
.action(async (options) => {
|
52
52
|
try {
|
53
53
|
const share = await shareManager.createShare(options.port, options.duration);
|
54
|
-
console.log('\
|
54
|
+
console.log('\n🌍 مشاركة المشروع');
|
55
55
|
console.log('--------------------------------');
|
56
|
-
console.log(
|
57
|
-
console.log(
|
58
|
-
console.log(
|
56
|
+
console.log(`📎 رابط المشاركة المباشر:`);
|
57
|
+
console.log(`${share.url}`);
|
58
|
+
console.log(`⏱️ مدة المشاركة: ${options.duration} دقيقة`);
|
59
59
|
console.log('--------------------------------\n');
|
60
60
|
} catch (error) {
|
61
|
-
console.error('
|
61
|
+
console.error('❌ فشل إنشاء المشاركة:', error.message);
|
62
62
|
}
|
63
63
|
});
|
64
64
|
|
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
const localtunnel = require('localtunnel');
|
2
|
-
const {
|
2
|
+
const { nanoid } = require('nanoid/non-secure');
|
3
3
|
|
4
4
|
class ShareManager {
|
5
5
|
constructor() {
|
@@ -8,20 +8,23 @@ class ShareManager {
|
|
8
8
|
|
9
9
|
async createShare(port, duration) {
|
10
10
|
try {
|
11
|
-
const tunnel = await localtunnel({
|
12
|
-
|
11
|
+
const tunnel = await localtunnel({
|
12
|
+
port,
|
13
|
+
subdomain: nanoid(6)
|
14
|
+
});
|
15
|
+
|
16
|
+
const shareId = tunnel.url.split('https://')[1].split('.')[0];
|
13
17
|
|
14
18
|
const share = {
|
15
19
|
id: shareId,
|
16
20
|
url: tunnel.url,
|
17
21
|
tunnel,
|
18
22
|
startTime: Date.now(),
|
19
|
-
duration: duration * 60 * 1000
|
23
|
+
duration: duration * 60 * 1000
|
20
24
|
};
|
21
25
|
|
22
26
|
this.activeShares.set(shareId, share);
|
23
27
|
|
24
|
-
// إغلاق المشاركة تلقائياً بعد انتهاء المدة
|
25
28
|
setTimeout(() => {
|
26
29
|
this.closeShare(shareId);
|
27
30
|
}, share.duration);
|