Skip to content

Commit

Permalink
Merge pull request #1 from smogon/master
Browse files Browse the repository at this point in the history
Merge updates
  • Loading branch information
Lucas-Meijer authored Nov 7, 2023
2 parents 6509702 + 8d699f8 commit a345222
Show file tree
Hide file tree
Showing 304 changed files with 176,150 additions and 28,430 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish to npm
on:
push:
branches:
- master
paths:
- 'package.json'
jobs:
test:
uses: ./.github/workflows/test.yml
get-version:
runs-on: ubuntu-latest
outputs:
current_version: ${{ steps.current_version.outputs.version }}
last_version: ${{ steps.last_version.outputs.version }}
token_exists: ${{ steps.check_token.outputs.token }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
# Check if the package.json version field has changed since the last push
- name: Get current version from package.json
id: current_version
run: |
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- name: Get the version from the last push
id: last_version
run: |
git checkout ${{ github.event.before }}
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- name: Check if NPM_TOKEN exists
id: check_token
run: |
echo "token=$(if [ -n "${{ secrets.NPM_TOKEN }}" ]; then echo true; else echo false; fi)" >> $GITHUB_OUTPUT
npm-publish:
needs:
- test
- get-version
runs-on: ubuntu-latest
# We only want to publish if the package.json version field has changed
if: needs.get-version.outputs.current_version != needs.get-version.outputs.last_version && needs.get-version.outputs.token_exists == 'true'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
60 changes: 55 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_call:

jobs:
build:
Expand All @@ -16,15 +17,64 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [16.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 100 # assumes PR/push to master is no larger than 100 commits. Other solutions are needlessly complex.

- name: Use Node.js ${{ matrix.node-version }}
uses: Zarel/setup-node@patch-1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run full-test
cache: 'npm'

- run: npm ci

- name: Determine which files to lint (if pull request)
if: ${{ github.event_name == 'pull_request' }}
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
./config/*.ts
./data/**/*.ts
./lib/*.ts
./server/**/*.ts
./server/**/*.tsx
./sim/**/*.ts
./tools/set-import/*.ts
files_ignore: |
./logs/
./node_modules/
./dist/
./data/**/learnsets.ts
./tools/set-import/importer.js
./tools/set-import/sets
./tools/modlog/converter.js
./server/global-variables.d.ts
- name: Determine whether test/sim or test/random-battles need to run (if pull request)
if: ${{ github.event_name == 'pull_request' }}
id: changed-directories
uses: tj-actions/changed-files@v35
with:
files: |
config/formats.ts
data/**
sim/**
- name: Run selective lint & neccessary tests (if pull request)
if: ${{ github.event_name == 'pull_request' }}
run: npm run full-test-ci
env:
CI: true
FILES: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
SKIPSIMTESTS: ${{ steps.changed-directories.outputs.all_changed_and_modified_files == '' }}

- name: Run full lint & test (if push to master)
run: npm run full-test
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
env:
CI: true
42 changes: 42 additions & 0 deletions .github/workflows/update_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update the npm package version

on:
workflow_dispatch:
inputs:
version:
required: true
type: choice
description: Version type
default: patch
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- prerelease
jobs:
update_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- id: bump_version
run: |
echo "old_version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
npm version ${{ github.event.inputs.version }} --no-git-tag-version
echo "new_version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- uses: peter-evans/create-pull-request@v4
with:
title: Bump package.json version to v${{ steps.bump_version.outputs.new_version }}}
body: |
Bump package.json version from `v${{ steps.bump_version.outputs.old_version }}` to `v${{ steps.bump_version.outputs.new_version }}`
commit-message: Bump package.json version to v${{ steps.bump_version.outputs.new_version }}
branch: npm-version-bump
base: master

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
npm-debug.log
.eslintcache
.eslintcache-no-types
package-lock.json
/tools/set-import/sets
databases/*.db*
*.o
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/config/*
!/config/formats.ts
!/config/config-example.js
/logs/*
/test/modlogs
/node_modules
Expand Down
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
package-lock=false
NODE_OPTIONS=--max-old-space-size=3072
9 changes: 7 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,28 @@ data/random-sets.json @MathyFurret @ACakeWearingAHat @livid-washed @adrivrie
data/random-teams.ts @AnnikaCodes @KrisXV @MathyFurret @ACakeWearingAHat @livid-washed @adrivrie
data/text/ @Marty-D
databases/ @monsanto
lib/sql.ts @mia-pi-git
server/artemis/* @mia-pi-git
server/chat-plugins/abuse-monitor.ts @mia-pi-git
server/chat-plugins/friends.ts @mia-pi-git
server/chat-plugins/github.ts @mia-pi-git
server/chat-plugins/hosts.ts @AnnikaCodes
server/chat-plugins/helptickets*.ts @mia-pi-git
server/chat-plugins/mafia.ts @HoeenCoder
server/chat-plugins/othermetas.ts @KrisXV
server/chat-plugins/permalocks.ts @mia-pi-git
server/chat-plugins/quotes.ts @mia-pi-git @KrisXV
server/chat-plugins/random-battles.ts @KrisXV @AnnikaCodes
server/chat-plugins/repeats.ts @AnnikaCodes
server/chat-plugins/responder.ts @mia-pi-git
server/chat-plugins/rock-paper-scissors.ts @mia-pi-git
server/chat-plugins/sample-teams.ts @KrisXV
server/chat-plugins/scavenger*.ts @xfix @sparkychildcharlie
server/chat-plugins/scavenger*.ts @xfix @sparkychildcharlie @PartMan7
sever/chat-plugins/teams.ts @mia-pi-git
server/chat-plugins/the-studio.ts @KrisXV
server/chat-plugins/abuse-monitor.ts @mia-pi-git
server/chat-plugins/trivia/ @AnnikaCodes
server/friends.ts @mia-pi-git
server/private-messages/* @mia-pi-git
server/chat-plugins/username-prefixes.ts @AnnikaCodes
server/chat-plugins/wifi.ts @KrisXV
server/friends.ts @mia-pi-git
Expand Down
6 changes: 3 additions & 3 deletions PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ represented by a space), and the rest of the string being their username.
> You just connected to the server, and we're giving you some information you'll need to log in.
>
> If you're already logged in and have session cookies, you can make an HTTP GET request to
> `https://play.pokemonshowdown.com/action.php?act=upkeep&challstr=CHALLSTR`
> `https://play.pokemonshowdown.com/api/upkeep?challstr=CHALLSTR`
>
> Otherwise, you'll need to make an HTTP POST request to `https://play.pokemonshowdown.com/action.php`
> with the data `act=login&name=USERNAME&pass=PASSWORD&challstr=CHALLSTR`
> Otherwise, you'll need to make an HTTP POST request to `https://play.pokemonshowdown.com/api/login`
> with the data `name=USERNAME&pass=PASSWORD&challstr=CHALLSTR`
>
> `USERNAME` is your username and `PASSWORD` is your password, and `CHALLSTR`
> is the value you got from `|challstr|`. Note that `CHALLSTR` contains `|`
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Navigation: [Website][1] | **Server repository** | [Client repository][2] | [Dex
[3]: https://github.com/Zarel/Pokemon-Showdown-Dex

[![Build Status](https://github.com/smogon/pokemon-showdown/workflows/Node.js%20CI/badge.svg)](https://github.com/smogon/pokemon-showdown/actions?query=workflow%3A%22Node.js+CI%22)
[![Dependency Status](https://david-dm.org/smogon/pokemon-showdown.svg)](https://david-dm.org/smogon/pokemon-showdown)
[![devDependency Status](https://david-dm.org/smogon/pokemon-showdown/dev-status.svg)](https://david-dm.org/smogon/pokemon-showdown?type=dev)
[![Dependency Status](https://img.shields.io/librariesio/github/smogon/pokemon-showdown)](https://libraries.io/github/smogon/pokemon-showdown)


Introduction
Expand Down Expand Up @@ -37,7 +36,7 @@ Pokémon Showdown is many things:

- [server/README.md](./server/README.md)

Pokémon Showdown simulates singles, doubles and triples battles in all the games out so far (Generations 1 through 8).
Pokémon Showdown simulates singles, doubles and triples battles in all the games out so far (Generations 1 through 9).


Documentation quick links
Expand Down Expand Up @@ -90,8 +89,10 @@ Staff
- Andrew Werner [HoeenHero] - Development
- Annika L. [Annika] - Development
- Chris Monsanto [chaos] - Development, Sysadmin
- Leonard Craft III - Research (game mechanics)
- Kris Johnson [Kris] - Development
- Leonard Craft III [DaWoblefet] - Research (game mechanics)
- Mathieu Dias-Martins [Marty-D] - Research (game mechanics), Development
- Mia A [Mia] - Development

Contributors

Expand Down
19 changes: 11 additions & 8 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"use strict";

try {
// technically this was introduced in Node 11, but we'll ask for the most recent LTS with it to be safe
[].flatMap(x => x);
// technically this was introduced in Node 15, but we'll ask for the most recent LTS with it to be safe
Promise.any([null]);
} catch (e) {
console.log("We require Node.js version 14 or later; you're using " + process.version);
console.log("We require Node.js version 16 or later; you're using " + process.version);
process.exit(1);
}

Expand All @@ -30,11 +30,6 @@ try {
console.log('Installing dependencies...');
shell('npm install');
}
// for some reason, esbuild won't be requirable until a tick has passed
// see https://stackoverflow.com/questions/53270058/node-cant-find-certain-modules-after-synchronous-install
setImmediate(() => {
require('./tools/build-utils').transpile(force, decl);
});

// Make sure config.js exists. If not, copy it over synchronously from
// config-example.js, since it's needed before we can start the server
Expand All @@ -49,3 +44,11 @@ try {
fs.readFileSync('config/config-example.js')
);
}

// for some reason, esbuild won't be requirable until a tick has passed
// see https://stackoverflow.com/questions/53270058/node-cant-find-certain-modules-after-synchronous-install
setImmediate(() => {
// npm package, don't rebuild
if (process.argv[2] === 'postinstall' && fs.existsSync('dist')) return;
require('./tools/build-utils').transpile(force, decl);
});
2 changes: 1 addition & 1 deletion config/CUSTOM-RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Pokémon Showdown supports custom rules in three ways:

- Tournaments, using the command `/tour rules RULES` (see the [Tournament command help][tour-help])

- Custom formats on your side server, by editing `config/formats.js`
- Custom formats on your side server, by editing `config/formats.ts`

[tour-help]: https://www.smogon.com/forums/threads/pok%C3%A9mon-showdown-forum-rules-resources-read-here-first.3570628/#post-6777489

Expand Down
1 change: 1 addition & 0 deletions config/config-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ exports.reportjoinsperiod = 0;
* report battles - shows messages like "OU battle started" in the lobby
* This feature can lag larger servers - turn this off if your server is
* getting more than 160 or so users.
* @type {boolean | string[] | string}
*/
exports.reportbattles = true;

Expand Down
Loading

0 comments on commit a345222

Please sign in to comment.