diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6cbaed3..67c9a0c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/.gitmodules b/.gitmodules index d1e2071..a8dd3b8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/bun.lockb b/bun.lockb index e7c46fb..0013a8d 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/excalidraw b/excalidraw new file mode 160000 index 0000000..b7d7ccc --- /dev/null +++ b/excalidraw @@ -0,0 +1 @@ +Subproject commit b7d7ccc929696cc17b4cc34452e4afd846d59f4f diff --git a/excalidraw.patch b/excalidraw.patch new file mode 100644 index 0000000..e644059 --- /dev/null +++ b/excalidraw.patch @@ -0,0 +1,37 @@ +diff --git a/src/packages/excalidraw/main.js b/src/packages/excalidraw/main.js +index 853bb70f..45883611 100644 +--- a/src/packages/excalidraw/main.js ++++ b/src/packages/excalidraw/main.js +@@ -1,11 +1 @@ +-if (process.env.IS_PREACT === "true") { +- if (process.env.NODE_ENV === "production") { +- module.exports = require("./dist/excalidraw-with-preact.production.min.js"); +- } else { +- module.exports = require("./dist/excalidraw-with-preact.development.js"); +- } +-} else if (process.env.NODE_ENV === "production") { +- module.exports = require("./dist/excalidraw.production.min.js"); +-} else { +- module.exports = require("./dist/excalidraw.development.js"); +-} ++module.exports = require("./dist/excalidraw.production.min.js"); +diff --git a/src/packages/excalidraw/webpack.prod.config.js b/src/packages/excalidraw/webpack.prod.config.js +index 0a2d7faa..01eaf8be 100644 +--- a/src/packages/excalidraw/webpack.prod.config.js ++++ b/src/packages/excalidraw/webpack.prod.config.js +@@ -96,13 +96,11 @@ module.exports = { + test: /\.js($|\?)/i, + }), + ], ++ runtimeChunk: false, + splitChunks: { + chunks: "async", + cacheGroups: { +- vendors: { +- test: /[\\/]node_modules[\\/]/, +- name: "vendor", +- }, ++ default: false, + }, + }, + }, diff --git a/flake.nix b/flake.nix index 2185a1b..cbce3ac 100644 --- a/flake.nix +++ b/flake.nix @@ -58,6 +58,7 @@ base-pkgs = with pkgs; [ bun + yarn nodejs_latest pandoc pandoc-norg-rs.packages.${system}.default diff --git a/package.json b/package.json index 6ebe23f..2afe51c 100644 --- a/package.json +++ b/package.json @@ -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/excalidraw", "@parcel/config-default": "^2.10.0", "@parcel/core": "^2.10.0", "@parcel/plugin": "^2.10.0", @@ -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": { diff --git a/scripts/build-excalidraw.js b/scripts/build-excalidraw.js new file mode 100644 index 0000000..2fce356 --- /dev/null +++ b/scripts/build-excalidraw.js @@ -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/excalidraw"); + +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", ["webpack", "--config", "webpack.prod.config.js"], { + 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;