mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 12:07:10 -04:00
Breaking changes.
This commit is contained in:
parent
2b2656b7e1
commit
1ae45f6cbb
56 changed files with 457 additions and 379 deletions
|
@ -12,21 +12,11 @@ insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
|
||||||
[package.json]
|
[{package.json,.travis.yml,.eslintrc}]
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
|
||||||
[.travis.yml]
|
[{*.md,*.jade}]
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
|
|
||||||
|
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
|
|
||||||
|
|
||||||
[*.jade]
|
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
|
||||||
|
|
3
.eslintignore
Normal file
3
.eslintignore
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
build/*
|
||||||
|
node_modules/*
|
||||||
|
**/vendor/*
|
210
.eslintrc
Normal file
210
.eslintrc
Normal file
|
@ -0,0 +1,210 @@
|
||||||
|
---
|
||||||
|
root: true
|
||||||
|
|
||||||
|
parser: babel-eslint
|
||||||
|
|
||||||
|
env:
|
||||||
|
es6: true
|
||||||
|
node: true
|
||||||
|
|
||||||
|
globals:
|
||||||
|
modulejs: false
|
||||||
|
|
||||||
|
ecmaFeatures:
|
||||||
|
arrowFunctions: true
|
||||||
|
binaryLiterals: true
|
||||||
|
blockBindings: true
|
||||||
|
classes: false
|
||||||
|
defaultParams: true
|
||||||
|
destructuring: true
|
||||||
|
forOf: true
|
||||||
|
generators: true
|
||||||
|
globalReturn: true
|
||||||
|
jsx: false
|
||||||
|
modules: true
|
||||||
|
objectLiteralComputedProperties: true
|
||||||
|
objectLiteralDuplicateProperties: true
|
||||||
|
objectLiteralShorthandMethods: true
|
||||||
|
objectLiteralShorthandProperties: true
|
||||||
|
octalLiterals: true
|
||||||
|
regexUFlag: true
|
||||||
|
regexYFlag: true
|
||||||
|
spread: true
|
||||||
|
superInFunctions: false
|
||||||
|
templateStrings: true
|
||||||
|
unicodeCodePointEscapes: true
|
||||||
|
|
||||||
|
rules:
|
||||||
|
array-bracket-spacing: [2, never]
|
||||||
|
arrow-parens: [2, as-needed]
|
||||||
|
arrow-spacing: 2
|
||||||
|
block-scoped-var: 2
|
||||||
|
brace-style: [2, 1tbs, {allowSingleLine: true}]
|
||||||
|
camelcase: 0
|
||||||
|
comma-dangle: [2, never]
|
||||||
|
comma-spacing: [2, {before: false, after: true}]
|
||||||
|
comma-style: [2, last]
|
||||||
|
complexity: [1, 25] ###
|
||||||
|
computed-property-spacing: [2, never]
|
||||||
|
consistent-return: 2
|
||||||
|
consistent-this: [2, self]
|
||||||
|
constructor-super: 2
|
||||||
|
curly: [2, multi-line]
|
||||||
|
default-case: 2
|
||||||
|
dot-location: [2, property]
|
||||||
|
dot-notation: [2, {allowKeywords: true}]
|
||||||
|
eol-last: 2
|
||||||
|
eqeqeq: 2
|
||||||
|
func-names: 2
|
||||||
|
func-style: [2, declaration, {allowArrowFunctions: true}]
|
||||||
|
generator-star-spacing: [2, after]
|
||||||
|
guard-for-in: 2
|
||||||
|
handle-callback-err: 2
|
||||||
|
indent: [2, 4]
|
||||||
|
key-spacing: [2, {beforeColon: false, afterColon: true}]
|
||||||
|
linebreak-style: [2, unix]
|
||||||
|
max-depth: [1, 4]
|
||||||
|
max-len: [0, 80, 4]
|
||||||
|
max-nested-callbacks: [1, 3]
|
||||||
|
max-params: [1, 5] ###
|
||||||
|
max-statements: [1, 80] ###
|
||||||
|
new-cap: 1
|
||||||
|
new-parens: 2
|
||||||
|
newline-after-var: 0
|
||||||
|
no-alert: 2
|
||||||
|
no-array-constructor: 2
|
||||||
|
no-bitwise: 2
|
||||||
|
no-caller: 2
|
||||||
|
no-catch-shadow: 2
|
||||||
|
no-class-assign: 2
|
||||||
|
no-cond-assign: 2
|
||||||
|
no-console: 0 ###
|
||||||
|
no-const-assign: 2
|
||||||
|
no-constant-condition: 1
|
||||||
|
no-continue: 0
|
||||||
|
no-control-regex: 2
|
||||||
|
no-debugger: 2
|
||||||
|
no-delete-var: 2
|
||||||
|
no-div-regex: 2
|
||||||
|
no-dupe-args: 2
|
||||||
|
no-dupe-class-members: 2
|
||||||
|
no-dupe-keys: 2
|
||||||
|
no-duplicate-case: 2
|
||||||
|
no-else-return: 1
|
||||||
|
no-empty: 2
|
||||||
|
no-empty-character-class: 2
|
||||||
|
no-empty-label: 2
|
||||||
|
no-empty-pattern: 2
|
||||||
|
no-eq-null: 2
|
||||||
|
no-eval: 2
|
||||||
|
no-ex-assign: 2
|
||||||
|
no-extend-native: 1
|
||||||
|
no-extra-bind: 2
|
||||||
|
no-extra-boolean-cast: 2
|
||||||
|
no-extra-parens: 1
|
||||||
|
no-extra-semi: 2
|
||||||
|
no-fallthrough: 2
|
||||||
|
no-floating-decimal: 2
|
||||||
|
no-func-assign: 2
|
||||||
|
no-implicit-coercion: [2, {boolean: false, number: true, string: true}]
|
||||||
|
no-implied-eval: 2
|
||||||
|
no-inline-comments: 0
|
||||||
|
no-inner-declarations: [2, functions]
|
||||||
|
no-invalid-regexp: 2
|
||||||
|
no-invalid-this: 2
|
||||||
|
no-irregular-whitespace: 2
|
||||||
|
no-iterator: 2
|
||||||
|
no-label-var: 2
|
||||||
|
no-labels: 2
|
||||||
|
no-lone-blocks: 2
|
||||||
|
no-lonely-if: 2
|
||||||
|
no-loop-func: 1
|
||||||
|
no-magic-numbers: 0
|
||||||
|
no-mixed-requires: [2, false]
|
||||||
|
no-mixed-spaces-and-tabs: [2, false]
|
||||||
|
no-multi-spaces: 2
|
||||||
|
no-multi-str: 2
|
||||||
|
no-multiple-empty-lines: [2, {max: 4}]
|
||||||
|
no-native-reassign: 1
|
||||||
|
no-negated-in-lhs: 2
|
||||||
|
no-nested-ternary: 0
|
||||||
|
no-new: 2
|
||||||
|
no-new-func: 2
|
||||||
|
no-new-object: 2
|
||||||
|
no-new-require: 2
|
||||||
|
no-new-wrappers: 2
|
||||||
|
no-obj-calls: 2
|
||||||
|
no-octal: 2
|
||||||
|
no-octal-escape: 2
|
||||||
|
no-param-reassign: 0
|
||||||
|
no-path-concat: 2
|
||||||
|
no-plusplus: 2
|
||||||
|
no-process-env: 2
|
||||||
|
no-process-exit: 2
|
||||||
|
no-proto: 2
|
||||||
|
no-redeclare: 2
|
||||||
|
no-regex-spaces: 2
|
||||||
|
no-restricted-modules: 2
|
||||||
|
no-return-assign: 2
|
||||||
|
no-script-url: 2
|
||||||
|
no-self-compare: 2
|
||||||
|
no-sequences: 2
|
||||||
|
no-shadow: 2
|
||||||
|
no-shadow-restricted-names: 2
|
||||||
|
no-spaced-func: 2
|
||||||
|
no-sparse-arrays: 2
|
||||||
|
no-sync: 0
|
||||||
|
no-ternary: 0
|
||||||
|
no-this-before-super: 2
|
||||||
|
no-throw-literal: 1
|
||||||
|
no-trailing-spaces: 2
|
||||||
|
no-undef: 2
|
||||||
|
no-undef-init: 2
|
||||||
|
no-undefined: 0
|
||||||
|
no-underscore-dangle: 0
|
||||||
|
no-unexpected-multiline: 2
|
||||||
|
no-unneeded-ternary: 2
|
||||||
|
no-unreachable: 2
|
||||||
|
no-useless-call: 2
|
||||||
|
no-useless-concat: 2
|
||||||
|
no-unused-expressions: 2
|
||||||
|
no-unused-vars: [1, {vars: all, args: after-used}]
|
||||||
|
no-use-before-define: 2
|
||||||
|
no-var: 2
|
||||||
|
no-void: 2
|
||||||
|
no-warning-comments: [1, {terms: [todo, fixme, xxx], location: start}]
|
||||||
|
no-with: 2
|
||||||
|
object-curly-spacing: [2, never]
|
||||||
|
object-shorthand: [2, always]
|
||||||
|
one-var: [2, never]
|
||||||
|
operator-assignment: [2, always]
|
||||||
|
operator-linebreak: [2, after]
|
||||||
|
padded-blocks: [2, never]
|
||||||
|
prefer-arrow-callback: 2
|
||||||
|
prefer-const: 1
|
||||||
|
prefer-reflect: 1
|
||||||
|
prefer-spread: 2
|
||||||
|
prefer-template: 0 ###
|
||||||
|
quote-props: [2, as-needed]
|
||||||
|
quotes: [2, single, avoid-escape]
|
||||||
|
radix: 2
|
||||||
|
require-yield: 2
|
||||||
|
semi: 2
|
||||||
|
semi-spacing: [2, {before: false, after: true}]
|
||||||
|
sort-vars: 0
|
||||||
|
space-after-keywords: [2, always]
|
||||||
|
space-before-blocks: [2, always]
|
||||||
|
space-before-function-paren: [2, {anonymous: always, named: never}]
|
||||||
|
space-in-parens: [2, never]
|
||||||
|
space-infix-ops: 2
|
||||||
|
space-return-throw-case: 2
|
||||||
|
space-unary-ops: [2, {words: true, nonwords: false}]
|
||||||
|
spaced-comment: [2, always]
|
||||||
|
strict: [2, never]
|
||||||
|
use-isnan: 2
|
||||||
|
valid-jsdoc: 2
|
||||||
|
valid-typeof: 2
|
||||||
|
vars-on-top: 0
|
||||||
|
wrap-iife: [2, outside]
|
||||||
|
wrap-regex: 2
|
||||||
|
yoda: [2, never, {exceptRange: true}]
|
144
.jscsrc
144
.jscsrc
|
@ -1,144 +0,0 @@
|
||||||
{
|
|
||||||
"disallowEmptyBlocks": true,
|
|
||||||
"disallowImplicitTypeConversion": [
|
|
||||||
"binary",
|
|
||||||
//"boolean",
|
|
||||||
"numeric",
|
|
||||||
"string"
|
|
||||||
],
|
|
||||||
"disallowKeywords": [
|
|
||||||
"with"
|
|
||||||
],
|
|
||||||
"disallowKeywordsOnNewLine": [
|
|
||||||
"else"
|
|
||||||
],
|
|
||||||
"disallowMixedSpacesAndTabs": true,
|
|
||||||
"disallowMultipleLineStrings": true,
|
|
||||||
"disallowMultipleSpaces": true,
|
|
||||||
"disallowMultipleVarDecl": true,
|
|
||||||
"disallowNewlineBeforeBlockStatements": true,
|
|
||||||
"disallowQuotedKeysInObjects": true,
|
|
||||||
"disallowSpaceAfterObjectKeys": true,
|
|
||||||
"disallowSpaceAfterPrefixUnaryOperators": [
|
|
||||||
"++",
|
|
||||||
"--",
|
|
||||||
"+",
|
|
||||||
"-",
|
|
||||||
"~",
|
|
||||||
"!"
|
|
||||||
],
|
|
||||||
"disallowSpaceBeforePostfixUnaryOperators": [
|
|
||||||
"++",
|
|
||||||
"--"
|
|
||||||
],
|
|
||||||
"disallowSpacesInCallExpression": true,
|
|
||||||
"disallowSpacesInsideArrayBrackets": "all",
|
|
||||||
"disallowSpacesInsideObjectBrackets": true,
|
|
||||||
"disallowSpacesInsideParentheses": true,
|
|
||||||
"disallowTrailingComma": true,
|
|
||||||
"disallowTrailingWhitespace": true,
|
|
||||||
"disallowYodaConditions": true,
|
|
||||||
"requireCapitalizedConstructors": true,
|
|
||||||
"requireCommaBeforeLineBreak": true,
|
|
||||||
"requireCurlyBraces": [
|
|
||||||
"if",
|
|
||||||
"else",
|
|
||||||
"for",
|
|
||||||
"while",
|
|
||||||
"do",
|
|
||||||
"try",
|
|
||||||
"catch",
|
|
||||||
"case",
|
|
||||||
"default"
|
|
||||||
],
|
|
||||||
"requireDollarBeforejQueryAssignment": true,
|
|
||||||
"requireDotNotation": true,
|
|
||||||
"requireLineBreakAfterVariableAssignment": true,
|
|
||||||
"requireLineFeedAtFileEnd": true,
|
|
||||||
"requireOperatorBeforeLineBreak": [
|
|
||||||
"?",
|
|
||||||
"=",
|
|
||||||
"+",
|
|
||||||
"-",
|
|
||||||
"/",
|
|
||||||
"*",
|
|
||||||
"==",
|
|
||||||
"===",
|
|
||||||
"!=",
|
|
||||||
"!==",
|
|
||||||
">",
|
|
||||||
">=",
|
|
||||||
"<",
|
|
||||||
"<="
|
|
||||||
],
|
|
||||||
"requireParenthesesAroundIIFE": true,
|
|
||||||
"requireSemicolons": true,
|
|
||||||
"requireSpaceAfterBinaryOperators": [
|
|
||||||
"=",
|
|
||||||
",",
|
|
||||||
"+",
|
|
||||||
"-",
|
|
||||||
"/",
|
|
||||||
"*",
|
|
||||||
"==",
|
|
||||||
"===",
|
|
||||||
"!=",
|
|
||||||
"!=="
|
|
||||||
],
|
|
||||||
"requireSpaceAfterKeywords": [
|
|
||||||
"do",
|
|
||||||
"for",
|
|
||||||
"if",
|
|
||||||
"else",
|
|
||||||
"switch",
|
|
||||||
"case",
|
|
||||||
"try",
|
|
||||||
"catch",
|
|
||||||
"void",
|
|
||||||
"while",
|
|
||||||
"with",
|
|
||||||
"return",
|
|
||||||
"typeof",
|
|
||||||
"function"
|
|
||||||
],
|
|
||||||
"requireSpaceAfterLineComment": true,
|
|
||||||
"requireSpaceBeforeBinaryOperators": [
|
|
||||||
"=",
|
|
||||||
"+",
|
|
||||||
"-",
|
|
||||||
"/",
|
|
||||||
"*",
|
|
||||||
"==",
|
|
||||||
"===",
|
|
||||||
"!=",
|
|
||||||
"!=="
|
|
||||||
],
|
|
||||||
"requireSpaceBeforeBlockStatements": true,
|
|
||||||
"requireSpaceBeforeKeywords": [
|
|
||||||
"else",
|
|
||||||
"while",
|
|
||||||
"catch"
|
|
||||||
],
|
|
||||||
"requireSpaceBeforeObjectValues": true,
|
|
||||||
"requireSpaceBetweenArguments": true,
|
|
||||||
"requireSpacesInAnonymousFunctionExpression": {
|
|
||||||
"beforeOpeningRoundBrace": true,
|
|
||||||
"beforeOpeningCurlyBrace": true
|
|
||||||
},
|
|
||||||
"requireSpacesInConditionalExpression": {
|
|
||||||
"afterTest": true,
|
|
||||||
"beforeConsequent": true,
|
|
||||||
"afterConsequent": true,
|
|
||||||
"beforeAlternate": true
|
|
||||||
},
|
|
||||||
"requireSpacesInForStatement": true,
|
|
||||||
"validateIndentation": 4,
|
|
||||||
"validateJSDoc": {
|
|
||||||
"checkParamNames": true,
|
|
||||||
"checkRedundantParams": true,
|
|
||||||
"requireParamTypes": true
|
|
||||||
},
|
|
||||||
"validateLineBreaks": "LF",
|
|
||||||
"validateParameterSeparator": ", ",
|
|
||||||
"validateQuoteMarks": "'"
|
|
||||||
}
|
|
26
.jshintrc
26
.jshintrc
|
@ -1,26 +0,0 @@
|
||||||
{
|
|
||||||
"bitwise": true,
|
|
||||||
"curly": true,
|
|
||||||
"eqeqeq": true,
|
|
||||||
"forin": true,
|
|
||||||
"freeze": true,
|
|
||||||
"futurehostile": true,
|
|
||||||
"latedef": true,
|
|
||||||
"maxdepth": 3,
|
|
||||||
"noarg": true,
|
|
||||||
"nocomma": true,
|
|
||||||
"nonbsp": true,
|
|
||||||
"nonew": true,
|
|
||||||
"plusplus": true,
|
|
||||||
"strict": false,
|
|
||||||
"supernew": true,
|
|
||||||
"trailing": true,
|
|
||||||
"undef": true,
|
|
||||||
"unused": true,
|
|
||||||
|
|
||||||
"browser": true,
|
|
||||||
|
|
||||||
"globals": {
|
|
||||||
"modulejs": false
|
|
||||||
}
|
|
||||||
}
|
|
17
README.md
17
README.md
|
@ -23,25 +23,16 @@ In short you have to take the following two steps:
|
||||||
There are installation ready packages for the latest [releases][release] and
|
There are installation ready packages for the latest [releases][release] and
|
||||||
[dev builds][develop]. But to clone and build **h5ai** yourself run the
|
[dev builds][develop]. But to clone and build **h5ai** yourself run the
|
||||||
following commands to find a fresh zipball in folder `build` (tested on linux
|
following commands to find a fresh zipball in folder `build` (tested on linux
|
||||||
only, requires [`git`][git] and [`node 0.12+`][node] to be installed).
|
only, requires [`git`][git] and [`node 4.x`][node] to be installed).
|
||||||
|
|
||||||
|
~~~sh
|
||||||
First install the global command line trigger for the [`mkr`][mkr] build tool:
|
|
||||||
|
|
||||||
~~~
|
|
||||||
> npm install -g mkr-global
|
|
||||||
~~~
|
|
||||||
|
|
||||||
Then run:
|
|
||||||
|
|
||||||
~~~
|
|
||||||
> git clone git://github.com/lrsjng/h5ai.git
|
> git clone git://github.com/lrsjng/h5ai.git
|
||||||
> cd h5ai
|
> cd h5ai
|
||||||
> npm install
|
> npm install
|
||||||
> mkr release
|
> npm run build
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
To build the frontend test suite run `mkr build-test`. This will output a
|
To build the frontend test suite run `npm run build-test`. This will output a
|
||||||
`file://`-URL you can look up in your browser to run the tests.
|
`file://`-URL you can look up in your browser to run the tests.
|
||||||
|
|
||||||
|
|
||||||
|
|
280
mkrfile.js
280
mkrfile.js
|
@ -1,167 +1,243 @@
|
||||||
/*jshint node: true */
|
import fq from 'fquery';
|
||||||
'use strict';
|
import dateformat from 'dateformat';
|
||||||
|
import {join, resolve} from 'path';
|
||||||
|
import webpack from 'webpack';
|
||||||
|
import {spawnSync} from 'child_process';
|
||||||
|
|
||||||
|
const loadPlugins = () => {
|
||||||
|
const pkg = require('./package.json');
|
||||||
|
const deps = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.devDependencies || {})];
|
||||||
|
const plugs = deps.filter(name => name.startsWith('fquery-'));
|
||||||
|
plugs.forEach(plug => fq.plugin(plug));
|
||||||
|
};
|
||||||
|
loadPlugins();
|
||||||
|
|
||||||
var path = require('path');
|
const root = resolve(__dirname);
|
||||||
var $ = require('fquery');
|
const src = join(root, 'src');
|
||||||
|
const build = join(root, 'build');
|
||||||
|
|
||||||
var pkg = require('./package.json');
|
function once(fn) {
|
||||||
|
let getter = () => {
|
||||||
var root = path.resolve(__dirname);
|
const value = fn();
|
||||||
var src = path.join(root, 'src');
|
getter = () => value;
|
||||||
var build = path.join(root, 'build');
|
return value;
|
||||||
|
};
|
||||||
|
return () => getter();
|
||||||
function getBuildSuffixSync() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
var out = require('child_process').execSync('git rev-list v' + pkg.version + '..HEAD', {cwd: root, encoding: 'utf8'});
|
|
||||||
var lines = out.trim().split(/\r?\n/);
|
|
||||||
return '+' + ('000' + lines.length).substr(-3) + '~' + lines[0].substring(0, 7);
|
|
||||||
} catch (e) {}
|
|
||||||
return '+X';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function run(cmd, {info = true, stdout = true, stderr = true, liberal = false, local = true} = {}) {
|
||||||
|
const stdio = ['ignore', stdout ? 1 : 'pipe', stderr ? 2 : 'pipe'];
|
||||||
|
if (info) {
|
||||||
|
fq.report({type: 'info', method: 'run', message: cmd});
|
||||||
|
}
|
||||||
|
const precmd = local ? 'PATH=./node_modules/.bin:$PATH;' : '';
|
||||||
|
const res = spawnSync('sh', ['-c', precmd + cmd], {
|
||||||
|
cwd: root,
|
||||||
|
stdio,
|
||||||
|
encoding: 'utf-8'
|
||||||
|
});
|
||||||
|
if (res.status !== 0 && !liberal) {
|
||||||
|
fq.report({type: 'err', method: 'run', message: `${cmd} [${res.status}] ${String(res.error)}`});
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
$.plugin('fquery-autoprefixer');
|
const getStamp = once(() => {
|
||||||
$.plugin('fquery-cssmin');
|
const stamp = new Date();
|
||||||
$.plugin('fquery-handlebars');
|
stamp.human = dateformat(stamp, 'yyyy-mm-dd HH:MM:ss');
|
||||||
$.plugin('fquery-includeit');
|
stamp.id = stamp.human.replace(/\D/g, '-');
|
||||||
$.plugin('fquery-jade');
|
stamp.sha1 = fq.getHash(stamp.id);
|
||||||
$.plugin('fquery-jshint');
|
return stamp;
|
||||||
$.plugin('fquery-jszip');
|
});
|
||||||
$.plugin('fquery-less');
|
|
||||||
$.plugin('fquery-uglifyjs');
|
|
||||||
|
|
||||||
|
const getPackage = once(() => {
|
||||||
|
const pkg = require('./package.json');
|
||||||
|
const res = run(`git rev-list v${pkg.version}..HEAD`, {info: false, stdout: false, stderr: false, liberal: true});
|
||||||
|
if (res.status === 0) {
|
||||||
|
const hashes = fq._.compact(res.stdout.split(/\r?\n/));
|
||||||
|
if (hashes.length) {
|
||||||
|
pkg.version += `+${hashes.length}~${hashes[0].substr(0, 7)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pkg;
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = function (suite) {
|
const getComment = once(() => {
|
||||||
|
const pkg = getPackage();
|
||||||
|
return `${pkg.name} v${pkg.version} - ${getStamp().human}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
const getHeader = once(() => `/* ${getComment()} */\n`);
|
||||||
|
|
||||||
|
function formatWebpackStats(stats, len) {
|
||||||
|
const json = stats.toJson();
|
||||||
|
const align = (s, i) => ` ${s}`.substr(-i);
|
||||||
|
const cmp = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
||||||
|
const sortBy = (arr, selector = x => x) => Array.from(arr).sort((a, b) => cmp(selector(a), selector(b)));
|
||||||
|
let res = sortBy(json.modules, x => x.size);
|
||||||
|
if (len) {
|
||||||
|
res = 'stats\n' + res.slice(-len).map(r => {
|
||||||
|
return `${align(`[${r.id}]`, 7)}${align(r.size, 10)} ${r.name}`;
|
||||||
|
}).join('\n');
|
||||||
|
res += `\n\n${align(json.modules.length, 7)}${align(json.assets[0].size, 10)} ${json.assets[0].name}`;
|
||||||
|
} else {
|
||||||
|
res = `modules: ${json.modules.length}, bytes: ${json.assets[0].size}, bundle: ${json.assets[0].name}`;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = suite => {
|
||||||
suite.defaults('release');
|
suite.defaults('release');
|
||||||
|
|
||||||
|
suite.target('clean', [], 'delete build folder').task(() => {
|
||||||
|
fq(build, {dirs: true}).delete();
|
||||||
|
});
|
||||||
|
|
||||||
suite.target('check-version', [], 'add git info to dev builds').task(function () {
|
suite.target('lint', [], 'lint all JavaScript files with eslint').task(() => {
|
||||||
|
run(`eslint ${src}/_h5ai/public/js`);
|
||||||
|
});
|
||||||
|
|
||||||
if (pkg.develop) {
|
suite.target('build:scripts').task(done => {
|
||||||
pkg.version += getBuildSuffixSync();
|
const mapSrc = fq.map.p(src, build);
|
||||||
$.report({type: 'info', method: 'check-version', message: 'version set to ' + pkg.version});
|
const scriptsChanged = fq(`${src}: _h5ai/public/js/scripts.js`)
|
||||||
|
.newerThan(mapSrc, fq(`${src}: _h5ai/public/js/**`)).length > 0;
|
||||||
|
|
||||||
|
if (!scriptsChanged) {
|
||||||
|
done();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const webpackConfig = {
|
||||||
|
context: src,
|
||||||
|
entry: './_h5ai/public/js/scripts.js',
|
||||||
|
output: {
|
||||||
|
path: build,
|
||||||
|
filename: '_h5ai/public/js/scripts.js'
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
loaders: [
|
||||||
|
{
|
||||||
|
include: [src],
|
||||||
|
loader: 'babel',
|
||||||
|
query: {
|
||||||
|
cacheDirectory: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!suite.args.production) {
|
||||||
|
webpackConfig.output.pathinfo = true;
|
||||||
|
webpackConfig.devtool = '#inline-source-map';
|
||||||
|
}
|
||||||
|
|
||||||
|
webpack(webpackConfig, (err, stats) => {
|
||||||
|
if (err) {
|
||||||
|
fq.report({type: 'err', method: 'scripts', message: err});
|
||||||
|
}
|
||||||
|
console.log(stats.toString({colors: true}));
|
||||||
|
// fq.report({type: 'info', method: 'webpack', message: formatWebpackStats(stats, 10)});
|
||||||
|
|
||||||
|
fq(`${build}: _h5ai/public/js/scripts.js`)
|
||||||
|
.if(suite.args.production, function applyuglifyjs() {
|
||||||
|
this.uglifyjs(); // eslint-disable-line no-invalid-this
|
||||||
|
})
|
||||||
|
.wrap(getHeader())
|
||||||
|
.write(mapSrc, true);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
suite.target('build', [], 'build all updated files, optionally use :uncompressed (e.g. mkr -b build :uncompressed)').task(() => {
|
||||||
|
const env = {pkg: getPackage()};
|
||||||
|
const mapSrc = fq.map.p(src, build).s('.less', '.css').s('.jade', '');
|
||||||
|
const mapRoot = fq.map.p(root, join(build, '_h5ai'));
|
||||||
|
|
||||||
suite.target('clean', [], 'delete build folder').task(function () {
|
fq(`${src}: _h5ai/public/js/*.js`)
|
||||||
|
.newerThan(mapSrc, fq(`${src}: _h5ai/public/js/**`))
|
||||||
$(build, {dirs: true}).delete();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
suite.target('lint', [], 'lint all JavaScript files with JSHint').task(function () {
|
|
||||||
|
|
||||||
var fs = require('fs');
|
|
||||||
var jshint = JSON.parse(fs.readFileSync('.jshintrc', 'utf8'));
|
|
||||||
|
|
||||||
$(src + '/_h5ai/public/js: **/*.js, ! lib/**')
|
|
||||||
.jshint(jshint, jshint.globals);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
suite.target('build', ['check-version', 'lint'], 'build all updated files, optionally use :uncompressed (e.g. mkr build :uncompressed)').task(function () {
|
|
||||||
|
|
||||||
var header = '/* ' + pkg.name + ' ' + pkg.version + ' - ' + pkg.homepage + ' */\n';
|
|
||||||
var env = {pkg: pkg};
|
|
||||||
var mapSrc = $.map.p(src, build).s('.less', '.css').s('.jade', '');
|
|
||||||
var mapRoot = $.map.p(root, path.join(build, '_h5ai'));
|
|
||||||
|
|
||||||
$(src + ': _h5ai/public/js/*.js')
|
|
||||||
.newerThan(mapSrc, $(src + ': _h5ai/public/js/**'))
|
|
||||||
.includeit()
|
.includeit()
|
||||||
.if(!suite.args.uncompressed, function () { this.uglifyjs(); })
|
.if(!suite.args.uncompressed, function applyuglifyjs() {
|
||||||
.wrap(header)
|
this.uglifyjs(); // eslint-disable-line no-invalid-this
|
||||||
|
})
|
||||||
|
.wrap(getHeader())
|
||||||
.write(mapSrc, true);
|
.write(mapSrc, true);
|
||||||
|
|
||||||
$(src + ': _h5ai/public/css/*.less')
|
fq(`${src}: _h5ai/public/css/*.less`)
|
||||||
.newerThan(mapSrc, $(src + ': _h5ai/public/css/**'))
|
.newerThan(mapSrc, fq(`${src}: _h5ai/public/css/**`))
|
||||||
.includeit()
|
.includeit()
|
||||||
.less()
|
.less()
|
||||||
.autoprefixer()
|
.autoprefixer()
|
||||||
.if(!suite.args.uncompressed, function () { this.cssmin(); })
|
.if(!suite.args.uncompressed, function applycssmin() {
|
||||||
.wrap(header)
|
this.cssmin(); // eslint-disable-line no-invalid-this
|
||||||
|
})
|
||||||
|
.wrap(getHeader())
|
||||||
.write(mapSrc, true);
|
.write(mapSrc, true);
|
||||||
|
|
||||||
$(src + ': **/*.jade, ! **/*.tpl.jade')
|
fq(`${src}: **/*.jade, ! **/*.tpl.jade`)
|
||||||
.newerThan(mapSrc)
|
.newerThan(mapSrc)
|
||||||
.jade(env)
|
.jade(env)
|
||||||
.write(mapSrc, true);
|
.write(mapSrc, true);
|
||||||
|
|
||||||
$(src + ': **, ! _h5ai/public/js/**, ! _h5ai/public/css/**, ! **/*.jade')
|
fq(`${src}: **, ! _h5ai/public/js/**, ! _h5ai/public/css/**, ! **/*.jade`)
|
||||||
.newerThan(mapSrc)
|
.newerThan(mapSrc)
|
||||||
.handlebars(env)
|
.handlebars(env)
|
||||||
.write(mapSrc, true);
|
.write(mapSrc, true);
|
||||||
|
|
||||||
$(root + ': *.md')
|
fq(`${root}: *.md`)
|
||||||
.newerThan(mapRoot)
|
.newerThan(mapRoot)
|
||||||
.write(mapRoot, true);
|
.write(mapRoot, true);
|
||||||
|
|
||||||
|
fq.report({type: 'info', message: getComment()});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
suite.target('deploy', ['build'], 'deploy to a specified path (e.g. mkr -b deploy :dest=/some/path)').task(() => {
|
||||||
suite.target('deploy', ['build'], 'deploy to a specified path (e.g. mkr deploy :dest=/some/path)').task(function () {
|
if (!fq._.isString(suite.args.dest)) {
|
||||||
|
fq.report({type: 'err', message: 'no destination path (e.g. mkr -b deploy :dest=/some/path)'});
|
||||||
if (!$._.isString(suite.args.dest)) {
|
|
||||||
$.report({
|
|
||||||
type: 'err',
|
|
||||||
message: 'no destination path (e.g. mkr deploy :dest=/some/path)'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var mapper = $.map.p(build, path.resolve(suite.args.dest));
|
const mapper = fq.map.p(build, resolve(suite.args.dest));
|
||||||
|
|
||||||
$(build + ': _h5ai/**')
|
fq(`${build}: _h5ai/**`)
|
||||||
.newerThan(mapper)
|
.newerThan(mapper)
|
||||||
.write(mapper, true);
|
.write(mapper, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// suite.target('release', ['clean', 'lint', 'build'], 'create a zipball').task(() => {
|
||||||
|
suite.target('release', ['clean', 'build'], 'create a zipball').task(() => {
|
||||||
|
const pkg = getPackage();
|
||||||
|
const target = join(build, `${pkg.name}-${pkg.version}.zip`);
|
||||||
|
|
||||||
suite.target('release', ['clean', 'build'], 'create a zipball').task(function () {
|
fq(`${build}: **`)
|
||||||
|
|
||||||
var target = path.join(build, pkg.name + '-' + pkg.version + '.zip');
|
|
||||||
|
|
||||||
$(build + ': **')
|
|
||||||
.jszip({dir: build, level: 9})
|
.jszip({dir: build, level: 9})
|
||||||
.write(target, true);
|
.write(target, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
suite.target('build-test', [], 'build a test suite').task(() => {
|
||||||
suite.target('build-test', ['check-version'], 'build a test suite').task(function () {
|
fq(`${src}/_h5ai/public/css/styles.less`)
|
||||||
|
|
||||||
var env = {pkg: pkg};
|
|
||||||
|
|
||||||
$(src + '/_h5ai/public/css/styles.less')
|
|
||||||
.includeit()
|
.includeit()
|
||||||
.less()
|
.less()
|
||||||
.autoprefixer()
|
.autoprefixer()
|
||||||
.write(build + '/test/h5ai-styles.css', true);
|
.write(`${build}/test/h5ai-styles.css`, true);
|
||||||
|
|
||||||
$(src + '/_h5ai/public/js/scripts.js')
|
fq(`${src}/_h5ai/public/js/scripts.js`)
|
||||||
.includeit()
|
.includeit()
|
||||||
.write(build + '/test/h5ai-scripts.js', true);
|
.write(`${build}/test/h5ai-scripts.js`, true);
|
||||||
|
|
||||||
$(root + '/test/styles.less')
|
fq(`${root}/test/styles.less`)
|
||||||
.includeit()
|
.includeit()
|
||||||
.less()
|
.less()
|
||||||
.autoprefixer()
|
.autoprefixer()
|
||||||
.write(build + '/test/styles.css', true);
|
.write(`${build}/test/styles.css`, true);
|
||||||
|
|
||||||
$(root + '/test/scripts.js')
|
fq(`${root}/test/scripts.js`)
|
||||||
.includeit()
|
.includeit()
|
||||||
.write(build + '/test/scripts.js', true);
|
.write(`${build}/test/scripts.js`, true);
|
||||||
|
|
||||||
$(root + '/test/index.html.jade')
|
fq(`${root}/test/index.html.jade`)
|
||||||
.jade(env)
|
.jade({pkg: getPackage()})
|
||||||
.write(build + '/test/index.html', true);
|
.write(`${build}/test/index.html`, true);
|
||||||
|
|
||||||
$.report({
|
fq.report({type: 'info', message: `browse to file://${build}/test/index.html`});
|
||||||
type: 'info',
|
|
||||||
message: 'browse to file://' + build + '/test/index.html'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
40
package.json
40
package.json
|
@ -2,33 +2,39 @@
|
||||||
"name": "h5ai",
|
"name": "h5ai",
|
||||||
"version": "0.27.0",
|
"version": "0.27.0",
|
||||||
"develop": true,
|
"develop": true,
|
||||||
"description": "a modern HTTP web server index",
|
"description": "A modern HTTP web server index.",
|
||||||
"homepage": "http://larsjung.de/h5ai/",
|
"homepage": "https://larsjung.de/h5ai/",
|
||||||
"bugs": "https://github.com/lrsjng/h5ai/issues",
|
"bugs": "https://github.com/lrsjng/h5ai/issues",
|
||||||
"author": "Lars Jung <lrsjng@gmail.com> (http://larsjung.de)",
|
"author": "Lars Jung <lrsjng@gmail.com> (https://larsjung.de)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/lrsjng/h5ai.git"
|
"url": "https://github.com/lrsjng/h5ai.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "mkr release",
|
"build": "mkr -b release",
|
||||||
"build-test": "mkr build-test"
|
"build-test": "mkr -b build-test"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"fquery": "~0.16.4",
|
"babel": "^5.8.23",
|
||||||
"fquery-autoprefixer": "~0.2.0",
|
"babel-eslint": "^4.1.3",
|
||||||
"fquery-cssmin": "~0.3.1",
|
"babel-loader": "^5.3.2",
|
||||||
"fquery-handlebars": "~0.3.0",
|
"dateformat": "^1.0.11",
|
||||||
"fquery-includeit": "~0.3.0",
|
"eslint": "^1.7.3",
|
||||||
"fquery-jade": "~0.5.0",
|
"fquery": "^0.16.4",
|
||||||
"fquery-jshint": "~0.3.0",
|
"fquery-autoprefixer": "^0.3.0",
|
||||||
"fquery-jszip": "~0.5.1",
|
"fquery-cssmin": "^0.3.1",
|
||||||
"fquery-less": "~0.3.0",
|
"fquery-gethash": "^0.3.0",
|
||||||
"fquery-uglifyjs": "~0.3.0",
|
"fquery-handlebars": "^0.3.0",
|
||||||
"mkr": "~0.8.5"
|
"fquery-includeit": "^0.3.0",
|
||||||
|
"fquery-jade": "^0.6.0",
|
||||||
|
"fquery-jszip": "^0.5.1",
|
||||||
|
"fquery-less": "^0.3.0",
|
||||||
|
"fquery-uglifyjs": "^0.3.0",
|
||||||
|
"mkr": "^0.10.0",
|
||||||
|
"webpack": "^1.12.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "0.12.x"
|
"node": "4.x"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
@charset "utf-8";
|
@charset "utf-8";
|
||||||
|
|
||||||
// @include "lib/h5bp-normalize.less"
|
// @include "vendor/normalize.less"
|
||||||
// @include "lib/h5bp-main-header.less"
|
// @include "vendor/h5bp-pre.less"
|
||||||
|
|
||||||
// @include "inc/colors.less"
|
// @include "lib/colors.less"
|
||||||
// @include "inc/fonts.less"
|
// @include "lib/fonts.less"
|
||||||
// @include "inc/misc.less"
|
// @include "lib/misc.less"
|
||||||
// @include "inc/mixins.less"
|
// @include "lib/mixins.less"
|
||||||
|
|
||||||
// @include "inc/*/*.less"
|
// @include "lib/*/*.less"
|
||||||
|
|
||||||
// @include "inc/responsive.less"
|
// @include "lib/responsive.less"
|
||||||
|
|
||||||
// @include "lib/h5bp-main-footer.less"
|
// @include "vendor/h5bp-post.less"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
========================================================================== */
|
========================================================================== */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hide visually and from screen readers:
|
* Hide visually and from screen readers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
|
@ -84,6 +84,7 @@
|
||||||
|
|
||||||
// @media print,
|
// @media print,
|
||||||
// (-webkit-min-device-pixel-ratio: 1.25),
|
// (-webkit-min-device-pixel-ratio: 1.25),
|
||||||
|
// (min-resolution: 1.25dppx),
|
||||||
// (min-resolution: 120dpi) {
|
// (min-resolution: 120dpi) {
|
||||||
// /* Style adjustments for high resolution devices */
|
// /* Style adjustments for high resolution devices */
|
||||||
// }
|
// }
|
||||||
|
@ -97,7 +98,9 @@
|
||||||
@media print {
|
@media print {
|
||||||
*,
|
*,
|
||||||
*:before,
|
*:before,
|
||||||
*:after {
|
*:after,
|
||||||
|
*:first-letter,
|
||||||
|
*:first-line {
|
||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
color: #000 !important; /* Black prints faster:
|
color: #000 !important; /* Black prints faster:
|
||||||
http://www.sanbeiji.com/archives/953 */
|
http://www.sanbeiji.com/archives/953 */
|
|
@ -1,4 +1,4 @@
|
||||||
/*! HTML5 Boilerplate v5.1.0 | MIT License | https://html5boilerplate.com/ */
|
/*! HTML5 Boilerplate v5.2.0 | MIT License | https://html5boilerplate.com/ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* What follows is the result of much research on cross-browser styling.
|
* What follows is the result of much research on cross-browser styling.
|
||||||
|
@ -84,12 +84,12 @@ textarea {
|
||||||
Browser Upgrade Prompt
|
Browser Upgrade Prompt
|
||||||
========================================================================== */
|
========================================================================== */
|
||||||
|
|
||||||
.browserupgrade {
|
// .browserupgrade {
|
||||||
margin: 0.2em 0;
|
// margin: 0.2em 0;
|
||||||
background: #ccc;
|
// background: #ccc;
|
||||||
color: #000;
|
// color: #000;
|
||||||
padding: 0.2em 0;
|
// padding: 0.2em 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* ==========================================================================
|
/* ==========================================================================
|
||||||
Author's custom styles
|
Author's custom styles
|
|
@ -1,7 +1,11 @@
|
||||||
modulejs.define('boot', ['$', 'core/server'], function ($, server) {
|
modulejs.define('boot', ['$', 'core/server'], function ($, server) {
|
||||||
|
|
||||||
var module = $('script[data-module]').data('module');
|
var module = $('script[data-module]').data('module');
|
||||||
var data = {action: 'get', setup: true, options: true, types: true};
|
var data = {
|
||||||
|
action: 'get',
|
||||||
|
setup: true,
|
||||||
|
options: true,
|
||||||
|
types: true
|
||||||
|
};
|
||||||
|
|
||||||
if (module === 'index') {
|
if (module === 'index') {
|
||||||
data.theme = true;
|
data.theme = true;
|
||||||
|
@ -13,8 +17,9 @@ modulejs.define('boot', ['$', 'core/server'], function ($, server) {
|
||||||
}
|
}
|
||||||
|
|
||||||
server.request(data, function (config) {
|
server.request(data, function (config) {
|
||||||
|
|
||||||
modulejs.define('config', config);
|
modulejs.define('config', config);
|
||||||
$(function () { modulejs.require('main/' + module); });
|
$(function () {
|
||||||
|
modulejs.require('main/' + module);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|
||||||
// @include 'lib/jquery-*.js'
|
// @include 'vendor/jquery-*.js'
|
||||||
// @include 'lib/jquery.*.js'
|
// @include 'vendor/jquery.*.js'
|
||||||
// @include 'lib/lodash-*.js'
|
// @include 'vendor/lodash-*.js'
|
||||||
// @include 'lib/marked-*.js'
|
// @include 'vendor/marked-*.js'
|
||||||
// @include 'lib/modulejs-*.js'
|
// @include 'vendor/modulejs-*.js'
|
||||||
// @include 'lib/prism-*.js'
|
// @include 'vendor/prism-*.js'
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
{
|
|
||||||
"bitwise": true,
|
|
||||||
"curly": true,
|
|
||||||
"eqeqeq": true,
|
|
||||||
"forin": true,
|
|
||||||
"freeze": true,
|
|
||||||
"futurehostile": true,
|
|
||||||
"latedef": true,
|
|
||||||
"maxdepth": 3,
|
|
||||||
"noarg": true,
|
|
||||||
"nocomma": true,
|
|
||||||
"nonbsp": true,
|
|
||||||
"nonew": true,
|
|
||||||
"plusplus": true,
|
|
||||||
"strict": true,
|
|
||||||
"supernew": true,
|
|
||||||
"trailing": true,
|
|
||||||
"undef": true,
|
|
||||||
"unused": true,
|
|
||||||
|
|
||||||
"browser": true,
|
|
||||||
"mocha": true,
|
|
||||||
|
|
||||||
"globals": {
|
|
||||||
"_": false,
|
|
||||||
"$": false,
|
|
||||||
"assert": false,
|
|
||||||
"chai": false,
|
|
||||||
"jQuery": false,
|
|
||||||
"mocha": false,
|
|
||||||
"modulejs": false,
|
|
||||||
"sinon": false,
|
|
||||||
"uniq": false,
|
|
||||||
"util": false
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
// @include "lib/*.js"
|
// @include "vendor/*.js"
|
||||||
// @include "util/*.js"
|
// @include "util/*.js"
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
0
test/lib/chai.js → test/vendor/chai.js
vendored
0
test/lib/chai.js → test/vendor/chai.js
vendored
0
test/lib/mocha.js → test/vendor/mocha.js
vendored
0
test/lib/mocha.js → test/vendor/mocha.js
vendored
0
test/lib/sinon.js → test/vendor/sinon.js
vendored
0
test/lib/sinon.js → test/vendor/sinon.js
vendored
0
test/lib/uniq.js → test/vendor/uniq.js
vendored
0
test/lib/uniq.js → test/vendor/uniq.js
vendored
Loading…
Add table
Add a link
Reference in a new issue