Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ds147000
/
react-project-storage
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3338e5b4
authored
Dec 29, 2020
by
杨周龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加cdn资源分离和自动推送脚步
1 parent
6f720159
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
1 deletions
config-overrides.js
src/shell/postOss.js
src/shell/tag.js
src/shell/tips.js
config-overrides.js
View file @
3338e5b
const
{
override
,
addWebpackAlias
}
=
require
(
'customize-cra'
)
const
{
override
,
addWebpackAlias
,
setWebpackPublicPath
}
=
require
(
'customize-cra'
)
const
path
=
require
(
'path'
)
const
Packgae
=
require
(
'./package.json'
)
module
.
exports
=
override
(
setWebpackPublicPath
(
process
.
env
.
NODE_ENV
===
'development'
?
''
:
`https://app-static.b2bwings.com/js/
${
Packgae
.
name
}
/
${
process
.
env
.
OUTPUT
}
/
${
Packgae
.
version
}
/`
),
// 配置路径别名
addWebpackAlias
({
'@'
:
path
.
resolve
(
__dirname
,
'./src'
),
...
...
src/shell/postOss.js
0 → 100644
View file @
3338e5b
/* eslint-disable no-console */
const
axios
=
require
(
'axios'
)
const
fs
=
require
(
'fs'
)
const
path
=
require
(
'path'
)
const
sha256
=
require
(
'js-sha256'
)
const
ora
=
require
(
'ora'
)
const
FormData
=
require
(
'form-data'
)
const
Package
=
require
(
'../package.json'
)
const
entryFile
=
'../build/static/'
const
url
=
`https://gateway-test.b2bwings.com/ops/oss/fileUpload?bucket=xbd-app&fileDirectory=js/
${
Package
.
name
}
/
${
process
.
env
.
OUTPUT
}
/
${
Package
.
version
}
/static/`
const
account
=
'13802965035'
const
pswd
=
'114331'
let
headers
const
mergePath
=
url
=>
path
.
resolve
(
__dirname
,
url
)
const
readDir
=
async
(
path
)
=>
{
return
new
Promise
((
res
,
rej
)
=>
{
fs
.
readdir
(
mergePath
(
path
),
{
encoding
:
'utf-8'
},
(
err
,
files
)
=>
err
?
rej
(
err
)
:
res
(
files
)
)
})
}
const
readFile
=
(
path
)
=>
{
return
fs
.
createReadStream
(
mergePath
(
path
),
{
encoding
:
'utf-8'
})
}
const
isDir
=
(
path
)
=>
{
const
state
=
fs
.
statSync
(
mergePath
(
path
))
return
state
.
isDirectory
()
}
/** 上传文件,回调遍历 */
const
upload
=
async
(
path
)
=>
{
if
(
isDir
(
path
))
{
// 文件夹
const
files
=
await
readDir
(
path
)
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
await
upload
(
path
+
'/'
+
files
[
i
])
return
null
}
else
{
// 文件
const
file
=
readFile
(
path
)
const
form
=
new
FormData
()
form
.
append
(
'file'
,
file
)
const
formHeaders
=
form
.
getHeaders
()
let
_url
=
url
+
String
(
path
).
replace
(
entryFile
,
''
)
_url
=
_url
.
slice
(
0
,
_url
.
lastIndexOf
(
'/'
)
+
1
)
const
data
=
{
url
:
_url
,
method
:
'post'
,
data
:
form
,
headers
:
{
...
headers
,
...
formHeaders
},
timeout
:
600000
}
return
axios
(
data
).
then
(
res
=>
{
if
(
res
.
data
.
code
!==
200
)
return
Promise
.
reject
(
res
.
data
.
message
)
return
Promise
.
resolve
()
}).
catch
(
err
=>
{
console
.
error
(
err
)
process
.
exit
(
err
)
})
}
}
/** 获取sessionid */
const
getSessionID
=
async
()
=>
{
const
spinner
=
ora
(
'获取sessionId'
)
spinner
.
start
()
return
axios
({
url
:
'https://gateway-test.b2bwings.com/user/sysLogin/login'
,
method
:
'post'
,
data
:
{
loginAccount
:
account
,
loginPassword
:
sha256
(
pswd
),
applyPlatform
:
[
1
],
applyCarrier
:
[
0
],
operationChannel
:
0
}
}).
then
(
async
(
res
)
=>
{
spinner
.
succeed
()
return
{
Sessionid
:
res
.
data
.
data
.
sessionid
}
})
.
catch
(
err
=>
{
console
.
error
(
err
)
process
.
exit
(
err
)
})
}
/** 上传文件 */
const
uploadFiles
=
async
(
path
)
=>
{
const
spinner
=
ora
(
'开始上传'
+
path
+
'\n'
)
spinner
.
start
()
await
upload
(
path
)
spinner
.
succeed
()
}
/** 上传所有文件 */
const
UploadAllFiles
=
async
()
=>
{
const
fiels
=
await
readDir
(
entryFile
)
for
(
let
i
=
0
;
i
<
fiels
.
length
;
i
++
)
await
uploadFiles
(
entryFile
+
fiels
[
i
])
}
const
app
=
async
()
=>
{
headers
=
await
getSessionID
()
await
UploadAllFiles
()
console
.
log
(
'\x1B[32m'
,
'上传成功'
)
}
app
()
src/shell/tag.js
0 → 100644
View file @
3338e5b
const
fs
=
require
(
'fs'
)
const
{
join
}
=
require
(
'path'
)
const
version
=
`V
${
new
Date
().
getMonth
()
+
1
}
-
${
new
Date
().
getDate
()}
${
new
Date
().
getHours
()}
.
${
new
Date
().
getMinutes
()}
.
${
new
Date
().
getSeconds
()}
`
const
content
=
`
const version = '
${
version
}
'
export default version
`
fs
.
writeFile
(
join
(
__dirname
,
'../src/version.js'
),
content
,
{
encoding
:
'utf-8'
},
()
=>
{
console
.
log
(
'创建版本成功,当前版本是'
+
version
)
})
src/shell/tips.js
0 → 100644
View file @
3338e5b
/* eslint-disable no-console */
console
.
log
(
'\x1B[31m'
,
'eslint 不再输出报表txt文件'
)
console
.
log
(
'\x1B[34m'
,
'\n\n 如需获取报表文件请运行'
)
console
.
log
(
'\x1B[32m'
,
'\n npm run lint-rep'
)
console
.
log
(
'\x1B[34m'
,
'\n\n 如需获取stylelint报告请运行'
)
console
.
log
(
'\x1B[32m'
,
'\n npm run style-lint'
)
console
.
log
(
'\x1B[32m'
,
'\n npm run style-lint-rep'
)
Write
Preview
Markdown
is supported
Attach a file
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 post a comment