Commit ff93d531 by sikang

test

parent 3d40025c
...@@ -10,6 +10,12 @@ android { ...@@ -10,6 +10,12 @@ android {
buildConfigField 'String', 'TONGDUN_PARENT_CODE', '\"\"' buildConfigField 'String', 'TONGDUN_PARENT_CODE', '\"\"'
buildConfigField 'String', 'TONGDUN_PARENT_KEY', '\"\"' buildConfigField 'String', 'TONGDUN_PARENT_KEY', '\"\"'
buildConfigField 'String', 'TONGDUN_APP_NAME', '\"\"' buildConfigField 'String', 'TONGDUN_APP_NAME', '\"\"'
buildConfigField 'String', 'FACEBOOK_APP_ID', "\"${facebook_app_id}\""
buildConfigField 'String', 'ACCOUNT_KIT_CLIENT_TOKEN', "\"${account_kit_client_token}\""
resValue('string', 'octopus_open_whatsapp', " Open Whatsapp") resValue('string', 'octopus_open_whatsapp', " Open Whatsapp")
try { try {
......
# -*-coding:utf-8-*-
from utils import Utils
import random
import sys
import os
import re
class BuildConfig:
# 随机生成包名
@staticmethod
def new_appid(app_name):
app_name = app_name.replace(" ", "").lower()
start_name = ["com", "cn", "id", "app", "host", "in"]
middle_name = ["android", "main", "home", "base", "play", "release", "full", "kredit", "cepat",
"saku", "wallet", "coin", "loan", "flash", "pjnm", "indo", "lib"]
# start
pkg_name = start_name[random.randint(
0, len(start_name) - 1)] + "." + app_name
# middle
length = random.randint(1, 3)
for i in range(0, length):
pkg_name += "." + \
middle_name[random.randint(0, len(middle_name) - 1)]
# end
random_str = ''.join(random.sample(
"abcdefghijklmnopqrstuvwxyz", random.randint(4, 8)))
pkg_name += "." + random_str
return pkg_name
# 加载shell变量
@staticmethod
def load_properties(path):
with open(path, "r", encoding="utf-8") as f:
lines = f.readlines()
config = {}
for line in lines:
if "=" in line:
key = Utils.clearStr(line.split("=")[0], ["\"", "\'", "\n"])
value = Utils.clearStr(line.split("=")[1], ["\"", "\'", "\n"])
config[key] = value
return config
# 创建签名文件
@staticmethod
def new_keystore(config):
# 只保留最近10个签名
count = 0
for root, dirs, files in os.walk(config['jks_path']):
for name in files:
count += 1
if count > 10:
os.remove(os.path.join(root, name))
# 创建签名文件
key_name = config['app_name'].replace(" ", "")+config['version_code']
command = "keytool -genkey" + " -alias <key_name> -keypass <key_name> -storepass <key_name>" \
+ " -dname \"CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown\"" \
+ " -keyalg RSA -validity 20000 -keystore <path>/<key_name>.keystore"
command = command.replace("<key_name>", key_name).replace(
"<path>", config["jks_path"])
os.system(command)
# 更新签名配置
jks_path = "%s/%s.keystore" % (config["jks_path"], key_name)
reset = {
"signing_keyAlias": key_name,
"signing_certificate": jks_path,
"signging_certificatePassword": key_name,
"signging_storePassword": key_name,
}
BuildConfig.update_properties(config, reset)
# 更新properties字段
@staticmethod
def update_properties(config, dict):
file_content = ""
replace_line = {}
with open(config['properties'], "r", encoding="utf-8") as f:
file_content = f.read()
for key in dict.keys():
info = re.compile(r''+key+"=(.*)\n")
targetLine = info.search(file_content).group()
newLine = "%s=%s\n" % (key, dict[key])
replace_line[targetLine] = newLine
for key in replace_line.keys():
print(replace_line[key])
file_content = file_content.replace(key, replace_line[key])
with open(config['properties'], "w", encoding="utf-8") as f_w:
f_w.write(file_content)
# -*-coding:utf-8-*-
from config import BuildConfig
from shell import Shell
import os
#properties 配置
config = BuildConfig.load_properties("../../gradle.properties")
config['root'] = "../.."
config['jks_path'] = "../../jks"
config['properties'] = "../../gradle.properties"
print(" ")
print("------------- 使用帮助 -----------------")
print("1、编译apk")
print("2、修改包名,版本号+1")
print("3、创建新的签名文件")
print("4、commit & push project")
print("5、commit & push lib_base")
print(" ")
commod = int(input("请输入指令编号:"))
#命令
if commod == 2:
app_name = BuildConfig.new_appid(config['app_name'])
print(app_name)
elif commod == 3:
BuildConfig.new_keystore(config)
elif commod == 4:
Shell.push_project(config)
elif commod == 5:
Shell.push_base(config)
\ No newline at end of file
# -*-coding:utf-8-*-
import os
class Shell:
#commit&push project
@staticmethod
def push_project(config):
command = "%s\n%s\n%s\n%s\n" \
% (
"cd "+config['root'],
"git add .",
"git commit -m \"%s\"" % (config['app_id'] +" " + config['version_name']),
"git push origin %s" % config['git_branch']
)
os.system(command)
#commit&push lib_base
@staticmethod
def push_base(config):
commit_msg = input("输入commit msg:\n")
command = "%s\n%s\n%s\n%s\n" \
% (
"cd %s/%s"%(config['root'],"lib_base"),
"git add .",
"git commit -m \"%s\"" % commit_msg,
"git push origin master"
)
os.system(command)
# -*-coding:utf-8-*-
import string
import os
class Utils:
@staticmethod
def clearStr(value,targets):
for target in targets:
value = value.replace(target,"")
return value
\ No newline at end of file
...@@ -78,15 +78,15 @@ ...@@ -78,15 +78,15 @@
android:value="640" /> android:value="640" />
<!--Facebook AccountKit--> <!--Facebook AccountKit-->
<meta-data <!--<meta-data-->
android:name="com.facebook.accountkit.ApplicationName" <!--android:name="com.facebook.accountkit.ApplicationName"-->
android:value="@string/app_name_str" /> <!--android:value="@string/app_name_str" />-->
<meta-data <!--<meta-data-->
android:name="com.facebook.sdk.ApplicationId" <!--android:name="com.facebook.sdk.ApplicationId"-->
android:value="@string/FACEBOOK_APP_ID" /> <!--android:value="@string/FACEBOOK_APP_ID" />-->
<meta-data <!--<meta-data-->
android:name="com.facebook.accountkit.ClientToken" <!--android:name="com.facebook.accountkit.ClientToken"-->
android:value="@string/ACCOUNT_KIT_CLIENT_TOKEN" /> <!--android:value="@string/ACCOUNT_KIT_CLIENT_TOKEN" />-->
<activity android:name="com.facebook.accountkit.ui.AccountKitActivity" /> <activity android:name="com.facebook.accountkit.ui.AccountKitActivity" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment