Skip to content

Commit

Permalink
fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
puntorigen committed Dec 3, 2022
1 parent 834bf0a commit 1855c7f
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 78 deletions.
128 changes: 70 additions & 58 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,31 @@
_this3.x_console.outT({
message: "generating autocomplete files",
color: 'brightCyan'
}); //get x_commands meta data object
}); //adds support for generating autocomplete files


var path = require('path'),
fs = require('fs').promises;

var tmp_directory = path.dirname(path.resolve(_this3.x_flags.dsl));
var autocomplete_path = path.join(tmp_directory, '.concepto', '.autocomplete');

try {
yield fs.mkdir(autocomplete_path, {
recursive: true
});
} catch (errdir) {}

if (!_this3.autocomplete) {
_this3.autocomplete = {
path: autocomplete_path,
records: {},
json: {},
refs: {}
};
} else {
_this3.autocomplete.path = autocomplete_path;
} //get x_commands meta data object
//const meta_ = Object.keys(this.x_commands.meta)[0]; //x_commands meta data for first lib of x_commands


Expand Down Expand Up @@ -927,8 +951,7 @@
'Hint': 'Descripción'
}
}; // concepto icons REAL location (for copying autocomplete icons)

var path = require('path');
//let path = require('path');

var iconsPath = '';

Expand Down Expand Up @@ -1044,8 +1067,7 @@

return new_;
};

require('fs').promises; //
//
// generate .autocomplete/autocomplete.json file
//

Expand Down Expand Up @@ -1181,65 +1203,55 @@
}
*/
//prepare input text: get first 16 chars of text and replace spaces and : with +
var preparedText = text.trim().substring(0, 16).replaceAll(' ', '+').replaceAll(':', '+'); //generate all keys alternatives for this definition

var keys = [];
var key = ''; //best key definition
//const preparedText = text.trim().substring(0,16).replaceAll(' ','+').replaceAll(':','+');
//generate all keys alternatives for this definition
//let keys = [];

if (icons.length > 0) {
key = icons.join('+');
keys.push(icons.join('+')); //just the joined icons
/*
let key = ''; //best key definition
if (icons.length>0) {
key = icons.join('+');
keys.push(icons.join('+')); //just the joined icons
}

if (preparedText.length > 0) {
if (key.length > 0) {
key += '-';
}

keys.push(preparedText); //just the prepared text

key += preparedText;
if (preparedText.length>0) {
if (key.length>0) {
key += '-';
}
keys.push(preparedText); //just the prepared text
key += preparedText;
}

if (level.length > 0) {
if (key.length > 0) {
key += '-';
} //append the level items to keys using es6


for (var i of level) {
keys.push(key + i); //variations of key with each level
}

keys.push(...level); //add the listed levels as well

key += level[0]; //just use first level as default for bestkey
if (level.length>0) {
if (key.length>0) {
key += '-';
}
//append the level items to keys using es6
for (let i of level) {
keys.push(key+i); //variations of key with each level
}
keys.push(...level); //add the listed levels as well
key += level[0]; //just use first level as default for bestkey
}

if (icons.length > 0 && level.length > 0) {
//icons-level
for (var _i of level) {
keys.push(icons.join('+') + '-' + _i); //add the listed levels combinations as well
}
if (icons.length>0 && level.length>0) {
//icons-level
for (let i of level) {
keys.push(icons.join('+') + '-' + i); //add the listed levels combinations as well
}
}

if (icons.length > 0 && preparedText.length > 0) {
//icons-preparedText
keys.push(icons.join('+') + '-' + preparedText);
if (icons.length>0 && preparedText.length>0) {
//icons-preparedText
keys.push(icons.join('+') + '-' + preparedText);
}

if (preparedText.length > 0 && level.length > 0) {
//preparedText-level
for (var _i2 of level) {
keys.push(preparedText + '-' + _i2); //add the listed levels combinations as well
}
} //add to def


if (preparedText.length>0 && level.length>0) {
//preparedText-level
for (let i of level) {
keys.push(preparedText + '-' + i); //add the listed levels combinations as well
}
}*/
//add to def
var hash = yield _this4.dsl_parser.hash(_arguments);
_this4.autocomplete.records[hash] = {
keys,
bestKey: key,
keys: [],
bestKey: '',
text,
icons,
level,
Expand Down Expand Up @@ -3490,8 +3502,8 @@
resp[keys[i]] = value;
}
} else {
for (var _i3 in resp) {
resp[_i3] = value;
for (var _i in resp) {
resp[_i] = value;
}
}

Expand Down
30 changes: 18 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@concepto/interface",
"version": "2.2.7",
"version": "2.2.721",
"description": "Concepto DSL - visually create and maintain modern node.js based apps (@interface)",
"keywords": [
"creador",
Expand Down
27 changes: 20 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,18 @@ export default class concepto {
async generateAutocompleteFiles() {
//reads object this.autocomplete.records and generates autocomplete files in the autocomplete folder
this.x_console.outT({ message:`generating autocomplete files`, color:'brightCyan' });
//adds support for generating autocomplete files
const path = require('path'), tmp = {}, fs = require('fs').promises;
const tmp_directory = path.dirname(path.resolve(this.x_flags.dsl));
let autocomplete_path = path.join(tmp_directory,'.concepto','.autocomplete');
try {
await fs.mkdir(autocomplete_path, { recursive:true });
} catch(errdir) { }
if (!this.autocomplete) {
this.autocomplete = { path:autocomplete_path, records:{}, json:{}, refs:{} };
} else {
this.autocomplete.path = autocomplete_path;
}
//get x_commands meta data object
//const meta_ = Object.keys(this.x_commands.meta)[0]; //x_commands meta data for first lib of x_commands
const meta = this.x_commands.meta;
Expand Down Expand Up @@ -603,7 +615,7 @@ export default class concepto {
}
};
// concepto icons REAL location (for copying autocomplete icons)
let path = require('path');
//let path = require('path');
let iconsPath = '';
try {
const root = (require('find-root'))(__dirname)
Expand Down Expand Up @@ -811,7 +823,7 @@ export default class concepto {
return xml;
};

let fs = require('fs').promises;
//let fs = require('fs').promises;
//
// generate .autocomplete/autocomplete.json file
//
Expand Down Expand Up @@ -921,9 +933,10 @@ export default class concepto {
}
*/
//prepare input text: get first 16 chars of text and replace spaces and : with +
const preparedText = text.trim().substring(0,16).replaceAll(' ','+').replaceAll(':','+');
//const preparedText = text.trim().substring(0,16).replaceAll(' ','+').replaceAll(':','+');
//generate all keys alternatives for this definition
let keys = [];
//let keys = [];
/*
let key = ''; //best key definition
if (icons.length>0) {
key = icons.join('+');
Expand Down Expand Up @@ -962,12 +975,12 @@ export default class concepto {
for (let i of level) {
keys.push(preparedText + '-' + i); //add the listed levels combinations as well
}
}
}*/
//add to def
let hash = await this.dsl_parser.hash(arguments);
this.autocomplete.records[hash] = {
keys,
bestKey:key,
keys:[],
bestKey:'',
text,
icons,
level,
Expand Down

0 comments on commit 1855c7f

Please sign in to comment.