diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b89826..daa06d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,12 +12,7 @@ concurrency: jobs: build: name: Build - strategy: - fail-fast: true - matrix: - platform: [ubuntu-latest] - runs-on: ${{ matrix.platform }} - + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -29,15 +24,12 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 21 cache: pnpm cache-dependency-path: pnpm-lock.yaml - - name: Install Rust toolchain - run: | - rustup update --no-self-update 1.72.0 - rustup component add --toolchain 1.72.0 rustfmt rust-src - rustup default 1.72.0 + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@stable - run: pnpm install @@ -46,48 +38,18 @@ jobs: sudo apt-get update sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev - - run: echo "PGN_EXTRACT_VERSION=22-11" >> $GITHUB_ENV - - - uses: actions/cache@v3 - id: pgn-extract-cache - with: - path: | - external/pgn-extract - key: pgn-extract-${{ env.PGN_EXTRACT_VERSION }} - - - name: Install pgn-extract - run: make pgn-extract - if: steps.pgn-extract-cache.outputs.cache-hit != 'true' - env: - PGN_EXTRACT_VERSION: ${{ env.PGN_EXTRACT_VERSION }} - - - run: echo "STOCKFISH_VERSION=16" >> $GITHUB_ENV - - - run: echo "STOCKFISH_PLATFORM=ubuntu" >> $GITHUB_ENV - # if: "{{matrix.platform == ubuntu-22.04}}" - - uses: actions/cache@v3 id: stockfish-cache with: path: | external/stockfish - key: stockfish-${{ env.STOCKFISH_VERSION }}-${{ env.STOCKFISH_PLATFORM }} + key: stockfish-${{ env.STOCKFISH_VERSION }}-ubuntu-latest + env: + STOCKFISH_VERSION: 16 - name: Install Stockfish - run: make stockfish + run: node scripts/downloadStockfish.js if: steps.stockfish-cache.outputs.cache-hit != 'true' - env: - PGN_EXTRACT_VERSION: ${{ env.PGN_EXTRACT_VERSION }} - STOCKFISH_VERSION: ${{ env.STOCKFISH_VERSION }} - STOCKFISH_PLATFORM: ${{ env.STOCKFISH_PLATFORM }} - - # - name: Mock bundled binaries - # run: | - # mkdir external - # mkdir -p src-tauri/bin - # touch external/stockfish - # touch external/pgn-extract - # node scripts/generateTargetTriple.js - name: Generate Target Triple run: | @@ -98,15 +60,6 @@ jobs: with: workspaces: src-tauri -> target - - name: Build application - run: pnpm tauri build --ci - - - uses: actions/upload-artifact@v3 - with: - name: release-ubuntu-deb - path: src-tauri/target/release/bundle/deb/openchess_0.0.0_amd64.deb - - - uses: actions/upload-artifact@v3 - with: - name: release-ubuntu-appimage - path: src-tauri/target/release/bundle/appimage/openchess_0.0.0_amd64.AppImage + - uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bbb663a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +name: Release + +on: + workflow_dispatch: + +jobs: + release: + permissions: + contents: write + strategy: + fail-fast: false + matrix: + platform: [ubuntu-20.04, windows-latest, macos-latest] + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: 8 + run_install: false + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 21 + cache: pnpm + cache-dependency-path: pnpm-lock.yaml + + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Install OS dependencies + if: matrix.platform == 'ubuntu-20.04' + run: | + sudo apt-get update + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev + + - name: Install frontend dependencies + run: pnpm install + + - uses: actions/cache@v3 + id: stockfish-cache + with: + path: | + external/stockfish + key: stockfish-${{ env.STOCKFISH_VERSION }}-${{ matrix.platform }} + env: + STOCKFISH_VERSION: 16 + + - name: Install Stockfish + run: node scripts/downloadStockfish.js + if: steps.stockfish-cache.outputs.cache-hit != 'true' + + - name: Generate Target Triples + run: | + mkdir src-tauri/bin + node scripts/generateTargetTriple.js + + - uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tagName: v__VERSION__ + releaseName: OpenChess v__VERSION__ + releaseDraft: true + prerelease: true diff --git a/Makefile b/Makefile index 2ac645b..e4d8641 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,3 @@ pgn-extract: cd external/pgn-extract-$(PGN_EXTRACT_VERSION) && make pgn-extract mv -f external/pgn-extract-$(PGN_EXTRACT_VERSION)/pgn-extract external rm -rf external/pgn-extract-$(PGN_EXTRACT_VERSION) - -stockfish: - mkdir -p external - rm -f external/stockfish - curl -fsSL https://github.com/official-stockfish/Stockfish/releases/download/sf_${STOCKFISH_VERSION}/stockfish-$(STOCKFISH_PLATFORM)-x86-64-modern.tar --output external/stockfish.tar - tar -xf external/stockfish.tar -C external - mv -f external/stockfish/stockfish-$(STOCKFISH_PLATFORM)-x86-64-modern external - rm -rf external/stockfish - mv -f external/stockfish-$(STOCKFISH_PLATFORM)-x86-64-modern external/stockfish - rm -f external/stockfish.tar diff --git a/package.json b/package.json index 064c037..a83c01d 100644 --- a/package.json +++ b/package.json @@ -53,10 +53,12 @@ "@vue/eslint-config-typescript": "^12.0.0", "@vue/typescript": "^1.8.20", "autoprefixer": "^10.4.16", + "cpu-features": "^0.0.9", "dotenv": "^16.3.1", "eslint": "^8.54.0", "eslint-plugin-vue": "^9.18.1", "execa": "^8.0.1", + "follow-redirects": "^1.15.3", "happy-dom": "^12.10.3", "kysely-codegen": "^0.11.0", "postcss": "^8.4.31", @@ -64,8 +66,10 @@ "prettier-plugin-organize-imports": "^3.2.4", "prettier-plugin-tailwindcss": "^0.5.7", "tailwindcss": "^3.3.5", + "tar": "^6.2.0", "typescript": "^5.3.2", "unplugin-vue-router": "^0.7.0", + "unzipper": "^0.10.14", "vite": "^5.0.2", "vite-plugin-vue-layouts": "^0.8.0", "vite-tsconfig-paths": "^4.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1cb9fb9..de50168 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -52,7 +52,7 @@ dependencies: version: 1.2.2(vue@3.3.9) tauri-plugin-sql-api: specifier: github:tauri-apps/tauri-plugin-sql#v1 - version: github.com/tauri-apps/tauri-plugin-sql/3c58961a8bc9e13c240f186bc78bf103ed1d8133 + version: github.com/tauri-apps/tauri-plugin-sql/0ff47f365d6f331c78bc75ed90a2246e0d4a8b39 uci-parser-ts: specifier: ^0.1.4 version: 0.1.4(happy-dom@12.10.3) @@ -103,6 +103,9 @@ devDependencies: autoprefixer: specifier: ^10.4.16 version: 10.4.16(postcss@8.4.31) + cpu-features: + specifier: ^0.0.9 + version: 0.0.9 dotenv: specifier: ^16.3.1 version: 16.3.1 @@ -115,6 +118,9 @@ devDependencies: execa: specifier: ^8.0.1 version: 8.0.1 + follow-redirects: + specifier: ^1.15.3 + version: 1.15.3 happy-dom: specifier: ^12.10.3 version: 12.10.3 @@ -136,12 +142,18 @@ devDependencies: tailwindcss: specifier: ^3.3.5 version: 3.3.5 + tar: + specifier: ^6.2.0 + version: 6.2.0 typescript: specifier: ^5.3.2 version: 5.3.2 unplugin-vue-router: specifier: ^0.7.0 version: 0.7.0(vue-router@4.2.5)(vue@3.3.9) + unzipper: + specifier: ^0.10.14 + version: 0.10.14 vite: specifier: ^5.0.2 version: 5.0.2(@types/node@20.10.0) @@ -969,6 +981,11 @@ packages: engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} dev: false + /@tauri-apps/api@1.5.3: + resolution: {integrity: sha512-zxnDjHHKjOsrIzZm6nO5Xapb/BxqUq1tc7cGkFXsFkGTsSWgCPH1D8mm0XS9weJY2OaR73I3k3S+b7eSzJDfqA==} + engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} + dev: false + /@tauri-apps/cli-darwin-arm64@1.5.6: resolution: {integrity: sha512-NNvG3XLtciCMsBahbDNUEvq184VZmOveTGOuy0So2R33b/6FDkuWaSgWZsR1mISpOuP034htQYW0VITCLelfqg==} engines: {node: '>= 10'} @@ -1807,6 +1824,13 @@ packages: engines: {node: '>=8'} dev: true + /binary@0.3.0: + resolution: {integrity: sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg==} + dependencies: + buffers: 0.1.1 + chainsaw: 0.1.0 + dev: true + /bindings@1.5.0: resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} dependencies: @@ -1819,6 +1843,10 @@ packages: inherits: 2.0.4 readable-stream: 3.6.2 + /bluebird@3.4.7: + resolution: {integrity: sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==} + dev: true + /body-parser@1.20.1: resolution: {integrity: sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} @@ -1890,12 +1918,27 @@ packages: resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} dev: true + /buffer-indexof-polyfill@1.0.2: + resolution: {integrity: sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==} + engines: {node: '>=0.10'} + dev: true + /buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} dependencies: base64-js: 1.5.1 ieee754: 1.2.1 + /buffers@0.1.1: + resolution: {integrity: sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==} + engines: {node: '>=0.2.0'} + dev: true + + /buildcheck@0.0.6: + resolution: {integrity: sha512-8f9ZJCUXyT1M35Jx7MkBgmBMo3oHTTBIPLiY9xyL0pl3T5RwcPEY8cUHr5LBNfu/fk6c2T4DJZuVM/8ZZT2D2A==} + engines: {node: '>=10.0.0'} + dev: true + /bundle-name@3.0.0: resolution: {integrity: sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==} engines: {node: '>=12'} @@ -1979,6 +2022,12 @@ packages: pathval: 1.1.1 type-detect: 4.0.8 + /chainsaw@0.1.0: + resolution: {integrity: sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ==} + dependencies: + traverse: 0.3.9 + dev: true + /chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -2029,6 +2078,11 @@ packages: /chownr@1.1.4: resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} + /chownr@2.0.0: + resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} + engines: {node: '>=10'} + dev: true + /cliui@7.0.4: resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} dependencies: @@ -2113,6 +2167,10 @@ packages: engines: {node: '>= 0.6'} dev: true + /core-util-is@1.0.3: + resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} + dev: true + /cors@2.8.5: resolution: {integrity: sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==} engines: {node: '>= 0.10'} @@ -2121,6 +2179,15 @@ packages: vary: 1.1.2 dev: true + /cpu-features@0.0.9: + resolution: {integrity: sha512-AKjgn2rP2yJyfbepsmLfiYcmtNn/2eUvocUyM/09yB0YDiz39HteK/5/T4Onf0pmdYDMgkBoGvRLvEguzyL7wQ==} + engines: {node: '>=10.0.0'} + requiresBuild: true + dependencies: + buildcheck: 0.0.6 + nan: 2.18.0 + dev: true + /cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} @@ -2306,6 +2373,12 @@ packages: engines: {node: '>=12'} dev: true + /duplexer2@0.1.4: + resolution: {integrity: sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==} + dependencies: + readable-stream: 2.3.8 + dev: true + /duplexer3@0.1.5: resolution: {integrity: sha512-1A8za6ws41LQgv9HrE/66jyC5yuSjQ3L/KOpFtoBilsAK2iA2wuS5rTt1OCzIvtS2V7nVmedsUU+DGRcjBmOYA==} dev: true @@ -3028,6 +3101,16 @@ packages: resolution: {integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==} dev: true + /follow-redirects@1.15.3: + resolution: {integrity: sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + dev: true + /foreground-child@2.0.0: resolution: {integrity: sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==} engines: {node: '>=8.0.0'} @@ -3062,6 +3145,13 @@ packages: universalify: 0.1.2 dev: true + /fs-minipass@2.1.0: + resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} + engines: {node: '>= 8'} + dependencies: + minipass: 3.3.6 + dev: true + /fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} @@ -3080,6 +3170,16 @@ packages: requiresBuild: true optional: true + /fstream@1.0.12: + resolution: {integrity: sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==} + engines: {node: '>=0.6'} + dependencies: + graceful-fs: 4.2.11 + inherits: 2.0.4 + mkdirp: 0.5.6 + rimraf: 2.7.1 + dev: true + /function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} @@ -3486,6 +3586,10 @@ packages: is-docker: 2.2.1 dev: true + /isarray@1.0.0: + resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} + dev: true + /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} @@ -3627,6 +3731,10 @@ packages: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} dev: true + /listenercount@1.0.1: + resolution: {integrity: sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ==} + dev: true + /local-pkg@0.4.3: resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==} engines: {node: '>=14'} @@ -3796,9 +3904,42 @@ packages: /minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + /minipass@3.3.6: + resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} + engines: {node: '>=8'} + dependencies: + yallist: 4.0.0 + dev: true + + /minipass@5.0.0: + resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==} + engines: {node: '>=8'} + dev: true + + /minizlib@2.1.2: + resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} + engines: {node: '>= 8'} + dependencies: + minipass: 3.3.6 + yallist: 4.0.0 + dev: true + /mkdirp-classic@0.5.3: resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} + /mkdirp@0.5.6: + resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} + hasBin: true + dependencies: + minimist: 1.2.8 + dev: true + + /mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + dev: true + /mlly@1.4.2: resolution: {integrity: sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==} dependencies: @@ -3835,6 +3976,10 @@ packages: thenify-all: 1.6.0 dev: true + /nan@2.18.0: + resolution: {integrity: sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==} + dev: true + /nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -4325,6 +4470,10 @@ packages: react-is: 18.2.0 dev: true + /process-nextick-args@2.0.1: + resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + dev: true + /progress@2.0.3: resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} engines: {node: '>=0.4.0'} @@ -4411,6 +4560,18 @@ packages: pify: 2.3.0 dev: true + /readable-stream@2.3.8: + resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} + dependencies: + core-util-is: 1.0.3 + inherits: 2.0.4 + isarray: 1.0.0 + process-nextick-args: 2.0.1 + safe-buffer: 5.1.2 + string_decoder: 1.1.1 + util-deprecate: 1.0.2 + dev: true + /readable-stream@3.6.2: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} @@ -4466,6 +4627,13 @@ packages: engines: {iojs: '>=1.0.0', node: '>=0.10.0'} dev: true + /rimraf@2.7.1: + resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==} + hasBin: true + dependencies: + glob: 7.2.3 + dev: true + /rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} hasBin: true @@ -4535,6 +4703,10 @@ packages: queue-microtask: 1.2.3 dev: true + /safe-buffer@5.1.2: + resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} + dev: true + /safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} @@ -4615,6 +4787,10 @@ packages: has-property-descriptors: 1.0.1 dev: true + /setimmediate@1.0.5: + resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==} + dev: true + /setprototypeof@1.2.0: resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==} dev: true @@ -4761,6 +4937,12 @@ packages: strip-ansi: 6.0.1 dev: false + /string_decoder@1.1.1: + resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} + dependencies: + safe-buffer: 5.1.2 + dev: true + /string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} dependencies: @@ -4894,6 +5076,18 @@ packages: inherits: 2.0.4 readable-stream: 3.6.2 + /tar@6.2.0: + resolution: {integrity: sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==} + engines: {node: '>=10'} + dependencies: + chownr: 2.0.0 + fs-minipass: 2.1.0 + minipass: 5.0.0 + minizlib: 2.1.2 + mkdirp: 1.0.4 + yallist: 4.0.0 + dev: true + /test-exclude@6.0.0: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} @@ -4970,6 +5164,10 @@ packages: engines: {node: '>=0.6'} dev: true + /traverse@0.3.9: + resolution: {integrity: sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==} + dev: true + /ts-api-utils@1.0.3(typescript@5.3.2): resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==} engines: {node: '>=16.13.0'} @@ -5126,6 +5324,21 @@ packages: engines: {node: '>=8'} dev: true + /unzipper@0.10.14: + resolution: {integrity: sha512-ti4wZj+0bQTiX2KmKWuwj7lhV+2n//uXEotUmGuQqrbVZSEGFMbI68+c6JCQ8aAmUWYvtHEz2A8K6wXvueR/6g==} + dependencies: + big-integer: 1.6.52 + binary: 0.3.0 + bluebird: 3.4.7 + buffer-indexof-polyfill: 1.0.2 + duplexer2: 0.1.4 + fstream: 1.0.12 + graceful-fs: 4.2.11 + listenercount: 1.0.1 + readable-stream: 2.3.8 + setimmediate: 1.0.5 + dev: true + /update-browserslist-db@1.0.13(browserslist@4.22.1): resolution: {integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==} hasBin: true @@ -5651,10 +5864,10 @@ packages: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} dev: false - github.com/tauri-apps/tauri-plugin-sql/3c58961a8bc9e13c240f186bc78bf103ed1d8133: - resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-sql/tar.gz/3c58961a8bc9e13c240f186bc78bf103ed1d8133} + github.com/tauri-apps/tauri-plugin-sql/0ff47f365d6f331c78bc75ed90a2246e0d4a8b39: + resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-sql/tar.gz/0ff47f365d6f331c78bc75ed90a2246e0d4a8b39} name: tauri-plugin-sql-api version: 0.0.0 dependencies: - '@tauri-apps/api': 1.5.1 + '@tauri-apps/api': 1.5.3 dev: false diff --git a/scripts/downloadStockfish.js b/scripts/downloadStockfish.js new file mode 100644 index 0000000..ffbdcba --- /dev/null +++ b/scripts/downloadStockfish.js @@ -0,0 +1,121 @@ +/* eslint-env node */ +import cpuFeatures from "cpu-features"; +import fd from "follow-redirects"; +import fs from "fs"; +import tar from "tar"; +import unzipper from "unzipper"; + +function getPlatform() { + const platform = process.platform; + if (platform === "win32") { + return "windows"; + } + if (platform === "darwin") { + return "macos"; + } + if (platform === "linux") { + return "ubuntu"; + } + throw new Error(`Unsupported platform: ${platform}`); +} + +function getCpuArchitecture() { + const features = cpuFeatures(); + if (features.flags.avx2) { + return "avx2"; + } + return "modern"; +} + +const STOCKFISH_VERSION = "16"; +const STOCKFISH_PLATFORM = getPlatform(); +const STOCKFISH_CPU_ARCHITECTURE = getCpuArchitecture(); + +const STOCKFISH_ARCHIVE_EXTENSION = STOCKFISH_PLATFORM === "windows" ? ".zip" : ".tar"; +const STOCKFISH_FILE_EXTENSION = STOCKFISH_PLATFORM === "windows" ? ".exe" : ""; +const STOCKFISH_FILENAME = `stockfish-${STOCKFISH_PLATFORM}-x86-64-${STOCKFISH_CPU_ARCHITECTURE}`; +const STOCKFISH_DOWNLOAD_BASE_URL = `https://github.com/official-stockfish/Stockfish/releases/download/sf_${STOCKFISH_VERSION}`; +const STOCKFISH_DOWNLOAD_URL = `${STOCKFISH_DOWNLOAD_BASE_URL}/${STOCKFISH_FILENAME}${STOCKFISH_ARCHIVE_EXTENSION}`; +const STOCKFISH_DOWNLOAD_PATH = `external/stockfish${STOCKFISH_ARCHIVE_EXTENSION}`; +const STOCKFISH_BINARY_PATH = `external/stockfish${STOCKFISH_FILE_EXTENSION}`; + +const stockfishBinaryFilter = (path) => path.includes(`${STOCKFISH_FILENAME}${STOCKFISH_FILE_EXTENSION}`); + +function renameAndCleanup() { + console.log("Cleaning up"); + if (fs.existsSync("external/stockfish")) { + const stockfishBinary = fs.readdirSync("external/stockfish")[0]; + fs.copyFileSync(`external/stockfish/${stockfishBinary}`, `external/${stockfishBinary}`); + fs.rmSync(STOCKFISH_BINARY_PATH, { recursive: true, force: true }); + fs.renameSync(`external/${stockfishBinary}`, `external/stockfish${STOCKFISH_FILE_EXTENSION}`); + } + if (fs.existsSync(STOCKFISH_DOWNLOAD_PATH)) { + fs.unlinkSync(STOCKFISH_DOWNLOAD_PATH); + } +} + +function parseArchive(readStream) { + if (STOCKFISH_ARCHIVE_EXTENSION === ".zip") { + console.log("Extracting zip archive"); + readStream.pipe(unzipper.Parse()).on("entry", (entry) => { + if (stockfishBinaryFilter(entry.path)) { + entry.pipe( + fs.createWriteStream(`external/stockfish${STOCKFISH_FILE_EXTENSION}`).on("finish", renameAndCleanup) + ); + } else { + entry.autodrain(); + } + }); + } else if (STOCKFISH_ARCHIVE_EXTENSION === ".tar") { + console.log("Extracting tar archive"); + readStream + .pipe( + tar.x({ + cwd: "external", + filter: stockfishBinaryFilter, + }) + ) + .on("error", (error) => { + if (error) throw error; + }) + .on("finish", () => { + console.log("Finished extracting tar archive"); + renameAndCleanup(); + }); + } else { + throw new Error(`Unsupported archive extension: ${STOCKFISH_ARCHIVE_EXTENSION}`); + } +} + +async function main() { + if (!fs.existsSync("external")) { + fs.mkdirSync("external"); + } + if (fs.existsSync(STOCKFISH_BINARY_PATH)) { + console.log("Deleting old stockfish binary"); + fs.unlinkSync(STOCKFISH_BINARY_PATH); + } + + console.log("Creating write stream"); + const writeStream = fs.createWriteStream(STOCKFISH_DOWNLOAD_PATH); + const request = fd.https.get(STOCKFISH_DOWNLOAD_URL, (response) => { + console.log(`Downloading from ${STOCKFISH_DOWNLOAD_URL}`); + response.pipe(writeStream); + }); + + request.on("error", (error) => { + fs.unlink(STOCKFISH_DOWNLOAD_PATH); + if (error) throw error; + }); + writeStream.on("finish", function () { + console.log("Finished downloading"); + writeStream.close(); + + const readStream = fs.createReadStream(STOCKFISH_DOWNLOAD_PATH); + parseArchive(readStream); + }); +} + +main().catch((error) => { + console.error(error); +}); diff --git a/scripts/generateTargetTriple.js b/scripts/generateTargetTriple.js index 9b614fb..48278a9 100644 --- a/scripts/generateTargetTriple.js +++ b/scripts/generateTargetTriple.js @@ -14,7 +14,7 @@ async function main() { console.error("Failed to determine platform target triple"); } copyFileSync(`external/stockfish${extension}`, `src-tauri/bin/stockfish-${targetTriple}${extension}`); - copyFileSync(`external/pgn-extract${extension}`, `src-tauri/bin/pgn-extract-${targetTriple}${extension}`); + // copyFileSync(`external/pgn-extract${extension}`, `src-tauri/bin/pgn-extract-${targetTriple}${extension}`); } main().catch((e) => { diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 6f2919d..185d043 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -9,7 +9,7 @@ use std::path; fn main() { let app_data_path = - path::Path::new(&tauri::api::path::local_data_dir().unwrap()).join("com.openchess.dev"); + path::Path::new(&tauri::api::path::data_dir().unwrap()).join("com.openchess.dev"); let database_path = app_data_path.join("db.sqlite"); assert!( app_data_path.exists() || std::fs::create_dir(&app_data_path).is_ok(), @@ -23,7 +23,9 @@ fn main() { .unwrap_or_else(|| panic!("Error convert path {:?} to url", database_path)); let mut connection = SqliteConnection::establish(&database_url) .unwrap_or_else(|_| panic!("Error connecting to {}", &database_url)); - connection.run_pending_migrations(MIGRATIONS).unwrap(); + connection + .run_pending_migrations(MIGRATIONS) + .unwrap_or_else(|_| panic!("Migrations could not be ran")); tauri::Builder::default() .plugin(tauri_plugin_sql::Builder::default().build()) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index b50b699..59b9fb6 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,8 +7,8 @@ "withGlobalTauri": false }, "package": { - "productName": "openchess", - "version": "0.0.0" + "productName": "OpenChess", + "version": "0.0.1" }, "tauri": { "allowlist": { @@ -43,8 +43,7 @@ "depends": [] }, "externalBin": [ - "bin/stockfish", - "bin/pgn-extract" + "bin/stockfish" ], "icon": [ "icons/32x32.png", @@ -82,7 +81,7 @@ "fullscreen": false, "height": 600, "resizable": true, - "title": "openchess", + "title": "OpenChess", "width": 800 } ] diff --git a/src/components/GameChessboard.vue b/src/components/GameChessboard.vue index 0deee41..bf2588f 100644 --- a/src/components/GameChessboard.vue +++ b/src/components/GameChessboard.vue @@ -1,30 +1,20 @@