From 7430f730071b2381716b4e3ecd68f641f502f3de Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Fri, 29 Dec 2023 03:02:55 -0500 Subject: [PATCH 01/17] update README with `yarn` install instructions - it was inconsistent for Aidan, this should be better? --- .yarnrc.yml | 2 -- README.md | 9 +++++++++ omega-flowey.code-workspace | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) delete mode 100644 .yarnrc.yml diff --git a/.yarnrc.yml b/.yarnrc.yml deleted file mode 100644 index 4948c3a3d..000000000 --- a/.yarnrc.yml +++ /dev/null @@ -1,2 +0,0 @@ -defaultSemverRangePrefix: "" -yarnPath: .yarn/releases/yarn-3.6.3.cjs diff --git a/README.md b/README.md index df3ed8e4a..cc64b7732 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,15 @@ Since then I've gained a lot of skills both in Minecraft map development and in ### Setup +#### Workspace + + + +1. Install [`Node.js >= 16.10`](https://nodejs.org/en/download) +1. Install [`Yarn 3.6.3`](https://v3.yarnpkg.com/getting-started/install) by running `corepack enable` +1. Initialize the repo by running `yarn` +1. Enable Yarn's Plug'n'Play with VSCode by running `yarn dlx @yarnpkg/sdks vscode` + #### Testing 1. Download the [Fabric mod loader](https://fabricmc.net/) and install a new profile to your Minecraft launcher diff --git a/omega-flowey.code-workspace b/omega-flowey.code-workspace index 1b758810b..afb8284ac 100644 --- a/omega-flowey.code-workspace +++ b/omega-flowey.code-workspace @@ -42,6 +42,8 @@ "**/versions": true }, "search.exclude": { + "**/.yarn": true, + "**/.pnp.*": true, "./omega-flowey/data/math": true, "./minecraft/**": true, "./versions": true From af2313f29bd85aaca3ef769bede0df2527893b6f Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Fri, 29 Dec 2023 03:15:57 -0500 Subject: [PATCH 02/17] add `prettier` for JS/YAML/JSON formatting use `.editorconfig` for settings --- .editorconfig | 1 + .prettierignore | 3 +++ .vscode/extensions.json | 3 ++- omega-flowey.code-workspace | 4 ++++ package.json | 1 + yarn.lock | 10 ++++++++++ 6 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .prettierignore diff --git a/.editorconfig b/.editorconfig index 1ed453a37..bdbf7c50b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,3 +8,4 @@ insert_final_newline = true charset = utf-8 indent_style = space indent_size = 2 +quote_type = single diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..aa897f215 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# Ignore datapack/resourcepack +datapacks +resourcepack diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 008deafc0..9c9f1bc02 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,7 @@ { "recommendations": [ "minecraftcommands.syntax-mcfunction", - "spgoding.datapack-language-server" + "spgoding.datapack-language-server", + "esbenp.prettier-vscode" ] } diff --git a/omega-flowey.code-workspace b/omega-flowey.code-workspace index afb8284ac..4d4a1662e 100644 --- a/omega-flowey.code-workspace +++ b/omega-flowey.code-workspace @@ -36,6 +36,8 @@ }, "datapack.trace.server": "messages", + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, "editor.tabSize": 2, "files.exclude": { @@ -49,6 +51,8 @@ "./versions": true }, + "prettier.prettierPath": ".yarn/sdks/prettier/index.cjs", + "terminal.integrated.defaultLocation": "editor" } } diff --git a/package.json b/package.json index 5d17d3425..5ccda3f1c 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "cpy-cli": "5.0.0", "nps": "5.10.0", "nps-utils": "1.7.0", + "prettier": "3.1.1", "rimraf": "5.0.1", "watch": "1.0.2" } diff --git a/yarn.lock b/yarn.lock index dfc944a11..83386d1b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1623,6 +1623,7 @@ __metadata: cpy-cli: 5.0.0 nps: 5.10.0 nps-utils: 1.7.0 + prettier: 3.1.1 rimraf: 5.0.1 watch: 1.0.2 languageName: unknown @@ -1948,6 +1949,15 @@ __metadata: languageName: node linkType: hard +"prettier@npm:3.1.1": + version: 3.1.1 + resolution: "prettier@npm:3.1.1" + bin: + prettier: bin/prettier.cjs + checksum: e386855e3a1af86a748e16953f168be555ce66d6233f4ba54eb6449b88eb0c6b2ca79441b11eae6d28a7f9a5c96440ce50864b9d5f6356d331d39d6bb66c648e + languageName: node + linkType: hard + "process-nextick-args@npm:~2.0.0": version: 2.0.1 resolution: "process-nextick-args@npm:2.0.1" From 228bcc73ea413c7f35513ab5a0a6308f4eeaae49 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Fri, 29 Dec 2023 03:32:23 -0500 Subject: [PATCH 03/17] add TODO for dev agnostic minecraft assets path --- omega-flowey.code-workspace | 2 ++ 1 file changed, 2 insertions(+) diff --git a/omega-flowey.code-workspace b/omega-flowey.code-workspace index 4d4a1662e..d4a6b09e1 100644 --- a/omega-flowey.code-workspace +++ b/omega-flowey.code-workspace @@ -6,6 +6,8 @@ }, { "name": "minecraft", + // TODO: dev agnostic minecraft assets path? ideally through `.env`, but not possible until + // https://github.com/microsoft/vscode/issues/44755 is complete "path": "C:\\Users\\afro\\AppData\\Roaming\\.minecraft\\versions\\1.20.1\\1.20.1\\assets\\minecraft" } ], From ecc4f6bb6469d5d87f8c99806c2d795ef6db837e Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Fri, 29 Dec 2023 03:51:55 -0500 Subject: [PATCH 04/17] add prettier to github workflows - rename test workflow to `validate_datapack` - change test workflow to only run on commits on PRs and commits that are pushed to main --- .../{validate.yml => validate_datapack.yml} | 11 +++++++--- .github/workflows/validate_scripts.yml | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) rename .github/workflows/{validate.yml => validate_datapack.yml} (63%) create mode 100644 .github/workflows/validate_scripts.yml diff --git a/.github/workflows/validate.yml b/.github/workflows/validate_datapack.yml similarity index 63% rename from .github/workflows/validate.yml rename to .github/workflows/validate_datapack.yml index 2e39225f3..5225b47f6 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate_datapack.yml @@ -1,6 +1,10 @@ -name: validate +name: validate_datapack -on: [push, workflow_dispatch] +on: + pull_request: + push: + branches: + - main # TODO(37): add linting jobs: @@ -8,7 +12,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: CarbonSmasher/packtest_runner@86d606f25d2bd2faa08b017326fe99964ac3aa5c + - name: Run PackTest + uses: CarbonSmasher/packtest_runner@86d606f25d2bd2faa08b017326fe99964ac3aa5c with: packs: 'datapacks/omega-flowey' packtest-url: 'https://github.com/misode/packtest/releases/download/v1.0/packtest-1.0-mc1.20.4.jar' diff --git a/.github/workflows/validate_scripts.yml b/.github/workflows/validate_scripts.yml new file mode 100644 index 000000000..3ebf6d7da --- /dev/null +++ b/.github/workflows/validate_scripts.yml @@ -0,0 +1,20 @@ +name: validate_scripts + +on: + pull_request: + push: + branches: + - main + +jobs: + prettier: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Ensure code is prettified + uses: creyD/prettier_action@v4.3 + with: + dry: True + prettier_options: '--check .' + prettier_version: 3.1.1 From 542c18d7b7ce13bd1b54b4ce2c54b0ad94275bcd Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Fri, 29 Dec 2023 04:07:08 -0500 Subject: [PATCH 05/17] add prettier to nps scripts - run with `yarn lint` --- package-scripts.js | 5 +++++ package.json | 1 + 2 files changed, 6 insertions(+) diff --git a/package-scripts.js b/package-scripts.js index b5ebfda3b..8dde3dbcc 100644 --- a/package-scripts.js +++ b/package-scripts.js @@ -42,5 +42,10 @@ module.exports = { datapacks: `yarn rimraf --glob ${minecraftWorldPath}/datapacks/**/*`, resourcepacks: `yarn rimraf --glob ${minecraftResourcePackPath}/**/*`, }, + lint: { + default: 'nps lint.check', + check: 'prettier --check .', + fix: 'prettier --write .', + }, }, }; diff --git a/package.json b/package.json index 5ccda3f1c..41ad7ba9a 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "omega-flowey-minecraft-remastered", "packageManager": "yarn@3.6.3", "scripts": { + "lint": "nps lint", "start": "nps", "sync": "nps sync.world" }, From 10b448d2cc0ee6c8f8acd3db5bb21f586615b4f9 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Fri, 29 Dec 2023 04:18:37 -0500 Subject: [PATCH 06/17] prettify .md + .js files - just ran `yarn start lint.fix` --- package-scripts.js | 34 +++++++++++++++++----------------- pull_request_template.md | 11 +++++++++-- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/package-scripts.js b/package-scripts.js index 8dde3dbcc..30de136f9 100644 --- a/package-scripts.js +++ b/package-scripts.js @@ -1,37 +1,37 @@ -const { concurrent, series } = require("nps-utils"); +const { concurrent, series } = require('nps-utils'); -const minecraftPath = "C:/Users/afro/AppData/Roaming/.minecraft"; -const worldName = "omega-flowey-remastered"; -const resourcePackName = "omega-flowey-remastered-resourcepack"; +const minecraftPath = 'C:/Users/afro/AppData/Roaming/.minecraft'; +const worldName = 'omega-flowey-remastered'; +const resourcePackName = 'omega-flowey-remastered-resourcepack'; const minecraftWorldPath = `${minecraftPath}/saves/${worldName}`; const minecraftResourcePackPath = `${minecraftPath}/resourcepacks/${resourcePackName}`; module.exports = { scripts: { - default: concurrent.nps("watch.datapacks", "watch.resourcepack"), + default: concurrent.nps('watch.datapacks', 'watch.resourcepack'), watch: { datapacks: 'watch --wait=1 "nps sync.datapacks" datapacks', resourcepack: 'watch --wait=1 "nps sync.resourcepack" resourcepack', }, sync: { datapacks: series( - "echo syncing datapacks", - "nps delete.datapacks", - "nps copy.datapacks", - "echo finished datapacks", - "mpg123 -f -5000 -q ./temp/anyway.mp3 || echo mpg123 not found on your system -- cannot play notification sound" + 'echo syncing datapacks', + 'nps delete.datapacks', + 'nps copy.datapacks', + 'echo finished datapacks', + 'mpg123 -f -5000 -q ./temp/anyway.mp3 || echo mpg123 not found on your system -- cannot play notification sound', ), resourcepack: series( - "echo syncing resourcepack", - "nps delete.resourcepack", - "nps copy.resourcepack", - "echo finished resourcepack", - "mpg123 -f -5000 -q ./temp/fnaf.mp3 || echo mpg123 not found on your system -- cannot play notification sound" + 'echo syncing resourcepack', + 'nps delete.resourcepack', + 'nps copy.resourcepack', + 'echo finished resourcepack', + 'mpg123 -f -5000 -q ./temp/fnaf.mp3 || echo mpg123 not found on your system -- cannot play notification sound', ), world: series( - "rimraf world.zip", - `bestzip world.zip ${minecraftWorldPath}/*` + 'rimraf world.zip', + `bestzip world.zip ${minecraftWorldPath}/*`, ), }, copy: { diff --git a/pull_request_template.md b/pull_request_template.md index 4de7ebafe..7a9571805 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -1,4 +1,5 @@ # Summary + ## Reproducing in-game + ## Preview + + | in-game -- before | in-game -- after | undertale | -|-|-|-| -| | | | +| ----------------- | ---------------- | --------- | +| | | | + --- ## Supplemental changes +