chore: prettify non-source files
This commit is contained in:
parent
eb37c7d7d8
commit
8178de8a6b
13
.eslintrc.js
13
.eslintrc.js
@ -1,13 +1,10 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
'extends': [
|
extends: ['standard', 'standard-jsx'],
|
||||||
'standard',
|
globals: {
|
||||||
'standard-jsx',
|
__DEV__: true
|
||||||
],
|
|
||||||
'globals': {
|
|
||||||
'__DEV__': true
|
|
||||||
},
|
},
|
||||||
'parser': 'babel-eslint',
|
parser: 'babel-eslint',
|
||||||
'rules': {
|
rules: {
|
||||||
'comma-dangle': ['error', 'always-multiline'],
|
'comma-dangle': ['error', 'always-multiline'],
|
||||||
'no-var': 'error',
|
'no-var': 'error',
|
||||||
'prefer-const': 'error'
|
'prefer-const': 'error'
|
||||||
|
131
gulpfile.js
131
gulpfile.js
@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
var SRC_DIR = __dirname + '/src' // eslint-disable-line no-path-concat
|
const SRC_DIR = __dirname + '/src' // eslint-disable-line no-path-concat
|
||||||
var DIST_DIR = __dirname + '/dist' // eslint-disable-line no-path-concat
|
const DIST_DIR = __dirname + '/dist' // eslint-disable-line no-path-concat
|
||||||
|
|
||||||
// Port to use for the livereload server.
|
// Port to use for the livereload server.
|
||||||
//
|
//
|
||||||
// It must be available and if possible unique to not conflict with other projects.
|
// It must be available and if possible unique to not conflict with other projects.
|
||||||
// http://www.random.org/integers/?num=1&min=1024&max=65535&col=1&base=10&format=plain&rnd=new
|
// http://www.random.org/integers/?num=1&min=1024&max=65535&col=1&base=10&format=plain&rnd=new
|
||||||
var LIVERELOAD_PORT = 26242
|
const LIVERELOAD_PORT = 26242
|
||||||
|
|
||||||
var PRODUCTION = process.env.NODE_ENV === 'production'
|
const PRODUCTION = process.env.NODE_ENV === 'production'
|
||||||
var DEVELOPMENT = !PRODUCTION
|
const DEVELOPMENT = !PRODUCTION
|
||||||
|
|
||||||
if (!process.env.XOA_PLAN) {
|
if (!process.env.XOA_PLAN) {
|
||||||
process.env.XOA_PLAN = '5' // Open Source
|
process.env.XOA_PLAN = '5' // Open Source
|
||||||
@ -20,12 +20,12 @@ if (!process.env.XOA_PLAN) {
|
|||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
var gulp = require('gulp')
|
const gulp = require('gulp')
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
function lazyFn (factory) {
|
function lazyFn (factory) {
|
||||||
var fn = function () {
|
let fn = function () {
|
||||||
fn = factory()
|
fn = factory()
|
||||||
return fn.apply(this, arguments)
|
return fn.apply(this, arguments)
|
||||||
}
|
}
|
||||||
@ -37,19 +37,19 @@ function lazyFn (factory) {
|
|||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
var livereload = lazyFn(function () {
|
const livereload = lazyFn(function () {
|
||||||
var livereload = require('gulp-refresh')
|
const livereload = require('gulp-refresh')
|
||||||
livereload.listen({
|
livereload.listen({
|
||||||
port: LIVERELOAD_PORT
|
port: LIVERELOAD_PORT,
|
||||||
})
|
})
|
||||||
|
|
||||||
return livereload
|
return livereload
|
||||||
})
|
})
|
||||||
|
|
||||||
var pipe = lazyFn(function () {
|
const pipe = lazyFn(function () {
|
||||||
var current
|
let current
|
||||||
function pipeCore (streams) {
|
function pipeCore (streams) {
|
||||||
var i, n, stream
|
let i, n, stream
|
||||||
for (i = 0, n = streams.length; i < n; ++i) {
|
for (i = 0, n = streams.length; i < n; ++i) {
|
||||||
stream = streams[i]
|
stream = streams[i]
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
@ -57,14 +57,12 @@ var pipe = lazyFn(function () {
|
|||||||
} else if (stream instanceof Array) {
|
} else if (stream instanceof Array) {
|
||||||
pipeCore(stream)
|
pipeCore(stream)
|
||||||
} else {
|
} else {
|
||||||
current = current
|
current = current ? current.pipe(stream) : stream
|
||||||
? current.pipe(stream)
|
|
||||||
: stream
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var push = Array.prototype.push
|
const push = Array.prototype.push
|
||||||
return function (streams) {
|
return function (streams) {
|
||||||
try {
|
try {
|
||||||
if (!(streams instanceof Array)) {
|
if (!(streams instanceof Array)) {
|
||||||
@ -81,7 +79,7 @@ var pipe = lazyFn(function () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var resolvePath = lazyFn(function () {
|
const resolvePath = lazyFn(function () {
|
||||||
return require('path').resolve
|
return require('path').resolve
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -89,37 +87,35 @@ var resolvePath = lazyFn(function () {
|
|||||||
|
|
||||||
// Similar to `gulp.src()` but the pattern is relative to `SRC_DIR`
|
// Similar to `gulp.src()` but the pattern is relative to `SRC_DIR`
|
||||||
// and files are automatically watched when not in production mode.
|
// and files are automatically watched when not in production mode.
|
||||||
var src = lazyFn(function () {
|
const src = lazyFn(function () {
|
||||||
function resolve (path) {
|
function resolve (path) {
|
||||||
return path
|
return path ? resolvePath(SRC_DIR, path) : SRC_DIR
|
||||||
? resolvePath(SRC_DIR, path)
|
|
||||||
: SRC_DIR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return PRODUCTION
|
return PRODUCTION
|
||||||
? function src (pattern, opts) {
|
? function src (pattern, opts) {
|
||||||
var base = resolve(opts && opts.base)
|
const base = resolve(opts && opts.base)
|
||||||
|
|
||||||
return gulp.src(pattern, {
|
return gulp.src(pattern, {
|
||||||
base: base,
|
base: base,
|
||||||
cwd: base,
|
cwd: base,
|
||||||
passthrough: opts && opts.passthrough,
|
passthrough: opts && opts.passthrough,
|
||||||
sourcemaps: opts && opts.sourcemaps
|
sourcemaps: opts && opts.sourcemaps,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
: function src (pattern, opts) {
|
: function src (pattern, opts) {
|
||||||
var base = resolve(opts && opts.base)
|
const base = resolve(opts && opts.base)
|
||||||
|
|
||||||
return pipe(
|
return pipe(
|
||||||
gulp.src(pattern, {
|
gulp.src(pattern, {
|
||||||
base: base,
|
base: base,
|
||||||
cwd: base,
|
cwd: base,
|
||||||
passthrough: opts && opts.passthrough,
|
passthrough: opts && opts.passthrough,
|
||||||
sourcemaps: opts && opts.sourcemaps
|
sourcemaps: opts && opts.sourcemaps,
|
||||||
}),
|
}),
|
||||||
require('gulp-watch')(pattern, {
|
require('gulp-watch')(pattern, {
|
||||||
base: base,
|
base: base,
|
||||||
cwd: base
|
cwd: base,
|
||||||
}),
|
}),
|
||||||
require('gulp-plumber')()
|
require('gulp-plumber')()
|
||||||
)
|
)
|
||||||
@ -129,17 +125,15 @@ var src = lazyFn(function () {
|
|||||||
// Similar to `gulp.dest()` but the output directory is relative to
|
// Similar to `gulp.dest()` but the output directory is relative to
|
||||||
// `DIST_DIR` and default to `./`, and files are automatically live-
|
// `DIST_DIR` and default to `./`, and files are automatically live-
|
||||||
// reloaded when not in production mode.
|
// reloaded when not in production mode.
|
||||||
var dest = lazyFn(function () {
|
const dest = lazyFn(function () {
|
||||||
function resolve (path) {
|
function resolve (path) {
|
||||||
return path
|
return path ? resolvePath(DIST_DIR, path) : DIST_DIR
|
||||||
? resolvePath(DIST_DIR, path)
|
|
||||||
: DIST_DIR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var opts = {
|
const opts = {
|
||||||
sourcemaps: {
|
sourcemaps: {
|
||||||
path: '.'
|
path: '.',
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return PRODUCTION
|
return PRODUCTION
|
||||||
@ -147,7 +141,7 @@ var dest = lazyFn(function () {
|
|||||||
return gulp.dest(resolve(path), opts)
|
return gulp.dest(resolve(path), opts)
|
||||||
}
|
}
|
||||||
: function dest (path) {
|
: function dest (path) {
|
||||||
var stream = gulp.dest(resolve(path), opts)
|
const stream = gulp.dest(resolve(path), opts)
|
||||||
stream.pipe(livereload())
|
stream.pipe(livereload())
|
||||||
return stream
|
return stream
|
||||||
}
|
}
|
||||||
@ -160,7 +154,7 @@ function browserify (path, opts) {
|
|||||||
opts = {}
|
opts = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
var bundler = require('browserify')(path, {
|
let bundler = require('browserify')(path, {
|
||||||
basedir: SRC_DIR,
|
basedir: SRC_DIR,
|
||||||
debug: true,
|
debug: true,
|
||||||
extensions: opts.extensions,
|
extensions: opts.extensions,
|
||||||
@ -170,12 +164,12 @@ function browserify (path, opts) {
|
|||||||
|
|
||||||
// Required by Watchify.
|
// Required by Watchify.
|
||||||
cache: {},
|
cache: {},
|
||||||
packageCache: {}
|
packageCache: {},
|
||||||
})
|
})
|
||||||
|
|
||||||
var plugins = opts.plugins
|
const plugins = opts.plugins
|
||||||
for (var i = 0, n = plugins && plugins.length; i < n; ++i) {
|
for (let i = 0, n = plugins && plugins.length; i < n; ++i) {
|
||||||
var plugin = plugins[i]
|
const plugin = plugins[i]
|
||||||
bundler.plugin(require(plugin[0]), plugin[1])
|
bundler.plugin(require(plugin[0]), plugin[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +180,7 @@ function browserify (path, opts) {
|
|||||||
bundler = require('watchify')(bundler, {
|
bundler = require('watchify')(bundler, {
|
||||||
// do not watch in `node_modules`
|
// do not watch in `node_modules`
|
||||||
// https://github.com/browserify/watchify#options
|
// https://github.com/browserify/watchify#options
|
||||||
ignoreWatch: true
|
ignoreWatch: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,11 +190,11 @@ function browserify (path, opts) {
|
|||||||
}
|
}
|
||||||
path = resolvePath(SRC_DIR, path)
|
path = resolvePath(SRC_DIR, path)
|
||||||
|
|
||||||
var stream = new (require('readable-stream'))({
|
let stream = new (require('readable-stream'))({
|
||||||
objectMode: true
|
objectMode: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
var write
|
let write
|
||||||
function bundle () {
|
function bundle () {
|
||||||
bundler.bundle(function onBundle (error, buffer) {
|
bundler.bundle(function onBundle (error, buffer) {
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -208,11 +202,13 @@ function browserify (path, opts) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
write(new (require('vinyl'))({
|
write(
|
||||||
base: SRC_DIR,
|
new (require('vinyl'))({
|
||||||
contents: buffer,
|
base: SRC_DIR,
|
||||||
path: path
|
contents: buffer,
|
||||||
}))
|
path: path,
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,9 +240,10 @@ gulp.task(function buildPages () {
|
|||||||
return pipe(
|
return pipe(
|
||||||
src('index.pug', { sourcemaps: true }),
|
src('index.pug', { sourcemaps: true }),
|
||||||
require('gulp-pug')(),
|
require('gulp-pug')(),
|
||||||
DEVELOPMENT && require('gulp-embedlr')({
|
DEVELOPMENT &&
|
||||||
port: LIVERELOAD_PORT
|
require('gulp-embedlr')({
|
||||||
}),
|
port: LIVERELOAD_PORT,
|
||||||
|
}),
|
||||||
dest()
|
dest()
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -256,10 +253,13 @@ gulp.task(function buildScripts () {
|
|||||||
browserify('./index.js', {
|
browserify('./index.js', {
|
||||||
plugins: [
|
plugins: [
|
||||||
// ['css-modulesify', {
|
// ['css-modulesify', {
|
||||||
['modular-css/browserify', {
|
[
|
||||||
css: DIST_DIR + '/modules.css'
|
'modular-css/browserify',
|
||||||
}]
|
{
|
||||||
]
|
css: DIST_DIR + '/modules.css',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
require('gulp-sourcemaps').init({ loadMaps: true }),
|
require('gulp-sourcemaps').init({ loadMaps: true }),
|
||||||
PRODUCTION && require('gulp-uglify/composer')(require('uglify-es'))(),
|
PRODUCTION && require('gulp-uglify/composer')(require('uglify-es'))(),
|
||||||
@ -271,10 +271,7 @@ gulp.task(function buildStyles () {
|
|||||||
return pipe(
|
return pipe(
|
||||||
src('index.scss', { sourcemaps: true }),
|
src('index.scss', { sourcemaps: true }),
|
||||||
require('gulp-sass')(),
|
require('gulp-sass')(),
|
||||||
require('gulp-autoprefixer')([
|
require('gulp-autoprefixer')(['last 1 version', '> 1%']),
|
||||||
'last 1 version',
|
|
||||||
'> 1%'
|
|
||||||
]),
|
|
||||||
PRODUCTION && require('gulp-csso')(),
|
PRODUCTION && require('gulp-csso')(),
|
||||||
dest()
|
dest()
|
||||||
)
|
)
|
||||||
@ -285,22 +282,20 @@ gulp.task(function copyAssets () {
|
|||||||
src(['assets/**/*', 'favicon.*']),
|
src(['assets/**/*', 'favicon.*']),
|
||||||
src('fontawesome-webfont.*', {
|
src('fontawesome-webfont.*', {
|
||||||
base: __dirname + '/node_modules/font-awesome/fonts', // eslint-disable-line no-path-concat
|
base: __dirname + '/node_modules/font-awesome/fonts', // eslint-disable-line no-path-concat
|
||||||
passthrough: true
|
passthrough: true,
|
||||||
}),
|
}),
|
||||||
src(['!*.css', 'font-mfizz.*'], {
|
src(['!*.css', 'font-mfizz.*'], {
|
||||||
base: __dirname + '/node_modules/font-mfizz/dist', // eslint-disable-line no-path-concat
|
base: __dirname + '/node_modules/font-mfizz/dist', // eslint-disable-line no-path-concat
|
||||||
passthrough: true
|
passthrough: true,
|
||||||
}),
|
}),
|
||||||
dest()
|
dest()
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('build', gulp.parallel(
|
gulp.task(
|
||||||
'buildPages',
|
'build',
|
||||||
'buildScripts',
|
gulp.parallel('buildPages', 'buildScripts', 'buildStyles', 'copyAssets')
|
||||||
'buildStyles',
|
)
|
||||||
'copyAssets'
|
|
||||||
))
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -2,25 +2,25 @@
|
|||||||
|
|
||||||
require('babel-register')
|
require('babel-register')
|
||||||
|
|
||||||
var Benchmark = require('benchmark')
|
const Benchmark = require('benchmark')
|
||||||
var globby = require('globby')
|
const globby = require('globby')
|
||||||
var resolve = require('path').resolve
|
const resolve = require('path').resolve
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
function bench (path) {
|
function bench (path) {
|
||||||
var fn = require(resolve(path))
|
let fn = require(resolve(path))
|
||||||
if (typeof fn !== 'function') {
|
if (typeof fn !== 'function') {
|
||||||
fn = fn.default
|
fn = fn.default
|
||||||
}
|
}
|
||||||
|
|
||||||
var benchmarks = []
|
const benchmarks = []
|
||||||
function benchmark (name, fn) {
|
function benchmark (name, fn) {
|
||||||
benchmarks.push(new Benchmark(name, fn))
|
benchmarks.push(new Benchmark(name, fn))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn({
|
fn({
|
||||||
benchmark: benchmark
|
benchmark: benchmark,
|
||||||
})
|
})
|
||||||
|
|
||||||
benchmarks.forEach(function (benchmark) {
|
benchmarks.forEach(function (benchmark) {
|
||||||
@ -38,7 +38,7 @@ function main (args) {
|
|||||||
throw new Error('no files to run')
|
throw new Error('no files to run')
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0, n = paths.length; i < n; ++i) {
|
for (let i = 0, n = paths.length; i < n; ++i) {
|
||||||
bench(paths[i])
|
bench(paths[i])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user