Unverified Commit 728bae02 authored by Robert Schütz's avatar Robert Schütz Committed by GitHub
Browse files

Merge pull request #253687 from dotlambda/plausible-2.0.0

plausible: 1.4.4 -> 2.0.0
parents ba606221 c4574a95
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -248,11 +248,10 @@ in {
            # setup
            ${cfg.package}/createdb.sh
            ${cfg.package}/migrate.sh
            export IP_GEOLOCATION_DB=${pkgs.dbip-country-lite}/share/dbip/dbip-country-lite.mmdb
            ${cfg.package}/bin/plausible eval "(Plausible.Release.prepare() ; Plausible.Auth.create_user(\"$ADMIN_USER_NAME\", \"$ADMIN_USER_EMAIL\", \"$ADMIN_USER_PWD\"))"
            ${optionalString cfg.adminUser.activate ''
              if ! ${cfg.package}/init-admin.sh | grep 'already exists'; then
                psql -d plausible <<< "UPDATE users SET email_verified=true;"
              fi
              psql -d plausible <<< "UPDATE users SET email_verified=true where email = '$ADMIN_USER_EMAIL';"
            ''}

            exec plausible start
+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {

    machine.succeed("curl -f localhost:8000 >&2")

    machine.succeed("curl -f localhost:8000/js/script.js >&2")

    csrf_token = machine.succeed(
        "curl -c /tmp/cookies localhost:8000/login | grep '_csrf_token' | sed -E 's,.*value=\"(.*)\".*,\\1,g'"
    )
+38 −24
Original line number Diff line number Diff line
{ lib
, stdenv
, beamPackages
, buildNpmPackage
, fetchFromGitHub
, glibcLocales
, cacert
, mkYarnModules
, fetchYarnDeps
, nodejs
, nixosTests
}:

let
  pname = "plausible";
  version = "1.5.1";
  version = "2.0.0";

  src = fetchFromGitHub {
    owner = "plausible";
    repo = "analytics";
    rev = "v${version}";
    hash = "sha256-KcIZMsWlKGCZFi7DrTS8JMWEahdERoExtpBj+7Ec+FQ=";
    hash = "sha256-yrTwxBguAZbfEKucUL+w49Hr6D7v9/2OjY1h27+w5WI=";
  };

  # TODO consider using `mix2nix` as soon as it supports git dependencies.
  mixFodDeps = beamPackages.fetchMixDeps {
    pname = "${pname}-deps";
    inherit src version;
    hash = "sha256-rLkD2FuNFKU3nB8FT/qPgSVP8H60qEmHtPvcdw4JUF8=";
    hash = "sha256-CAyZLpjmw1JreK3MopqI0XsWhP+fJEMpXlww7CibSaM=";
  };

  yarnDeps = mkYarnModules {
    pname = "${pname}-yarn-deps";
  assets = buildNpmPackage {
    pname = "${pname}-assets";
    inherit version;
    packageJSON = ./package.json;
    yarnLock = ./yarn.lock;
    yarnNix = ./yarn.nix;
    preBuild = ''
      mkdir -p tmp/deps
      cp -r ${mixFodDeps}/phoenix tmp/deps/phoenix
      cp -r ${mixFodDeps}/phoenix_html tmp/deps/phoenix_html
    src = "${src}/assets";
    npmDepsHash = "sha256-2t1M6RQhBjZxx36qawVUVC+ob9SvQIq5dy4HgVeY2Eo=";
    dontNpmBuild = true;
    installPhase = ''
      runHook preInstall
      cp -r . "$out"
      runHook postInstall
    '';
    postBuild = ''
      echo 'module.exports = {}' > $out/node_modules/flatpickr/dist/postcss.config.js
  };

  tracker = buildNpmPackage {
    pname = "${pname}-tracker";
    inherit version;
    src = "${src}/tracker";
    npmDepsHash = "sha256-y09jVSwUrxF0nLpLqS1yQweYL+iMF6jVx0sUdQtvrpc=";
    dontNpmBuild = true;
    installPhase = ''
      runHook preInstall
      cp -r . "$out"
      runHook postInstall
    '';
  };
in
beamPackages.mixRelease {
  inherit pname version src mixFodDeps;

  nativeBuildInputs = [ nodejs ];
  nativeBuildInputs = [
    nodejs
  ];

  passthru = {
    tests = { inherit (nixosTests) plausible; };
@@ -58,11 +66,16 @@ beamPackages.mixRelease {
    substituteInPlace lib/plausible_release.ex --replace 'defp prepare do' 'def prepare do'
  '';

  preBuild = ''
    rm -r assets tracker
    cp -r ${assets} assets
    cp -r ${tracker} tracker
  '';

  postBuild = ''
    export HOME=$TMPDIR
    export NODE_OPTIONS=--openssl-legacy-provider # required for webpack compatibility with OpenSSL 3 (https://github.com/webpack/webpack/issues/14532)
    ln -sf ${yarnDeps}/node_modules assets/node_modules
    npm run deploy --prefix ./assets
    npm run deploy --prefix ./tracker

    # for external task you need a workaround for the no deps check flag
    # https://github.com/phoenixframework/phoenix/issues/2690
@@ -72,8 +85,9 @@ beamPackages.mixRelease {
  meta = with lib; {
    license = licenses.agpl3Plus;
    homepage = "https://plausible.io/";
    description = " Simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.";
    maintainers = with maintainers; [ ];
    changelog = "https://github.com/plausible/analytics/blob/${src.rev}/CHANGELOG.md";
    description = " Simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics";
    maintainers = with maintainers; [ softinio ];
    platforms = platforms.unix;
  };
}
+0 −72
Original line number Diff line number Diff line
{
  "repository": {},
  "version": "v1.5.1",
  "license": "AGPL-3.0-or-later",
  "scripts": {
    "deploy": "webpack --mode production",
    "watch": "webpack --mode development --watch",
    "format": "prettier --write {css,js}/**",
    "check-format": "prettier --check {css,js}/**",
    "lint": "eslint js/**",
    "bundlemon": "bundlemon"
  },
  "dependencies": {
    "@babel/core": "^7.14.3",
    "@babel/preset-env": "^7.14.4",
    "@babel/preset-react": "^7.13.13",
    "@headlessui/react": "^1.3.0",
    "@heroicons/react": "^2.0.11",
    "@juggle/resize-observer": "^3.3.1",
    "@kunukn/react-collapse": "^2.2.9",
    "@popperjs/core": "^2.11.6",
    "@tailwindcss/aspect-ratio": "^0.2.1",
    "@tailwindcss/forms": "^0.3.2",
    "@tailwindcss/typography": "^0.4.1",
    "abortcontroller-polyfill": "^1.7.3",
    "alpinejs": "^2.8.2",
    "autoprefixer": "^10.2.6",
    "babel-loader": "^8.2.2",
    "chart.js": "^3.3.2",
    "classnames": "^2.3.1",
    "copy-webpack-plugin": "^9.0.0",
    "css-loader": "^5.2.6",
    "css-minimizer-webpack-plugin": "^3.2.0",
    "datamaps": "^0.5.9",
    "debounce-promise": "^3.1.2",
    "downshift": "^6.1.3",
    "iframe-resizer": "^4.3.2",
    "mini-css-extract-plugin": "^1.6.0",
    "phoenix": "1.5.0",
    "phoenix_html": "2.12",
    "postcss": "^8.3.0",
    "postcss-loader": "^6.1.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-flatpickr": "3.10.5",
    "react-flip-move": "^3.0.4",
    "react-popper": "^2.3.0",
    "react-router-dom": "^5.2.0",
    "react-transition-group": "^4.4.2",
    "tailwindcss": "^2.1.2",
    "terser-webpack-plugin": "^5.1.2",
    "url-search-params-polyfill": "^8.1.1",
    "webpack": "5.38.1",
    "webpack-cli": "^4.7.0"
  },
  "devDependencies": {
    "babel-eslint": "^10.1.0",
    "bundlemon": "^1.4.0",
    "eslint": "^7.2.0",
    "eslint-config-prettier": "^7.0.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.3.0",
    "eslint-plugin-react": "^7.21.5",
    "eslint-plugin-react-hooks": "^4.2.0",
    "stylelint": "^14.1.0",
    "stylelint-config-prettier": "^9.0.3",
    "stylelint-config-standard": "^24.0.0",
    "webpack-bundle-analyzer": "^4.4.2"
  },
  "name": "plausible"
}
+0 −5766

File deleted.

Preview size limit exceeded, changes collapsed.

Loading