Skip to content

Commit fa075f6

Browse files
committed
chore: format docs build config
1 parent 8008dbe commit fa075f6

File tree

10 files changed

+93
-55
lines changed

10 files changed

+93
-55
lines changed

.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
},
4444
{
4545
"files": [
46-
"**/test/**/*.test.js",
47-
"**/test/**/test.js"
46+
"test/**/*.test.js",
47+
"test/**/test.js"
4848
],
4949
"rules": {
5050
"taro/no-stateless-component": "off",

packages/taro-ui-docs/build/addImportLoader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ md = md({
1717
})
1818
.enable(['smartquotes'])
1919
.set({
20-
highlight (content, languageHint) {
20+
highlight(content, languageHint) {
2121
let highlightedContent
2222

2323
highlight.configure({

packages/taro-ui-docs/build/build-docs.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ const webpackBaseConf = require('./webpack.base.config')
77
const webpackProdConf = require('./webpack.prod.config')
88
const formatWebpackMessage = require('./format_webpack_message')
99

10-
function printBuildError (err) {
10+
function printBuildError(err) {
1111
const message = err != null && err.message
1212
const stack = err != null && err.stack
13-
if (stack && typeof message === 'string' && message.indexOf('from UglifyJs') !== -1) {
13+
if (
14+
stack &&
15+
typeof message === 'string' &&
16+
message.indexOf('from UglifyJs') !== -1
17+
) {
1418
try {
1519
const matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack)
1620
if (!matched) {
@@ -47,13 +51,15 @@ webpackCompiler.run((err, stats) => {
4751
const isSuccess = !errors.length && !warnings.length
4852
if (isSuccess) {
4953
buildSpinner.succeed(chalk.green('Compile successfully!\n'))
50-
process.stdout.write(`${stats.toString({
51-
colors: true,
52-
modules: false,
53-
children: false,
54-
chunks: false,
55-
chunkModules: false
56-
})}\n`)
54+
process.stdout.write(
55+
`${stats.toString({
56+
colors: true,
57+
modules: false,
58+
children: false,
59+
chunks: false,
60+
chunkModules: false
61+
})}\n`
62+
)
5763
return
5864
}
5965
if (errors.length) {

packages/taro-ui-docs/build/build-static.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ const ora = require('ora')
22
const fs = require('fs-extra')
33
const path = require('path')
44

5-
const spinner = ora('copy h5 website to docs...')
5+
const spinner = ora('Copy h5 website to docs...')
66

77
spinner.start()
88

9-
fs.emptyDirSync(path.resolve(__dirname, '../docs/h5'))
9+
// packages/taro-ui-docs/dist/h5
10+
fs.emptyDirSync(path.resolve(__dirname, '../dist/h5'))
1011

11-
fs.copy(path.resolve(__dirname, '../dist/h5'), path.resolve(__dirname, '../docs/h5'))
12+
fs.copy(
13+
// packages/taro-ui-demo/dist
14+
path.resolve(__dirname, '../../taro-ui-demo/dist'),
15+
path.resolve(__dirname, '../dist/h5')
16+
)
1217
.then(() => {
1318
spinner.stop()
1419
})

packages/taro-ui-docs/build/conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
output: 'site'
2+
output: 'dist'
33
}

packages/taro-ui-docs/build/devServer.conf.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
module.exports = function ({ publicPath, contentBase, protocol, host, publicUrl }) {
1+
module.exports = function ({
2+
publicPath,
3+
contentBase,
4+
protocol,
5+
host,
6+
publicUrl
7+
}) {
28
return {
39
disableHostCheck: process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
410
compress: true,

packages/taro-ui-docs/build/format_webpack_message.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const chalk = require('chalk')
22

33
const syntaxErrorLabel = 'Syntax error:'
44

5-
function isLikelyASyntaxError (message) {
5+
function isLikelyASyntaxError(message) {
66
return message.indexOf(syntaxErrorLabel) >= 0
77
}
88

9-
function formatMessage (message) {
9+
function formatMessage(message) {
1010
let lines = message.split('\n')
1111
if (lines.length > 2 && lines[1] === '') {
1212
lines.splice(1, 1)
@@ -44,11 +44,14 @@ function formatMessage (message) {
4444
lines[0] = chalk.inverse(lines[0])
4545
message = lines.join('\n')
4646

47-
message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, '')
47+
message = message.replace(
48+
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
49+
''
50+
)
4851
return message.trim()
4952
}
5053

51-
module.exports = function formatWebpackMessage (message) {
54+
module.exports = function formatWebpackMessage(message) {
5255
const errors = message.errors.map(item => formatMessage(item))
5356
const warnings = message.warnings.map(item => formatMessage(item))
5457

packages/taro-ui-docs/build/open.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const exec = require('child_process').exec
22

3-
module.exports = function open (target, appName, callback) {
3+
module.exports = function open(target, appName, callback) {
44
let opener
55

6-
if (typeof (appName) === 'function') {
6+
if (typeof appName === 'function') {
77
callback = appName
88
appName = null
99
}
@@ -38,6 +38,6 @@ module.exports = function open (target, appName, callback) {
3838
return exec(`${opener} "${escape(target)}"`, callback)
3939
}
4040

41-
function escape (s) {
41+
function escape(s) {
4242
return s.replace(/"/g, '\\"')
4343
}

packages/taro-ui-docs/build/util.js

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = require('path')
22
const url = require('url')
33
const os = require('os')
44

5-
function _normalizeFamily (family) {
5+
function _normalizeFamily(family) {
66
return family ? family.toLowerCase() : 'ipv4'
77
}
88

@@ -26,7 +26,10 @@ exports.formatTime = function (date) {
2626
const day = date.getDate()
2727
const hour = date.getHours()
2828
const minute = date.getMinutes()
29-
return `${year}-${exports.zeroPad(month, 2)}-${exports.zeroPad(day, 2)} ${exports.zeroPad(hour, 2)}:${exports.zeroPad(minute, 2)}`
29+
return `${year}-${exports.zeroPad(month, 2)}-${exports.zeroPad(
30+
day,
31+
2
32+
)} ${exports.zeroPad(hour, 2)}:${exports.zeroPad(minute, 2)}`
3033
}
3134

3235
exports.getLocalIp = function (name, family) {
@@ -51,29 +54,32 @@ exports.getLocalIp = function (name, family) {
5154
return res[0].address
5255
}
5356

54-
const all = Object.keys(interfaces).map(nic => {
55-
//
56-
// Note: name will only be `public` or `private`
57-
// when this is called.
58-
//
59-
const addresses = interfaces[nic].filter(details => {
60-
details.family = details.family.toLowerCase()
61-
if (details.family !== family || exports.isLoopback(details.address)) {
62-
return false
63-
} else if (!name) {
64-
return true
65-
}
57+
const all = Object.keys(interfaces)
58+
.map(nic => {
59+
//
60+
// Note: name will only be `public` or `private`
61+
// when this is called.
62+
//
63+
const addresses = interfaces[nic].filter(details => {
64+
details.family = details.family.toLowerCase()
65+
if (details.family !== family || exports.isLoopback(details.address)) {
66+
return false
67+
} else if (!name) {
68+
return true
69+
}
6670

67-
return name === 'public' ? !exports.isPrivate(details.address)
68-
: exports.isPrivate(details.address)
71+
return name === 'public'
72+
? !exports.isPrivate(details.address)
73+
: exports.isPrivate(details.address)
74+
})
75+
return addresses.length ? addresses[0].address : undefined
6976
})
70-
return addresses.length ? addresses[0].address : undefined
71-
}).filter(Boolean)
77+
.filter(Boolean)
7278

7379
return !all.length ? exports.loopback(family) : all[0]
7480
}
7581

76-
exports.loopback = function loopback (family) {
82+
exports.loopback = function loopback(family) {
7783
//
7884
// Default to `ipv4`
7985
//
@@ -86,29 +92,32 @@ exports.loopback = function loopback (family) {
8692
return family === 'ipv4' ? '127.0.0.1' : 'fe80::1'
8793
}
8894

89-
exports.isLoopback = function isLoopback (addr) {
90-
return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/
91-
.test(addr) ||
95+
exports.isLoopback = function isLoopback(addr) {
96+
return (
97+
/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/.test(addr) ||
9298
/^fe80::1$/.test(addr) ||
9399
/^::1$/.test(addr) ||
94100
/^::$/.test(addr)
101+
)
95102
}
96103

97-
exports.isPrivate = function isPrivate (addr) {
98-
return /^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/
99-
.test(addr) ||
104+
exports.isPrivate = function isPrivate(addr) {
105+
return (
106+
/^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(addr) ||
100107
/^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/.test(addr) ||
101-
/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/
102-
.test(addr) ||
108+
/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/.test(
109+
addr
110+
) ||
103111
/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(addr) ||
104112
/^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/.test(addr) ||
105113
/^fc00:/i.test(addr) ||
106114
/^fe80:/i.test(addr) ||
107115
/^::1$/.test(addr) ||
108116
/^::$/.test(addr)
117+
)
109118
}
110119

111-
exports.isPublic = function isPublic (addr) {
120+
exports.isPublic = function isPublic(addr) {
112121
return !exports.isPrivate(addr)
113122
}
114123

packages/taro-ui-docs/build/webpack.base.config.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ module.exports = {
3232
},
3333
{
3434
test: /\.md$/,
35-
loader: `babel-loader!${path.join(__dirname, './addImportLoader.js')}`
35+
loader: `babel-loader!${path.join(
36+
__dirname,
37+
'./addImportLoader.js'
38+
)}`
3639
},
3740
{
3841
test: /\.(css|scss|sass)(\?.*)?$/,
@@ -51,7 +54,13 @@ module.exports = {
5154
ident: 'postcss',
5255
plugins: () => [
5356
autoprefixer({
54-
overrideBrowserslist: ['ie >= 9', 'Chrome >= 21', 'Firefox >= 1', 'Edge >= 13', 'last 3 versions'],
57+
overrideBrowserslist: [
58+
'ie >= 9',
59+
'Chrome >= 21',
60+
'Firefox >= 1',
61+
'Edge >= 13',
62+
'last 3 versions'
63+
],
5564
flexbox: 'no-2009'
5665
})
5766
]
@@ -100,7 +109,7 @@ module.exports = {
100109
alias: {
101110
react: 'nervjs',
102111
'react-dom': 'nervjs',
103-
'@md': path.resolve(__dirname, '../docs/markdown/'),
112+
'@md': path.resolve(__dirname, '../docs/markdown/')
104113
}
105114
},
106115
plugins: [

0 commit comments

Comments
 (0)