mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Migrate the usage of CommonJS specific code and imports to ESM. Roughly summarised this: - Changes all require() calls to import statement or expressions. - Changes usage of module.exports to export statements. - Replaces require.resolve with import.meta.resolve. - Replaces conditional imports with conditional subpath imports. - Replaces module === require.main with import.meta.main. - Adds the full filename with extention to all relative imports. - Changes all usage of __dirname and __filename to their import.meta equivalents. - Sets "type": "module" in package.json files. - Removes usage of "use strict". - Adds .ts an an alias of .js for the webpack build. Due to differences in how require and import resolves files the plugin entrypoints will have to include the filename and extension after this migration in order to work.
Manual Tests
This folder contains files used for performing manual tests that are non-trivial to automate.
Setup test mod
Run node packages/lib/dist/node/build_mod.js --source-dir test/manual/test_mod/ --output-dir mods/ to create the test mod.
Test handling of bad setting values
-
Create a ModPack with missmatched values with
node test/manual/test_settings_mod_pack.jsand import it. -
Run a data export on an instance with the mod pack assigned, the values will get coerced to the correct types.
-
Use ctl to set the settings back to their wrong values:
SETTING_TYPES=(bool-setting int-setting double-setting string-setting color-setting) VALUE_TYPES=(bool int double string color missing) VALUES=( --bool-setting false --int-setting 1 --double-setting 0.5 --string-setting str --color-setting '{"r":0,"g":1,"b":0,"a":1}' --remove-setting ) node packages/ctl mod-pack edit test-settings $( for TYPE in "${SETTING_TYPES[@]}" ; do for (( I = 0; I < ${#VALUE_TYPES[@]}; I++ )); do printf "%s startup %s-with-%s-value %s " ${VALUES[((I * 2))]} $TYPE ${VALUE_TYPES[I]} ${VALUES[((I * 2 + 1))]} done done ) -
Verify that the Web UI gracefully handles all combinations of wrong settings types.