From fae43e90dad534f4cfdc0b9e23cc150a2db1bed1 Mon Sep 17 00:00:00 2001 From: Lin Onetwo Date: Wed, 4 Jan 2023 17:54:19 +0800 Subject: [PATCH] feat: build affine dist html --- client-app/README.md | 9 ++++ client-app/package.json | 3 +- client-app/scripts/buildAffine.mjs | 28 +++++++++++ pnpm-lock.yaml | 78 ------------------------------ 4 files changed, 39 insertions(+), 79 deletions(-) create mode 100644 client-app/scripts/buildAffine.mjs diff --git a/client-app/README.md b/client-app/README.md index 6f0c61a60..be71ac4c4 100644 --- a/client-app/README.md +++ b/client-app/README.md @@ -18,6 +18,15 @@ Currently client-app depends on a rapidly developing rust library "Octobase", we We will provide its binary binding soon, to replace the git-submodule, before Octobase become opensource. +### Scripts + +On this folder: + +- `pnpm dev:app` will start a vite server +- `pnpm build:prerequisite` will link the Octobase and prepare affine dist html and tauri preload script + +On project root folder: + ### Recommended IDE Setup - [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) diff --git a/client-app/package.json b/client-app/package.json index 5a845ffd9..ebea7939d 100644 --- a/client-app/package.json +++ b/client-app/package.json @@ -7,11 +7,12 @@ "module": "true", "scripts": { "dev:app": "tauri dev", - "build:prerequisite": "pnpm build:submodules && pnpm build:preload", + "build:prerequisite": "pnpm build:submodules && pnpm build:affine && pnpm build:preload", "dev:web": "vite", "build:rs-types": "zx scripts/generateTsTypingsFromJsonSchema.mjs", "build:web": "tsc && vite build", "build:submodules": "zx scripts/buildSubModules.mjs", + "build:affine": "zx scripts/buildAffine.mjs", "build:preload": "esbuild src/preload/index.ts --outdir=public/preload", "build:app": "tauri build", "preview": "vite preview" diff --git a/client-app/scripts/buildAffine.mjs b/client-app/scripts/buildAffine.mjs new file mode 100644 index 000000000..a86521c30 --- /dev/null +++ b/client-app/scripts/buildAffine.mjs @@ -0,0 +1,28 @@ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +const repoDirectory = path.join(__dirname, '..', '..'); +const clientAppDirectory = path.join(__dirname, '..'); +const publicDistributionDirectory = path.join(clientAppDirectory, 'public'); +const affineSrcDirectory = path.join(repoDirectory, 'packages', 'app'); +const affineSrcOutDirectory = path.join(affineSrcDirectory, 'out'); +const publicAffineOutDirectory = path.join( + publicDistributionDirectory, + 'affine-out' +); + +/** + * Build affine dist html + */ +cd(repoDirectory); +await $`pnpm i -r`; +await $`pnpm build`; +cd(affineSrcDirectory); +$.env.BASE_PATH = '/affine-out'; +await $`pnpm build`; +await $`pnpm export`; +await fs.remove(publicAffineOutDirectory); +await fs.move(affineSrcOutDirectory, publicAffineOutDirectory); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 872f60b45..98a575e09 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,9 +44,6 @@ importers: client-app: specifiers: - '@blocksuite/blocks': 0.3.0-alpha.18 - '@blocksuite/editor': 0.3.0-alpha.18 - '@blocksuite/store': 0.3.0-alpha.18 '@emotion/react': ^11.10.5 '@emotion/styled': ^11.10.5 '@tauri-apps/api': ^1.2.0 @@ -94,9 +91,6 @@ importers: yjs: ^13.5.43 zx: ^7.1.1 dependencies: - '@blocksuite/blocks': 0.3.0-alpha.18 - '@blocksuite/editor': 0.3.0-alpha.18 - '@blocksuite/store': 0.3.0-alpha.18 '@emotion/react': 11.10.5_kzbn2opkn2327fwg5yzwzya5o4 '@emotion/styled': 11.10.5_qvatmowesywn4ye42qoh247szu '@tauri-apps/api': 1.2.0 @@ -1608,23 +1602,6 @@ packages: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true - /@blocksuite/blocks/0.3.0-alpha.18: - resolution: {integrity: sha512-1s86UvQj1oG+b0ca0EBwNCW5krtbkAaq4brNITioS+2Q40k1RPO0SOno81E2an7xX3ZepUC+5h4TLAHlR42Qfw==} - dependencies: - '@blocksuite/store': 0.3.0-alpha.18 - '@tldraw/intersect': 1.8.0 - highlight.js: 11.7.0 - hotkeys-js: 3.10.1 - lit: 2.5.0 - perfect-freehand: 1.2.0 - quill: 1.3.7 - quill-cursors: 4.0.0 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - dev: false - /@blocksuite/blocks/0.3.1_yjs@13.5.44: resolution: {integrity: sha512-b0dGz2MG4yIgngJPRumaMY58wAsd2FEVSZl3tpCXlagK9I0HD165Bq70PxcaRHVjBSV1Gf29ZVHUF6BVTYogPw==} dependencies: @@ -1644,20 +1621,6 @@ packages: - yjs dev: false - /@blocksuite/editor/0.3.0-alpha.18: - resolution: {integrity: sha512-GSA9CJCVu2RwFcxzShJtM+lSNXovKz2OzqXn0C0GUJt244Q+HYeJ4Am3djsJy1x+RD454qgqeCU7JTKnSj1ciA==} - dependencies: - '@blocksuite/blocks': 0.3.0-alpha.18 - '@blocksuite/store': 0.3.0-alpha.18 - lit: 2.5.0 - marked: 4.2.5 - turndown: 7.1.1 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - dev: false - /@blocksuite/editor/0.3.1_yjs@13.5.44: resolution: {integrity: sha512-ycKcyvPW6R8R2GZOFneGH1xNi5gJBx5WtWjW9YwcQslFzXVWMCCBips1Bud2uL4kkbWQoodyua6k2vsXxGAKLw==} dependencies: @@ -1683,27 +1646,6 @@ packages: react: 18.2.0 dev: false - /@blocksuite/store/0.3.0-alpha.18: - resolution: {integrity: sha512-1XLV85Qz16gcLSjkiINC4/29OlFLOtcY2KzcmQ3ajhJ/KS9dvnfayt3XWd/Xj0KVcWeDMh87CaIPXohI8sQtJw==} - dependencies: - '@types/flexsearch': 0.7.3 - '@types/quill': 1.3.10 - buffer: 6.0.3 - flexsearch: 0.7.21 - idb-keyval: 6.2.0 - ky: 0.32.2 - lib0: 0.2.58 - sha3: 2.1.4 - y-indexeddb: 9.0.9_yjs@13.5.44 - y-protocols: 1.0.5 - y-webrtc: 10.2.3 - yjs: 13.5.44 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - dev: false - /@blocksuite/store/0.3.1_yjs@13.5.44: resolution: {integrity: sha512-kynVTDfNCSChz2JI2rtGHxRIV2YrLzvAgVajcbfDVCuXKG0siBoEjLasG1a0kvevbvW/FabrNAj+xaIplklioA==} peerDependencies: @@ -8772,11 +8714,6 @@ packages: node-fetch: 3.3.0 dev: false - /ky/0.32.2: - resolution: {integrity: sha512-eBJeF6IXNwX5rksdwBrE2rIJrU2d84GoTvdM7OmmTIwUVXEMd72wIwvT+nyhrqtv7AzbSNsWz7yRsHgVhj1uog==} - engines: {node: '>=14.16'} - dev: false - /ky/0.33.1: resolution: {integrity: sha512-zZ9OlhgM4UEunvgJBH1bBl7+a7vas1HnCLSezu2CJawc4Ka+yJculRAVKbakUece4gW7kC5Dz+UGvbXIlpDt1w==} engines: {node: '>=14.16'} @@ -10457,12 +10394,6 @@ packages: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} dev: true - /sha3/2.1.4: - resolution: {integrity: sha512-S8cNxbyb0UGUM2VhRD4Poe5N58gJnJsLJ5vC7FYWGUmGhcsj4++WaIOBFVDxlG0W3To6xBuiRh+i0Qp2oNCOtg==} - dependencies: - buffer: 6.0.3 - dev: false - /shebang-command/1.2.0: resolution: {integrity: sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==} engines: {node: '>=0.10.0'} @@ -11777,15 +11708,6 @@ packages: object-keys: 0.4.0 dev: false - /y-indexeddb/9.0.9_yjs@13.5.44: - resolution: {integrity: sha512-GcJbiJa2eD5hankj46Hea9z4hbDnDjvh1fT62E5SpZRsv8GcEemw34l1hwI2eknGcv5Ih9JfusT37JLx9q3LFg==} - peerDependencies: - yjs: ^13.0.0 - dependencies: - lib0: 0.2.58 - yjs: 13.5.44 - dev: false - /y-protocols/1.0.5: resolution: {integrity: sha512-Wil92b7cGk712lRHDqS4T90IczF6RkcvCwAD0A2OPg+adKmOe+nOiT/N2hvpQIWS3zfjmtL4CPaH5sIW1Hkm/A==} dependencies: