Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
srvpro
Commits
6ef9511e
Commit
6ef9511e
authored
Jul 28, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add cdn in pre
parent
5a145c57
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
5 deletions
+52
-5
.gitignore
.gitignore
+1
-0
config.json
config.json
+8
-0
ygopro-pre.js
ygopro-pre.js
+43
-5
No files found.
.gitignore
View file @
6ef9511e
...
@@ -12,6 +12,7 @@ config.*.json
...
@@ -12,6 +12,7 @@ config.*.json
/decks_save*
/decks_save*
/node_modules/
/node_modules/
/ssl
/ssl
/ygosrv233
test*
test*
*.heapsnapshot
*.heapsnapshot
...
...
config.json
View file @
6ef9511e
...
@@ -95,6 +95,14 @@
...
@@ -95,6 +95,14 @@
"db_path"
:
"../ygopro-pre-data/unofficial/"
,
"db_path"
:
"../ygopro-pre-data/unofficial/"
,
"html_img_rel_path"
:
"pre/pics/"
,
"html_img_rel_path"
:
"pre/pics/"
,
"html_img_thumbnail"
:
"thumbnail/"
,
"html_img_thumbnail"
:
"thumbnail/"
,
"cdn"
:
{
"enabled"
:
false
,
"exe"
:
"upx"
,
"params"
:
[
"sync"
],
"local"
:
"./ygosrv233"
,
"remote"
:
"/ygosrv233"
,
"pics_remote"
:
"/ygopro/"
},
"ygopro_path"
:
"../ygopro-pre/"
,
"ygopro_path"
:
"../ygopro-pre/"
,
"only_show_dbs"
:
{
"only_show_dbs"
:
{
"news.cdb"
:
true
,
"news.cdb"
:
true
,
...
...
ygopro-pre.js
View file @
6ef9511e
...
@@ -206,7 +206,9 @@ var writeToFile = function(message) {
...
@@ -206,7 +206,9 @@ var writeToFile = function(message) {
}
}
fs
.
writeFileSync
(
config
.
html_path
+
config
.
html_filename
,
fileContent
);
fs
.
writeFileSync
(
config
.
html_path
+
config
.
html_filename
,
fileContent
);
sendResponse
(
"
列表更新完成。
"
);
sendResponse
(
"
列表更新完成。
"
);
copyImages
();
if
(
!
config
.
cdn
.
enabled
)
{
copyImages
();
}
}
}
//读取指定文件夹里所有数据库,异步
//读取指定文件夹里所有数据库,异步
...
@@ -251,6 +253,13 @@ var fetchDatas = function() {
...
@@ -251,6 +253,13 @@ var fetchDatas = function() {
//更新本地网页到服务器,异步
//更新本地网页到服务器,异步
var
pushDatas
=
function
()
{
var
pushDatas
=
function
()
{
if
(
config
.
cdn
.
enabled
)
{
uploadCDN
(
config
.
cdn
.
local
,
config
.
cdn
.
remote
,
function
()
{
uploadCDN
(
config
.
db_path
+
"
pics
"
,
config
.
cdn
.
pics_remote
+
"
pics
"
,
function
()
{
sendResponse
(
"
CDN上传全部完成。
"
);
});
});
}
try
{
try
{
execSync
(
'
git add --all .
'
,
{
cwd
:
config
.
git_html_path
,
env
:
process
.
env
});
execSync
(
'
git add --all .
'
,
{
cwd
:
config
.
git_html_path
,
env
:
process
.
env
});
execSync
(
'
git commit -m update-auto
'
,
{
cwd
:
config
.
git_html_path
,
env
:
process
.
env
});
execSync
(
'
git commit -m update-auto
'
,
{
cwd
:
config
.
git_html_path
,
env
:
process
.
env
});
...
@@ -280,6 +289,31 @@ var pushDatas = function() {
...
@@ -280,6 +289,31 @@ var pushDatas = function() {
}
}
}
}
//上传到CDN,异步
var
uploadCDN
=
function
(
local
,
remote
,
callback
)
{
sendResponse
(
"
CDN
"
+
remote
+
"
开始上传。
"
);
var
params
=
config
.
cdn
.
params
.
slice
(
0
);
params
.
push
(
local
);
params
.
push
(
remote
);
var
proc
=
spawn
(
config
.
cdn
.
exe
,
params
,
{
cwd
:
"
.
"
,
env
:
process
.
env
});
proc
.
stdout
.
setEncoding
(
'
utf8
'
);
proc
.
stdout
.
on
(
'
data
'
,
function
(
data
)
{
data
=
data
+
""
;
if
(
data
.
includes
(
"
fails
"
))
{
var
datas
=
data
.
split
(
"
\n
"
);
sendResponse
(
"
CDN
"
+
remote
+
"
:
"
+
datas
[
datas
.
length
-
2
]);
}
});
proc
.
stderr
.
setEncoding
(
'
utf8
'
);
proc
.
stderr
.
on
(
'
data
'
,
function
(
data
)
{
sendResponse
(
"
CDN:
"
+
data
);
});
proc
.
on
(
'
close
'
,
function
(
code
)
{
sendResponse
(
"
CDN
"
+
remote
+
"
上传完成。
"
);
callback
();
});
}
//将数据库文件夹里卡图复制到列表页对应文件夹里,同步
//将数据库文件夹里卡图复制到列表页对应文件夹里,同步
var
copyImages
=
function
()
{
var
copyImages
=
function
()
{
execSync
(
'
rm -rf "
'
+
config
.
html_path
+
config
.
html_img_rel_path
+
'
"
'
);
execSync
(
'
rm -rf "
'
+
config
.
html_path
+
config
.
html_img_rel_path
+
'
"
'
);
...
@@ -301,7 +335,11 @@ var copyToYGOPRO = function() {
...
@@ -301,7 +335,11 @@ var copyToYGOPRO = function() {
}
}
//生成更新包,异步
//生成更新包,异步
var
packDatas
=
function
()
{
var
packDatas
=
function
()
{
file_path
=
config
.
html_path
;
if
(
config
.
cdn
.
enabled
)
{
file_path
=
config
.
cdn
.
local
;
}
execSync
(
'
cp -r "
'
+
config
.
db_path
+
'
expansions" "
'
+
config
.
db_path
+
'
cdb"
'
);
execSync
(
'
cp -r "
'
+
config
.
db_path
+
'
expansions" "
'
+
config
.
db_path
+
'
cdb"
'
);
execSync
(
'
cp -r "
'
+
config
.
db_path
+
'
script" "
'
+
config
.
db_path
+
'
expansions/script"
'
);
execSync
(
'
cp -r "
'
+
config
.
db_path
+
'
script" "
'
+
config
.
db_path
+
'
expansions/script"
'
);
execSync
(
'
cp -r "
'
+
config
.
db_path
+
'
pics" "
'
+
config
.
db_path
+
'
expansions/pics"
'
);
execSync
(
'
cp -r "
'
+
config
.
db_path
+
'
pics" "
'
+
config
.
db_path
+
'
expansions/pics"
'
);
...
@@ -316,7 +354,7 @@ var packDatas = function() {
...
@@ -316,7 +354,7 @@ var packDatas = function() {
sendResponse
(
"
7z error:
"
+
data
);
sendResponse
(
"
7z error:
"
+
data
);
});
});
proc
.
on
(
'
close
'
,
function
(
code
)
{
proc
.
on
(
'
close
'
,
function
(
code
)
{
execSync
(
'
mv -f "
'
+
config
.
db_path
+
'
ygosrv233-pre.zip" "
'
+
config
.
html
_path
+
'
"
'
);
execSync
(
'
mv -f "
'
+
config
.
db_path
+
'
ygosrv233-pre.zip" "
'
+
file
_path
+
'
"
'
);
execSync
(
'
rm -rf "
'
+
config
.
db_path
+
'
expansions/script" "
'
+
config
.
db_path
+
'
expansions/pics"
'
);
execSync
(
'
rm -rf "
'
+
config
.
db_path
+
'
expansions/script" "
'
+
config
.
db_path
+
'
expansions/pics"
'
);
sendResponse
(
"
电脑更新包打包完成。
"
);
sendResponse
(
"
电脑更新包打包完成。
"
);
});
});
...
@@ -330,7 +368,7 @@ var packDatas = function() {
...
@@ -330,7 +368,7 @@ var packDatas = function() {
sendResponse
(
"
7z error:
"
+
data
);
sendResponse
(
"
7z error:
"
+
data
);
});
});
proc2
.
on
(
'
close
'
,
function
(
code
)
{
proc2
.
on
(
'
close
'
,
function
(
code
)
{
execSync
(
'
mv -f "
'
+
config
.
db_path
+
'
ygosrv233-pre-mobile.zip" "
'
+
config
.
html
_path
+
'
"
'
);
execSync
(
'
mv -f "
'
+
config
.
db_path
+
'
ygosrv233-pre-mobile.zip" "
'
+
file
_path
+
'
"
'
);
sendResponse
(
"
手机更新包打包完成。
"
);
sendResponse
(
"
手机更新包打包完成。
"
);
});
});
var
proc3
=
spawn
(
"
7za
"
,
[
"
a
"
,
"
-x!*.zip
"
,
"
-x!mobile.cdb
"
,
"
-x!expansions
"
,
"
-x!pics
"
,
"
ygosrv233-pre-2.zip
"
,
"
*
"
],
{
cwd
:
config
.
db_path
,
env
:
process
.
env
});
var
proc3
=
spawn
(
"
7za
"
,
[
"
a
"
,
"
-x!*.zip
"
,
"
-x!mobile.cdb
"
,
"
-x!expansions
"
,
"
-x!pics
"
,
"
ygosrv233-pre-2.zip
"
,
"
*
"
],
{
cwd
:
config
.
db_path
,
env
:
process
.
env
});
...
@@ -343,7 +381,7 @@ var packDatas = function() {
...
@@ -343,7 +381,7 @@ var packDatas = function() {
sendResponse
(
"
7z error:
"
+
data
);
sendResponse
(
"
7z error:
"
+
data
);
});
});
proc3
.
on
(
'
close
'
,
function
(
code
)
{
proc3
.
on
(
'
close
'
,
function
(
code
)
{
execSync
(
'
mv -f "
'
+
config
.
db_path
+
'
ygosrv233-pre-2.zip" "
'
+
config
.
html
_path
+
'
"
'
);
execSync
(
'
mv -f "
'
+
config
.
db_path
+
'
ygosrv233-pre-2.zip" "
'
+
file
_path
+
'
"
'
);
execSync
(
'
rm -rf "
'
+
config
.
db_path
+
'
cdb"
'
);
execSync
(
'
rm -rf "
'
+
config
.
db_path
+
'
cdb"
'
);
execSync
(
'
rm -rf "
'
+
config
.
db_path
+
'
picture/field"
'
);
execSync
(
'
rm -rf "
'
+
config
.
db_path
+
'
picture/field"
'
);
sendResponse
(
"
PRO2更新包打包完成。
"
);
sendResponse
(
"
PRO2更新包打包完成。
"
);
...
...
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