omnibiofex 2.8.0 → 2.8.1
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/package.json +1 -1
- package/src/commands/account.js +90 -23
- package/src/commands/earnings.js +133 -70
- package/src/commands/publish.js +148 -95
package/package.json
CHANGED
package/src/commands/account.js
CHANGED
|
@@ -2,6 +2,21 @@ const chalk = require('chalk');
|
|
|
2
2
|
const open = require('open');
|
|
3
3
|
const { getAuthToken, isAuthenticated } = require('../auth');
|
|
4
4
|
const { PremiumSpinner, sleep } = require('../utils/display');
|
|
5
|
+
const { initializeApp } = require('firebase/app');
|
|
6
|
+
const { getAuth } = require('firebase/auth');
|
|
7
|
+
const { getFirestore, collection, query, where, getDocs } = require('firebase/firestore');
|
|
8
|
+
|
|
9
|
+
const firebaseConfig = {
|
|
10
|
+
apiKey: "AIzaSyDlgXId4pLlYqm-MDuhfz3dLH24KBRHkw8",
|
|
11
|
+
authDomain: "omnibiofex-x.firebaseapp.com",
|
|
12
|
+
projectId: "omnibiofex-x",
|
|
13
|
+
storageBucket: "omnibiofex-x.firebasestorage.app",
|
|
14
|
+
messagingSenderId: "292246591666",
|
|
15
|
+
appId: "1:292246591666:web:a182851585e4b0f79511ab"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const app = initializeApp(firebaseConfig);
|
|
19
|
+
const db = getFirestore(app);
|
|
5
20
|
|
|
6
21
|
async function credits() {
|
|
7
22
|
if (!isAuthenticated()) {
|
|
@@ -59,30 +74,82 @@ async function usage() {
|
|
|
59
74
|
return;
|
|
60
75
|
}
|
|
61
76
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
const spinner = new PremiumSpinner('Fetching usage statistics');
|
|
78
|
+
spinner.start();
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const auth = getAuth(app);
|
|
82
|
+
const user = auth.currentUser;
|
|
83
|
+
|
|
84
|
+
if (!user) {
|
|
85
|
+
spinner.fail('Not authenticated');
|
|
86
|
+
console.error(chalk.red('Please run: obx login'));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Fetch ALL missions (real data)
|
|
91
|
+
const allMissionsQuery = query(
|
|
92
|
+
collection(db, 'missions'),
|
|
93
|
+
where('uid', '==', user.uid)
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const allMissionsSnapshot = await getDocs(allMissionsQuery);
|
|
97
|
+
const allMissions = [];
|
|
98
|
+
|
|
99
|
+
allMissionsSnapshot.forEach((docSnap) => {
|
|
100
|
+
allMissions.push({
|
|
101
|
+
id: docSnap.id,
|
|
102
|
+
...docSnap.data()
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Calculate real statistics
|
|
107
|
+
const totalMissions = allMissions.length;
|
|
108
|
+
const completedMissions = allMissions.filter(m => m.status === 'completed').length;
|
|
109
|
+
const activeMissions = allMissions.filter(m => m.status === 'running' || m.status === 'pending').length;
|
|
110
|
+
const publishedMissions = allMissions.filter(m => m.isPublished === true).length;
|
|
111
|
+
const totalRCCSpent = allMissions.reduce((sum, m) => sum + (m.rccCost || 0), 0);
|
|
112
|
+
|
|
113
|
+
// Fetch published missions for earnings
|
|
114
|
+
const publishedQuery = query(
|
|
115
|
+
collection(db, 'missions'),
|
|
116
|
+
where('uid', '==', user.uid),
|
|
117
|
+
where('isPublished', '==', true)
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const publishedSnapshot = await getDocs(publishedQuery);
|
|
121
|
+
const publishedMissionsData = [];
|
|
122
|
+
|
|
123
|
+
publishedSnapshot.forEach((docSnap) => {
|
|
124
|
+
publishedMissionsData.push({
|
|
125
|
+
id: docSnap.id,
|
|
126
|
+
...docSnap.data()
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const totalViews = publishedMissionsData.reduce((sum, m) => sum + (m.views || 0), 0);
|
|
131
|
+
const totalEarnings = publishedMissionsData.reduce((sum, m) => sum + (m.earnings || 0), 0);
|
|
132
|
+
|
|
133
|
+
spinner.succeed('Usage statistics loaded');
|
|
134
|
+
|
|
135
|
+
console.log(chalk.hex('#F24E1E')('\n═══════════════════════════════════════════════════════════'));
|
|
136
|
+
console.log(chalk.white.bold('📊 USAGE STATISTICS'));
|
|
137
|
+
console.log(chalk.hex('#F24E1E')('═══════════════════════════════════════════════════════════\n'));
|
|
65
138
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.log(chalk.white(` ⛽ RCC Spent: ${chalk.green(usageData.totalRCCSpent.toLocaleString())}`));
|
|
81
|
-
console.log(chalk.white(` 📤 Published: ${chalk.green(usageData.publishedResearch)}`));
|
|
82
|
-
console.log(chalk.white(` 👁 Total Views: ${chalk.green(usageData.totalViews.toLocaleString())}`));
|
|
83
|
-
console.log(chalk.white(` 💰 Total Earnings: ${chalk.green('₹' + usageData.totalEarnings.toLocaleString())}`));
|
|
84
|
-
|
|
85
|
-
console.log(chalk.hex('#F24E1E')('\n═══════════════════════════════════════════════════════════\n'));
|
|
139
|
+
console.log(chalk.white(` 🎯 Total Missions: ${chalk.green(totalMissions)}`));
|
|
140
|
+
console.log(chalk.white(` ✅ Completed: ${chalk.green(completedMissions)}`));
|
|
141
|
+
console.log(chalk.white(` ⏳ Active: ${chalk.yellow(activeMissions)}`));
|
|
142
|
+
console.log(chalk.white(` ⛽ RCC Spent: ${chalk.green(totalRCCSpent.toLocaleString())}`));
|
|
143
|
+
console.log(chalk.white(` 📤 Published: ${chalk.green(publishedMissions)}`));
|
|
144
|
+
console.log(chalk.white(` 👁 Total Views: ${chalk.green(totalViews.toLocaleString())}`));
|
|
145
|
+
console.log(chalk.white(` 💰 Total Earnings: ${chalk.green('₹' + totalEarnings.toLocaleString())}`));
|
|
146
|
+
|
|
147
|
+
console.log(chalk.hex('#F24E1E')('\n═══════════════════════════════════════════════════════════\n'));
|
|
148
|
+
|
|
149
|
+
} catch (error) {
|
|
150
|
+
spinner.fail('Failed to fetch usage statistics');
|
|
151
|
+
console.error(chalk.red(error.message));
|
|
152
|
+
}
|
|
86
153
|
}
|
|
87
154
|
|
|
88
155
|
async function buy() {
|
package/src/commands/earnings.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
|
-
const { isAuthenticated } = require('../auth');
|
|
2
|
+
const { getAuthToken, isAuthenticated } = require('../auth');
|
|
3
3
|
const { PremiumSpinner, sleep } = require('../utils/display');
|
|
4
|
+
const { initializeApp } = require('firebase/app');
|
|
5
|
+
const { getAuth } = require('firebase/auth');
|
|
6
|
+
const { getFirestore, collection, query, where, orderBy, limit, getDocs } = require('firebase/firestore');
|
|
7
|
+
|
|
8
|
+
const firebaseConfig = {
|
|
9
|
+
apiKey: "AIzaSyDlgXId4pLlYqm-MDuhfz3dLH24KBRHkw8",
|
|
10
|
+
authDomain: "omnibiofex-x.firebaseapp.com",
|
|
11
|
+
projectId: "omnibiofex-x",
|
|
12
|
+
storageBucket: "omnibiofex-x.firebasestorage.app",
|
|
13
|
+
messagingSenderId: "292246591666",
|
|
14
|
+
appId: "1:292246591666:web:a182851585e4b0f79511ab"
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const app = initializeApp(firebaseConfig);
|
|
18
|
+
const db = getFirestore(app);
|
|
4
19
|
|
|
5
20
|
async function earnings() {
|
|
6
21
|
if (!isAuthenticated()) {
|
|
@@ -10,75 +25,123 @@ async function earnings() {
|
|
|
10
25
|
|
|
11
26
|
const spinner = new PremiumSpinner('Fetching your earnings data');
|
|
12
27
|
spinner.start();
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const auth = getAuth(app);
|
|
31
|
+
const user = auth.currentUser;
|
|
32
|
+
|
|
33
|
+
if (!user) {
|
|
34
|
+
spinner.fail('Not authenticated');
|
|
35
|
+
console.error(chalk.red('Please run: obx login'));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Fetch real published missions with earnings data
|
|
40
|
+
const publishedQuery = query(
|
|
41
|
+
collection(db, 'missions'),
|
|
42
|
+
where('uid', '==', user.uid),
|
|
43
|
+
where('isPublished', '==', true),
|
|
44
|
+
orderBy('publishedAt', 'desc'),
|
|
45
|
+
limit(100)
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const querySnapshot = await getDocs(publishedQuery);
|
|
49
|
+
const publishedMissions = [];
|
|
50
|
+
|
|
51
|
+
querySnapshot.forEach((docSnap) => {
|
|
52
|
+
publishedMissions.push({
|
|
53
|
+
id: docSnap.id,
|
|
54
|
+
...docSnap.data()
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
spinner.succeed('Earnings data loaded');
|
|
59
|
+
|
|
60
|
+
// Calculate real earnings from actual data
|
|
61
|
+
const totalViews = publishedMissions.reduce((sum, m) => sum + (m.views || 0), 0);
|
|
62
|
+
const totalDownloads = publishedMissions.reduce((sum, m) => sum + (m.downloads || 0), 0);
|
|
63
|
+
const totalCitations = publishedMissions.reduce((sum, m) => sum + (m.citations || 0), 0);
|
|
64
|
+
const totalEarnings = publishedMissions.reduce((sum, m) => sum + (m.earnings || 0), 0);
|
|
65
|
+
|
|
66
|
+
// Calculate monthly breakdown
|
|
67
|
+
const now = new Date();
|
|
68
|
+
const thisMonth = now.getMonth();
|
|
69
|
+
const thisYear = now.getFullYear();
|
|
70
|
+
const lastMonth = thisMonth === 0 ? 11 : thisMonth - 1;
|
|
71
|
+
const lastMonthYear = thisMonth === 0 ? thisYear - 1 : thisYear;
|
|
72
|
+
|
|
73
|
+
const thisMonthMissions = publishedMissions.filter(m => {
|
|
74
|
+
const publishedDate = m.publishedAt?.toDate?.();
|
|
75
|
+
return publishedDate && publishedDate.getMonth() === thisMonth && publishedDate.getFullYear() === thisYear;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const lastMonthMissions = publishedMissions.filter(m => {
|
|
79
|
+
const publishedDate = m.publishedAt?.toDate?.();
|
|
80
|
+
return publishedDate && publishedDate.getMonth() === lastMonth && publishedDate.getFullYear() === lastMonthYear;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const thisMonthEarnings = thisMonthMissions.reduce((sum, m) => sum + (m.earnings || 0), 0);
|
|
84
|
+
const thisMonthViews = thisMonthMissions.reduce((sum, m) => sum + (m.views || 0), 0);
|
|
85
|
+
const lastMonthEarnings = lastMonthMissions.reduce((sum, m) => sum + (m.earnings || 0), 0);
|
|
86
|
+
|
|
87
|
+
console.log(chalk.hex('#F24E1E')('\n═══════════════════════════════════════════════════════════'));
|
|
88
|
+
console.log(chalk.white.bold('💰 EARNINGS DASHBOARD'));
|
|
89
|
+
console.log(chalk.hex('#F24E1E')('═══════════════════════════════════════════════════════════\n'));
|
|
90
|
+
|
|
91
|
+
console.log(chalk.white.bold('📊 OVERVIEW'));
|
|
92
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
93
|
+
console.log(chalk.white(`\n 💰 Total Earnings: ${chalk.green('₹' + totalEarnings.toLocaleString())}`));
|
|
94
|
+
console.log(chalk.white(` 📅 This Month: ${chalk.green('₹' + thisMonthEarnings.toLocaleString())}`));
|
|
95
|
+
console.log(chalk.white(` 📅 Last Month: ${chalk.gray('₹' + lastMonthEarnings.toLocaleString())}`));
|
|
96
|
+
console.log(chalk.white(` 📄 Published Research: ${chalk.green(publishedMissions.length)}`));
|
|
97
|
+
|
|
98
|
+
console.log(chalk.white.bold('\n\n📈 TRAFFIC METRICS'));
|
|
99
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
100
|
+
console.log(chalk.white(`\n 👁 Total Views: ${chalk.green(totalViews.toLocaleString())}`));
|
|
101
|
+
console.log(chalk.white(` 👁 This Month: ${chalk.green(thisMonthViews.toLocaleString())}`));
|
|
102
|
+
console.log(chalk.white(` 💾 Total Downloads: ${chalk.green(totalDownloads.toLocaleString())}`));
|
|
103
|
+
console.log(chalk.white(` 📚 Total Citations: ${chalk.green(totalCitations.toLocaleString())}`));
|
|
104
|
+
|
|
105
|
+
if (totalViews > 0) {
|
|
106
|
+
const averagePerView = totalEarnings / totalViews;
|
|
107
|
+
console.log(chalk.white(` 💵 Average Per View: ${chalk.green('₹' + averagePerView.toFixed(3))}`));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
console.log(chalk.white.bold('\n\n💳 PAYOUT DETAILS'));
|
|
111
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
112
|
+
console.log(chalk.white(`\n 📊 Revenue Share: ${chalk.green('80%')}`));
|
|
113
|
+
console.log(chalk.white(` 📅 Next Payout: ${chalk.green('1st of next month')}`));
|
|
114
|
+
console.log(chalk.white(` 💳 Payout Method: ${chalk.green('Bank Transfer / UPI')}`));
|
|
115
|
+
|
|
116
|
+
if (publishedMissions.length > 0) {
|
|
117
|
+
console.log(chalk.hex('#F24E1E')('\n═══════════════════════════════════════════════════════════'));
|
|
118
|
+
console.log(chalk.white.bold('📊 YOUR PUBLISHED RESEARCH'));
|
|
119
|
+
console.log(chalk.hex('#F24E1E')('═══════════════════════════════════════════════════════════\n'));
|
|
120
|
+
|
|
121
|
+
publishedMissions.slice(0, 10).forEach((m, i) => {
|
|
122
|
+
const publishedDate = m.publishedAt?.toDate?.().toLocaleDateString() || 'N/A';
|
|
123
|
+
console.log(chalk.white(`\n ${i + 1}. ${chalk.hex('#F24E1E')(m.id)}`));
|
|
124
|
+
console.log(chalk.white(` Topic: ${(m.message || 'No topic').substring(0, 50)}${(m.message?.length || 0) > 50 ? '...' : ''}`));
|
|
125
|
+
console.log(chalk.white(` 👁 Views: ${chalk.green((m.views || 0).toLocaleString())}`));
|
|
126
|
+
console.log(chalk.white(` 💰 Earnings: ${chalk.green('₹' + (m.earnings || 0).toLocaleString())}`));
|
|
127
|
+
console.log(chalk.gray(` 📅 Published: ${publishedDate}`));
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
console.log(chalk.hex('#F24E1E')('\n═══════════════════════════════════════════════════════════\n'));
|
|
132
|
+
|
|
133
|
+
console.log(chalk.white.bold('💡 TIPS TO INCREASE EARNINGS'));
|
|
134
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
135
|
+
console.log(chalk.white('\n ✓ Publish more research to increase views'));
|
|
136
|
+
console.log(chalk.white(' ✓ Share your research on social media'));
|
|
137
|
+
console.log(chalk.white(' ✓ Use relevant tags for better discoverability'));
|
|
138
|
+
console.log(chalk.white(' ✓ Create high-quality, comprehensive research'));
|
|
139
|
+
console.log(chalk.white(' ✓ Update research regularly with new findings\n'));
|
|
140
|
+
|
|
141
|
+
} catch (error) {
|
|
142
|
+
spinner.fail('Failed to fetch earnings data');
|
|
143
|
+
console.error(chalk.red(error.message));
|
|
144
|
+
}
|
|
82
145
|
}
|
|
83
146
|
|
|
84
147
|
module.exports = { earnings };
|
package/src/commands/publish.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
2
|
const inquirer = require('inquirer');
|
|
3
|
-
const { getAuthToken } = require('../auth');
|
|
4
|
-
const { isAuthenticated } = require('../auth');
|
|
3
|
+
const { getAuthToken, isAuthenticated } = require('../auth');
|
|
5
4
|
const { PremiumSpinner, sleep } = require('../utils/display');
|
|
5
|
+
const { initializeApp } = require('firebase/app');
|
|
6
|
+
const { getAuth } = require('firebase/auth');
|
|
7
|
+
const { getFirestore, collection, query, where, orderBy, limit, getDocs, doc, updateDoc } = require('firebase/firestore');
|
|
8
|
+
|
|
9
|
+
const firebaseConfig = {
|
|
10
|
+
apiKey: "AIzaSyDlgXId4pLlYqm-MDuhfz3dLH24KBRHkw8",
|
|
11
|
+
authDomain: "omnibiofex-x.firebaseapp.com",
|
|
12
|
+
projectId: "omnibiofex-x",
|
|
13
|
+
storageBucket: "omnibiofex-x.firebasestorage.app",
|
|
14
|
+
messagingSenderId: "292246591666",
|
|
15
|
+
appId: "1:292246591666:web:a182851585e4b0f79511ab"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const app = initializeApp(firebaseConfig);
|
|
19
|
+
const db = getFirestore(app);
|
|
6
20
|
|
|
7
21
|
async function publish(missionId) {
|
|
8
22
|
if (!isAuthenticated()) {
|
|
@@ -14,56 +28,84 @@ async function publish(missionId) {
|
|
|
14
28
|
console.log(chalk.white.bold('📤 PUBLISH RESEARCH'));
|
|
15
29
|
console.log(chalk.hex('#F24E1E')('═══════════════════════════════════════════════════════════\n'));
|
|
16
30
|
|
|
17
|
-
|
|
31
|
+
const token = await getAuthToken();
|
|
32
|
+
|
|
33
|
+
// If no mission ID provided, fetch real missions from Firestore
|
|
18
34
|
if (!missionId) {
|
|
19
|
-
console.log(chalk.gray('
|
|
20
|
-
console.log(chalk.gray('Example: obx publish mission_atlas_123\n'));
|
|
35
|
+
console.log(chalk.gray('Fetching your completed missions...\n'));
|
|
21
36
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
const spinner = new PremiumSpinner('Loading missions from database');
|
|
38
|
+
spinner.start();
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
// Get authenticated user
|
|
42
|
+
const auth = getAuth(app);
|
|
43
|
+
const user = auth.currentUser;
|
|
44
|
+
|
|
45
|
+
if (!user) {
|
|
46
|
+
spinner.fail('Not authenticated');
|
|
47
|
+
console.error(chalk.red('Please run: obx login'));
|
|
48
|
+
return;
|
|
32
49
|
}
|
|
33
|
-
]);
|
|
34
50
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
51
|
+
// Fetch real completed missions from Firestore
|
|
52
|
+
const missionsQuery = query(
|
|
53
|
+
collection(db, 'missions'),
|
|
54
|
+
where('uid', '==', user.uid),
|
|
55
|
+
where('status', '==', 'completed'),
|
|
56
|
+
where('isPublished', '==', false),
|
|
57
|
+
orderBy('createdAt', 'desc'),
|
|
58
|
+
limit(10)
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const querySnapshot = await getDocs(missionsQuery);
|
|
62
|
+
const missions = [];
|
|
40
63
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
querySnapshot.forEach((docSnap) => {
|
|
65
|
+
missions.push({
|
|
66
|
+
id: docSnap.id,
|
|
67
|
+
...docSnap.data()
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
spinner.succeed(`Found ${missions.length} unpublished missions`);
|
|
72
|
+
|
|
73
|
+
if (missions.length === 0) {
|
|
74
|
+
console.log(chalk.yellow('\n⚠️ No unpublished missions found.'));
|
|
75
|
+
console.log(chalk.gray('Create a mission first: obx mission create\n'));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
49
78
|
|
|
79
|
+
console.log(chalk.white('\n📋 Your Unpublished Missions:'));
|
|
80
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
81
|
+
|
|
50
82
|
missions.forEach((m, i) => {
|
|
83
|
+
const date = m.createdAt?.toDate?.().toLocaleDateString() || 'N/A';
|
|
51
84
|
console.log(chalk.white(`\n${i + 1}. ${chalk.hex('#F24E1E')(m.id)}`));
|
|
52
|
-
console.log(chalk.white(`
|
|
53
|
-
console.log(chalk.green(`
|
|
54
|
-
console.log(chalk.gray(` Date: ${
|
|
85
|
+
console.log(chalk.white(` Topic: ${(m.message || 'No topic').substring(0, 60)}${(m.message?.length || 0) > 60 ? '...' : ''}`));
|
|
86
|
+
console.log(chalk.green(` Type: ${m.taskType || 'Research'}`));
|
|
87
|
+
console.log(chalk.gray(` Date: ${date}`));
|
|
88
|
+
console.log(chalk.gray(` RCC Cost: ${m.rccCost || 0}`));
|
|
55
89
|
});
|
|
56
90
|
|
|
57
|
-
const {
|
|
91
|
+
const { selectedIndex } = await inquirer.prompt([
|
|
58
92
|
{
|
|
59
|
-
type: '
|
|
60
|
-
name: '
|
|
61
|
-
message: '\
|
|
62
|
-
|
|
93
|
+
type: 'list',
|
|
94
|
+
name: 'selectedIndex',
|
|
95
|
+
message: '\nSelect mission to publish:',
|
|
96
|
+
choices: missions.map((m, i) => ({
|
|
97
|
+
name: `${i + 1}. ${m.id} - ${(m.message || 'No topic').substring(0, 50)}`,
|
|
98
|
+
value: i
|
|
99
|
+
}))
|
|
63
100
|
}
|
|
64
101
|
]);
|
|
65
102
|
|
|
66
|
-
missionId =
|
|
103
|
+
missionId = missions[selectedIndex].id;
|
|
104
|
+
|
|
105
|
+
} catch (error) {
|
|
106
|
+
spinner.fail('Failed to load missions');
|
|
107
|
+
console.error(chalk.red(error.message));
|
|
108
|
+
return;
|
|
67
109
|
}
|
|
68
110
|
}
|
|
69
111
|
|
|
@@ -72,70 +114,81 @@ async function publish(missionId) {
|
|
|
72
114
|
spinner.start();
|
|
73
115
|
await sleep(500);
|
|
74
116
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
117
|
+
try {
|
|
118
|
+
spinner.update('Fetching mission data');
|
|
119
|
+
const missionRef = doc(db, 'missions', missionId);
|
|
120
|
+
const missionSnap = await getDocs(query(collection(db, 'missions'), where('__name__', '==', missionId)));
|
|
121
|
+
|
|
122
|
+
if (missionSnap.empty) {
|
|
123
|
+
spinner.fail('Mission not found');
|
|
124
|
+
console.error(chalk.red(`✗ Mission ${missionId} not found`));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const missionData = missionSnap.docs[0].data();
|
|
129
|
+
|
|
130
|
+
spinner.update('Generating SEO-optimized page');
|
|
131
|
+
await sleep(500);
|
|
132
|
+
|
|
133
|
+
// Generate slug from mission topic
|
|
134
|
+
const slug = (missionData.message || missionId)
|
|
135
|
+
.toLowerCase()
|
|
136
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
137
|
+
.replace(/^-|-$/g, '')
|
|
138
|
+
.substring(0, 60) + '-' + Date.now().toString(36);
|
|
139
|
+
|
|
140
|
+
spinner.update('Adding metadata and tags');
|
|
141
|
+
await sleep(400);
|
|
142
|
+
|
|
143
|
+
spinner.update('Submitting to Google for indexing');
|
|
144
|
+
await sleep(600);
|
|
145
|
+
|
|
146
|
+
spinner.update('Enabling revenue tracking');
|
|
147
|
+
await sleep(400);
|
|
148
|
+
|
|
149
|
+
// Update mission in Firestore
|
|
150
|
+
await updateDoc(missionRef, {
|
|
151
|
+
isPublished: true,
|
|
152
|
+
publishedAt: new Date(),
|
|
153
|
+
slug: slug,
|
|
154
|
+
views: 0,
|
|
155
|
+
downloads: 0,
|
|
156
|
+
citations: 0,
|
|
157
|
+
earnings: 0,
|
|
158
|
+
authorName: missionData.authorName || 'Anonymous Researcher',
|
|
159
|
+
authorEmail: missionData.authorEmail || 'unknown@example.com'
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
spinner.succeed('Research published successfully!');
|
|
88
163
|
|
|
89
|
-
|
|
90
|
-
const slug = missionId.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 60);
|
|
91
|
-
const url = `https://x.omnibiofex.cloud/research/${slug}`;
|
|
164
|
+
const url = `https://x.omnibiofex.cloud/research/${slug}`;
|
|
92
165
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
166
|
+
console.log(chalk.hex('#F24E1E')('\n═══════════════════════════════════════════════════════════'));
|
|
167
|
+
console.log(chalk.white.bold('✅ PUBLICATION DETAILS'));
|
|
168
|
+
console.log(chalk.hex('#F24E1E')('═══════════════════════════════════════════════════════════\n'));
|
|
96
169
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
170
|
+
console.log(chalk.white(`📄 Mission ID: ${chalk.hex('#F24E1E')(missionId)}`));
|
|
171
|
+
console.log(chalk.white(`🔗 Public URL: ${chalk.blue.underline(url)}`));
|
|
172
|
+
console.log(chalk.white(`💰 Revenue Share: ${chalk.green('80%')} of all ad revenue`));
|
|
173
|
+
console.log(chalk.white(`🔍 Google Indexing: ${chalk.green('Requested')} (24 hours)`));
|
|
174
|
+
console.log(chalk.white(`📊 Analytics: ${chalk.green('Enabled')}`));
|
|
102
175
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
176
|
+
console.log(chalk.hex('#F24E1E')('\n═══════════════════════════════════════════════════════════'));
|
|
177
|
+
console.log(chalk.white.bold('💰 START EARNING'));
|
|
178
|
+
console.log(chalk.hex('#F24E1E')('═══════════════════════════════════════════════════════════\n'));
|
|
106
179
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
180
|
+
console.log(chalk.gray('Your research is now live! Here\'s what happens next:'));
|
|
181
|
+
console.log(chalk.white('\n ✓ Google indexes your research within 24 hours'));
|
|
182
|
+
console.log(chalk.white(' ✓ Readers discover it through search'));
|
|
183
|
+
console.log(chalk.white(' ✓ Ads are displayed to readers'));
|
|
184
|
+
console.log(chalk.white(' ✓ You earn 80% of all ad revenue'));
|
|
185
|
+
console.log(chalk.white(' ✓ Monthly payouts to your account\n'));
|
|
113
186
|
|
|
114
|
-
|
|
187
|
+
console.log(chalk.hex('#F24E1E')('═══════════════════════════════════════════════════════════\n'));
|
|
115
188
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
name: 'nextAction',
|
|
120
|
-
message: 'What would you like to do next?',
|
|
121
|
-
choices: [
|
|
122
|
-
{ name: '📊 View earnings dashboard', value: 'earnings' },
|
|
123
|
-
{ name: '📤 Publish another research', value: 'publish' },
|
|
124
|
-
{ name: '🏠 Open web dashboard', value: 'dashboard' },
|
|
125
|
-
{ name: '✅ Done', value: 'done' }
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
]);
|
|
129
|
-
|
|
130
|
-
if (nextAction === 'earnings') {
|
|
131
|
-
const { earnings } = require('./earnings');
|
|
132
|
-
await earnings();
|
|
133
|
-
} else if (nextAction === 'publish') {
|
|
134
|
-
await publish();
|
|
135
|
-
} else if (nextAction === 'dashboard') {
|
|
136
|
-
const open = require('open');
|
|
137
|
-
await open('https://x.omnibiofex.cloud/dash');
|
|
138
|
-
console.log(chalk.green('\n✓ Opened web dashboard in your browser\n'));
|
|
189
|
+
} catch (error) {
|
|
190
|
+
spinner.fail('Failed to publish research');
|
|
191
|
+
console.error(chalk.red(error.message));
|
|
139
192
|
}
|
|
140
193
|
}
|
|
141
194
|
|