Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
ff93d531
Commit
ff93d531
authored
Oct 17, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
3d40025c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
185 additions
and
9 deletions
+185
-9
app_build.gradle
+6
-0
python/config.py
+92
-0
python/main.py
+38
-0
python/shell.py
+29
-0
python/utils.py
+11
-0
src/main/AndroidManifest.xml
+9
-9
No files found.
app_build.gradle
View file @
ff93d531
...
...
@@ -10,6 +10,12 @@ android {
buildConfigField
'String'
,
'TONGDUN_PARENT_CODE'
,
'\"\"'
buildConfigField
'String'
,
'TONGDUN_PARENT_KEY'
,
'\"\"'
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"
)
try
{
...
...
python/config.py
0 → 100644
View file @
ff93d531
# -*-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
)
python/main.py
0 → 100644
View file @
ff93d531
# -*-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
python/shell.py
0 → 100644
View file @
ff93d531
# -*-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
)
python/utils.py
0 → 100644
View file @
ff93d531
# -*-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
src/main/AndroidManifest.xml
View file @
ff93d531
...
...
@@ -78,15 +78,15 @@
android:value=
"640"
/>
<!--Facebook AccountKit-->
<
meta-data
android:name=
"com.facebook.accountkit.ApplicationName"
android:value=
"@string/app_name_str"
/
>
<
meta-data
android:name=
"com.facebook.sdk.ApplicationId"
android:value=
"@string/FACEBOOK_APP_ID"
/
>
<
meta-data
android:name=
"com.facebook.accountkit.ClientToken"
android:value=
"@string/ACCOUNT_KIT_CLIENT_TOKEN"
/
>
<
!--<meta-data-->
<!--android:name="com.facebook.accountkit.ApplicationName"-->
<!--android:value="@string/app_name_str" />--
>
<
!--<meta-data-->
<!--android:name="com.facebook.sdk.ApplicationId"-->
<!--android:value="@string/FACEBOOK_APP_ID" />--
>
<
!--<meta-data-->
<!--android:name="com.facebook.accountkit.ClientToken"-->
<!--android:value="@string/ACCOUNT_KIT_CLIENT_TOKEN" />--
>
<activity
android:name=
"com.facebook.accountkit.ui.AccountKitActivity"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment