Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sparkweb
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wildfirecode13
sparkweb
Commits
a2f2e3ad
Commit
a2f2e3ad
authored
Jun 04, 2020
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
babde061
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
238 additions
and
0 deletions
+238
-0
.DS_Store
.DS_Store
+0
-0
workspace.xml
.idea/workspace.xml
+78
-0
upload.js
script/upload.js
+160
-0
No files found.
.DS_Store
View file @
a2f2e3ad
No preview for this file type
.idea/workspace.xml
View file @
a2f2e3ad
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"16751153-0676-4795-9253-f8f1d2290e77"
name=
"Default Changelist"
comment=
"oss"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
<option
name=
"LAST_RESOLUTION"
value=
"IGNORE"
/>
</component>
<component
name=
"Git.Settings"
>
<option
name=
"RECENT_GIT_ROOT_PATH"
value=
"$PROJECT_DIR$"
/>
</component>
<component
name=
"ProjectId"
id=
"1cqymIbMuxr9X7DKNcPgxKEXuSJ"
/>
<component
name=
"ProjectViewState"
>
<option
name=
"hideEmptyMiddlePackages"
value=
"true"
/>
<option
name=
"showLibraryContents"
value=
"true"
/>
</component>
<component
name=
"PropertiesComponent"
>
<property
name=
"RunOnceActivity.OpenProjectViewOnStart"
value=
"true"
/>
<property
name=
"RunOnceActivity.ShowReadmeOnStart"
value=
"true"
/>
<property
name=
"WebServerToolWindowFactoryState"
value=
"false"
/>
<property
name=
"nodejs_interpreter_path.stuck_in_default_project"
value=
"undefined stuck path"
/>
<property
name=
"nodejs_npm_path_reset_for_default_project"
value=
"true"
/>
<property
name=
"nodejs_package_manager_path"
value=
"yarn"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"editor.preferences.fonts.default"
/>
</component>
<component
name=
"SvnConfiguration"
>
<configuration
/>
</component>
<component
name=
"TaskManager"
>
<task
active=
"true"
id=
"Default"
summary=
"Default task"
>
<changelist
id=
"16751153-0676-4795-9253-f8f1d2290e77"
name=
"Default Changelist"
comment=
""
/>
<created>
1591270575177
</created>
<option
name=
"number"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<updated>
1591270575177
</updated>
<workItem
from=
"1591270576445"
duration=
"308000"
/>
</task>
<task
id=
"LOCAL-00001"
summary=
"oss"
>
<created>
1591270731235
</created>
<option
name=
"number"
value=
"00001"
/>
<option
name=
"presentableId"
value=
"LOCAL-00001"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1591270731235
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"2"
/>
<servers
/>
</component>
<component
name=
"TypeScriptGeneratedFilesManager"
>
<option
name=
"version"
value=
"2"
/>
</component>
<component
name=
"VcsManagerConfiguration"
>
<MESSAGE
value=
"oss"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"oss"
/>
</component>
<component
name=
"WindowStateProjectService"
>
<state
x=
"467"
y=
"108"
key=
"CommitChangelistDialog2"
timestamp=
"1591270742820"
>
<screen
x=
"37"
y=
"23"
width=
"1643"
height=
"1027"
/>
</state>
<state
x=
"467"
y=
"108"
key=
"CommitChangelistDialog2/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027"
timestamp=
"1591270742820"
/>
<state
width=
"1601"
height=
"280"
key=
"GridCell.Tab.0.bottom"
timestamp=
"1591270708263"
>
<screen
x=
"37"
y=
"23"
width=
"1643"
height=
"1027"
/>
</state>
<state
width=
"1601"
height=
"280"
key=
"GridCell.Tab.0.bottom/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027"
timestamp=
"1591270708263"
/>
<state
width=
"1601"
height=
"280"
key=
"GridCell.Tab.0.center"
timestamp=
"1591270708261"
>
<screen
x=
"37"
y=
"23"
width=
"1643"
height=
"1027"
/>
</state>
<state
width=
"1601"
height=
"280"
key=
"GridCell.Tab.0.center/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027"
timestamp=
"1591270708261"
/>
<state
width=
"1601"
height=
"280"
key=
"GridCell.Tab.0.left"
timestamp=
"1591270708260"
>
<screen
x=
"37"
y=
"23"
width=
"1643"
height=
"1027"
/>
</state>
<state
width=
"1601"
height=
"280"
key=
"GridCell.Tab.0.left/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027"
timestamp=
"1591270708260"
/>
<state
width=
"1601"
height=
"280"
key=
"GridCell.Tab.0.right"
timestamp=
"1591270708261"
>
<screen
x=
"37"
y=
"23"
width=
"1643"
height=
"1027"
/>
</state>
<state
width=
"1601"
height=
"280"
key=
"GridCell.Tab.0.right/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027"
timestamp=
"1591270708261"
/>
<state
x=
"654"
y=
"263"
key=
"RollbackChangesDialog"
timestamp=
"1591270716679"
>
<screen
x=
"37"
y=
"23"
width=
"1643"
height=
"1027"
/>
</state>
<state
x=
"654"
y=
"263"
key=
"RollbackChangesDialog/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027"
timestamp=
"1591270716679"
/>
<state
x=
"433"
y=
"141"
key=
"com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser"
timestamp=
"1591270602195"
>
<screen
x=
"37"
y=
"23"
width=
"1643"
height=
"1027"
/>
</state>
<state
x=
"433"
y=
"141"
key=
"com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027"
timestamp=
"1591270602195"
/>
</component>
</project>
\ No newline at end of file
script/upload.js
0 → 100644
View file @
a2f2e3ad
var
fs
=
require
(
'fs'
);
var
path
=
require
(
'path'
);
const
co
=
require
(
'co'
);
const
OSS
=
require
(
'ali-oss'
);
const
chalk
=
require
(
'chalk'
);
const
ProgressBar
=
require
(
'progress'
);
class
TuiaAutoUpload
{
constructor
(
props
,
type
)
{
this
.
type
=
type
;
const
defaultOptions
=
{
dir
:
undefined
,
originDir
:
undefined
}
this
.
options
=
Object
.
assign
({},
defaultOptions
,
props
);
if
(
!
this
.
options
.
dir
||
!
this
.
options
.
originDir
)
{
console
.
log
(
chalk
.
red
(
'缺少参数,初始化失败'
))
return
;
}
this
.
init
();
}
init
()
{
var
_this
=
this
;
this
.
client
=
new
OSS
({
region
:
'oss-cn-hangzhou'
,
accessKeyId
:
'LTAI4Fw25WcfcGv7FvcHoiHK'
,
accessKeySecret
:
'NZk1NtT9J5HFaAolNbtQdzTzLLvLYm'
,
bucket
:
_this
.
type
===
'prod'
?
'duiba'
:
'daily-duiba'
});
this
.
bar
=
new
ProgressBar
(
chalk
.
yellow
(
` 文件上传中 [:bar] :current/
${
this
.
files
().
length
}
:percent :elapseds`
),
{
complete
:
'●'
,
incomplete
:
'○'
,
width
:
20
,
total
:
this
.
files
().
length
,
callback
:
()
=>
{
console
.
log
(
chalk
.
green
(
'
\
n All complete.'
));
console
.
log
(
chalk
.
blue
(
`\n 本次队列文件共
${
this
.
files
().
length
}
个,已存在文件
${
this
.
existFiles
}
个,上传文件
${
this
.
uploadFiles
}
个,上传失败文件
${
this
.
errorFiles
}
个\n`
));
}
})
return
this
;
}
files
()
{
var
_this
=
this
;
if
(
this
.
_files
)
return
this
.
_files
;
this
.
_files
=
[];
/**
* 文件遍历方法
* @param filePath 需要遍历的文件路径
*/
function
fileDisplay
(
filePath
)
{
//根据文件路径读取文件,返回文件列表
var
files
=
fs
.
readdirSync
(
filePath
);
files
.
forEach
(
function
(
filename
)
{
//获取当前文件的绝对路径
var
filedir
=
path
.
join
(
filePath
,
filename
);
//根据文件路径获取文件信息,返回一个fs.Stats对象
var
stats
=
fs
.
statSync
(
filedir
);
var
isFile
=
stats
.
isFile
();
//是文件
var
isDir
=
stats
.
isDirectory
();
//是文件夹
if
(
isFile
)
{
var
sep
=
'/'
;
if
(
'win32'
==
process
.
platform
)
sep
=
'
\
\'
;
var newDirArr = filedir.split(sep);
newDirArr.shift();
_this._files.push(newDirArr.join('
/
'));
}
if (isDir) {
fileDisplay(filedir);//递归,如果是文件夹,就继续遍历该文件夹下面的文件
}
});
}
//调用文件遍历方法
fileDisplay(this.options.dir);
return this._files;
}
start() {
this.files().map((file, index) => {
let _this = this;
const path1 = path.join(path.resolve(__dirname, '
..
'), '
released
', file);
let originFile;
this.existFiles = 0;
this.uploadFiles = 0;
this.errorFiles = 0;
co(function* () {
const originPath = `${_this.options.originDir}${file}`;
try {
originFile = yield _this.client.head(originPath);
} catch (error) {
originFile = error;
}
if (_this.type === '
prod
') {
if (originFile.status === 404) {
yield _this.client.put(originPath, path1);
_this.uploadFiles += 1;
} else {
_this.existFiles += 1;
}
} else if (_this.type === '
dev
') {
if (originFile.status === 404 || originFile.status === 200) {
_this.existFiles += 1;
}
yield _this.client.put(originPath, path1, {
headers: {
'
Cache
-
Control
': '
no
-
cache
'
}
})
_this.uploadFiles += 1;
}
_this.bar.tick();
}).catch(function (err) {
_this.errorFiles += 1;
console.log(err);
});
});
}
}
const configFileName = '
project
.
json
';
if (!fs.existsSync(configFileName)) {
throw new Error(`${configFileName}不存在.`)
}
let config = fs.readFileSync('
project
.
json
');
config = JSON.parse(config + '');
if (!config.type) {
throw new Error(`${configFileName}的type不存在.`)
}
if (!config.name) {
throw new Error(`${configFileName}的name不存在.`)
}
const now = new Date();
const version = Math.round(now.getTime() / 1000);
console.log(`版本号:
${version}`)
const autoupload = new TuiaAutoUpload({
dir: '
.
/
released
/
',
// dir: path.join(__dirname, '
.
/
released
/
'),
originDir: `/db_games/${config.type}/${config.name}/${version}/`
}, "prod")
autoupload.start()
var iconv = require('
iconv
-
lite
');
var readPath = "./released/resource/";
//读取json文件
var data = iconv.decode(fs.readFileSync(readPath + "res.json"), "GBK");
//反序列化
data = JSON.parse(data);
data.path = `https://yun.duiba.com.cn/db_games/${config.type}/${config.name}/${version}/resource/`
//写入目标文件夹,可配置,每个项目必须修改,或者直接和project的保持一致(淘宝项目文件固定后)
var endPath = '
.
/
src
/
';
var endFile = `export const ResJson = ${JSON.stringify(data, "", "
\
t")}`
fs.writeFileSync(endPath + "ResJson.ts", endFile);
\ No newline at end of file
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