<commit_before>var d3 = require('d3');
var inherits = require('inherits');

var margin = {
    top: 20,
    right: 20,
    bottom: 20,
    left: 45
};

var height = 500 - margin.top - margin.bottom;

var ForceDirectedNetworkViz = function(selector, data, images, opts) {

	var color = d3.scale.category10();

    var width = $(selector).width() - margin.left - margin.right;

    console.log(data.nodes)

    var zoom = d3.behavior.zoom()
        .scaleExtent([0.1, 20])
        .on("zoom", zoomed)

    var svg = d3.select(selector)
        .append('svg:svg')
        .attr('class', 'line-plot')
        .attr('width', width + margin.left + margin.right)
        .attr('height', height + margin.top + margin.bottom)
        .attr('pointer-events', 'all')
        .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')
        .call(zoom)
        .append('svg:g')

    function zoomed() {
        svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")");
    }

    var force = d3.layout.force()
        .size([width, height])
        .linkDistance(function (d) { return 100*Math.sqrt(d.value)})
        .charge(-100)
        .gravity(0)
        .nodes(data.nodes)
        .links(data.links)
        .start();

    var drag = force.drag()
      .on("dragstart", function(d) {
        d3.event.sourceEvent.stopPropagation();
      });

    var link = svg.selectAll(".link")
        .data(data.links)
    .enter().append("line")
        .attr("class", "link")
        .style("stroke-width", function(d) { return Math.sqrt(d.value); })
        .style("stroke", '#999')
        .style("stroke-opacity", 0.9);

    var node = svg.selectAll(".node")
        .data(data.nodes)
    .enter().append("circle")
        .attr("class", "node")
        .attr("r", 6)
        .style("fill", function(d) { return color(d.group); })
        .style("stroke", "white")
        .style("stroke-width", 1)
        .call(drag);

    force.on("tick", function() {
        link.attr("x1", function(d) { return d.source.x; })
            .attr("y1", function(d) { return d.source.y; })
            .attr("x2", function(d) { return d.target.x; })
            .attr("y2", function(d) { return d.target.y; });

        node.attr("cx", function(d) { return d.x; })
            .attr("cy", function(d) { return d.y; });
    });

};

module.exports = ForceDirectedNetworkViz;<commit_msg>Modify defaults<commit_after>var d3 = require('d3');
var inherits = require('inherits');

var margin = {
    top: 20,
    right: 20,
    bottom: 20,
    left: 45
};

var height = 500 - margin.top - margin.bottom;

var ForceDirectedNetworkViz = function(selector, data, images, opts) {

	var color = d3.scale.category10();

    var width = $(selector).width() - margin.left - margin.right;

    console.log(data.nodes)

    var zoom = d3.behavior.zoom()
        .scaleExtent([0.1, 20])
        .on("zoom", zoomed)

    var svg = d3.select(selector)
        .append('svg:svg')
        .attr('class', 'line-plot')
        .attr('width', width + margin.left + margin.right)
        .attr('height', height + margin.top + margin.bottom)
        .attr('pointer-events', 'all')
        .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')
        .call(zoom)
        .append('svg:g')

    function zoomed() {
        svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")");
    }

    var force = d3.layout.force()
        .size([width, height])
        .charge(-120)
        .linkDistance(30)
        .nodes(data.nodes)
        .links(data.links)
        .start();

    var drag = force.drag()
      .on("dragstart", function(d) {
        d3.event.sourceEvent.stopPropagation();
      });

    var link = svg.selectAll(".link")
        .data(data.links)
    .enter().append("line")
        .attr("class", "link")
        .style("stroke-width", function(d) { return Math.sqrt(d.value); })
        .style("stroke", '#999')
        .style("stroke-opacity", 0.9);

    var node = svg.selectAll(".node")
        .data(data.nodes)
    .enter().append("circle")
        .attr("class", "node")
        .attr("r", 6)
        .style("fill", function(d) { return color(d.group); })
        .style("stroke", "white")
        .style("stroke-width", 1)
        .call(drag);

    force.on("tick", function() {
        link.attr("x1", function(d) { return d.source.x; })
            .attr("y1", function(d) { return d.source.y; })
            .attr("x2", function(d) { return d.target.x; })
            .attr("y2", function(d) { return d.target.y; });

        node.attr("cx", function(d) { return d.x; })
            .attr("cy", function(d) { return d.y; });
    });

};

module.exports = ForceDirectedNetworkViz;<|endoftext|>


<commit_before>(function() {
	// Variables globales
	var ToDos = []; // Aqui tendremos un array de objectos. Cada objecto será una tarea.
	var storage = localStorage; // Tecnología que utilizaremos para guardar los datos.
	var prefix = "ToDo";

	// Capturamos los elementos que necesitamos
	var newTodoInput = document.getElementById("todoInput");
	var addTodoBtn = document.getElementById("addBtn");
	var todoList = document.getElementById("todoList");

	// Funciones
	var getToDos = function() {
		if (storage.length > 0) {
			for(var i = 0; i < storage.length; i++) {
				if (storage.key(i) === prefix) {
					ToDos = JSON.parse(storage.getItem(storage.key(i)));
				}
			}
			//success(); // Callback. Si hay tareas guardadas en local mostrarlas.
			showToDoList();
		}
	};
	var showToDoList = function() {
		if (ToDos.length > 0) {
			for (var i = 0; i < ToDos.length; i++) {
				addToDoToList(ToDos[i].text, ToDos[i].isDone);
			}
		}
	};
	var addTodo = function(e) {
		e.preventDefault();
		if (newTodoInput.value.trim() !== '') {
			addToDoToList(newTodoInput.value.trim(), false);
			saveTodo(newTodoInput.value.trim());
			newTodoInput.value = ""; // Limpiamos el input para nuevas tareas
		}
	};
	var addToDoToList = function(text, isDone) {
		// Creamos un checkbox, que servirá para marcar que la tarea esta completada.
		var newCheckbox = document.createElement("input");
		newCheckbox.type = "checkbox";
		newCheckbox.classList.add("delete");

		// Creamos un span para meter en él la descripción de la tarea.
		var newTodoText = document.createElement("span");
		newTodoText.innerText = text;

		// Creamos un botón para eliminar la tarea
		var newDeleteBtn = document.createElement("button");
		newDeleteBtn.classList.add("deleteBtn");
		newDeleteBtn.innerText = "-";

		// Comprobamos si la tarea esta hecha o no
		if (isDone) {
			newTodoText.classList.add("todoDone"); // Aparecerá tachada
			newCheckbox.checked = true; // El checkbox aparecera 'checked'
		}

		// Creamos un nuevo elemento (li) para la lista e insertamos en él los elementos de arriba.
		var newTodo = document.createElement("li");
		newTodo.appendChild(newCheckbox);
		newTodo.appendChild(newTodoText);
		newTodo.appendChild(newDeleteBtn);

		// Insertamos en el UL el nuevo elemento LI que hemos creado.
		todoList.appendChild(newTodo);
	};
	var saveTodo = function(text) {
		var ToDo = {
			text : text,
			isDone : false
		};
		ToDos.push(ToDo); // Update de array of ToDos
		updateLocalToDos(); // Actualizar el array guardado localmente
	};
	var updateLocalToDos = function() {
		storage.setItem(prefix, JSON.stringify(ToDos));
	};
	var deleteTodo = function(e) {
		if (e.target.type === "submit") {
			var li = e.target.parentNode;
			var span = e.target.parentNode.getElementsByTagName("span");
			var text = span[0].innerText;
			var posicion;
			for (var i = 0; i < ToDos.length; i++) {
				if (ToDos[i].text === text) {
					posicion = i;
					i = ToDos.length;
				}
			}
			if (posicion >= 0) {
				todoList.removeChild(li); // Eliminar el li
				ToDos.splice(posicion, 1); // Eliminar el objeto del array
				updateLocalToDos(); // Actualizar el array guardado localmente
			}
		}
	};
	var toggleDoneUndone = function(e) {
		if (e.target.type === "checkbox") {
			var span = e.target.parentNode.getElementsByTagName("span");
			var text = span[0].innerText;
			var posicion;
			if (e.target.checked) {
				span[0].classList.add("todoDone");
				findToDoPosition(text, updateToDoStatus({"status": 1}));

				for (var i = 0; i < ToDos.length; i++) {
					if (ToDos[i].text === text) {
						posicion = i;
						i = ToDos.length;
					}
				}
				if (posicion >= 0) {
					ToDos[posicion].isDone = true;
					updateLocalToDos();
				}
			} else {
				span[0].classList.remove("todoDone");
				for (var i = 0; i < ToDos.length; i++) {
					if (ToDos[i].text === text) {
						posicion = i;
						i = ToDos.length;
					}
				}
				if (posicion >= 0) {
					ToDos[posicion].isDone = false;
					updateLocalToDos();
				}
			}
		}
	};
	var findToDoPosition = function(text, success) {
		var position;
		for (var i = 0; i < ToDos.length; i++) {
			if (ToDos[i].text === text) {
				position = i;
				i = ToDos.length;
			}
		}
		if (position >= 0) {
			success({"position": position});
		}
	};
	var updateToDoStatus = function(data) {
		console.log("El elemento esta en " + data.position + " y su estado es " + data.status);
	};

	// Listeners
	window.addEventListener("load", getToDos, false);
	addTodoBtn.addEventListener("click", addTodo, false);
	todoList.addEventListener("click", deleteTodo, false);
	todoList.addEventListener("click", toggleDoneUndone, false);

	// Dataset
	// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
})();<commit_msg>Correcciones<commit_after>(function() {
	// Variables globales
	var ToDos = []; // Aqui tendremos un array de objectos. Cada objecto será una tarea.
	var storage = localStorage; // Tecnología que utilizaremos para guardar los datos.
	var prefix = "ToDo";
	var lastID; // Last ID number used in a ToDo. It'll identify any ToDO.

	// Capturamos los elementos que necesitamos
	var newTodoInput = document.getElementById("todoInput");
	var addTodoBtn = document.getElementById("addBtn");
	var todoList = document.getElementById("todoList");

	// Funciones
	var getToDos = function() {
		if (storage.length > 0) {
			for(var i = 0; i < storage.length; i++) {
				if (storage.key(i) === prefix) {
					ToDos = JSON.parse(storage.getItem(storage.key(i)));
					lastID = ToDos[ToDos.length-1].id;
					lastID = lastID + 1;
				} else {
					lastID = 0;
				}
			}
			showToDoList();
		} else {
			lastID = 0;
		}
	};
	var showToDoList = function() {
		if (ToDos.length > 0) {
			for (var i = 0; i < ToDos.length; i++) {
				addToDoToList(ToDos[i].id, ToDos[i].text, ToDos[i].isDone);
			}
		}
	};
	var addTodo = function(e) {
		e.preventDefault();
		if (newTodoInput.value.trim() !== '') {
			addToDoToList(lastID, newTodoInput.value.trim(), false);
			saveTodo(newTodoInput.value.trim());
			newTodoInput.value = ""; // Limpiamos el input para nuevas tareas
		}
	};
	var addToDoToList = function(id, text, isDone) {
		// Creamos un checkbox, que servirá para marcar que la tarea esta completada.
		var newCheckbox = document.createElement("input");
		newCheckbox.type = "checkbox";
		newCheckbox.classList.add("delete");

		// Creamos un span para meter en él la descripción de la tarea.
		var newTodoText = document.createElement("span");
		newTodoText.innerText = text;

		// Creamos un botón para eliminar la tarea
		var newDeleteBtn = document.createElement("button");
		newDeleteBtn.classList.add("deleteBtn");
		newDeleteBtn.innerText = "-";

		// Comprobamos si la tarea esta hecha o no
		if (isDone) {
			newTodoText.classList.add("todoDone"); // Aparecerá tachada
			newCheckbox.checked = true; // El checkbox aparecera 'checked'
		}

		// Creamos un nuevo elemento (li) para la lista e insertamos en él los elementos de arriba.
		var newTodo = document.createElement("li");
		newTodo.setAttribute('data-id', id);
		newTodo.appendChild(newCheckbox);
		newTodo.appendChild(newTodoText);
		newTodo.appendChild(newDeleteBtn);

		// Insertamos en el UL el nuevo elemento LI que hemos creado.
		todoList.appendChild(newTodo);
	};
	var saveTodo = function(text) {
		var ToDo = {
			id: lastID,
			text : text,
			isDone : false
		};
		ToDos.push(ToDo); // Update de array of ToDos
		updateLocalToDos(); // Actualizar el array guardado localmente
		lastID = lastID + 1;
	};
	var updateLocalToDos = function() {
		storage.setItem(prefix, JSON.stringify(ToDos));
	};
	var deleteTodo = function(e) {
		if (e.target.type === "submit") {
			var li = e.target.parentNode;
			var todoId = li.getAttribute('data-id');
			getToDoPosition(todoId, function(position) {
				todoList.removeChild(li); // Eliminar el li
				ToDos.splice(position, 1); // Eliminar el objeto del array
				updateLocalToDos(); // Actualizar el array guardado localmente
			});
		}
	};
	var toggleDoneUndone = function(e) {
		if (e.target.type === "checkbox") {
			var li = e.target.parentNode;
			var todoId = li.getAttribute('data-id');
			var span = e.target.parentNode.getElementsByTagName("span");

			if (e.target.checked) {
				getToDoPosition(todoId, function(position) {
					span[0].classList.add("todoDone");
					ToDos[position].isDone = true;
					updateLocalToDos();
				});
			} else {
				getToDoPosition(todoId, function(position) {
					span[0].classList.remove("todoDone");
					ToDos[position].isDone = false;
					updateLocalToDos();
				});
			}
		}
	};
	var getToDoPosition = function(id, success) {
		var position;
		for (var i = 0; i < ToDos.length; i++) {
			if (parseInt(ToDos[i].id) === parseInt(id)) {
				position = i;
				i = ToDos.length;
			}
		}
		if (position >= 0) {
			success(position);
		}
	};
	var updateToDoStatus = function(data) {
		console.log("El elemento esta en " + data.position + " y su estado es " + data.status);
	};

	// Listeners
	window.addEventListener("load", getToDos, false);
	addTodoBtn.addEventListener("click", addTodo, false);
	todoList.addEventListener("click", deleteTodo, false);
	todoList.addEventListener("click", toggleDoneUndone, false);

	// Dataset
	// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
})();<|endoftext|>


<commit_before>/*
 * Copyright 2014-2018 Simon Edwards <simon@simonzone.com>
 *
 * This source code is licensed under the MIT license which is detailed in the LICENSE.txt file.
 */
require('shelljs/global');
const fs = require('fs');
const path = require('path');
const packager = require('electron-packager');
const getRepoInfo = require('git-repo-info');

const log = console.log.bind(console);
const BUILD_TMP = 'build_tmp';
const MODULE_VERSON = 53; // This version number also appears in thememanager.ts

function main() {
  "use strict";

  if ( ! test('-f', './package.json')) {
    echo("This script was called from the wrong directory.");
    return;
  }

  const srcRootDir = "" + pwd();
  if (test('-d', BUILD_TMP)) {
    rm('-rf', BUILD_TMP);
  }
  mkdir(BUILD_TMP);

  const packageJson = fs.readFileSync('package.json');
  const packageData = JSON.parse(packageJson);

  const gitUrl = packageData.repository.url.replace("git://github.com/", "git@github.com:");

  const info = getRepoInfo();

  echo("Fetching a clean copy of the source code from " + gitUrl);
  cd(BUILD_TMP);

  // For some reason pwd() is returning "not quite strings" which path.join() doesn't like. Thus "" + ...
  const buildTmpPath = "" + pwd();

  exec("git clone --depth 1 -b " + info.branch + " " + gitUrl);
  cd("extraterm");

  echo("Setting up the run time dependencies in " + BUILD_TMP);

  exec("yarn install");
  exec("yarn run electron-rebuild");
  exec("yarn run build");

  echo("Removing development dependencies");
  exec("yarn install --production=true");

  // Create the commands zip
  echo("Creating commands.zip");
  const commandsDir = packageData.name + "-commands-" + packageData.version;
  cp("-r", "extraterm/src/commands", path.join(buildTmpPath, commandsDir));
  const codeDir = pwd();
  cd(buildTmpPath);
  exec(`zip -y -r ${commandsDir}.zip ${commandsDir}`);
  cd(codeDir);

  const electronVersion = packageData.devDependencies['electron'];

  const ignoreRegExp = [
    /^\/build_scripts\b/,
    /^\/extraterm-web-component-decorators\b/,
    /^\/extraterm-extension-api\b/,
    /^\/test\b/,
    /^\/build_tmp\b/,
    /^\/src\/typedocs\b/,
    /\.ts$/,
    /\.js\.map$/,
    /^\/\.git\//,
    /^\/docs\b/,
    /^\/resources\/extra_icons\b/,
    /^\/src\/test\b/,
    /^\/src\/testfiles\b/
  ];

  const ignoreFunc = function ignoreFunc(filePath) {
    const result = ignoreRegExp.some( (exp) => exp.test(filePath));
    return result;
  };

  function appDir(platform) {
    return platform === "darwin" ? "extraterm.app/Contents/Resources/app" : "resources/app";
  }

  function pruneNodeSass(versionedOutputDir, arch, platform) {
    const gutsDir = appDir(platform);
    const nodeSassVendorDir = path.join(versionedOutputDir, gutsDir, "node_modules/node-sass/vendor");

    rm('-rf', nodeSassVendorDir);

    const nodeSassBinaryDir = path.join(versionedOutputDir, gutsDir, "src/node-sass-binary");
    ["darwin-x64", "linux-ia32", "linux-x64", "win32-x64"].forEach( (name) => {
      if (name !== platform + "-" + arch) {
        rm('-rf', path.join(nodeSassBinaryDir, name + "-" + MODULE_VERSON));
      }
    });
  }

  function pruneEmojiOne(versionedOutputDir, platform) {
    if (platform !== "linux") {
      const emojiOnePath = path.join(versionedOutputDir, appDir(platform), "extraterm/resources/themes/default/emojione-android.ttf");
      rm(emojiOnePath);
    }
  }

  function hoistSubprojectsModules(versionedOutputDir, platform) {
    const modulesDir = path.join(versionedOutputDir, appDir(platform), "node_modules");

    // Delete the symlinks.
    for (const item of ls(modulesDir)) {
      const itemPath = path.join(modulesDir, item);
      if (test('-L', itemPath)) {
        echo(`Deleting symlink ${item} in ${modulesDir}`);
        rm(itemPath);
      }
    }

    // Move the 'packages' subprojects up into this node_modules dir.
    const packagesDir = path.join(versionedOutputDir, appDir(platform), "packages");
    for (const item of ls(packagesDir)) {
      const destDir = path.join(modulesDir, item);
      echo(`Moving ${item} in to ${destDir}`);
      mv(path.join(packagesDir, item), destDir);
    }
  }

  function pruneNodeModules(versionedOutputDir, platform) {
    const prevDir = pwd();

    cd(path.join(versionedOutputDir, appDir(platform)));
    exec("modclean -n default:safe -r");
    pruneSpecificNodeModules();

    cd(prevDir);
  }

  function pruneSpecificNodeModules() {
    [
      "codemirror/src",
      "node-sass/src",
      "node-sass/node_modules/nan",
      "node-sass/vendor",
      "node-gyp",
      "ajv",
      "globule",
      "vue/src",
      "vue/dist/vue.esm.browser.js",
      "vue/dist/vue.esm.js",
      "vue/dist/vue.js",
      "vue/dist/vue.min.js",
      "vue/dist/vue.runtime.esm.js",
      "vue/dist/vue.runtime.js",
      "vue/dist/vue.runtime.min.js",
      "font-manager/src",
      ".bin"
    ].forEach( (subpath) => {
      const fullPath = path.join("node_modules", subpath);

      echo("Deleting " + fullPath);

      if (test('-d', fullPath)) {
        rm('-rf', fullPath);
      } else if (test('-f', fullPath)) {
          rm(fullPath);
      } else {
        echo("----------- Unable to find path "+ fullPath);
      }
    });

  }

  function makePackage(arch, platform) {
    log("");
    return new Promise(function(resolve, reject) {

      // Clean up the output dirs and files first.
      const versionedOutputDir = packageData.name + "-" + packageData.version + "-" + platform + "-" + arch;
      if (test('-d', versionedOutputDir)) {
        rm('-rf', versionedOutputDir);
      }

      const outputZip = path.join(buildTmpPath, versionedOutputDir + ".zip");

      const packagerOptions = {
        arch: arch,
        dir: ".",
        platform: platform,
        version: electronVersion,
        ignore: ignoreFunc,
        name: platform === "darwin" ? "Extraterm" : "extraterm",
        overwrite: true,
        out: buildTmpPath,
        packageManager: "yarn",
        afterPrune: [
          (buildPath, electronVersion, platform, arch, callback) => {
            replaceDirs(path.join(buildPath, "node_modules"), path.join("" + codeDir,`build_scripts/node_modules-${platform}-${arch}`));
            callback();
          }
        ]
      };
      if (platform === "win32") {
        packagerOptions.icon = "extraterm/resources/logo/extraterm_small_logo.ico";
        packagerOptions.win32metadata = {
          FileDescription: "Extraterm",
          ProductName: "Extraterm",
          LegalCopyright: "(C) 2018 Simon Edwards"
        };
      } else if (platform === "darwin") {
        packagerOptions.icon = "extraterm/resources/logo/extraterm_small_logo.icns";
      }

      packager(packagerOptions, function done(err, appPath) {
        if (err !== null) {
          log(err);
          reject();
        } else {
          // Rename the output dir to a one with a version number in it.
          mv(appPath[0], path.join(buildTmpPath, versionedOutputDir));

          const thisCD = pwd();
          cd(buildTmpPath);

          hoistSubprojectsModules(versionedOutputDir, platform);
          pruneNodeModules(versionedOutputDir, platform);

          // Prune any unneeded node-sass binaries.
          pruneNodeSass(versionedOutputDir, arch, platform);

          pruneEmojiOne(versionedOutputDir, platform);

          // Zip it up.
          log("Zipping up the package");

          mv(path.join(versionedOutputDir, "LICENSE"), path.join(versionedOutputDir, "LICENSE_electron.txt"));
          cp("extraterm/README.md", versionedOutputDir);
          cp("extraterm/LICENSE.txt", versionedOutputDir);

          exec(`zip -y -r ${outputZip} ${versionedOutputDir}`);
          cd(thisCD);

          log("App bundle written to " + versionedOutputDir);
          resolve();
        }
      });
    });
  }

  function replaceDirs(targetDir, replacementsDir) {
    const prevDir = pwd();
    cd(srcRootDir);
    const replacements = ls(replacementsDir);
    replacements.forEach( (rDir) => {
      const targetSubDir = path.join(targetDir, rDir);
      if (test('-d', targetSubDir)) {
        rm('-r', targetSubDir);
      }
      cp('-r', path.join(replacementsDir, rDir), targetSubDir);
    });
    cd(prevDir);
  }

  function makeDmg() {
    echo("");
    echo("---------------------------------------------------");
    echo("Building dmg file for macOS");
    echo("---------------------------------------------------");

    const darwinPath = path.join(buildTmpPath, `extraterm-${packageData.version}-darwin-x64`);
    for (const f of ls(darwinPath)) {
      if ( ! f.endsWith(".app")) {
        echo(`Deleting ${f}`);
        rm(path.join(darwinPath, f));
      }
    }

    cp(path.join(srcRootDir, "build_scripts/resources/macos/.DS_Store"), path.join(darwinPath, ".DS_Store"));
    cp(path.join(srcRootDir, "build_scripts/resources/macos/.VolumeIcon.icns"), path.join(darwinPath, ".VolumeIcon.icns"));
    mkdir(path.join(darwinPath,".background"));
    cp(path.join(srcRootDir, "build_scripts/resources/macos/.background/extraterm_background.png"), path.join(darwinPath, ".background/extraterm_background.png"));

    mv(path.join(darwinPath, "extraterm.app"), path.join(darwinPath, "Extraterm.app"));

    ln("-s", "/Applications", path.join(darwinPath, "Applications"));

    exec(`docker run --rm -v "${buildTmpPath}:/files" sporsh/create-dmg Extraterm /files/extraterm-${packageData.version}-darwin-x64/ /files/extraterm_${packageData.version}.dmg`);
  }

  function makeNsis() {
    echo("");
    echo("---------------------------------------------------");
    echo("Building NSIS based installer for Windows");
    echo("---------------------------------------------------");

    const windowsBuildDirName = `extraterm-${packageData.version}-win32-x64`;
    const windowsPath = path.join(buildTmpPath, windowsBuildDirName);

    const versionSplit = packageData.version.split(".");
    const majorVersion = versionSplit[0];
    const minorVersion = versionSplit[1];
    const patchVersion = versionSplit[2];

    const installerScript = `
!include "MUI2.nsh"
!include "FileFunc.nsh"

!define APPNAME "Extraterm"
!define DESCRIPTION "Terminal emulator"
!define COMPANYNAME "extraterm.org"
!define VERSIONMAJOR ${majorVersion}
!define VERSIONMINOR ${minorVersion}
!define VERSIONBUILD ${patchVersion}

!define MUI_ABORTWARNING # This will warn the user if they exit from the installer.
!define MUI_INSTFILESPAGE_COLORS "3db54a 000000"
!define MUI_ICON "${windowsBuildDirName}\\resources\\app\\extraterm\\resources\\logo\\extraterm_small_logo.ico"

!insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.
!insertmacro MUI_PAGE_DIRECTORY # In which folder install page.
!insertmacro MUI_PAGE_INSTFILES # Installing page.
!insertmacro MUI_PAGE_FINISH # Finished installation page.

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Name "Extraterm"
BrandingText " "
OutFile "extraterm-setup-${packageData.version}.exe"
InstallDir "$PROGRAMFILES64\\Extraterm"
InstallDirRegKey HKLM "Software\\Extraterm" "InstallLocation"

ShowInstDetails show # This will always show the installation details.

Section "Extraterm"
  SetOutPath $INSTDIR
  File /r "${windowsBuildDirName}\\*"

  WriteUninstaller "$INSTDIR\\Uninstall.exe"

  createShortCut "$SMPROGRAMS\\Extraterm.lnk" "$INSTDIR\\extraterm.exe" "" "$INSTDIR\\resources\\app\\extraterm\\resources\\logo\\extraterm_small_logo.ico"

  WriteRegStr HKLM "Software\\Extraterm" "InstallLocation" "$\\"$INSTDIR$\\""
  WriteRegStr HKLM "Software\\Extraterm" "Version" "${packageData.version}"

  # Registry information for add/remove programs
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "DisplayName" "\${APPNAME} - \${DESCRIPTION}"
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "UninstallString" "$\\"$INSTDIR\\uninstall.exe$\\""
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "QuietUninstallString" "$\\"$INSTDIR\\uninstall.exe$\\" /S"
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "InstallLocation" "$\\"$INSTDIR$\\""
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "DisplayIcon" "$\\"$INSTDIR\\resources\\app\\extraterm\\resources\\logo\\extraterm_small_logo.ico$\\""
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "Publisher" "\${COMPANYNAME}"

	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "DisplayVersion" "\${VERSIONMAJOR}.\${VERSIONMINOR}.\${VERSIONBUILD}"
	WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "VersionMajor" \${VERSIONMAJOR}
	WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "VersionMinor" \${VERSIONMINOR}
	# There is no option for modifying or repairing the install
	WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "NoModify" 1
	WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "NoRepair" 1
	# Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size

  # Record the installation size
  \${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
  IntFmt $0 "0x%08X" $0
  WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "EstimatedSize" "\$0"

SectionEnd

Section "Uninstall"
  # Remove Start Menu launcher
	Delete "$SMPROGRAMS\\Extraterm.lnk"

  Delete "$INSTDIR\\*.*"
  Delete "$INSTDIR\\Uninstall.exe"
  RMDir /r "$INSTDIR"

  DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}"
  DeleteRegKey HKLM "Software\\Extraterm"
SectionEnd
`;
    fs.writeFileSync(path.join(buildTmpPath, "installer.nsi"), installerScript, {encoding: "utf-8"});

    exec(`docker run -t -v ${buildTmpPath}:/wine/drive_c/src/ cdrx/nsis`);
  }

  makePackage("x64", "win32")
    .then(() => makePackage("x64", "linux"))
    .then(() => makePackage("x64", "darwin"))
    .then(makeDmg)
    .then(makeNsis)
    .then(() => { log("Done"); } );
}

main();
<commit_msg>Remove unneeded files from the macOS build.<commit_after>/*
 * Copyright 2014-2018 Simon Edwards <simon@simonzone.com>
 *
 * This source code is licensed under the MIT license which is detailed in the LICENSE.txt file.
 */
require('shelljs/global');
const fs = require('fs');
const path = require('path');
const packager = require('electron-packager');
const getRepoInfo = require('git-repo-info');

const log = console.log.bind(console);
const BUILD_TMP = 'build_tmp';
const MODULE_VERSON = 53; // This version number also appears in thememanager.ts

function main() {
  "use strict";

  if ( ! test('-f', './package.json')) {
    echo("This script was called from the wrong directory.");
    return;
  }

  const srcRootDir = "" + pwd();
  if (test('-d', BUILD_TMP)) {
    rm('-rf', BUILD_TMP);
  }
  mkdir(BUILD_TMP);

  const packageJson = fs.readFileSync('package.json');
  const packageData = JSON.parse(packageJson);

  const gitUrl = packageData.repository.url.replace("git://github.com/", "git@github.com:");

  const info = getRepoInfo();

  echo("Fetching a clean copy of the source code from " + gitUrl);
  cd(BUILD_TMP);

  // For some reason pwd() is returning "not quite strings" which path.join() doesn't like. Thus "" + ...
  const buildTmpPath = "" + pwd();

  exec("git clone --depth 1 -b " + info.branch + " " + gitUrl);
  cd("extraterm");

  echo("Setting up the run time dependencies in " + BUILD_TMP);

  exec("yarn install");
  exec("yarn run electron-rebuild");
  exec("yarn run build");

  echo("Removing development dependencies");
  exec("yarn install --production=true");

  // Create the commands zip
  echo("Creating commands.zip");
  const commandsDir = packageData.name + "-commands-" + packageData.version;
  cp("-r", "extraterm/src/commands", path.join(buildTmpPath, commandsDir));
  const codeDir = pwd();
  cd(buildTmpPath);
  exec(`zip -y -r ${commandsDir}.zip ${commandsDir}`);
  cd(codeDir);

  const electronVersion = packageData.devDependencies['electron'];

  const ignoreRegExp = [
    /^\/build_scripts\b/,
    /^\/extraterm-web-component-decorators\b/,
    /^\/extraterm-extension-api\b/,
    /^\/test\b/,
    /^\/build_tmp\b/,
    /^\/src\/typedocs\b/,
    /\.ts$/,
    /\.js\.map$/,
    /^\/\.git\//,
    /^\/docs\b/,
    /^\/resources\/extra_icons\b/,
    /^\/src\/test\b/,
    /^\/src\/testfiles\b/
  ];

  const ignoreFunc = function ignoreFunc(filePath) {
    const result = ignoreRegExp.some( (exp) => exp.test(filePath));
    return result;
  };

  function appDir(platform) {
    return platform === "darwin" ? "Extraterm.app/Contents/Resources/app" : "resources/app";
  }

  function pruneNodeSass(versionedOutputDir, arch, platform) {
    const gutsDir = appDir(platform);
    const nodeSassVendorDir = path.join(versionedOutputDir, gutsDir, "node_modules/node-sass/vendor");

    rm('-rf', nodeSassVendorDir);

    const nodeSassBinaryDir = path.join(versionedOutputDir, gutsDir, "src/node-sass-binary");
    ["darwin-x64", "linux-ia32", "linux-x64", "win32-x64"].forEach( (name) => {
      if (name !== platform + "-" + arch) {
        rm('-rf', path.join(nodeSassBinaryDir, name + "-" + MODULE_VERSON));
      }
    });
  }

  function pruneEmojiOne(versionedOutputDir, platform) {
    if (platform !== "linux") {
      const emojiOnePath = path.join(versionedOutputDir, appDir(platform), "extraterm/resources/themes/default/emojione-android.ttf");
      rm(emojiOnePath);
    }
  }

  function hoistSubprojectsModules(versionedOutputDir, platform) {
    const modulesDir = path.join(versionedOutputDir, appDir(platform), "node_modules");

    // Delete the symlinks.
    for (const item of ls(modulesDir)) {
      const itemPath = path.join(modulesDir, item);
      if (test('-L', itemPath)) {
        echo(`Deleting symlink ${item} in ${modulesDir}`);
        rm(itemPath);
      }
    }

    // Move the 'packages' subprojects up into this node_modules dir.
    const packagesDir = path.join(versionedOutputDir, appDir(platform), "packages");
    for (const item of ls(packagesDir)) {
      const destDir = path.join(modulesDir, item);
      echo(`Moving ${item} in to ${destDir}`);
      mv(path.join(packagesDir, item), destDir);
    }
  }

  function pruneNodeModules(versionedOutputDir, platform) {
    const prevDir = pwd();

    cd(path.join(versionedOutputDir, appDir(platform)));
    exec("modclean -n default:safe -r");
    pruneSpecificNodeModules();

    cd(prevDir);
  }

  function pruneSpecificNodeModules() {
    [
      "codemirror/src",
      "node-sass/src",
      "node-sass/node_modules/nan",
      "node-sass/vendor",
      "node-gyp",
      "ajv",
      "globule",
      "vue/src",
      "vue/dist/vue.esm.browser.js",
      "vue/dist/vue.esm.js",
      "vue/dist/vue.js",
      "vue/dist/vue.min.js",
      "vue/dist/vue.runtime.esm.js",
      "vue/dist/vue.runtime.js",
      "vue/dist/vue.runtime.min.js",
      "font-manager/src",
      ".bin"
    ].forEach( (subpath) => {
      const fullPath = path.join("node_modules", subpath);

      echo("Deleting " + fullPath);

      if (test('-d', fullPath)) {
        rm('-rf', fullPath);
      } else if (test('-f', fullPath)) {
          rm(fullPath);
      } else {
        echo("----------- Unable to find path "+ fullPath);
      }
    });

  }

  function makePackage(arch, platform) {
    log("");
    return new Promise(function(resolve, reject) {

      // Clean up the output dirs and files first.
      const versionedOutputDir = packageData.name + "-" + packageData.version + "-" + platform + "-" + arch;
      if (test('-d', versionedOutputDir)) {
        rm('-rf', versionedOutputDir);
      }

      const outputZip = path.join(buildTmpPath, versionedOutputDir + ".zip");

      const packagerOptions = {
        arch: arch,
        dir: ".",
        platform: platform,
        version: electronVersion,
        ignore: ignoreFunc,
        name: platform === "darwin" ? "Extraterm" : "extraterm",
        overwrite: true,
        out: buildTmpPath,
        packageManager: "yarn",
        afterPrune: [
          (buildPath, electronVersion, platform, arch, callback) => {
            replaceDirs(path.join(buildPath, "node_modules"), path.join("" + codeDir,`build_scripts/node_modules-${platform}-${arch}`));
            callback();
          }
        ]
      };
      if (platform === "win32") {
        packagerOptions.icon = "extraterm/resources/logo/extraterm_small_logo.ico";
        packagerOptions.win32metadata = {
          FileDescription: "Extraterm",
          ProductName: "Extraterm",
          LegalCopyright: "(C) 2018 Simon Edwards"
        };
      } else if (platform === "darwin") {
        packagerOptions.icon = "extraterm/resources/logo/extraterm_small_logo.icns";
      }

      packager(packagerOptions, function done(err, appPath) {
        if (err !== null) {
          log(err);
          reject();
        } else {
          // Rename the output dir to a one with a version number in it.
          mv(appPath[0], path.join(buildTmpPath, versionedOutputDir));

          const thisCD = pwd();
          cd(buildTmpPath);

          hoistSubprojectsModules(versionedOutputDir, platform);
          pruneNodeModules(versionedOutputDir, platform);

          // Prune any unneeded node-sass binaries.
          pruneNodeSass(versionedOutputDir, arch, platform);

          pruneEmojiOne(versionedOutputDir, platform);

          // Zip it up.
          log("Zipping up the package");

          mv(path.join(versionedOutputDir, "LICENSE"), path.join(versionedOutputDir, "LICENSE_electron.txt"));
          cp("extraterm/README.md", versionedOutputDir);
          cp("extraterm/LICENSE.txt", versionedOutputDir);

          exec(`zip -y -r ${outputZip} ${versionedOutputDir}`);
          cd(thisCD);

          log("App bundle written to " + versionedOutputDir);
          resolve();
        }
      });
    });
  }

  function replaceDirs(targetDir, replacementsDir) {
    const prevDir = pwd();
    cd(srcRootDir);
    const replacements = ls(replacementsDir);
    replacements.forEach( (rDir) => {
      const targetSubDir = path.join(targetDir, rDir);
      if (test('-d', targetSubDir)) {
        rm('-r', targetSubDir);
      }
      cp('-r', path.join(replacementsDir, rDir), targetSubDir);
    });
    cd(prevDir);
  }

  function makeDmg() {
    echo("");
    echo("---------------------------------------------------");
    echo("Building dmg file for macOS");
    echo("---------------------------------------------------");

    const darwinPath = path.join(buildTmpPath, `extraterm-${packageData.version}-darwin-x64`);
    for (const f of ls(darwinPath)) {
      if ( ! f.endsWith(".app")) {
        echo(`Deleting ${f}`);
        rm(path.join(darwinPath, f));
      }
    }

    cp(path.join(srcRootDir, "build_scripts/resources/macos/.DS_Store"), path.join(darwinPath, ".DS_Store"));
    cp(path.join(srcRootDir, "build_scripts/resources/macos/.VolumeIcon.icns"), path.join(darwinPath, ".VolumeIcon.icns"));
    mkdir(path.join(darwinPath,".background"));
    cp(path.join(srcRootDir, "build_scripts/resources/macos/.background/extraterm_background.png"), path.join(darwinPath, ".background/extraterm_background.png"));

    ln("-s", "/Applications", path.join(darwinPath, "Applications"));

    exec(`docker run --rm -v "${buildTmpPath}:/files" sporsh/create-dmg Extraterm /files/extraterm-${packageData.version}-darwin-x64/ /files/extraterm_${packageData.version}.dmg`);
  }

  function makeNsis() {
    echo("");
    echo("---------------------------------------------------");
    echo("Building NSIS based installer for Windows");
    echo("---------------------------------------------------");

    const windowsBuildDirName = `extraterm-${packageData.version}-win32-x64`;
    const windowsPath = path.join(buildTmpPath, windowsBuildDirName);

    const versionSplit = packageData.version.split(".");
    const majorVersion = versionSplit[0];
    const minorVersion = versionSplit[1];
    const patchVersion = versionSplit[2];

    const installerScript = `
!include "MUI2.nsh"
!include "FileFunc.nsh"

!define APPNAME "Extraterm"
!define DESCRIPTION "Terminal emulator"
!define COMPANYNAME "extraterm.org"
!define VERSIONMAJOR ${majorVersion}
!define VERSIONMINOR ${minorVersion}
!define VERSIONBUILD ${patchVersion}

!define MUI_ABORTWARNING # This will warn the user if they exit from the installer.
!define MUI_INSTFILESPAGE_COLORS "3db54a 000000"
!define MUI_ICON "${windowsBuildDirName}\\resources\\app\\extraterm\\resources\\logo\\extraterm_small_logo.ico"

!insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.
!insertmacro MUI_PAGE_DIRECTORY # In which folder install page.
!insertmacro MUI_PAGE_INSTFILES # Installing page.
!insertmacro MUI_PAGE_FINISH # Finished installation page.

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Name "Extraterm"
BrandingText " "
OutFile "extraterm-setup-${packageData.version}.exe"
InstallDir "$PROGRAMFILES64\\Extraterm"
InstallDirRegKey HKLM "Software\\Extraterm" "InstallLocation"

ShowInstDetails show # This will always show the installation details.

Section "Extraterm"
  SetOutPath $INSTDIR
  File /r "${windowsBuildDirName}\\*"

  WriteUninstaller "$INSTDIR\\Uninstall.exe"

  createShortCut "$SMPROGRAMS\\Extraterm.lnk" "$INSTDIR\\extraterm.exe" "" "$INSTDIR\\resources\\app\\extraterm\\resources\\logo\\extraterm_small_logo.ico"

  WriteRegStr HKLM "Software\\Extraterm" "InstallLocation" "$\\"$INSTDIR$\\""
  WriteRegStr HKLM "Software\\Extraterm" "Version" "${packageData.version}"

  # Registry information for add/remove programs
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "DisplayName" "\${APPNAME} - \${DESCRIPTION}"
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "UninstallString" "$\\"$INSTDIR\\uninstall.exe$\\""
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "QuietUninstallString" "$\\"$INSTDIR\\uninstall.exe$\\" /S"
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "InstallLocation" "$\\"$INSTDIR$\\""
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "DisplayIcon" "$\\"$INSTDIR\\resources\\app\\extraterm\\resources\\logo\\extraterm_small_logo.ico$\\""
	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "Publisher" "\${COMPANYNAME}"

	WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "DisplayVersion" "\${VERSIONMAJOR}.\${VERSIONMINOR}.\${VERSIONBUILD}"
	WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "VersionMajor" \${VERSIONMAJOR}
	WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "VersionMinor" \${VERSIONMINOR}
	# There is no option for modifying or repairing the install
	WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "NoModify" 1
	WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "NoRepair" 1
	# Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size

  # Record the installation size
  \${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
  IntFmt $0 "0x%08X" $0
  WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}" "EstimatedSize" "\$0"

SectionEnd

Section "Uninstall"
  # Remove Start Menu launcher
	Delete "$SMPROGRAMS\\Extraterm.lnk"

  Delete "$INSTDIR\\*.*"
  Delete "$INSTDIR\\Uninstall.exe"
  RMDir /r "$INSTDIR"

  DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${APPNAME}"
  DeleteRegKey HKLM "Software\\Extraterm"
SectionEnd
`;
    fs.writeFileSync(path.join(buildTmpPath, "installer.nsi"), installerScript, {encoding: "utf-8"});

    exec(`docker run -t -v ${buildTmpPath}:/wine/drive_c/src/ cdrx/nsis`);
  }

  makePackage("x64", "win32")
    .then(() => makePackage("x64", "linux"))
    .then(() => makePackage("x64", "darwin"))
    .then(makeDmg)
    .then(makeNsis)
    .then(() => { log("Done"); } );
}

main();
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Thu May 19 2016 17:00:28 GMT+0200 (CEST)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'bower_components/angular/angular.js',
      'bower_components/angular-mocks/angular-mocks.js',
      'dist/hbUi.geo-0.0.1.js',
    //  'src/*.js',
      'test/**/*.spec.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome', 'Firefox', 'PhantomJS'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
}
<commit_msg>Provides mocked config info. Here clientDebugEnable var is neccessary to hbUi.geo module intialisation.<commit_after>// Karma configuration
// Generated on Thu May 19 2016 17:00:28 GMT+0200 (CEST)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'bower_components/angular/angular.js',
      'bower_components/angular-mocks/angular-mocks.js',
      'test/conf.js',
      'dist/hbUi.geo-0.0.1.js',
    //  'src/*.js',
      'test/**/*.spec.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome', 'Firefox', 'PhantomJS'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
}
<|endoftext|>


<commit_before>(function () {
    var $$ = {
        on: function(root, eventName, selector, fn) {
            root.addEventListener(eventName, function(event) {
                var target = event.target.closest(selector);
                if (root.contains(target)) {
                    fn.call(target, event);
                }
            });
        },
        show: function(element) {
            element.style.display = 'block';
        },
        hide: function(element) {
            element.style.display = 'none';
        },
        toggle: function(element, value) {
            if (value) {
                $$.show(element);
            } else {
                $$.hide(element);
            }
        },
        visible: function(element) {
            style = getComputedStyle(element);
            return style.display !== 'none';
        },
        executeScripts: function(root) {
            root.querySelectorAll('script').forEach(function(e) {
                var clone = document.createElement('script');
                clone.src = e.src;
                root.appendChild(clone);
            });
        },
    };

    var onKeyDown = function(event) {
        if (event.keyCode == 27) {
            djdt.hide_one_level();
        }
    };

    var ajax = function(url, init) {
        init = Object.assign({credentials: 'same-origin'}, init);
        return fetch(url, init).then(function(response) {
            if (response.ok) {
                return response.text();
            } else {
                var win = document.querySelector('#djDebugWindow');
                win.innerHTML = '
»
'+response.status+': '+response.statusText+'

';
                $$.show(win);
                return Promise.reject();
            }
        });
    };

    var djdt = {
        handleDragged: false,
        events: {
            ready: []
        },
        isReady: false,
        init: function() {
            var djDebug = document.querySelector('#djDebug');
            $$.show(djDebug);
            $$.on(djDebug.querySelector('#djDebugPanelList'), 'click', 'li a', function(event) {
                event.preventDefault();
                if (!this.className) {
                    return;
                }
                var current = djDebug.querySelector('#' + this.className);
                if ($$.visible(current)) {
                    djdt.hide_panels();
                } else {
                    djdt.hide_panels();

                    $$.show(current);
                    this.parentElement.classList.add('djdt-active');

                    var inner = current.querySelector('.djDebugPanelContent .djdt-scroll'),
                        store_id = djDebug.dataset.storeId;
                    if (store_id && inner.children.length === 0) {
                        var url = djDebug.dataset.renderPanelUrl;
                        var url_params = new URLSearchParams();
                        url_params.append('store_id', store_id);
                        url_params.append('panel_id', this.className);
                        url += '?' + url_params.toString();
                        ajax(url).then(function(body) {
                            inner.previousElementSibling.remove();  // Remove AJAX loader
                            inner.innerHTML = body;
                            $$.executeScripts(inner);
                        });
                    }
                }
            });
            $$.on(djDebug, 'click', 'a.djDebugClose', function(event) {
                event.preventDefault();
                djdt.hide_one_level();
            });
            $$.on(djDebug, 'click', '.djDebugPanelButton input[type=checkbox]', function() {
                djdt.cookie.set(this.dataset.cookie, this.checked ? 'on' : 'off', {
                    path: '/',
                    expires: 10
                });
            });

            // Used by the SQL and template panels
            $$.on(djDebug, 'click', '.remoteCall', function(event) {
                event.preventDefault();

                var name = this.tagName.toLowerCase();
                var ajax_data = {};

                if (name == 'button') {
                    var form = this.closest('form');
                    ajax_data.url = this.getAttribute('formaction');

                    if (form) {
                        ajax_data.body = new FormData(form);
                        ajax_data.method = form.getAttribute('method') || 'POST';
                    }
                }

                if (name == 'a') {
                    ajax_data.url = this.getAttribute('href');
                }

                ajax(ajax_data.url, ajax_data).then(function(body) {
                    var win = djDebug.querySelector('#djDebugWindow');
                    win.innerHTML = body;
                    $$.executeScripts(win);
                    $$.show(win);
                });
            });

            // Used by the cache, profiling and SQL panels
            $$.on(djDebug, 'click', 'a.djToggleSwitch', function(event) {
                event.preventDefault();
                var self = this;
                var id = this.dataset.toggleId;
                var open_me = this.textContent == this.dataset.toggleOpen;
                if (id === '' || !id) {
                    return;
                }
                var name = this.dataset.toggleName;
                var container = this.closest('.djDebugPanelContent').querySelector('#' + name + '_' + id);
                container.querySelectorAll('.djDebugCollapsed').forEach(function(e) {
                    $$.toggle(e, open_me);
                });
                container.querySelectorAll('.djDebugUncollapsed').forEach(function(e) {
                    $$.toggle(e, !open_me);
                });
                this.closest('.djDebugPanelContent').querySelectorAll('.djToggleDetails_' + id).forEach(function(e) {
                    if (open_me) {
                        e.classList.add('djSelected');
                        e.classList.remove('djUnselected');
                        self.textContent = self.dataset.toggleClose;
                    } else {
                        e.classList.remove('djSelected');
                        e.classList.add('djUnselected');
                        self.textContent = self.dataset.toggleOpen;
                    }
                    var switch_ = e.querySelector('.djToggleSwitch')
                    if (switch_) switch_.textContent = self.textContent;
                });
            });

            djDebug.querySelector('#djHideToolBarButton').addEventListener('click', function(event) {
                event.preventDefault();
                djdt.hide_toolbar(true);
            });
            djDebug.querySelector('#djShowToolBarButton').addEventListener('click', function(event) {
                event.preventDefault();
                if (!djdt.handleDragged) {
                    djdt.show_toolbar();
                }
            });
            var startPageY, baseY;
            var handle = document.querySelector('#djDebugToolbarHandle');
            var onHandleMove = function(event) {
                // Chrome can send spurious mousemove events, so don't do anything unless the
                // cursor really moved.  Otherwise, it will be impossible to expand the toolbar
                // due to djdt.handleDragged being set to true.
                if (djdt.handleDragged || event.pageY != startPageY) {
                    var top = baseY + event.pageY;

                    if (top < 0) {
                        top = 0;
                    } else if (top + handle.offsetHeight > window.innerHeight) {
                        top = window.innerHeight - handle.offsetHeight;
                    }

                    handle.style.top = top + 'px';
                    djdt.handleDragged = true;
                }
            };
            djDebug.querySelector('#djShowToolBarButton').addEventListener('mousedown', function(event) {
                event.preventDefault();
                startPageY = event.pageY;
                baseY = handle.offsetTop - startPageY;
                document.addEventListener('mousemove', onHandleMove);
            });
            document.addEventListener('mouseup', function (event) {
                document.removeEventListener('mousemove', onHandleMove);
                if (djdt.handleDragged) {
                    event.preventDefault();
                    djdt.cookie.set('djdttop', handle.offsetTop, {
                        path: '/',
                        expires: 10
                    });
                    setTimeout(function () {
                        djdt.handleDragged = false;
                    }, 10);
                }
            });
            if (djdt.cookie.get('djdt') == 'hide') {
                djdt.hide_toolbar(false);
            } else {
                djdt.show_toolbar();
            }
            djdt.isReady = true;
            djdt.events.ready.forEach(function(callback) {
                callback(djdt);
            });
        },
        hide_panels: function() {
            $$.hide(djDebug.querySelector('#djDebugWindow'));
            djDebug.querySelectorAll('.djdt-panelContent').forEach(function(e) {
                $$.hide(e);
            });
            djDebug.querySelectorAll('#djDebugToolbar li').forEach(function(e) {
                e.classList.remove('djdt-active');
            });
        },
        hide_toolbar: function(setCookie) {
            djdt.hide_panels();
            $$.hide(djDebug.querySelector('#djDebugToolbar'));

            var handle = document.querySelector('#djDebugToolbarHandle');
            $$.show(handle);
            // set handle position
            var handleTop = djdt.cookie.get('djdttop');
            if (handleTop) {
                handleTop = Math.min(handleTop, window.innerHeight - handle.offsetHeight);
                handle.style.top = handleTop + 'px';
            }

            document.removeEventListener('keydown', onKeyDown);

            if (setCookie) {
                djdt.cookie.set('djdt', 'hide', {
                    path: '/',
                    expires: 10
                });
            }
        },
        hide_one_level: function(skipDebugWindow) {
            if ($$.visible(djDebug.querySelector('#djDebugWindow'))) {
                $$.hide(djDebug.querySelector('#djDebugWindow'));
            } else if (djDebug.querySelector('#djDebugToolbar li.djdt-active')) {
                djdt.hide_panels();
            } else {
                djdt.hide_toolbar(true);
            }
        },
        show_toolbar: function() {
            document.addEventListener('keydown', onKeyDown);
            $$.hide(djDebug.querySelector('#djDebugToolbarHandle'));
            $$.show(djDebug.querySelector('#djDebugToolbar'));
            djdt.cookie.set('djdt', 'show', {
                path: '/',
                expires: 10
            });
        },
        ready: function(callback){
            if (djdt.isReady) {
                callback(djdt);
            } else {
                djdt.events.ready.push(callback);
            }
        },
        cookie: {
            get: function(key){
                if (document.cookie.indexOf(key) === -1) return null;

                var cookieArray = document.cookie.split('; '),
                    cookies = {};

                cookieArray.forEach(function(e){
                    var parts = e.split('=');
                    cookies[ parts[0] ] = parts[1];
                });

                return cookies[ key ];
            },
            set: function(key, value, options){
                options = options || {};

                if (typeof options.expires === 'number') {
                    var days = options.expires, t = options.expires = new Date();
                    t.setDate(t.getDate() + days);
                }

                document.cookie = [
                    encodeURIComponent(key) + '=' + String(value),
                    options.expires ? '; expires=' + options.expires.toUTCString() : '',
                    options.path    ? '; path=' + options.path : '',
                    options.domain  ? '; domain=' + options.domain : '',
                    options.secure  ? '; secure' : ''
                ].join('');

                return value;
            }
        },
    };
    window.djdt = {
        show_toolbar: djdt.show_toolbar,
        hide_toolbar: djdt.hide_toolbar,
        init: djdt.init,
        close: djdt.hide_one_level,
        cookie: djdt.cookie,
    };
    document.addEventListener('DOMContentLoaded', djdt.init);
})();
<commit_msg>Remove unnecessary guard for empty data-toggle-id value<commit_after>(function () {
    var $$ = {
        on: function(root, eventName, selector, fn) {
            root.addEventListener(eventName, function(event) {
                var target = event.target.closest(selector);
                if (root.contains(target)) {
                    fn.call(target, event);
                }
            });
        },
        show: function(element) {
            element.style.display = 'block';
        },
        hide: function(element) {
            element.style.display = 'none';
        },
        toggle: function(element, value) {
            if (value) {
                $$.show(element);
            } else {
                $$.hide(element);
            }
        },
        visible: function(element) {
            style = getComputedStyle(element);
            return style.display !== 'none';
        },
        executeScripts: function(root) {
            root.querySelectorAll('script').forEach(function(e) {
                var clone = document.createElement('script');
                clone.src = e.src;
                root.appendChild(clone);
            });
        },
    };

    var onKeyDown = function(event) {
        if (event.keyCode == 27) {
            djdt.hide_one_level();
        }
    };

    var ajax = function(url, init) {
        init = Object.assign({credentials: 'same-origin'}, init);
        return fetch(url, init).then(function(response) {
            if (response.ok) {
                return response.text();
            } else {
                var win = document.querySelector('#djDebugWindow');
                win.innerHTML = '
»
'+response.status+': '+response.statusText+'

';
                $$.show(win);
                return Promise.reject();
            }
        });
    };

    var djdt = {
        handleDragged: false,
        events: {
            ready: []
        },
        isReady: false,
        init: function() {
            var djDebug = document.querySelector('#djDebug');
            $$.show(djDebug);
            $$.on(djDebug.querySelector('#djDebugPanelList'), 'click', 'li a', function(event) {
                event.preventDefault();
                if (!this.className) {
                    return;
                }
                var current = djDebug.querySelector('#' + this.className);
                if ($$.visible(current)) {
                    djdt.hide_panels();
                } else {
                    djdt.hide_panels();

                    $$.show(current);
                    this.parentElement.classList.add('djdt-active');

                    var inner = current.querySelector('.djDebugPanelContent .djdt-scroll'),
                        store_id = djDebug.dataset.storeId;
                    if (store_id && inner.children.length === 0) {
                        var url = djDebug.dataset.renderPanelUrl;
                        var url_params = new URLSearchParams();
                        url_params.append('store_id', store_id);
                        url_params.append('panel_id', this.className);
                        url += '?' + url_params.toString();
                        ajax(url).then(function(body) {
                            inner.previousElementSibling.remove();  // Remove AJAX loader
                            inner.innerHTML = body;
                            $$.executeScripts(inner);
                        });
                    }
                }
            });
            $$.on(djDebug, 'click', 'a.djDebugClose', function(event) {
                event.preventDefault();
                djdt.hide_one_level();
            });
            $$.on(djDebug, 'click', '.djDebugPanelButton input[type=checkbox]', function() {
                djdt.cookie.set(this.dataset.cookie, this.checked ? 'on' : 'off', {
                    path: '/',
                    expires: 10
                });
            });

            // Used by the SQL and template panels
            $$.on(djDebug, 'click', '.remoteCall', function(event) {
                event.preventDefault();

                var name = this.tagName.toLowerCase();
                var ajax_data = {};

                if (name == 'button') {
                    var form = this.closest('form');
                    ajax_data.url = this.getAttribute('formaction');

                    if (form) {
                        ajax_data.body = new FormData(form);
                        ajax_data.method = form.getAttribute('method') || 'POST';
                    }
                }

                if (name == 'a') {
                    ajax_data.url = this.getAttribute('href');
                }

                ajax(ajax_data.url, ajax_data).then(function(body) {
                    var win = djDebug.querySelector('#djDebugWindow');
                    win.innerHTML = body;
                    $$.executeScripts(win);
                    $$.show(win);
                });
            });

            // Used by the cache, profiling and SQL panels
            $$.on(djDebug, 'click', 'a.djToggleSwitch', function(event) {
                event.preventDefault();
                var self = this;
                var id = this.dataset.toggleId;
                var open_me = this.textContent == this.dataset.toggleOpen;
                var name = this.dataset.toggleName;
                var container = this.closest('.djDebugPanelContent').querySelector('#' + name + '_' + id);
                container.querySelectorAll('.djDebugCollapsed').forEach(function(e) {
                    $$.toggle(e, open_me);
                });
                container.querySelectorAll('.djDebugUncollapsed').forEach(function(e) {
                    $$.toggle(e, !open_me);
                });
                this.closest('.djDebugPanelContent').querySelectorAll('.djToggleDetails_' + id).forEach(function(e) {
                    if (open_me) {
                        e.classList.add('djSelected');
                        e.classList.remove('djUnselected');
                        self.textContent = self.dataset.toggleClose;
                    } else {
                        e.classList.remove('djSelected');
                        e.classList.add('djUnselected');
                        self.textContent = self.dataset.toggleOpen;
                    }
                    var switch_ = e.querySelector('.djToggleSwitch')
                    if (switch_) switch_.textContent = self.textContent;
                });
            });

            djDebug.querySelector('#djHideToolBarButton').addEventListener('click', function(event) {
                event.preventDefault();
                djdt.hide_toolbar(true);
            });
            djDebug.querySelector('#djShowToolBarButton').addEventListener('click', function(event) {
                event.preventDefault();
                if (!djdt.handleDragged) {
                    djdt.show_toolbar();
                }
            });
            var startPageY, baseY;
            var handle = document.querySelector('#djDebugToolbarHandle');
            var onHandleMove = function(event) {
                // Chrome can send spurious mousemove events, so don't do anything unless the
                // cursor really moved.  Otherwise, it will be impossible to expand the toolbar
                // due to djdt.handleDragged being set to true.
                if (djdt.handleDragged || event.pageY != startPageY) {
                    var top = baseY + event.pageY;

                    if (top < 0) {
                        top = 0;
                    } else if (top + handle.offsetHeight > window.innerHeight) {
                        top = window.innerHeight - handle.offsetHeight;
                    }

                    handle.style.top = top + 'px';
                    djdt.handleDragged = true;
                }
            };
            djDebug.querySelector('#djShowToolBarButton').addEventListener('mousedown', function(event) {
                event.preventDefault();
                startPageY = event.pageY;
                baseY = handle.offsetTop - startPageY;
                document.addEventListener('mousemove', onHandleMove);
            });
            document.addEventListener('mouseup', function (event) {
                document.removeEventListener('mousemove', onHandleMove);
                if (djdt.handleDragged) {
                    event.preventDefault();
                    djdt.cookie.set('djdttop', handle.offsetTop, {
                        path: '/',
                        expires: 10
                    });
                    setTimeout(function () {
                        djdt.handleDragged = false;
                    }, 10);
                }
            });
            if (djdt.cookie.get('djdt') == 'hide') {
                djdt.hide_toolbar(false);
            } else {
                djdt.show_toolbar();
            }
            djdt.isReady = true;
            djdt.events.ready.forEach(function(callback) {
                callback(djdt);
            });
        },
        hide_panels: function() {
            $$.hide(djDebug.querySelector('#djDebugWindow'));
            djDebug.querySelectorAll('.djdt-panelContent').forEach(function(e) {
                $$.hide(e);
            });
            djDebug.querySelectorAll('#djDebugToolbar li').forEach(function(e) {
                e.classList.remove('djdt-active');
            });
        },
        hide_toolbar: function(setCookie) {
            djdt.hide_panels();
            $$.hide(djDebug.querySelector('#djDebugToolbar'));

            var handle = document.querySelector('#djDebugToolbarHandle');
            $$.show(handle);
            // set handle position
            var handleTop = djdt.cookie.get('djdttop');
            if (handleTop) {
                handleTop = Math.min(handleTop, window.innerHeight - handle.offsetHeight);
                handle.style.top = handleTop + 'px';
            }

            document.removeEventListener('keydown', onKeyDown);

            if (setCookie) {
                djdt.cookie.set('djdt', 'hide', {
                    path: '/',
                    expires: 10
                });
            }
        },
        hide_one_level: function(skipDebugWindow) {
            if ($$.visible(djDebug.querySelector('#djDebugWindow'))) {
                $$.hide(djDebug.querySelector('#djDebugWindow'));
            } else if (djDebug.querySelector('#djDebugToolbar li.djdt-active')) {
                djdt.hide_panels();
            } else {
                djdt.hide_toolbar(true);
            }
        },
        show_toolbar: function() {
            document.addEventListener('keydown', onKeyDown);
            $$.hide(djDebug.querySelector('#djDebugToolbarHandle'));
            $$.show(djDebug.querySelector('#djDebugToolbar'));
            djdt.cookie.set('djdt', 'show', {
                path: '/',
                expires: 10
            });
        },
        ready: function(callback){
            if (djdt.isReady) {
                callback(djdt);
            } else {
                djdt.events.ready.push(callback);
            }
        },
        cookie: {
            get: function(key){
                if (document.cookie.indexOf(key) === -1) return null;

                var cookieArray = document.cookie.split('; '),
                    cookies = {};

                cookieArray.forEach(function(e){
                    var parts = e.split('=');
                    cookies[ parts[0] ] = parts[1];
                });

                return cookies[ key ];
            },
            set: function(key, value, options){
                options = options || {};

                if (typeof options.expires === 'number') {
                    var days = options.expires, t = options.expires = new Date();
                    t.setDate(t.getDate() + days);
                }

                document.cookie = [
                    encodeURIComponent(key) + '=' + String(value),
                    options.expires ? '; expires=' + options.expires.toUTCString() : '',
                    options.path    ? '; path=' + options.path : '',
                    options.domain  ? '; domain=' + options.domain : '',
                    options.secure  ? '; secure' : ''
                ].join('');

                return value;
            }
        },
    };
    window.djdt = {
        show_toolbar: djdt.show_toolbar,
        hide_toolbar: djdt.hide_toolbar,
        init: djdt.init,
        close: djdt.hide_one_level,
        cookie: djdt.cookie,
    };
    document.addEventListener('DOMContentLoaded', djdt.init);
})();
<|endoftext|>


<commit_before><commit_msg>Updated script<commit_after><|endoftext|>


<commit_before>const fs = require('fs')
const path = require('path')
const hash = require('hash-sum')
const VueLoaderPlugin = require('../dist/plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')

module.exports = (env = {}) => {
  const isProd = env.prod
  const minimize = isProd && !env.noMinimize
  const babel = isProd && !env.noBabel

  return {
    mode: isProd ? 'production' : 'development',
    entry: path.resolve(__dirname, './main.js'),
    devtool: isProd ? 'source-map' : 'cheap-module-eval-source-map',
    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: '[name].js',
      publicPath: '/dist/'
    },
    module: {
      rules: [
        {
          test: /\.vue$/,
          loader: 'vue-loader'
        },
        {
          test: /\.png$/,
          use: [
            {
              loader: 'url-loader',
              options: {
                limit: 8192
              }
            }
          ]
        },
        {
          test: /\.css$/,
          use: [
            {
              loader: MiniCssExtractPlugin.loader,
              options: {
                hmr: !isProd
              }
            },
            'css-loader'
          ]
        },
        {
          test: /\.js$/,
          use: [
            {
              loader: 'cache-loader',
              options: {
                cacheIdentifier: hash(
                  fs.readFileSync(path.resolve(__dirname, '../package.json')) +
                    JSON.stringify(env)
                )
              }
            },
            ...(babel
              ? [
                  {
                    loader: 'babel-loader',
                    options: {
                      presets: ['@babel/preset-env']
                    }
                  }
                ]
              : [])
          ]
        },
        // target <docs> custom blocks
        {
          resourceQuery: /blockType=docs/,
          loader: require.resolve('./docs-loader')
        }
      ]
    },
    plugins: [
      new VueLoaderPlugin(),
      new MiniCssExtractPlugin({
        filename: '[name].css'
      })
    ],
    optimization: {
      minimize,
      splitChunks: {
        cacheGroups: {
          commons: {
            test: /esm-bundler/,
            name: 'vendors',
            chunks: 'all'
          }
        }
      }
    },
    devServer: {
      stats: 'minimal',
      contentBase: __dirname,
      overlay: true
    },
    resolveLoader: {
      alias: {
        'vue-loader': require.resolve('../')
      }
    }
  }
}
<commit_msg>comment<commit_after>const fs = require('fs')
const path = require('path')
const hash = require('hash-sum')
const VueLoaderPlugin = require('../dist/plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')

module.exports = (env = {}) => {
  const isProd = env.prod
  const minimize = isProd && !env.noMinimize
  const babel = isProd && !env.noBabel

  return {
    mode: isProd ? 'production' : 'development',
    entry: path.resolve(__dirname, './main.js'),
    devtool: isProd ? 'source-map' : 'cheap-module-eval-source-map',
    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: '[name].js',
      publicPath: '/dist/'
    },
    module: {
      rules: [
        {
          test: /\.vue$/,
          loader: 'vue-loader'
        },
        {
          test: /\.png$/,
          use: [
            {
              loader: 'url-loader',
              options: {
                limit: 8192
              }
            }
          ]
        },
        {
          test: /\.css$/,
          use: [
            {
              loader: MiniCssExtractPlugin.loader,
              options: {
                hmr: !isProd
              }
            },
            'css-loader'
          ]
        },
        {
          test: /\.js$/,
          use: [
            {
              loader: 'cache-loader',
              options: {
                cacheIdentifier: hash(
                  fs.readFileSync(path.resolve(__dirname, '../package.json')) +
                    JSON.stringify(env)
                )
              }
            },
            ...(babel
              ? [
                  {
                    loader: 'babel-loader',
                    options: {
                      // use yarn build-example --env.noMinimize to verify that
                      // babel is properly applied to all js code, including the
                      // render function compiled from SFC templates.
                      presets: ['@babel/preset-env']
                    }
                  }
                ]
              : [])
          ]
        },
        // target <docs> custom blocks
        {
          resourceQuery: /blockType=docs/,
          loader: require.resolve('./docs-loader')
        }
      ]
    },
    plugins: [
      new VueLoaderPlugin(),
      new MiniCssExtractPlugin({
        filename: '[name].css'
      })
    ],
    optimization: {
      minimize,
      splitChunks: {
        cacheGroups: {
          commons: {
            test: /esm-bundler/,
            name: 'vendors',
            chunks: 'all'
          }
        }
      }
    },
    devServer: {
      stats: 'minimal',
      contentBase: __dirname,
      overlay: true
    },
    resolveLoader: {
      alias: {
        'vue-loader': require.resolve('../')
      }
    }
  }
}
<|endoftext|>