From 47d228dca5107b7e54263740a29959e290029b4a Mon Sep 17 00:00:00 2001 From: Pamela Ubuntu Date: Thu, 16 May 2024 15:13:05 -0300 Subject: [PATCH] 1.18.4 --- buildWBR.js | 12 +++- package.json | 2 +- build.js => scaffolding.js | 60 ++++++++---------- scaffolding/package.json | 2 +- scaffolding/wbr.js => wbr.js | 114 +++++++++++++---------------------- 5 files changed, 78 insertions(+), 112 deletions(-) rename build.js => scaffolding.js (80%) rename scaffolding/wbr.js => wbr.js (93%) diff --git a/buildWBR.js b/buildWBR.js index fee12c4..8281723 100644 --- a/buildWBR.js +++ b/buildWBR.js @@ -6,7 +6,13 @@ const ncp = require("ncp").ncp; // @ts-ignore ncp.limit = 16; ncp( - path.join(__dirname, "./scaffolding/wbr.js"), + path.join(__dirname, "./wbr.js"), path.join(__dirname, "../../", "wbr.js"), - function (err) { } -); \ No newline at end of file + function (err) {} +); + +ncp( + path.join(__dirname, "./scaffolding.js"), + path.join(__dirname, "../../", "scaffolding.js"), + function (err) {} +); diff --git a/package.json b/package.json index 7e9e95f..743f8ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "winnetoujs", - "version": "1.18.3", + "version": "1.18.4", "description": "The indie javascript constructor", "main": "src/winnetou.js", "dependencies": { diff --git a/build.js b/scaffolding.js similarity index 80% rename from build.js rename to scaffolding.js index b59abbe..5b8818c 100644 --- a/build.js +++ b/scaffolding.js @@ -67,29 +67,17 @@ const drawText = (text = "", params) => { let line = "= " + color + text + "\x1b[0m"; if (params && params.type === "add") { - line = - "= \x1b[42m\x1b[37m success \x1b[0m " + - color + - text + - "\x1b[0m"; + line = "= \x1b[42m\x1b[37m success \x1b[0m " + color + text + "\x1b[0m"; text = " success " + text; } if (params && params.type === "change") { - line = - "= \x1b[45m\x1b[37m changed \x1b[0m " + - color + - text + - "\x1b[0m"; + line = "= \x1b[45m\x1b[37m changed \x1b[0m " + color + text + "\x1b[0m"; text = " changed " + text; } if (params && params.type === "addError") { - line = - "= \x1b[5m\x1b[43m\x1b[37m fail \x1b[0m " + - color + - text + - "\x1b[0m"; + line = "= \x1b[5m\x1b[43m\x1b[37m fail \x1b[0m " + color + text + "\x1b[0m"; text = " fail " + text; } @@ -107,7 +95,7 @@ const drawText = (text = "", params) => { const drawTextBlock = (text, params) => { let arr = text.match(/.{1,74}/g); - arr.forEach(item => { + arr.forEach((item) => { drawText(item, params); }); }; @@ -124,7 +112,7 @@ const drawSpace = () => { * Draw error * @param {string} text error string */ -const drawError = text => { +const drawError = (text) => { errorsCount++; drawLine(); drawBlankLine(); @@ -136,7 +124,7 @@ const drawError = text => { drawBlankLine(); }; -const drawWarning = text => { +const drawWarning = (text) => { warningCount++; drawLine(); drawBlankLine(); @@ -154,10 +142,9 @@ const drawWelcome = () => { drawBlankLine(); drawText("W I N N E T O U J S ", { color: "bright" }); drawBlankLine(); - drawText( - "T h e i n d i e j a v a s c r i p t c o n s t r u c t o r", - { color: "dim" } - ); + drawText("T h e i n d i e j a v a s c r i p t c o n s t r u c t o r", { + color: "dim", + }); drawBlankLine(); drawText("WinnetouJs.org", { color: "yellow" }); @@ -184,28 +171,28 @@ const drawWelcome = () => { * Draw add * @param {string} text add string */ -const drawAdd = text => { +const drawAdd = (text) => { drawText(text, { type: "add", color: "green" }); drawBlankLine(); }; -const drawChange = text => { +const drawChange = (text) => { drawText(text, { type: "change", color: "green" }); drawBlankLine(); }; -const drawAddError = text => { +const drawAddError = (text) => { errorsCount++; drawText(text, { type: "addError", color: "cyan" }); drawBlankLine(); }; -const drawHtmlMin = text => { +const drawHtmlMin = (text) => { console.log("> [html minifield] " + text); }; -const drawEnd = text => { +const drawEnd = (text) => { console.log("> [Bundle Release Finished] " + text); }; @@ -240,12 +227,15 @@ drawBlankLine(); //@ts-ignore ncp.limit = 16; - -ncp( path.join(__dirname, "./scaffolding"), path.join(__dirname, "../../"), function (err) { - if (err) { - return drawError(err); - } - drawAdd('Scaffolding complete'); - drawFinal(); -}); +ncp( + path.join(__dirname, "./node_modules/winnetoujs/scaffolding"), + path.join(__dirname, "./"), + function (err) { + if (err) { + return drawError(err.join("\n")); + } + drawAdd("Scaffolding complete"); + drawFinal(); + } +); diff --git a/scaffolding/package.json b/scaffolding/package.json index a397bdf..249beea 100644 --- a/scaffolding/package.json +++ b/scaffolding/package.json @@ -10,7 +10,7 @@ "recursive-readdir": "^2.2.2", "sass": "^1.77.1", "uglifycss": "0.0.29", - "winnetoujs": "^1.18.3", + "winnetoujs": "^1.18.4", "xml-parse": "^0.4.0" }, "devDependencies": { diff --git a/scaffolding/wbr.js b/wbr.js similarity index 93% rename from scaffolding/wbr.js rename to wbr.js index c3a98c3..91ceaa7 100644 --- a/scaffolding/wbr.js +++ b/wbr.js @@ -35,7 +35,7 @@ const ncp = require("ncp").ncp; let global = { errorsCount: 0, warningCount: 0, - /**@type {import("./interfaces.js").IWinConfig} */ + /**@type {import("./scaffolding/interfaces.js").IWinConfig} */ config: { constructosPath: "", constructosOut: "", @@ -113,14 +113,6 @@ class WBR { : this.bundleRelease(); break; - case "--scaffolding": - this.scaffolding(); - break; - - case "-scaffolding": - this.scaffolding(); - break; - case "": this.transpileAll(); break; @@ -138,28 +130,6 @@ class WBR { } } - scaffolding() { - new Drawer().drawText("Init scaffolding ..."); - new Drawer().drawBlankLine(); - - // COPY METHODS =============================================== - - //@ts-ignore - ncp.limit = 16; - - ncp( - path.join(__dirname, "./node_modules/winnetoujs/scaffolding"), - path.join(__dirname, "./"), - function (err) { - if (err) { - return new Drawer().drawError(err.join("\n")); - } - new Drawer().drawAdd("Scaffolding complete"); - new Drawer().drawFinal(); - } - ); - } - fixedJson(badJSON) { let a = badJSON.replace("export default", "").replace(";", ""); return eval(`(${a})`); @@ -239,7 +209,7 @@ class WBR { } watchFiles() { - const refresh = name => { + const refresh = (name) => { new Drawer().drawChange(name); global.idList = []; global.promisesConstructos = []; @@ -335,7 +305,7 @@ class WBR { let out = global.config.out; if (typeof entry === "object") { let keys = Object.keys(entry); - keys.map(key => { + keys.map((key) => { global.config.entry = entry[key]; global.config.out = out[key]; return this.__bundle(entry[key], out[key]); @@ -432,11 +402,11 @@ class Icons { } } - Promise.all(global.promisesIcons).then(async res => { + Promise.all(global.promisesIcons).then(async (res) => { let splitter = new Array(); splitter["icons"] = []; - res.forEach(item => { + res.forEach((item) => { if (typeof item == "object") { let s = item.iconPath.split("/"); if (s.length > 2) { @@ -450,7 +420,7 @@ class Icons { let finalPromise = []; - Object.keys(splitter).forEach(key => { + Object.keys(splitter).forEach((key) => { finalPromise.push( fs.outputFile( path.join( @@ -462,7 +432,7 @@ class Icons { ); }); - Promise.all(finalPromise).then(res => { + Promise.all(finalPromise).then((res) => { global.transpileIconsComplete = true; return resolve(true); }); @@ -479,7 +449,7 @@ class Icons { let id = iconPath.match(regPath); - id = id.filter(x => x != "svg"); + id = id.filter((x) => x != "svg"); id = id.join("_"); @@ -549,8 +519,8 @@ class Constructos { return resolve(true); } files2 = files2 - .filter(x => x.includes("win-")) - .filter(x => x.includes(".htm") || x.includes(".html")); + .filter((x) => x.includes("win-")) + .filter((x) => x.includes(".htm") || x.includes(".html")); if (files2.length > 0) { try { @@ -589,14 +559,14 @@ class Constructos { async transpileConstructo(filePath) { return new Promise((resolve, reject) => { try { - new Files().getFileFromCacheAsync(filePath).then(data => { + new Files().getFileFromCacheAsync(filePath).then((data) => { // transforma o html em método let dom = htmlParser.parse(data); let components = dom.querySelectorAll("winnetou"); let finalReturn = ""; let constructos = []; - Array.from(components).forEach(component => { + Array.from(components).forEach((component) => { let descri = component.getAttribute("description"); let constructo = component.innerHTML; let jsdoc = "\n\n// ========================================"; @@ -621,7 +591,7 @@ class Constructos { let pureId = id + "-win-${identifier}"; - let verify = global.idList.filter(data => data.id === id); + let verify = global.idList.filter((data) => data.id === id); //duplicated constructo if (verify.length > 0) { @@ -644,12 +614,12 @@ class Constructos { let ids = "ids:{"; - matchIds = matchIds.map(item => + matchIds = matchIds.map((item) => item.replace("[[", "").replace("]]", "") ); - matchIds = matchIds.map(item => item + "-win-${identifier}"); + matchIds = matchIds.map((item) => item + "-win-${identifier}"); - matchIds.forEach(item => { + matchIds.forEach((item) => { let nome = item.split("-win-")[0]; ids += nome + ":`" + item + "`,"; }); @@ -670,7 +640,7 @@ class Constructos { let matches = constructo.match(regex); if (matches) { - matches.forEach(match => { + matches.forEach((match) => { let el = match.replace("{{", ""); el = el.replace("}}", ""); @@ -785,7 +755,7 @@ class Constructos { async execPromisesConstructos() { return new Promise((resolve, reject) => { - Promise.all(global.promisesConstructos).then(async data => { + Promise.all(global.promisesConstructos).then(async (data) => { /** * data[0].method * data[0].constructosList @@ -842,8 +812,8 @@ class Constructos { recursive("./node_modules", async (err2, files2) => { if (err2) files2 = []; files2 = files2 - .filter(x => x.includes("win-")) - .filter(x => x.includes(".htm") || x.includes(".html")); + .filter((x) => x.includes("win-")) + .filter((x) => x.includes(".htm") || x.includes(".html")); if (files2.length > 0) { try { @@ -853,17 +823,17 @@ class Constructos { } } - files = files.map(x => path.parse(x).name); + files = files.map((x) => path.parse(x).name); recursive(constructosOut, async (err3, jsFiles) => { - jsFiles = jsFiles.map(x => path.parse(x).name); + jsFiles = jsFiles.map((x) => path.parse(x).name); let diff = this.diffArray(files, jsFiles); - diff = diff.map(x => path.join("./", constructosOut, x + ".js")); + diff = diff.map((x) => path.join("./", constructosOut, x + ".js")); - diff.forEach(item => { - fs.unlink(item, e => {}); + diff.forEach((item) => { + fs.unlink(item, (e) => {}); }); }); }); @@ -873,7 +843,7 @@ class Constructos { diffArray(arr1, arr2) { return arr1 .concat(arr2) - .filter(val => !(arr1.includes(val) && arr2.includes(val))); + .filter((val) => !(arr1.includes(val) && arr2.includes(val))); } } @@ -901,7 +871,7 @@ class Translator { } let trad = xml.parse(data)[0].childNodes; - trad.forEach(item => { + trad.forEach((item) => { if (item.tagName && item.childNodes[0]?.text) { strings += ` /** @property ${item.childNodes[0].text.trim()} */ @@ -929,7 +899,7 @@ class Translator { indent_size: 2, space_in_empty_paren: true, }), - err => { + (err) => { new Drawer().drawAdd("Strings"); return resolve(true); } @@ -961,7 +931,7 @@ class Translator { return resolve(true); } - Object.keys(file).map(key => { + Object.keys(file).map((key) => { let value = file[key]; strings += ` /** @property ${value} */ @@ -985,7 +955,7 @@ class Translator { indent_size: 2, space_in_empty_paren: true, }), - err => { + (err) => { new Drawer().drawAdd("Strings"); return resolve(true); } @@ -1031,10 +1001,10 @@ class Sass { return new Promise(async (resolve, reject) => { sass .compileAsync(file) - .then(res => { + .then((res) => { return resolve(res.css.toString()); }) - .catch(e => { + .catch((e) => { return reject(e); }); }); @@ -1043,7 +1013,7 @@ class Sass { async execSassPromises() { return new Promise((resolve, reject) => { Promise.all(global.promisesCss) - .then(data => { + .then((data) => { // data has all css files data.push( ` @@ -1069,7 +1039,7 @@ class Sass { } ); }) - .catch(e => { + .catch((e) => { new Err().e004(); return resolve(true); }); @@ -1166,7 +1136,7 @@ class Drawer { drawTextBlock = (text, params) => { let arr = text.match(/.{1,74}/g); - arr.forEach(item => { + arr.forEach((item) => { this.drawText(item, params); }); }; @@ -1183,7 +1153,7 @@ class Drawer { * Draw error * @param {string} text error string */ - drawError = text => { + drawError = (text) => { global.errorsCount++; this.drawLine(); this.drawBlankLine(); @@ -1195,7 +1165,7 @@ class Drawer { this.drawBlankLine(); }; - drawWarning = text => { + drawWarning = (text) => { global.warningCount++; this.drawLine(); this.drawBlankLine(); @@ -1248,28 +1218,28 @@ class Drawer { * Draw add * @param {string} text add string */ - drawAdd = text => { + drawAdd = (text) => { this.drawText(text, { type: "add", color: "green" }); this.drawBlankLine(); }; - drawChange = text => { + drawChange = (text) => { this.drawText(text, { type: "change", color: "green" }); this.drawBlankLine(); }; - drawAddError = text => { + drawAddError = (text) => { global.errorsCount++; this.drawText(text, { type: "addError", color: "cyan" }); this.drawBlankLine(); }; - drawHtmlMin = text => { + drawHtmlMin = (text) => { console.log("> [html minified] " + text); }; - drawEnd = text => { + drawEnd = (text) => { console.log("> [Bundle Release Finished] " + text); };