This commit is contained in:
Lars Jung 2019-04-24 02:09:57 +02:00
parent 24d8359a2e
commit 50167d3382
11 changed files with 396 additions and 599 deletions

View File

@ -9,9 +9,10 @@
* remove `babel-loader`
* update `eslint` to 5.16.0
* update `ghu` to 0.18.0
* update `jsdom` to 14.0.0
* update `kjua` to 0.4.0
* update `jsdom` to 15.0.0
* update `kjua` to 0.5.0
* update `lolight` to 1.2.0
* update `null-loader` to 1.0.0
* update `scar` to 1.6.0

15
ghu.js
View File

@ -1,7 +1,7 @@
const {resolve, join} = require('path');
const {
ghu, autoprefixer, cssmin, each, ife, includeit, jszip, less, mapfn,
newerThan, pug, read, remove, run, uglify, watch, webpack, wrap, write
pug, read, remove, run, uglify, watch, webpack, wrap, write
} = require('ghu');
const ROOT = resolve(__dirname);
@ -54,8 +54,7 @@ ghu.task('clean', 'delete build folder', () => {
ghu.task('build:scripts', runtime => {
return read(`${SRC}/_h5ai/public/js/scripts.js`)
.then(newerThan(mapper, `${SRC}/_h5ai/public/js/**`))
.then(webpack(webpack_cfg(SRC), {showStats: false}))
.then(webpack(webpack_cfg(SRC)))
.then(wrap('\n\n// @include "pre.js"\n\n'))
.then(includeit())
.then(ife(() => runtime.args.production, uglify()))
@ -65,7 +64,6 @@ ghu.task('build:scripts', runtime => {
ghu.task('build:styles', runtime => {
return read(`${SRC}/_h5ai/public/css/*.less`)
.then(newerThan(mapper, `${SRC}/_h5ai/public/css/**`))
.then(includeit())
.then(less())
.then(autoprefixer())
@ -76,7 +74,6 @@ ghu.task('build:styles', runtime => {
ghu.task('build:pages', runtime => {
return read(`${SRC}: **/*.pug, ! **/*.tpl.pug`)
.then(newerThan(mapper, `${SRC}/**/*.tpl.pug`))
.then(pug({pkg: runtime.pkg}))
.then(wrap('', runtime.comment_html))
.then(write(mapper, {overwrite: true}));
@ -87,12 +84,10 @@ ghu.task('build:copy', runtime => {
return Promise.all([
read(`${SRC}/**/conf/*.json`)
.then(newerThan(mapper))
.then(wrap(runtime.comment_js))
.then(write(mapper, {overwrite: true, cluster: true})),
read(`${SRC}: **, ! **/*.js, ! **/*.less, ! **/*.pug, ! **/conf/*.json`)
.then(newerThan(mapper))
.then(each(obj => {
if ((/index\.php$/).test(obj.source)) {
obj.content = obj.content.replace('{{VERSION}}', runtime.pkg.version);
@ -101,7 +96,6 @@ ghu.task('build:copy', runtime => {
.then(write(mapper, {overwrite: true, cluster: true})),
read(`${ROOT}/*.md`)
.then(newerThan(mapper_root))
.then(write(mapper_root, {overwrite: true, cluster: true}))
]);
});
@ -109,15 +103,13 @@ ghu.task('build:copy', runtime => {
ghu.task('build:tests', ['build:styles'], 'build the test suite', () => {
return Promise.all([
read(`${BUILD}/_h5ai/public/css/styles.css`)
.then(newerThan(`${BUILD}/test/h5ai-styles.css`))
.then(write(`${BUILD}/test/h5ai-styles.css`, {overwrite: true})),
read(`${TEST}/index.html`)
.then(newerThan(`${BUILD}/test/index.html`))
.then(write(`${BUILD}/test/index.html`, {overwrite: true})),
read(`${TEST}: index.js`)
.then(webpack(webpack_cfg(SRC, TEST), {showStats: false}))
.then(webpack(webpack_cfg(SRC, TEST)))
.then(wrap(`\n\n// @include "${SRC}/**/js/pre.js"\n\n`))
.then(includeit())
.then(write(mapfn.p(TEST, `${BUILD}/test`), {overwrite: true}))
@ -138,7 +130,6 @@ ghu.task('deploy', ['build'], 'deploy to a specified path with :dest=/some/path'
const mapper_deploy = mapfn.p(BUILD, resolve(runtime.args.dest));
return read(`${BUILD}/_h5ai/**`)
.then(newerThan(mapper_deploy))
.then(write(mapper_deploy, {overwrite: true, cluster: true}));
});

936
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,12 +21,12 @@
"@babel/preset-env": "7.4.3",
"eslint": "5.16.0",
"ghu": "0.18.0",
"jsdom": "14.0.0",
"kjua": "0.4.0",
"jsdom": "15.0.0",
"kjua": "0.5.0",
"lolight": "1.2.0",
"marked": "0.6.2",
"normalize.css": "8.0.1",
"null-loader": "0.1.1",
"null-loader": "1.0.0",
"scar": "1.6.0"
},
"engines": {

View File

@ -4,7 +4,7 @@ if (!global.window) {
}
const {test} = require('scar');
const {pinHtml} = require('./util/pin');
const {pin_html} = require('./util/pin');
require('./tests/premisses');
require('./tests/unit/core/event');
@ -12,6 +12,6 @@ require('./tests/unit/core/format');
require('./tests/unit/util/naturalCmp');
require('./tests/unit/util/parsePatten');
pinHtml();
pin_html();
test.cli({sync: true});

View File

@ -1,5 +1,6 @@
const {test, assert} = require('scar');
const event = require('../../../../src/_h5ai/public/js/lib/core/event');
const reqlib = require('../../../util/reqlib');
const event = reqlib('core/event');
test('core.event', () => {
assert.equal(typeof event, 'object', 'is object');

View File

@ -1,5 +1,6 @@
const {test, assert} = require('scar');
const format = require('../../../../src/_h5ai/public/js/lib/core/format');
const reqlib = require('../../../util/reqlib');
const format = reqlib('core/format');
test('core.format', () => {
assert.equal(typeof format, 'object');

View File

@ -1,5 +1,6 @@
const {test, assert, insp} = require('scar');
const {naturalCmp} = require('../../../../src/_h5ai/public/js/lib/util');
const reqlib = require('../../../util/reqlib');
const {naturalCmp} = reqlib('util');
test('util.naturalCmp()', () => {
assert.equal(typeof naturalCmp, 'function', 'is function');

View File

@ -1,5 +1,6 @@
const {test, assert, insp} = require('scar');
const {parsePattern} = require('../../../../src/_h5ai/public/js/lib/util');
const reqlib = require('../../../util/reqlib');
const {parsePattern} = reqlib('util');
test('util.parsePattern()', () => {
assert.equal(typeof parsePattern, 'function', 'is function');

View File

@ -16,30 +16,30 @@ const attr = (el, name, value) => {
return el.setAttribute(name, value);
};
const rootChildren = () => {
const root_children = () => {
return [
...doc.querySelector('head').childNodes,
...doc.querySelector('body').childNodes
];
};
const pinHtml = () => {
const pin_html = () => {
pinned.title = doc.title;
pinned.htmlId = attr('html', 'id');
pinned.htmlClasses = attr('html', 'class');
pinned.bodyId = attr('body', 'id');
pinned.bodyClasses = attr('body', 'class');
pinned.els = rootChildren();
pinned.els = root_children();
// console.log('pinned', pinned);
};
const restoreHtml = () => {
const restore_html = () => {
doc.title = pinned.title;
attr('html', 'id', pinned.htmlId);
attr('html', 'class', pinned.htmlClasses);
attr('body', 'id', pinned.bodyId);
attr('body', 'class', pinned.bodyClasses);
rootChildren().forEach(el => {
root_children().forEach(el => {
if (pinned.els.indexOf(el) < 0) {
el.remove();
}
@ -48,6 +48,6 @@ const restoreHtml = () => {
};
module.exports = {
pinHtml,
restoreHtml
pin_html,
restore_html
};

3
test/util/reqlib.js Normal file
View File

@ -0,0 +1,3 @@
const reqlib = x => require(`../../src/_h5ai/public/js/lib/${x}`);
module.exports = reqlib;