/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ /* eslint-disable no-console */ const fs = require("fs"); const { mkdir } = require("shelljs"); const path = require("path"); // Note: DEFAULT_OPTIONS.baseUrl should match BASE_URL in aboutNewTabService.js // in mozilla-central. const DEFAULT_OPTIONS = { addonPath: "..", baseUrl: "resource://activity-stream/", }; /** * templateHTML - Generates HTML for activity stream, given some options and * prerendered HTML if necessary. * * @param {obj} options * {str} options.baseUrl The base URL for all local assets * {bool} options.debug Should we use dev versions of JS libraries? * {bool} options.noscripts Should we include scripts in the prerendered files? * @return {str} An HTML document as a string */ function templateHTML(options) { const debugString = options.debug ? "-dev" : ""; // This list must match any similar ones in AboutNewTabService.jsm. const scripts = [ "chrome://browser/content/contentSearchUI.js", "chrome://browser/content/contentSearchHandoffUI.js", "chrome://browser/content/contentTheme.js", `${options.baseUrl}vendor/react${debugString}.js`, `${options.baseUrl}vendor/react-dom${debugString}.js`, `${options.baseUrl}vendor/prop-types.js`, `${options.baseUrl}vendor/redux.js`, `${options.baseUrl}vendor/react-redux.js`, `${options.baseUrl}vendor/react-transition-group.js`, `${options.baseUrl}data/content/activity-stream.bundle.js`, `${options.baseUrl}data/content/newtab-render.js`, ]; // Add spacing and script tags const scriptRender = `\n${scripts .map(script => ` `) .join("\n")}`; // The markup below needs to be formatted by Prettier. But any diff after // running this script should be caught by try-runnner.js return `