Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 5e9075d

Browse files
committed
[add] add usage reporter & refactor local db & add tab auto completion
1 parent e162edf commit 5e9075d

117 files changed

Lines changed: 3242 additions & 425 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1

Lines changed: 0 additions & 31 deletions
This file was deleted.

NERD_tree_1

Lines changed: 0 additions & 31 deletions
This file was deleted.

bin/cloudbase.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const address = require('address')
1010
const pkg = require('../package.json')
1111
const store = require('../lib/utils/store')
1212
const { getProxy } = require('../lib/utils/proxy')
13+
const { handleCompletion } = require('../lib/completion')
1314

1415
let processArgv = process.argv
1516
const isBeta = pkg.version.indexOf('-') > -1
@@ -81,9 +82,12 @@ if (processArgv.includes('--tcb-test')) {
8182

8283
// debug 模式
8384
process.IS_DEBUG = processArgv.includes('-debug')
85+
if (processArgv.includes('completion')) {
86+
return handleCompletion()
87+
}
8488

8589
// 需要隐藏的选项
86-
const hideArgs = ['-debug', '--tcb-test']
90+
const hideArgs = ['-debug', '--tcb-test', '--completion']
8791
hideArgs.forEach(arg => {
8892
const index = processArgv.indexOf(arg)
8993
if (index > -1) {
@@ -94,6 +98,8 @@ hideArgs.forEach(arg => {
9498
// 注册命令
9599
require('../lib')
96100

101+
// console.log(Object.keys(program._events))
102+
97103
// 设置 Sentry 上报的用户 uin
98104
Sentry.configureScope(scope => {
99105
try {
@@ -158,7 +164,6 @@ try {
158164
}
159165

160166
function errorHandler(err) {
161-
console.log(err)
162167
process.emit('tcbError')
163168
const stackIngoreErrors = ['TencentCloudSDKHttpException', 'CloudBaseError']
164169
// 忽略自定义错误的错误栈

cloudbase/functions/agree/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const tcb = require('@cloudbase/node-sdk')
2+
3+
const app = tcb.init({
4+
env: 'tcli'
5+
})
6+
7+
class DataSchema {
8+
constructor(data) {
9+
this.ip = data.ip || ''
10+
this.agree = data.agree || false
11+
this.macMd5 = data.macMd5 || ''
12+
this.uin = data.uin || ''
13+
this.os = data.os || ''
14+
this.date = new Date()
15+
}
16+
}
17+
18+
exports.main = async (event = {}) => {
19+
const { headers = {}, body } = event
20+
const ip = headers['x-real-ip'] || ''
21+
22+
const bodyData = JSON.parse(body)
23+
const data = new DataSchema({
24+
...bodyData,
25+
ip
26+
})
27+
28+
const db = app.database()
29+
const collection = db.collection('user-agree')
30+
return collection.add(data)
31+
}

0 commit comments

Comments
 (0)