Fixed transpile issues for .js files

pull/12/head
mertsincan 2019-05-29 10:11:07 +03:00
parent bdde45ac1d
commit 8f44e19412
5 changed files with 125 additions and 107 deletions

View File

@ -1,17 +1,32 @@
const fs = require('fs-extra'); const fs = require('fs-extra');
const path = require('path'); const path = require('path');
const {execSync} = require('child_process'); const { execSync } = require('child_process');
const vueCliServicePath = path.resolve(__dirname, 'node_modules/@vue/cli-service/bin/vue-cli-service'); const vueCliServicePath = path.resolve(__dirname, 'node_modules/@vue/cli-service/bin/vue-cli-service');
fs.readdirSync(path.resolve(__dirname, './src/components/')).forEach(folder => { fs.readdirSync(path.resolve(__dirname, './src/components/')).forEach(folder => {
fs.readdirSync(path.resolve(__dirname, './src/components/' + folder)).forEach(file => { fs.readdirSync(path.resolve(__dirname, './src/components/' + folder)).forEach(file => {
if (/\.vue$/.test(file) || /\.js$/.test(file)) { let filename = file.split(/(.vue)$|(.js)$/)[0].toLowerCase();
let filename = file.split(/(.vue)$|(.js)$/)[0].toLowerCase(); if (/\.vue$/.test(file)) {
console.log('Building ' + filename); console.log('Building ' + blue(filename));
execSync( execSync(
`node ${vueCliServicePath} build src/components/${folder}/${file} --target lib --name ${filename} --dest components/${folder} --no-clean ` `node ${vueCliServicePath} build src/components/${folder}/${file} --target lib --name ${filename} --dest components/${folder} --no-clean `
) )
} }
else if (/\.js$/.test(file)) {
console.log('Building ' + blue(filename));
execSync(
`node ${vueCliServicePath} build src/components/${folder}/${file} --target lib --name ${filename} --dest components/${folder} --no-clean `
)
execSync(
`babel --no-babelrc src/components/${folder}/${file} --out-file components/${folder}/${file} --presets=es2015,stage-2 `
)
}
}); });
}); });
function blue (str) {
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'
}

View File

@ -8,7 +8,7 @@ var gulp = require('gulp'),
flatten = require('gulp-flatten'); flatten = require('gulp-flatten');
gulp.task('copy-components', function() { gulp.task('copy-components', function() {
return gulp.src(['src/components/**/*']) return gulp.src(['src/components/**/*.vue'])
.pipe(gulp.dest('./components')); .pipe(gulp.dest('./components'));
}); });

View File

@ -26,6 +26,8 @@
"babel-core": "7.0.0-bridge.0", "babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0", "babel-jest": "^23.6.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"eslint": "^5.8.0", "eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0-0", "eslint-plugin-vue": "^5.0.0-0",
"node-sass": "^4.9.0", "node-sass": "^4.9.0",

View File

@ -1,81 +0,0 @@
export default class FilterUtils {
static startsWith(value, filter) {
if(filter === undefined || filter === null || filter.trim() === '') {
return true;
}
if(value === undefined || value === null) {
return false;
}
let filterValue = filter.toLowerCase();
return value.toString().toLowerCase().slice(0, filterValue.length) === filterValue;
}
static contains(value, filter) {
if(filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
return true;
}
if(value === undefined || value === null) {
return false;
}
return value.toString().toLowerCase().indexOf(filter.toLowerCase()) !== -1;
}
static endsWith(value, filter) {
if(filter === undefined || filter === null || filter.trim() === '') {
return true;
}
if(value === undefined || value === null) {
return false;
}
let filterValue = filter.toString().toLowerCase();
return value.toString().toLowerCase().indexOf(filterValue, value.toString().length - filterValue.length) !== -1;
}
static equals(value, filter) {
if(filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
return true;
}
if(value === undefined || value === null) {
return false;
}
return value.toString().toLowerCase() === filter.toString().toLowerCase();
}
static notEquals(value, filter) {
if(filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
return false;
}
if(value === undefined || value === null) {
return true;
}
return value.toString().toLowerCase() !== filter.toString().toLowerCase();
}
static in(value, filter) {
if(filter === undefined || filter === null || filter.length === 0) {
return true;
}
if(value === undefined || value === null) {
return false;
}
for(let i = 0; i < filter.length; i++) {
if(filter[i] === value)
return true;
}
return false;
}
}

View File

@ -1,7 +1,7 @@
export default class ObjectUtils { export default class ObjectUtils {
static equals(obj1, obj2, field) { static equals(obj1, obj2, field) {
if(field) if (field)
return (this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field)); return (this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field));
else else
return this.deepEquals(obj1, obj2); return this.deepEquals(obj1, obj2);
@ -56,16 +56,16 @@ export default class ObjectUtils {
return a !== a && b !== b; return a !== a && b !== b;
} }
static resolveFieldData(data, field) { static resolveFieldData(data, field) {
if(data && field) { if (data && field) {
if(field.indexOf('.') === -1) { if (field.indexOf('.') === -1) {
return data[field]; return data[field];
} }
else { else {
let fields = field.split('.'); let fields = field.split('.');
let value = data; let value = data;
for(var i = 0, len = fields.length; i < len; ++i) { for (var i = 0, len = fields.length; i < len; ++i) {
value = value[fields[i]]; value = value[fields[i]];
} }
return value; return value;
@ -76,12 +76,12 @@ export default class ObjectUtils {
} }
} }
static filter(value, fields, filterValue) { static filter(value, fields, filterValue) {
var filteredItems=[]; var filteredItems = [];
if(value) { if (value) {
for(let item of value) { for (let item of value) {
for(let field of fields) { for (let field of fields) {
if(String(this.resolveFieldData(item, field)).toLowerCase().indexOf(filterValue.toLowerCase()) > -1) { if (String(this.resolveFieldData(item, field)).toLowerCase().indexOf(filterValue.toLowerCase()) > -1) {
filteredItems.push(item); filteredItems.push(item);
break; break;
} }
@ -94,29 +94,29 @@ export default class ObjectUtils {
static reorderArray(value, from, to) { static reorderArray(value, from, to) {
let target; let target;
if(value && (from !== to)) { if (value && (from !== to)) {
if(to >= value.length) { if (to >= value.length) {
target = to - value.length; target = to - value.length;
while((target--) + 1) { while ((target--) + 1) {
value.push(undefined); value.push(undefined);
} }
} }
value.splice(to, 0, value.splice(from, 1)[0]); value.splice(to, 0, value.splice(from, 1)[0]);
} }
} }
static findIndexInList(value, list) { static findIndexInList(value, list) {
let index = -1; let index = -1;
if(list) { if (list) {
for(let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
if(list[i] === value) { if (list[i] === value) {
index = i; index = i;
break; break;
} }
} }
} }
return index; return index;
} }
@ -130,4 +130,86 @@ export default class ObjectUtils {
return false; return false;
} }
static filterConstraints = {
startsWith(value, filter) {
if (filter === undefined || filter === null || filter.trim() === '') {
return true;
}
if (value === undefined || value === null) {
return false;
}
let filterValue = filter.toLowerCase();
return value.toString().toLowerCase().slice(0, filterValue.length) === filterValue;
},
contains(value, filter) {
if (filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
return true;
}
if (value === undefined || value === null) {
return false;
}
return value.toString().toLowerCase().indexOf(filter.toLowerCase()) !== -1;
},
endsWith(value, filter) {
if (filter === undefined || filter === null || filter.trim() === '') {
return true;
}
if (value === undefined || value === null) {
return false;
}
let filterValue = filter.toString().toLowerCase();
return value.toString().toLowerCase().indexOf(filterValue, value.toString().length - filterValue.length) !== -1;
},
equals(value, filter) {
if (filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
return true;
}
if (value === undefined || value === null) {
return false;
}
return value.toString().toLowerCase() === filter.toString().toLowerCase();
},
notEquals(value, filter) {
if (filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
return false;
}
if (value === undefined || value === null) {
return true;
}
return value.toString().toLowerCase() !== filter.toString().toLowerCase();
},
in(value, filter) {
if (filter === undefined || filter === null || filter.length === 0) {
return true;
}
if (value === undefined || value === null) {
return false;
}
for (let i = 0; i < filter.length; i++) {
if (filter[i] === value)
return true;
}
return false;
}
}
} }