Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/implion'
Browse files Browse the repository at this point in the history
# Conflicts:
#	docker/docker-compose.yml
  • Loading branch information
zakiso committed Apr 30, 2019
2 parents 8b6e50d + 7eb4a82 commit 8ccfc8d
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 22 deletions.
2 changes: 1 addition & 1 deletion server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const common = {
dbUser: process.env.FABU_DBUSER || undefined, //数据库用户 (没有开启mongodb用户认证的可以不填写)
dbPass: process.env.FABU_DBPWD || undefined, //数据库密码 (没有开启mongodb用户认证的可以不填写)
dbName: process.env.FABU_DB_NAME || "fabulove", //数据库名称
dbHost: process.env.FABU_DB_HOST || "localhost", //数据库地址
dbHost: process.env.FABU_DB_HOST || "0.0.0.0", //数据库地址
dbPort: process.env.FABU_DB_PORT || "27017", //数据库端口

emailService: process.env.FABU_EMAIL_SERVICE || "qq", //邮件相关配置 用于找回密码和邀请团队成员发送邮件
Expand Down
95 changes: 74 additions & 21 deletions server/controllers/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ async function extractIpaIcon(filename, guid, team) {
.on('finish', resolve)
}
})
}).catch({

})

if (!found) {
Expand Down Expand Up @@ -276,37 +278,68 @@ async function extractIpaIcon(filename, guid, team) {
}

///解析apk
function parseApk(filename) {
function parseApk(filename) {

const parser = new AppInfoParser(filename)


return new Promise((resolve, reject) => {
apkParser3(filename, (err, data) => {
var apkPackage = parseText(data.package)
console.log(data)
console.log("----------------")
console.log(data['application-label'])
parser.parse().then(result => {
// console.log('app info ----> ', result)
// console.log('icon base64 ----> ', result.icon)
// console.log('====================================', JSON.stringify(result));
var label = undefined
data['launchable-activity']
.split(' ')
.filter(s => s.length != 0)
.map(element => { return element.split('=') })
.forEach(element => {
if (element && element.length > 2 && element[0] == 'label') {
label = element[1]
}
})

if(result.application && result.application.label && result.application.label.length > 0) {
label = result.application.label[0]
}

if (label) {
label = label.replace(/'/g, '')
}
var appName = (data['application-label'] || data['application-label-zh-CN'] || data['application-label-es-US'] ||
data['application-label-zh_CN'] || data['application-label-es_US'] || label || 'unknown')
var appName = (result['application-label'] || result['application-label-zh-CN'] || result['application-label-es-US'] ||
result['application-label-zh_CN'] || result['application-label-es_US'] || label || 'unknown')

var info = {
'appName': appName.replace(/'/g, ''),
'versionCode': Number(apkPackage.versionCode),
'bundleId': apkPackage.name,
'versionStr': apkPackage.versionName,
'versionCode': Number(result.versionCode),
'bundleId': result.package,
'versionStr': result.versionName,
'platform': 'android'
}
resolve(info)
})
}).catch(err => {
console.log('err ----> ', err)
})
// apkParser3(filename, (err, data) => {
// var apkPackage = parseText(data.package)
// console.log(data)
// console.log("----------------")
// console.log(data['application-label'])
// var label = undefined
// data['launchable-activity']
// .split(' ')
// .filter(s => s.length != 0)
// .map(element => { return element.split('=') })
// .forEach(element => {
// if (element && element.length > 2 && element[0] == 'label') {
// label = element[1]
// }
// })
// if (label) {
// label = label.replace(/'/g, '')
// }
// var appName = (data['application-label'] || data['application-label-zh-CN'] || data['application-label-es-US'] ||
// data['application-label-zh_CN'] || data['application-label-es_US'] || label || 'unknown')
// var info = {
// 'appName': appName.replace(/'/g, ''),
// 'versionCode': Number(apkPackage.versionCode),
// 'bundleId': apkPackage.name,
// 'versionStr': apkPackage.versionName,
// 'platform': 'android'
// }
// resolve(info)
// })
})
}

Expand Down Expand Up @@ -335,6 +368,25 @@ function extractApkIcon(filepath, guid, team) {
var { ext, dir } = path.parse(iconPath);
// 获取到最大的png的路径
let maxSizePath;
// if (ext === '.xml') {

// } else {
// fs.createReadStream(filepath)
// .pipe(unzip.Parse())
// .pipe(etl.map(entry => {
// // 适配iconPath为ic_launcher.xml的情况
// const entryPath = entry.path
// // const isXml = entryPath.indexOf('.xml') >= 0
// // if ( (!isXml && entryPath.indexOf(iconPath) != -1) || (isXml && entry.path.indexOf(maxSizePath) != -1)) {
// // console.log(entry.path)
// entry.pipe(etl.toFile(tempOut))
// resolve({ 'success': true, fileName: realPath })
// // } else {
// // entry.autodrain()
// // }
// }))
// }

const initialPromise = ext === '.xml' ?
unzip.Open.file(filepath).then(directory => {
const getMaxSizeImagePath = compose(get('path'), maxBy('compressedSize'),
Expand All @@ -353,6 +405,7 @@ function extractApkIcon(filepath, guid, team) {
entry.pipe(etl.toFile(tempOut))
resolve({ 'success': true, fileName: realPath })
} else {
resolve({ 'success': true, fileName: realPath })
entry.autodrain()
}
}))
Expand Down
9 changes: 9 additions & 0 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"mongoose": "^5.4.19",
"jsonwebtoken": "^8.5.0",
"unzipper": "^0.9.3",
"unzip-stream": "^0.3.0",
"lodash": "^4.17.4",
"pm2": "^2.9.3",
"uuid": "^3.2.1",
Expand Down

0 comments on commit 8ccfc8d

Please sign in to comment.