Permalink
Browse files

chore: change builder

  • Loading branch information...
adriancmiranda committed Oct 18, 2017
1 parent 5fde1ce commit 3969e6dc88420e34386bd86b91720a162ed4c5d4

This file was deleted.

Oops, something went wrong.
@@ -6,12 +6,6 @@ All notable changes to this project will be documented in this file. See [standa
# [1.6.0](https://github.com/adriancmiranda/dotcfg/compare/v1.5.14...v1.6.0) (2017-10-18)



<a name="1.1.0"></a>
# [1.1.0](https://github.com/adriancmiranda/dotcfg/compare/v1.5.14...v1.1.0) (2017-10-18)



<a name="1.5.14"></a>
## [1.5.14](https://github.com/adriancmiranda/dotcfg/compare/v1.5.13...v1.5.14) (2017-06-07)

@@ -0,0 +1,36 @@
const { lstatSync, readdirSync } = require('fs');
const { join, sep } = require('path');

exports.isDirectory = srcpath =>
lstatSync(srcpath).isDirectory()
;

exports.isFile = srcpath =>
lstatSync(srcpath).isFile()
;

exports.flatten = lists =>
lists.reduce((a, b) => a.concat(b), [])
;

exports.dirs = (srcpath, options = { includeOwn: true }) => {
const content = readdirSync(srcpath).map(name => join(srcpath, name));
const dirs = content.filter(exports.isDirectory);
return options.includeOwn ? [srcpath, ...dirs] : dirs;
};

exports.tree = (srcpath, options = { includeOwn: false }) => {
const dirs = exports.dirs(srcpath, { includeOwn: false });
const tree = exports.flatten(dirs.map(src => exports.tree(src, options)));
return options.includeOwn ? [srcpath, ...tree] : tree;
};

exports.aliases = (srcpath, options = { includeOwn: true, recursively: false, main: '', prefix: '' }) => {
const aliases = Object.create(null);
exports[options.recursively ? 'tree' : 'dirs'](srcpath, options).forEach(path => {
const slug = path.slice(srcpath.length + 1).replace(new RegExp(`\\${sep}`), '-');
const key = options.prefix ? options.prefix + slug.replace(new RegExp(`^\\${options.prefix}`), '') : slug;
aliases[`${key}` || '~'] = options.main ? join(path, options.main) : path;
});
return aliases;
};
@@ -0,0 +1,22 @@
exports.args = argv => {
const keys = Object.create(null);
const reArg = /^--?(.+)/;
const reParam = /=/;
argv = argv.slice(2);
argv.forEach((key, index) => {
if (reArg.test(key)) {
const argvalues = key.split(reParam);
let argname = key.replace(reArg, '$1');
let argvalue = argv[index + 1];
if (argvalues.length === 2) {
argname = argvalues[0].replace(reArg, '$1');
argvalue = argvalues[1];
}
keys[argname] = argname in keys ?
[keys[argname]].concat([argvalue]) :
argvalue
;
}
});
return keys;
};
@@ -0,0 +1,12 @@
const pirateFlag = require('pirate-flag');
const moment = require('moment');

moment.locale();

module.exports = (pack, git, options) => pirateFlag(pack, {
commit: git.commithash(),
moment: moment().format('LLLL'),
homepage: pack.homepage,
author: pack.author,
license: `(c) 2016-${+moment().format('GGGG') + 3} Adrian C. Miranda\n`,
}, Object.assign({ comment: true, image: [''] }, options));
@@ -0,0 +1,24 @@
exports.param = key => {
const multi = /,/;
if (key && key.constructor === String && multi.test(key)) {
key = key.split(multi);
}
if (/^false$/i.test(key)) {
return false;
}
if (/^true$/i.test(key)) {
return true;
}
if (/^([0-9]+|NaN|Infinity)$/.test(key)) {
return Number(key);
}
return key;
};

exports.params = env => {
const keys = Object.create(null);
Object.keys(env || '').forEach(key => {
keys[key] = exports.param(env[key]);
});
return keys;
};
@@ -0,0 +1,11 @@
const spawn = require('cross-spawn');
const { resolve } = require('path');
const { sync } = require('glob');
const { argv } = require('../config');

const files = Array.isArray(argv.f) ? `{${argv.f.join(',')}}` : argv.f || '**/*';
sync(resolve(`test/benchmark/${files}.bench.js`)).forEach(file => {
spawn.sync('babel-node', ['--presets', 'env', file], {
stdio: 'inherit',
});
});
@@ -0,0 +1,24 @@
const Git = require('git-revision-webpack-plugin');
const { resolve } = require('path');
const { aliases } = require('./@utilities/aliases');
const { params } = require('./@utilities/env');
const { args } = require('./@utilities/argv');
const banner = require('./@utilities/banner');

exports.git = new Git({ lightweightTags: true, branch: true });

exports.env = params(process.env);

exports.argv = args(process.argv);

exports.pack = require('../package.json');

exports.flag = banner(exports.pack, exports.git);

exports.aliases = aliases(resolve('source'));

exports.vars = {
__ENV__: exports.env.NODE_ENV || 'development',
__COMMIT__: exports.git.commithash(),
__VERSION__: exports.pack.version,
};
@@ -0,0 +1,11 @@
const spawn = require('cross-spawn');
const { resolve } = require('path');
const { sync } = require('glob');
const { argv } = require('../config');

const files = Array.isArray(argv.f) ? `{${argv.f.join(',')}}` : argv.f || '**/*';
sync(resolve(`test/fixtures/${files}?(.fixture).js`)).forEach(file => {
spawn.sync('babel-node', ['--presets', 'env', file], {
stdio: 'inherit',
});
});
@@ -0,0 +1,9 @@
const { env } = require('./config');
const rollup = require('./rollup');

module.exports = ([{
module: 'dotcfg',
source: 'index',
output: 'dist/dotcfg',
format: env.FORMATS,
}]).map(file => rollup(file));
@@ -0,0 +1,53 @@
const { resolve } = require('path');
const { DefinePlugin } = require('webpack');
const { aliases, env } = require('../config');

const webpack = {
plugins: [new DefinePlugin(env)],
devtool: '#inline-source-map',
resolve: {
alias: Object.assign({
fixtures: resolve('test/fixtures'),
}, aliases),
},
module: {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['env'],
},
}],
},
};

module.exports = {
webpack,
basePath: '../../',
port: 9876,
colors: true,
frameworks: ['jasmine', 'jasmine-matchers', 'sinon', 'fixture', 'phantomjs-shim'],
files: [{
pattern: 'index.js',
}, {
pattern: 'test/fixtures/**/*.fixture.*',
watched: true,
}, {
pattern: 'test/unit/index.js',
watched: true,
}],
preprocessors: {
'index.js': ['webpack', 'sourcemap'],
'test/unit/**/{index,*.unit}.js': ['webpack', 'sourcemap'],
'test/fixtures/**/{index,*.fixture}.js': ['webpack', 'sourcemap'],
'test/fixtures/**/*.fixture.html': ['html2js'],
'test/fixtures/**/*.fixture.json': ['json_fixtures'],
},
webpackMiddleware: {
noInfo: true,
},
jsonFixturesPreprocessor: {
variableName: '__json__',
},
};
@@ -0,0 +1,12 @@
const base = require('./base.config');

module.exports = config => {
config.set(Object.assign(base, {
browsers: ['Chrome', 'Firefox', 'Safari'],
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
concurrency: 2,
reporters: ['spec'],
singleRun: true,
}));
};
@@ -0,0 +1,16 @@
const base = require('./base.config');

module.exports = config => {
const options = Object.assign(base, {
singleRun: true,
browsers: ['PhantomJS'],
reporters: ['spec', 'coverage'],
coverageReporter: {
reporters: [
{ type: 'lcov', dir: '../coverage', subdir: '.' },
{ type: 'text-summary', dir: '../coverage', subdir: '.' },
],
},
});
config.set(options);
};
@@ -0,0 +1,8 @@
const base = require('./base.config');

module.exports = config => {
config.set(Object.assign(base, {
browsers: ['Chrome'],
reporters: ['dots', 'kjhtml'],
}));
};
@@ -0,0 +1,9 @@
const base = require('./base.config');

module.exports = config => {
config.set(Object.assign(base, {
browsers: ['Chrome', 'Firefox', 'Safari'],
reporters: ['progress'],
singleRun: true,
}));
};
@@ -0,0 +1,61 @@
const chromedriver = require('chromedriver');
const geckodriver = require('geckodriver');
const server = require('selenium-server');

// http://nightwatchjs.org/guide#settings-file
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_commands_path: ['node_modules/nightwatch-helpers/commands'],
custom_assertions_path: ['node_modules/nightwatch-helpers/assertions'],

selenium: {
start_process: true,
server_path: server.path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': chromedriver.path,
'webdriver.gecko.driver': geckodriver.path,
},
},

test_settings: {
default: {
selenium_port: 4444,
selenium_host: 'localhost',
silent: true,
screenshots: {
enabled: true,
on_failure: true,
on_error: false,
path: 'test/e2e/screenshots',
},
},

chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
},
},

firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true,
marionette: true,
},
},

phantomjs: {
desiredCapabilities: {
browserName: 'phantomjs',
javascriptEnabled: true,
acceptSslCerts: true,
},
},
},
};
@@ -0,0 +1,34 @@
const path = require('path');
const spawn = require('cross-spawn');
const httpServer = require('http-server');
const server = httpServer.createServer({
root: path.resolve(__dirname, '../../'),
});

let argv = process.argv.slice(2);
if (argv.indexOf('--config') === -1) {
argv = argv.concat(['-c', 'bin/nightwatch/config.js']);
}
if (argv.indexOf('--env') === -1) {
argv = argv.concat(['-e', 'chrome,phantomjs']);
}
const i = argv.indexOf('--test');
if (i > -1) {
argv[i + 1] = `test/e2e/specs/${argv[i + 1]}.spec.js`;
}

const runner = spawn('nightwatch', argv, {
stdio: 'inherit',
});

runner.on('exit', function onExit(code) {
server.close();
process.exit(code);
});

runner.on('error', function onError(err) {
server.close();
throw err;
});

server.listen(8080);
Oops, something went wrong.

0 comments on commit 3969e6d

Please sign in to comment.