diff --git a/build.js b/build.js index eb53108224367..2e35f4e0f7edd 100644 --- a/build.js +++ b/build.js @@ -21,7 +21,6 @@ const Program = require('commander'); // Joomla Build modules const buildCheck = require('./build/build-modules-js/build-check'); -const installer = require('./build/build-modules-js/installation'); const copyAssets = require('./build/build-modules-js/update'); const compileCSS = require('./build/build-modules-js/compilescss'); const compileJS = require('./build/build-modules-js/compilejs'); @@ -45,8 +44,7 @@ Program .option('--compile-css, --compile-css path', 'Compiles all the scss files to css') .option('--compile-ce, --compile-ce path', 'Compiles/traspiles all the custom elements files') .option('--watch, --watch path', 'Watch file changes and re-compile (Only work for compile-css and compile-js now).') - .option('--installer', 'Creates the language file for installer error page') - .option('--buildcheck', 'Creates the language file for build check error page') + .option('--build-check', 'Creates the error pages for unsupported PHP version & incomplete environment') .on('--help', () => { // eslint-disable-next-line no-console console.log(`Version: ${options.version}`); @@ -78,14 +76,10 @@ if (Program.copyAssets) { }); } -// Create the languages file for the error page on the installer -if (Program.installer) { - installer.installation(); -} -// Create the languages file for the error page on incomplete repo build -if (Program.buildcheck) { - buildCheck.buildCheck(); +// Creates the error pages for unsupported PHP version & incomplete environment +if (Program.buildCheck) { + buildCheck.buildCheck(options); } // Convert scss to css diff --git a/build/build-modules-js/build-check.js b/build/build-modules-js/build-check.js index f5cdab7c91084..d34eb69d64eb7 100644 --- a/build/build-modules-js/build-check.js +++ b/build/build-modules-js/build-check.js @@ -1,3 +1,13 @@ +/** + * Will produce 2 .html files + * Expects three files: + * build/warning_page/template.css + * build/warning_page/template.html + * build/warning_page/template.js + * + * And also specific strings in the languages in the installation folder! + * Also the base strings are held in build/build-modules-js/settings.json + */ const fs = require('fs'); const ini = require('ini'); const Recurs = require('recursive-readdir'); @@ -6,16 +16,16 @@ const uglifyJs = require('uglify-es'); const rootPath = require('./rootpath.js')._(); const dir = `${rootPath}/installation/language`; -const installationFile = `${rootPath}/templates/system/build_incomplete.html`; -const srcPath = `${rootPath}/build/repo_build_incomplete`; +const srcPath = `${rootPath}/build/warning_page`; // Set the initial template -let template = 'window.errorLocale = {'; +let incomplete = 'window.errorLocale = {'; +let unsupported = 'window.errorLocale = {'; -const buildCheck = () => { - let checkContent = fs.readFileSync(`${srcPath}/incomplete.html`, 'utf-8'); - let cssContent = fs.readFileSync(`${srcPath}/incomplete.css`, 'utf-8'); - let jsContent = fs.readFileSync(`${srcPath}/incomplete.js`, 'utf-8'); +const buildCheck = (options) => { + let initTemplate = fs.readFileSync(`${srcPath}/template.html`, 'utf-8'); + let cssContent = fs.readFileSync(`${srcPath}/template.css`, 'utf-8'); + let jsContent = fs.readFileSync(`${srcPath}/template.js`, 'utf-8'); cssContent = uglifyCss.processString(cssContent, { expandVars: false }); jsContent = uglifyJs.minify(jsContent); @@ -24,40 +34,56 @@ const buildCheck = () => { (files) => { files.forEach((file) => { const languageStrings = ini.parse(fs.readFileSync(file, 'UTF-8')); + + // Build the variables into json for the unsupported page + if (languageStrings.MIN_PHP_ERROR_LANGUAGE) { + const name = file.replace('.ini', '').replace(/.+\//, ''); + unsupported += `"${name}":{"language":"${languageStrings.MIN_PHP_ERROR_LANGUAGE}","header":"${languageStrings.MIN_PHP_ERROR_HEADER}","text1":"${languageStrings.MIN_PHP_ERROR_TEXT}","help-url-text":"${languageStrings.MIN_PHP_ERROR_URL_TEXT}"},`; + } + + // Build the variables into json for the unsupported page if (languageStrings.BUILD_INCOMPLETE_LANGUAGE) { const name = file.replace('.ini', '').replace(/.+\//, ''); - template += ` -"${name}":{"language":"${languageStrings.BUILD_INCOMPLETE_LANGUAGE}","header":"${languageStrings.BUILD_INCOMPLETE_HEADER}","text1":"${languageStrings.BUILD_INCOMPLETE_TEXT}","help-url-text":"${languageStrings.BUILD_INCOMPLETE_URL_TEXT}"},`; + incomplete += `"${name}":{"language":"${languageStrings.BUILD_INCOMPLETE_LANGUAGE}","header":"${languageStrings.BUILD_INCOMPLETE_HEADER}","text1":"${languageStrings.BUILD_INCOMPLETE_TEXT}","help-url-text":"${languageStrings.BUILD_INCOMPLETE_URL_TEXT}"},`; } }); - template = `${template} -}`; + unsupported = `${unsupported}}`; + incomplete = `${incomplete}}`; - checkContent = checkContent.replace('{{jsonContents}}', template); + for (const name in options.settings.errorPages) { + checkContent = initTemplate; + checkContent = checkContent.replace('{{jsonContents}}', name === 'incomplete' ? incomplete : unsupported); + checkContent = checkContent.replace('{{PHP_VERSION}}', ''); + checkContent = checkContent.replace('{{Title}}', options.settings.errorPages[name].title); + checkContent = checkContent.replace('{{Header}}', options.settings.errorPages[name].header); + checkContent = checkContent.replace('{{Description}}', options.settings.errorPages[name].text); + checkContent = checkContent.replace('{{Link}}', options.settings.errorPages[name].link); + checkContent = checkContent.replace('{{LinkText}}', options.settings.errorPages[name].linkText); - if (cssContent) { - checkContent = checkContent.replace('{{cssContents}}', cssContent); - } + if (cssContent) { + checkContent = checkContent.replace('{{cssContents}}', cssContent); + } - if (jsContent) { - checkContent = checkContent.replace('{{jsContents}}', jsContent.code); - } + if (jsContent) { + checkContent = checkContent.replace('{{jsContents}}', jsContent.code); + } - fs.writeFile( - installationFile, - checkContent, - (err) => { - if (err) { - // eslint-disable-next-line no-console - console.log(err); - return; - } + fs.writeFile( + `${rootPath}${options.settings.errorPages[name].destFile}`, + checkContent, + (err) => { + if (err) { + // eslint-disable-next-line no-console + console.log(err); + return; + } - // eslint-disable-next-line no-console - console.log('The build check error page was saved!'); - }, - ); + // eslint-disable-next-line no-console + console.log(`The ${options.settings.errorPages[name].destFile} page was created successfully!`); + }, + ); + } }, (error) => { // eslint-disable-next-line no-console diff --git a/build/build-modules-js/installation.js b/build/build-modules-js/installation.js deleted file mode 100644 index e4ddd00e6753e..0000000000000 --- a/build/build-modules-js/installation.js +++ /dev/null @@ -1,69 +0,0 @@ -const fs = require('fs'); -const ini = require('ini'); -const Recurs = require('recursive-readdir'); -const uglifyCss = require('uglifycss'); -const uglifyJs = require('uglify-es'); -const rootPath = require('./rootpath.js')._(); - -const dir = `${rootPath}/installation/language`; -const installationFile = `${rootPath}/templates/system/incompatible.html`; -const srcPath = `${rootPath}/build/incompatible_page`; - -// Set the initial template -let template = 'window.errorLocale = {'; - -const installation = () => { - let installationContent = fs.readFileSync(`${srcPath}/incompatible.html`, 'utf-8'); - let cssContent = fs.readFileSync(`${srcPath}/incompatible.css`, 'utf-8'); - let jsContent = fs.readFileSync(`${srcPath}/incompatible.js`, 'utf-8'); - - cssContent = uglifyCss.processString(cssContent, { expandVars: false }); - jsContent = uglifyJs.minify(jsContent); - - Recurs(dir).then( - (files) => { - files.forEach((file) => { - const languageStrings = ini.parse(fs.readFileSync(file, 'UTF-8')); - if (languageStrings.MIN_PHP_ERROR_LANGUAGE) { - const name = file.replace('.ini', '').replace(/.+\//, ''); - template += ` -"${name}":{"language":"${languageStrings.MIN_PHP_ERROR_LANGUAGE}","header":"${languageStrings.MIN_PHP_ERROR_HEADER}","text1":"${languageStrings.MIN_PHP_ERROR_TEXT}","help-url-text":"${languageStrings.MIN_PHP_ERROR_URL_TEXT}"},`; - } - }); - - template = `${template} -}`; - - installationContent = installationContent.replace('{{jsonContents}}', template); - - if (cssContent) { - installationContent = installationContent.replace('{{cssContents}}', cssContent); - } - - if (jsContent) { - installationContent = installationContent.replace('{{jsContents}}', jsContent.code); - } - - fs.writeFile( - installationFile, - installationContent, - (err) => { - if (err) { - // eslint-disable-next-line no-console - console.log(err); - return; - } - - // eslint-disable-next-line no-console - console.log('The installation error page was saved!'); - }, - ); - }, - (error) => { - // eslint-disable-next-line no-console - console.error('something exploded', error); - }, - ); -}; - -module.exports.installation = installation; diff --git a/build/build-modules-js/settings.json b/build/build-modules-js/settings.json index a7653b56b170b..ad881b4396878 100644 --- a/build/build-modules-js/settings.json +++ b/build/build-modules-js/settings.json @@ -273,6 +273,26 @@ "dependencies": [], "licenseFilename": "LICENSE.md" } + }, + "errorPages": { + "incomplete": { + "phpVersionReplaceble": "", + "title": "Joomla: Environment Setup Incomplete", + "header": "Environment Setup Incomplete", + "text": "It looks like you are trying to run Joomla! from our git repository. To do so requires you complete a couple of extra steps first.", + "link": "J4.x:Setting_Up_Your_Local_Environment", + "linkText": "More Details", + "destFile": "/templates/system/build_incomplete.html" + }, + "unsupported": { + "phpVersionReplaceble": "data-php-version=\"{{PHP_VERSION}}\"", + "title": "Joomla: unsupported PHP version", + "header": "Sorry, your PHP version is not supported", + "text": "Your host needs to use PHP version {{PHP_VERSION}} or newer to run this version of Joomla!", + "link": "Unsupported_PHP_Version", + "linkText": "Help me resolve this", + "destFile": "/templates/system/incompatible.html" + } } } -} \ No newline at end of file +} diff --git a/build/repo_build_incomplete/incomplete.css b/build/repo_build_incomplete/incomplete.css deleted file mode 100644 index 72bd0203f174b..0000000000000 --- a/build/repo_build_incomplete/incomplete.css +++ /dev/null @@ -1,162 +0,0 @@ -body { - margin: 0; - padding: 0; - font: 14px / 18px sans-serif; - color: #555; - background-color: transparent -} - -html { - background: rgb(241,241,241); - background: -moz-radial-gradient(center, ellipse cover, rgba(241,241,241,1) 0%, rgba(58,146,200,1) 100%); - background: -webkit-radial-gradient(center, ellipse cover, rgba(241,241,241,1) 0%,rgba(58,146,200,1) 100%); - background: radial-gradient(ellipse at center, rgba(241,241,241,1) 0%,rgba(58,146,200,1) 100%); - background-repeat: no-repeat; - background-attachment: fixed; -} - -ol, ul { - padding: 0; - margin: 0; - list-style: none -} - -a { - color: #0084b4; - text-decoration: none; - outline: 0 -} - -a:hover, a:focus { - text-decoration: underline -} - -p a { - line-height: inherit -} - -.container { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - position: relative; - margin: 0 auto; - width: 100%; - height: 100vh; - overflow: hidden; -} - -.alert-main { - display: block; - position: relative; - background: #fff; - border: 1px solid rgba(0,0,0,0.1); - border-radius: 5px; - padding: 20px 60px; - margin: 0 20px; - box-shadow: 0 0 10px rgba(0,0,0,0.05); -} - -svg { - position: absolute; - bottom: -120px; - right: -70px; - width: 400px; - transform: rotate(10deg); - z-index: -1; -} - -h1, p { - position: relative; - z-index: 10; - text-align: center; - text-rendering: optimizeLegibility -} - -h1 { - margin: 18px 0 0; - font-size: 40px; - font-weight: 200; - line-height: 1; - text-shadow: 0 1px 2px rgba(0, 0, 0, .2) -} - -p, label { - margin: 10px 0 20px; - font-size: 18px; - font-weight: 300; - line-height: 25px; - color: #777 -} - -p a { - font-weight: bold; - color: #1C3D5C -} - -.link-help { - padding: .4rem .85rem; - font-size: 1rem; - font-weight: normal; - border-radius: .25rem; - text-decoration: none; - background-color: #f5f5f5; - border: 1px solid rgba(0,0,0,0.1); -} -.link-help:hover { - background-color: #eee; - text-decoration: none; -} - -.footer { - margin: 8px 20px; - text-align: left; - font-size: 11px -} - -.footer ul { - margin-bottom: 5px; -} - -.footer li { - display: inline; - margin: 0 5px; - line-height: 20px -} - -.footer li, .footer a { - color: #1C3D5C -} - -.footer a:hover { - color: #59B0FF -} - -.links { - display: block; - text-align: center; - margin-top: 4rem; - margin-left: auto; - margin-right: auto; - font-size: 1rem -} -.links li { - display: inline-block; - margin-top: 20px; -} - -@media screen and (max-width:480px) { - .container { - height: auto; - padding-top: 20px; - padding-bottom: 20px; - } - h1 { - font-size: 30px - } - - .link-help { - white-space: nowrap; - } -} diff --git a/build/repo_build_incomplete/incomplete.html b/build/repo_build_incomplete/incomplete.html deleted file mode 100644 index 01c70edd66658..0000000000000 --- a/build/repo_build_incomplete/incomplete.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - Joomla: Environment Setup Incomplete - - - - - - - -
-
-
-

Environment Setup Incomplete

-

It looks like you are trying to run Joomla! from our git repository. To do so requires you complete a couple of extra steps first.

-

More Details

- - - - - - - - -
- -
-
- - - diff --git a/build/repo_build_incomplete/incomplete.js b/build/repo_build_incomplete/incomplete.js deleted file mode 100644 index 2df1777730b4f..0000000000000 --- a/build/repo_build_incomplete/incomplete.js +++ /dev/null @@ -1,62 +0,0 @@ -var errorLocale = window.errorLocale || null; - -(function(document, errorLocale) { - 'use strict'; - - if (errorLocale) { - var header = document.getElementById('headerText'); - - // Create links for all the languages - Object.keys(errorLocale).forEach(function(key) { - var sel = document.getElementById('translatedLanguagesSelect'); - var opt = document.createElement('option'); - opt.text = errorLocale[key].language; - opt.value = key; - - if (key === 'en-GB') { - opt.setAttribute('selected', 'selected'); - } - - document.getElementById('translatedLanguagesSelect').addEventListener('change', function(e) { - var ref = e.target.value; - if (ref) { - header.innerHTML = errorLocale[ref].header; - } - - var helpLink = document.getElementById('linkHelp'); - if (helpLink) { - helpLink.innerText = errorLocale[ref]['help-url-text']; - } - - var meta = document.querySelector('[http-equiv="Content-Language"]'); - if (meta) { - meta.setAttribute('content', ref); - } - }); - - sel.appendChild(opt) - }); - - // Select language based on Browser's language - Object.keys(errorLocale).forEach(function(key) { - if (navigator.language === key) { - // Remove the selected property - document.querySelector('#translatedLanguagesSelect option[value="en-GB"]').removeAttribute('selected'); - document.querySelector('#translatedLanguagesSelect option[value="' + key + '"]').setAttribute('selected', 'selected'); - - // Append the translated strings - header.innerHTML = errorLocale[key].header; - - var helpLink = document.getElementById('linkHelp'); - if (helpLink) { - helpLink.innerText = errorLocale[key]['help-url-text']; - } - - var meta = document.querySelector('[http-equiv="Content-Language"]'); - if (meta) { - meta.setAttribute('content', key); - } - } - }); - } -})(document, errorLocale); diff --git a/build/incompatible_page/incompatible.css b/build/warning_page/template.css similarity index 100% rename from build/incompatible_page/incompatible.css rename to build/warning_page/template.css diff --git a/build/incompatible_page/incompatible.html b/build/warning_page/template.html similarity index 72% rename from build/incompatible_page/incompatible.html rename to build/warning_page/template.html index 7656fd30da08c..3d5d183f6061b 100644 --- a/build/incompatible_page/incompatible.html +++ b/build/warning_page/template.html @@ -1,23 +1,20 @@ - + - Joomla: unsupported PHP version - - - - + {{Title}} + + - - +
-

Sorry, your PHP version is not supported

-

Your host needs to use PHP version {{PHP_VERSION}} or newer to run this version of Joomla!

-

Help me resolve this

+

{{Header}}

+

{{Description}}

+

{{LinkText}}

@@ -37,6 +34,6 @@

Sorry, your PHP version is not supported

- + diff --git a/build/incompatible_page/incompatible.js b/build/warning_page/template.js similarity index 100% rename from build/incompatible_page/incompatible.js rename to build/warning_page/template.js diff --git a/package.json b/package.json index f139011d537f5..61ed0a00bf74e 100644 --- a/package.json +++ b/package.json @@ -12,15 +12,15 @@ "npm": ">=5.6.0" }, "scripts": { - "build:js": "node build.js --compilejs", - "build:css": "node build.js --compilecss", - "watch:js": "node build.js --compilejs --watch", - "watch:css": "node build.js --compilecss --watch", + "build:js": "node build.js --compile-js", + "build:css": "node build.js --compile-css", + "watch:js": "node build.js --compile-js --watch", + "watch:css": "node build.js --compile-css --watch", "lint:js": "node ./node_modules/eslint/bin/eslint.js . || exit 0", "test": "node node_modules/karma/bin/karma start karma.conf.js --single-run", - "install": "node build.js --copy-assets && node build.js --installer && node build.js --buildcheck", + "install": "node build.js --copy-assets && node build.js --build-check", "postinstall": "node build.js --compile-js && node build.js --compile-css && node build.js --compile-ce &&cd administrator/components/com_media && npm install && npm run build", - "update": "node build.js --copy-assets && node build.js --installer && node build.js --buildcheck && node build.js --compile-js && node build.js --compile-ce && node build.js --compile-css" + "update": "node build.js --copy-assets && node build.js --build-check && node build.js --compile-js && node build.js --compile-ce && node build.js --compile-css" }, "dependencies": { "@claviska/jquery-minicolors": "2.2.6", diff --git a/templates/system/build_incomplete.html b/templates/system/build_incomplete.html index b24c4223bd1c4..9f819b15d49e0 100644 --- a/templates/system/build_incomplete.html +++ b/templates/system/build_incomplete.html @@ -1,34 +1,29 @@ - + - Joomla: Environment Setup Incomplete - - - - + Joomla: Environment Setup Incomplete + + - - +
-

Environment Setup Incomplete

-

It looks like you are trying to run Joomla! from our git repository. To do so requires you complete a couple of extra steps first.

-

More Details

- - - - - - - - +

Environment Setup Incomplete

+

It looks like you are trying to run Joomla! from our git repository. To do so requires you complete a couple of extra steps first.

+

More Details

+ + + + + + + +
- + diff --git a/templates/system/incompatible.html b/templates/system/incompatible.html index b9e4181b0bcfe..6d2da7eaa98c2 100644 --- a/templates/system/incompatible.html +++ b/templates/system/incompatible.html @@ -1,26 +1,20 @@ - + - Joomla: unsupported PHP version - - - - + Joomla: unsupported PHP version + + - - +
-

Sorry, your PHP version is not supported

-

Your host needs to use PHP version {{PHP_VERSION}} or newer to run this version of Joomla!

-

Help me resolve this

+

Sorry, your PHP version is not supported

+

Your host needs to use PHP version {{PHP_VERSION}} or newer to run this version of Joomla!

+

Help me resolve this

@@ -40,6 +34,6 @@

Sorry, your PHP version is not supported

- +