Skip to content

Commit

Permalink
important fixes (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy authored Sep 26, 2023
2 parents 358203f + bd19f85 commit 8aa4e35
Show file tree
Hide file tree
Showing 30 changed files with 1,640 additions and 2,515 deletions.
73 changes: 73 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"extends": "zardoy",
"rules": {
"semi": [
"error",
"never"
],
"indent": [
"error",
2,
{
"SwitchCase": 2,
"ignoredNodes": [
"TemplateLiteral"
]
}
],
"quotes": [
"error",
"single",
{
"allowTemplateLiterals": true
}
],
// perf
"import/no-deprecated": "off",
// ---
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/naming-convention": "off",
"prefer-template": "off",
// intentional: improve readability in some cases
"no-else-return": "off",
"@typescript-eslint/padding-line-between-statements": "off",
"arrow-body-style": "off",
"unicorn/prefer-ternary": "off",
"unicorn/switch-case-braces": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"unicorn/explicit-length-check": "off",
"unicorn/prefer-dom-node-append": "off",
"typescript-eslint/no-confusing-void-expression": "off",
"unicorn/no-lonely-if": "off",
"no-multi-assign": "off",
"sonarjs/no-duplicate-string": "off",
"new-cap": "off",
"unicorn/consistent-destructuring": "off",
"unicorn/no-await-expression-member": "off",
"unicorn/prefer-add-event-listener": "off",
"unicorn/prefer-top-level-await": "off",
"default-case": "off",
// I guess it would better to fix
"node/prefer-global/buffer": "off",
"unicorn/prefer-optional-catch-binding": "off", // still useful for debugging
"no-alert": "off", // todo once replaced with ui, enable
"@typescript-eslint/restrict-plus-operands": "off",
// ---
"@typescript-eslint/no-throw-literal": "off", // disabling because of "rule expansion"
"no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"import/no-extraneous-dependencies": "off",
"@typescript-eslint/ban-types": "off",
"unicorn/prefer-query-selector": "off",
"@typescript-eslint/dot-notation": "off", // trick prop type-checking
"@typescript-eslint/consistent-type-imports": "off",
"no-negated-condition": "off",
"@typescript-eslint/no-require-imports": "off",
"unicorn/prefer-number-properties": "off",
"@typescript-eslint/no-confusing-void-expression": "off",
// needs to be fixed actually
"@typescript-eslint/no-floating-promises": "warn",
"no-async-promise-executor": "off",
"no-bitwise": "off"
}
}
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
- name: Install pnpm
run: npm i -g pnpm
- run: pnpm install
- run: pnpm lint
- run: pnpm check-build
- run: nohup pnpm prod-start &
- run: nohup node cypress/minecraft-server.mjs &
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ jobs:
- run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
# will install + build to .vercel/output/static
- run: vercel build --token=${{ secrets.VERCEL_TOKEN }} --prod
- run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --prod
- run: pnpx zardoy-release node
- name: Deploy Project to Vercel
uses: mathiasvr/[email protected]
with:
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --prod
id: deploy
- run: |
pnpx zardoy-release node --footer "This release URL: ${{ steps.deploy.outputs.stdout }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: cp vercel.json .vercel/output/static/vercel.json
Expand Down
93 changes: 47 additions & 46 deletions cypress/integration/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,78 @@
import type { AppOptions } from '../../src/optionsStorage'

const cleanVisit = () => {
window.localStorage.clear()
visit()
window.localStorage.clear()
visit()
}

const visit = (url = '/') => {
window.localStorage.cypress = 'true'
cy.visit(url)
window.localStorage.cypress = 'true'
cy.visit(url)
}

// todo use ssl

const compareRenderedFlatWorld = () => {
// wait for render
// cy.wait(6000)
// cy.get('body').toMatchImageSnapshot({
// name: 'superflat-world',
// })
// wait for render
// cy.wait(6000)
// cy.get('body').toMatchImageSnapshot({
// name: 'superflat-world',
// })
}

const testWorldLoad = () => {
cy.document().then({ timeout: 20_000, }, doc => {
return new Cypress.Promise(resolve => {
doc.addEventListener('cypress-world-ready', resolve)
})
}).then(() => {
compareRenderedFlatWorld()
cy.document().then({ timeout: 20_000, }, doc => {
return new Cypress.Promise(resolve => {
doc.addEventListener('cypress-world-ready', resolve)
})
}).then(() => {
compareRenderedFlatWorld()
})
}

const setOptions = (options: Partial<AppOptions>) => {
cy.window().then(win => {
Object.assign(win['options'], options)
})
cy.window().then(win => {
Object.assign(win['options'], options)
})
}

it('Loads & renders singleplayer', () => {
cleanVisit()
setOptions({
localServerOptions: {
generation: {
name: 'superflat',
options: { seed: 250869072 }
},
},
renderDistance: 2
})
cy.get('#title-screen').find('[data-test-id="singleplayer-button"]', { includeShadowDom: true, }).click()
testWorldLoad()
cleanVisit()
setOptions({
localServerOptions: {
generation: {
name: 'superflat',
// eslint-disable-next-line unicorn/numeric-separators-style
options: { seed: 250869072 }
},
},
renderDistance: 2
})
cy.get('#title-screen').find('[data-test-id="singleplayer-button"]', { includeShadowDom: true, }).click()
testWorldLoad()
})

it('Joins to server', () => {
// visit('/?version=1.16.1')
window.localStorage.version = '1.16.1'
visit()
// todo replace with data-test
cy.get('#title-screen').find('[data-test-id="connect-screen-button"]', { includeShadowDom: true, }).click()
cy.get('input#serverip', { includeShadowDom: true, }).clear().focus().type('localhost')
cy.get('[data-test-id="connect-to-server"]', { includeShadowDom: true, }).click()
testWorldLoad()
// visit('/?version=1.16.1')
window.localStorage.version = ''
visit()
// todo replace with data-test
cy.get('#title-screen').find('[data-test-id="connect-screen-button"]', { includeShadowDom: true, }).click()
cy.get('input#serverip', { includeShadowDom: true, }).clear().focus().type('localhost')
cy.get('[data-test-id="connect-to-server"]', { includeShadowDom: true, }).click()
testWorldLoad()
})

it('Loads & renders zip world', () => {
cleanVisit()
cy.get('#title-screen').find('[data-test-id="select-file-folder"]', { includeShadowDom: true, }).click({ shiftKey: true })
cy.get('input[type="file"]').selectFile('cypress/superflat.zip', { force: true })
testWorldLoad()
cleanVisit()
cy.get('#title-screen').find('[data-test-id="select-file-folder"]', { includeShadowDom: true, }).click({ shiftKey: true })
cy.get('input[type="file"]').selectFile('cypress/superflat.zip', { force: true })
testWorldLoad()
})

it.skip('Performance test', () => {
// select that world
// from -2 85 24
// await bot.loadPlugin(pathfinder.pathfinder)
// bot.pathfinder.goto(new pathfinder.goals.GoalXZ(28, -28))
// select that world
// from -2 85 24
// await bot.loadPlugin(pathfinder.pathfinder)
// bot.pathfinder.goto(new pathfinder.goals.GoalXZ(28, -28))
})
31 changes: 6 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
"start-watch-script": "nodemon -w esbuild.mjs esbuild.mjs",
"build": "node scripts/build.js copyFiles && node scripts/prepareData.mjs -f && node esbuild.mjs --minify --prod",
"check-build": "tsc && pnpm build",
"watch": "node scripts/build.js copyFilesDev && webpack serve --config webpack.dev.js --progress",
"test:cypress": "cypress run",
"test:e2e": "start-test http-get://localhost:8080 test:cypress",
"prod-start": "node server.js",
"postinstall": "node scripts/gen-texturepack-files.mjs"
"postinstall": "node scripts/gen-texturepack-files.mjs",
"lint": "eslint \"{src,cypress}/**/*.{ts,js,jsx,tsx}\""
},
"keywords": [
"prismarine",
"web",
"client"
],
"bin": "./server.js",
"author": "PrismarineJS",
"license": "MIT",
"dependencies": {
"@dimaka/interface": "0.0.3-alpha.0",
"@emotion/css": "^11.11.2",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"@types/wicg-file-system-access": "^2020.9.6",
Expand All @@ -33,10 +32,8 @@
"compression": "^1.7.4",
"cypress-plugin-snapshots": "^1.4.4",
"debug": "^4.3.4",
"diamond-square": "^1.2.0",
"eruda": "^3.0.1",
"esbuild": "^0.19.3",
"esbuild-loader": "^4.0.0",
"esbuild-plugin-polyfill-node": "^0.3.0",
"express": "^4.18.2",
"flying-squid": "github:zardoy/space-squid#everything",
Expand All @@ -46,16 +43,13 @@
"lit": "^2.8.0",
"lodash": "^4.17.21",
"minecraft-data": "^3.0.0",
"net-browserify": "github:PrismarineJS/net-browserify",
"net-browserify": "github:zardoy/prismarinejs-net-browserify",
"peerjs": "^1.5.0",
"pretty-bytes": "^6.1.1",
"qrcode.react": "^3.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-refresh": "^0.14.0",
"speed-measure-webpack-plugin": "^1.5.0",
"stats.js": "^0.17.0",
"url": "^0.11.1",
"valtio": "^1.11.1",
"workbox-build": "^7.0.0"
},
Expand All @@ -64,22 +58,18 @@
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"clean-webpack-plugin": "^4.0.0",
"constants-browserify": "^1.0.0",
"contro-max": "^0.1.1",
"copy-webpack-plugin": "^11.0.0",
"crypto-browserify": "^3.12.0",
"css-loader": "^6.8.1",
"cypress": "^9.5.4",
"cypress-esbuild-preprocessor": "^1.0.2",
"eslint": "^8.50.0",
"eslint-config-zardoy": "^0.2.17",
"events": "^3.3.0",
"filesize": "^10.0.12",
"html-webpack-plugin": "^5.5.3",
"http-browserify": "^1.7.0",
"http-server": "^14.1.1",
"https-browserify": "^1.0.0",
"lodash-webpack-plugin": "^0.11.6",
"memfs": "^3.5.3",
"minecraft-inventory-gui": "github:zardoy/minecraft-inventory-gui#next",
"mineflayer": "github:zardoy/mineflayer#custom",
"mineflayer-pathfinder": "^2.4.4",
Expand All @@ -90,19 +80,10 @@
"process": "github:PrismarineJS/node-process",
"rimraf": "^5.0.1",
"stream-browserify": "^3.0.0",
"style-loader": "^3.3.3",
"three": "0.128.0",
"timers-browserify": "^2.0.12",
"typescript": "^5.2.2",
"url-loader": "^4.1.1",
"use-typed-event-listener": "^4.0.2",
"vite": "^4.4.9",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-middleware": "^6.1.1",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.9.0",
"workbox-webpack-plugin": "^6.6.0",
"yaml": "^2.3.2"
},
"pnpm": {
Expand Down
Loading

0 comments on commit 8aa4e35

Please sign in to comment.