Skip to content

Commit

Permalink
Merge pull request #388 from SC5/dev
Browse files Browse the repository at this point in the history
0.2.17
  • Loading branch information
varya committed Jan 8, 2015
2 parents 9080372 + ca14d49 commit b4a0f36
Show file tree
Hide file tree
Showing 16 changed files with 631 additions and 239 deletions.
24 changes: 13 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
## 0.2.16 (2014-12-22)
## 0.2.17 (2015-01-08)

### New features
* Declare Angular directives in KSS comments (#[364](https://github.com/SC5/sc5-styleguide/pull/364))
### Features
* Example to shows colors with functions (#[379](https://github.com/SC5/sc5-styleguide/pull/379))
* --port help added to CLI (#[376](https://github.com/SC5/sc5-styleguide/pull/376))

### Improvements
* Show variable source file name(s) (#[360](https://github.com/SC5/sc5-styleguide/pull/360))
* Nice looking designer tool for mobile devices (#[359](https://github.com/SC5/sc5-styleguide/pull/359))
* Hide absolute paths on client (#[358](https://github.com/SC5/sc5-styleguide/pull/358))
* Save only changed variables (#[355](https://github.com/SC5/sc5-styleguide/pull/355))
### Fixes
* Clean up custom KSS params before processing KSS (#[385](https://github.com/SC5/sc5-styleguide/pull/385))
* Remove defined in texts in variables. Update KSS example data (#[373](https://github.com/SC5/sc5-styleguide/pull/373))

### Internal changes
* Add Dockerfile to run demo in docker container (#[357](https://github.com/SC5/sc5-styleguide/pull/357))
* Minor fixes to releasing instruction (#[349](https://github.com/SC5/sc5-styleguide/pull/349))
### Internal
* Move gulp test tasks to own file (#[383](https://github.com/SC5/sc5-styleguide/pull/383))
* Move bin/styleguide to lib/cli.js (#[384](https://github.com/SC5/sc5-styleguide/pull/384))
* Improve npm integration tests (#[382](https://github.com/SC5/sc5-styleguide/pull/382))
* Add npm package integration test (#[378](https://github.com/SC5/sc5-styleguide/pull/378))
* Correct markup for code in README (#[367](https://github.com/SC5/sc5-styleguide/pull/367))

88 changes: 1 addition & 87 deletions bin/styleguide
Original file line number Diff line number Diff line change
@@ -1,89 +1,3 @@
#!/usr/bin/env node

var styleguide = require(__dirname + '/../lib/styleguide.js'),
gulp = require('gulp'),
runSequence = require('run-sequence'),
args = ['styleguide'],
chalk = require('chalk'),
path = require('path'),
yargs = require('yargs'),
neat = require('node-neat'),
util = require('gulp-util'),
extend = require('node.extend'),
fs = require('fs'),
argv,
gulpProcess,
config,
configPath,
sourcePath,
sourceFiles,
watchFiles,
outputPath,
options;

argv = yargs
.usage('This is how ' + chalk.cyan.bold('YOU') + ' can generate ' +
chalk.cyan.bold('COOL') + ' styleguides')
.example('$0 -s <src> -o <dest>', 'Generate a styleguide to dest using src')
.example('$0 -s <src> -o <dest> --watch', 'Generate a styleguide to dest using src and run server watching changes')
.demand('source', chalk.red('Please provide source path using -s <path>'))
.demand('output', chalk.red('Please provide output path using -o <path>'))
.alias('o', 'output')
.alias('s', 'source')
.alias('c', 'config')
.describe('s', 'Source file(s)')
.describe('o', 'Output directory')
.describe('c', 'Path to config JSON file')
.describe('server', 'Start minimal web-server to host the styleguide from the output directory')
.describe('watch', 'Automatically generate styleguide on file change')
.argv;

sourcePath = path.resolve(argv.source);
if (fs.lstatSync(sourcePath).isDirectory()) {
sourceFiles = [sourcePath + '/**/*.css', sourcePath + '/**/*.scss', sourcePath + '/**/*.less'];
} else {
sourceFiles = [sourcePath];
}
watchFiles = sourceFiles.slice(0);

outputPath = path.resolve(argv.output);
configPath = argv.config ? path.resolve(argv.config) : undefined;
config = configPath ? require(configPath) : {};

// Resolve overviewPath and styleVariables files in relation to config file location
if (config.overviewPath) {
config.overviewPath = path.resolve(path.dirname(argv.config), config.overviewPath);
watchFiles.push(config.overviewPath);
}
if (config.styleVariables) {
config.styleVariables = path.resolve(path.dirname(argv.config), config.styleVariables);
watchFiles.push(config.styleVariables);
} else if (config.sassVariables) {
// For backward compatibility
config.sassVariables = path.resolve(path.dirname(argv.config), config.sassVariables);
watchFiles.push(config.sassVariables);
}
options = extend({
sass: {
includePaths: neat.includePaths
},
server: !!argv.server,
port: argv.port,
rootPath: outputPath
}, config);

gulp.task('styleguide', function() {
gulp.src(sourceFiles)
.pipe(styleguide(options))
.pipe(gulp.dest(outputPath));
});

gulp.task('watch', function() {
gulp.watch(watchFiles, ['styleguide']);
});

var tasks = ['styleguide'];
if (argv.watch) {
tasks.push('watch');
}
runSequence.apply(this, tasks);
require('../lib/cli').main();
135 changes: 135 additions & 0 deletions gulpfile-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
'use strict';

var vfs = require('vinyl-fs'),
path = require('path'),
plumber = require('gulp-plumber'),
jscs = require('gulp-jscs'),
jshint = require('gulp-jshint'),
mocha = require('gulp-mocha'),
karma = require('karma').server,
coverage = require('istanbul'),
istanbul = require('gulp-istanbul'),
through = require('through2'),
runSequence = require('run-sequence'),
del = require('del'),
tasks;

module.exports = function registerTasks(gulp) {
Object.keys(tasks).forEach(function(task) {
gulp.task(task, tasks[task]);
});
};

tasks = {
//jscs:disable disallowQuotedKeysInObjects
'jscs': runJscs,
'jshint': runJsHint,
'lint:js': ['jscs', 'jshint'],
'test:unit': runUnitTests,
'test:integration': runIntegrationTests,
'test:angular:unit': runAngularUnitTests,
'test:angular:functional': runAngularFunctionalTests,
'test:angular': ['test:angular:unit', 'test:angular:functional'],
'test': runAllTests,
'clean-coverage': cleanCoverageDir,
'generate-coverage-report': generateCoverageReport
//jscs:enable disallowQuotedKeysInObjects
};

function srcJsLint() {
return vfs.src([
'gulpfile.js',
'gulp-tasks/*',
'bin/**/*.js',
'lib/**/*.js',
'test/**/*.js',
'!lib/dist/**/*.js',
'!lib/app/js/components/**/*.js'
]);
}

function runJscs() {
return srcJsLint()
.pipe(plumber())
.pipe(jscs({configPath: '.jscsrc'}));
}

function runJsHint() {
return srcJsLint()
.pipe(plumber())
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
}

function runMocha() {
return mocha({reporter: 'spec'});
}

function runUnitTests(done) {
vfs.src(['lib/modules/**/*.js'])
.pipe(istanbul({includeUntested: true}))
.pipe(istanbul.hookRequire())
.on('finish', function() {
vfs.src(['test/unit/**/*.js'])
.pipe(runMocha())
.pipe(writeUnitTestCoverage())
.pipe(printUnitTestCoverage())
.on('end', done);
});
}

function writeUnitTestCoverage() {
return istanbul.writeReports({
reporters: ['json'],
reportOpts: {file: path.resolve('./coverage/unit-coverage.json')}
});
}

function printUnitTestCoverage() {
return istanbul.writeReports({reporters: ['text']});
}

function runIntegrationTests() {
return vfs.src('test/integration/**/*.js').pipe(runMocha());
}

function runAngularUnitTests(done) {
karma.start({
configFile: path.resolve('./test/karma.conf.js'),
exclude: ['test/angular/functional/**/*.js']
}, done);
}

function runAngularFunctionalTests(done) {
karma.start({
configFile: path.resolve('./test/karma.conf.js'),
exclude: ['test/angular/unit/**/*.js'],
preprocessors: {},
reporters: ['mocha']
}, done);
}

function runAllTests(done) {
runSequence('test:unit', 'test:angular', 'test:integration', 'lint:js', done);
}

function cleanCoverageDir(done) {
del('coverage/*', done);
}

function generateCoverageReport() {
var collector = new coverage.Collector(),
lcov = coverage.Report.create('lcov', {dir: 'coverage'}),
summary = coverage.Report.create('text');

return vfs.src('coverage/*.json')
.pipe(through.obj(function(file, enc, done) {
collector.add(JSON.parse(file.contents.toString()));
done();
}, function(callback) {
lcov.writeReport(collector);
summary.writeReport(collector);
callback();
}));
}
Loading

0 comments on commit b4a0f36

Please sign in to comment.