Skip to content

Commit 0c0a80e

Browse files
committed
config and beginning build
1 parent c109278 commit 0c0a80e

File tree

11 files changed

+354
-0
lines changed

11 files changed

+354
-0
lines changed

.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": ["es2015", "stage-0"],
3+
"plugins": ["transform-runtime"],
4+
"comments": false
5+
}

.eslintrc.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module.exports = {
2+
root: true,
3+
"env": {
4+
"browser": true,
5+
"commonjs": true,
6+
"es6": true,
7+
"jquery": false,
8+
mocha: true
9+
},
10+
"extends": "eslint:recommended",
11+
"parserOptions": {
12+
"sourceType": "module"
13+
},
14+
"plugins": [
15+
"html"
16+
],
17+
"rules": {
18+
"indent": [
19+
"warn",
20+
"tab"
21+
],
22+
"quotes": [
23+
"warn",
24+
"double"
25+
],
26+
"semi": [
27+
"error",
28+
"always"
29+
],
30+
"no-var": [
31+
"error"
32+
],
33+
"no-console": [
34+
"off"
35+
],
36+
"no-unused-vars": [
37+
"warn"
38+
]
39+
}
40+
};

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*~
2+
\#*\#
3+
/.emacs.desktop
4+
/.emacs.desktop.lock
5+
6+
# flymake-mode
7+
*_flymake.*
8+
9+
# Flycheck
10+
flycheck_*.el
11+
12+
node_modules/
13+
coverage/
14+
test/unit/coverage

package.json

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"name": "vue-formly",
3+
"version": "0.1.0",
4+
"description": "A simple and extendable form builder for Vue.js",
5+
"main": "dist/vue-formly.common.js",
6+
"jsnext:main": "dist/vue-formly.es2015.js",
7+
"scripts": {
8+
"test": "karma start test/unit/karma.conf.js",
9+
"build": "node build/build.js",
10+
"release": "node build/release.js"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/matt-sanders/vue-formly.git"
15+
},
16+
"keywords": [
17+
"vue",
18+
"vuejs",
19+
"form"
20+
],
21+
"license": "MIT",
22+
"bugs": {
23+
"url": "https://github.com/matt-sanders/vue-formly/issues"
24+
},
25+
"homepage": "https://github.com/matt-sanders/vue-formly#readme",
26+
"devDependencies": {
27+
"babel-core": "6.11.4",
28+
"babel-loader": "6.2.4",
29+
"babel-plugin-transform-runtime": "6.12.0",
30+
"babel-preset-es2015": "6.9.0",
31+
"babel-preset-stage-0": "6.5.0",
32+
"chai": "3.5.0",
33+
"conventional-changelog-cli": "1.2.0",
34+
"conventional-github-releaser": "1.1.3",
35+
"coveralls": "2.11.12",
36+
"css-loader": "0.23.1",
37+
"eslint": "3.2.2",
38+
"eslint-friendly-formatter": "2.0.6",
39+
"eslint-loader": "1.5.0",
40+
"eslint-plugin-html": "1.5.1",
41+
"eslint-plugin-vue": "0.1.1",
42+
"extract-text-webpack-plugin": "1.0.1",
43+
"fakerator": "0.3.0",
44+
"gitbook-cli": "2.3.0",
45+
"inject-loader": "2.0.1",
46+
"isparta-loader": "2.0.0",
47+
"jade": "1.11.0",
48+
"jade-loader": "0.8.0",
49+
"karma": "1.1.2",
50+
"karma-chai": "0.1.0",
51+
"karma-chrome-launcher": "1.0.1",
52+
"karma-coverage": "1.1.1",
53+
"karma-coveralls": "1.1.2",
54+
"karma-mocha": "1.1.1",
55+
"karma-phantomjs-launcher": "1.0.1",
56+
"karma-sinon-chai": "1.2.3",
57+
"karma-sourcemap-loader": "0.3.7",
58+
"karma-spec-reporter": "0.0.26",
59+
"karma-webpack": "1.7.0",
60+
"lolex": "1.5.1",
61+
"mocha": "2.5.3",
62+
"mocha-generators": "1.2.0",
63+
"mocha-loader": "0.7.1",
64+
"moment": "2.14.1",
65+
"node-sass": "3.8.0",
66+
"phantomjs-prebuilt": "2.1.10",
67+
"sass-loader": "3.2.0",
68+
"sinon": "1.17.5",
69+
"sinon-chai": "2.8.0",
70+
"style-loader": "0.13.1",
71+
"vue": "1.0.26",
72+
"vue-hot-reload-api": "1.3.2",
73+
"vue-html-loader": "1.2.3",
74+
"vue-loader": "8.5.3",
75+
"vue-style-loader": "1.0.0",
76+
"webpack": "1.13.1",
77+
"webpack-dev-middleware": "1.6.1",
78+
"webpack-dev-server": "1.14.1",
79+
"webpack-merge": "0.14.1"
80+
}
81+
}

src/components.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function(Vue){
2+
3+
}

src/index.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import Components from './components';
2+
3+
4+
let Formly = {};
5+
6+
Formly.install = function(Vue, options){
7+
8+
if ( Formly.installed ){
9+
return;
10+
}
11+
12+
Vue.$formly = {
13+
14+
fields: {},
15+
16+
/**
17+
* Allow additional templates to be added
18+
* @param {String} id
19+
* @param {Object} options
20+
*/
21+
addType(id, options){
22+
//our base component
23+
let base = {
24+
props: ['model', 'schema']
25+
};
26+
27+
//merge
28+
Object.assign(options, base);
29+
Vue.$formly.fields[id] = Vue.extend(options);
30+
}
31+
};
32+
33+
};
34+
35+
//auto install
36+
if (typeof window !== 'undefined' && window.Vue) {
37+
window.Vue.use(Formly);
38+
}
39+
export default Formly;

test/unit/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// require all test files (files that ends with .spec.js)
2+
var testsContext = require.context('./specs', true, /\.spec$/);
3+
testsContext.keys().forEach(testsContext);
4+
5+
6+
// require all src files except main.js for coverage.
7+
// you can also change this to match only the subset of files that
8+
// you want coverage for.
9+
var srcContext = require.context('src', true, /\.(js|vue)$/);
10+
srcContext.keys().forEach(srcContext);

test/unit/karma.conf.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var wsConfig = require('./webpack.test.config');
2+
3+
module.exports = function(config) {
4+
var settings = {
5+
// base path that will be used to resolve all patterns (eg. files, exclude)
6+
basePath: '',
7+
8+
browsers: ['PhantomJS'],
9+
10+
reporters: ['spec', 'coverage'],
11+
12+
frameworks: ['mocha', 'chai', 'sinon-chai'],
13+
14+
files: ['./index.js'],
15+
16+
exclude: [],
17+
18+
preprocessors: {
19+
'./index.js': ['webpack', 'sourcemap']
20+
},
21+
22+
webpack: wsConfig,
23+
24+
webpackMiddleware: {
25+
noInfo: true
26+
},
27+
28+
port: 9876,
29+
30+
colors: true,
31+
32+
logLevel: config.LOG_INFO,
33+
34+
autoWatch: false,
35+
36+
singleRun: true,
37+
38+
coverageReporter: {
39+
dir: './coverage',
40+
reporters: [
41+
{ type: 'lcov', subdir: '.' },
42+
{ type: 'text-summary' }
43+
]
44+
}
45+
}
46+
47+
config.set(settings);
48+
}

test/unit/specs/VueFormly.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {expect} from 'chai';
2+
import Vue from 'vue';
3+
import VueFormly from 'src/index';
4+
Vue.use(VueFormly);
5+
6+
let el, vm;
7+
8+
function createForm(template){
9+
el = document.createElement('div');
10+
el.innerHTML = template;
11+
vm = new Vue({
12+
el: el
13+
});
14+
15+
return [el, vm];
16+
}
17+
18+
describe('VueFormly', () => {
19+
20+
it('should create two new components', () => {
21+
createForm('<vue-formly></vue-formly><vf-input></vf-input>');
22+
23+
console.log(vm.$el);
24+
console.log(vm.$refs);
25+
26+
});
27+
});

test/unit/specs/index.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {expect} from 'chai';
2+
3+
import VueFormly from 'src/index';
4+
5+
6+
describe('module', () => {
7+
8+
it('module props', () => {
9+
expect(VueFormly).to.exist;
10+
expect(VueFormly.install).to.be.a('function');
11+
});
12+
13+
});

0 commit comments

Comments
 (0)