diff --git a/.github/asset.js b/.github/asset.js new file mode 100644 index 0000000..c499ffd --- /dev/null +++ b/.github/asset.js @@ -0,0 +1,33 @@ +const fs = require('fs'); + +console.log(process.argv); + +let github_event = JSON.parse(fs.readFileSync(process.argv[3]).toString()); + +let token = process.argv[2]; +let id = github_event.release.id; +let repo = process.argv[4]; +let filename = process.argv[5]; +let filetype = process.argv[6] || 'application/octet-stream'; +let length = fs.statSync(filename).size; + +let cmd = 'curl -v -X POST' + + ' -H "Authorization: token ' + token + '"' + + ' -H "Content-Length: ' + length + '"' + + ' -H "Content-Type: ' + filetype + '"' + + ' --upload-file ' + filename + + ' https://uploads.github.com/repos/' + repo + '/releases/' + id + '/assets?name=' + filename; + +console.log(cmd.replace(token, 'b2c736a8de4c71f45429acc0775671d9b5e452c3')); + +var exec = require('child_process').exec; + +exec(cmd, function(error, stdout, stderr) { + if(error){ + console.error(error); + } + else{ + console.log("curl success, stdout:\n" + stdout); + } +}); + diff --git a/.github/tag.js b/.github/tag.js new file mode 100644 index 0000000..85d81b9 --- /dev/null +++ b/.github/tag.js @@ -0,0 +1,56 @@ +const fs = require('fs'); + +let alltext = fs.readFileSync(__dirname + '/doc/release-notes.txt').toString(); +let packagefile = JSON.parse(fs.readFileSync(__dirname + '/package.json').toString()); +alltext = alltext.replace(/\r/g, ''); +let text = ''; +let package_version = 'v' + packagefile.version; +let version = ''; +for (let i = 0; i < alltext.length; i ++ ){ + if (alltext[i] == '\n' && version.length == 0) + version = 'v' + alltext.slice(0, i); + if (alltext[i] == '\n' && alltext[i + 1] == '\n'){ + text = alltext.slice(0, i); + break; + } +} + +if (package_version != version){ + console.error('version differ!', package_version, version); + process.exit(1); +} + +version = package_version; + +let result = { + "tag_name": version, + "target_commitish": "master", + "name": version, + "body": text, + "draft": false, + "prerelease": false +}; + +result = JSON.stringify(result); + +let token = process.argv[2]; +let repo = process.argv[3]; + +let cmd = 'curl -X POST -H "Authorization: token ' + token + '"' + + ' --data ' + "'" + result + "'" + + ' https://api.github.com/repos/' + repo + '/releases'; + +console.log(cmd.replace(token, 'b2c736a8de4c71f45429acc0775671d9b5e452c3')); + +var exec = require('child_process').exec; + +exec(cmd, function(error, stdout, stderr) { + if(error){ + console.error(error); + process.exit(1); + } + else{ + console.log("curl success, stdout:\n" + stdout); + } +}); + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7a9f373 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: master CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: windows-latest + + strategy: + matrix: + node-version: [10.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm + run: | + npm ci + npm run-script package-win + - name: cmake + run: | + git submodule update --init --recursive + mkdir bin + mkdir bin/release + cd bin/release + cmake ../.. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" + make -j + - name: collect + run: | + cp -r dist/MajsoulPaipuCrawler-win32-x64 result + cp bin/release/PaipuAnalyzer.exe result/ + mkdir result/data + cp config.json result/ + cp PAADData.json result/ + cp doc/README.txt result/ + cp doc/release-notes.txt result/ + cp -r i18n/ result/ + mv result MajsoulPaipuAnalyzer-win-x64 + - name: archive + run: 7z a MajsoulPaipuAnalyzer-win-x64.7z MajsoulPaipuAnalyzer-win-x64 -m0=LZMA2 -mmt + - uses: actions/upload-artifact@v2 + with: + name: MajsoulPaipuAnalyzer-win-x64.7z + path: MajsoulPaipuAnalyzer-win-x64.7z + # - name: check GITHUB_EVENT_PATH + # run: echo $env:GITHUB_EVENT_PATH; echo `cat $env:GITHUB_EVENT_PATH` diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..6e59335 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,59 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Linux CI + +on: + release: + types: [published] + +jobs: + build: + if: "!github.event.release.prerelease" + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm + run: | + npm ci + npm run-script package-linux + - name: cmake + run: | + git submodule update --init --recursive + mkdir bin + mkdir bin/release + cd bin/release + cmake ../.. -DCMAKE_BUILD_TYPE=Release + make -j + - name: collect + run: | + cp -r dist/MajsoulPaipuCrawler-linux-x64 result + cp bin/release/PaipuAnalyzer result/ + mkdir result/data + cp config.json result/ + cp PAADData.json result/ + cp doc/README.txt result/ + cp doc/release-notes.txt result/ + cp -r i18n/ result/ + mv result MajsoulPaipuAnalyzer-linux-x64 + - name: archive + run: 7z a MajsoulPaipuAnalyzer-linux-x64.7z MajsoulPaipuAnalyzer-linux-x64 -m0=LZMA2 -mmt + # - uses: actions/upload-artifact@v2 + # with: + # name: MajsoulPaipuAnalyzer-linux-x64.7z + # path: MajsoulPaipuAnalyzer-linux-x64.7z + # - name: fake artifact + # run: mv result.html MajsoulPaipuAnalyzer-linux-x64.7z + - name: Upload to release + run: | + cp .github/asset.js . + node asset.js ${{ secrets.ACCESS_TOKEN }} $GITHUB_EVENT_PATH $GITHUB_REPOSITORY MajsoulPaipuAnalyzer-linux-x64.7z application/octet_stream \ No newline at end of file diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..aa58445 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,55 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: MacOS CI + +on: + release: + types: [published] + +jobs: + build: + if: "!github.event.release.prerelease" + runs-on: macOS-latest + + strategy: + matrix: + node-version: [10.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm + run: | + npm ci + npm run-script package-darwin + - name: cmake + run: | + git submodule update --init --recursive + mkdir bin + mkdir bin/release + cd bin/release + cmake ../.. -DCMAKE_BUILD_TYPE=Release + make -j + - name: collect + run: | + cp -r dist/MajsoulPaipuCrawler-darwin-x64 result + cp bin/release/PaipuAnalyzer result/ + mkdir result/data + cp config.json result/ + cp PAADData.json result/ + cp doc/README.txt result/ + cp doc/release-notes.txt result/ + cp -r i18n/ result/ + mv result MajsoulPaipuAnalyzer-macos-x64 + - name: archive + run: | + brew install p7zip + 7z a MajsoulPaipuAnalyzer-macos-x64.7z MajsoulPaipuAnalyzer-macos-x64 -m0=LZMA2 -mmt + - name: Upload to release + run: | + cp .github/asset.js . + node asset.js ${{ secrets.ACCESS_TOKEN }} $GITHUB_EVENT_PATH $GITHUB_REPOSITORY MajsoulPaipuAnalyzer-macos-x64.7z application/octet_stream \ No newline at end of file diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..41770a6 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: New Tag + +on: + push: + tags: + - '*' + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + # - name: check GITHUB_EVENT_PATH + # run: echo $GITHUB_EVENT_PATH; echo `cat $GITHUB_EVENT_PATH` + - name: update tag + run: | + cp .github/tag.js . + node tag.js ${{ secrets.ACCESS_TOKEN }} $GITHUB_REPOSITORY \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..9e63016 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,55 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Windows CI + +on: + release: + types: [ published ] + +jobs: + build: + if: "!github.event.release.prerelease" + runs-on: windows-latest + + strategy: + matrix: + node-version: [10.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm + run: | + npm ci + npm run-script package-win + - name: cmake + run: | + git submodule update --init --recursive + mkdir bin + mkdir bin/release + cd bin/release + cmake ../.. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" + make -j + - name: collect + run: | + cp -r dist/MajsoulPaipuCrawler-win32-x64 result + cp bin/release/PaipuAnalyzer.exe result/ + mkdir result/data + cp config.json result/ + cp PAADData.json result/ + cp doc/README.txt result/ + cp doc/release-notes.txt result/ + cp -r i18n/ result/ + mv result MajsoulPaipuAnalyzer-win-x64 + - name: archive + run: 7z a MajsoulPaipuAnalyzer-win-x64.7z MajsoulPaipuAnalyzer-win-x64 -m0=LZMA2 -mmt + - name: Upload to release + run: | + echo $GITHUB_EVENT_PATH $GITHUB_REPOSITORY + echo $env:GITHUB_EVENT_PATH $env:GITHUB_REPOSITORY + cp .github/asset.js . + node asset.js ${{ secrets.ACCESS_TOKEN }} $env:GITHUB_EVENT_PATH $env:GITHUB_REPOSITORY MajsoulPaipuAnalyzer-win-x64.7z application/octet_stream \ No newline at end of file diff --git a/lib/config.js b/lib/config.js index 1ffd9f9..46dbbd5 100644 --- a/lib/config.js +++ b/lib/config.js @@ -7,9 +7,9 @@ const request = require('request'); const { version, repository } = require('../package.json'); const defaultconfig = { - DefaultURL: 'https://www.majsoul.com/1/', - PaipuMinVersion: '0.3.0', - ConfigMinVersion: '0.3.0' + DefaultURL: 'https://game.maj-soul.com/1/', + PaipuMinVersion: '0.4.4', + ConfigMinVersion: '0.4.5' }; var config = undefined; const configfilename = 'config.json'; diff --git a/main.js b/main.js index 7b8b3e8..e346545 100644 --- a/main.js +++ b/main.js @@ -51,7 +51,7 @@ const ready = () => { browseWindow.webContents.on('dom-ready', function (){ //browseinject(); - if (!/^https:\/\/(?:(?:www\.)?majsoul|game.mahjongsoul|mahjongsoul)/.test(browseWindow.webContents.getURL())){ + if (!/^https:\/\/(?:(?:www\.)?majsoul|game.mah?jo?n?g?-?soul|mahjongsoul)/.test(browseWindow.webContents.getURL())){ if (browseWindow.nowingamepage) dialog.showMessageBox({ type: 'info', @@ -328,9 +328,9 @@ const ready = () => { bwindowload(); } }, { - label: '进入国服', + label: '进入中文服', click: function () { - gotonewpage('https://www.majsoul.com/1/'); + gotonewpage('https://game.maj-soul.com/1/'); } }, { label: '进入日服', @@ -349,6 +349,11 @@ const ready = () => { message: '由于技术原因,使用国际服时请确保当前网络能够较为通畅的访问Google, FaceBook等,否则很可能无法正确获取牌谱数据。' }); */ } + }, { + label: '进入国服(已关服)', + click: function () { + gotonewpage('https://www.majsoul.com/1/'); + } }, { label: '登录专用窗口', click: function () { diff --git a/package.json b/package.json index 5e8508e..42cfd62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "majsoul-paipu-crawler", - "version": "0.4.3", + "version": "0.4.4", "description": "Get Paipu from Majsoul", "main": "main.js", "scripts": {