Skip to content

Commit

Permalink
remove loader script so it works on node 18 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
quisquous committed Dec 20, 2023
1 parent cfe8b77 commit a0679c9
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 34 deletions.
1 change: 0 additions & 1 deletion .mocharc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
'test/helper/*',
],
loader: [
// TODO: figure out how to do something like ./loader.js for mocha.
'ts-node/esm',
],
extension: [
Expand Down
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,9 @@ npm install -g typescript
```

Most commands have npm versions of them, e.g. `npm test` or `npm lint`
If you need to run a typescript file on its own, with Node v20 and later
you must pass an additional loader parameter.
Either of the following work for now:
You must pass a `--loader` parameter to make these scripts run.

```shell
node --import ./loader.js util/sync_files.ts
node --loader=ts-node/esm util/sync_files.ts
```

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ To install dependencies there are 2 methods: **per script** and **manually**
### Dependencies: Script Method

1. `curl` MUST be installed (this is used to download dependencies)
1. Execute `node --import ./loader.js util/fetch_deps.ts` script
1. Execute `node --loader=ts-node/esm util/fetch_deps.ts` script
1. Continue with **Steps to build**

### Dependencies: Manual Method
Expand Down
6 changes: 3 additions & 3 deletions docs/PatchUpdateChecklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ python util/gen_zone_id_and_info.py
python util/gen_weather_rate.py
python util/gen_hunt_data.py

node --import ./loader.js util/gen_effect_id.ts
node --import ./loader.js util/gen_world_ids.ts
node --import ./loader.js util/gen_pet_names.ts
node --loader=ts-node/esm util/gen_effect_id.ts
node --loader=ts-node/esm util/gen_world_ids.ts
node --loader=ts-node/esm util/gen_pet_names.ts
```

Here's an example: <https://github.com/quisquous/cactbot/pull/5823/files>
Expand Down
18 changes: 9 additions & 9 deletions docs/TimelineGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ For example, in this fight, these are the relevant log lines and times:
You can then make a timeline from those times by running the following command.

```bash
node --import ./loader.js util/logtools/make_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.934
node --loader=ts-node/esm util/logtools/make_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.934

0 "Start"
2.0 "Shield Skewer" sync /:Rhitahtyn sas Arvina:471:/
Expand Down Expand Up @@ -508,7 +508,7 @@ node --import ./loader.js util/logtools/make_timeline.ts -f CapeWestwind.log -s
(Note that you can also use the `-lf` parameter to list the encounters in the combat log.

```bash
node --import ./loader.js util/logtools/make_timeline.ts -f CapeWestwind.log -lf
node --loader=ts-node/esm util/logtools/make_timeline.ts -f CapeWestwind.log -lf

┌───────┬──────────────┬────────────────┬──────────┬─────────────────────────────────────────┬─────────────────────────────────────────┬───────────────┐
│ Index │ Start Date │ Start Time │ Duration │ Zone Name │ Encounter Name │ End Type │
Expand Down Expand Up @@ -543,14 +543,14 @@ Most of the time, you can't count on adds to have reliable
timing relative to the main boss, so it's usually better to
remove them.

The `node --import ./loader.js util/logtools/make_timeline.ts` script has two options to do this.
The `node --loader=ts-node/esm util/logtools/make_timeline.ts` script has two options to do this.
One is "ignore combatants" and the other is "ignore id".
Either `-ic "7Th Cohort Optio"` or `-ii 0A 2CD 2CE 194 14`
will remove all of these abilities.
We'll go with ids.

Run the command again with this ignore to have a cleaned up version:
`node --import ./loader.js util/logtools/make_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.934 -ii 0A 2CD 2CE 194 14`
`node --loader=ts-node/esm util/logtools/make_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.934 -ii 0A 2CD 2CE 194 14`

At this point, it may also be worth going through and finding other lines to add.
Usually, these are [added combatant](LogGuide.md#line-03-0x03-addcombatant) lines
Expand Down Expand Up @@ -681,7 +681,7 @@ let's adjust the first usage of `Shrapnel Shell`
so here we would write it as `-p 474:204.3`.

Here's the new command line we've built up to:
`node --import ./loader.js util/logtools/make_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.934 -ii 0A 2CD 2CE 194 14 -p 474:204.3`
`node --loader=ts-node/esm util/logtools/make_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.934 -ii 0A 2CD 2CE 194 14 -p 474:204.3`

This gets us the following output for phase 2,
with manually added blank lines to break out the loops.
Expand Down Expand Up @@ -881,7 +881,7 @@ Let's start phase 4 at 600 seconds, so we'll adjust the
first use of `Magitek Missile` (ability id 478) to be t=610.

Here's the final command line, including this second phase:
`node --import ./loader.js util/logtools/make_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.934 -ii 0A 2CD 2CE 194 14 -p 474:204.3 478:610`
`node --loader=ts-node/esm util/logtools/make_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.934 -ii 0A 2CD 2CE 194 14 -p 474:204.3 478:610`

```bash
# manually added in
Expand Down Expand Up @@ -1216,7 +1216,7 @@ in the **ui/raidboss/data/timelines** folder, minus the .txt extension.
(As with `make_timeline`, you can use the `-lf` parameter to list encounters.)

```bash
$ node --import ./loader.js util/logtools/test_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.934 -t cape_westwind
$ node --loader=ts-node/esm util/logtools/test_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.934 -t cape_westwind
0.000: Matched entry: 2.0 Shield Skewer (+2.000s)
10.556: Matched entry: 10.6 Shield Skewer (+0.044s)
18.985: Matched entry: 19.0 Shield Skewer (+0.015s)
Expand Down Expand Up @@ -1367,7 +1367,7 @@ The new time will be 595 - 10.7 = 584.3.
Rerunning the tester (most output omitted)

```bash
$ node --import ./loader.js util/logtools/test_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.
$ node --loader=ts-node/esm util/logtools/test_timeline.ts -f CapeWestwind.log -s 18:42:23.614 -e 18:49:22.
934 -t cape_westwind
431.400: Matched entry: 584.3 --sync-- (+152.900s)
Expand All @@ -1390,7 +1390,7 @@ but `Shrapnel Shell` is now in the right spot.
It's important to test against multiple fight instances to make sure that the timeline is good.
Here's an example of running against the **CapeWestwind2.log** file.

If you run `node --import ./loader.js util/logtools/test_timeline.ts -f CapeWestwind2.log -s 13:21:00.688 -e 13:29:36.976 -t cape_westwind` yourself, you can spot at least two problems.
If you run `node --loader=ts-node/esm util/logtools/test_timeline.ts -f CapeWestwind2.log -s 13:21:00.688 -e 13:29:36.976 -t cape_westwind` yourself, you can spot at least two problems.

One minor problem is that this boss is inconsistent:

Expand Down
2 changes: 1 addition & 1 deletion docs/ko-KR/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ cactbot은 테스트 UI를 기본으로 제공합니다.
### 의존성 설치: 스크립트 방식

1. `curl`이 반드시 설치되어 있어야 합니다. (의존성 파일들을 다운로드하기 위해 사용됩니다.)
1. `node --import ./loader.js ./util/fetch_deps.ts` 스크립트를 실행하세요.
1. `node --import node --loader=ts-node/esm ./util/fetch_deps.ts` 스크립트를 실행하세요.
1. **빌드하는 단계**로 이동하세요.

### 의존성 설치: 수동
Expand Down
2 changes: 1 addition & 1 deletion docs/zh-CN/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ cactbot 提供以下模块:
### 安装依赖:脚本方式

1. 必须先安装 `curl`(用于下载依赖项)
1. 运行 `node --import ./loader.js ./util/fetch_deps.ts` 脚本
1. 运行 `node --import node --loader=ts-node/esm ./util/fetch_deps.ts` 脚本
1. 下转 **构建步骤**

### 安装依赖:手动方式
Expand Down
5 changes: 0 additions & 5 deletions loader.js

This file was deleted.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"build": "webpack --progress --config webpack/webpack.prod.ts",
"build-gh-pages": " webpack --config webpack/webpack.ghpages.ts",
"start": "webpack serve --config webpack/webpack.dev.ts",
"fetch-deps": "node --import ./loader.js ./util/fetch_deps.ts",
"fetch-deps": "node --loader=ts-node/esm ./util/fetch_deps.ts",
"tsc-no-emit": "tsc --noEmit",
"lint": "run-s lint:**",
"lint:dprint": "dprint check",
Expand All @@ -31,17 +31,17 @@
"stylelintfix": "stylelint --fix \"resources/**/*.css\" \"ui/**/*.css\" \"user/**/*.css\" \"test/**/*.css\" \"util/**/*.css\"",
"markdownlint": "markdownlint . --ignore node_modules --ignore publish --ignore plugin/ThirdParty",
"test": "mocha",
"sync-files": "node --import ./loader.js util/sync_files.ts && git diff --exit-code",
"sync-files": "node --loader=ts-node/esm util/sync_files.ts && git diff --exit-code",
"lint-staged": "lint-staged",
"coverage-report": "node --import ./loader.js util/gen_coverage_report.ts",
"util": "node --import ./loader.js util/index.ts",
"coverage-report": "node --loader=ts-node/esm util/gen_coverage_report.ts",
"util": "node --loader=ts-node/esm util/index.ts",
"find-translations": "npm run util -- findTranslations",
"translate-timeline": "npm run util -- translateTimeline",
"generate": "npm run util -- generate",
"process-triggers": "node --import ./loader.js util/process_triggers_folder.ts",
"generate-log-guide": "node --import ./loader.js util/gen_log_guide.ts",
"validate-versions": "node --import ./loader.js util/validate_versions.ts",
"version": "node --import ./loader.js util/bump_version.ts"
"process-triggers": "node --loader=ts-node/esm util/process_triggers_folder.ts",
"generate-log-guide": "node --loader=ts-node/esm util/gen_log_guide.ts",
"validate-versions": "node --loader=ts-node/esm util/validate_versions.ts",
"version": "node --loader=ts-node/esm util/bump_version.ts"
},
"devDependencies": {
"@actions/exec": "^1.1.1",
Expand Down Expand Up @@ -145,7 +145,7 @@
"*.md": "markdownlint",
"*.py": "python -m pylint --errors-only",
"ui/(raidboss|oopsyraidsy)/data/**": [
"node --import ./loader.js test/test_data_files.ts"
"node --loader=ts-node/esm test/test_data_files.ts"
]
},
"dependencies": {
Expand Down

0 comments on commit a0679c9

Please sign in to comment.