Skip to content

Commit

Permalink
Merge pull request #134 from jonataswalker/update-deps
Browse files Browse the repository at this point in the history
Rewrite (almost) the project
  • Loading branch information
jonataswalker authored Nov 14, 2017
2 parents 1581a7a + 5484937 commit 5d7680b
Show file tree
Hide file tree
Showing 49 changed files with 13,328 additions and 7,568 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
extends: ['jwalker'],
rules: {
'no-console': 1
},
globals: {
Geocoder: true,
},
};
27 changes: 13 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@ sudo: required
dist: trusty

language: node_js

node_js:
- "6"
- "8"

cache:
bundler: true
yarn: true
directories:
- travis-phantomjs
- node_modules

addons:
chrome: stable

before_install:
# PhantomJS
- "if [ $(phantomjs --version) != '2.1.1' ]; then rm -rf $PWD/travis-phantomjs; mkdir -p $PWD/travis-phantomjs; fi"
- "if [ $(phantomjs --version) != '2.1.1' ]; then wget https://github.com/BIGjuevos/phantomjs-builds/archive/v2.1.1.tar.gz -O $PWD/travis-phantomjs/v2.1.1.tar.gz; fi"
- "if [ $(phantomjs --version) != '2.1.1' ]; then tar -xf $PWD/travis-phantomjs/v2.1.1.tar.gz -C $PWD/travis-phantomjs; fi"
- "if [ $(phantomjs --version) != '2.1.1' ]; then sudo ln -sf $PWD/travis-phantomjs/phantomjs-builds-2.1.1/bin/phantomjs $(which phantomjs); fi"
- "phantomjs --version"
- stty cols 80
- sudo apt-get -qq update
- sudo apt-get install -y libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
- sudo apt-get install -y fluxbox
- npm i -g npm@5

before_script:

script:
- xvfb-run -a npm run test
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3
- fluxbox >/dev/null 2>&1 &

branches:
only:
- "master"
- /^greenkeeper-.*$/
66 changes: 0 additions & 66 deletions build-css.js

This file was deleted.

73 changes: 0 additions & 73 deletions build-js.js

This file was deleted.

File renamed without changes.
62 changes: 62 additions & 0 deletions build/build-css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const { writeFileSync, readFileSync } = require('fs');
const boxen = require('boxen');
const chalk = require('chalk');
const gzip = require('gzip-size');
const bytes = require('bytes');
const sass = require('node-sass');
const jsonImporter = require('node-sass-json-importer');
const autoprefixer = require('autoprefixer');
const postcss = require('postcss');
const postcssReport = require('postcss-reporter');
const cssnano = require('cssnano');
const pkg = require('../package.json');

var banner = readFileSync('./build/banner.js', 'utf-8')
.replace('${name}', pkg.name)
.replace('${description}', pkg.description)
.replace('${homepage}', pkg.homepage)
.replace('${version}', pkg.version)
.replace('${time}', new Date());


sass.render({
file: './src/sass/main.scss',
importer: jsonImporter
}, (err, result) => {
if (err) throw err.message;

const prefixer = postcss([
autoprefixer({ browsers: ['> 5%'] }),
postcssReport({ clearMessages: true })
]);
prefixer.process(result.css).then(res => {
res.warnings().forEach((warn) => {
console.warn(warn.toString());
});

writeFileSync('./dist/ol-geocoder.css', banner + res.css);

cssnano.process(res.css).then(min => {
writeFileSync('./dist/ol-geocoder.min.css', banner + min.css);

const cssSize = bytes(Buffer.byteLength(res.css));
const cssMinSize = bytes(Buffer.byteLength(min.css));
const cssGzip = bytes(gzip.sync(res.css));
const cssMinGzip = bytes(gzip.sync(min.css));

// eslint-disable-next-line no-console
console.log(boxen([
chalk.green.bold('CSS: '),
chalk.yellow.bold(cssSize), ', ',
chalk.green.bold('Gzipped: '),
chalk.yellow.bold(cssGzip), '\n',
chalk.green.bold('Minified: '),
chalk.yellow.bold(cssMinSize), ', ',
chalk.green.bold('Gzipped: '),
chalk.yellow.bold(cssMinGzip), '\n',
chalk.green.bold('Now: '),
chalk.yellow.bold(new Date())
].join(''), { padding: 1 }));
});
});
});
79 changes: 79 additions & 0 deletions build/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { readFileSync } from 'fs';
import { minify } from 'uglify-es';
import nodeResolve from 'rollup-plugin-node-resolve';
import json from 'rollup-plugin-json';
import buble from 'rollup-plugin-buble';
import commonjs from 'rollup-plugin-commonjs';
import eslint from 'rollup-plugin-eslint';
import includePaths from 'rollup-plugin-includepaths';
import bundleSize from 'rollup-plugin-filesize';
import uglify from 'rollup-plugin-uglify';

const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
const external = Object.keys(pkg.dependencies);

const globals = {
openlayers: 'ol',
};

const lintOpts = {
// extensions: ['js'],
exclude: ['**/*.json'],
cache: true,
throwOnError: true
};

const includePathOptions = {
paths: ['', './src']
};

const banner = readFileSync('./build/banner.js', 'utf-8')
.replace('${name}', pkg.name)
.replace('${description}', pkg.description)
.replace('${homepage}', pkg.homepage)
.replace('${version}', pkg.version)
.replace('${time}', new Date());

export default [
{
external,
banner,
globals,
input: './src/base.js',
output: {
file: './dist/ol-geocoder.js',
format: 'umd',
name: 'Geocoder',
},
plugins: [
includePaths(includePathOptions),
eslint(lintOpts),
bundleSize(),
nodeResolve(),
commonjs(),
json({ exclude: 'node_modules/**' }),
buble({ target: { ie: 11 } }),
uglify({ output: { comments: /^!/ } }, minify)
],
},
{
external,
banner,
globals,
input: './src/base.js',
output: {
file: './dist/ol-geocoder-debug.js',
format: 'umd',
name: 'Geocoder',
},
plugins: [
includePaths(includePathOptions),
eslint(lintOpts),
bundleSize(),
nodeResolve(),
commonjs(),
json({ exclude: 'node_modules/**' }),
buble({ target: { ie: 11 } })
],
}
];
Loading

0 comments on commit 5d7680b

Please sign in to comment.