Skip to content

Commit

Permalink
chore: Cherry-pick a bunch of dependency updates and test fixes from #…
Browse files Browse the repository at this point in the history
…340

Signed-off-by: Reece Dunham <[email protected]>
  • Loading branch information
RDIL committed Nov 22, 2023
1 parent 7fb174f commit 2d83a4c
Show file tree
Hide file tree
Showing 12 changed files with 587 additions and 1,656 deletions.
132 changes: 65 additions & 67 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,70 @@
env:
# don't clone the entire repository history, saves time
CIRRUS_CLONE_DEPTH: 1
# don't clone the entire repository history, saves time
CIRRUS_CLONE_DEPTH: 1

Build_task:
container:
image: node:18-slim
Enable_Corepack_script:
- corepack enable
Yarn_cache:
folder: .yarn/cache
reupload_on_changes: true
Yarn_Populate_script:
- yarn
Install_System_Dependencies_script:
- apt update --yes
- apt install zip jq curl --yes
Build_Modules_script:
- yarn build
Optimize_script:
- yarn optimize
Download_NodeJS_script:
- curl https://nodejs.org/dist/$(cat .nvmrc)/node-$(cat .nvmrc)-win-x64.zip -o node.zip
- unzip node.zip
- mkdir nodedist
- cp node-$(cat .nvmrc)-win-x64/node.exe nodedist/node.exe
- cp node-$(cat .nvmrc)-win-x64/LICENSE nodedist/LICENSE
Assemble_Full_script:
- ./packaging/ciAssemble.sh
Assemble_Linux_script:
- ./packaging/ciAssemble.sh linux
Peacock_Release_artifacts:
path: Peacock-v*.zip
type: application/zip
SourceMap_artifacts:
path: chunk0.js.map
container:
image: node:18-slim
Enable_Corepack_script:
- corepack enable
Yarn_cache:
folder: .yarn/cache
reupload_on_changes: true
Yarn_Populate_script:
- yarn
Install_System_Dependencies_script:
- apt update --yes
- apt install zip jq curl --yes
Build_Modules_script:
- yarn build
Optimize_script:
- yarn optimize
Download_NodeJS_script:
- curl https://nodejs.org/dist/$(cat .nvmrc)/node-$(cat .nvmrc)-win-x64.zip -o node.zip
- unzip node.zip
- mkdir nodedist
- cp node-$(cat .nvmrc)-win-x64/node.exe nodedist/node.exe
- cp node-$(cat .nvmrc)-win-x64/LICENSE nodedist/LICENSE
Assemble_Full_script:
- ./packaging/ciAssemble.sh
Assemble_Linux_script:
- ./packaging/ciAssemble.sh linux
Peacock_Release_artifacts:
path: Peacock-v*.zip
type: application/zip
SourceMap_artifacts:
path: chunk0.js.map

task:
container:
image: node:18-slim
Enable_Corepack_script:
- corepack enable
Yarn_cache:
folder: .yarn/cache
reupload_on_changes: true
Yarn_Populate_script:
- yarn
Type_Check_script:
- yarn typecheck
matrix:
- only_if: $CIRRUS_TAG != ''
name: Types Publish
env:
NPM_AUTH_TOKEN: ENCRYPTED[7e0bc6b5e2d4f27aff6a60acf686376ca26abed3334738847a419e4bd8c245490caeddc81d8ce403745516e11604c094]
Install_System_Dependencies_script:
- apt update --yes
- apt install rsync --yes
Push_Types_script:
- rsync -a --include '*/' --include '*.d.ts' --exclude '*' build/ packaging/typedefs/
- yarn typedefs reversion
- yarn typedefs pack
- yarn config set npmAuthToken $NPM_AUTH_TOKEN
- yarn typedefs npm publish
- only_if: $CIRRUS_TAG == ''
name: Linting
Lint_script:
- yarn lint
- yarn prettier:check
- only_if: $CIRRUS_TAG == ''
name: Tests
Test_script:
- yarn test
container:
image: node:18-slim
Enable_Corepack_script:
- corepack enable
Yarn_cache:
folder: .yarn/cache
reupload_on_changes: true
Yarn_Populate_script:
- yarn
Type_Check_script:
- yarn typecheck
matrix:
- only_if: $CIRRUS_TAG != ''
name: Types Publish
env:
NPM_AUTH_TOKEN: ENCRYPTED[7e0bc6b5e2d4f27aff6a60acf686376ca26abed3334738847a419e4bd8c245490caeddc81d8ce403745516e11604c094]
Install_System_Dependencies_script:
- apt update --yes
- apt install rsync --yes
Push_Types_script:
- rsync -a --include '*/' --include '*.d.ts' --exclude '*' build/ packaging/typedefs/
- yarn typedefs reversion
- yarn typedefs pack
- yarn config set npmAuthToken $NPM_AUTH_TOKEN
- yarn typedefs npm publish
- only_if: $CIRRUS_TAG == ''
name: Tests
Lint_script:
- yarn lint
- yarn prettier:check
Test_script:
- yarn test:main
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ max_line_length = 80
[*.xml]
insert_final_newline = false
indent_size = 2

[*.yml]
indent_size = 2
893 changes: 0 additions & 893 deletions .yarn/releases/yarn-4.0.0-rc.53.cjs

This file was deleted.

6 changes: 2 additions & 4 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ initScope: peacockproject
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-outdated.cjs
spec: "https://mskelton.dev/yarn-outdated/v2"

yarnPath: .yarn/releases/yarn-4.0.0-rc.53.cjs
- path: .yarn/plugins/@yarnpkg/plugin-outdated.cjs
spec: "https://mskelton.dev/yarn-outdated/v2"
50 changes: 23 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
"build-plugins": "node --no-warnings packaging/buildPlugins.mjs",
"typecheck-ws": "tsc",
"typecheck": "yarn workspaces foreach -A run typecheck-ws",
"lint": "eslint --format=pretty .",
"lint": "eslint .",
"rebuild-locale": "node resources/rebuildLocale.cjs",
"optimize": "terser chunk0.js -o chunk0.js -c --toplevel --timings --ecma 2021 -m --source-map \"content='chunk0.js.map'\"",
"webui": "yarn workspace @peacockproject/web-ui",
"typedefs": "yarn workspace @peacockproject/core",
"run-dev": "node packaging/devLoader.mjs",
"extract-challenge-data": "node packaging/extractChallengeData.mjs",
"test": "vitest --run --config tests/vitest.config.ts",
"test-ui": "vitest --config tests/vitest.config.ts --ui"
"extract-challenge-data": "node packaging/extractChallengeData.mjs"
},
"prettier": {
"semi": false,
Expand All @@ -37,60 +35,57 @@
},
"dependencies": {
"@peacockproject/statemachine-parser": "^5.9.3",
"@yarnpkg/fslib": "^3.0.0-rc.53",
"@yarnpkg/libzip": "^3.0.0-rc.53",
"@yarnpkg/fslib": "^3.0.1",
"@yarnpkg/libzip": "^3.0.0",
"atomically": "^2.0.2",
"axios": "^1.5.1",
"axios": "^1.6.0",
"body-parser": "*",
"clipanion": "^3.2.1",
"commander": "^11.1.0",
"deepmerge-ts": "^5.1.0",
"esbuild-wasm": "^0.19.4",
"esbuild-wasm": "^0.19.5",
"express": "patch:express@npm%3A4.18.2#~/.yarn/patches/express-npm-4.18.2-bb15ff679a.patch",
"jest-diff": "^29.7.0",
"js-ini": "^1.6.0",
"json5": "^2.2.3",
"jsonwebtoken": "^9.0.2",
"md5-file": "^5.0.0",
"msgpackr": "^1.9.9",
"nanoid": "^5.0.1",
"nanoid": "^5.0.3",
"parseurl": "^1.3.3",
"picocolors": "patch:picocolors@npm%3A1.0.0#~/.yarn/patches/picocolors-npm-1.0.0-d81e0b1927.patch",
"progress": "^2.0.3",
"prompts": "^2.4.2",
"random": "^4.1.0",
"send": "0.18.0",
"serve-static": "^1.15.0"
"serve-static": "^1.15.0",
"tapable": "^2.2.1"
},
"devDependencies": {
"@mixer/parallel-prettier": "^2.0.3",
"@peacockproject/eslint-plugin": "workspace:*",
"@types/body-parser": "1.19.3",
"@types/express": "^4.17.19",
"@types/jsonwebtoken": "^9.0.3",
"@types/express": "^4.17.20",
"@types/jsonwebtoken": "^9.0.4",
"@types/node": "^20",
"@types/parseurl": "^1.3.1",
"@types/progress": "^2.0.5",
"@types/prompts": "^2.4.6",
"@types/send": "^0.17.2",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@vitest/ui": "^0.34.6",
"esbuild": "^0.19.4",
"@types/parseurl": "^1.3.2",
"@types/progress": "^2.0.6",
"@types/prompts": "^2.4.7",
"@types/send": "^0.17.3",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"esbuild": "^0.19.5",
"esbuild-register": "^3.5.0",
"eslint": "^8.51.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-formatter-pretty": "^5.0.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react-hooks": "^4.6.0",
"fast-glob": "^3.3.1",
"fast-glob": "^3.3.2",
"json-keys-sort": "^2.1.0",
"ms": "^2.1.3",
"prettier": "^2.8.8",
"rimraf": "^5.0.5",
"terser": "^5.21.0",
"typescript": "5.2.2",
"vitest": "^0.34.6",
"winston": "^3.11.0",
"winston-daily-rotate-file": "^4.7.1"
},
Expand All @@ -100,7 +95,8 @@
"workspaces": [
"webui",
"packaging/typedefs",
"packaging/eslint"
"packaging/eslint",
"tests"
],
"packageManager": "[email protected].0-rc.53"
"packageManager": "[email protected].2"
}
7 changes: 3 additions & 4 deletions packaging/extractElusivesChallengeData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import jsonfile from "jsonfile"
import fs from "fs"
import path from "path"
import { randomUUID } from "crypto"

function makeTargetDown(id, codename, parent, sub) {
return {
CategoryName: "UI_MENU_PAGE_PROFILE_CHALLENGES_CATEGORY_ELUSIVE",
Expand Down Expand Up @@ -391,7 +392,7 @@ async function fetchContractCAndPFromIOI(axiosClient, contractId) {

/**
* @param {import("axios").AxiosInstance} axiosClient
* @param {string} locationId
* @param {string} contractId
* @returns {Promise<*>}
*/
async function fetchContract(axiosClient, contractId) {
Expand Down Expand Up @@ -572,16 +573,14 @@ async function extract(locationParent, jwt, apiUrl) {
}
}

const uniqueObjects = challengeObjects.filter((object, index) => {
challengeObjects = challengeObjects.filter((object, index) => {
const lastIndex = challengeObjects.findIndex(
(otherObject, otherIndex) =>
otherIndex < index && otherObject.Id === object.Id,
)
return lastIndex === -1
})

challengeObjects = uniqueObjects

console.log(`Compiled ${pc.green(challengeObjects.length)} challenges`)

return group
Expand Down
6 changes: 3 additions & 3 deletions packaging/typedefs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
},
"dependencies": {
"@peacockproject/statemachine-parser": "^5.9.3",
"@types/express": "^4.17.19",
"@types/node": "^20.8.6",
"@types/express": "^4.17.20",
"@types/node": "^20.8.10",
"atomically": "^2.0.2",
"axios": "^1.5.1",
"axios": "^1.6.0",
"js-ini": "^1.6.0"
},
"optionalDependencies": {
Expand Down
20 changes: 19 additions & 1 deletion tests/helpers/testHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
/*
* The Peacock Project - a HITMAN server replacement.
* Copyright (C) 2021-2023 The Peacock Project Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/* eslint-disable @typescript-eslint/no-explicit-any */
import type * as core from "express-serve-static-core"
import { RequestWithJwt } from "../../components/types/types"
import { Mock } from "vitest"
import { Mock, vi, expect } from "vitest"
import { sign } from "jsonwebtoken"

export function asMock<T>(value: T): Mock {
Expand Down
14 changes: 14 additions & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@peacockproject/tests",
"type": "module",
"private": true,
"dependencies": {
"@vitest/ui": "^0.34.6",
"vite": "^5.0.0-0",
"vitest": "^0.34.6"
},
"scripts": {
"test:main": "vitest --run --config vitest.config.ts",
"test:ui": "vitest --config vitest.config.ts --ui"
}
}
20 changes: 19 additions & 1 deletion tests/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* The Peacock Project - a HITMAN server replacement.
* Copyright (C) 2021-2023 The Peacock Project Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import path from "path"
import { defineConfig } from "vitest/config"
import { Plugin } from "vite"
Expand Down Expand Up @@ -37,7 +55,7 @@ function dontLoadJsonPlugin() {
export default defineConfig({
test: {
globals: true,
setupFiles: ["tests/setup/globalDefines.ts"],
setupFiles: ["setup/globalDefines.ts"],
},
plugins: [dontLoadJsonPlugin()],
})
Loading

0 comments on commit 2d83a4c

Please sign in to comment.