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 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');
fs.readdirSync(path.resolve(__dirname, './src/components/')).forEach(folder => {
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();
console.log('Building ' + filename);
let filename = file.split(/(.vue)$|(.js)$/)[0].toLowerCase();
if (/\.vue$/.test(file)) {
console.log('Building ' + blue(filename));
execSync(
`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');
gulp.task('copy-components', function() {
return gulp.src(['src/components/**/*'])
return gulp.src(['src/components/**/*.vue'])
.pipe(gulp.dest('./components'));
});

View File

@ -26,6 +26,8 @@
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0-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 {
static equals(obj1, obj2, field) {
if(field)
if (field)
return (this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field));
else
return this.deepEquals(obj1, obj2);
@ -56,16 +56,16 @@ export default class ObjectUtils {
return a !== a && b !== b;
}
static resolveFieldData(data, field) {
if(data && field) {
if(field.indexOf('.') === -1) {
if (data && field) {
if (field.indexOf('.') === -1) {
return data[field];
}
else {
let fields = field.split('.');
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]];
}
return value;
@ -76,12 +76,12 @@ export default class ObjectUtils {
}
}
static filter(value, fields, filterValue) {
var filteredItems=[];
var filteredItems = [];
if(value) {
for(let item of value) {
for(let field of fields) {
if(String(this.resolveFieldData(item, field)).toLowerCase().indexOf(filterValue.toLowerCase()) > -1) {
if (value) {
for (let item of value) {
for (let field of fields) {
if (String(this.resolveFieldData(item, field)).toLowerCase().indexOf(filterValue.toLowerCase()) > -1) {
filteredItems.push(item);
break;
}
@ -94,29 +94,29 @@ export default class ObjectUtils {
static reorderArray(value, from, to) {
let target;
if(value && (from !== to)) {
if(to >= value.length) {
if (value && (from !== to)) {
if (to >= value.length) {
target = to - value.length;
while((target--) + 1) {
while ((target--) + 1) {
value.push(undefined);
}
}
value.splice(to, 0, value.splice(from, 1)[0]);
}
}
static findIndexInList(value, list) {
let index = -1;
if(list) {
for(let i = 0; i < list.length; i++) {
if(list[i] === value) {
if (list) {
for (let i = 0; i < list.length; i++) {
if (list[i] === value) {
index = i;
break;
}
}
}
return index;
}
@ -130,4 +130,86 @@ export default class ObjectUtils {
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;
}
}
}