Skip to content

Commit

Permalink
build dist
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Sep 28, 2016
1 parent b665c9b commit 82793cb
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 81 deletions.
6 changes: 3 additions & 3 deletions dist/cli/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ var _mkdirp2 = _interopRequireDefault(_mkdirp);

var _es6Promise = require('es6-promise');

var _slugify = require('./helpers/slugify');
var _limax = require('limax');

var _slugify2 = _interopRequireDefault(_slugify);
var _limax2 = _interopRequireDefault(_limax);

var _ = require('./');

Expand All @@ -37,7 +37,7 @@ var Create = function () {
var _this = this;

path = path.split('/');
path[path.length - 1] = (0, _slugify2.default)(path[path.length - 1]);
path[path.length - 1] = (0, _limax2.default)(path[path.length - 1]);
path = path.join('/');
this.addFolder(path).then(function () {
process.chdir(path);
Expand Down
2 changes: 1 addition & 1 deletion dist/cli/config/abe-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var config = {
fontSrc: [],
connectSrc: []
},
security: true,
security: false,
htmlWhiteList: {
'blockquote': ['style'],
'span': ['style'],
Expand Down
28 changes: 16 additions & 12 deletions dist/cli/helpers/abe-get-select-template-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,22 @@ var findRequestColumns = function findRequestColumns(templatesList) {
switch (type) {
case 'request':
var request = _cli.Sql.handleSqlRequest(obj.sourceString, {});
Array.prototype.forEach.call(request.columns, function (column) {
if (typeof whereKeysCheck[column] === 'undefined' || whereKeysCheck[column] === null) {
whereKeysCheck[column] = true;
whereKeys.push(column);
}
});
Array.prototype.forEach.call(request.where, function (where) {
if (typeof whereKeysCheck[where.left] === 'undefined' || whereKeysCheck[where.left] === null) {
whereKeysCheck[where.left] = true;
whereKeys.push(where.left);
}
});
if (typeof request.columns !== 'undefined' && request.columns !== null) {
Array.prototype.forEach.call(request.columns, function (column) {
if (typeof whereKeysCheck[column] === 'undefined' || whereKeysCheck[column] === null) {
whereKeysCheck[column] = true;
whereKeys.push(column);
}
});
}
if (typeof request.where !== 'undefined' && request.where !== null) {
Array.prototype.forEach.call(request.where, function (where) {
if (typeof whereKeysCheck[where.left] === 'undefined' || whereKeysCheck[where.left] === null) {
whereKeysCheck[where.left] = true;
whereKeys.push(where.left);
}
});
}
}
});
});
Expand Down
102 changes: 46 additions & 56 deletions dist/cli/helpers/abe-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ var Sql = function () {
jsonValues[column] = json[column];
}
});
jsonValues[_.config.meta.name] = json[_.config.meta.name];
jsonValues["abe_meta"] = json["abe_meta"];
} else {
jsonValues = json;
}
Expand Down Expand Up @@ -531,7 +531,7 @@ var Sql = function () {
key: 'whereNotEquals',
value: function whereNotEquals(where, value, compare, json) {
var shouldAdd = true;
if (where.left === 'template') {
if (where.left === 'template' || where.left === 'abe_meta.template') {

if (value.indexOf('/') > -1 && value === compare) {
shouldAdd = false;
Expand Down Expand Up @@ -577,7 +577,7 @@ var Sql = function () {
key: 'whereLike',
value: function whereLike(where, value, compare, json) {
var shouldAdd = true;
if (where.left === 'template') {
if (where.left === 'template' || where.left === 'abe_meta.template') {

if (value.indexOf(compare) === -1) {
shouldAdd = false;
Expand Down Expand Up @@ -609,11 +609,8 @@ var Sql = function () {
foundOne = true;
}
});
} else if (value === compare) {
// only none is Array
if (value.indexOf(compare) !== -1) {
foundOne = true;
}
} else if (value.indexOf(compare) === -1) {
foundOne = true;
}

if (foundOne) {
Expand All @@ -631,61 +628,54 @@ var Sql = function () {
var shouldAdd = jsonDoc;

if (typeof wheres !== 'undefined' && wheres !== null) {
(function () {
var meta = _.config.meta.name;
if (typeof jsonDoc[meta] !== 'undefined' && jsonDoc[meta] !== null) {
Array.prototype.forEach.call(wheres, function (where) {
var value;
var compare;

if (where.left === 'template' || where.left === 'abe_meta.template') {
value = _.FileParser.getTemplate(jsonDoc[meta].template);
} else {
try {
value = eval('jsonDoc.' + where.left);
} catch (e) {
// console.log('e', e)
}
}
compare = where.right;

var matchVariable = /^{{(.*)}}$/.exec(compare);
if (typeof matchVariable !== 'undefined' && matchVariable !== null && matchVariable.length > 0) {
try {
var shouldCompare = eval('jsonOriginalDoc.' + matchVariable[1]);
if (typeof shouldCompare !== 'undefined' && shouldCompare !== null) {
compare = shouldCompare;
} else {
shouldAdd = false;
}
} catch (e) {
shouldAdd = false;
// console.log('e', e)
}
}
Array.prototype.forEach.call(wheres, function (where) {
var value;
var compare;

if (typeof value !== 'undefined' && value !== null) {
switch (where.compare) {
case '=':
shouldAdd = Sql.whereEquals(where, value, compare, shouldAdd);
break;
case '!=':
shouldAdd = Sql.whereNotEquals(where, value, compare, shouldAdd);
break;
case 'LIKE':
shouldAdd = Sql.whereLike(where, value, compare, shouldAdd);
break;
default:
break;
}
if ((where.left === 'template' || where.left === 'abe_meta.template') && typeof jsonDoc["abe_meta"] !== 'undefined' && jsonDoc["abe_meta"] !== null) {
value = _.FileParser.getTemplate(jsonDoc["abe_meta"].template);
} else {
try {
value = eval('jsonDoc.' + where.left);
} catch (e) {
// console.log('e', e)
}
}
compare = where.right;

var matchVariable = /^{{(.*)}}$/.exec(compare);
if (typeof matchVariable !== 'undefined' && matchVariable !== null && matchVariable.length > 0) {
try {
var shouldCompare = eval('jsonOriginalDoc.' + matchVariable[1]);
if (typeof shouldCompare !== 'undefined' && shouldCompare !== null) {
compare = shouldCompare;
} else {
shouldAdd = false;
}
});
} catch (e) {
shouldAdd = false;
// console.log('e', e)
}
}

if (typeof value !== 'undefined' && value !== null) {
switch (where.compare) {
case '=':
shouldAdd = Sql.whereEquals(where, value, compare, shouldAdd);
break;
case '!=':
shouldAdd = Sql.whereNotEquals(where, value, compare, shouldAdd);
break;
case 'LIKE':
shouldAdd = Sql.whereLike(where, value, compare, shouldAdd);
break;
default:
break;
}
} else {
shouldAdd = false;
}
})();
});
}

return shouldAdd;
Expand Down
29 changes: 22 additions & 7 deletions dist/cli/helpers/abe-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addOrder = addOrder;
exports.getAbeImport = getAbeImport;
exports.includePartials = includePartials;
exports.getTemplate = getTemplate;

var _fsExtra = require('fs-extra');
Expand Down Expand Up @@ -46,19 +49,31 @@ function addOrder(text) {
return text;
}

function partials(text) {
var importReg = /({{abe.*type=[\'|\"]import.*}})/g;
function getAbeImport(text) {
var partials = [];
var listReg = /({{abe.*?type=[\'|\"]import.*?}})/g;
var match;
while (match = listReg.exec(text)) {
partials.push(match[0]);
}

return partials;
}

while (match = importReg.exec(text)) {
var file = (0, _cli.getAttr)(match[0], 'file');
function includePartials(text) {
var abeImports = getAbeImport(text);

Array.prototype.forEach.call(abeImports, function (abeImport) {
var obj = _cli.Util.getAllAttributes(abeImport, {});

var file = obj.file;
var partial = '';
file = _path2.default.join(_cli.config.root, _cli.config.partials, file);
if (_cli.fileUtils.isFile(file)) {
partial = _fsExtra2.default.readFileSync(file, 'utf8');
}
text = text.replace((0, _cli.escapeTextToRegex)(match[0], 'g'), partial);
}
text = text.replace((0, _cli.escapeTextToRegex)(abeImport, 'g'), partial);
});

return text;
}
Expand Down Expand Up @@ -121,7 +136,7 @@ function getTemplate(file) {
file = _path2.default.join(_cli.config.root, _cli.config.templates.url, file + '.' + _cli.config.files.templates.extension);
if (_cli.fileUtils.isFile(file)) {
text = _fsExtra2.default.readFileSync(file, 'utf8');
text = partials(text);
text = includePartials(text);
text = translate(text);
text = addOrder(text);
} else {
Expand Down
1 change: 1 addition & 0 deletions dist/cli/helpers/abe-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ var Utils = function () {
tab: 'default',
type: 'text',
value: '',
file: '',
visible: true
};

Expand Down
2 changes: 1 addition & 1 deletion dist/cli/helpers/file-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ var FileParser = function () {

if (typeof json.abe_meta !== 'undefined' && json.abe_meta !== null) {
var date = null;
if (typeof json.abe_meta.latest.date !== 'undefined' && json.abe_meta.latest.date !== null) {
if (typeof json.abe_meta.latest !== 'undefined' && json.abe_meta.latest !== null && typeof json.abe_meta.latest.date !== 'undefined' && json.abe_meta.latest.date !== null) {
date = json.abe_meta.latest.date;
} else if (typeof json.abe_meta.date !== 'undefined' && json.abe_meta.date !== null) {
date = json.abe_meta.date;
Expand Down
2 changes: 1 addition & 1 deletion dist/cli/models/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var Manager = function () {
_this._whereKeys = whereKeys;
_this.updateList();
resolve();
}, function () {
}, function (e) {
console.log('Manager._init', e);
}).catch(function (e) {
console.log('Manager._init', e);
Expand Down

0 comments on commit 82793cb

Please sign in to comment.