Skip to content

Commit

Permalink
FIX EXCALIDRAW I SWEAR
Browse files Browse the repository at this point in the history
  • Loading branch information
JCapucho committed Dec 11, 2023
1 parent c578844 commit 327a337
Show file tree
Hide file tree
Showing 9 changed files with 572 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: false
- name: Checkout excalidraw
run: git submodule update --init excalidraw
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Setup Nix Cache
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "MAS/Projeto (site)"]
path = MAS/Projeto (site)
url = https://github.com/JCapucho/mas-projeto-final.git
[submodule "excalidraw"]
path = excalidraw
url = https://github.com/excalidraw/excalidraw.git
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions excalidraw
Submodule excalidraw added at b7d7cc
488 changes: 488 additions & 0 deletions excalidraw.patch

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

base-pkgs = with pkgs; [
bun
yarn
nodejs_latest
pandoc
pandoc-norg-rs.packages.${system}.default
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"scripts": {
"dev": "parcel index.eta",
"build": "parcel build index.eta",
"index": "pagefind --site dist"
"index": "pagefind --site dist",
"postinstall": "bun ./scripts/build-excalidraw.js"
},
"staticFiles": {
"staticPath": "public"
},
"devDependencies": {
"@excalidraw/excalidraw": "^0.17.2",
"@excalidraw/excalidraw": "file:./excalidraw/src/packages/utils",
"@parcel/config-default": "^2.10.0",
"@parcel/core": "^2.10.0",
"@parcel/plugin": "^2.10.0",
Expand All @@ -27,6 +28,7 @@
"posthtml": "^0.16.6",
"posthtml-parser": "^0.11.0",
"posthtml-toc": "posthtml/posthtml-toc#0c19ee4de97c5985fda86550d0590e29074191d4",
"rewire": "^7.0.0",
"tailwindcss": "^3.3.3"
},
"dependencies": {
Expand Down
3 changes: 3 additions & 0 deletions plugins/excalidrawSetupDom.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ import "global-jsdom/register";
import excalidrawPkg from "@excalidraw/excalidraw/package.json" assert { type: "json" };
const excalidrawAssets = `https://unpkg.com/@excalidraw/excalidraw@${excalidrawPkg.version}`;

const localDistUrl = import.meta.resolve("@excalidraw/excalidraw/dist");

global.Path2D = Path2D;
global.window.EXCALIDRAW_ASSET_PATH = excalidrawAssets;
global.window.EXCALIDRAW_WEBPACK_ASSET_PATH = localDistUrl + "/";
68 changes: 68 additions & 0 deletions scripts/build-excalidraw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import path from "node:path";
import { fileURLToPath } from "node:url";
import { spawnSync } from "node:child_process";

const __dirname = path.dirname(fileURLToPath(import.meta.url));
export const project_root = path.join(__dirname, "..");

const excalidrawDir = path.join(project_root, "excalidraw");
const excalidrawPkgDir = path.join(excalidrawDir, "src/packages/utils");

const gitRevCheck = spawnSync(
"git",
[
"apply",
"--reverse",
"--check",
path.join(project_root, "excalidraw.patch"),
],
{
cwd: excalidrawDir,
},
);

if (gitRevCheck.status != 0) {
spawnSync("git", ["apply", path.join(project_root, "excalidraw.patch")], {
cwd: excalidrawDir,
stdio: "inherit",
});
} else {
console.error("Excalidraw patch already applied");
}

let res = spawnSync("yarn", ["--frozen-lockfile"], {
stdio: "inherit",
cwd: excalidrawDir,
});

if (res.error) throw res.error;

res = spawnSync("yarn", ["--frozen-lockfile"], {
stdio: "inherit",
cwd: excalidrawPkgDir,
});

if (res.error) throw res.error;

res = spawnSync("rm", ["-rf", "dist"], {
stdio: "inherit",
cwd: excalidrawPkgDir,
});

if (res.error) throw res.error;

res = spawnSync("yarn", ["run", "build:umd"], {
stdio: "inherit",
cwd: excalidrawPkgDir,
env: {
NODE_ENV: "production",
},
});

if (res.error) throw res.error;

res = spawnSync("bun", ["install", "--ignore-scripts", "--frozen-lockfile"], {
stdio: "inherit",
});

if (res.error) throw res.error;

0 comments on commit 327a337

Please sign in to comment.