Skip to content

Commit

Permalink
Maintenance.
Browse files Browse the repository at this point in the history
  • Loading branch information
lrsjng committed Jul 5, 2016
1 parent f6b1e15 commit 8f15b44
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 36 deletions.
2 changes: 1 addition & 1 deletion dist/pagemap.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions ghu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const {resolve, join} = require('path');
const {ghu, jszip, mapfn, read, remove, run, uglify, webpack, wrap, write} = require('ghu');

const NAME = 'pagemap';

const ROOT = resolve(__dirname);
const SRC = join(ROOT, 'src');
const DEMO = join(SRC, 'demo');
const BUILD = join(ROOT, 'build');
const DIST = join(ROOT, 'dist');

ghu.defaults('release');

ghu.before(runtime => {
runtime.pkg = Object.assign({}, require('./package.json'));
runtime.comment = `${NAME} v${runtime.pkg.version} - ${runtime.pkg.homepage}`;
runtime.commentJs = `/*! ${runtime.comment} */\n`;
console.log(runtime.comment);
});

ghu.task('clean', () => {
return remove(`${BUILD}, ${DIST}`);
});

ghu.task('lint', () => {
return run('eslint .', {stdio: 'inherit'});
});

ghu.task('build:script', runtime => {
const webpackConfig = {
output: {
library: NAME,
libraryTarget: 'umd'
},
module: {
loaders: [
{
include: [SRC],
loader: 'babel-loader',
query: {
cacheDirectory: true,
presets: ['es2015']
}
}
]
}
};

return read(`${SRC}/${NAME}.js`)
.then(webpack(webpackConfig, {showStats: false}))
.then(uglify({compressor: {warnings: false}}))
.then(wrap(runtime.commentJs))
.then(write(`${DIST}/${NAME}.min.js`, {overwrite: true}))
.then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.min.js`, {overwrite: true}));
});

ghu.task('build:copy', () => {
return read(`${ROOT}/*.md`)
.then(write(mapfn.p(ROOT, BUILD), {overwrite: true}));
});

ghu.task('build:demo', ['build:script'], () => {
return Promise.all([
read(`${DEMO}: *`)
.then(write(mapfn.p(SRC, BUILD), {overwrite: true})),

read(`${BUILD}: ${NAME}-*.min.js`)
.then(write(`${BUILD}/demo/${NAME}.min.js`, {overwrite: true}))
]);
});

ghu.task('build', ['build:script', 'build:copy', 'build:demo']);

ghu.task('zip', ['build'], runtime => {
return read(`${BUILD}/**`)
.then(jszip({dir: BUILD, level: 9}))
.then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.zip`, {overwrite: true}));
});

ghu.task('release', ['clean', 'zip']);
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pagemap",
"version": "0.2.0",
"version": "0.3.0",
"description": "Mini map for web pages.",
"homepage": "https://larsjung.de/pagemap/",
"bugs": "https://github.com/lrsjng/pagemap/issues",
Expand All @@ -13,15 +13,14 @@
"main": "dist/pagemap",
"scripts": {
"lint": "eslint .",
"build": "rimraf dist && webpack",
"build": "node ghu release",
"precommit": "npm run -s lint && npm run -s build"
},
"devDependencies": {
"babel-loader": "6.2.4",
"babel-preset-es2015": "6.9.0",
"eslint": "2.12.0",
"rimraf": "2.5.2",
"webpack": "1.13.1"
"eslint": "3.0.0",
"ghu": "0.6.0"
},
"engines": {
"node": ">=6.0.0"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion demo/boxes.html → src/demo/boxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<canvas id="map"></canvas>

<script src="../dist/pagemap.min.js"></script>
<script src="pagemap.min.js"></script>
<script>
pagemap(document.querySelector('#map'), {
// viewport: document.querySelector('#container'),
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion demo/text.html → src/demo/text.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<body>
<canvas id="map"></canvas>

<script src="../dist/pagemap.min.js"></script>
<script src="pagemap.min.js"></script>
<script>
pagemap(document.querySelector('#map'));
</script>
Expand Down
File renamed without changes.
File renamed without changes.
28 changes: 0 additions & 28 deletions webpack.config.js

This file was deleted.

0 comments on commit 8f15b44

Please sign in to comment.