Unverified Commit 78f21546 authored by Yt's avatar Yt Committed by GitHub
Browse files

documenso: 0.9 -> 1.12.6 (#455280)

parents 4570ceef f060465d
Loading
Loading
Loading
Loading
+789 −0

File added.

Preview size limit exceeded, changes collapsed.

+40 −0
Original line number Diff line number Diff line
diff --git a/package.json b/package.json
index 1ff8701..e337979 100644
--- a/package.json
+++ b/package.json
@@ -44,22 +44,22 @@
     "@commitlint/cli": "^17.7.1",
     "@commitlint/config-conventional": "^17.7.0",
     "@lingui/cli": "^5.2.0",
+    "@prisma/client": "^6.8.2",
     "dotenv": "^16.5.0",
     "dotenv-cli": "^8.0.0",
     "eslint": "^8.40.0",
     "eslint-config-custom": "*",
     "husky": "^9.0.11",
     "lint-staged": "^15.2.2",
+    "nodemailer": "^6.10.1",
     "playwright": "1.52.0",
     "prettier": "^3.3.3",
-    "rimraf": "^5.0.1",
-    "turbo": "^1.9.3",
-    "vite": "^6.3.5",
-    "@prisma/client": "^6.8.2",
     "prisma": "^6.8.2",
     "prisma-extension-kysely": "^3.0.0",
     "prisma-kysely": "^1.8.0",
-    "nodemailer": "^6.10.1"
+    "rimraf": "^5.0.1",
+    "turbo": "^2.5.8",
+    "vite": "^6.3.5"
   },
   "name": "@documenso/root",
   "workspaces": [
@@ -71,7 +71,6 @@
     "@documenso/prisma": "^0.0.0",
     "@lingui/conf": "^5.2.0",
     "@lingui/core": "^5.2.0",
-    "inngest-cli": "^0.29.1",
     "luxon": "^3.5.0",
     "mupdf": "^1.0.0",
     "react": "^18",
+93 −23
Original line number Diff line number Diff line
{
  lib,
  nodejs,
  node-gyp,
  node-pre-gyp,
  pixman,
  fetchFromGitHub,
  buildNpmPackage,
  prisma,
  nix-update-script,
  prisma-engines,
  vips,
  pkg-config,
  cairo,
  pango,
  bash,
  openssl,
}:
let
  version = "0.9";
  pname = "documenso";
  version = "1.12.6";
in
buildNpmPackage {
  pname = "documenso";
  inherit version;

  inherit version pname;

  src = fetchFromGitHub {
    owner = "documenso";
    repo = "documenso";
    rev = "v${version}";
    hash = "sha256-uKOJVZ0GRHo/CYvd/Ix/tq1WDhutRji1tSGdcITsNlo=";
    hash = "sha256-1TKjsOKJkv3COFgsE4tPAymI0MdeT+T8HiNgnoWHlAY=";
  };

  nativeBuildInputs = [ prisma ];
  npmDepsHash = "sha256-ZddRSBDasa3mMAS2dqXgXRMOc1nvspdXsuTZ7c+einw=";

  preBuild = ''
    # somehow for linux, npm is not finding the prisma package with the
    # packages installed with the lockfile.
    # This generates a prisma version incompatibility warning and is a kludge
    # until the upstream package-lock is modified.
    prisma generate
  '';
  env.PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1";

  env.PRISMA_QUERY_ENGINE_LIBRARY = "${prisma-engines}/lib/libquery_engine.node";
  env.PRISMA_QUERY_ENGINE_BINARY = "${prisma-engines}/bin/query-engine";
  env.PRISMA_SCHEMA_ENGINE_BINARY = "${prisma-engines}/bin/schema-engine";
  env.TURBO_NO_UPDATE_NOTIFIER = "true";
  env.TURBO_FORCE = "true";
  env.TURBO_REMOTE_CACHE_ENABLED = "false";

  nativeBuildInputs = [
    pkg-config
    vips
    node-gyp
  ];

  buildInputs = [
    node-pre-gyp
    node-gyp
    pixman
    cairo
    pango
    vips
  ];

  npmDepsHash = "sha256-+JbvFMi8xoyxkuL9k96K1Vq0neciCGkkyZUPd15ES2E=";
  patches = [
    ./package-lock.json.patch
    ./package.json.patch
    ./turbo.json.patch
  ];

  buildPhase = ''
    runHook preBuild

    patchShebangs apps/remix/.bin/build.sh
    npm exec turbo -- telemetry disable
    npm exec turbo -- build --filter=@documenso/remix

    runHook postBuild
  '';

  installPhase = ''
          runHook preInstall

    mkdir $out
    cp -r node_modules $out/
    cp package-lock.json $out
    cp apps/web/package.json $out
    cp -r apps/web/public $out/
    cp -r apps/web/.next $out/
          mkdir -p $out/bin
          cp -r . $out/

          cat > $out/bin/${pname} <<EOF
    #!${bash}/bin/bash
    export PKG_CONFIG_PATH=${openssl.dev}/lib/pkgconfig;
    export PRISMA_QUERY_ENGINE_LIBRARY=${prisma-engines}/lib/libquery_engine.node
    export PRISMA_QUERY_ENGINE_BINARY=${prisma-engines}/bin/query-engine
    export PRISMA_SCHEMA_ENGINE_BINARY=${prisma-engines}
    cd $out/apps/remix
    ${prisma}/bin/prisma migrate deploy --schema ../../packages/prisma/schema.prisma
    ${nodejs}/bin/node build/server/main.js
    EOF
          chmod +x $out/bin/${pname}

          runHook postInstall
  '';

  passthru.updateScript = nix-update-script { };
  # cleanup dangling symlinks for workspaces
  preFixup = ''
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/assets
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/lib
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/documentation
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/prettier-config
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/signing
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/ui
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/eslint-config
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/tailwind-config
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/email
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/prisma
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/remix
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/openpage-api
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/api
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/tsconfig
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/app-tests
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/trpc
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/ee
    rm -Rf $out/lib/node_modules/@documenso/root/node_modules/@documenso/auth
  '';

  meta = with lib; {
    description = "Open Source DocuSign Alternative";
@@ -52,5 +121,6 @@ buildNpmPackage {
    license = licenses.agpl3Only;
    maintainers = with maintainers; [ happysalada ];
    platforms = platforms.unix;
    mainProgram = pname;
  };
}
+104 −0
Original line number Diff line number Diff line
diff --git a/turbo.json b/turbo.json
index d767b46..b2d1ad3 100644
--- a/turbo.json
+++ b/turbo.json
@@ -1,41 +1,8 @@
 {
   "$schema": "https://turbo.build/schema.json",
-  "pipeline": {
-    "build": {
-      "dependsOn": ["prebuild", "^build"],
-      "outputs": [".next/**", "!.next/cache/**"]
-    },
-    "prebuild": {
-      "cache": false,
-      "dependsOn": ["^prebuild"]
-    },
-    "lint": {
-      "cache": false
-    },
-    "lint:fix": {
-      "cache": false
-    },
-    "clean": {
-      "cache": false
-    },
-    "dev": {
-      "cache": false,
-      "persistent": true
-    },
-    "start": {
-      "dependsOn": ["^build"],
-      "cache": false,
-      "persistent": true
-    },
-    "dev:test": {
-      "cache": false
-    },
-    "test:e2e": {
-      "dependsOn": ["^build"],
-      "cache": false
-    }
-  },
-  "globalDependencies": ["**/.env.*local"],
+  "globalDependencies": [
+    "**/.env.*local"
+  ],
   "globalEnv": [
     "APP_VERSION",
     "NEXT_PRIVATE_ENCRYPTION_KEY",
@@ -119,5 +86,53 @@
     "E2E_TEST_AUTHENTICATE_USERNAME",
     "E2E_TEST_AUTHENTICATE_USER_EMAIL",
     "E2E_TEST_AUTHENTICATE_USER_PASSWORD"
-  ]
+  ],
+  "tasks": {
+    "build": {
+      "dependsOn": [
+        "prebuild",
+        "^build"
+      ],
+      "outputs": [
+        ".next/**",
+        "!.next/cache/**"
+      ]
+    },
+    "prebuild": {
+      "cache": false,
+      "dependsOn": [
+        "^prebuild"
+      ]
+    },
+    "lint": {
+      "cache": false
+    },
+    "lint:fix": {
+      "cache": false
+    },
+    "clean": {
+      "cache": false
+    },
+    "dev": {
+      "cache": false,
+      "persistent": true
+    },
+    "start": {
+      "dependsOn": [
+        "^build"
+      ],
+      "cache": false,
+      "persistent": true
+    },
+    "dev:test": {
+      "cache": false
+    },
+    "test:e2e": {
+      "dependsOn": [
+        "^build"
+      ],
+      "cache": false
+    }
+  },
+  "envMode": "loose"
 }
+55 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash
CMDS=();DESC=();NARGS=$#;ARG1=$1;make_command(){ CMDS+=($1);DESC+=("$2");};usage(){ printf "\nUsage: %s [command]\n\nCommands:\n" $0;line="              ";for((i=0;i<=$(( ${#CMDS[*]} -1));i++));do printf "  %s %s ${DESC[$i]}\n" ${CMDS[$i]} "${line:${#CMDS[$i]}}";done;echo;};runme(){ if test $NARGS -eq 1;then eval "$ARG1"||usage;else usage;fi;}

version="1.12.6";

make_command "about" "About this update script."
about(){
  echo "Documenso upstream needs some fixing before it can be build in a pure sandbox"
  echo "environment. This script does the following:"
  echo "  - download documenso version ${version} from github in a temp dir"
  echo "  - uninstall inngest-cli which runs a binary download script at build time."
  echo "  - upgrade turborepo as the older upstream version 'phones home' at build time."
  echo "  - update the turbo.json to make it work with preset environment vars"
  echo "  - fix the lockfile by generating missing hash signatures"
  echo "  - create patches from changed json files"
}

make_command "update" "Get upstream and prepatch."
update(){

  echo "updating documenso for nixpkgs packaging"
  current_nixpkgs_dir=${PWD}
  temptarfile=/tmp/documenso-v${version}.tar.gz
  tempdir=/tmp/documenso-v${version}

  if [ ! -f "$temptarfile" ]; then
    echo "Tarball does not exist; downloading from github.";
    wget https://github.com/documenso/documenso/archive/refs/tags/v${version}.tar.gz -O $temptarfile
  fi

  rm -Rf $tempdir
  mkdir $tempdir
  tar -xzvf /tmp/documenso-v${version}.tar.gz -C $tempdir --strip-components=1
  cd $tempdir
  git init
  git add package-lock.json package.json turbo.json
  git commit -m "commit4diff" package-lock.json package.json turbo.json

  echo "rm inngest-cli from root"
  npm uninstall inngest-cli

  npx @turbo/codemod migrate . --force

  jq '.envMode="loose"' turbo.json > turbo-patched.json
  cp turbo-patched.json turbo.json

  echo "fix package-lock.json hashes"
  nix run nixpkgs#npm-lockfile-fix -- package-lock.json

  git diff package-lock.json > $current_nixpkgs_dir/package-lock.json.patch
  git diff package.json > $current_nixpkgs_dir/package.json.patch
  git diff turbo.json > $current_nixpkgs_dir/turbo.json.patch
}

runme