Browse Source

chore: Remove support for deprecated Excalidraw for Desktop (#2465)

Lipis 4 years ago
parent
commit
10e07e434c
4 changed files with 21 additions and 40 deletions
  1. 0 27
      package-lock.json
  2. 2 3
      package.json
  3. 2 0
      public/index.html
  4. 17 10
      scripts/build-version.js

+ 0 - 27
package-lock.json

@@ -4276,27 +4276,6 @@
       "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
       "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
     },
-    "asar": {
-      "version": "3.0.3",
-      "resolved": "https://registry.npmjs.org/asar/-/asar-3.0.3.tgz",
-      "integrity": "sha512-k7zd+KoR+n8pl71PvgElcoKHrVNiSXtw7odKbyNpmgKe7EGRF9Pnu3uLOukD37EvavKwVFxOUpqXTIZC5B5Pmw==",
-      "dev": true,
-      "requires": {
-        "@types/glob": "^7.1.1",
-        "chromium-pickle-js": "^0.2.0",
-        "commander": "^5.0.0",
-        "glob": "^7.1.6",
-        "minimatch": "^3.0.4"
-      },
-      "dependencies": {
-        "commander": {
-          "version": "5.0.0",
-          "resolved": "https://registry.npmjs.org/commander/-/commander-5.0.0.tgz",
-          "integrity": "sha512-JrDGPAKjMGSP1G0DUoaceEJ3DZgAfr/q6X7FVk4+U5KxUSKviYGM2k6zWkfyyBHy5rAtzgYJFa1ro2O9PtoxwQ==",
-          "dev": true
-        }
-      }
-    },
     "asn1": {
       "version": "0.2.4",
       "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
@@ -5699,12 +5678,6 @@
         "tslib": "^1.9.0"
       }
     },
-    "chromium-pickle-js": {
-      "version": "0.2.0",
-      "resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
-      "integrity": "sha1-BKEGZywYsIWrd02YPfo+oTjyIgU=",
-      "dev": true
-    },
     "ci-info": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz",

+ 2 - 3
package.json

@@ -52,7 +52,6 @@
   "devDependencies": {
     "@types/lodash.throttle": "4.1.6",
     "@types/pako": "1.0.1",
-    "asar": "3.0.3",
     "eslint-config-prettier": "7.0.0",
     "eslint-plugin-prettier": "3.3.0",
     "firebase-tools": "8.19.0",
@@ -84,8 +83,8 @@
     "build-node": "node ./scripts/build-node.js",
     "build:app:docker": "REACT_APP_INCLUDE_GTAG=false REACT_APP_DISABLE_SENTRY=true react-scripts build",
     "build:app": "REACT_APP_INCLUDE_GTAG=true REACT_APP_GIT_SHA=$NOW_GITHUB_COMMIT_SHA react-scripts build",
-    "build:zip": "node ./scripts/build-version.js",
-    "build": "npm run build:app && npm run build:zip",
+    "build:version": "node ./scripts/build-version.js",
+    "build": "npm run build:app && npm run build:version",
     "eject": "react-scripts eject",
     "fix:code": "npm run test:code -- --fix",
     "fix:other": "npm run prettier -- --write",

+ 2 - 0
public/index.html

@@ -55,6 +55,8 @@
     <meta name="twitter:image" content="https://excalidraw.com/og-image.png" />
     <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
 
+    <!-- Excalidraw version -->
+    <meta name="version" content="{version}" />
     <link
       rel="preload"
       href="FG_Virgil.woff2"

+ 17 - 10
scripts/build-version.js

@@ -2,7 +2,8 @@
 
 const fs = require("fs");
 const path = require("path");
-const asar = require("asar");
+const versionFile = path.join("build", "version.json");
+const indexFile = path.join("build", "index.html");
 
 const zero = (digit) => `0${digit}`.slice(-2);
 
@@ -20,18 +21,24 @@ const now = new Date();
 
 const data = JSON.stringify(
   {
-    asar: "excalidraw.asar",
     version: versionDate(now),
   },
   undefined,
   2,
 );
 
-fs.writeFileSync(path.join("build", "version.json"), data);
-
-(async () => {
-  const src = "build/";
-  const dest = path.join("build", `excalidraw.asar`);
-
-  await asar.createPackage(src, dest);
-})();
+fs.writeFileSync(versionFile, data);
+
+// https://stackoverflow.com/a/14181136/8418
+fs.readFile(indexFile, "utf8", (error, data) => {
+  if (error) {
+    return console.error(error);
+  }
+  const result = data.replace(/{version}/g, versionDate(now));
+
+  fs.writeFile(indexFile, result, "utf8", (error) => {
+    if (error) {
+      return console.error(error);
+    }
+  });
+});