Skip to content

Commit

Permalink
feat: rest of the containerisation
Browse files Browse the repository at this point in the history
  • Loading branch information
zkrising committed Aug 17, 2024
1 parent 0e2c106 commit 5233121
Show file tree
Hide file tree
Showing 15 changed files with 205 additions and 154 deletions.
14 changes: 12 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
"workspaceFolder": "/tachi",
"postAttachCommand": "./dev/bootstrap.sh",
"updateRemoteUserUID": true,
// "containerUser": "tachi",
"containerUser": "tachi",
"customizations": {
"vscode": {
"settings": {},
"settings": {
"typescript.tsdk": "node_modules/typescript/lib",
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
},
"extensions": [
"dbaeumer.vscode-eslint"
]
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-vscode-remote.remote-containers"
]
}
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
}
},
}
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RUN rm -f /etc/localtime && ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN echo "LC_ALL=en_US.UTF-8\nLANG=en_US.UTF-8" > /etc/default/locale

# nice to haves
RUN apt install -y fish just fzf curl wget parallel neovim fd-find bat
RUN apt install -y gh fish just fzf curl wget parallel neovim fd-find bat

# `fd` is called `find-fd` on ubuntu. Awesome.
RUN ln -s $(which fdfind) /usr/bin/fd
Expand Down
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,28 @@ Check the [Documentation](https://docs.tachi.ac/contributing/setup) for how to s

You can then check the component-specific guides to see how to run those components and contribute back!

## Quick Setup For Nerds
## Quick Setup For Experienced Programmers

Already know what you're doing?
Install VSCode and use the dev container extension.
This is my the supported way of working and will ensure you have the correct versions of everything.

Install docker + docker-compose and use `./run.sh start` or `./run.bat start` to start Tachi.
### Unsupported stuff

Other commands you might want to execute are included inside the `run` file.
Tachi is intended to be developed inside a container. This ensures that you have the correct version of MongoDB, Redis, Typescript and all that jazz.

VSCode has excellent native support for dev containers, and as such this is the only method of local development we officially support.

Over the years we have had a *lot* of issues with people having subtle variations on their system (or on windows). Given the contributor-centricity of Tachi, it's untenable to expect every contributor to be an expert with local dev setup.

The devcontainer provides us with the most simple, consistent experience, and allows us to put nice-to-haves inside the user's shell.

That said, if you're ardently against using VSCode or Docker...

**DO NOT REPORT ISSUES TO ME IF YOU DO THIS**

You can run the docker-compose file and `dev/boostrap.sh` inside the container yourself. Work inside the container.

Alternatively if you want to work outside of docker you're on your own. Figure out the correct versions for everything (npm, pnpm, mongo, redis, ts-node...) and `dev/bootstrap.sh`.

## Repository Info

Expand Down
5 changes: 5 additions & 0 deletions dev/functions.fish
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ end


function fish_greeting
# check $PATH is correct
if not contains ~/.local/pnpm $PATH
fish_add_path ~/.local/pnpm
end

echo "Welcome to $(rgb "Tachi" e61c6e 131313)!"

if ! test -e /tachi/I_HAVE_BOOTSTRAPPED_OK
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/routes/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ None.
### Example

!!! note
`zkrising` is the username for the user with userID 1.
`zk` is the username for the user with userID 1.

it's also the username of the person writing these
docs. Hi!
Expand Down
25 changes: 5 additions & 20 deletions docs/docs/contributing/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ The Tachi repository that you just set up is made up of multiple "components".

All of them have their own things going on, so this page has all the guides for each specific component.

## For Professionals...

If you're already very familiar with `git`, the terminal, `node` and JSON, and care more about Tachi specific stuff (how to get the components running, what our architecture looks like), you should skip over that stuff in each guide.

We maintain these guides so that people with knowledge about how to improve Tachi can help out, regardless of their skill level! As such, not all of the information will be of use to you - Skip over the tooling explanations.

## What can I contribute to?

In order of difficulty, here are the components of Tachi you can contribute to!
Expand All @@ -25,7 +19,7 @@ of the bug.

!!! note
Although they're called GitHub *issues*, they're actually used for tracking anything. If you've
came up with a cool feature idea, send it over as an issue! `zkrising` will read and Triage them.
came up with a cool feature idea, send it over as an issue! `zk` will read and Triage them.

For more information, read our [Issue Reporting Guide](./components/issues.md).

Expand All @@ -35,15 +29,11 @@ We store our documentation as a series of markdown files in the [Main Repository

Writing, maintaining and proofreading the documentation is something that is **severely** neglected
at the moment. Simple things like typo fixes, all the way up to writing new explanations about major features
are **thoroughly** appreciated, as `zkrising` prioritises maintaining the core of working code.
are **thoroughly** appreciated, as `zk` prioritises maintaining the core of working code.

If you're interested in this, check out the [Documentation Contribution Guide](./components/documentation.md).

It'll teach you `shell` and `git` basics,
setting up a programming environment for Tachi,
and how to use our documentation builder.

### Database Seeds
j### Database Seeds

We use an interesting system for parts of our database. We actually store a game's songs and charts *in*
our GitHub repository! That means you can:
Expand All @@ -56,21 +46,16 @@ our GitHub repository! That means you can:

!!! important
This part of Tachi is the most important part for external contributors.
You guys know these games better than `zkrising` does, and you guys keep an eye on all the updates for your games!
You guys know these games better than `zk` does, and you guys keep an eye on all the updates for your games!

If people don't add songs/charts to this database, `zkrising` will **not** keep an eye on the game for you! Someone *has* to pick up the reigns for each game!
If people don't add songs/charts to this database, `zk` will **not** keep an eye on the game for you! Someone *has* to pick up the reigns for each game!

If you want to add/fix songs, charts, folders or tables for your favourite game - **START HERE!**

Or in general, if you just want to contribute and don't know what to -- **this is the MOST in need of help. Always.**

Want to get started on contributing to the Database? Check out our [Database Contribution Guide](./components/seeds.md).

It'll teach you `shell` and `git` basics,
setting up a programming environment for Tachi,
`json`,
and we'll even do a little scripting as a treat!

### Server, Client

The server and client form the powerful *core* of Tachi.
Expand Down
43 changes: 43 additions & 0 deletions docs/docs/contributing/components/core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Client + Server Contribution Guide

The client and server are the meat and potatoes of Tachi. They handle all of our requests and display our fancy UI.

Contributing here is a bit more difficult than contributing to the seeds, but it's certainly not impossible!

Plus, it's good fun to be able to mess around with websites. If you've got something you want to mess around with, you might find it surprisingly easy to do!

## Pre-Setup

You must have [Setup a local dev environment](../setup.md) in order to work nicely with the docs!

## Component Overview

The content for the client is inside `client/` and the content for the server is inside `server/`.

The client and server share quite a bit of code. This is inside `common/`.

To run the client and server, use `just start`. You can hit `Ctrl+C` to stop the server.

## Editing the Client

With `just start` running, the client will listen for changes you make, and reload accordingly. You will see your changes reflected on http://127.0.0.1:3000.

## Editing the Server

Likewise, with `just start` running, the server will listen for changes you make, and reload accordingly.

!!! warning
Be careful with triggering a server reload. If you do it mid-import you can cause some serious state issues.

If you suspect that your local state is screwed up, run `just wipe-local-db` to reset
the database.

## Getting real data

The client, out of the box, is sort of hard to test because you'll have no scores to display.

Use `just load-kamai-dataset` or `just load-boku-dataset` to load a *real* dataset from either of the Tachis.

You'll then need to edit `server/conf.json5` and change `MONGO_DATABASE_NAME` to `"anon-kamai"` or `"anon-boku"`.

Everyone's passwords are set to `password`, so feel free to log in as anyone, and see real data!
30 changes: 6 additions & 24 deletions docs/docs/contributing/components/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@

The documentation component of Tachi powers the website you're currently viewing. Hi!

## Tool Knowledge
## Pre-Setup

To properly contribute to the documentation, you'll need to know the following things:

- [The Terminal](../tools/terminal.md)
- [Git](../tools/git.md)

If you don't know, or aren't comfortable with all of the things on this list, click on them to learn about them!
You must have [Setup a local dev environment](../setup.md) in order to work nicely with the docs!

## Component Overview

Expand All @@ -20,33 +15,20 @@ It contains another folder, inconveniently called `docs/`, which contains all of
There's another folder called `includes/`, which contains some things that are constantly
referenced throughout the documentation.

At the top level, there's `mkdocs.yml`, which we'll go over later.
At the top level, there's `mkdocs.yml` which configures how our documentation works later.

## Software Overview

We use [MKDocs Material](https://squidfunk.github.io/mkdocs-material/) for our documentation.
It extends markdown a bit to let us add things like admonitions and references.

This is a Python package, making it the only part of our codebase that is Python based. As such, you'll need a way of installing python packages.

Their documentation is **incredibly** good, so check their stuff out there if you want to use their markdown extensions.

Other than that, our documentation is vanilla [markdown](https://www.markdownguide.org/basic-syntax/). If you know how to write a reddit comment, you know how to write documentation.

## Dependencies

Use `pip` to install `mkdocs` and `mkdocs-material`.

!!! danger
[Python package management is an utter disasterous mess](https://stackoverflow.com/questions/48941116/does-python-pip-have-the-equivalent-of-nodes-package-json). Feel free to set up a venv or some other elaborate rube-goldberg machine to ensure that your packages don't bleed everywhere.

Either way, you want to install such that is `mkdocs` on your terminal.
Their documentation is **incredibly** good, so check their stuff out there if you want to see what features are available.

You might have to restart your terminal after installing it, depending on the alignment of `pip` with the sun.
Other than that, our documentation is [markdown](https://www.markdownguide.org/basic-syntax/). If you know how to format a discord message, you know how to write documentation!

## Running the Documentation

Use `mkdocs serve` inside Tachi's `docs/` folder to start up a local documentation viewer on port `8000`.
Use `just docs start` inside Tachi to start up a local documentation viewer on http://127.0.0.1:8001.

This will automatically refresh when you edit anything related to the documentation, so you can quickly see how your stuff goes.

Expand Down
41 changes: 17 additions & 24 deletions docs/docs/contributing/components/seeds.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,9 @@ The database seeds component of Tachi controls the actual data inside the app.
Changes made in this component are automatically synchronised with the live Tachi database,
it's kind of a cool system, and allows anyone to contribute patches to songs, charts, folders, and more!

## Tool Knowledge
## Pre-Setup

To properly contribute to the documentation, you'll need to know the following things:

- [The Terminal](../tools/terminal.md)
- [Git](../tools/git.md)
- [JSON](../tools/json.md)

If you know JavaScript, that will be helpful for the scripting sections when we go over how
to batch-apply updates.
However, we don't maintain a JS guide (yet). You'll have to ask in the discord!

If you don't know, or aren't comfortable with all of the things on this list, click on them to learn about them!
You must have [Setup a local dev environment](../setup.md) in order to work nicely with the docs!

## Component Overview

Expand All @@ -38,10 +28,6 @@ The collections are all just plain JSON files.

The scripts are written in either TypeScript or JavaScript.

## Dependencies

Installation of dependencies for this part of the codebase should be already handled, if you ran the `bootstrap.sh` script.

## How do I know what a song is meant to look like?

These are called schemas (or interfaces) and you can find them in two places:
Expand All @@ -60,14 +46,11 @@ We also maintain a bit more human readable form for schemas in this documentatio

## Important Scripts

After doing **anything** to the collections, such as adding a new item to the database, you **MUST** run `pnpm run sort` inside the `scripts/` folder.
After doing **anything** to the collections, such as adding a new item to the database, you **MUST** run `just seeds sort` inside the `scripts/` folder.

This will deterministically sort the data you put into the collections, making sure that `git` history stays sane (i.e. it only says things that actually changed, changed).

!!! info
`pnpm run sort` is an alias for `node deterministic-collection-sort.js`

Before sending any changes, run `pnpm test` to check all your data. If anything you've sent is invalid, it'll be logged in `failed-tests.log`, and the command won't pass.
Before sending any changes, run `just seeds test` to check all your data. If anything you've sent is invalid, it'll be logged in `failed-tests.log`, and the command won't pass.

This is automatically ran when changes are sent to me, but you should run it yourself before committing anyway!

Expand All @@ -87,12 +70,17 @@ It should be obvious what each one does, though.

If you're looking to add a BMS table to Tachi for an example, you'd look into the rerunner scripts.

## Single-Time Scripts
## Single-Use Scripts

Some scripts we only want to run once, and we don't really need to keep them around. These are saved into the `single-time` folder, and will never be tracked by `git`.
Some scripts we only want to run once, and we don't really need to keep them around. These are saved into the `single-use` folder, and will never be tracked by `git`.

You can make quick hacky scripts here.

!!! warning
Anything in this folder will *NOT* be shared. Please be generous with what you share,
far too many people have assumed nobody is interested in their scripts, and then lost
the scripts when moving machines!

## Scripting Changes

We provide utilities for mutating data inside the collections comfortably inside `scripts/util.js`. The most important one is `MutateCollection`, which, as expected, mutates a collection.
Expand Down Expand Up @@ -142,4 +130,9 @@ Below are some examples of what you can do with this API.
});
```

For even more examples, see the `rerunners/` folder, as it makes liberal use of this API.
For even more examples, see the `rerunners/` folder, as it makes liberal use of this API.

## Running scripts

To run a seeds script, type `seeds` and pick your script. This will type out the
command for you.
2 changes: 0 additions & 2 deletions docs/docs/contributing/cookbook/sdvx-mdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ The file you're looking to run is `merge-mdb.ts`, but it needs two arguments:

You can run this script by typing `ts-node merge-mdb.ts --input YOUR_INPUT_HERE --version YOUR_VERSION_HERE` in the terminal.

!!! tip
Make sure you have `ts-node` installed. If you don't, you can get it with `pnpm add -g ts-node`.
3 changes: 0 additions & 3 deletions docs/docs/contributing/core.md

This file was deleted.

18 changes: 4 additions & 14 deletions docs/docs/contributing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,20 @@ But, what *can* you contribute, and where can you help out?
Contrary to what you might already think, contributing to Tachi actually has remarkably little to
do with code.

The primary Tachi maintainer (henceforth referred to as `zkrising`, because that's their name)
The primary Tachi maintainer (henceforth referred to as `zk`, because that's their name)
deals with the core of the codebase; things like importing scores, adding new features and most of the UI work
is handled by them.

Tachi actually doesn't really have a shortage of people who can write good code, and the core of the codebase
feature-wise is maintainable entirely by `zkrising` comfortably.
feature-wise is maintainable entirely by `zk` comfortably.

What **isn't** possible to maintain, is the sheer amount of things going on in every game! `zkrising`
What **isn't** possible to maintain, is the sheer amount of things going on in every game! `zk`
cannot reasonably keep track of all the games we support and everything that's going on in them.

That's where you step in - people who actually actively *play* games on Tachi! By letting `zkrising`
That's where you step in - people who actually actively *play* games on Tachi! By letting `zk`
know about things going on in your game - and even contributing things yourself - you help make their life easier
and Tachi's support for your favourite game even better!



## For Novices...

The Novice guides also cover things like how to get a proper code editing setup, how to use the terminal, and more.

You should be able to follow these *even if* you don't know the first thing about programming!

All of the novice guides are further down in this page.

## Sounds good.

Awesome! Start with the [Setup](./setup.md) guide. This will get Tachi running on your local PC, so you can test all your changes.
Loading

0 comments on commit 5233121

Please sign in to comment.