Skip to content

Commit

Permalink
Merge pull request #47 from danmademe/greenkeeper/initial
Browse files Browse the repository at this point in the history
Update dependencies to enable Greenkeeper 馃尨
  • Loading branch information
danielcherubini committed Mar 9, 2017
2 parents a56ec24 + a3ea55e commit 878fe03
Show file tree
Hide file tree
Showing 11 changed files with 2,017 additions and 360 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
test/*
dist/*
test/*
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<a href="https://david-dm.org/danmademe/express-vue"><img src="https://david-dm.org/danmademe/express-vue.svg?theme=shields.io" alt="Dependency Status"></a>
<a href="https://coveralls.io/r/danmademe/express-vue"><img src="https://coveralls.io/repos/danmademe/express-vue/badge.svg" alt="Coverage Status"></a>
<a href="https://lima.codeclimate.com/github/danmademe/express-vue"><img src="https://lima.codeclimate.com/github/danmademe/express-vue/badges/gpa.svg" /></a>
<a href="https://greenkeeper.io"><img src="https://badges.greenkeeper.io/danmademe/express-vue.svg" /></a>
</p>


Expand Down
49 changes: 7 additions & 42 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ var path = require('path');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');
var coveralls = require('gulp-coveralls');
var babel = require('gulp-babel');
var del = require('del');
var isparta = require('isparta');
var ava = require('gulp-ava');

// Initialize the babel transpiler so ES2015 files gets compiled
// when they're loaded
require('babel-register');

gulp.task('static', function () {
gulp.task('eslint', function () {
return gulp.src('**/*.js')
.pipe(excludeGitignore())
.pipe(eslint())
Expand All @@ -27,40 +23,6 @@ gulp.task('nsp', function (cb) {
nsp({package: path.resolve('package.json')}, cb);
});

gulp.task('pre-test', function () {
return gulp.src('lib/**/*.js')
.pipe(excludeGitignore())
.pipe(istanbul({
includeUntested: true,
instrumenter: isparta.Instrumenter
}))
.pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-test'], function (cb) {
var mochaErr;

gulp.src('test/**/*.js')
.pipe(plumber())
.pipe(mocha({reporter: 'spec'}))
.on('error', function (err) {
mochaErr = err;
})
.pipe(istanbul.writeReports())
.on('end', function () {
cb(mochaErr);
});
});

gulp.task('coveralls', ['test'], function () {
if (!process.env.CI) {
return;
}

return gulp.src(path.join(__dirname, 'coverage/lcov.info'))
.pipe(coveralls());
});

gulp.task('typescript', ['clean'], function() {
return gulp.src('lib/**/*.ts')
.pipe(gulp.dest('dist'));
Expand All @@ -76,9 +38,12 @@ gulp.task('clean', function () {
return del('dist');
});

gulp.task('build', ['nsp', 'babel']);
gulp.task('default', ['static', 'test', 'coveralls']);
gulp.task('test', ['eslint'], function() {
return gulp.src('test/**/*.js')
.pipe(ava({nyc:true}));
});

gulp.task('build', ['nsp', 'babel']);

gulp.task('watch', function () {
gulp.watch(['lib/**/*.js'], ['build']);
Expand Down
33 changes: 26 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,29 @@
"engines": {
"node": ">=6.0.0"
},
"ava": {
"files": [
"test/*.js"
],
"source": [
"lib/**/*.js",
"!dist/**/*"
],
"concurrency": 5,
"failFast": false,
"powerAssert": false,
"require": [
"babel-register"
],
"babel": "inherit"
},
"nyc": {
"include": [
"lib/**/*.js"
]
},
"devDependencies": {
"ava": "^0.18.2",
"babel-eslint": "^7.1.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
Expand All @@ -31,19 +53,16 @@
"eslint-config-xo-space": "^0.15.0",
"eslint-plugin-babel": "^4.0.0",
"express": "^4.14.0",
"flow-bin": "^0.40.0",
"flow-bin": "^0.41.0",
"gulp": "^3.9.1",
"gulp-ava": "^0.16.0",
"gulp-babel": "^6.1.2",
"gulp-concat": "^2.6.1",
"gulp-coveralls": "^0.1.4",
"gulp-eslint": "^3.0.1",
"gulp-exclude-gitignore": "^1.1.1",
"gulp-istanbul": "^1.1.1",
"gulp-line-ending-corrector": "^1.0.1",
"gulp-mocha": "3.0.1",
"gulp-nsp": "^2.4.2",
"gulp-plumber": "^1.1.0",
"isparta": "^4.0.0"
"nyc": "^10.1.2"
},
"eslintConfig": {
"extends": "xo-space",
Expand All @@ -54,7 +73,7 @@
"repository": "danmademe/express-vue",
"scripts": {
"prepublish": "gulp build",
"test": "gulp",
"test": "gulp test",
"preversion": "npm test",
"version": "gulp build && git add -A",
"postversion": "git push && git push --tags"
Expand Down
216 changes: 4 additions & 212 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,216 +1,8 @@
import assert from 'assert';
import test from 'ava';
import expressVue from '../lib';
import {Defaults, Types} from '../lib/defaults';
import {
renderUtil,
layoutUtil,
renderHtmlUtil,
renderVueComponents,
renderVueMixins,
scriptToString,
headUtil
} from '../lib/utils';
import {
componentParser,
layoutParser
} from '../lib/parser';

describe('express-vue', function () {
it('Express Vue loads', function () {
const isAFunction = typeof expressVue === 'function';
test('Express Vue loads', t => {
const isAFunction = typeof expressVue === 'function';

assert(isAFunction, 'Loads and is a function');
});

it('should have a defaults class', function() {
const object = {
componentsDir: '/baz',
defaultLayout: 'qux'
};
const viewsPath = '/foo/bar';
const defaultObject = new Defaults(object, viewsPath);

//Booleans
const componentsDir = defaultObject.componentsDir === '/baz/';
const rootPath = defaultObject.rootPath === '/foo/bar/';
const backupLayout = defaultObject.backupLayout === '<template><!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><script src="https://unpkg.com/vue/dist/vue.js"></script></head><body>{{{app}}}{{{script}}}</body></html></template><script></script><style></style>';
const defaultLayout = defaultObject.defaultLayout === '/foo/bar/qux';


assert(componentsDir, 'Components Directory is Present');
assert(rootPath, 'Root Path is correct');
assert(backupLayout, 'Backup layout is present');
assert(defaultLayout, 'default layout is constructing correctly');
});

it('it should turn objects to strings' , function() {
const object = {
'string': 'foo',
'function': function() {
return 'baz';
},
'array': ['one', 'two', 'three'],
'object': {
dog: true,
cat: false
},
'number': 42,
'boolean': true
}

const string = scriptToString(object);

//Booleans
const hasString = string.includes(`string: "foo"`);
const hasNumber = string.includes(`number: 42`);
const hasArray = string.includes(`array: ["one","two","three"]`);
const hasObject = string.includes(`object: {dog: true,cat: false,}`);
const hasBoolean = string.includes(`boolean: true`);
const hasFunction = string.includes(`function: function _function() {
return 'baz';
}`);
const hasFinal = string === `{string: "foo",function: function _function() {
return 'baz';
},array: ["one","two","three"],object: {dog: true,cat: false,},number: 42,boolean: true,}`;

assert(hasString, 'Has a String');
assert(hasNumber, 'Has a Number');
assert(hasArray, 'Has a Array');
assert(hasObject, 'Has a Object');
assert(hasBoolean, 'Has a Boolean');
assert(hasFunction, 'Has a Function');
assert(hasFinal, 'Is a fully formed string')
});

it('it should do head', function() {
const object = {
head: {
title: 'It was a Pleasure',
meta: [
{ name: 'application-name', content: 'Name of my application' },
{ name: 'description', content: 'A description of the page', id: 'desc' },
{ name: 'twitter:title', content: 'Content Title' },
{ property: 'fb:app_id', content: '123456789' },
{ property: 'og:title', content: 'Content Title' },
{ script: '/assets/scripts/hammer.min.js' },
{ script: '/assets/scripts/vue-touch.min.js', charset: 'utf-8' },
{ style: '/assets/rendered/style.css' },
{ style: '/assets/rendered/style.css', type: 'text/css' },
{ style: '/assets/rendered/style.css', type: 'text/css', rel: 'stylesheet' }
]
}
};

const metaString = headUtil(object);

//Booleans
const stringIsCorrect = metaString === '<title>It was a Pleasure</title><meta name="application-name" content="Name of my application" /><meta name="description" content="A description of the page" /><meta name="twitter:title" content="Content Title" /><meta property="fb:app_id" content="123456789" /><meta property="og:title" content="Content Title" /><script src="/assets/scripts/hammer.min.js" charset="utf-8"></script><script src="/assets/scripts/vue-touch.min.js" charset="utf-8"></script><link rel="stylesheet" type="text/css" href="/assets/rendered/style.css"><link rel="stylesheet" type="text/css" href="/assets/rendered/style.css"><link rel="stylesheet" type="text/css" href="/assets/rendered/style.css"></head>'
const hasTitle = metaString.includes('<title>It was a Pleasure</title>');
const hasMetaName = metaString.includes(`<meta name="application-name" content="Name of my application" />`);
const hasMetaProperty = metaString.includes(`<meta property="og:title" content="Content Title" />`);
const hasScript = metaString.includes(`<script src="/assets/scripts/hammer.min.js" charset="utf-8">`)
const hasStyle = metaString.includes(`<link rel="stylesheet" type="text/css" href="/assets/rendered/style.css">`)

assert(stringIsCorrect, 'String is correct');
assert(hasTitle, 'has title section');
assert(hasMetaName, 'has meta name section');
assert(hasMetaProperty, 'has meta property section');
assert(hasScript, 'has scripts');
assert(hasStyle, 'has style 馃幏');
});

it('it should do old Head', function() {
const object = {
meta: {
title: 'It was a Pleasure',
head: [
{ name: 'application-name', content: 'Name of my application' },
{ name: 'description', content: 'A description of the page', id: 'desc' },
{ name: 'twitter:title', content: 'Content Title' },
{ property: 'fb:app_id', content: '123456789' },
{ property: 'og:title', content: 'Content Title' },
{ script: '/assets/scripts/hammer.min.js' },
{ script: '/assets/scripts/vue-touch.min.js', charset: 'utf-8' },
{ style: '/assets/rendered/style.css' },
{ style: '/assets/rendered/style.css', type: 'text/css' },
{ style: '/assets/rendered/style.css', type: 'text/css', rel: 'stylesheet' }
]
}
};

const metaString = headUtil(object);

//Booleans
const stringIsCorrect = metaString === '<title>It was a Pleasure</title><meta name="application-name" content="Name of my application" /><meta name="description" content="A description of the page" /><meta name="twitter:title" content="Content Title" /><meta property="fb:app_id" content="123456789" /><meta property="og:title" content="Content Title" /><script src="/assets/scripts/hammer.min.js" charset="utf-8"></script><script src="/assets/scripts/vue-touch.min.js" charset="utf-8"></script><link rel="stylesheet" type="text/css" href="/assets/rendered/style.css"><link rel="stylesheet" type="text/css" href="/assets/rendered/style.css"><link rel="stylesheet" type="text/css" href="/assets/rendered/style.css"></head>'
const hasTitle = metaString.includes('<title>It was a Pleasure</title>');
const hasMetaName = metaString.includes(`<meta name="application-name" content="Name of my application" />`);
const hasMetaProperty = metaString.includes(`<meta property="og:title" content="Content Title" />`);
const hasScript = metaString.includes(`<script src="/assets/scripts/hammer.min.js" charset="utf-8">`)
const hasStyle = metaString.includes(`<link rel="stylesheet" type="text/css" href="/assets/rendered/style.css">`)

assert(stringIsCorrect, 'String is correct');
assert(hasTitle, 'has title section');
assert(hasMetaName, 'has meta name section');
assert(hasMetaProperty, 'has meta property section');
assert(hasScript, 'has scripts');
assert(hasStyle, 'has style 馃幏');
});

it('it should parse components', function() {
let types = new Types();
const component = __dirname + '/component.vue';
const object = {
componentsDir: __dirname + ''
};
const viewsPath = '/foo/bar';
const defaultObject = new Defaults(object, viewsPath);
defaultObject.options = {
vue: {}
}
const componentArray = [
layoutParser('', defaultObject, types.LAYOUT),
componentParser(component, defaultObject, types.COMPONENT)
];
Promise.all(componentArray).then(function(components) {
renderHtmlUtil(components, defaultObject).then(function(html) {
assert(true, 'it cant parse components');
}).catch(function(error) {
assert(false, 'it cant parse components' + error);
});
}, function(error) {
assert(false, 'it cant parse components' + error);
});
});

it('it should render global mixins', function() {
var mixin = {
created: function () {
var myOption = this.$options.myOption
if (myOption) {
console.log(myOption)
}
}
}
const mixinString = renderVueMixins([mixin]);
const hasMixinString = mixinString.includes('Vue.mixin')

assert(hasMixinString, 'it cant render global mixins')
})

// it('it should render global components', function() {
// var component = {
// name: 'headerComponent',
// script: {props: ["user"],data: function(){return {}}}
// }
// var script = {
// components: {
// headerComponent: component
// }
// }
// const componentString = renderVueComponents(script, [component]);
// console.log(componentString);
// const hasComponentString = componentString.includes('Vue.component')
//
// assert(hasComponentString, 'it cant render global components')
// })
t.is(isAFunction, true);
});
Loading

0 comments on commit 878fe03

Please sign in to comment.