From b2f7aeedf0b07c63f7ad9e6407fcf6a8601dd3ad Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Mon, 26 Dec 2022 12:05:46 +0100 Subject: [PATCH 1/4] refactor: replaced hogan.js by handlebars In an effort to keep our codebase up to date, we're replacing the much older hogan.js by handlebars --- packages/engine-react/lib/engine_react.js | 4 +-- packages/engine-react/package.json | 2 +- packages/uikit-workshop/package.json | 2 +- .../src/scripts/components/panels-viewer.js | 8 ++--- yarn.lock | 29 +------------------ 5 files changed, 9 insertions(+), 36 deletions(-) diff --git a/packages/engine-react/lib/engine_react.js b/packages/engine-react/lib/engine_react.js index 3c33f1eca..411a3bc2c 100644 --- a/packages/engine-react/lib/engine_react.js +++ b/packages/engine-react/lib/engine_react.js @@ -14,7 +14,7 @@ const path = require('path'); const React = require('react'); const ReactDOMServer = require('react-dom/server'); const Babel = require('babel-core'); -const Hogan = require('hogan'); +const Handlebars = require('handlebars'); const beautify = require('js-beautify'); const cheerio = require('cheerio'); const _require = require; @@ -44,7 +44,7 @@ let patternLabConfig = {}; let enableRuntimeCode = true; -const outputTemplate = Hogan.compile( +const outputTemplate = Handlebars.compile( fs.readFileSync(path.join(__dirname, './outputTemplate.mustache'), 'utf8') ); diff --git a/packages/engine-react/package.json b/packages/engine-react/package.json index a3ce0e3f0..2aa12b67b 100644 --- a/packages/engine-react/package.json +++ b/packages/engine-react/package.json @@ -9,7 +9,7 @@ "babel-plugin-transform-es2015-modules-commonjs": "6.16.0", "babel-preset-react": "6.16.0", "cheerio": "0.22.0", - "hogan": "1.0.2", + "handlebars": "^4.7.7", "js-beautify": "1.13.5", "react": "15.3.2", "react-dom": "15.3.2" diff --git a/packages/uikit-workshop/package.json b/packages/uikit-workshop/package.json index e1330de8b..3347167d1 100644 --- a/packages/uikit-workshop/package.json +++ b/packages/uikit-workshop/package.json @@ -63,9 +63,9 @@ "express": "^4.17.1", "fg-loadjs": "^1.1.0", "fuse.js": "^6.4.6", + "handlebars": "4.7.7", "hard-source-webpack-plugin-patch": "^0.13.3", "hasha": "^5.2.2", - "hogan.js": "^3.0.2", "html-loader": "^0.5.5", "html-webpack-plugin": "^4.0.0-beta.11", "lit-element": "^2.2.1", diff --git a/packages/uikit-workshop/src/scripts/components/panels-viewer.js b/packages/uikit-workshop/src/scripts/components/panels-viewer.js index 474bc91ad..a7989e978 100644 --- a/packages/uikit-workshop/src/scripts/components/panels-viewer.js +++ b/packages/uikit-workshop/src/scripts/components/panels-viewer.js @@ -3,7 +3,7 @@ */ /* eslint-disable no-param-reassign, no-unused-vars */ -import Hogan from 'hogan.js'; +import Handlebars from 'handlebars'; import pretty from 'pretty'; import { html, render } from 'lit-html'; import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'; @@ -175,7 +175,7 @@ export const panelsViewer = { } else { // vanilla render of pattern data template = document.getElementById(panel.templateID); - templateCompiled = Hogan.compile(template.innerHTML); + templateCompiled = Handlebars.compile(template.innerHTML); templateRendered = templateCompiled.render(patternData); const normalizedCode = normalizeWhitespace.normalize(templateRendered); @@ -272,7 +272,7 @@ export const panelsViewer = { } } - // add *Exists attributes for Hogan templates + // add *Exists attributes for Handlebars templates // figure out if the description exists patternData.patternDescExists = patternData.patternDesc.length > 0 || @@ -304,7 +304,7 @@ export const panelsViewer = { // render all of the panels in the base panel template const template = document.querySelector('.pl-js-panel-template-base'); - const templateCompiled = Hogan.compile(template.innerHTML); + const templateCompiled = Handlebars.compile(template.innerHTML); templateRendered = templateCompiled.render(patternData); // make sure templateRendered is modified to be an HTML element diff --git a/yarn.lock b/yarn.lock index 2ffddd8a3..0cfddf050 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7949,7 +7949,7 @@ hamljs@^0.6.2: resolved "https://registry.yarnpkg.com/hamljs/-/hamljs-0.6.2.tgz#7b7116cf6dbe7278e42b3f6ef8725a33e177c8e3" integrity sha1-e3EWz22+cnjkKz9u+HJaM+F3yOM= -handlebars@^4.7.6, handlebars@^4.7.7: +handlebars@4.7.7, handlebars@^4.7.6, handlebars@^4.7.7: version "4.7.7" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1" integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA== @@ -8158,21 +8158,6 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hogan.js@*, hogan.js@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/hogan.js/-/hogan.js-3.0.2.tgz#4cd9e1abd4294146e7679e41d7898732b02c7bfd" - integrity sha1-TNnhq9QpQUbnZ55B14mHMrAse/0= - dependencies: - mkdirp "0.3.0" - nopt "1.0.10" - -hogan@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/hogan/-/hogan-1.0.2.tgz#d8d5e57fae0e7787b3e01e14256f9d588a23d1f0" - integrity sha1-2NXlf64Od4ez4B4UJW+dWIoj0fA= - dependencies: - hogan.js "*" - home-or-tmp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" @@ -11031,11 +11016,6 @@ mkdirp2@^1.0.4: resolved "https://registry.yarnpkg.com/mkdirp2/-/mkdirp2-1.0.5.tgz#68bbe61defefafce4b48948608ec0bac942512c2" integrity sha512-xOE9xbICroUDmG1ye2h4bZ8WBie9EGmACaco8K8cx6RlkJJrxGIqjGqztAI+NMhexXBcdGbSEzI6N3EJPevxZw== -mkdirp@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" - integrity sha1-G79asbqCevI1dRQ0kEJkVfSB/h4= - mkdirp@0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" @@ -11369,13 +11349,6 @@ node-releases@^2.0.1: resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.1.tgz#3d1d395f204f1f2f29a54358b9fb678765ad2fc5" integrity sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA== -nopt@1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee" - integrity sha1-bd0hvSoxQXuScn3Vhfim83YI6+4= - dependencies: - abbrev "1" - nopt@^4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.3.tgz#a375cad9d02fd921278d954c2254d5aa57e15e48" From a606e6ce389fc15577bcac69aae70f7e9cf68ab6 Mon Sep 17 00:00:00 2001 From: Maximilian <787658+mfranzke@users.noreply.github.com> Date: Tue, 27 Dec 2022 22:13:03 +0100 Subject: [PATCH 2/4] chore: regenerated yarn.lock file --- yarn.lock | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/yarn.lock b/yarn.lock index 1e716ec97..fb9eeef26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7972,7 +7972,7 @@ hamljs@^0.6.2: resolved "https://registry.yarnpkg.com/hamljs/-/hamljs-0.6.2.tgz#7b7116cf6dbe7278e42b3f6ef8725a33e177c8e3" integrity sha1-e3EWz22+cnjkKz9u+HJaM+F3yOM= -handlebars@^4.7.6, handlebars@^4.7.7: +handlebars@4.7.7, handlebars@^4.7.6, handlebars@^4.7.7: version "4.7.7" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1" integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA== @@ -8181,21 +8181,6 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hogan.js@*, hogan.js@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/hogan.js/-/hogan.js-3.0.2.tgz#4cd9e1abd4294146e7679e41d7898732b02c7bfd" - integrity sha1-TNnhq9QpQUbnZ55B14mHMrAse/0= - dependencies: - mkdirp "0.3.0" - nopt "1.0.10" - -hogan@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/hogan/-/hogan-1.0.2.tgz#d8d5e57fae0e7787b3e01e14256f9d588a23d1f0" - integrity sha1-2NXlf64Od4ez4B4UJW+dWIoj0fA= - dependencies: - hogan.js "*" - home-or-tmp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" @@ -11061,11 +11046,6 @@ mkdirp2@^1.0.4: resolved "https://registry.yarnpkg.com/mkdirp2/-/mkdirp2-1.0.5.tgz#68bbe61defefafce4b48948608ec0bac942512c2" integrity sha512-xOE9xbICroUDmG1ye2h4bZ8WBie9EGmACaco8K8cx6RlkJJrxGIqjGqztAI+NMhexXBcdGbSEzI6N3EJPevxZw== -mkdirp@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" - integrity sha1-G79asbqCevI1dRQ0kEJkVfSB/h4= - mkdirp@0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" @@ -11407,13 +11387,6 @@ noms@0.0.0: inherits "^2.0.1" readable-stream "~1.0.31" -nopt@1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee" - integrity sha1-bd0hvSoxQXuScn3Vhfim83YI6+4= - dependencies: - abbrev "1" - nopt@^4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.3.tgz#a375cad9d02fd921278d954c2254d5aa57e15e48" From f1f2c604ca778c0f2a0e023f23be56ebdef4e211 Mon Sep 17 00:00:00 2001 From: Maximilian <787658+mfranzke@users.noreply.github.com> Date: Tue, 27 Dec 2022 22:19:18 +0100 Subject: [PATCH 3/4] chore: we don't need to pin that version --- packages/uikit-workshop/package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/uikit-workshop/package.json b/packages/uikit-workshop/package.json index 3347167d1..93f6a3368 100644 --- a/packages/uikit-workshop/package.json +++ b/packages/uikit-workshop/package.json @@ -63,7 +63,7 @@ "express": "^4.17.1", "fg-loadjs": "^1.1.0", "fuse.js": "^6.4.6", - "handlebars": "4.7.7", + "handlebars": "^4.7.7", "hard-source-webpack-plugin-patch": "^0.13.3", "hasha": "^5.2.2", "html-loader": "^0.5.5", diff --git a/yarn.lock b/yarn.lock index fb9eeef26..dc8ba1201 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7972,7 +7972,7 @@ hamljs@^0.6.2: resolved "https://registry.yarnpkg.com/hamljs/-/hamljs-0.6.2.tgz#7b7116cf6dbe7278e42b3f6ef8725a33e177c8e3" integrity sha1-e3EWz22+cnjkKz9u+HJaM+F3yOM= -handlebars@4.7.7, handlebars@^4.7.6, handlebars@^4.7.7: +handlebars@^4.7.6, handlebars@^4.7.7: version "4.7.7" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1" integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA== From 76d1db84add55cb8a806a1b2a4565b1a89a3f8c4 Mon Sep 17 00:00:00 2001 From: Maximilian <787658+mfranzke@users.noreply.github.com> Date: Tue, 27 Dec 2022 22:42:58 +0100 Subject: [PATCH 4/4] chore: let's revert those for the moment as they aren't as critical as the uikit-workshop package --- packages/engine-react/lib/engine_react.js | 4 ++-- packages/engine-react/package.json | 2 +- yarn.lock | 27 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/engine-react/lib/engine_react.js b/packages/engine-react/lib/engine_react.js index 411a3bc2c..3c33f1eca 100644 --- a/packages/engine-react/lib/engine_react.js +++ b/packages/engine-react/lib/engine_react.js @@ -14,7 +14,7 @@ const path = require('path'); const React = require('react'); const ReactDOMServer = require('react-dom/server'); const Babel = require('babel-core'); -const Handlebars = require('handlebars'); +const Hogan = require('hogan'); const beautify = require('js-beautify'); const cheerio = require('cheerio'); const _require = require; @@ -44,7 +44,7 @@ let patternLabConfig = {}; let enableRuntimeCode = true; -const outputTemplate = Handlebars.compile( +const outputTemplate = Hogan.compile( fs.readFileSync(path.join(__dirname, './outputTemplate.mustache'), 'utf8') ); diff --git a/packages/engine-react/package.json b/packages/engine-react/package.json index 2aa12b67b..a3ce0e3f0 100644 --- a/packages/engine-react/package.json +++ b/packages/engine-react/package.json @@ -9,7 +9,7 @@ "babel-plugin-transform-es2015-modules-commonjs": "6.16.0", "babel-preset-react": "6.16.0", "cheerio": "0.22.0", - "handlebars": "^4.7.7", + "hogan": "1.0.2", "js-beautify": "1.13.5", "react": "15.3.2", "react-dom": "15.3.2" diff --git a/yarn.lock b/yarn.lock index dc8ba1201..02f76ff35 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8181,6 +8181,21 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" +hogan.js@*: + version "3.0.2" + resolved "https://registry.yarnpkg.com/hogan.js/-/hogan.js-3.0.2.tgz#4cd9e1abd4294146e7679e41d7898732b02c7bfd" + integrity sha512-RqGs4wavGYJWE07t35JQccByczmNUXQT0E12ZYV1VKYu5UiAU9lsos/yBAcf840+zrUQQxgVduCR5/B8nNtibg== + dependencies: + mkdirp "0.3.0" + nopt "1.0.10" + +hogan@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/hogan/-/hogan-1.0.2.tgz#d8d5e57fae0e7787b3e01e14256f9d588a23d1f0" + integrity sha512-2RV7G4f+Rt9YIYDu01r6pgZvP+XhrXi/JKlXd4b+vRybXk94ui4PQjbh/lFaH8gQtxCygy/WKkqmpm0IyZysJA== + dependencies: + hogan.js "*" + home-or-tmp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" @@ -11046,6 +11061,11 @@ mkdirp2@^1.0.4: resolved "https://registry.yarnpkg.com/mkdirp2/-/mkdirp2-1.0.5.tgz#68bbe61defefafce4b48948608ec0bac942512c2" integrity sha512-xOE9xbICroUDmG1ye2h4bZ8WBie9EGmACaco8K8cx6RlkJJrxGIqjGqztAI+NMhexXBcdGbSEzI6N3EJPevxZw== +mkdirp@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" + integrity sha512-OHsdUcVAQ6pOtg5JYWpCBo9W/GySVuwvP9hueRMW7UqshC0tbfzLv8wjySTPm3tfUZ/21CE9E1pJagOA91Pxew== + mkdirp@0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" @@ -11387,6 +11407,13 @@ noms@0.0.0: inherits "^2.0.1" readable-stream "~1.0.31" +nopt@1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee" + integrity sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg== + dependencies: + abbrev "1" + nopt@^4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.3.tgz#a375cad9d02fd921278d954c2254d5aa57e15e48"