From 1855c7f74a12b773eb749a12160234bf7be8c38b Mon Sep 17 00:00:00 2001 From: Pablo Schaffner Date: Sat, 3 Dec 2022 10:58:32 -0300 Subject: [PATCH] fixed some bugs --- lib/index.js | 128 +++++++++++++++++++++++++--------------------- package-lock.json | 30 ++++++----- package.json | 2 +- src/index.js | 27 +++++++--- 4 files changed, 109 insertions(+), 78 deletions(-) diff --git a/lib/index.js b/lib/index.js index 6c222e3..09450cc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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 @@ -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 = ''; @@ -1044,8 +1067,7 @@ return new_; }; - - require('fs').promises; // + // // generate .autocomplete/autocomplete.json file // @@ -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, @@ -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; } } diff --git a/package-lock.json b/package-lock.json index ad7666f..546a46b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@concepto/interface", - "version": "2.1.998", + "version": "2.2.71", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@concepto/interface", - "version": "2.1.998", + "version": "2.2.71", "license": "MIT", "dependencies": { "@concepto/console": "*", @@ -2224,14 +2224,20 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001286", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001286.tgz", - "integrity": "sha512-zaEMRH6xg8ESMi2eQ3R4eZ5qw/hJiVsO/HlLwniIwErij0JDr9P+8V4dtx1l+kLq6j3yy8l8W4fst1lBnat5wQ==", + "version": "1.0.30001436", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001436.tgz", + "integrity": "sha512-ZmWkKsnC2ifEPoWUvSAIGyOYwT+keAaaWPHiQ9DfMqS1t6tfuyFYoWR78TeZtznkEQ64+vGXH9cZrElwR2Mrxg==", "dev": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - } + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + } + ] }, "node_modules/catharsis": { "version": "0.9.0", @@ -6642,9 +6648,9 @@ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" }, "caniuse-lite": { - "version": "1.0.30001286", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001286.tgz", - "integrity": "sha512-zaEMRH6xg8ESMi2eQ3R4eZ5qw/hJiVsO/HlLwniIwErij0JDr9P+8V4dtx1l+kLq6j3yy8l8W4fst1lBnat5wQ==", + "version": "1.0.30001436", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001436.tgz", + "integrity": "sha512-ZmWkKsnC2ifEPoWUvSAIGyOYwT+keAaaWPHiQ9DfMqS1t6tfuyFYoWR78TeZtznkEQ64+vGXH9cZrElwR2Mrxg==", "dev": true }, "catharsis": { diff --git a/package.json b/package.json index cf1b1b2..a091055 100755 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.js b/src/index.js index 21fe40a..0c1c6a1 100644 --- a/src/index.js +++ b/src/index.js @@ -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; @@ -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) @@ -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 // @@ -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('+'); @@ -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,